Skip to content

Commit 307a9d0

Browse files
author
Clement Champetier
committed
OptionLoader: add flags to loadOptions
* 2 new params: * req_flags * rej_flags * Can manage specific AVOptions depending on their flags.
1 parent 0c766a8 commit 307a9d0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

app/optionChecker/optionChecker.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
#include <AvTranscoder/Options/OptionChoice.hpp>
66
#include <AvTranscoder/OptionLoader.hpp>
77

8+
extern "C" {
9+
#ifndef __STDC_CONSTANT_MACROS
10+
#define __STDC_CONSTANT_MACROS
11+
#endif
12+
#include <libavutil/opt.h>
13+
}
14+
815
#include <string>
916
#include <iostream>
1017
#include <iomanip>
@@ -18,7 +25,7 @@ int optionChecker( const std::string& inputfilename )
1825
avtranscoder::AudioDesc audioDesc( inputFile.getStream( 0 ).getAudioDesc() );
1926

2027
avtranscoder::OptionLoader optionLoader;
21-
optionLoader.loadOptions( audioDesc.getCodecContext() );
28+
optionLoader.loadOptions( audioDesc.getCodecContext(), 0, 0 );
2229

2330
// display Options
2431
for( auto option : optionLoader.getOptions() )

src/AvTranscoder/OptionLoader.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ OptionLoader::OptionLoader()
2020

2121
}
2222

23-
void OptionLoader::loadOptions( void* av_class )
23+
void OptionLoader::loadOptions( void* av_class, int req_flags, int rej_flags )
2424
{
2525
// tmp vectors to access easely to the OptionChoice/OptionGroup to add choice / boolean to them
2626
std::vector<avtranscoder::OptionChoice*> optionsChoice;
@@ -31,7 +31,10 @@ void OptionLoader::loadOptions( void* av_class )
3131

3232
while( ( avOption = av_opt_next( av_class, avOption ) ) != NULL )
3333
{
34-
if( !avOption || ! avOption->name )
34+
if( !avOption ||
35+
! avOption->name ||
36+
( avOption->flags & req_flags ) != req_flags ||
37+
( avOption->flags & rej_flags ) )
3538
{
3639
continue;
3740
}
@@ -109,6 +112,8 @@ void OptionLoader::loadOptions( void* av_class )
109112
{
110113
if( !avOption ||
111114
!avOption->name ||
115+
( avOption->flags & req_flags ) != req_flags ||
116+
( avOption->flags & rej_flags ) ||
112117
( avOption->unit && avOption->type == AV_OPT_TYPE_FLAGS ) ||
113118
( avOption->unit && avOption->type == AV_OPT_TYPE_INT ) )
114119
{

src/AvTranscoder/OptionLoader.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class OptionLoader
1919

2020
std::vector<Option*>& getOptions() { return m_options; }
2121

22-
void loadOptions( void* av_class );
22+
/**
23+
* @param av_class: a libav / ffmpeg object which contains AVOption.
24+
*/
25+
void loadOptions( void* av_class, int req_flags, int rej_flags );
2326

2427
private:
2528
std::vector<Option*> m_options;

0 commit comments

Comments
 (0)