AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_MEDIA_PROPERTY_UTIL_HPP_
2 #define _AV_TRANSCODER_MEDIA_PROPERTY_UTIL_HPP_
3 
5 
6 extern "C" {
7 #include <libavutil/dict.h>
8 }
9 
10 #include <vector>
11 #include <utility>
12 #include <map>
13 #include <string>
14 #include <sstream>
15 #include <iomanip>
16 
17 namespace avtranscoder
18 {
19 
20 /**
21  * @brief PropertyVector is a vector of pair, because the order of properties matters to us.
22  */
23 typedef std::vector<std::pair<std::string, std::string> > PropertyVector;
24 typedef std::map<std::string, std::string> PropertyMap;
25 
26 namespace detail
27 {
28 
29 /**
30  * Variables to print properties class to the terminal.
31  */
32 const size_t keyWidth = 32;
33 const std::string separator = "====================";
34 
35 /**
36  * If cannot access the property, get this value.
37  */
38 const std::string propertyValueIfError = "null";
39 
40 template <typename T>
41 void add(PropertyVector& propertyVector, const std::string& key, const T& value)
42 {
43  std::stringstream ss;
44  ss << value;
45  add(propertyVector, key, ss.str());
46 }
47 
48 template <>
49 void add(PropertyVector& propertyVector, const std::string& key, const size_t& value);
50 
51 template <>
52 void add(PropertyVector& propertyVector, const std::string& key, const float& value);
53 
54 template <>
55 void add(PropertyVector& propertyVector, const std::string& key, const std::string& value);
56 
57 template <>
58 void add(PropertyVector& propertyVector, const std::string& key, const bool& value);
59 
60 template <>
61 void add(PropertyVector& propertyVector, const std::string& key, const Rational& value);
62 
63 /**
64  * @brief Fill metadata parameter with the given AVDictionary.
65  */
66 void AvExport fillMetadataDictionnary(AVDictionary* avdictionnary, PropertyVector& metadata);
67 }
68 }
69 
70 #endif
std::vector< std::pair< std::string, std::string > > PropertyVector
PropertyVector is a vector of pair, because the order of properties matters to us.
Definition: util.hpp:23
const size_t keyWidth
Definition: util.hpp:32
const std::string separator
Definition: util.hpp:33
void add(PropertyVector &propertyVector, const std::string &key, const size_t &value)
Definition: util.cpp:16
void fillMetadataDictionnary(AVDictionary *avdictionnary, PropertyVector &metadata)
Fill metadata parameter with the given AVDictionary.
Definition: util.cpp:55
std::map< std::string, std::string > PropertyMap
Definition: util.hpp:24
AVRational Rational
Definition: common.hpp:55
const std::string propertyValueIfError
Definition: util.hpp:38