gst_segment_init (&dvdemux->time_segment, GST_FORMAT_TIME);
}
-static void
-gst_dvdemux_add_video_pad (GstDVDemux * dvdemux)
+static GstPad *
+gst_dvdemux_add_pad (GstDVDemux * dvdemux, GstStaticPadTemplate * template)
{
- if (dvdemux->videosrcpad)
- return;
-
- dvdemux->videosrcpad =
- gst_pad_new_from_static_template (&video_src_temp, "video");
- gst_pad_set_query_function (dvdemux->videosrcpad,
- GST_DEBUG_FUNCPTR (gst_dvdemux_src_query));
- gst_pad_set_query_type_function (dvdemux->videosrcpad,
- GST_DEBUG_FUNCPTR (gst_dvdemux_get_src_query_types));
- gst_pad_set_event_function (dvdemux->videosrcpad,
- GST_DEBUG_FUNCPTR (gst_dvdemux_handle_src_event));
- gst_pad_use_fixed_caps (dvdemux->videosrcpad);
- gst_pad_set_active (dvdemux->videosrcpad, TRUE);
- gst_element_add_pad (GST_ELEMENT (dvdemux), dvdemux->videosrcpad);
-
- if (dvdemux->videosrcpad && dvdemux->audiosrcpad)
- gst_element_no_more_pads (GST_ELEMENT (dvdemux));
+ gboolean no_more_pads;
+ GstPad *pad;
- gst_pad_push_event (dvdemux->videosrcpad, gst_event_new_new_segment (FALSE,
- dvdemux->byte_segment.rate, GST_FORMAT_TIME,
- dvdemux->time_segment.start, dvdemux->time_segment.stop,
- dvdemux->time_segment.start));
-}
+ pad = gst_pad_new_from_static_template (template, template->name_template);
-static void
-gst_dvdemux_add_audio_pad (GstDVDemux * dvdemux)
-{
- if (dvdemux->audiosrcpad)
- return;
+ gst_pad_set_query_function (pad, GST_DEBUG_FUNCPTR (gst_dvdemux_src_query));
- dvdemux->audiosrcpad =
- gst_pad_new_from_static_template (&audio_src_temp, "audio");
- gst_pad_set_query_function (dvdemux->audiosrcpad,
- GST_DEBUG_FUNCPTR (gst_dvdemux_src_query));
- gst_pad_set_query_type_function (dvdemux->audiosrcpad,
+ gst_pad_set_query_type_function (pad,
GST_DEBUG_FUNCPTR (gst_dvdemux_get_src_query_types));
- gst_pad_set_event_function (dvdemux->audiosrcpad,
+ gst_pad_set_event_function (pad,
GST_DEBUG_FUNCPTR (gst_dvdemux_handle_src_event));
- gst_pad_use_fixed_caps (dvdemux->audiosrcpad);
- gst_pad_set_active (dvdemux->audiosrcpad, TRUE);
- gst_element_add_pad (GST_ELEMENT (dvdemux), dvdemux->audiosrcpad);
+ gst_pad_use_fixed_caps (pad);
+ gst_pad_set_active (pad, TRUE);
+ gst_element_add_pad (GST_ELEMENT (dvdemux), pad);
- if (dvdemux->videosrcpad && dvdemux->audiosrcpad)
+ no_more_pads =
+ (dvdemux->videosrcpad != NULL && template == &audio_src_temp) ||
+ (dvdemux->audiosrcpad != NULL && template == &video_src_temp);
+
+ if (no_more_pads)
gst_element_no_more_pads (GST_ELEMENT (dvdemux));
- gst_pad_push_event (dvdemux->audiosrcpad, gst_event_new_new_segment (FALSE,
+ gst_pad_push_event (pad, gst_event_new_new_segment (FALSE,
dvdemux->byte_segment.rate, GST_FORMAT_TIME,
dvdemux->time_segment.start, dvdemux->time_segment.stop,
dvdemux->time_segment.start));
+
+ if (no_more_pads) {
+ gst_element_found_tags (GST_ELEMENT (dvdemux),
+ gst_tag_list_new_full (GST_TAG_CONTAINER_FORMAT, "DV", NULL));
+ }
+
+ return pad;
}
static void
GstBuffer *outbuf;
gint frequency, channels;
- if (!dvdemux->audiosrcpad)
- gst_dvdemux_add_audio_pad (dvdemux);
+ if (dvdemux->audiosrcpad == NULL)
+ dvdemux->audiosrcpad = gst_dvdemux_add_pad (dvdemux, &audio_src_temp);
/* get initial format or check if format changed */
frequency = dv_get_frequency (dvdemux->decoder);
gboolean wide;
GstFlowReturn ret = GST_FLOW_OK;
- if (!dvdemux->videosrcpad)
- gst_dvdemux_add_video_pad (dvdemux);
+ if (dvdemux->videosrcpad == NULL)
+ dvdemux->videosrcpad = gst_dvdemux_add_pad (dvdemux, &video_src_temp);
/* get params */
/* framerate is already up-to-date */