25
25
#include < ni/media/audio/iotools.h>
26
26
#include < ni/media/iostreams/positioning.h>
27
27
28
- #include < boost/algorithm/clamp.hpp>
29
- #include < boost/algorithm/cxx11/any_of.hpp>
30
- #include < boost/format.hpp>
31
28
#include < boost/make_unique.hpp>
32
29
33
30
#include < algorithm>
34
- #include < codecvt>
35
- #include < functional>
36
- #include < iostream>
37
- #include < locale>
38
-
39
31
#include < gst/app/gstappsink.h>
40
32
41
33
namespace detail
@@ -196,15 +188,21 @@ void gstreamer_file_source::fill_format_info( GstStructure*
196
188
m_info.lossless ( false );
197
189
198
190
gint64 num_frames = 0 ;
199
- gst_element_query_duration ( m_pipeline.get (), GST_FORMAT_DEFAULT, &num_frames );
191
+ if ( !gst_element_query_duration ( m_pipeline.get (), GST_FORMAT_DEFAULT, &num_frames ) )
192
+ throw std::runtime_error ( " gstreamer_file_source: could not query duration from gstreamer" );
193
+
200
194
m_info.num_frames ( num_frames );
201
195
202
196
int sample_rate = 0 ;
203
- gst_structure_get_int ( caps_struct, " rate" , &sample_rate );
197
+ if ( !gst_structure_get_int ( caps_struct, " rate" , &sample_rate ) )
198
+ throw std::runtime_error ( " gstreamer_file_source: could not query sample rate from gstreamer" );
199
+
204
200
m_info.sample_rate ( sample_rate );
205
201
206
202
int num_channels = 0 ;
207
- gst_structure_get_int ( caps_struct, " channels" , &num_channels );
203
+ if ( !gst_structure_get_int ( caps_struct, " channels" , &num_channels ) )
204
+ throw std::runtime_error ( " gstreamer_file_source: could not query number of channels from gstreamer" );
205
+
208
206
m_info.num_channels ( num_channels );
209
207
210
208
m_info.format ( create_runtime_format ( caps_struct ) );
@@ -214,11 +212,14 @@ void gstreamer_file_source::fill_format_info( GstStructure*
214
212
215
213
pcm::runtime_format gstreamer_file_source::create_runtime_format ( GstStructure* caps_struct )
216
214
{
217
- const gchar* format = gst_structure_get_string ( caps_struct, " format" );
218
- pcm::number_type number_type = gst_format_char_to_number_type ( format[0 ] );
219
- auto srcDepth = std::atol ( format + 1 );
220
- auto endian = ( strcmp ( format, " BE" ) == 0 ) ? pcm::big_endian : pcm::little_endian;
221
- return pcm::runtime_format ( number_type, srcDepth, endian );
215
+ if ( auto format = gst_structure_get_string ( caps_struct, " format" ) )
216
+ {
217
+ pcm::number_type number_type = gst_format_char_to_number_type ( format[0 ] );
218
+ auto srcDepth = std::atol ( format + 1 );
219
+ auto endian = ( strcmp ( format, " BE" ) == 0 ) ? pcm::big_endian : pcm::little_endian;
220
+ return pcm::runtime_format ( number_type, srcDepth, endian );
221
+ }
222
+ throw std::runtime_error ( " gstreamer_file_source: could not get runtime format from gstreamer caps" );
222
223
}
223
224
224
225
// ----------------------------------------------------------------------------------------------------------------------
0 commit comments