static gboolean audioresample_transform_size (GstBaseTransform * base, GstPadDirection direction, GstCaps * caps, guint size, GstCaps * othercaps, guint * othersize) { GstAudioresample *audioresample = GST_AUDIORESAMPLE (base); ResampleState *state; GstCaps *srccaps, *sinkcaps; gboolean use_internal = FALSE; /* whether we use the internal state */ gboolean ret = TRUE; GST_LOG_OBJECT (base, "asked to transform size %d in direction %s", size, direction == GST_PAD_SINK ? "SINK" : "SRC"); if (direction == GST_PAD_SINK) { sinkcaps = caps; srccaps = othercaps; } else { sinkcaps = othercaps; srccaps = caps; } /* if the caps are the ones that _set_caps got called with; we can use * our own state; otherwise we'll have to create a state */ if (gst_caps_is_equal (sinkcaps, audioresample->sinkcaps) && gst_caps_is_equal (srccaps, audioresample->srccaps)) { use_internal = TRUE; state = audioresample->resample; } else { GST_DEBUG_OBJECT (audioresample, "caps are not the set caps, creating state"); state = resample_new (); resample_set_filter_length (state, audioresample->filter_length); resample_set_state_from_caps (state, sinkcaps, srccaps, NULL, NULL, NULL); } if (direction == GST_PAD_SINK) { /* asked to convert size of an incoming buffer */ *othersize = resample_get_output_size_for_input (state, size); } else { /* asked to convert size of an outgoing buffer */ *othersize = resample_get_input_size_for_output (state, size); } g_assert (*othersize % state->sample_size == 0); /* we make room for one extra sample, given that the resampling filter * can output an extra one for non-integral i_rate/o_rate */ GST_LOG_OBJECT (base, "transformed size %d to %d", size, *othersize); if (!use_internal) { resample_free (state); } return ret; }
/* vmethods */ static gboolean audioresample_start (GstBaseTransform * base) { GstAudioresample *audioresample = GST_AUDIORESAMPLE (base); audioresample->resample = resample_new (); audioresample->ts_offset = -1; audioresample->offset = -1; audioresample->next_ts = -1; resample_set_filter_length (audioresample->resample, audioresample->filter_length); return TRUE; }
/* vmethods */ static gboolean legacyresample_start (GstBaseTransform * base) { GstLegacyresample *legacyresample = GST_LEGACYRESAMPLE (base); legacyresample->resample = resample_new (); legacyresample->ts_offset = -1; legacyresample->offset = -1; legacyresample->next_ts = -1; resample_set_filter_length (legacyresample->resample, legacyresample->filter_length); return TRUE; }