Skip to content

Commit a5ceb7f

Browse files
author
Clement Champetier
committed
mediaProperty: can get video and audio properties by a vector or a map
Fix #141
1 parent c0aed47 commit a5ceb7f

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

src/AvTranscoder/mediaProperty/AudioProperties.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,19 @@ PropertyVector AudioProperties::getPropertiesAsVector() const
231231
return data;
232232
}
233233

234+
PropertyMap AudioProperties::getPropertiesAsMap() const
235+
{
236+
PropertyMap dataMap;
237+
238+
PropertyVector dataVector( getPropertiesAsVector() );
239+
for( PropertyVector::const_iterator it = dataVector.begin();
240+
it != dataVector.end();
241+
++it )
242+
{
243+
dataMap.insert( std::make_pair( it->first, it->second ) );
244+
}
245+
246+
return dataMap;
247+
}
248+
234249
}

src/AvTranscoder/mediaProperty/AudioProperties.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class AvExport AudioProperties
4242
AVCodecContext& getAVCodecContext() { return *_codecContext; }
4343
#endif
4444

45-
PropertyVector getPropertiesAsVector() const; ///< Return all audio properties as a vector (name of property: value)
45+
PropertyMap getPropertiesAsMap() const; ///< Return all audio properties as a map (name of property, value)
46+
PropertyVector getPropertiesAsVector() const; ///< Same data with a specific order
4647

4748
private:
4849
#ifndef SWIG

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,4 +696,19 @@ PropertyVector VideoProperties::getPropertiesAsVector() const
696696
return data;
697697
}
698698

699+
PropertyMap VideoProperties::getPropertiesAsMap() const
700+
{
701+
PropertyMap dataMap;
702+
703+
PropertyVector dataVector( getPropertiesAsVector() );
704+
for( PropertyVector::const_iterator it = dataVector.begin();
705+
it != dataVector.end();
706+
++it )
707+
{
708+
dataMap.insert( std::make_pair( it->first, it->second ) );
709+
}
710+
711+
return dataMap;
712+
}
713+
699714
}

src/AvTranscoder/mediaProperty/VideoProperties.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class AvExport VideoProperties
8383
const PixelProperties& getPixelProperties() const { return _pixelProperties; }
8484
#endif
8585

86-
PropertyVector getPropertiesAsVector() const; ///< Return all video and pixel properties as a vector (name of property: value)
86+
PropertyMap getPropertiesAsMap() const; ///< Return all video and pixel properties as a map (name of property, value)
87+
PropertyVector getPropertiesAsVector() const; ///< Same data with a specific order
8788

8889
private:
8990
/**

src/AvTranscoder/mediaProperty/util.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern "C" {
99

1010
#include <vector>
1111
#include <utility>
12+
#include <map>
1213
#include <string>
1314
#include <sstream>
1415

@@ -19,6 +20,7 @@ namespace avtranscoder
1920
* @brief PropertyVector is a vector of pair, because the order of properties matters to us.
2021
*/
2122
typedef std::vector< std::pair<std::string, std::string> > PropertyVector;
23+
typedef std::map< std::string, std::string > PropertyMap;
2224

2325
namespace detail
2426
{

0 commit comments

Comments
 (0)