@@ -158,6 +158,21 @@ static GstFlowReturn gst_spectrum_transform_ip (GstBaseTransform * trans,
158158static gboolean gst_spectrum_setup (GstAudioFilter * base ,
159159 const GstAudioInfo * info );
160160
161+ #if defined (GSTREAMER_LITE ) && defined (OSX )
162+ gboolean gst_spectrum_setup_api (GstAudioFilter * base , const GstAudioInfo * info ,
163+ guint bps_user , guint bpf_user ) {
164+ GstSpectrum * spectrum = GST_SPECTRUM (base );
165+ spectrum -> bps_user = bps_user ;
166+ spectrum -> bpf_user = bpf_user ;
167+ return gst_spectrum_setup (base , info );
168+ }
169+
170+ GstFlowReturn
171+ gst_spectrum_transform_ip_api (GstBaseTransform * trans , GstBuffer * buffer ) {
172+ return gst_spectrum_transform_ip (trans , buffer );
173+ }
174+ #endif // GSTREAMER_LITE and OSX
175+
161176static void
162177gst_spectrum_class_init (GstSpectrumClass * klass )
163178{
@@ -251,6 +266,12 @@ gst_spectrum_init (GstSpectrum * spectrum)
251266 spectrum -> bands = DEFAULT_BANDS ;
252267 spectrum -> threshold = DEFAULT_THRESHOLD ;
253268
269+ #if defined (GSTREAMER_LITE ) && defined (OSX )
270+ spectrum -> bps_user = 0 ;
271+ spectrum -> bpf_user = 0 ;
272+ spectrum -> user_data = NULL ;
273+ #endif // GSTREAMER_LITE and OSX
274+
254275 g_mutex_init (& spectrum -> lock );
255276}
256277
@@ -714,10 +735,24 @@ gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime timestamp,
714735
715736 GST_DEBUG_OBJECT (spectrum , "preparing message, bands =%d " , spectrum -> bands );
716737
738+ #if defined (GSTREAMER_LITE ) && defined (OSX )
739+ // When running spectrum directly we cannot figure out time stamps, since we do not
740+ // have full pipeline. Caller will be responsible to handle time stamps.
741+ if (spectrum -> user_data != NULL ) {
742+ running_time = 0 ;
743+ stream_time = 0 ;
744+ } else {
745+ running_time = gst_segment_to_running_time (& trans -> segment , GST_FORMAT_TIME ,
746+ timestamp );
747+ stream_time = gst_segment_to_stream_time (& trans -> segment , GST_FORMAT_TIME ,
748+ timestamp );
749+ }
750+ #else // GSTREAMER_LITE and OSX
717751 running_time = gst_segment_to_running_time (& trans -> segment , GST_FORMAT_TIME ,
718752 timestamp );
719753 stream_time = gst_segment_to_stream_time (& trans -> segment , GST_FORMAT_TIME ,
720754 timestamp );
755+ #endif // GSTREAMER_LITE and OSX
721756 /* endtime is for backwards compatibility */
722757 endtime = stream_time + duration ;
723758
@@ -877,6 +912,12 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
877912 channels = GST_AUDIO_FILTER_CHANNELS (spectrum );
878913 bps = GST_AUDIO_FILTER_BPS (spectrum );
879914 bpf = GST_AUDIO_FILTER_BPF (spectrum );
915+ #ifdef OSX
916+ if (spectrum -> bps_user != 0 && spectrum -> bpf_user != 0 ) {
917+ bps = spectrum -> bps_user ;
918+ bpf = spectrum -> bpf_user ;
919+ }
920+ #endif // OSX
880921 output_channels = spectrum -> multi_channel ? channels : 1 ;
881922 max_value = (1UL << ((bps << 3 ) - 1 )) - 1 ;
882923 bands = spectrum -> bands ;
0 commit comments