summaryrefslogtreecommitdiff
blob: f6fc333ff79655b2d22b3030c74cc239f836a7f1 (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
Parts of:
http://cvs.pld-linux.org/cgi-bin/viewvc.cgi/cvs/packages/FusionSound/FusionSound-ffmpeg.patch?view=markup

and remove a write only variable.
https://bugs.gentoo.org/show_bug.cgi?id=405721

Index: FusionSound-1.1.1/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c
===================================================================
--- FusionSound-1.1.1.orig/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c
+++ FusionSound-1.1.1/interfaces/IFusionSoundMusicProvider/ifusionsoundmusicprovider_ffmpeg.c
@@ -41,6 +41,7 @@
 
 #include <misc/sound_util.h>
 
+#define FF_API_OLD_METADATA2 0
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 
@@ -476,17 +477,26 @@ static DFBResult
 IFusionSoundMusicProvider_FFmpeg_GetTrackDescription( IFusionSoundMusicProvider *thiz,
                                                       FSTrackDescription        *desc )
 {
+     AVDictionaryEntry *tag = NULL;
+
      DIRECT_INTERFACE_GET_DATA( IFusionSoundMusicProvider_FFmpeg )
      
      if (!desc)
           return DFB_INVARG;
 
-     direct_snputs( desc->artist, data->ctx->author, FS_TRACK_DESC_ARTIST_LENGTH );
-     direct_snputs( desc->title, data->ctx->title, FS_TRACK_DESC_TITLE_LENGTH );
-     direct_snputs( desc->album, data->ctx->album, FS_TRACK_DESC_ALBUM_LENGTH );
-     direct_snputs( desc->genre, data->ctx->genre, FS_TRACK_DESC_GENRE_LENGTH );
-     direct_snputs( desc->encoding, data->codec->codec->name, FS_TRACK_DESC_ENCODING_LENGTH );
-     desc->year = data->ctx->year;
+     tag = av_dict_get(data->ctx->metadata, "artist", NULL, 0);
+     if (tag) direct_snputs( desc->artist, tag->value, FS_TRACK_DESC_ARTIST_LENGTH );
+     tag = av_dict_get(data->ctx->metadata, "title", NULL, 0);
+     if (tag) direct_snputs( desc->title, tag->value, FS_TRACK_DESC_TITLE_LENGTH );
+     tag = av_dict_get(data->ctx->metadata, "album", NULL, 0);
+     if (tag) direct_snputs( desc->album, tag->value, FS_TRACK_DESC_ALBUM_LENGTH );
+     tag = av_dict_get(data->ctx->metadata, "genre", NULL, 0);
+     if (tag) direct_snputs( desc->genre, tag->value, FS_TRACK_DESC_GENRE_LENGTH );
+     tag = av_dict_get(data->ctx->metadata, "encoding", NULL, 0);
+     if (tag) direct_snputs( desc->encoding, tag->value, FS_TRACK_DESC_ENCODING_LENGTH );
+     tag = av_dict_get(data->ctx->metadata, "year", NULL, 0);
+     if (tag) desc->year = atoi(tag->value);
+
      desc->bitrate = data->codec->bit_rate;
      desc->replaygain = desc->replaygain_album = 0;
      
@@ -540,7 +550,6 @@ FFmpegStreamThread( DirectThread *thread
      IFusionSoundMusicProvider_FFmpeg_data *data = ctx;
      
      AVPacket  pkt;
-     u8       *pkt_data = NULL;
      int       pkt_size = 0;
      s64       pkt_pts  = AV_NOPTS_VALUE;
      
@@ -584,7 +593,6 @@ FFmpegStreamThread( DirectThread *thread
                     continue;
                }
                
-               pkt_data = pkt.data;
                pkt_size = pkt.size;
                pkt_pts  = pkt.pts;
                if (pkt_pts != AV_NOPTS_VALUE) {
@@ -595,14 +603,13 @@ FFmpegStreamThread( DirectThread *thread
           }
           
           len = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-          decoded = avcodec_decode_audio2( data->codec, 
-                                          (s16*)data->buf, &len, pkt_data, pkt_size );
+          decoded = avcodec_decode_audio3( data->codec, 
+                                          (s16*)data->buf, &len, &pkt );
           if (decoded < 0) {
                av_free_packet( &pkt );
                pkt_size = 0;
           }
           else {    
-               pkt_data += decoded;
                pkt_size -= decoded;
                if (pkt_size <= 0)
                     av_free_packet( &pkt );
@@ -739,7 +746,6 @@ FFmpegBufferThread( DirectThread *thread
      IFusionSoundMusicProvider_FFmpeg_data *data = ctx;
      
      AVPacket  pkt;
-     u8       *pkt_data = NULL;
      int       pkt_size = 0;
      s64       pkt_pts  = AV_NOPTS_VALUE;
      int       pos      = 0;
@@ -789,7 +795,6 @@ FFmpegBufferThread( DirectThread *thread
                     continue;
                }
                
-               pkt_data = pkt.data;
                pkt_size = pkt.size;
                pkt_pts  = pkt.pts;
                if (pkt_pts != AV_NOPTS_VALUE) {
@@ -800,14 +805,13 @@ FFmpegBufferThread( DirectThread *thread
           }
           
           len = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-          decoded = avcodec_decode_audio2( data->codec,
-                                          (s16*)data->buf, &len, pkt_data, pkt_size );
+          decoded = avcodec_decode_audio3( data->codec,
+                                          (s16*)data->buf, &len, &pkt );
           if (decoded < 0) {
                av_free_packet( &pkt );
                pkt_size = 0;
           }
           else {    
-               pkt_data += decoded;
                pkt_size -= decoded;
                if (pkt_size <= 0)
                     av_free_packet( &pkt );
@@ -1208,7 +1212,7 @@ Construct( IFusionSoundMusicProvider *th
      }
      
      for (i = 0; i < data->ctx->nb_streams; i++) {
-          if (data->ctx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
+          if (data->ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
                if (!data->st || data->st->codec->bit_rate < data->ctx->streams[i]->codec->bit_rate)
                     data->st = data->ctx->streams[i];
           }