summaryrefslogtreecommitdiff
path: root/app-misc/strigi/files/strigi-0.7.5-ffmpeg.patch
blob: ee1bfc026025a3bc27ed715afc5784b012dba105 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
diff -ruN strigi-0.7.5.orig/libstreamanalyzer/plugins/endplugins/ffmpegendanalyzer.cpp strigi-0.7.5/libstreamanalyzer/plugins/endplugins/ffmpegendanalyzer.cpp
--- strigi-0.7.5.orig/libstreamanalyzer/plugins/endplugins/ffmpegendanalyzer.cpp	2011-06-02 11:29:26.000000000 +0200
+++ strigi-0.7.5/libstreamanalyzer/plugins/endplugins/ffmpegendanalyzer.cpp	2011-08-02 23:25:04.936181179 +0200
@@ -1,6 +1,7 @@
 /* This file is part of Strigi Desktop Search
  *
  * Copyright (C) 2010 Evgeny Egorochkin <phreedom.stdin@gmail.com>
+ * Copyright (C) 2011 Tirtha Chatterjee <tirtha.p.chatterjee@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -348,7 +349,7 @@
     if ((size = in->size()) >= 0)
       ar.addValue(factory->durationProperty, (uint32_t)(size/(fc->bit_rate/8)));
   }
-  if(fc->nb_streams==1 && fc->streams[0]->codec->codec_type == CODEC_TYPE_AUDIO) {
+  if(fc->nb_streams==1 && fc->streams[0]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
     ar.addValue(factory->typeProperty, NFO "Audio");
     ar.addValue(factory->typeProperty, NMM_DRAFT "MusicPiece");
   } else {
@@ -359,7 +360,7 @@
     const AVStream &stream = *fc->streams[i];
     const AVCodecContext &codec = *stream.codec;
     
-    if (codec.codec_type == CODEC_TYPE_AUDIO || codec.codec_type == CODEC_TYPE_VIDEO) {
+    if (codec.codec_type == AVMEDIA_TYPE_AUDIO || codec.codec_type == AVMEDIA_TYPE_VIDEO) {
       const string streamuri = ar.newAnonymousUri();
       ar.addValue(factory->hasPartProperty, streamuri);
       ar.addTriplet(streamuri, partOfPropertyName, ar.path());
@@ -370,8 +371,16 @@
         outs << (stream.duration * stream.time_base.num / stream.time_base.den);
         ar.addTriplet(streamuri, durationPropertyName,outs.str());
       }
-      if (size_t len = strlen(stream.language)) {
-        ar.addTriplet(streamuri, languagePropertyName, string(stream.language, len));
+
+      //FIXME we must stop using the deprecated fuction av_metadata_get and use
+      // av_dict_get once we are able to detect the version of FFMpeg being used
+      // using version macros. same goes for all occurences of this function.
+      AVMetadataTag *entry = av_metadata_get(stream.metadata, "language", NULL, 0);
+      if (entry != NULL) {
+        const char *languageValue = entry->value;
+        if (size_t len = strlen(languageValue)) {
+          ar.addTriplet(streamuri, languagePropertyName, string(languageValue, len));
+        }
       }
       const AVCodec *p = avcodec_find_decoder(codec.codec_id);
       if (p) {
@@ -408,7 +417,7 @@
         ar.addTriplet(streamuri, bitratePropertyName, outs.str());
       }
 
-      if (codec.codec_type == CODEC_TYPE_AUDIO) {
+      if (codec.codec_type == AVMEDIA_TYPE_AUDIO) {
         
         ar.addTriplet(streamuri, typePropertyName, audioClassName);
         if (codec.channels) {
@@ -458,36 +467,83 @@
   }
 
   // Tags
-  
-  if (int32_t len = strlen(fc->title)) {
-    ar.addValue(factory->titleProperty, string(fc->title, len) );
+
+  AVMetadataTag *entry = av_metadata_get(fc->metadata, "title", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *titleValue = entry->value;
+    if (int32_t len = strlen(titleValue)) {
+      ar.addValue(factory->titleProperty, string(titleValue, len) );
+    }
+  }
+
+  entry = av_metadata_get(fc->metadata, "author", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *authorValue = entry->value;
+    if (int32_t len = strlen(authorValue)) {
+      const string creatoruri = ar.newAnonymousUri();
+      ar.addValue(factory->creatorProperty, creatoruri);
+      ar.addTriplet(creatoruri, typePropertyName, contactClassName);
+      ar.addTriplet(creatoruri, fullnamePropertyName, string(authorValue, len) );
+    }
+  }
+
+  entry = av_metadata_get(fc->metadata, "copyright", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *copyrightValue = entry->value;
+    if (int32_t len = strlen(copyrightValue)) {
+      ar.addValue(factory->copyrightProperty, string(copyrightValue, len) );
+    }
   }
-  if (int32_t len = strlen(fc->author)) {
-    const string creatoruri = ar.newAnonymousUri();
-    ar.addValue(factory->creatorProperty, creatoruri);
-    ar.addTriplet(creatoruri, typePropertyName, contactClassName);
-    ar.addTriplet(creatoruri, fullnamePropertyName, string(fc->author, len) );
-  }
-  if (int32_t len = strlen(fc->copyright)) {
-    ar.addValue(factory->copyrightProperty, string(fc->copyright, len) );
-  }
-  if (int32_t len = strlen(fc->comment)) {
-    ar.addValue(factory->commentProperty, string(fc->comment, len) );
-  }
-  if (int32_t len = strlen(fc->album)) {
-    const string album = ar.newAnonymousUri();
-    ar.addValue(factory->albumProperty, album);
+
+  entry = av_metadata_get(fc->metadata, "comment", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *commentValue = entry->value;
+    if (int32_t len = strlen(commentValue)) {
+      ar.addValue(factory->commentProperty, string(commentValue, len) );
+    }
+  }
+
+  entry = av_metadata_get(fc->metadata, "album", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *albumValue = entry->value;
+    if (int32_t len = strlen(albumValue)) {
+      const string album = ar.newAnonymousUri();
+      ar.addValue(factory->albumProperty, album);
     ar.addTriplet(album, typePropertyName, albumClassName);
-    ar.addTriplet(album, titlePropertyName, string(fc->album, len) );
+    ar.addTriplet(album, titlePropertyName, string(albumValue, len) );
+    }
   }
-  if (int32_t len = strlen(fc->genre)) {
-    ar.addValue(factory->genreProperty, string(fc->genre, len) );
+
+  entry = av_metadata_get(fc->metadata, "genre", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *genreValue = entry->value;
+    if (int32_t len = strlen(genreValue)) {
+      ar.addValue(factory->genreProperty, string(genreValue, len) );
+    }
   }
-  if (fc->track) {
-    ar.addValue(factory->trackProperty, fc->track);
+
+  entry = av_metadata_get(fc->metadata, "track", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *trackValue = entry->value;
+    if (int32_t len = strlen(trackValue)) {
+      ar.addValue(factory->trackProperty, string(trackValue, len) );
+    }
   }
-  if (fc->year) {
-    ar.addValue(factory->createdProperty, fc->year);
+
+  entry = av_metadata_get(fc->metadata, "year", NULL, 0);
+  if (entry != NULL)
+  {
+    const char *yearValue = entry->value;
+    if (int32_t len = strlen(yearValue)) {
+      ar.addValue(factory->createdProperty, string(yearValue, len) );
+    }
   }
 
   av_close_input_stream(fc);