-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathffmpeg-php.c
195 lines (156 loc) · 5.44 KB
/
ffmpeg-php.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
This file is part of ffmpeg-php
Copyright (C) 2004-2008 Todd Kirby (ffmpeg.php AT gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
In addition, as a special exception, the copyright holders of ffmpeg-php
give you permission to combine ffmpeg-php with code included in the
standard release of PHP under the PHP license (or modified versions of
such code, with unchanged license). You may copy and distribute such a
system following the terms of the GNU GPL for ffmpeg-php and the licenses
of the other code concerned, provided that you include the source code of
that other code when and as the GNU GPL requires distribution of source code.
You must obey the GNU General Public License in all respects for all of the
code used other than standard release of PHP. If you modify this file, you
may extend this exception to your version of the file, but you are not
obligated to do so. If you do not wish to do so, delete this exception
statement from your version.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include <avcodec.h>
#include <avformat.h>
#if HAVE_SWSCALER
#include <swscale.h>
#endif
#include "php_ini.h"
#include "php_globals.h"
#include "ext/standard/info.h"
#include "php_ffmpeg.h"
#include "ffmpeg_errorhandler.h"
#define FFMPEG_PHP_VERSION "3.2.18"
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO(arginfo_ffmpeg_movie_list, 0)
ZEND_END_ARG_INFO()
/* }}} */
/* }}} */
/* {{{ ffmpeg_functions[]
*/
const zend_function_entry ffmpeg_functions[] = {
PHP_FE(ffmpeg_movie_list, arginfo_ffmpeg_movie_list)
PHP_FE_END
};
/* }}} */
zend_module_entry ffmpeg_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"ffmpeg",
ffmpeg_functions,
PHP_MINIT(ffmpeg),
PHP_MSHUTDOWN(ffmpeg),
NULL,
NULL,
PHP_MINFO(ffmpeg),
#if ZEND_MODULE_API_NO >= 20010901
FFMPEG_PHP_VERSION,
#endif
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_FFMPEG
ZEND_GET_MODULE(ffmpeg);
#endif
extern void register_ffmpeg_movie_class(int);
extern void register_ffmpeg_frame_class(int);
PHP_INI_BEGIN()
PHP_INI_ENTRY("ffmpeg.allow_persistent", "0", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("ffmpeg.show_warnings", "0", PHP_INI_ALL, NULL)
PHP_INI_END()
/* {{{ php module init function
*/
PHP_MINIT_FUNCTION(ffmpeg)
{
/* register all codecs */
av_register_all();
REGISTER_INI_ENTRIES();
if (INI_BOOL("ffmpeg.show_warnings")) {
av_log_set_callback(ffmpeg_errorhandler);
} else {
av_log_set_callback(ffmpeg_hide_errors);
}
avformat_network_init();
register_ffmpeg_movie_class(module_number);
register_ffmpeg_frame_class(module_number);
REGISTER_STRING_CONSTANT("FFMPEG_PHP_VERSION_STRING",
FFMPEG_PHP_VERSION, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("FFMPEG_PHP_BUILD_DATE_STRING",
__DATE__ " " __TIME__, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("LIBAVCODEC_VERSION_NUMBER",
avcodec_version(), CONST_CS | CONST_PERSISTENT);
#ifdef LIBAVCODEC_BUILD
REGISTER_LONG_CONSTANT("LIBAVCODEC_BUILD_NUMBER",
LIBAVCODEC_BUILD, CONST_CS | CONST_PERSISTENT);
#else
REGISTER_LONG_CONSTANT("LIBAVCODEC_BUILD_NUMBER",
avcodec_build(), CONST_CS | CONST_PERSISTENT);
#endif
#if HAVE_LIBGD20
REGISTER_LONG_CONSTANT("FFMPEG_PHP_GD_ENABLED", 1, CONST_CS | CONST_PERSISTENT);
#else
REGISTER_LONG_CONSTANT("FFMPEG_PHP_GD_ENABLED", 0, CONST_CS | CONST_PERSISTENT);
#endif // HAVE_LIBGD20
return SUCCESS;
}
/* }}} */
/* {{{ php module shutdown function
*/
PHP_MSHUTDOWN_FUNCTION(ffmpeg)
{
avformat_network_deinit();
// TODO: Free any remaining persistent movies here?
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
/* }}} */
/* {{{ php info function
Add an entry for ffmpeg-php support in phpinfo() */
PHP_MINFO_FUNCTION(ffmpeg)
{
php_info_print_table_start();
// php_info_print_table_header(2, "ffmpeg-php", "enabled");
php_info_print_table_row(2, "ffmpeg-php version", FFMPEG_PHP_VERSION);
php_info_print_table_row(2, "ffmpeg-php built on", __DATE__ " " __TIME__);
#if HAVE_LIBGD20
php_info_print_table_row(2, "ffmpeg-php gd support ", "enabled");
#else
php_info_print_table_row(2, "ffmpeg-php gd support ", "disabled");
#endif // HAVE_LIBGD20
php_info_print_table_row(2, "ffmpeg libavcodec version", LIBAVCODEC_IDENT);
php_info_print_table_row(2, "ffmpeg libavformat version", LIBAVFORMAT_IDENT);
#if HAVE_SWSCALER
php_info_print_table_row(2, "ffmpeg swscaler version", LIBSWSCALE_IDENT);
#else
php_info_print_table_row(2, "ffmpeg swscaler", "disabled");
#endif
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4
* vim<600: noet sw=4 ts=4
*/