ccextractor: Support changes of the caption type
https://bugzilla.gnome.org/show_bug.cgi?id=797370
This commit is contained in:
parent
3d8a0b8996
commit
7cfe6b0bf3
@ -224,31 +224,12 @@ gst_cc_extractor_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||||||
return gst_pad_event_default (pad, parent, event);
|
return gst_pad_event_default (pad, parent, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstCaps *
|
||||||
gst_cc_extractor_handle_meta (GstCCExtractor * filter, GstBuffer * buf,
|
create_caps_from_caption_type (GstVideoCaptionType caption_type)
|
||||||
GstVideoCaptionMeta * meta)
|
|
||||||
{
|
{
|
||||||
GstBuffer *outbuf = NULL;
|
|
||||||
GstEvent *event;
|
|
||||||
gchar *captionid;
|
|
||||||
GstFlowReturn flow;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (filter, "Handling meta");
|
|
||||||
|
|
||||||
/* Check if the meta type matches the configured one */
|
|
||||||
if (filter->captionpad != NULL && meta->caption_type != filter->caption_type) {
|
|
||||||
GST_ERROR_OBJECT (filter,
|
|
||||||
"GstVideoCaptionMeta type changed, Not handled currently");
|
|
||||||
flow = GST_FLOW_NOT_NEGOTIATED;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filter->captionpad == NULL) {
|
|
||||||
GstCaps *caption_caps = NULL;
|
GstCaps *caption_caps = NULL;
|
||||||
GstEvent *stream_event;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (filter, "Creating new caption pad");
|
switch (caption_type) {
|
||||||
switch (meta->caption_type) {
|
|
||||||
case GST_VIDEO_CAPTION_TYPE_CEA608_RAW:
|
case GST_VIDEO_CAPTION_TYPE_CEA608_RAW:
|
||||||
caption_caps = gst_caps_new_simple ("closedcaption/x-cea-608",
|
caption_caps = gst_caps_new_simple ("closedcaption/x-cea-608",
|
||||||
"format", G_TYPE_STRING, "raw", NULL);
|
"format", G_TYPE_STRING, "raw", NULL);
|
||||||
@ -267,6 +248,27 @@ gst_cc_extractor_handle_meta (GstCCExtractor * filter, GstBuffer * buf,
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return caption_caps;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_cc_extractor_handle_meta (GstCCExtractor * filter, GstBuffer * buf,
|
||||||
|
GstVideoCaptionMeta * meta)
|
||||||
|
{
|
||||||
|
GstBuffer *outbuf = NULL;
|
||||||
|
GstEvent *event;
|
||||||
|
gchar *captionid;
|
||||||
|
GstFlowReturn flow;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (filter, "Handling meta");
|
||||||
|
|
||||||
|
/* Check if the meta type matches the configured one */
|
||||||
|
if (filter->captionpad == NULL) {
|
||||||
|
GstCaps *caption_caps = create_caps_from_caption_type (meta->caption_type);
|
||||||
|
GstEvent *stream_event;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (filter, "Creating new caption pad");
|
||||||
if (caption_caps == NULL) {
|
if (caption_caps == NULL) {
|
||||||
GST_ERROR_OBJECT (filter, "Unknown/invalid caption type");
|
GST_ERROR_OBJECT (filter, "Unknown/invalid caption type");
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
@ -307,6 +309,19 @@ gst_cc_extractor_handle_meta (GstCCExtractor * filter, GstBuffer * buf,
|
|||||||
if ((event = gst_pad_get_sticky_event (filter->srcpad, GST_EVENT_TAG, 0)))
|
if ((event = gst_pad_get_sticky_event (filter->srcpad, GST_EVENT_TAG, 0)))
|
||||||
gst_pad_push_event (filter->captionpad, event);
|
gst_pad_push_event (filter->captionpad, event);
|
||||||
|
|
||||||
|
filter->caption_type = meta->caption_type;
|
||||||
|
} else if (meta->caption_type != filter->caption_type) {
|
||||||
|
GstCaps *caption_caps = create_caps_from_caption_type (meta->caption_type);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (filter, "Caption type changed from %d to %d",
|
||||||
|
filter->caption_type, meta->caption_type);
|
||||||
|
if (caption_caps == NULL) {
|
||||||
|
GST_ERROR_OBJECT (filter, "Unknown/invalid caption type");
|
||||||
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_pad_set_caps (filter->captionpad, caption_caps);
|
||||||
|
gst_caps_unref (caption_caps);
|
||||||
|
|
||||||
filter->caption_type = meta->caption_type;
|
filter->caption_type = meta->caption_type;
|
||||||
}
|
}
|
||||||
@ -323,7 +338,6 @@ gst_cc_extractor_handle_meta (GstCCExtractor * filter, GstBuffer * buf,
|
|||||||
/* We don't really care about the flow return */
|
/* We don't really care about the flow return */
|
||||||
flow = gst_pad_push (filter->captionpad, outbuf);
|
flow = gst_pad_push (filter->captionpad, outbuf);
|
||||||
|
|
||||||
out:
|
|
||||||
/* Set flow return on pad and return combined value */
|
/* Set flow return on pad and return combined value */
|
||||||
return gst_flow_combiner_update_pad_flow (filter->combiner,
|
return gst_flow_combiner_update_pad_flow (filter->combiner,
|
||||||
filter->captionpad, flow);
|
filter->captionpad, flow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user