openbsd-ports/multimedia/ffmpeg-php/patches/patch-ffmpeg-php_c
ajacoutot 1450b83078 Update ffmpeg-php for newer FFmpeg API.
from upstream via Brad
2012-05-01 06:19:12 +00:00

108 lines
3.7 KiB
Plaintext

$OpenBSD: patch-ffmpeg-php_c,v 1.3 2012/05/01 06:19:12 ajacoutot Exp $
--- ffmpeg-php.c.orig Mon Oct 13 15:00:08 2008
+++ ffmpeg-php.c Mon Apr 30 02:41:09 2012
@@ -51,8 +51,9 @@
#include "ext/standard/info.h"
#include "php_ffmpeg.h"
+#include "ffmpeg_errorhandler.h"
-#define FFMPEG_PHP_VERSION "0.6.0-svn"
+#define FFMPEG_PHP_VERSION "0.6.0+patches"
zend_module_entry ffmpeg_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
@@ -76,9 +77,10 @@ zend_module_entry ffmpeg_module_entry = {
ZEND_GET_MODULE(ffmpeg);
#endif
+#define FFMPEG_AVMEDIA_TYPE(flag) (flag == AVMEDIA_TYPE_VIDEO ? "v" : (flag == AVMEDIA_TYPE_AUDIO ? "a" : (flag == AVMEDIA_TYPE_SUBTITLE ? "s" : "u")))
+
extern void register_ffmpeg_movie_class(int);
extern void register_ffmpeg_frame_class(int);
-extern void ffmpeg_errorhandler(void *ptr, int level, const char *msg, va_list args);
PHP_INI_BEGIN()
PHP_INI_ENTRY("ffmpeg.allow_persistent", "0", PHP_INI_ALL, NULL)
@@ -90,9 +92,6 @@ PHP_INI_END()
*/
PHP_MINIT_FUNCTION(ffmpeg)
{
- /* must be called before using avcodec libraries. */
- avcodec_init();
-
/* register all codecs */
av_register_all();
@@ -100,7 +99,9 @@ PHP_MINIT_FUNCTION(ffmpeg)
if (INI_BOOL("ffmpeg.show_warnings")) {
av_log_set_callback(ffmpeg_errorhandler);
- }
+ } else {
+ av_log_set_callback(ffmpeg_hide_errors);
+ }
register_ffmpeg_movie_class(module_number);
register_ffmpeg_frame_class(module_number);
@@ -119,6 +120,12 @@ PHP_MINIT_FUNCTION(ffmpeg)
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;
}
/* }}} */
@@ -138,7 +145,7 @@ PHP_MSHUTDOWN_FUNCTION(ffmpeg)
/* {{{ php info function
- Add an entry for ffmpeg support in phpinfo() */
+ Add an entry for ffmpeg-php support in phpinfo() */
PHP_MINFO_FUNCTION(ffmpeg)
{
php_info_print_table_start();
@@ -157,6 +164,37 @@ PHP_MINFO_FUNCTION(ffmpeg)
#else
php_info_print_table_row(2, "ffmpeg swscaler", "disabled");
#endif
+
+ //phpinfo should show the codec list available to aid developers
+ AVCodec *next_codec = NULL;
+ char *m_codec_list = NULL;
+ long m_codec_list_len = 0;
+ long m_codec_len = 0;
+ while((next_codec = av_codec_next(next_codec))) {
+ //go through each codec and add to the list
+ m_codec_len = (strlen(next_codec->name) + 5);
+ m_codec_list_len += m_codec_len;
+ m_codec_list = realloc(m_codec_list, m_codec_list_len);
+
+ //wtf? always gives buffer overflows...
+ //sprintf(m_codec_list+(m_codec_list_len-m_codec_len), "%s(%c), ", next_codec->name, FFMPEG_AVMEDIA_TYPE(next_codec->type));
+
+ //doing it the long way instead
+ memcpy(m_codec_list+(m_codec_list_len-m_codec_len), next_codec->name, m_codec_len);
+ memcpy(m_codec_list+(m_codec_list_len-5), "(", 1);
+ memcpy(m_codec_list+(m_codec_list_len-4), FFMPEG_AVMEDIA_TYPE(next_codec->type), 1);
+ memcpy(m_codec_list+(m_codec_list_len-3), ")", 1);
+ memcpy(m_codec_list+(m_codec_list_len-2), ", ", 2);
+ }
+
+ m_codec_list = realloc(m_codec_list, m_codec_list_len+1);
+ m_codec_list[m_codec_list_len] = (char)NULL;
+
+ //give the user a list of available codecs
+ //should really add (dec/enc) on the end of each to show each is capable of
+ //consider giving each codec its own row in in a codec table displaying if the codec is cable of a/v/s and enc/dec
+ php_info_print_table_row(2, "ffmpeg codec_list", m_codec_list);
+
php_info_print_table_end();
DISPLAY_INI_ENTRIES();