@@ -38,33 +38,34 @@ size_t AudioProperties::getStreamId() const
38
38
39
39
std::string AudioProperties::getCodecName () const
40
40
{
41
- if ( _codec && _codec->name )
42
- return std::string ( _codec-> name );
43
- return " unknown codec " ;
41
+ if ( ! _codec || ! _codec->name )
42
+ throw std::runtime_error ( " unknown codec name" );
43
+ return std::string ( _codec-> name ) ;
44
44
}
45
45
46
46
std::string AudioProperties::getCodecLongName () const
47
47
{
48
- if ( _codec && _codec->long_name )
49
- return std::string ( _codec-> long_name );
50
- return " unknown codec " ;
48
+ if ( ! _codec || ! _codec->long_name )
49
+ throw std::runtime_error ( " unknown codec long name " );
50
+ return std::string ( _codec-> long_name ) ;
51
51
}
52
52
53
53
std::string AudioProperties::getSampleFormatName () const
54
54
{
55
55
if ( ! _codecContext )
56
- return " unknown codec context" ;
56
+ throw std::runtime_error ( " unknown codec context" ) ;
57
57
58
58
const char * fmtName = av_get_sample_fmt_name ( _codecContext->sample_fmt );
59
- if ( fmtName )
60
- return std::string ( fmtName );
61
- return " unknown sample format" ;
59
+ if ( ! fmtName )
60
+ throw std::runtime_error ( " unknown sample format" );
61
+
62
+ return std::string ( fmtName );
62
63
}
63
64
64
65
std::string AudioProperties::getSampleFormatLongName () const
65
66
{
66
67
if ( ! _codecContext )
67
- return " unknown codec context" ;
68
+ throw std::runtime_error ( " unknown codec context" ) ;
68
69
69
70
switch ( _codecContext->sample_fmt )
70
71
{
@@ -99,7 +100,7 @@ std::string AudioProperties::getSampleFormatLongName() const
99
100
std::string AudioProperties::getChannelLayout () const
100
101
{
101
102
if ( ! _codecContext )
102
- return " unknown codec context" ;
103
+ throw std::runtime_error ( " unknown codec context" ) ;
103
104
104
105
char buf1[1024 ];
105
106
av_get_channel_layout_string ( buf1, sizeof ( buf1 ), -1 , _codecContext->channel_layout );
@@ -109,26 +110,27 @@ std::string AudioProperties::getChannelLayout() const
109
110
std::string AudioProperties::getChannelName () const
110
111
{
111
112
if ( ! _codecContext )
112
- return " unknown codec context" ;
113
+ throw std::runtime_error ( " unknown codec context" ) ;
113
114
114
115
const char * channelName = av_get_channel_name ( _codecContext->channel_layout );
115
- if ( channelName )
116
- return std::string ( channelName );
117
- return " unknown channel name" ;
116
+ if ( ! channelName )
117
+ throw std::runtime_error ( " unknown channel name" );
118
+
119
+ return std::string ( channelName );
118
120
}
119
121
120
122
std::string AudioProperties::getChannelDescription () const
121
123
{
122
124
if ( ! _codecContext )
123
- return " unknown codec context" ;
125
+ throw std::runtime_error ( " unknown codec context" ) ;
124
126
125
- #ifdef FF_RESAMPLE_LIBRARY
127
+ #ifdef AVTRANSCODER_FFMPEG_DEPENDENCY
126
128
const char * channelDescription = av_get_channel_description ( _codecContext->channel_layout );
127
- if ( channelDescription )
128
- return std::string ( channelDescription );
129
- return " unknown channel description " ;
129
+ if ( ! channelDescription )
130
+ throw std::runtime_error ( " unknown channel description " );
131
+ return std::string ( channelDescription ) ;
130
132
#else
131
- return " can't access channel description" ;
133
+ throw std::runtime_error ( " can't access channel description" ) ;
132
134
#endif
133
135
}
134
136
0 commit comments