AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.cpp
Go to the documentation of this file.
1 #include "util.hpp"
2 
3 extern "C" {
4 #include <libavutil/avutil.h>
5 }
6 
7 #include <sstream>
8 
9 namespace avtranscoder
10 {
11 
12 namespace detail
13 {
14 
15 template <>
16 void add(PropertyVector& propertyVector, const std::string& key, const size_t& value)
17 {
18  std::stringstream ss;
19  if(value == (size_t)AV_NOPTS_VALUE)
20  ss << "N/A";
21  else
22  ss << value;
23  add(propertyVector, key, ss.str());
24 }
25 
26 template <>
27 void add(PropertyVector& propertyVector, const std::string& key, const float& value)
28 {
29  std::stringstream ss;
30  if(value <= AV_NOPTS_VALUE || value >= -(float)AV_NOPTS_VALUE)
31  ss << "N/A";
32  else
33  ss << value;
34  add(propertyVector, key, ss.str());
35 }
36 
37 template <>
38 void add(PropertyVector& propertyVector, const std::string& key, const std::string& value)
39 {
40  propertyVector.push_back(std::make_pair(key, value));
41 }
42 
43 template <>
44 void add(PropertyVector& propertyVector, const std::string& key, const bool& value)
45 {
46  add(propertyVector, key, value ? "True" : "False");
47 }
48 
49 template <>
50 void add(PropertyVector& propertyVector, const std::string& key, const Rational& value)
51 {
52  add(propertyVector, key, value.num / (double)value.den);
53 }
54 
55 void fillMetadataDictionnary(AVDictionary* avdictionnary, PropertyVector& metadata)
56 {
57  AVDictionaryEntry* tag = NULL;
58  while((tag = av_dict_get(avdictionnary, "", tag, AV_DICT_IGNORE_SUFFIX)))
59  {
60  metadata.push_back(std::make_pair(tag->key, tag->value));
61  }
62 }
63 }
64 }
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
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
AVRational Rational
Definition: common.hpp:55
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