Skip to content

Commit 9847d50

Browse files
author
Clement Champetier
committed
Rename OptionLoader files to util
* No more OptionLoader class: the options are manage by Context and Option classes. * Keep utilities functions of OptionLoader in a new file named util. * Context: * add getOptions and getOptionsMap. * add documentation. * OptionChecker app: fit to new architecture.
1 parent 6d4cf16 commit 9847d50

File tree

7 files changed

+496
-521
lines changed

7 files changed

+496
-521
lines changed

app/optionChecker/optionChecker.cpp

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
#include <AvTranscoder/option/OptionLoader.hpp>
1+
#include <AvTranscoder/util.hpp>
2+
#include <AvTranscoder/option/Context.hpp>
23
#include <AvTranscoder/option/Option.hpp>
34

5+
extern "C" {
6+
#ifndef __STDC_CONSTANT_MACROS
7+
#define __STDC_CONSTANT_MACROS
8+
#endif
9+
#include <libavformat/avformat.h>
10+
}
11+
412
#include <string>
513
#include <iostream>
614
#include <map>
715
#include <vector>
8-
#include <utility> //pair
16+
#include <utility>
917

10-
void displayOptions( avtranscoder::OptionLoader::OptionArray& options )
18+
void displayOptions( std::vector<avtranscoder::Option>& options )
1119
{
1220
for( auto option : options )
1321
{
@@ -60,37 +68,39 @@ void displayOptions( avtranscoder::OptionLoader::OptionArray& options )
6068
}
6169
}
6270

63-
void optionChecker( const std::string& inputfilename )
64-
{
65-
avtranscoder::OptionLoader optionLoader;
66-
67-
//avtranscoder::OptionLoader::OptionArray optionsArray = optionLoader.loadOptions( AV_OPT_FLAG_AUDIO_PARAM );
68-
avtranscoder::OptionLoader::OptionMap optionsMap = optionLoader.loadOutputFormatOptions();
69-
70-
//displayOptions( optionsArray );
71-
for( avtranscoder::OptionLoader::OptionMap::iterator it = optionsMap.begin();
72-
it != optionsMap.end();
73-
++it )
74-
{
75-
std::cout << "----- " << it->first << " -----" << std::endl;
76-
displayOptions( it->second );
77-
}
71+
void optionChecker()
72+
{
73+
// format options
74+
AVFormatContext* avFormatContext = avformat_alloc_context();
75+
avtranscoder::Context formatContext( avFormatContext );
76+
std::vector<avtranscoder::Option> formatOptions = formatContext.getOptions();
77+
displayOptions( formatOptions );
78+
79+
// pixel formats
80+
// std::vector<std::string> pixelFormats = avtranscoder::getPixelFormats();
81+
// for( size_t i = 0; i < pixelFormats.size(); ++i )
82+
// {
83+
// std::cout << "----- " << pixelFormats[i] << " -----" << std::endl;
84+
// }
85+
86+
// options per format
87+
// std::map< std::string, std::vector<avtranscoder::Option> > optionsPerFormat = avtranscoder::getOutputFormatOptions();
88+
// for( std::map< std::string, std::vector<avtranscoder::Option> >::iterator it = optionsPerFormat.begin();
89+
// it != optionsPerFormat.end();
90+
// ++it )
91+
// {
92+
// std::cout << "----- " << it->first << " -----" << std::endl;
93+
// displayOptions( it->second );
94+
// }
7895
}
7996

8097
int main( int argc, char** argv )
8198
{
82-
if( argc <= 1 )
83-
{
84-
std::cout << "audiorewrapper require a media filename" << std::endl;
85-
std::cout << "example: audioWrap file.ext" << std::endl;
86-
return( -1 );
87-
}
88-
8999
std::cout << "start ..." << std::endl;
90100

91101
try
92102
{
93-
optionChecker( argv[1] );
103+
optionChecker();
94104
}
95105
catch( std::exception &e )
96106
{

src/AvTranscoder/option/Context.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ extern "C" {
1616
namespace avtranscoder
1717
{
1818

19+
std::vector<Option> Context::getOptions()
20+
{
21+
std::vector<Option> optionsArray;
22+
for( std::map<std::string, Option>::iterator it = _options.begin(); it != _options.end(); ++it )
23+
{
24+
optionsArray.push_back( it->second );
25+
}
26+
return optionsArray;
27+
}
28+
1929
void Context::loadOptions( void* av_class, int req_flags )
2030
{
2131
std::multimap<std::string, std::string> optionUnitToParentName;

src/AvTranscoder/option/Context.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,30 @@ namespace avtranscoder
1414
/**
1515
* @brief Wrapper of AVContext.
1616
* Can access Options through the corresponding context.
17-
* The context could be an AVFormatContext or an AVCodecContext.
1817
*/
1918
class Context
2019
{
2120
public:
21+
/**
22+
* @param avContext: could be an AVFormatContext or an AVCodecContext.
23+
* @param req_flags: filter the AVOption loaded by the Context (default = 0: no flag restriction).
24+
* Possible values of flags are:
25+
* AV_OPT_FLAG_ENCODING_PARAM
26+
* AV_OPT_FLAG_DECODING_PARAM
27+
* AV_OPT_FLAG_METADATA
28+
* AV_OPT_FLAG_AUDIO_PARAM
29+
* AV_OPT_FLAG_VIDEO_PARAM
30+
* AV_OPT_FLAG_SUBTITLE_PARAM
31+
*/
2232
Context( void* avContext, int req_flags = 0 )
2333
: _avContext( avContext )
2434
{
2535
loadOptions( avContext, req_flags );
2636
}
2737

38+
std::vector<Option> getOptions();
39+
std::map<std::string, Option>& getOptionsMap() { return _options; }
40+
2841
Option& getOption( const std::string& optionName ) { return _options.at(optionName); }
2942

3043
private:

0 commit comments

Comments
 (0)