Skip to content

Commit 6eb8a95

Browse files
author
Clement Champetier
committed
MediadataStructures: add getDataMap()
* Can get all data of Properties structures by getDataMap(), which return a MetadatasMap. * Update Print file. This is the choice of the application which uses AvTranscoder of how to display the data.
1 parent f79f59b commit 6eb8a95

File tree

3 files changed

+247
-92
lines changed

3 files changed

+247
-92
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#include "MediaMetadatasStructures.hpp"
2+
3+
#include <sstream>
4+
5+
namespace avtranscoder
6+
{
7+
8+
namespace detail
9+
{
10+
11+
template<typename T>
12+
void add( MetadatasMap& dataMap, const std::string& key, const T& value )
13+
{
14+
std::stringstream ss;
15+
ss << value;
16+
dataMap[key]= ss.str();
17+
}
18+
19+
template<>
20+
void add( MetadatasMap& dataMap, const std::string& key, const std::string& value )
21+
{
22+
dataMap[key]= value;
23+
}
24+
25+
template<>
26+
void add( MetadatasMap& dataMap, const std::string& key, const bool& value )
27+
{
28+
dataMap[key]= ( value ? "True" : "False" );
29+
}
30+
31+
}
32+
33+
MetadatasMap VideoProperties::getDataMap() const
34+
{
35+
MetadatasMap dataMap;
36+
37+
detail::add( dataMap, "codec name", codecName );
38+
detail::add( dataMap, "codec long name", codecLongName );
39+
detail::add( dataMap, "profile name", profileName );
40+
detail::add( dataMap, "start timecode", startTimecode );
41+
detail::add( dataMap, "pixel type", pixelName );
42+
detail::add( dataMap, "bit wise acked", bitWisePacked );
43+
detail::add( dataMap, "rgb pixel", rgbPixelData );
44+
detail::add( dataMap, "as alpha", asAlpha );
45+
detail::add( dataMap, "endianess", endianess );
46+
detail::add( dataMap, "color transfert", colorTransfert );
47+
detail::add( dataMap, "colorspace", colorspace );
48+
detail::add( dataMap, "color range", colorRange );
49+
detail::add( dataMap, "color primaries", colorPrimaries );
50+
detail::add( dataMap, "indexed colors", indexedColors );
51+
detail::add( dataMap, "pseudo paletted", pseudoPaletted );
52+
detail::add( dataMap, "chroma sample location", chromaSampleLocation);
53+
detail::add( dataMap, "interlaced ", isInterlaced );
54+
detail::add( dataMap, "top field first", topFieldFirst );
55+
detail::add( dataMap, "field order", fieldOrder);
56+
detail::add( dataMap, "has B frames", hasBFrames );
57+
58+
std::string gop;
59+
for( size_t frameIndex = 0; frameIndex < gopStructure.size(); ++frameIndex )
60+
{
61+
gop += gopStructure.at( frameIndex ).first;
62+
gop += ( gopStructure.at( frameIndex ).second ? "*" : " " );
63+
}
64+
detail::add( dataMap, "gop", gop );
65+
66+
detail::add( dataMap, "codec id", codecId );
67+
detail::add( dataMap, "stream id", streamId );
68+
detail::add( dataMap, "profile", profile );
69+
detail::add( dataMap, "level", level );
70+
detail::add( dataMap, "width", width );
71+
detail::add( dataMap, "height", height );
72+
detail::add( dataMap, "dtgActiveFormat", dtgActiveFormat );
73+
detail::add( dataMap, "timeBase", timeBase.num / timeBase.den );
74+
detail::add( dataMap, "fps", fps );
75+
detail::add( dataMap, "ticksPerFrame", ticksPerFrame );
76+
detail::add( dataMap, "pixel aspect ratio", sar.num / sar.den );
77+
detail::add( dataMap, "display aspect ratio", dar.num / dar.den );
78+
detail::add( dataMap, "bit rate", bitRate );
79+
detail::add( dataMap, "max bit rate", maxBitRate );
80+
detail::add( dataMap, "min bit rate", minBitRate );
81+
detail::add( dataMap, "components count", componentsCount );
82+
detail::add( dataMap, "chroma width", chromaWidth );
83+
detail::add( dataMap, "chroma height", chromaHeight );
84+
detail::add( dataMap, "gop size", gopSize );
85+
detail::add( dataMap, "references frames", referencesFrames );
86+
87+
return dataMap;
88+
}
89+
90+
MetadatasMap AudioProperties::getDataMap() const
91+
{
92+
MetadatasMap dataMap;
93+
94+
detail::add( dataMap, "codec name", codecName );
95+
detail::add( dataMap, "codec long name", codecLongName );
96+
detail::add( dataMap, "sample format", sampleFormat );
97+
detail::add( dataMap, "channel layout", channelLayout );
98+
detail::add( dataMap, "channel name", channelName );
99+
detail::add( dataMap, "channel description", channelDescription );
100+
101+
detail::add( dataMap, "codec id", codecId );
102+
detail::add( dataMap, "stream id", streamId );
103+
detail::add( dataMap, "sample rate", sampleRate );
104+
detail::add( dataMap, "channels", channels );
105+
detail::add( dataMap, "bit rate", bit_rate );
106+
107+
return dataMap;
108+
}
109+
110+
MetadatasMap DataProperties::getDataMap() const
111+
{
112+
MetadatasMap dataMap;
113+
114+
detail::add( dataMap, "streamId", streamId );
115+
116+
return dataMap;
117+
}
118+
119+
MetadatasMap SubtitleProperties::getDataMap() const
120+
{
121+
MetadatasMap dataMap;
122+
123+
detail::add( dataMap, "streamId", streamId );
124+
125+
return dataMap;
126+
}
127+
128+
MetadatasMap AttachementProperties::getDataMap() const
129+
{
130+
MetadatasMap dataMap;
131+
132+
detail::add( dataMap, "streamId", streamId );
133+
134+
return dataMap;
135+
}
136+
137+
MetadatasMap UnknownProperties::getDataMap() const
138+
{
139+
MetadatasMap dataMap;
140+
141+
detail::add( dataMap, "streamId", streamId );
142+
143+
return dataMap;
144+
}
145+
146+
MetadatasMap Properties::getDataMap() const
147+
{
148+
MetadatasMap dataMap;
149+
150+
detail::add( dataMap, "filename", filename );
151+
detail::add( dataMap, "format name", formatName );
152+
detail::add( dataMap, "format long name", formatLongName );
153+
154+
for( size_t metadataIndex = 0; metadataIndex < metadatas.size(); ++metadataIndex )
155+
{
156+
std::string key( "Metadatas " + metadatas.at( metadataIndex ).first );
157+
detail::add( dataMap, key, metadatas.at( metadataIndex ).second );
158+
}
159+
160+
detail::add( dataMap, "start time", startTime );
161+
detail::add( dataMap, "duration", duration );
162+
detail::add( dataMap, "bitrate", bitRate );
163+
detail::add( dataMap, "number of streams", streamsCount );
164+
detail::add( dataMap, "number of programs", programsCount );
165+
detail::add( dataMap, "number of video streams", videoStreams.size() );
166+
detail::add( dataMap, "number of audio streams", audioStreams.size() );
167+
detail::add( dataMap, "number of data streams", dataStreams.size() );
168+
detail::add( dataMap, "number of subtitle streams", subtitleStreams.size() );
169+
detail::add( dataMap, "number of attachement streams", attachementStreams.size() );
170+
detail::add( dataMap, "number of unknown streams", unknownStreams.size() );
171+
172+
return dataMap;
173+
}
174+
175+
}

src/AvTranscoder/Metadatas/MediaMetadatasStructures.hpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
#ifndef _AV_TRANSCODER_MEDIA_HPP_
22
#define _AV_TRANSCODER_MEDIA_HPP_
33

4+
#include <AvTranscoder/common.hpp>
5+
46
#include <string>
57
#include <vector>
6-
8+
#include <map>
79

810
namespace avtranscoder
911
{
1012

13+
/**
14+
* @brief Can get all data of Properties structures by getDataMap(), which return a MetadatasMap.
15+
*/
16+
typedef std::map<std::string, std::string> MetadatasMap;
17+
1118
struct Channel {
1219
size_t id;
1320
size_t chromaHeight;
@@ -67,6 +74,9 @@ struct VideoProperties {
6774
// ( frame type / is key frame )
6875
std::vector< std::pair< char, bool > > gopStructure;
6976
std::vector<Channel> channels;
77+
78+
public:
79+
MetadatasMap getDataMap() const;
7080
};
7181

7282
struct AudioProperties {
@@ -81,22 +91,37 @@ struct AudioProperties {
8191
size_t sampleRate;
8292
size_t channels;
8393
size_t bit_rate;
94+
95+
public:
96+
MetadatasMap getDataMap() const;
8497
};
8598

8699
struct DataProperties {
87100
size_t streamId;
101+
102+
public:
103+
MetadatasMap getDataMap() const;
88104
};
89105

90106
struct SubtitleProperties {
91107
size_t streamId;
108+
109+
public:
110+
MetadatasMap getDataMap() const;
92111
};
93112

94113
struct AttachementProperties {
95114
size_t streamId;
115+
116+
public:
117+
MetadatasMap getDataMap() const;
96118
};
97119

98120
struct UnknownProperties {
99121
size_t streamId;
122+
123+
public:
124+
MetadatasMap getDataMap() const;
100125
};
101126

102127
struct Properties {
@@ -118,6 +143,9 @@ struct Properties {
118143
std::vector< UnknownProperties > unknownStreams;
119144

120145
std::vector< std::pair< std::string, std::string > > metadatas; // ( key, value )
146+
147+
public:
148+
MetadatasMap getDataMap() const;
121149
};
122150

123151
}

0 commit comments

Comments
 (0)