Skip to content

Commit d06084a

Browse files
committed
Fix deprecated warnings into util and common code
1 parent 7953180 commit d06084a

File tree

4 files changed

+39
-30
lines changed

4 files changed

+39
-30
lines changed

src/AvTranscoder/Library.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ Libraries getLibraries()
105105
std::vector<std::string> getInputExtensions()
106106
{
107107
std::vector<std::string> extensions;
108-
AVInputFormat* iFormat = NULL;
108+
const AVInputFormat* iFormat = NULL;
109+
void *iFormatOpaque = NULL;
109110

110-
while((iFormat = av_iformat_next(iFormat)))
111+
while((iFormat = av_demuxer_iterate(&iFormatOpaque)))
111112
{
112113
if(iFormat->extensions != NULL)
113114
{
@@ -143,9 +144,10 @@ std::vector<std::string> getInputExtensions()
143144
std::vector<std::string> getOutputExtensions()
144145
{
145146
std::vector<std::string> extensions;
146-
AVOutputFormat* oFormat = NULL;
147+
const AVOutputFormat* oFormat = NULL;
148+
void *oFormatOpaque = NULL;
147149

148-
while((oFormat = av_oformat_next(oFormat)))
150+
while((oFormat = av_muxer_iterate(&oFormatOpaque)))
149151
{
150152
if(oFormat->extensions != NULL)
151153
{

src/AvTranscoder/common.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ namespace avtranscoder
1515

1616
void preloadCodecsAndFormats()
1717
{
18+
#if LIBAVFILTER_VERSION_MAJOR < 7
1819
av_register_all();
1920
avfilter_register_all();
21+
#endif
2022
}
2123

2224
std::string getDescriptionFromErrorCode(const int code)

src/AvTranscoder/util.cpp

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ std::string getSampleFormatName(const AVSampleFormat sampleFormat)
109109
return formatName ? std::string(formatName) : "";
110110
}
111111

112-
std::vector<AVOutputFormat*> getAvailableFormats()
112+
std::vector<const AVOutputFormat*> getAvailableFormats()
113113
{
114-
std::vector<AVOutputFormat*> formats;
114+
std::vector<const AVOutputFormat*> formats;
115+
void* formatOpaque = NULL;
115116

116-
AVOutputFormat* fmt = NULL;
117-
while((fmt = av_oformat_next(fmt)))
117+
const AVOutputFormat* fmt = NULL;
118+
while((fmt = av_muxer_iterate(&formatOpaque)))
118119
{
119120
if(!fmt->name)
120121
continue;
@@ -127,10 +128,10 @@ std::vector<AVOutputFormat*> getAvailableFormats()
127128
NamesMap getAvailableFormatsNames()
128129
{
129130
NamesMap formatsNames;
130-
std::vector<AVOutputFormat*> formats = getAvailableFormats();
131+
std::vector<const AVOutputFormat*> formats = getAvailableFormats();
131132
for(size_t i = 0; i < formats.size(); ++i)
132133
{
133-
AVOutputFormat* fmt = formats.at(i);
134+
const AVOutputFormat* fmt = formats.at(i);
134135
formatsNames.insert(std::make_pair(std::string(fmt->name), std::string(fmt->long_name ? fmt->long_name : "")));
135136
}
136137
return formatsNames;
@@ -139,10 +140,10 @@ NamesMap getAvailableFormatsNames()
139140
NamesMap getAvailableVideoFormatsNames()
140141
{
141142
NamesMap formatsNames;
142-
std::vector<AVOutputFormat*> formats = getAvailableFormats();
143+
std::vector<const AVOutputFormat*> formats = getAvailableFormats();
143144
for(size_t i = 0; i < formats.size(); ++i)
144145
{
145-
AVOutputFormat* fmt = formats.at(i);
146+
const AVOutputFormat* fmt = formats.at(i);
146147
// skip format which cannot handle video
147148
if(fmt->video_codec == AV_CODEC_ID_NONE)
148149
continue;
@@ -154,10 +155,10 @@ NamesMap getAvailableVideoFormatsNames()
154155
NamesMap getAvailableAudioFormatsNames()
155156
{
156157
NamesMap formatsNames;
157-
std::vector<AVOutputFormat*> formats = getAvailableFormats();
158+
std::vector<const AVOutputFormat*> formats = getAvailableFormats();
158159
for(size_t i = 0; i < formats.size(); ++i)
159160
{
160-
AVOutputFormat* fmt = formats.at(i);
161+
const AVOutputFormat* fmt = formats.at(i);
161162
// skip format which cannot handle audio
162163
if(fmt->audio_codec == AV_CODEC_ID_NONE)
163164
continue;
@@ -166,12 +167,13 @@ NamesMap getAvailableAudioFormatsNames()
166167
return formatsNames;
167168
}
168169

169-
std::vector<AVCodec*> getAvailableCodecs()
170+
std::vector<const AVCodec*> getAvailableCodecs()
170171
{
171-
std::vector<AVCodec*> codecs;
172+
std::vector<const AVCodec*> codecs;
172173

173-
AVCodec* c = NULL;
174-
while((c = av_codec_next(c)))
174+
const AVCodec* c = NULL;
175+
void* cOpaque = NULL;
176+
while((c = av_codec_iterate(&cOpaque)))
175177
{
176178
if(!c->name)
177179
continue;
@@ -184,10 +186,10 @@ std::vector<AVCodec*> getAvailableCodecs()
184186
NamesMap getAvailableVideoCodecsNames()
185187
{
186188
NamesMap videoCodecsNames;
187-
std::vector<AVCodec*> codecs = getAvailableCodecs();
189+
std::vector<const AVCodec*> codecs = getAvailableCodecs();
188190
for(size_t i = 0; i < codecs.size(); ++i)
189191
{
190-
AVCodec* c = codecs.at(i);
192+
const AVCodec* c = codecs.at(i);
191193
if(c->type == AVMEDIA_TYPE_VIDEO)
192194
{
193195
videoCodecsNames.insert(std::make_pair(std::string(c->name), std::string(c->long_name ? c->long_name : "")));
@@ -199,10 +201,10 @@ NamesMap getAvailableVideoCodecsNames()
199201
NamesMap getAvailableAudioCodecsNames()
200202
{
201203
NamesMap audioCodecsNames;
202-
std::vector<AVCodec*> codecs = getAvailableCodecs();
204+
std::vector<const AVCodec*> codecs = getAvailableCodecs();
203205
for(size_t i = 0; i < codecs.size(); ++i)
204206
{
205-
AVCodec* c = codecs.at(i);
207+
const AVCodec* c = codecs.at(i);
206208
if(c->type == AVMEDIA_TYPE_AUDIO)
207209
{
208210
audioCodecsNames.insert(std::make_pair(std::string(c->name), std::string(c->long_name ? c->long_name : "")));
@@ -215,7 +217,8 @@ OptionArrayMap getAvailableOptionsPerOutputFormat()
215217
{
216218
OptionArrayMap optionsPerFormat;
217219

218-
AVOutputFormat* outputFormat = av_oformat_next(NULL);
220+
void* outputFormatOpaque = NULL;
221+
const AVOutputFormat* outputFormat = av_muxer_iterate(&outputFormatOpaque);
219222

220223
// iterate on formats
221224
while(outputFormat)
@@ -230,7 +233,7 @@ OptionArrayMap getAvailableOptionsPerOutputFormat()
230233
loadOptions(options, (void*)&outputFormat->priv_class, 0);
231234
}
232235
optionsPerFormat.insert(std::make_pair(outputFormatName, options));
233-
outputFormat = av_oformat_next(outputFormat);
236+
outputFormat = av_muxer_iterate(&outputFormatOpaque);
234237
}
235238
return optionsPerFormat;
236239
}
@@ -239,7 +242,8 @@ OptionArrayMap getAvailableOptionsPerVideoCodec()
239242
{
240243
OptionArrayMap videoCodecOptions;
241244

242-
AVCodec* codec = av_codec_next(NULL);
245+
void* codecOpaque = NULL;
246+
const AVCodec* codec = av_codec_iterate(&codecOpaque);
243247

244248
// iterate on codecs
245249
while(codec)
@@ -258,7 +262,7 @@ OptionArrayMap getAvailableOptionsPerVideoCodec()
258262
}
259263
videoCodecOptions.insert(std::make_pair(videoCodecName, options));
260264
}
261-
codec = av_codec_next(codec);
265+
codec = av_codec_iterate(&codecOpaque);
262266
}
263267
return videoCodecOptions;
264268
}
@@ -267,7 +271,8 @@ OptionArrayMap getAvailableOptionsPerAudioCodec()
267271
{
268272
OptionArrayMap audioCodecOptions;
269273

270-
AVCodec* codec = av_codec_next(NULL);
274+
void* codecOpaque = NULL;
275+
const AVCodec* codec = av_codec_iterate(&codecOpaque);
271276

272277
// iterate on codecs
273278
while(codec)
@@ -286,7 +291,7 @@ OptionArrayMap getAvailableOptionsPerAudioCodec()
286291
}
287292
audioCodecOptions.insert(std::make_pair(audioCodecName, options));
288293
}
289-
codec = av_codec_next(codec);
294+
codec = av_codec_iterate(&codecOpaque);
290295
}
291296
return audioCodecOptions;
292297
}

src/AvTranscoder/util.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ std::string AvExport getSampleFormatName(const AVSampleFormat sampleFormat);
6363
/**
6464
* @return The list of all formats available in FFmpeg / libav.
6565
*/
66-
std::vector<AVOutputFormat*> getAvailableFormats();
66+
std::vector<const AVOutputFormat*> getAvailableFormats();
6767
#endif
6868
/**
6969
* @brief Get a map of short/long names of all formats available in FFmpeg / libav.
@@ -87,7 +87,7 @@ NamesMap AvExport getAvailableAudioFormatsNames();
8787
/**
8888
* @return The list of all codecs available in FFmpeg / libav.
8989
*/
90-
std::vector<AVCodec*> getAvailableCodecs();
90+
std::vector<const AVCodec*> getAvailableCodecs();
9191
#endif
9292

9393
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy