Skip to content

Commit 3839b06

Browse files
author
Clement Champetier
committed
2 parents 45dfa4c + 623d0a3 commit 3839b06

File tree

7 files changed

+47
-28
lines changed

7 files changed

+47
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can also use it in Java & Python for simpliest integration in projects.
99
#### Continuous Integration
1010

1111
###### Drone.io
12-
[![Build Status](https://drone.io/github.com/MarcAntoine-Arnaud/avTranscoder/status.png)](https://drone.io/github.com/MarcAntoine-Arnaud/avTranscoder/latest)
12+
[![Build Status](https://drone.io/github.com/avTranscoder/avTranscoder/status.png)](https://drone.io/github.com/avTranscoder/avTranscoder/latest)
1313

1414
#### Packaging
1515

app/SConscript

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,21 @@ if platform.system() != 'Windows':
9898
],
9999
)
100100

101-
avprofiles = env.Program(
102-
'avoptions',
103-
Glob( 'optionChecker/*.cpp' ),
104-
LIBS = [
105-
sAvTranscoder,
106-
'avutil',
107-
'avformat',
108-
'avcodec',
109-
'swscale',
110-
resampleLibraryName,
111-
],
112-
CXXFLAGS = [
113-
'-std=c++0x'
114-
],
115-
)
101+
avprofiles = env.Program(
102+
'avoptions',
103+
Glob( 'optionChecker/*.cpp' ),
104+
LIBS = [
105+
sAvTranscoder,
106+
'avutil',
107+
'avformat',
108+
'avcodec',
109+
'swscale',
110+
resampleLibraryName,
111+
],
112+
CXXFLAGS = [
113+
'-std=c++0x'
114+
],
115+
)
116116

117117
env.Depends( avmeta, sAvTranscoder )
118118

src/AvTranscoder/DatasStructures/AudioDesc.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern "C" {
1717
#include <iostream>
1818
#include <stdexcept>
1919
#include <sstream>
20+
#include <cassert>
2021

2122
namespace avtranscoder
2223
{
@@ -36,6 +37,13 @@ AudioDesc::AudioDesc( const AVCodecID codecId )
3637
setAudioCodec( codecId );
3738
}
3839

40+
AudioDesc::AudioDesc( const AudioDesc& audioDesc )
41+
: m_codec( NULL )
42+
, m_codecContext( NULL )
43+
{
44+
setAudioCodec( audioDesc.getAudioCodecId() );
45+
}
46+
3947
void AudioDesc::setAudioCodec( const std::string& codecName )
4048
{
4149
avcodec_register_all(); // Warning: should be called only once
@@ -186,32 +194,38 @@ void AudioDesc::set( const std::string& key, const std::string& value )
186194

187195
std::string AudioDesc::getAudioCodec() const
188196
{
197+
assert( m_codecContext != NULL );
189198
return m_codecContext->codec_name;
190199
}
191200

192201
AVCodecID AudioDesc::getAudioCodecId() const
193202
{
203+
assert( m_codecContext != NULL );
194204
return m_codecContext->codec_id;
195205
}
196206

197207

198208
const size_t AudioDesc::getSampleRate() const
199209
{
210+
assert( m_codecContext != NULL );
200211
return m_codecContext->sample_rate;
201212
}
202213

203214
const size_t AudioDesc::getChannels() const
204215
{
216+
assert( m_codecContext != NULL );
205217
return m_codecContext->channels;
206218
}
207219

208220
const AVSampleFormat AudioDesc::getSampleFormat() const
209221
{
222+
assert( m_codecContext != NULL );
210223
return m_codecContext->sample_fmt;
211224
}
212225

213226
AudioFrameDesc AudioDesc::getFrameDesc() const
214227
{
228+
assert( m_codecContext != NULL );
215229
AudioFrameDesc audioFrameDesc;
216230

217231
audioFrameDesc.setChannels( m_codecContext->channels );

src/AvTranscoder/DatasStructures/AudioDesc.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class AvExport AudioDesc
2525
public:
2626
AudioDesc( const std::string& codecName = "" );
2727
AudioDesc( const AVCodecID codecId );
28+
29+
AudioDesc( const AudioDesc& audioDesc );
2830

2931
void setAudioCodec( const std::string& codecName );
3032
void setAudioCodec( const AVCodecID codecId );

src/AvTranscoder/DatasStructures/VideoDesc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern "C" {
1616
#include <iostream>
1717
#include <stdexcept>
1818
#include <sstream>
19+
#include <cassert>
1920

2021
namespace avtranscoder
2122
{
@@ -76,16 +77,19 @@ void VideoDesc::setTimeBase( const size_t num, const size_t den, const size_t ti
7677

7778
std::string VideoDesc::getVideoCodec() const
7879
{
80+
assert( m_codecContext != NULL );
7981
return m_codecContext->codec_name;
8082
}
8183

8284
AVCodecID VideoDesc::getVideoCodecId() const
8385
{
86+
assert( m_codecContext != NULL );
8487
return m_codecContext->codec_id;
8588
}
8689

8790
std::pair< size_t, size_t > VideoDesc::getTimeBase() const
8891
{
92+
assert( m_codecContext != NULL );
8993
std::pair< size_t, size_t > timeBase;
9094
timeBase.first = m_codecContext->time_base.num;
9195
timeBase.second = m_codecContext->time_base.den;
@@ -221,6 +225,7 @@ void VideoDesc::set( const std::string& key, const std::string& value )
221225

222226
ImageDesc VideoDesc::getImageDesc() const
223227
{
228+
assert( m_codecContext != NULL );
224229
ImageDesc imageDesc;
225230
Pixel pixel( m_codecContext->pix_fmt );
226231

src/AvTranscoder/Transcoder/Transcoder.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ void Transcoder::addRewrapStream( const std::string& filename, const size_t stre
125125
{
126126
InputFile* referenceFile = addInputFile( filename, streamIndex );
127127

128-
StreamTranscoder* streamTranscoder = new StreamTranscoder( referenceFile->getStream( streamIndex ), _outputFile );
129-
_streamTranscoders.push_back( streamTranscoder );
128+
_streamTranscoders.push_back( new StreamTranscoder( referenceFile->getStream( streamIndex ), _outputFile ) );
130129
_inputStreams.push_back( &referenceFile->getStream( streamIndex ) );
131130
}
132131

@@ -138,15 +137,13 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
138137
{
139138
case AVMEDIA_TYPE_VIDEO:
140139
{
141-
StreamTranscoder* streamTranscoder = new StreamTranscoder( referenceFile->getStream( streamIndex ), _outputFile, profile );
142-
_streamTranscoders.push_back( streamTranscoder );
140+
_streamTranscoders.push_back( new StreamTranscoder( referenceFile->getStream( streamIndex ), _outputFile, profile ) );
143141
_inputStreams.push_back( &referenceFile->getStream( streamIndex ) );
144142
break;
145143
}
146144
case AVMEDIA_TYPE_AUDIO:
147145
{
148-
StreamTranscoder* streamTranscoder = new StreamTranscoder( referenceFile->getStream( streamIndex ), _outputFile, profile );
149-
_streamTranscoders.push_back( streamTranscoder );
146+
_streamTranscoders.push_back( new StreamTranscoder( referenceFile->getStream( streamIndex ), _outputFile, profile ) );
150147
_inputStreams.push_back( &referenceFile->getStream( streamIndex ) );
151148
break;
152149
}
@@ -167,16 +164,14 @@ void Transcoder::addDummyStream( Profile::ProfileDesc& profile )
167164

168165
if( profile.find( Profile::avProfileType )->second == Profile::avProfileTypeAudio )
169166
{
170-
DummyAudio* dummyAudio = new DummyAudio();
171-
StreamTranscoder* streamTranscoder = new StreamTranscoder( *dummyAudio, _outputFile, profile );
172-
_streamTranscoders.push_back( streamTranscoder );
167+
_dummyAudio.push_back( DummyAudio() );
168+
_streamTranscoders.push_back( new StreamTranscoder( _dummyAudio.back(), _outputFile, profile ) );
173169
}
174170

175171
if( profile.find( Profile::avProfileType )->second == Profile::avProfileTypeVideo )
176172
{
177-
DummyVideo* dummyVideo = new DummyVideo();
178-
StreamTranscoder* streamTranscoder = new StreamTranscoder( *dummyVideo, _outputFile, profile );
179-
_streamTranscoders.push_back( streamTranscoder );
173+
_dummyVideo.push_back( DummyVideo() );
174+
_streamTranscoders.push_back( new StreamTranscoder( _dummyVideo.back(), _outputFile, profile ) );
180175
}
181176
}
182177

src/AvTranscoder/Transcoder/Transcoder.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class Transcoder
6060
std::vector< InputStream* > _inputStreams;
6161
std::vector< StreamTranscoder* > _streamTranscoders;
6262

63+
std::vector< DummyAudio > _dummyAudio;
64+
std::vector< DummyVideo > _dummyVideo;
65+
6366
Profile _profile;
6467

6568
bool _verbose;

0 commit comments

Comments
 (0)