Skip to content

Commit c134cc6

Browse files
author
Clement Champetier
committed
InputFile: remove functions already available in AvInputStream
* AvInputStream: all functions return reference of objects (no pointer).
1 parent 2b5d09e commit c134cc6

File tree

5 files changed

+17
-35
lines changed

5 files changed

+17
-35
lines changed

src/AvTranscoder/codedStream/AvInputStream.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ VideoCodec& AvInputStream::getVideoCodec()
9393
{
9494
assert( _streamIndex <= _inputFile->getAVFormatContext().nb_streams );
9595

96-
if( getAVStream()->codec->codec_type != AVMEDIA_TYPE_VIDEO )
96+
if( getStreamType() != AVMEDIA_TYPE_VIDEO )
9797
{
9898
throw std::runtime_error( "unable to get video descriptor on non-video stream" );
9999
}
@@ -105,7 +105,7 @@ AudioCodec& AvInputStream::getAudioCodec()
105105
{
106106
assert( _streamIndex <= _inputFile->getAVFormatContext().nb_streams );
107107

108-
if( getAVStream()->codec->codec_type != AVMEDIA_TYPE_AUDIO )
108+
if( getStreamType() != AVMEDIA_TYPE_AUDIO )
109109
{
110110
throw std::runtime_error( "unable to get audio descriptor on non-audio stream" );
111111
}
@@ -117,7 +117,7 @@ DataCodec& AvInputStream::getDataCodec()
117117
{
118118
assert( _streamIndex <= _inputFile->getAVFormatContext().nb_streams );
119119

120-
if( getAVStream()->codec->codec_type != AVMEDIA_TYPE_DATA )
120+
if( getStreamType() != AVMEDIA_TYPE_DATA )
121121
{
122122
throw std::runtime_error( "unable to get data descriptor on non-data stream" );
123123
}
@@ -127,7 +127,7 @@ DataCodec& AvInputStream::getDataCodec()
127127

128128
AVMediaType AvInputStream::getStreamType() const
129129
{
130-
return _inputFile->getStreamType( _streamIndex );
130+
return getAVCodecContext().codec_type;
131131
}
132132

133133
double AvInputStream::getDuration() const
@@ -151,9 +151,14 @@ void AvInputStream::clearBuffering()
151151
_streamCache = std::queue<CodedData>();
152152
}
153153

154-
AVStream* AvInputStream::getAVStream() const
154+
AVStream& AvInputStream::getAVStream() const
155155
{
156-
return _inputFile->getAVFormatContext().streams[_streamIndex];
156+
return *_inputFile->getAVFormatContext().streams[_streamIndex];
157+
}
158+
159+
AVCodecContext& AvInputStream::getAVCodecContext() const
160+
{
161+
return *getAVStream().codec;
157162
}
158163

159164
}

src/AvTranscoder/codedStream/AvInputStream.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AvExport AvInputStream : public IInputStream
1616
{
1717
public:
1818
AvInputStream( InputFile& inputFile, const size_t streamIndex );
19-
AvInputStream( const AvInputStream& inputStream );
19+
AvInputStream( const AvInputStream& inputStream ); ///< Does not copy _streamCache
2020
~AvInputStream( );
2121

2222
bool readNextPacket( CodedData& data );
@@ -40,7 +40,8 @@ class AvExport AvInputStream : public IInputStream
4040
//@}
4141

4242
private:
43-
AVStream* getAVStream() const;
43+
AVStream& getAVStream() const;
44+
AVCodecContext& getAVCodecContext() const;
4445

4546
private:
4647
InputFile* _inputFile; ///< Has link (no ownership)

src/AvTranscoder/file/InputFile.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,6 @@ AvInputStream& InputFile::getStream( size_t index )
203203
}
204204
}
205205

206-
AVMediaType InputFile::getStreamType( size_t index )
207-
{
208-
if( index >= _formatContext->nb_streams )
209-
return AVMEDIA_TYPE_UNKNOWN;
210-
return _formatContext->streams[index]->codec->codec_type;
211-
}
212-
213-
bool InputFile::isStreamActivated( const size_t streamIndex )
214-
{
215-
return _inputStreams.at( streamIndex )->isActivated();
216-
}
217-
218206
void InputFile::setProfile( const ProfileLoader::Profile& profile )
219207
{
220208
Context formatContext( _formatContext, AV_OPT_FLAG_DECODING_PARAM );

src/AvTranscoder/file/InputFile.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@ class AvExport InputFile
8383
**/
8484
AvInputStream& getStream( size_t index );
8585

86-
/**
87-
* @brief Get stream type: video, audio, subtitle, etc.
88-
* @param index stream index
89-
* @return media stream type of specified index stream
90-
**/
91-
AVMediaType getStreamType( size_t index );
92-
93-
/**
94-
* @brief Indicate that the stream is activated
95-
**/
96-
bool isStreamActivated( const size_t streamIndex );
97-
9886
/**
9987
* @brief Get LibAV/FFmpeg AVFormatContext
10088
* @return format context on current InputFile

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
375375
// Add profile
376376
_profileLoader.update( profile );
377377

378-
switch( referenceFile->getStreamType( streamIndex ) )
378+
switch( referenceFile->getStream( streamIndex ).getStreamType() )
379379
{
380380
case AVMEDIA_TYPE_VIDEO:
381381
case AVMEDIA_TYPE_AUDIO:
@@ -397,7 +397,7 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
397397
{
398398
InputFile* referenceFile = addInputFile( filename, streamIndex );
399399

400-
switch( referenceFile->getStreamType( streamIndex ) )
400+
switch( referenceFile->getStream( streamIndex ).getStreamType() )
401401
{
402402
case AVMEDIA_TYPE_VIDEO:
403403
case AVMEDIA_TYPE_AUDIO:
@@ -440,7 +440,7 @@ InputFile* Transcoder::addInputFile( const std::string& filename, const size_t s
440440
for( std::vector< InputFile* >::iterator it = _inputFiles.begin(); it != _inputFiles.end(); ++it )
441441
{
442442
if( ( (*it)->getFilename() == filename ) &&
443-
( ! (*it)->isStreamActivated( streamIndex ) ) )
443+
( ! (*it)->getStream( streamIndex ).isActivated() ) )
444444
{
445445
referenceFile = (*it);
446446
break;

0 commit comments

Comments
 (0)