static void mpegtsdemux_set_header_on_caps (MpegTsMux * mux) { GstBuffer *buf; GstStructure *structure; GValue array = { 0 }; GValue value = { 0 }; GstCaps *caps = GST_PAD_CAPS (mux->srcpad); GList *sh; caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); g_value_init (&array, GST_TYPE_ARRAY); sh = mux->streamheader; while (sh) { buf = sh->data; GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS); g_value_init (&value, GST_TYPE_BUFFER); gst_value_take_buffer (&value, buf); gst_value_array_append_value (&array, &value); g_value_unset (&value); sh = g_list_next (sh); } g_list_free (mux->streamheader); mux->streamheader = NULL; gst_structure_set_value (structure, "streamheader", &array); gst_pad_set_caps (mux->srcpad, caps); g_value_unset (&array); gst_caps_unref (caps); }
/* Can't use glib-genmarshal for this, as it doesn't know how to handle * GstMiniObject-based types, which are a new fundamental type */ static void gst_app_marshal_BUFFER__VOID (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) { typedef GstBuffer *(*GMarshalFunc_BUFFER__VOID) (gpointer data1, gpointer data2); register GMarshalFunc_BUFFER__VOID callback; register GCClosure *cc = (GCClosure *) closure; register gpointer data1, data2; GstBuffer *v_return; g_return_if_fail (return_value != NULL); g_return_if_fail (n_param_values == 1); if (G_CCLOSURE_SWAP_DATA (closure)) { data1 = closure->data; data2 = g_value_peek_pointer (param_values + 0); } else { data1 = g_value_peek_pointer (param_values + 0); data2 = closure->data; } callback = (GMarshalFunc_BUFFER__VOID) (marshal_data ? marshal_data : cc->callback); v_return = callback (data1, data2); gst_value_take_buffer (return_value, v_return); }
/* prepare the source pad for output */ static gboolean mpegpsdemux_prepare_srcpad (MpegPsMux * mux) { GstSegment segment; GValue val = { 0, }; GList *headers, *l; GstCaps *caps; caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 2, "systemstream", G_TYPE_BOOLEAN, TRUE, NULL); headers = psmux_get_stream_headers (mux->psmux); g_value_init (&val, GST_TYPE_ARRAY); for (l = headers; l != NULL; l = l->next) { GValue buf_val = { 0, }; g_value_init (&buf_val, GST_TYPE_BUFFER); gst_value_take_buffer (&buf_val, GST_BUFFER (l->data)); l->data = NULL; gst_value_array_append_value (&val, &buf_val); g_value_unset (&buf_val); } gst_caps_set_value (caps, "streamheader", &val); g_value_unset (&val); g_list_free (headers); /* Set caps on src pad and push new segment */ gst_pad_push_event (mux->srcpad, gst_event_new_caps (caps)); gst_caps_unref (caps); gst_segment_init (&segment, GST_FORMAT_BYTES); gst_pad_push_event (mux->srcpad, gst_event_new_segment (&segment)); return TRUE; }
static gboolean mpegpsdemux_prepare_srcpad (MpegPsMux * mux) { GValue val = { 0, }; GList *headers, *l; /* prepare the source pad for output */ GstEvent *new_seg = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0); GstCaps *caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 2, "systemstream", G_TYPE_BOOLEAN, TRUE, NULL); /* gst_static_pad_template_get_caps (&mpegpsmux_src_factory); */ headers = psmux_get_stream_headers (mux->psmux); g_value_init (&val, GST_TYPE_ARRAY); for (l = headers; l != NULL; l = l->next) { GValue buf_val = { 0, }; g_value_init (&buf_val, GST_TYPE_BUFFER); gst_value_take_buffer (&buf_val, GST_BUFFER (l->data)); l->data = NULL; gst_value_array_append_value (&val, &buf_val); g_value_unset (&buf_val); } gst_caps_set_value (caps, "streamheader", &val); g_value_unset (&val); g_list_free (headers); /* Set caps on src pad from our template and push new segment */ gst_pad_set_caps (mux->srcpad, caps); if (!gst_pad_push_event (mux->srcpad, new_seg)) { GST_WARNING_OBJECT (mux, "New segment event was not handled"); return FALSE; } return TRUE; }
GstCaps * gst_kate_util_set_header_on_caps (GstElement * element, GstCaps * caps, GList * headers) { GstStructure *structure; GValue array = { 0 }; GST_LOG_OBJECT (element, "caps: %" GST_PTR_FORMAT, caps); if (G_UNLIKELY (!caps)) return NULL; if (G_UNLIKELY (!headers)) return NULL; caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); g_value_init (&array, GST_TYPE_ARRAY); while (headers) { GValue value = { 0 }; GstBuffer *buffer = headers->data; g_assert (buffer); g_value_init (&value, GST_TYPE_BUFFER); buffer = gst_buffer_copy (buffer); GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_HEADER); gst_value_take_buffer (&value, buffer); gst_value_array_append_value (&array, &value); g_value_unset (&value); headers = headers->next; } gst_structure_take_value (structure, "streamheader", &array); GST_LOG_OBJECT (element, "here are the newly set caps: %" GST_PTR_FORMAT, caps); return caps; }