Skip to content

Commit 2b5d09e

Browse files
author
Clement Champetier
committed
IInputStream: refactore order of functions
* Getters and setters together. * Same thing for its implementation.
1 parent 456cff2 commit 2b5d09e

File tree

3 files changed

+39
-31
lines changed

3 files changed

+39
-31
lines changed

src/AvTranscoder/codedStream/AvInputStream.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ bool AvInputStream::readNextPacket( CodedData& data )
8989
return true;
9090
}
9191

92-
void AvInputStream::addPacket( AVPacket& packet )
93-
{
94-
// Do not cache data if the stream is declared as unused in process
95-
if( ! _isActivated )
96-
return;
97-
98-
CodedData data;
99-
_streamCache.push( data );
100-
_streamCache.back().copyData( packet.data, packet.size );
101-
}
102-
10392
VideoCodec& AvInputStream::getVideoCodec()
10493
{
10594
assert( _streamIndex <= _inputFile->getAVFormatContext().nb_streams );
@@ -146,6 +135,17 @@ double AvInputStream::getDuration() const
146135
return 1.0 * _inputFile->getAVFormatContext().duration / AV_TIME_BASE;
147136
}
148137

138+
void AvInputStream::addPacket( AVPacket& packet )
139+
{
140+
// Do not cache data if the stream is declared as unused in process
141+
if( ! _isActivated )
142+
return;
143+
144+
CodedData data;
145+
_streamCache.push( data );
146+
_streamCache.back().copyData( packet.data, packet.size );
147+
}
148+
149149
void AvInputStream::clearBuffering()
150150
{
151151
_streamCache = std::queue<CodedData>();

src/AvTranscoder/codedStream/AvInputStream.hpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,27 @@ class AvExport AvInputStream : public IInputStream
1717
public:
1818
AvInputStream( InputFile& inputFile, const size_t streamIndex );
1919
AvInputStream( const AvInputStream& inputStream );
20-
2120
~AvInputStream( );
2221

23-
size_t getStreamIndex() const { return _streamIndex; }
24-
2522
bool readNextPacket( CodedData& data );
2623

27-
// Stream properties
24+
size_t getStreamIndex() const { return _streamIndex; }
25+
double getDuration() const;
26+
AVMediaType getStreamType() const;
27+
2828
VideoCodec& getVideoCodec();
2929
AudioCodec& getAudioCodec();
3030
DataCodec& getDataCodec();
3131

32-
AVMediaType getStreamType() const;
33-
34-
double getDuration() const;
35-
36-
void addPacket( AVPacket& packet );
37-
32+
//@{
33+
/**
34+
* @brief Functions about buffering
35+
*/
3836
void activate( const bool activate = true ){ _isActivated = activate; };
3937
bool isActivated() const { return _isActivated; };
40-
38+
void addPacket( AVPacket& packet );
4139
void clearBuffering();
40+
//@}
4241

4342
private:
4443
AVStream* getAVStream() const;

src/AvTranscoder/codedStream/IInputStream.hpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,33 @@ class IInputStream
1414
public:
1515
virtual ~IInputStream() {};
1616

17-
virtual size_t getStreamIndex() const = 0;
18-
17+
/**
18+
* @brief Read the next packet of the stream
19+
* @param data: data of next packet read
20+
* @return if next packet was read succefully
21+
**/
1922
virtual bool readNextPacket( CodedData& data ) = 0;
2023

21-
// Stream properties
24+
virtual size_t getStreamIndex() const = 0;
25+
virtual double getDuration() const = 0;
26+
virtual AVMediaType getStreamType() const = 0;
27+
28+
//@{
29+
/**
30+
* Return the codec informations of the stream
31+
* @exception Raise a runtime error if the stream is not of the corresponding type
32+
*/
2233
virtual VideoCodec& getVideoCodec() = 0;
2334
virtual AudioCodec& getAudioCodec() = 0;
2435
virtual DataCodec& getDataCodec() = 0;
25-
26-
virtual AVMediaType getStreamType() const = 0;
27-
28-
virtual double getDuration() const = 0;
36+
//@}
2937

38+
/**
39+
* @brief Activate the stream will buffered its data when read packets.
40+
**/
3041
virtual void activate( const bool activate = true ) = 0;
3142
virtual bool isActivated() const = 0;
32-
3343
virtual void clearBuffering() = 0;
34-
3544
};
3645

3746
}

0 commit comments

Comments
 (0)