summaryrefslogtreecommitdiff
blob: 480819d9987dd5c3bc32604c2117f617119fc677 (plain)
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
Description: Improve detection of av_register_protocol() for ffmpeg.
Author: Angel Carpintero <motiondevelop@gmail.com>
Origin: Upstream, https://github.com/sackmotion/motion/commit/7aec4b#svn538
Last-Update: 2012-02-12

--- a/configure.in
+++ b/configure.in
@@ -316,7 +316,7 @@
 #
 else if test "${FFMPEG_DIR}" = "yes"; then
 	# AUTODETECT STATIC/SHARED LIB 
-	AC_MSG_CHECKING(for ffmpeg autodetecting)
+	AC_MSG_CHECKING(for ffmpeg autodetecting libraries)
 
 	if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then
 		AC_MSG_RESULT(found in /usr/lib64)
@@ -347,7 +347,7 @@
 		echo ""		
 	fi 
 else
-	AC_MSG_CHECKING(for ffmpeg in -> [${FFMPEG_DIR}] <-)
+	AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-)
 	if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then
 		AC_MSG_RESULT(found)
 		FFMPEG_OK="found"
@@ -392,9 +392,11 @@
 	elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then
 		AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h)
 		FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES"
+		AVFORMAT="-I${FFMPEG_DIR}/include/libavformat"
     elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then
         AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h)
         FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES" 
+	AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat"
 	else
 		AC_MSG_RESULT(not found)
 		FFMPEG_OK="no_found"
@@ -423,9 +425,11 @@
 		AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?])
 		saved_CFLAGS=$CFLAGS
 		saved_LIBS=$LIBS
-		CFLAGS="${FFMPEG_CFLAGS}"
+
+
+		CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}"
 		LIBS="$TEMP_LIBS"
-		
+    	
 		AC_COMPILE_IFELSE(
 			[
 			#include <avformat.h>
@@ -442,7 +446,35 @@
 			]
 		)
 		CFLAGS=$saved_CFLAGS
-		LIBS=$saved_LIBS	
+		LIBS=$saved_LIBS
+       
+        AC_MSG_CHECKING([av_register_protocol is defined in ffmpeg ?]) 
+        saved_CFLAGS=$CFLAGS
+        saved_LIBS=$LIBS
+        CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}"
+        LIBS="$TEMP_LIBS"
+       
+        AC_COMPILE_IFELSE(
+            [
+            #include <avformat.h>
+            URLProtocol test_file_protocol;
+            int main(void){
+                av_register_protocol(&test_file_protocol);
+        	    return 0;
+            }
+            ],
+            [
+                AC_MSG_RESULT(yes)
+                TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_AV_REGISTER_PROTOCOL"
+            ],
+            [
+                AC_MSG_RESULT(no)
+            ]
+        )
+
+        CFLAGS=$saved_CFLAGS
+        LIBS=$saved_LIBS
+                                        
 	fi
 fi	
 fi
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -232,11 +232,11 @@
     mpeg1_file_protocol.url_seek  = file_protocol.url_seek;
     mpeg1_file_protocol.url_close = file_protocol.url_close;
 
-    /* Register the append file protocol. */
-#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8)
+/* Register the append file protocol. */
+#ifdef HAVE_FFMPEG_AV_REGISTER_PROTOCOL
     av_register_protocol(&mpeg1_file_protocol);
 #else
-    register_protocol(&mpeg1_file_protocol);
+    av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol));
 #endif
 }
 
@@ -410,7 +410,11 @@
 
     ffmpeg->c     = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st);
     c->codec_id   = ffmpeg->oc->oformat->video_codec;
+#if LIBAVCODEC_VERSION_MAJOR < 53    
     c->codec_type = CODEC_TYPE_VIDEO;
+#else
+    c->codec_type = AVMEDIA_TYPE_VIDEO;
+#endif    
     is_mpeg1      = c->codec_id == CODEC_ID_MPEG1VIDEO;
 
     if (strcmp(ffmpeg_video_codec, "ffv1") == 0)
@@ -679,7 +683,11 @@
     if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) {
         /* raw video case. The API will change slightly in the near future for that */
 #ifdef FFMPEG_AVWRITEFRAME_NEWAPI
+#if LIBAVCODEC_VERSION_MAJOR < 53        
         pkt.flags |= PKT_FLAG_KEY;
+#else
+        pkt.flags |= AV_PKT_FLAG_KEY;  
+#endif        
         pkt.data = (uint8_t *)pic;
         pkt.size = sizeof(AVPicture);
         ret = av_write_frame(ffmpeg->oc, &pkt);
@@ -700,7 +708,11 @@
 #ifdef FFMPEG_AVWRITEFRAME_NEWAPI
             pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts;
             if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) {
+#if LIBAVCODEC_VERSION_MAJOR < 53                
                 pkt.flags |= PKT_FLAG_KEY;
+#else
+                pkt.flags |= AV_PKT_FLAG_KEY;
+#endif                
             }
             pkt.data = ffmpeg->video_outbuf;
             pkt.size = out_size;