File tree Expand file tree Collapse file tree 5 files changed +29
-16
lines changed
src/AvTranscoder/EssenceStream Expand file tree Collapse file tree 5 files changed +29
-16
lines changed Original file line number Diff line number Diff line change @@ -24,20 +24,27 @@ OutputAudio::OutputAudio()
24
24
{
25
25
}
26
26
27
- bool OutputAudio::setup ()
27
+ void OutputAudio::setup ()
28
28
{
29
29
av_register_all (); // Warning: should be called only once
30
30
31
31
AVCodecContext* codecContext ( _audioDesc.getCodecContext () );
32
32
33
33
if ( codecContext == NULL )
34
- return false ;
34
+ {
35
+ throw std::runtime_error ( " could not allocate audio codec context" );
36
+ }
35
37
36
38
// try to open encoder with parameters.
37
- if ( avcodec_open2 ( codecContext, _audioDesc.getCodec (), NULL ) < 0 )
38
- return false ;
39
-
40
- return true ;
39
+ int ret = avcodec_open2 ( codecContext, _audioDesc.getCodec (), NULL );
40
+ if ( ret < 0 )
41
+ {
42
+ char err[250 ];
43
+ av_strerror ( ret, err, 250 );
44
+ std::string msg = " could not open audio encoder: " ;
45
+ msg += err;
46
+ throw std::runtime_error ( msg );
47
+ }
41
48
}
42
49
43
50
bool OutputAudio::encodeFrame ( const Frame& sourceFrame, DataStream& codedFrame )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class OutputAudio : public OutputEssence
17
17
public:
18
18
OutputAudio ();
19
19
20
- bool setup ();
20
+ void setup ();
21
21
22
22
/* *
23
23
* @param[out] codedFrame
Original file line number Diff line number Diff line change @@ -30,9 +30,8 @@ class AvExport OutputEssence
30
30
31
31
/* *
32
32
* @brief Setup the encoder
33
- * @return status of setup
34
33
*/
35
- virtual bool setup () = 0;
34
+ virtual void setup () = 0;
36
35
37
36
/* *
38
37
* @brief Encode a new frame, and get coded frame
Original file line number Diff line number Diff line change @@ -27,20 +27,27 @@ OutputVideo::OutputVideo( )
27
27
{
28
28
}
29
29
30
- bool OutputVideo::setup ( )
30
+ void OutputVideo::setup ( )
31
31
{
32
32
av_register_all (); // Warning: should be called only once
33
33
34
34
AVCodecContext* codecContext ( _videoDesc.getCodecContext () );
35
35
36
36
if ( codecContext == NULL )
37
- return false ;
37
+ {
38
+ throw std::runtime_error ( " could not allocate video codec context" );
39
+ }
38
40
39
41
// try to open encoder with parameters
40
- if ( avcodec_open2 ( codecContext, _videoDesc.getCodec (), NULL ) < 0 )
41
- return false ;
42
-
43
- return true ;
42
+ int ret = avcodec_open2 ( codecContext, _videoDesc.getCodec (), NULL );
43
+ if ( ret < 0 )
44
+ {
45
+ char err[250 ];
46
+ av_strerror ( ret, err, 250 );
47
+ std::string msg = " could not open video encoder: " ;
48
+ msg += err;
49
+ throw std::runtime_error ( msg );
50
+ }
44
51
}
45
52
46
53
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class AvExport OutputVideo : public OutputEssence
30
30
public:
31
31
OutputVideo ();
32
32
33
- bool setup ();
33
+ void setup ();
34
34
35
35
// void setVideoDesc( const VideoDesc& videoDesc );
36
36
You can’t perform that action at this time.
0 commit comments