Skip to content

Commit bc363a0

Browse files
author
Clement Champetier
committed
Remove DataStream class
* Duplicate with Frame class. * Add a typedef of Frame, CodedData, to represent buffer of coded data.
1 parent aaa0944 commit bc363a0

22 files changed

+59
-92
lines changed

app/avTranscoder/avTranscoder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
#include <AvTranscoder/file/InputFile.hpp>
66
#include <AvTranscoder/file/OutputFile.hpp>
7+
8+
#include <AvTranscoder/frame/Frame.hpp>
9+
710
#include <AvTranscoder/essenceStream/AvInputAudio.hpp>
811
#include <AvTranscoder/essenceStream/AvInputVideo.hpp>
912
#include <AvTranscoder/essenceStream/AvOutputAudio.hpp>
1013
#include <AvTranscoder/essenceStream/AvOutputVideo.hpp>
14+
1115
#include <AvTranscoder/transform/VideoTransform.hpp>
1216

1317
#include <AvTranscoder/progress/ConsoleProgress.hpp>
@@ -36,7 +40,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )
3640
outputVideo.setProfile( profile.getProfile( "xdcamhd422" ), VideoFrameDesc );
3741
VideoFrame imageToEncode( outputVideo.getVideoCodec().getVideoFrameDesc() );
3842

39-
DataStream codedImage;
43+
CodedData codedImage;
4044

4145
// setup wrapper
4246
//mxftkwrapper::MxftkOutputFile of( outputFilename );

src/AvTranscoder/avTranscoder.i

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <AvTranscoder/codec/VideoCodec.hpp>
2626
#include <AvTranscoder/codec/AudioCodec.hpp>
2727
#include <AvTranscoder/codec/DataCodec.hpp>
28-
#include <AvTranscoder/codec/DataStream.hpp>
2928

3029
#include <AvTranscoder/mediaProperty/mediaProperty.hpp>
3130

@@ -80,8 +79,6 @@ namespace std {
8079
%include <AvTranscoder/codec/VideoCodec.hpp>
8180
%include <AvTranscoder/codec/AudioCodec.hpp>
8281
%include <AvTranscoder/codec/DataCodec.hpp>
83-
%include <AvTranscoder/codec/DataStream.hpp>
84-
8582

8683
%include <AvTranscoder/mediaProperty/mediaProperty.hpp>
8784

src/AvTranscoder/codec/DataStream.hpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/AvTranscoder/codedStream/AvInputStream.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ AvInputStream::~AvInputStream( )
4040
{
4141
}
4242

43-
bool AvInputStream::readNextPacket( DataStream& data )
43+
bool AvInputStream::readNextPacket( CodedData& data )
4444
{
4545
if( ! _bufferized )
4646
throw std::runtime_error( "Can't read packet on non-bufferized input stream." );
@@ -61,7 +61,7 @@ bool AvInputStream::readNextPacket( DataStream& data )
6161
void AvInputStream::addPacket( AVPacket& packet )
6262
{
6363
//std::cout << "add packet for stream " << _streamIndex << std::endl;
64-
DataStream data;
64+
CodedData data;
6565
_streamCache.push_back( data );
6666
_packetDuration = packet.duration;
6767

@@ -78,7 +78,7 @@ void AvInputStream::addPacket( AVPacket& packet )
7878
// &tmpData[0] = packet.data;
7979
// tmpData.size( packet.size );
8080

81-
// remove reference on packet because it's passed to DataStream
81+
// remove reference on packet because it's passed to CodedData
8282
// packet.data = NULL;
8383
// packet.size = 0;
8484

src/AvTranscoder/codedStream/AvInputStream.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#define _AV_TRANSCODER_CODED_STREAM_AV_INPUT_STREAM_HPP_
33

44
#include "IInputStream.hpp"
5-
6-
#include <AvTranscoder/codec/DataStream.hpp>
5+
#include <AvTranscoder/frame/Frame.hpp>
76

87
struct AVStream;
98

@@ -28,7 +27,7 @@ class AvExport AvInputStream : public IInputStream
2827

2928
size_t getStreamIndex() const { return _streamIndex; }
3029

31-
bool readNextPacket( DataStream& data );
30+
bool readNextPacket( CodedData& data );
3231

3332
// Stream properties
3433
VideoCodec getVideoCodec() const;
@@ -52,7 +51,7 @@ class AvExport AvInputStream : public IInputStream
5251

5352
private:
5453
InputFile* _inputFile;
55-
std::vector<DataStream> _streamCache;
54+
std::vector<CodedData> _streamCache;
5655

5756
VideoCodec _videoDesc;
5857
AudioCodec _audioDesc;

src/AvTranscoder/codedStream/AvOutputStream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ AvOutputStream::~AvOutputStream()
1818
{
1919
}
2020

21-
bool AvOutputStream::wrap( DataStream& data )
21+
bool AvOutputStream::wrap( CodedData& data )
2222
{
2323
assert( _outputFile != NULL );
2424

src/AvTranscoder/codedStream/AvOutputStream.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _AV_TRANSCODER_CODED_STREAM_AV_OUTPUT_STREAM_HPP_
33

44
#include "IOutputStream.hpp"
5+
#include <AvTranscoder/frame/Frame.hpp>
56

67
namespace avtranscoder
78
{
@@ -23,7 +24,7 @@ class AvExport AvOutputStream : public IOutputStream
2324

2425
size_t getStreamIndex() const { return _streamIndex; }
2526

26-
bool wrap( DataStream& data );
27+
bool wrap( CodedData& data );
2728

2829
// Stream propeerties
2930
VideoCodec getVideoCodec() const;

src/AvTranscoder/codedStream/IInputStream.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef _AV_TRANSCODER_CODED_STREAM_I_INPUT_STREAM_HPP_
22
#define _AV_TRANSCODER_CODED_STREAM_I_INPUT_STREAM_HPP_
33

4-
#include <AvTranscoder/codec/DataStream.hpp>
54
#include <AvTranscoder/codec/AudioCodec.hpp>
65
#include <AvTranscoder/codec/VideoCodec.hpp>
76
#include <AvTranscoder/codec/DataCodec.hpp>
7+
#include <AvTranscoder/frame/Frame.hpp>
88

99
namespace avtranscoder
1010
{
@@ -16,7 +16,7 @@ class IInputStream
1616

1717
virtual size_t getStreamIndex() const = 0;
1818

19-
virtual bool readNextPacket( DataStream& data ) = 0;
19+
virtual bool readNextPacket( CodedData& data ) = 0;
2020

2121
// Stream properties
2222
virtual VideoCodec getVideoCodec() const = 0;

src/AvTranscoder/codedStream/IOutputStream.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef _AV_TRANSCODER_CODED_STREAM_I_OUTPUT_STREAM_HPP_
22
#define _AV_TRANSCODER_CODED_STREAM_I_OUTPUT_STREAM_HPP_
33

4-
#include <AvTranscoder/codec/DataStream.hpp>
54
#include <AvTranscoder/codec/AudioCodec.hpp>
65
#include <AvTranscoder/codec/VideoCodec.hpp>
6+
#include <AvTranscoder/frame/Frame.hpp>
77

88
namespace avtranscoder
99
{
@@ -15,7 +15,7 @@ class IOutputStream
1515

1616
virtual size_t getStreamIndex() const = 0;
1717

18-
virtual bool wrap( DataStream& data ) = 0;
18+
virtual bool wrap( CodedData& data ) = 0;
1919

2020
// Stream properties
2121
virtual VideoCodec getVideoCodec() const = 0;

src/AvTranscoder/essenceStream/AvInputAudio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ bool AvInputAudio::getNextFrame()
180180
int got_frame = 0;
181181
while( ! got_frame )
182182
{
183-
DataStream data;
183+
CodedData data;
184184
if( ! _inputStream->readNextPacket( data ) ) // error or end of file
185185
return false;
186186

src/AvTranscoder/essenceStream/AvInputVideo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool AvInputVideo::readNextFrame( Frame& frameBuffer )
102102

103103
while( ! got_frame )
104104
{
105-
DataStream data;
105+
CodedData data;
106106
if( ! _inputStream->readNextPacket( data ) )
107107
return false;
108108

src/AvTranscoder/essenceStream/AvOutputAudio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void AvOutputAudio::setup()
4545
}
4646
}
4747

48-
bool AvOutputAudio::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame )
48+
bool AvOutputAudio::encodeFrame( const Frame& sourceFrame, Frame& codedFrame )
4949
{
5050
#if LIBAVCODEC_VERSION_MAJOR > 54
5151
AVFrame* frame = av_frame_alloc();
@@ -139,7 +139,7 @@ bool AvOutputAudio::encodeFrame( const Frame& sourceFrame, DataStream& codedFram
139139
return ret == 0;
140140
}
141141

142-
bool AvOutputAudio::encodeFrame( DataStream& codedFrame )
142+
bool AvOutputAudio::encodeFrame( Frame& codedFrame )
143143
{
144144
AVCodecContext* codecContext = _codedDesc.getAVCodecContext();
145145

src/AvTranscoder/essenceStream/AvOutputAudio.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
#include "IOutputEssence.hpp"
55

6-
#include <AvTranscoder/codec/DataStream.hpp>
76
#include <AvTranscoder/codec/AudioCodec.hpp>
8-
#include <AvTranscoder/frame/AudioFrame.hpp>
9-
7+
#include <AvTranscoder/frame/Frame.hpp>
108
#include <AvTranscoder/Profile.hpp>
119

1210
namespace avtranscoder
@@ -22,12 +20,12 @@ class AvOutputAudio : public IOutputEssence
2220
/**
2321
* @param[out] codedFrame
2422
*/
25-
bool encodeFrame( const Frame& sourceFrame, DataStream& codedFrame );
23+
bool encodeFrame( const Frame& sourceFrame, Frame& codedFrame );
2624

2725
/**
2826
* get delayed encoded frames
2927
*/
30-
bool encodeFrame( DataStream& codedFrame );
28+
bool encodeFrame( Frame& codedFrame );
3129

3230
void setProfile( const Profile::ProfileDesc& desc, const AudioFrameDesc& frameDesc );
3331

src/AvTranscoder/essenceStream/AvOutputVideo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void AvOutputVideo::setup( )
4747
}
4848

4949

50-
bool AvOutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame )
50+
bool AvOutputVideo::encodeFrame( const Frame& sourceFrame, Frame& codedFrame )
5151
{
5252
#if LIBAVCODEC_VERSION_MAJOR > 54
5353
AVFrame* frame = av_frame_alloc();
@@ -140,7 +140,7 @@ bool AvOutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFram
140140
return ret == 0;
141141
}
142142

143-
bool AvOutputVideo::encodeFrame( DataStream& codedFrame )
143+
bool AvOutputVideo::encodeFrame( Frame& codedFrame )
144144
{
145145
AVCodecContext* codecContext = _codedDesc.getAVCodecContext();
146146

src/AvTranscoder/essenceStream/AvOutputVideo.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
#include "IOutputEssence.hpp"
55

6-
#include <AvTranscoder/codec/DataStream.hpp>
76
#include <AvTranscoder/codec/VideoCodec.hpp>
8-
#include <AvTranscoder/frame/VideoFrame.hpp>
9-
7+
#include <AvTranscoder/frame/Frame.hpp>
108
#include <AvTranscoder/Profile.hpp>
119

1210
namespace avtranscoder
@@ -22,12 +20,12 @@ class AvExport AvOutputVideo : public IOutputEssence
2220
/**
2321
* @param[out] codedFrame blabla
2422
*/
25-
bool encodeFrame( const Frame& sourceFrame, DataStream& codedFrame );
23+
bool encodeFrame( const Frame& sourceFrame, Frame& codedFrame );
2624

2725
/**
2826
* get delayed encoded frames
2927
*/
30-
bool encodeFrame( DataStream& codedFrame );
28+
bool encodeFrame( Frame& codedFrame );
3129

3230
void setProfile( const Profile::ProfileDesc& desc, const avtranscoder::VideoFrameDesc& frameDesc );
3331

src/AvTranscoder/essenceStream/IOutputEssence.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define _AV_TRANSCODER_ESSENCE_STREAM_IOUTPUT_ESSENCE_HPP_
33

44
#include <AvTranscoder/frame/Frame.hpp>
5-
#include <AvTranscoder/codec/DataStream.hpp>
65
#include <AvTranscoder/codec/ICodec.hpp>
76

87
namespace avtranscoder
@@ -29,14 +28,14 @@ class AvExport IOutputEssence
2928
* @param codedFrame data of the coded frame if present (first frames can be delayed)
3029
* @return status of encoding
3130
*/
32-
virtual bool encodeFrame( const Frame& sourceFrame, DataStream& codedFrame ) = 0;
31+
virtual bool encodeFrame( const Frame& sourceFrame, Frame& codedFrame ) = 0;
3332

3433
/**
3534
* @brief Get delayed encoded frames
3635
* @param codedFrame data of the coded frame if present (first frames can be delayed)
3736
* @return status of encoding
3837
*/
39-
virtual bool encodeFrame( DataStream& codedFrame ) = 0;
38+
virtual bool encodeFrame( Frame& codedFrame ) = 0;
4039

4140
ICodec& getCodedDesc() { return _codedDesc; }
4241

src/AvTranscoder/file/InputFile.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <AvTranscoder/common.hpp>
55

6-
#include <AvTranscoder/codec/DataStream.hpp>
76
#include <AvTranscoder/codec/AudioCodec.hpp>
87
#include <AvTranscoder/codec/VideoCodec.hpp>
98

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ bool OutputFile::beginWrap( )
150150
return true;
151151
}
152152

153-
bool OutputFile::wrap( const DataStream& data, const size_t streamId )
153+
bool OutputFile::wrap( const CodedData& data, const size_t streamId )
154154
{
155155
if( ! data.getSize() )
156156
return true;

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include <AvTranscoder/mediaProperty/mediaProperty.hpp>
77

8-
#include <AvTranscoder/codec/DataStream.hpp>
98
#include <AvTranscoder/codec/VideoCodec.hpp>
109
#include <AvTranscoder/codec/AudioCodec.hpp>
1110
#include <AvTranscoder/codec/DataCodec.hpp>
@@ -87,7 +86,7 @@ class AvExport OutputFile
8786
* @param data coded packet information for the current stream
8887
* @param streamId refers to the stream in output ressource
8988
**/
90-
virtual bool wrap( const DataStream& data, const size_t streamId );
89+
virtual bool wrap( const CodedData& data, const size_t streamId );
9190

9291
/**
9392
* @brief Finalize the end of the wrapping

src/AvTranscoder/frame/Frame.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class AvExport Frame
2828
DataBuffer _dataBuffer;
2929
};
3030

31+
// Typedef to represent buffer of coded data.
32+
// Example 1: in case of image, no sense to get size if coded data.
33+
// Example 2: in case of audio, no sense to get number of channels if coded data.
34+
typedef Frame CodedData;
35+
3136
}
3237

3338
#endif

0 commit comments

Comments
 (0)