Skip to content

Commit 3d99fa5

Browse files
author
Clement Champetier
committed
MediaMetadatasStructures: add fillMetadataDictionnary
* This functions fills metadata parameter with the given AVDictionary. * Use it when add metadata of AVFormatContext in InputFile::analyse function.
1 parent 4bd847c commit 3d99fa5

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/AvTranscoder/File/InputFile.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ InputFile& InputFile::analyse( ProgressListener& progress, const EAnalyseLevel l
8080
_properties.bitRate = _formatContext->bit_rate;
8181
_properties.packetSize = _formatContext->packet_size;
8282

83-
AVDictionaryEntry *tag = NULL;
84-
while( ( tag = av_dict_get( _formatContext->metadata, "", tag, AV_DICT_IGNORE_SUFFIX ) ) )
85-
{
86-
_properties.metadatas.push_back( std::pair<std::string, std::string>( tag->key, tag->value ) );
87-
}
83+
detail::fillMetadataDictionnary( _formatContext->metadata, _properties.metadatas );
8884

8985
for( size_t streamId = 0; streamId < _formatContext->nb_streams; streamId++ )
9086
{

src/AvTranscoder/Metadatas/MediaMetadatasStructures.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#include "MediaMetadatasStructures.hpp"
22

3+
extern "C" {
4+
#ifndef __STDC_CONSTANT_MACROS
5+
#define __STDC_CONSTANT_MACROS
6+
#endif
7+
#include <libavutil/dict.h>
8+
}
9+
310
#include <sstream>
411
#include <utility>
512

@@ -28,6 +35,14 @@ void add( MetadatasMap& dataMap, const std::string& key, const bool& value )
2835
{
2936
add( dataMap, key, value ? "True" : "False" );
3037
}
38+
39+
void fillMetadataDictionnary( AVDictionary* avdictionnary, MetadatasMap& metadata )
40+
{
41+
AVDictionaryEntry* tag = NULL;
42+
while( ( tag = av_dict_get( avdictionnary, "", tag, AV_DICT_IGNORE_SUFFIX ) ) )
43+
{
44+
metadata.push_back( std::pair<std::string, std::string>( tag->key, tag->value ) );
45+
}
3146
}
3247

3348
}

src/AvTranscoder/Metadatas/MediaMetadatasStructures.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ namespace avtranscoder
1515
*/
1616
typedef std::vector< std::pair<std::string, std::string> > MetadatasMap;
1717

18+
namespace detail
19+
{
20+
/**
21+
* @brief Fill metadata parameter with the given AVDictionary.
22+
*/
23+
void fillMetadataDictionnary( AVDictionary* avdictionnary, MetadatasMap& metadata );
24+
}
25+
1826
struct Channel
1927
{
2028
size_t id;

0 commit comments

Comments
 (0)
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