static void theora_enc_finalize (GObject * object) { GstTheoraEnc *enc = GST_THEORA_ENC (object); GST_DEBUG_OBJECT (enc, "Finalizing"); if (enc->encoder) th_encode_free (enc->encoder); th_comment_clear (&enc->comment); th_info_clear (&enc->info); g_free (enc->multipass_cache_file); theora_enc_clear_multipass_cache (enc); G_OBJECT_CLASS (parent_class)->finalize (object); }
static gboolean theora_enc_finish (GstVideoEncoder * benc) { GstTheoraEnc *enc; ogg_packet op; enc = GST_THEORA_ENC (benc); if (enc->initialised) { /* push last packet with eos flag, should not be called */ while (th_encode_packetout (enc->encoder, 1, &op)) { theora_push_packet (enc, &op); } } if (enc->initialised && enc->multipass_cache_fd && enc->multipass_mode == MULTIPASS_MODE_FIRST_PASS) theora_enc_write_multipass_cache (enc, TRUE, TRUE); theora_enc_clear_multipass_cache (enc); return TRUE; }
static gboolean theora_enc_stop (GstVideoEncoder * benc) { GstTheoraEnc *enc; GST_DEBUG_OBJECT (benc, "stop: clearing theora state"); enc = GST_THEORA_ENC (benc); if (enc->encoder) th_encode_free (enc->encoder); enc->encoder = NULL; th_comment_clear (&enc->comment); th_info_clear (&enc->info); if (enc->input_state) gst_video_codec_state_unref (enc->input_state); enc->input_state = NULL; /* Everything else is handled in reset() */ theora_enc_clear_multipass_cache (enc); return TRUE; }
static gboolean theora_enc_sink_event (GstPad * pad, GstEvent * event) { GstTheoraEnc *enc; ogg_packet op; gboolean res; enc = GST_THEORA_ENC (GST_PAD_PARENT (pad)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_NEWSEGMENT: { gboolean update; gdouble rate, applied_rate; GstFormat format; gint64 start, stop, time; gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate, &format, &start, &stop, &time); gst_segment_set_newsegment_full (&enc->segment, update, rate, applied_rate, format, start, stop, time); res = gst_pad_push_event (enc->srcpad, event); break; } case GST_EVENT_EOS: if (enc->initialised) { /* push last packet with eos flag, should not be called */ while (th_encode_packetout (enc->encoder, 1, &op)) { GstClockTime next_time = th_granule_time (enc->encoder, op.granulepos) * GST_SECOND; theora_push_packet (enc, &op, GST_CLOCK_TIME_NONE, enc->next_ts, next_time - enc->next_ts); enc->next_ts = next_time; } } if (enc->initialised && enc->multipass_cache_fd && enc->multipass_mode == MULTIPASS_MODE_FIRST_PASS) theora_enc_write_multipass_cache (enc, TRUE, TRUE); theora_enc_clear_multipass_cache (enc); res = gst_pad_push_event (enc->srcpad, event); break; case GST_EVENT_FLUSH_STOP: gst_segment_init (&enc->segment, GST_FORMAT_UNDEFINED); res = gst_pad_push_event (enc->srcpad, event); break; case GST_EVENT_CUSTOM_DOWNSTREAM: { const GstStructure *s; s = gst_event_get_structure (event); if (gst_structure_has_name (s, "GstForceKeyUnit")) theora_enc_force_keyframe (enc); res = gst_pad_push_event (enc->srcpad, event); break; } default: res = gst_pad_push_event (enc->srcpad, event); break; } return res; }