]> git.pld-linux.org Git - packages/FusionSound.git/blob - FusionSound-ffmpeg.patch
73ce7fd2b9937dd28cc61b5f069397a335fa1b5f
[packages/FusionSound.git] / FusionSound-ffmpeg.patch
1 --- fs/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c.orig     2011-06-15 20:01:31.000000000 +0200
2 +++ fs/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c  2011-06-15 20:01:45.000000000 +0200
3 @@ -64,7 +64,7 @@
4  
5       DirectStream                 *stream;
6  
7 -     ByteIOContext                 pb;
8 +     AVIOContext                   pb;
9       AVFormatContext              *ctx;
10       AVStream                     *st;
11       void                         *iobuf;
12 --- FusionSound-1.1.1.org/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c       2011-09-11 20:21:02.521648411 +0200
13 +++ FusionSound-1.1.1/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c   2011-09-11 20:20:22.216456936 +0200
14 @@ -41,6 +41,7 @@
15  
16  #include <misc/sound_util.h>
17  
18 +#define FF_API_OLD_METADATA2 0
19  #include <libavcodec/avcodec.h>
20  #include <libavformat/avformat.h>
21  
22 @@ -476,17 +477,37 @@
23  IFusionSoundMusicProvider_FFmpeg_GetTrackDescription( IFusionSoundMusicProvider *thiz,
24                                                        FSTrackDescription        *desc )
25  {
26 +     AVDictionaryEntry *tag = NULL;
27 +
28       DIRECT_INTERFACE_GET_DATA( IFusionSoundMusicProvider_FFmpeg )
29 -     
30 +
31       if (!desc)
32            return DR_INVARG;
33  
34 -     direct_snputs( desc->artist, data->ctx->author, FS_TRACK_DESC_ARTIST_LENGTH );
35 -     direct_snputs( desc->title, data->ctx->title, FS_TRACK_DESC_TITLE_LENGTH );
36 -     direct_snputs( desc->album, data->ctx->album, FS_TRACK_DESC_ALBUM_LENGTH );
37 -     direct_snputs( desc->genre, data->ctx->genre, FS_TRACK_DESC_GENRE_LENGTH );
38 -     direct_snputs( desc->encoding, data->codec->codec->name, FS_TRACK_DESC_ENCODING_LENGTH );
39 -     desc->year = data->ctx->year;
40 +     tag = av_dict_get(data->ctx->metadata, "artist", NULL, 0);
41 +     if (tag)
42 +       direct_snputs( desc->artist, tag->value, FS_TRACK_DESC_ARTIST_LENGTH );
43 +
44 +     tag = av_dict_get(data->ctx->metadata, "title", NULL, 0);
45 +     if (tag)
46 +       direct_snputs( desc->title, tag->value, FS_TRACK_DESC_TITLE_LENGTH );
47 +
48 +     tag = av_dict_get(data->ctx->metadata, "album", NULL, 0);
49 +     if (tag)
50 +       direct_snputs( desc->album, tag->value, FS_TRACK_DESC_ALBUM_LENGTH );
51 +
52 +     tag = av_dict_get(data->ctx->metadata, "genre", NULL, 0);
53 +     if (tag)
54 +       direct_snputs( desc->genre, tag->value, FS_TRACK_DESC_GENRE_LENGTH );
55 +
56 +     tag = av_dict_get(data->ctx->metadata, "encoding", NULL, 0);
57 +     if (tag)
58 +       direct_snputs( desc->encoding, tag->value, FS_TRACK_DESC_ENCODING_LENGTH );
59 +
60 +     tag = av_dict_get(data->ctx->metadata, "year", NULL, 0);
61 +     if (tag)
62 +       desc->year = atoi(tag->value);
63 +
64       desc->bitrate = data->codec->bit_rate;
65       desc->replaygain = desc->replaygain_album = 0;
66       
67 @@ -595,8 +616,8 @@
68            }
69            
70            len = AVCODEC_MAX_AUDIO_FRAME_SIZE;
71 -          decoded = avcodec_decode_audio2( data->codec, 
72 -                                          (s16*)data->buf, &len, pkt_data, pkt_size );
73 +          decoded = avcodec_decode_audio3( data->codec, 
74 +                                          (s16*)data->buf, &len, &pkt );
75            if (decoded < 0) {
76                 av_free_packet( &pkt );
77                 pkt_size = 0;
78 @@ -800,8 +821,8 @@
79            }
80            
81            len = AVCODEC_MAX_AUDIO_FRAME_SIZE;
82 -          decoded = avcodec_decode_audio2( data->codec,
83 -                                          (s16*)data->buf, &len, pkt_data, pkt_size );
84 +          decoded = avcodec_decode_audio3( data->codec,
85 +                                          (s16*)data->buf, &len, &pkt );
86            if (decoded < 0) {
87                 av_free_packet( &pkt );
88                 pkt_size = 0;
89 @@ -1208,7 +1229,7 @@
90       }
91       
92       for (i = 0; i < data->ctx->nb_streams; i++) {
93 -          if (data->ctx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
94 +          if (data->ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
95                 if (!data->st || data->st->codec->bit_rate < data->ctx->streams[i]->codec->bit_rate)
96                      data->st = data->ctx->streams[i];
97            }
98 --- FusionSound-1.6.0/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c.orig      2012-06-19 21:43:14.057077681 +0200
99 +++ FusionSound-1.6.0/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c   2012-06-22 17:46:15.046796804 +0200
100 @@ -1208,16 +1208,17 @@
101            return D_OOM();
102       }
103       
104 -     if (init_put_byte( &data->pb, data->iobuf, 4096, 0, 
105 +     if (ffio_init_context( &data->pb, data->iobuf, 4096, 0, 
106                          (void*)data, av_read_callback, NULL,
107                          direct_stream_seekable( stream ) ? av_seek_callback : NULL ) < 0) {
108 -          D_ERROR( "IFusionSoundMusicProvider_FFmpeg: init_put_byte() failed!\n" );
109 +          D_ERROR( "IFusionSoundMusicProvider_FFmpeg: ffio_init_context() failed!\n" );
110            IFusionSoundMusicProvider_FFmpeg_Destruct( thiz );
111            return DR_INIT;
112       }
113       
114 -     if (av_open_input_stream( &data->ctx, &data->pb, filename, fmt, NULL ) < 0) {
115 -          D_ERROR( "IFusionSoundMusicProvider_FFmpeg: av_open_input_stream() failed!\n" );
116 +     data->ctx->pb = &data->pb;
117 +     if (avformat_open_input( &data->ctx, filename, fmt, NULL ) < 0) {
118 +          D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avformat_open_input() failed!\n" );
119            IFusionSoundMusicProvider_FFmpeg_Destruct( thiz );
120            return DR_FAILURE;
121       }
122 --- FusionSound-1.6.0/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c.orig      2012-06-22 19:05:38.449930237 +0200
123 +++ FusionSound-1.6.0/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c   2012-06-22 20:12:51.699760976 +0200
124 @@ -65,7 +65,7 @@
125  
126       DirectStream                 *stream;
127  
128 -     AVIOContext                   pb;
129 +     AVIOContext                  *pb;
130       AVFormatContext              *ctx;
131       AVStream                     *st;
132       void                         *iobuf;
133 @@ -424,6 +424,9 @@
134            }
135       }
136       
137 +     if (data->pb)
138 +         av_free( data->pb);
139 +
140       if (data->iobuf)
141            D_FREE( data->iobuf );
142  
143 @@ -1208,15 +1211,24 @@
144            return D_OOM();
145       }
146       
147 -     if (ffio_init_context( &data->pb, data->iobuf, 4096, 0, 
148 +     if ((data->pb = avio_alloc_context( data->iobuf, 4096, 0, 
149                          (void*)data, av_read_callback, NULL,
150 -                        direct_stream_seekable( stream ) ? av_seek_callback : NULL ) < 0) {
151 -          D_ERROR( "IFusionSoundMusicProvider_FFmpeg: ffio_init_context() failed!\n" );
152 +                        direct_stream_seekable( stream ) ? av_seek_callback : NULL )) == NULL) {
153 +          D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avio_alloc_context() failed!\n" );
154            IFusionSoundMusicProvider_FFmpeg_Destruct( thiz );
155            return DR_INIT;
156       }
157 -     
158 -     data->ctx->pb = &data->pb;
159 +
160 +     if(data->ctx == NULL) {
161 +         data->ctx = avformat_alloc_context();
162 +         if (data->ctx == NULL) {
163 +               D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avformat_alloc_context() failed!\n" );
164 +               IFusionSoundMusicProvider_FFmpeg_Destruct( thiz );
165 +               return DR_FAILURE;
166 +         }
167 +     }
168 +
169 +     data->ctx->pb = data->pb;
170       if (avformat_open_input( &data->ctx, filename, fmt, NULL ) < 0) {
171            D_ERROR( "IFusionSoundMusicProvider_FFmpeg: avformat_open_input() failed!\n" );
172            IFusionSoundMusicProvider_FFmpeg_Destruct( thiz );
This page took 0.053381 seconds and 2 git commands to generate.