Annotation of /trunk/strigi/patches/strigi-0.7.7-ffmpeg.patch
Parent Directory | Revision Log
Revision 1936 -
(hide annotations)
(download)
Sat Nov 3 13:13:09 2012 UTC (11 years, 11 months ago) by niro
File size: 5939 byte(s)
Sat Nov 3 13:13:09 2012 UTC (11 years, 11 months ago) by niro
File size: 5939 byte(s)
-fix build with new ffmpeg
1 | niro | 1936 | diff --git a/libstreamanalyzer/plugins/endplugins/ffmpegendanalyzer.cpp b/plugins/endplugins/ffmpegendanalyzer.cpp |
2 | index 8805457..3456e46 100644 | ||
3 | --- a/libstreamanalyzer/plugins/endplugins/ffmpegendanalyzer.cpp | ||
4 | +++ b/libstreamanalyzer/plugins/endplugins/ffmpegendanalyzer.cpp | ||
5 | @@ -300,11 +300,16 @@ int64_t seek_data(void *opaque, int64_t offset, int whence) { | ||
6 | |||
7 | int64_t const no_bitrate = 0x8000000000000000ULL; | ||
8 | |||
9 | +//SAMPLE_FMT_NONE has been renamed in later versions of FFmpeg | ||
10 | +#if not defined SAMPLE_FMT_NONE | ||
11 | + #define SAMPLE_FMT_NONE AV_SAMPLE_FMT_NONE | ||
12 | +#endif | ||
13 | signed char | ||
14 | FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
15 | uint8_t pDataBuffer[32768];//65536]; | ||
16 | long lSize = 32768; | ||
17 | |||
18 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
19 | ByteIOContext ByteIOCtx; | ||
20 | if(init_put_byte(&ByteIOCtx, pDataBuffer, lSize, 0, in, read_data, NULL, seek_data) < 0) | ||
21 | return -1; | ||
22 | @@ -312,6 +317,12 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
23 | //pAVInputFormat->flags |= AVFMT_NOFILE; | ||
24 | ByteIOCtx.is_streamed = 0; | ||
25 | |||
26 | +#else | ||
27 | + AVFormatContext *fc = avformat_alloc_context(); | ||
28 | + fc->pb = avio_alloc_context(pDataBuffer, lSize, 0, in, read_data, NULL, seek_data); | ||
29 | + if(!fc || !(fc->pb)) | ||
30 | + return -1; | ||
31 | +#endif | ||
32 | AVProbeData pd; | ||
33 | const char *buf; | ||
34 | pd.filename =""; | ||
35 | @@ -324,6 +335,7 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
36 | if(fmt == NULL) | ||
37 | return 1; | ||
38 | |||
39 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
40 | AVFormatContext *fc = NULL; | ||
41 | if(av_open_input_stream(&fc, &ByteIOCtx, "", fmt, NULL) < 0) | ||
42 | return -1; | ||
43 | @@ -333,6 +345,15 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
44 | // Dump information about file onto standard error | ||
45 | dump_format(fc, 0, ar.path().c_str(), false); | ||
46 | |||
47 | +#else | ||
48 | + if(avformat_open_input(&fc, "", fmt, NULL) < 0) | ||
49 | + return -1; | ||
50 | + | ||
51 | + avformat_find_stream_info(fc,NULL); | ||
52 | + // Dump information about file onto standard error | ||
53 | + av_dump_format(fc, 0, ar.path().c_str(), false); | ||
54 | +#endif | ||
55 | + | ||
56 | if(fc->bit_rate) | ||
57 | ar.addValue(factory->bitrateProperty, fc->bit_rate); | ||
58 | else if (fc->duration!= no_bitrate && fc->duration > 0) { | ||
59 | @@ -372,10 +393,14 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
60 | ar.addTriplet(streamuri, durationPropertyName,outs.str()); | ||
61 | } | ||
62 | |||
63 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
64 | //FIXME we must stop using the deprecated fuction av_metadata_get and use | ||
65 | // av_dict_get once we are able to detect the version of FFMpeg being used | ||
66 | // using version macros. same goes for all occurences of this function. | ||
67 | AVMetadataTag *entry = av_metadata_get(stream.metadata, "language", NULL, 0); | ||
68 | +#else | ||
69 | + AVDictionaryEntry *entry = av_dict_get(stream.metadata, "language", NULL, 0); | ||
70 | +#endif | ||
71 | if (entry != NULL) { | ||
72 | const char *languageValue = entry->value; | ||
73 | if (size_t len = strlen(languageValue)) { | ||
74 | @@ -469,7 +494,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
75 | |||
76 | // Tags | ||
77 | |||
78 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
79 | AVMetadataTag *entry = av_metadata_get(fc->metadata, "title", NULL, 0); | ||
80 | +#else | ||
81 | + AVDictionaryEntry *entry = av_dict_get(fc->metadata, "title", NULL, 0); | ||
82 | +#endif | ||
83 | if (entry != NULL) | ||
84 | { | ||
85 | const char *titleValue = entry->value; | ||
86 | @@ -478,7 +507,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
87 | } | ||
88 | } | ||
89 | |||
90 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
91 | entry = av_metadata_get(fc->metadata, "author", NULL, 0); | ||
92 | +#else | ||
93 | + entry = av_dict_get(fc->metadata, "author", NULL, 0); | ||
94 | +#endif | ||
95 | if (entry != NULL) | ||
96 | { | ||
97 | const char *authorValue = entry->value; | ||
98 | @@ -490,7 +523,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
99 | } | ||
100 | } | ||
101 | |||
102 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
103 | entry = av_metadata_get(fc->metadata, "copyright", NULL, 0); | ||
104 | +#else | ||
105 | + entry = av_dict_get(fc->metadata, "copyright", NULL, 0); | ||
106 | +#endif | ||
107 | if (entry != NULL) | ||
108 | { | ||
109 | const char *copyrightValue = entry->value; | ||
110 | @@ -499,7 +536,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
111 | } | ||
112 | } | ||
113 | |||
114 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
115 | entry = av_metadata_get(fc->metadata, "comment", NULL, 0); | ||
116 | +#else | ||
117 | + entry = av_dict_get(fc->metadata, "comment", NULL, 0); | ||
118 | +#endif | ||
119 | if (entry != NULL) | ||
120 | { | ||
121 | const char *commentValue = entry->value; | ||
122 | @@ -508,7 +549,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
123 | } | ||
124 | } | ||
125 | |||
126 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
127 | entry = av_metadata_get(fc->metadata, "album", NULL, 0); | ||
128 | +#else | ||
129 | + entry = av_dict_get(fc->metadata, "album", NULL, 0); | ||
130 | +#endif | ||
131 | if (entry != NULL) | ||
132 | { | ||
133 | const char *albumValue = entry->value; | ||
134 | @@ -520,7 +565,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
135 | } | ||
136 | } | ||
137 | |||
138 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
139 | entry = av_metadata_get(fc->metadata, "genre", NULL, 0); | ||
140 | +#else | ||
141 | + entry = av_dict_get(fc->metadata, "genre", NULL, 0); | ||
142 | +#endif | ||
143 | if (entry != NULL) | ||
144 | { | ||
145 | const char *genreValue = entry->value; | ||
146 | @@ -529,7 +578,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
147 | } | ||
148 | } | ||
149 | |||
150 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
151 | entry = av_metadata_get(fc->metadata, "track", NULL, 0); | ||
152 | +#else | ||
153 | + entry = av_dict_get(fc->metadata, "track", NULL, 0); | ||
154 | +#endif | ||
155 | if (entry != NULL) | ||
156 | { | ||
157 | const char *trackValue = entry->value; | ||
158 | @@ -538,7 +591,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
159 | } | ||
160 | } | ||
161 | |||
162 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
163 | entry = av_metadata_get(fc->metadata, "year", NULL, 0); | ||
164 | +#else | ||
165 | + entry = av_dict_get(fc->metadata, "year", NULL, 0); | ||
166 | +#endif | ||
167 | if (entry != NULL) | ||
168 | { | ||
169 | const char *yearValue = entry->value; | ||
170 | @@ -547,7 +604,11 @@ FFMPEGEndAnalyzer::analyze(AnalysisResult& ar, ::InputStream* in) { | ||
171 | } | ||
172 | } | ||
173 | |||
174 | +#if (LIBAVUTIL_VERSION_MAJOR < 51) | ||
175 | av_close_input_stream(fc); | ||
176 | +#else | ||
177 | + avformat_close_input(&fc); | ||
178 | +#endif | ||
179 | //url_fclose(&ByteIOCtx); | ||
180 | |||
181 | return 0; |