Skip to content

Commit 1002196

Browse files
Merge pull request #105 from cchampet/dev_pyTest
Add python nosetests
2 parents 6e6e9a7 + bae154c commit 1002196

24 files changed

+705
-134
lines changed

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@ before_script:
1212
- env | sort
1313
- date -u
1414
- uname -a
15-
15+
1616
- chmod +x tools/travis.linux.install.deps.sh
1717
- chmod +x tools/travis.osx.install.deps.sh
1818

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

2222
script:
23+
# Build
2324
- mkdir build
2425
- cd build
25-
- cmake ..
26-
- make
27-
26+
- cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/dist
27+
- make install
28+
# Launch tests
29+
- cd ..
30+
- chmod +x tools/travis.python.nosetests.sh
31+
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./tools/travis.python.nosetests.sh; fi

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ Based on LibAV/FFMpeg libraries to support various video formats, avTranscoder p
66

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

9-
#### Requirements
10-
* GitPython (>=0.3.2)
11-
129
#### Continuous Integration
1310

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

23+
#### Tests
24+
25+
###### nosetests
26+
Python tests using nosetests.
27+
28+
Create environment variables to use your files in tests.
29+
* AVTRANSCODER_TEST_AUDIO_FILE
30+
* AVTRANSCODER_TEST_VIDEO_FILE
31+
2632
#### Packaging
2733

2834
###### Build openSUSE

src/AvTranscoder/avTranscoder.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
%module AvTranscoder
1+
%module avtranscoder
22

3-
%module(directors="1") AvTranscoder
3+
%module(directors="1") avtranscoder
44

55
%include "std_string.i"
66
%include "std_vector.i"

src/AvTranscoder/codec/ICodec.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ ICodec::ICodec( const ECodecType type, const AVCodecID codecId )
2929

3030
ICodec::~ICodec()
3131
{
32-
avcodec_close( _codecContext );
33-
av_free( _codecContext );
34-
_codecContext = NULL;
32+
if( _codecContext && _codec )
33+
{
34+
avcodec_close( _codecContext );
35+
av_free( _codecContext );
36+
_codecContext = NULL;
37+
_codec = NULL;
38+
}
3539
}
3640

3741
std::string ICodec::getCodecName() const

src/AvTranscoder/codedStream/AvOutputStream.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ AvOutputStream::AvOutputStream( OutputFile& outputFile, const size_t streamIndex
1414
{
1515
}
1616

17-
AvOutputStream::~AvOutputStream()
18-
{
19-
}
20-
21-
bool AvOutputStream::wrap( CodedData& data )
17+
bool AvOutputStream::wrap( const CodedData& data )
2218
{
2319
assert( _outputFile != NULL );
24-
2520
return _outputFile->wrap( data, _streamIndex );
2621
}
2722

src/AvTranscoder/codedStream/AvOutputStream.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ class AvExport AvOutputStream : public IOutputStream
1313
public:
1414
AvOutputStream( OutputFile& outputFile, const size_t streamIndex );
1515

16-
~AvOutputStream( );
17-
1816
size_t getStreamIndex() const { return _streamIndex; }
1917

20-
bool wrap( CodedData& data );
18+
bool wrap( const CodedData& data );
2119

2220
private:
2321
OutputFile* _outputFile;

src/AvTranscoder/codedStream/IOutputStream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class IOutputStream
1515

1616
virtual size_t getStreamIndex() const = 0;
1717

18-
virtual bool wrap( CodedData& data ) = 0;
18+
virtual bool wrap( const CodedData& data ) = 0;
1919
};
2020

2121
}

src/AvTranscoder/essenceStream/GeneratorAudio.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,25 @@ namespace avtranscoder
55

66
GeneratorAudio::GeneratorAudio( )
77
: IInputEssence( )
8+
, _codec( NULL )
89
, _inputFrame( NULL )
9-
, _codec( eCodecTypeEncoder )
1010
, _frameDesc()
1111
{
1212
}
1313

14-
GeneratorAudio::~GeneratorAudio( )
15-
{
16-
}
17-
1814
void GeneratorAudio::setAudioCodec( const AudioCodec& codec )
1915
{
2016
_frameDesc.setFps ( 25.0 );
21-
_codec = codec;
17+
_codec = &codec;
2218

23-
_frameDesc.setSampleRate( _codec.getAVCodecContext()->sample_rate );
24-
_frameDesc.setChannels( _codec.getAVCodecContext()->channels );
25-
_frameDesc.setSampleFormat( _codec.getAVCodecContext()->sample_fmt );
19+
_frameDesc.setSampleRate( _codec->getAVCodecContext()->sample_rate );
20+
_frameDesc.setChannels( _codec->getAVCodecContext()->channels );
21+
_frameDesc.setSampleFormat( _codec->getAVCodecContext()->sample_fmt );
2622
}
2723

28-
AudioCodec& GeneratorAudio::getAudioCodec()
24+
const AudioCodec& GeneratorAudio::getAudioCodec()
2925
{
30-
return _codec;
26+
return *_codec;
3127
}
3228

3329
void GeneratorAudio::setFrame( Frame& inputFrame )

src/AvTranscoder/essenceStream/GeneratorAudio.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ class AvExport GeneratorAudio : public IInputEssence
1212
public:
1313
GeneratorAudio( );
1414

15-
~GeneratorAudio( );
16-
1715
void setAudioCodec( const AudioCodec& codec );
1816

19-
AudioCodec& getAudioCodec();
17+
const AudioCodec& getAudioCodec();
2018

2119
void setup() {}
2220

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

2826
private:
29-
AudioCodec _codec;
30-
AudioFrameDesc _frameDesc;
31-
27+
const AudioCodec* _codec;
3228
Frame* _inputFrame;
29+
AudioFrameDesc _frameDesc;
3330
};
3431

3532
}

src/AvTranscoder/essenceStream/GeneratorVideo.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,22 @@ namespace avtranscoder
77

88
GeneratorVideo::GeneratorVideo( )
99
: IInputEssence( )
10+
, _codec( NULL )
1011
, _inputFrame( NULL )
11-
, _codec( eCodecTypeEncoder )
1212
, _videoFrameDesc()
1313
, _numberOfView( 1 )
1414
{
1515
}
1616

17-
GeneratorVideo::~GeneratorVideo( )
18-
{
19-
}
20-
2117
void GeneratorVideo::setVideoCodec( const VideoCodec& codec )
2218
{
23-
_codec = codec;
24-
_videoFrameDesc = _codec.getVideoFrameDesc();
19+
_codec = &codec;
20+
_videoFrameDesc = _codec->getVideoFrameDesc();
2521
}
2622

27-
VideoCodec& GeneratorVideo::getVideoCodec()
23+
const VideoCodec& GeneratorVideo::getVideoCodec()
2824
{
29-
return _codec;
25+
return *_codec;
3026
}
3127

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

47-
VideoFrameDesc desc( _codec.getVideoFrameDesc() );
43+
VideoFrameDesc desc( _codec->getVideoFrameDesc() );
4844
Pixel rgbPixel;
4945
rgbPixel.setColorComponents( eComponentRgb );
5046
rgbPixel.setPlanar( false );

0 commit comments

Comments
 (0)