]>
Commit | Line | Data |
---|---|---|
1 | --- DirectFB-1.7.0/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c.orig 2013-01-12 06:06:23.000000000 +0100 | |
2 | +++ DirectFB-1.7.0/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c 2013-07-19 17:15:41.004724901 +0200 | |
3 | @@ -55,6 +55,9 @@ | |
4 | ||
5 | #include <libavutil/avutil.h> | |
6 | ||
7 | +#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE | |
8 | +# define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 | |
9 | +#endif | |
10 | ||
11 | static DirectResult | |
12 | Probe( IFusionSoundMusicProvider_ProbeContext *ctx ); | |
13 | @@ -79,7 +82,7 @@ | |
14 | DirectStream *stream; | |
15 | ||
16 | #if (LIBAVFORMAT_VERSION_MAJOR >= 53) | |
17 | - AVIOContext pb; | |
18 | + AVIOContext *pb; | |
19 | #else | |
20 | ByteIOContext pb; | |
21 | #endif | |
22 | @@ -412,6 +415,11 @@ | |
23 | data->dest.buffer = NULL; | |
24 | } | |
25 | ||
26 | + if (data->pb) { | |
27 | + av_free( data->pb ); | |
28 | + data->pb = NULL; | |
29 | + } | |
30 | + | |
31 | /* release output buffer */ | |
32 | if (data->buf) { | |
33 | D_FREE( data->buf ); | |
34 | @@ -1279,16 +1287,26 @@ | |
35 | return D_OOM(); | |
36 | } | |
37 | ||
38 | - if (init_put_byte( &data->pb, data->iobuf, 4096, 0, | |
39 | + if ((data->pb = avio_alloc_context( data->iobuf, 4096, 0, | |
40 | (void*)data, av_read_callback, NULL, | |
41 | - direct_stream_seekable( stream ) ? av_seek_callback : NULL ) < 0) { | |
42 | - D_ERROR( "IFusionSoundMusicProvider_FFmpeg: init_put_byte() failed!\n" ); | |
43 | + direct_stream_seekable( stream ) ? av_seek_callback : NULL )) == NULL) { | |
44 | + D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avio_alloc_context() failed!\n" ); | |
45 | IFusionSoundMusicProvider_FFmpeg_Destruct( thiz ); | |
46 | return DR_INIT; | |
47 | } | |
48 | ||
49 | - if (av_open_input_stream( &data->ctx, &data->pb, filename, fmt, NULL ) < 0) { | |
50 | - D_ERROR( "IFusionSoundMusicProvider_FFmpeg: av_open_input_stream() failed!\n" ); | |
51 | + if(data->ctx == NULL) { | |
52 | + data->ctx = avformat_alloc_context(); | |
53 | + if (data->ctx == NULL) { | |
54 | + D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avformat_alloc_context() failed!\n" ); | |
55 | + IFusionSoundMusicProvider_FFmpeg_Destruct( thiz ); | |
56 | + return DR_FAILURE; | |
57 | + } | |
58 | + } | |
59 | + | |
60 | + data->ctx->pb = data->pb; | |
61 | + if (avformat_open_input( &data->ctx, filename, fmt, NULL ) < 0) { | |
62 | + D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avformat_open_input() failed!\n" ); | |
63 | IFusionSoundMusicProvider_FFmpeg_Destruct( thiz ); | |
64 | return DR_FAILURE; | |
65 | } | |
66 | @@ -1318,7 +1336,7 @@ | |
67 | ||
68 | data->codec = data->st->codec; | |
69 | c = avcodec_find_decoder( data->codec->codec_id ); | |
70 | - if (!c || avcodec_open( data->codec, c ) < 0) { | |
71 | + if (!c || avcodec_open2( data->codec, c, NULL ) < 0) { | |
72 | D_ERROR( "IFusionSoundMusicProvider_FFmpeg: couldn't find audio decoder!\n" ); | |
73 | IFusionSoundMusicProvider_FFmpeg_Destruct( thiz ); | |
74 | return DR_FAILURE; | |
75 | --- DirectFB-1.7.0/interfaces/IDirectFBVideoProvider/idirectfbvideoprovider_ffmpeg.c.orig 2013-01-12 06:06:23.000000000 +0100 | |
76 | +++ DirectFB-1.7.0/interfaces/IDirectFBVideoProvider/idirectfbvideoprovider_ffmpeg.c 2013-07-19 16:38:03.281486315 +0200 | |
77 | @@ -128,7 +128,7 @@ | |
78 | bool seekable; | |
79 | void *iobuf; | |
80 | #if (LIBAVFORMAT_VERSION_MAJOR >= 53) | |
81 | - AVIOContext pb; | |
82 | + AVIOContext *pb; | |
83 | #else | |
84 | ByteIOContext pb; | |
85 | #endif | |
86 | @@ -479,7 +479,7 @@ | |
87 | { | |
88 | IDirectFBVideoProvider_FFmpeg_data *data = arg; | |
89 | ||
90 | - if (url_is_streamed( data->context->pb )) { | |
91 | + if (!data->context->pb->seekable) { | |
92 | data->input.buffering = true; | |
93 | pthread_mutex_lock( &data->video.queue.lock ); | |
94 | pthread_mutex_lock( &data->audio.queue.lock ); | |
95 | @@ -506,7 +506,7 @@ | |
96 | flush_packets( &data->audio.queue ); | |
97 | ||
98 | if (!data->input.buffering && | |
99 | - url_is_streamed( data->context->pb )) { | |
100 | + !data->context->pb->seekable) { | |
101 | data->input.buffering = true; | |
102 | pthread_mutex_lock( &data->video.queue.lock ); | |
103 | pthread_mutex_lock( &data->audio.queue.lock ); | |
104 | @@ -541,7 +541,7 @@ | |
105 | else if (data->video.queue.size == 0 || | |
106 | data->audio.queue.size == 0) { | |
107 | if (!data->input.buffering && | |
108 | - url_is_streamed( data->context->pb )) { | |
109 | + !data->context->pb->seekable) { | |
110 | data->input.buffering = true; | |
111 | pthread_mutex_lock( &data->video.queue.lock ); | |
112 | pthread_mutex_lock( &data->audio.queue.lock ); | |
113 | @@ -798,14 +798,14 @@ | |
114 | IDirectFBVideoProvider_FFmpeg_data *data = arg; | |
115 | ||
116 | AVStream *st = data->audio.st; | |
117 | - u8 buf[AVCODEC_MAX_AUDIO_FRAME_SIZE]; | |
118 | + u8 buf[192000 /* AVCODEC_MAX_AUDIO_FRAME_SIZE */]; | |
119 | ||
120 | while (data->status != DVSTATE_STOP) { | |
121 | AVPacket pkt; | |
122 | u8 *pkt_data; | |
123 | int pkt_size; | |
124 | int decoded = 0; | |
125 | - int len = AVCODEC_MAX_AUDIO_FRAME_SIZE; | |
126 | + int len = 192000 /* AVCODEC_MAX_AUDIO_FRAME_SIZE */; | |
127 | int size = 0; | |
128 | ||
129 | direct_thread_testcancel( self ); | |
130 | @@ -939,6 +939,11 @@ | |
131 | } | |
132 | } | |
133 | ||
134 | + if (data->pb) { | |
135 | + av_free( data->pb ); | |
136 | + data->pb = NULL; | |
137 | + } | |
138 | + | |
139 | if (data->buffer) | |
140 | data->buffer->Release( data->buffer ); | |
141 | ||
142 | @@ -1778,23 +1783,32 @@ | |
143 | return D_OOM(); | |
144 | } | |
145 | ||
146 | - if (init_put_byte( &data->pb, data->iobuf, IO_BUFFER_SIZE * 1024, 0, | |
147 | + if ((data->pb = avio_alloc_context( data->iobuf, IO_BUFFER_SIZE * 1024, 0, | |
148 | (void*)data, av_read_callback, NULL, | |
149 | - data->seekable ? av_seek_callback : NULL ) < 0) { | |
150 | + data->seekable ? av_seek_callback : NULL )) == NULL) { | |
151 | D_ERROR( "IDirectFBVideoProvider_FFmpeg: " | |
152 | - "init_put_byte() failed!\n" ); | |
153 | + "avio_alloc_context() failed!\n" ); | |
154 | IDirectFBVideoProvider_FFmpeg_Destruct( thiz ); | |
155 | return DFB_INIT; | |
156 | } | |
157 | ||
158 | - data->pb.is_streamed = (!data->seekable || | |
159 | + data->pb->seekable = !(!data->seekable || | |
160 | !strncmp( pd.filename, "http://", 7 ) || | |
161 | !strncmp( pd.filename, "unsv://", 7 ) || | |
162 | !strncmp( pd.filename, "ftp://", 6 ) || | |
163 | !strncmp( pd.filename, "rtsp://", 7 )); | |
164 | ||
165 | - if (av_open_input_stream( &data->context, | |
166 | - &data->pb, pd.filename, fmt, NULL ) < 0) { | |
167 | + if (data->context == NULL) { | |
168 | + if ((data->ctx = avformat_alloc_context()) == NULL) { | |
169 | + D_ERROR( "IDirectFBVideoProvider_FFmpeg: avformat_alloc_context() failed!\n" ); | |
170 | + IDirectFBVideoProvider_FFmpeg_Destruct( thiz ); | |
171 | + return DFB_FAILURE; | |
172 | + } | |
173 | + } | |
174 | + | |
175 | + data->context->pb = data->pb; | |
176 | + if (avformat_open_input( &data->context, | |
177 | + pd.filename, fmt, NULL ) < 0) { | |
178 | D_ERROR( "IDirectFBVideoProvider_FFmpeg: " | |
179 | "av_open_input_stream() failed!\n" ); | |
180 | IDirectFBVideoProvider_FFmpeg_Destruct( thiz ); | |
181 | @@ -1845,7 +1859,7 @@ | |
182 | data->video.ctx = data->video.st->codec; | |
183 | data->video.codec = avcodec_find_decoder( data->video.ctx->codec_id ); | |
184 | if (!data->video.codec || | |
185 | - avcodec_open( data->video.ctx, data->video.codec ) < 0) | |
186 | + avcodec_open2( data->video.ctx, data->video.codec, NULL ) < 0) | |
187 | { | |
188 | D_ERROR( "IDirectFBVideoProvider_FFmpeg: " | |
189 | "error opening video codec!\n" ); | |
190 | @@ -1870,7 +1884,7 @@ | |
191 | data->audio.ctx = data->audio.st->codec; | |
192 | data->audio.codec = avcodec_find_decoder( data->audio.ctx->codec_id ); | |
193 | if (!data->audio.codec || | |
194 | - avcodec_open( data->audio.ctx, data->audio.codec ) < 0) { | |
195 | + avcodec_open2( data->audio.ctx, data->audio.codec, NULL ) < 0) { | |
196 | data->audio.st = NULL; | |
197 | data->audio.ctx = NULL; | |
198 | data->audio.codec = NULL; |