Skip to content

Commit 0b7fbdc

Browse files
author
Clement Champetier
committed
InputFile/OutputFile: can get format name/long name/mime type
* Fix #193
1 parent 9f75cb9 commit 0b7fbdc

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

src/AvTranscoder/file/InputFile.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,28 @@ InputStream& InputFile::getStream( size_t index )
116116
}
117117
}
118118

119+
120+
std::string InputFile::getFormatName() const
121+
{
122+
if( _formatContext.getAVInputFormat().name == NULL )
123+
return "unknown";
124+
return std::string(_formatContext.getAVInputFormat().name);
125+
}
126+
127+
std::string InputFile::getFormatLongName() const
128+
{
129+
if( _formatContext.getAVInputFormat().long_name == NULL )
130+
return "unknown";
131+
return std::string(_formatContext.getAVInputFormat().long_name);
132+
}
133+
134+
std::string InputFile::getFormatMimeType() const
135+
{
136+
if( _formatContext.getAVInputFormat().mime_type == NULL )
137+
return "unknown";
138+
return std::string(_formatContext.getAVInputFormat().mime_type);
139+
}
140+
119141
double InputFile::getFps()
120142
{
121143
double fps = 1;

src/AvTranscoder/file/InputFile.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class AvExport InputFile
8080
**/
8181
InputStream& getStream( size_t index );
8282

83+
std::string getFormatName() const;
84+
std::string getFormatLongName() const;
85+
std::string getFormatMimeType() const;
86+
8387
FormatContext& getFormatContext() { return _formatContext; }
8488

8589
/**

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,27 @@ IOutputStream& OutputFile::getStream( const size_t streamId )
8585
return *_outputStreams.at( streamId );
8686
}
8787

88+
std::string OutputFile::getFormatName() const
89+
{
90+
if( _formatContext.getAVOutputFormat().name == NULL )
91+
return "unknown";
92+
return std::string(_formatContext.getAVOutputFormat().name);
93+
}
94+
95+
std::string OutputFile::getFormatLongName() const
96+
{
97+
if( _formatContext.getAVOutputFormat().long_name == NULL )
98+
return "unknown";
99+
return std::string(_formatContext.getAVOutputFormat().long_name);
100+
}
101+
102+
std::string OutputFile::getFormatMimeType() const
103+
{
104+
if( _formatContext.getAVOutputFormat().mime_type == NULL )
105+
return "unknown";
106+
return std::string(_formatContext.getAVOutputFormat().mime_type);
107+
}
108+
88109
bool OutputFile::beginWrap( )
89110
{
90111
LOG_DEBUG( "Begin wrap of OutputFile" )

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ class AvExport OutputFile : public IOutputFile
5353
void addMetadata( const std::string& key, const std::string& value );
5454

5555
IOutputStream& getStream( const size_t streamId );
56+
57+
std::string getFormatName() const;
58+
std::string getFormatLongName() const;
59+
std::string getFormatMimeType() const;
60+
5661
FormatContext& getFormatContext() { return _formatContext; }
5762

5863
/**

0 commit comments

Comments
 (0)