Skip to content

Add python nosetests #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Oct 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
12c368e
PyTest: add testProperties
Sep 1, 2014
9a613f6
PyTest: add testTranscoder for dummy/rewrap/transcode
Sep 1, 2014
d2633b4
Merge branch 'master' of https://github.com/avTranscoder/avTranscoder…
Oct 6, 2014
c922917
Swig: rename AvTranscoder to avtranscoder
Oct 6, 2014
2a1aa88
Swig python: install __init__.py file
Oct 6, 2014
d4eeef1
Swig python: fix library name
Oct 6, 2014
7cea2f1
pyTest testProperties: fit to new API
Oct 6, 2014
5645fdd
pyTest testProperties: clean tests
Oct 6, 2014
c23d280
pyTest testTranscoderDummy: fit to new API
Oct 7, 2014
851d4e8
pyTest testTranscoderRewrap: fit to new API
Oct 7, 2014
9c16cc3
pyTest testTranscoderTranscode: fit to new API
Oct 7, 2014
4528be0
pyTest: use environment variables to use files in tests
Oct 7, 2014
c37387d
pyTest: comment tests which failed
Oct 7, 2014
2683fa1
Update README: add Tests section
Oct 7, 2014
fc0051b
Update README: remove Requirements section
Oct 7, 2014
2e32a5f
pyTest testTranscoderTranscode: add testTranscodeYUV420
Oct 7, 2014
aba8560
pyTest testTranscoderDummy: clean tests
Oct 7, 2014
a2463b1
Travis: launch python nosetests after build
Oct 7, 2014
776b9ca
pyTest testTranscoderRewrap: remove setProcessMethod
Oct 16, 2014
39ed040
Merge branch 'master' of https://github.com/avTranscoder/avTranscoder…
Oct 17, 2014
dc6bb8e
AvOuputStream: remove unnecessary destructor
Oct 17, 2014
6d781df
Generator Video/Audio: remove unnecessary destructors
Oct 17, 2014
0a98baa
OutputFile: remove unused variables
Oct 17, 2014
e431658
IOutputStream: wrap a const CodedData
Oct 17, 2014
bddc5f8
ICodec: close avcodec only if necessary in destructor
Oct 17, 2014
926d5c1
Transcoder / StreamTranscoder: refactoring
Oct 17, 2014
b0628c5
pyTest testTranscoderDummy: rename AudioDesc to AudioCodec
Oct 17, 2014
d8c2393
OutputFile: fix free avcodec_close
Oct 17, 2014
dbf16e5
pyTest testTranscoderRewrap: update output format
Oct 17, 2014
ae94f42
pyTest testTranscoderTranscode: comment video profile tests
Oct 17, 2014
314597c
pyTest testTranscoderRewrap: update testRewrapVideoStream
Oct 17, 2014
ef16095
Travis tests script: get assets from avTranscoder-data repository
Oct 17, 2014
9e8553e
Merge branch 'master' of https://github.com/avTranscoder/avTranscoder…
Oct 17, 2014
2889e7e
pyTest testTranscoderDummy: update avProfileIdentificator
Oct 17, 2014
83613eb
Travis: use the daily updated package for libav
Oct 20, 2014
5d0038e
Travis: install last version of libav
Oct 20, 2014
aa99dd2
Merge branch 'master' of https://github.com/avTranscoder/avTranscoder…
Oct 20, 2014
d9f2e08
Travis: fix launch nosetests after build (linux)
Oct 20, 2014
b849d53
Travis: launch nosetests after MacOS build
Oct 21, 2014
8a31d86
pyTest testTranscoderRewrap: check video and audio streams properties
Oct 22, 2014
5d1ebfd
Travis: fix launch nosetests after build (macos)
Oct 23, 2014
b08bead
pyTest testTranscoderRewrap: clean testRewrap Video/Audio stream
Oct 23, 2014
1887683
ICodec: fix free avcodec in destructor
Oct 23, 2014
bae154c
StreamTranscoder: clean constructor in case of generator essence
Oct 23, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ before_script:
- env | sort
- date -u
- uname -a

- chmod +x tools/travis.linux.install.deps.sh
- chmod +x tools/travis.osx.install.deps.sh

- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./tools/travis.linux.install.deps.sh; fi
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./tools/travis.osx.install.deps.sh; fi

script:
# Build
- mkdir build
- cd build
- cmake ..
- make

- cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/dist
- make install
# Launch tests
- cd ..
- chmod +x tools/travis.python.nosetests.sh
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./tools/travis.python.nosetests.sh; fi
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ Based on LibAV/FFMpeg libraries to support various video formats, avTranscoder p

You can also use its Java & Python bindings for simpler integration in your own projects.

#### Requirements
* GitPython (>=0.3.2)

#### Continuous Integration

###### Drone.io
Expand All @@ -23,6 +20,15 @@ You can also use its Java & Python bindings for simpler integration in your own
src="https://scan.coverity.com/projects/2626/badge.svg"/>
</a>

#### Tests

###### nosetests
Python tests using nosetests.

Create environment variables to use your files in tests.
* AVTRANSCODER_TEST_AUDIO_FILE
* AVTRANSCODER_TEST_VIDEO_FILE

#### Packaging

###### Build openSUSE
Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/avTranscoder.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%module AvTranscoder
%module avtranscoder

%module(directors="1") AvTranscoder
%module(directors="1") avtranscoder

%include "std_string.i"
%include "std_vector.i"
Expand Down
10 changes: 7 additions & 3 deletions src/AvTranscoder/codec/ICodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ ICodec::ICodec( const ECodecType type, const AVCodecID codecId )

ICodec::~ICodec()
{
avcodec_close( _codecContext );
av_free( _codecContext );
_codecContext = NULL;
if( _codecContext && _codec )
{
avcodec_close( _codecContext );
av_free( _codecContext );
_codecContext = NULL;
_codec = NULL;
}
}

std::string ICodec::getCodecName() const
Expand Down
7 changes: 1 addition & 6 deletions src/AvTranscoder/codedStream/AvOutputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ AvOutputStream::AvOutputStream( OutputFile& outputFile, const size_t streamIndex
{
}

AvOutputStream::~AvOutputStream()
{
}

bool AvOutputStream::wrap( CodedData& data )
bool AvOutputStream::wrap( const CodedData& data )
{
assert( _outputFile != NULL );

return _outputFile->wrap( data, _streamIndex );
}

Expand Down
4 changes: 1 addition & 3 deletions src/AvTranscoder/codedStream/AvOutputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ class AvExport AvOutputStream : public IOutputStream
public:
AvOutputStream( OutputFile& outputFile, const size_t streamIndex );

~AvOutputStream( );

size_t getStreamIndex() const { return _streamIndex; }

bool wrap( CodedData& data );
bool wrap( const CodedData& data );

private:
OutputFile* _outputFile;
Expand Down
2 changes: 1 addition & 1 deletion src/AvTranscoder/codedStream/IOutputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IOutputStream

virtual size_t getStreamIndex() const = 0;

virtual bool wrap( CodedData& data ) = 0;
virtual bool wrap( const CodedData& data ) = 0;
};

}
Expand Down
18 changes: 7 additions & 11 deletions src/AvTranscoder/essenceStream/GeneratorAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,25 @@ namespace avtranscoder

GeneratorAudio::GeneratorAudio( )
: IInputEssence( )
, _codec( NULL )
, _inputFrame( NULL )
, _codec( eCodecTypeEncoder )
, _frameDesc()
{
}

GeneratorAudio::~GeneratorAudio( )
{
}

void GeneratorAudio::setAudioCodec( const AudioCodec& codec )
{
_frameDesc.setFps ( 25.0 );
_codec = codec;
_codec = &codec;

_frameDesc.setSampleRate( _codec.getAVCodecContext()->sample_rate );
_frameDesc.setChannels( _codec.getAVCodecContext()->channels );
_frameDesc.setSampleFormat( _codec.getAVCodecContext()->sample_fmt );
_frameDesc.setSampleRate( _codec->getAVCodecContext()->sample_rate );
_frameDesc.setChannels( _codec->getAVCodecContext()->channels );
_frameDesc.setSampleFormat( _codec->getAVCodecContext()->sample_fmt );
}

AudioCodec& GeneratorAudio::getAudioCodec()
const AudioCodec& GeneratorAudio::getAudioCodec()
{
return _codec;
return *_codec;
}

void GeneratorAudio::setFrame( Frame& inputFrame )
Expand Down
9 changes: 3 additions & 6 deletions src/AvTranscoder/essenceStream/GeneratorAudio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ class AvExport GeneratorAudio : public IInputEssence
public:
GeneratorAudio( );

~GeneratorAudio( );

void setAudioCodec( const AudioCodec& codec );

AudioCodec& getAudioCodec();
const AudioCodec& getAudioCodec();

void setup() {}

Expand All @@ -26,10 +24,9 @@ class AvExport GeneratorAudio : public IInputEssence
bool readNextFrame( Frame& frameBuffer, const size_t subStreamIndex );

private:
AudioCodec _codec;
AudioFrameDesc _frameDesc;

const AudioCodec* _codec;
Frame* _inputFrame;
AudioFrameDesc _frameDesc;
};

}
Expand Down
16 changes: 6 additions & 10 deletions src/AvTranscoder/essenceStream/GeneratorVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@ namespace avtranscoder

GeneratorVideo::GeneratorVideo( )
: IInputEssence( )
, _codec( NULL )
, _inputFrame( NULL )
, _codec( eCodecTypeEncoder )
, _videoFrameDesc()
, _numberOfView( 1 )
{
}

GeneratorVideo::~GeneratorVideo( )
{
}

void GeneratorVideo::setVideoCodec( const VideoCodec& codec )
{
_codec = codec;
_videoFrameDesc = _codec.getVideoFrameDesc();
_codec = &codec;
_videoFrameDesc = _codec->getVideoFrameDesc();
}

VideoCodec& GeneratorVideo::getVideoCodec()
const VideoCodec& GeneratorVideo::getVideoCodec()
{
return _codec;
return *_codec;
}

void GeneratorVideo::setFrame( Frame& inputFrame )
Expand All @@ -44,7 +40,7 @@ bool GeneratorVideo::readNextFrame( Frame& frameBuffer )
if( frameBuffer.getSize() != _videoFrameDesc.getDataSize() )
frameBuffer.getBuffer().resize( _videoFrameDesc.getDataSize() );

VideoFrameDesc desc( _codec.getVideoFrameDesc() );
VideoFrameDesc desc( _codec->getVideoFrameDesc() );
Pixel rgbPixel;
rgbPixel.setColorComponents( eComponentRgb );
rgbPixel.setPlanar( false );
Expand Down
8 changes: 3 additions & 5 deletions src/AvTranscoder/essenceStream/GeneratorVideo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ class AvExport GeneratorVideo : public IInputEssence
public:
GeneratorVideo( );

~GeneratorVideo( );

// Stream properties
void setVideoCodec( const VideoCodec& codec );

VideoCodec& getVideoCodec();
const VideoCodec& getVideoCodec();

void setup() {}

Expand All @@ -27,8 +25,8 @@ class AvExport GeneratorVideo : public IInputEssence
bool readNextFrame( Frame& frameBuffer, const size_t subStreamIndex );

private:
Frame* _inputFrame;
VideoCodec _codec;
const VideoCodec* _codec;
Frame* _inputFrame;
VideoFrameDesc _videoFrameDesc;

size_t _numberOfView;
Expand Down
4 changes: 1 addition & 3 deletions src/AvTranscoder/file/OutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace avtranscoder
OutputFile::OutputFile( const std::string& filename )
: _outputFormat ( NULL )
, _formatContext ( NULL )
, _codec ( NULL )
, _codecContext ( NULL )
, _stream ( NULL )
, _filename ( filename )
, _packetCount ( 0 )
Expand Down Expand Up @@ -192,7 +190,7 @@ bool OutputFile::endWrap( )
{
throw std::runtime_error( "could not write trailer" );
}
avcodec_close( _stream->codec );

if( !( _formatContext->oformat->flags & AVFMT_NOFILE ) )
{
avio_close( _formatContext->pb );
Expand Down
2 changes: 0 additions & 2 deletions src/AvTranscoder/file/OutputFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ class AvExport OutputFile
AVOutputFormat* _outputFormat;
AVFormatContext* _formatContext;

AVCodec* _codec;
AVCodecContext* _codecContext;
AVStream* _stream;

std::vector<size_t> _frameCount;
Expand Down
84 changes: 45 additions & 39 deletions src/AvTranscoder/transcoder/StreamTranscoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ StreamTranscoder::StreamTranscoder(
}

StreamTranscoder::StreamTranscoder(
IInputEssence& inputEssence,
const ICodec& inputCodec,
OutputFile& outputFile,
const Profile::ProfileDesc& profile
)
: _inputStream( NULL )
, _outputStream( NULL )
, _sourceBuffer( NULL )
, _frameBuffer( NULL )
, _inputEssence( &inputEssence )
, _inputEssence( NULL )
, _generatorEssence( NULL )
, _currentEssence( NULL )
, _outputEssence( NULL )
Expand All @@ -189,66 +189,72 @@ StreamTranscoder::StreamTranscoder(

if( profile.find( constants::avProfileType )->second == constants::avProfileTypeVideo )
{
AvOutputVideo* outputVideo = new AvOutputVideo();

_outputEssence = outputVideo;

VideoFrameDesc inputFrameDesc = static_cast<GeneratorVideo*>( _inputEssence )->getVideoCodec().getVideoFrameDesc();

// Create input essence based on a given input VideoCodec
GeneratorVideo* generatorVideo = new GeneratorVideo();
const VideoCodec& inputVideoCodec = static_cast<const VideoCodec&>( inputCodec );
generatorVideo->setVideoCodec( inputVideoCodec );
_inputEssence = generatorVideo;

// Create inputFrame, and outputFrame which is based on a given profile
VideoFrameDesc inputFrameDesc = inputVideoCodec.getVideoFrameDesc();
VideoFrameDesc outputFrameDesc = inputFrameDesc;
outputFrameDesc.setParameters( profile );
_sourceBuffer = new VideoFrame( inputFrameDesc );
_frameBuffer = new VideoFrame( outputFrameDesc );

// Create output essence
AvOutputVideo* outputVideo = new AvOutputVideo();
outputVideo->setProfile( profile, outputFrameDesc );
_outputEssence = outputVideo;

// Create a video stream in the output file
_outputStream = &outputFile.addVideoStream( outputVideo->getVideoCodec() );
_sourceBuffer = new VideoFrame( inputFrameDesc );
_frameBuffer = new VideoFrame( outputFrameDesc );

_transform = new VideoTransform();

_currentEssence = _inputEssence;

return;
_currentEssence = _inputEssence;
}

if( profile.find( constants::avProfileType )->second == constants::avProfileTypeAudio )
else if( profile.find( constants::avProfileType )->second == constants::avProfileTypeAudio )
{
AvOutputAudio* outputAudio = new AvOutputAudio();

_outputEssence = outputAudio;

AudioFrameDesc inputFrameDesc = static_cast<GeneratorAudio*>( _inputEssence )->getAudioCodec().getFrameDesc();

// Create input essence based on a given input AudioCodec
GeneratorAudio* generatorAudio = new GeneratorAudio();
const AudioCodec& inputAudioCodec = static_cast<const AudioCodec&>( inputCodec );
generatorAudio->setAudioCodec( inputAudioCodec );
_inputEssence = generatorAudio;

// Create inputFrame, and outputFrame which is based on a given profile
AudioFrameDesc inputFrameDesc = inputAudioCodec.getFrameDesc();
AudioFrameDesc outputFrameDesc = inputFrameDesc;
outputFrameDesc.setParameters( profile );
_sourceBuffer = new AudioFrame( inputFrameDesc );
_frameBuffer = new AudioFrame( outputFrameDesc );

// Create output essence
AvOutputAudio* outputAudio = new AvOutputAudio();
outputAudio->setProfile( profile, outputFrameDesc );
_outputEssence = outputAudio;

// Create an audio stream in the output file
_outputStream = &outputFile.addAudioStream( outputAudio->getAudioCodec() );
_sourceBuffer = new AudioFrame( inputFrameDesc );
_frameBuffer = new AudioFrame( outputFrameDesc );

_transform = new AudioTransform();

_currentEssence = _inputEssence;
return;
}

throw std::runtime_error( "unupported stream type" );
else
{
throw std::runtime_error( "unupported stream type" );
}
}

StreamTranscoder::~StreamTranscoder()
{
if( _frameBuffer )
delete _frameBuffer;
if( _sourceBuffer )
delete _sourceBuffer;
if( _inputEssence && _inputStream )
delete _inputEssence;
if( _generatorEssence )
delete _generatorEssence;
if( _outputEssence )
delete _outputEssence;
if( _transform )
delete _transform;
delete _frameBuffer;
delete _sourceBuffer;
delete _generatorEssence;
delete _outputEssence;
delete _transform;
delete _inputEssence;
}

void StreamTranscoder::init()
Expand Down
Loading