static GstStateChangeReturn gst_two_lame_change_state (GstElement * element, GstStateChange transition) { GstTwoLame *twolame; GstStateChangeReturn result; twolame = GST_TWO_LAME (element); switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: twolame->last_flow = GST_FLOW_OK; twolame->last_ts = GST_CLOCK_TIME_NONE; twolame->eos_ts = GST_CLOCK_TIME_NONE; break; default: break; } result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_READY_TO_NULL: gst_two_lame_release_memory (twolame); break; default: break; } return result; }
static void gst_two_lame_finalize (GObject * obj) { gst_two_lame_release_memory (GST_TWO_LAME (obj)); G_OBJECT_CLASS (parent_class)->finalize (obj); }
static gboolean gst_two_lame_stop (GstAudioEncoder * enc) { GstTwoLame *twolame = GST_TWO_LAME (enc); GST_DEBUG_OBJECT (twolame, "stop"); gst_two_lame_release_memory (twolame); return TRUE; }
static gboolean gst_two_lame_set_format (GstAudioEncoder * enc, GstAudioInfo * info) { GstTwoLame *twolame; gint out_samplerate; gint version; GstCaps *othercaps; twolame = GST_TWO_LAME (enc); /* parameters already parsed for us */ twolame->samplerate = GST_AUDIO_INFO_RATE (info); twolame->num_channels = GST_AUDIO_INFO_CHANNELS (info); twolame->float_input = !GST_AUDIO_INFO_IS_INTEGER (info); /* but we might be asked to reconfigure, so reset */ gst_two_lame_release_memory (twolame); GST_DEBUG_OBJECT (twolame, "setting up twolame"); if (!gst_two_lame_setup (twolame)) goto setup_failed; out_samplerate = twolame_get_out_samplerate (twolame->glopts); if (out_samplerate == 0) goto zero_output_rate; if (out_samplerate != twolame->samplerate) { GST_WARNING_OBJECT (twolame, "output samplerate %d is different from incoming samplerate %d", out_samplerate, twolame->samplerate); } version = twolame_get_version (twolame->glopts); if (version == TWOLAME_MPEG2) version = 2; else version = 1; othercaps = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1, "mpegaudioversion", G_TYPE_INT, version, "layer", G_TYPE_INT, 2, "channels", G_TYPE_INT, twolame->mode == TWOLAME_MONO ? 1 : twolame->num_channels, "rate", G_TYPE_INT, out_samplerate, NULL); /* and use these caps */ gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (twolame), othercaps); gst_caps_unref (othercaps); /* report needs to base class: * hand one frame at a time, if we are pretty sure what a frame is */ if (out_samplerate == twolame->samplerate) { gst_audio_encoder_set_frame_samples_min (enc, 1152); gst_audio_encoder_set_frame_samples_max (enc, 1152); gst_audio_encoder_set_frame_max (enc, 1); } return TRUE; zero_output_rate: { GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS, (NULL), ("TwoLAME decided on a zero sample rate")); return FALSE; } setup_failed: { GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS, (_("Failed to configure TwoLAME encoder. Check your encoding parameters.")), (NULL)); return FALSE; } }