From 20eb83367d82bdc1697a0518f4b0cc9b539f28dc Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Mon, 14 Jul 2025 16:55:33 +0300 Subject: [PATCH] tttocea{6,7}08: Disallow pango markup from input caps Otherwise the elements treat pango markup as plain text, making the text appear corrupted. Part-of: --- docs/plugins/gst_plugins_cache.json | 4 ++-- video/closedcaption/src/tttocea608/imp.rs | 4 +++- video/closedcaption/src/tttocea708/imp.rs | 4 +++- video/closedcaption/tests/tttocea608.rs | 14 +++++++------- video/closedcaption/tests/tttocea708.rs | 8 ++++---- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/plugins/gst_plugins_cache.json b/docs/plugins/gst_plugins_cache.json index e2d67313f..56f3e6cb3 100644 --- a/docs/plugins/gst_plugins_cache.json +++ b/docs/plugins/gst_plugins_cache.json @@ -9809,7 +9809,7 @@ "long-name": "TT to CEA-608", "pad-templates": { "sink": { - "caps": "text/x-raw:\napplication/x-json:\n format: cea608\n", + "caps": "text/x-raw:\n format: utf8\napplication/x-json:\n format: cea608\n", "direction": "sink", "presence": "always" }, @@ -9890,7 +9890,7 @@ "klass": "Generic", "pad-templates": { "sink": { - "caps": "text/x-raw:\n", + "caps": "text/x-raw:\n format: utf8\n", "direction": "sink", "presence": "always" }, diff --git a/video/closedcaption/src/tttocea608/imp.rs b/video/closedcaption/src/tttocea608/imp.rs index b1e0636c9..895a99e34 100644 --- a/video/closedcaption/src/tttocea608/imp.rs +++ b/video/closedcaption/src/tttocea608/imp.rs @@ -576,7 +576,9 @@ impl ElementImpl for TtToCea608 { { let caps = caps.get_mut().unwrap(); - let s = gst::Structure::builder("text/x-raw").build(); + let s = gst::Structure::builder("text/x-raw") + .field("format", "utf8") + .build(); caps.append_structure(s); let s = gst::Structure::builder("application/x-json") diff --git a/video/closedcaption/src/tttocea708/imp.rs b/video/closedcaption/src/tttocea708/imp.rs index d0aae5157..52362b50b 100644 --- a/video/closedcaption/src/tttocea708/imp.rs +++ b/video/closedcaption/src/tttocea708/imp.rs @@ -597,7 +597,9 @@ impl ElementImpl for TtToCea708 { { let caps = caps.get_mut().unwrap(); - let s = gst::Structure::builder("text/x-raw").build(); + let s = gst::Structure::builder("text/x-raw") + .field("format", "utf8") + .build(); caps.append_structure(s); } diff --git a/video/closedcaption/tests/tttocea608.rs b/video/closedcaption/tests/tttocea608.rs index a97e04c9d..24e99e5a4 100644 --- a/video/closedcaption/tests/tttocea608.rs +++ b/video/closedcaption/tests/tttocea608.rs @@ -37,7 +37,7 @@ fn test_non_timed_buffer() { init(); let mut h = gst_check::Harness::new_parse("tttocea608 mode=pop-on"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); let inbuf = gst::Buffer::from_slice("Hello"); @@ -50,7 +50,7 @@ fn test_one_timed_buffer_and_eos() { init(); let mut h = gst_check::Harness::new_parse("tttocea608 mode=pop-on"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); while h.events_in_queue() != 0 { let _event = h.pull_event().unwrap(); @@ -149,7 +149,7 @@ fn test_erase_display_memory_non_spliced() { init(); let mut h = gst_check::Harness::new_parse("tttocea608 mode=pop-on"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); while h.events_in_queue() != 0 { let _event = h.pull_event().unwrap(); @@ -191,7 +191,7 @@ fn test_erase_display_memory_spliced() { init(); let mut h = gst_check::Harness::new_parse("tttocea608 mode=pop-on"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); while h.events_in_queue() != 0 { let _event = h.pull_event().unwrap(); @@ -237,7 +237,7 @@ fn test_output_gaps() { init(); let mut h = gst_check::Harness::new_parse("tttocea608 mode=pop-on"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); while h.events_in_queue() != 0 { let _event = h.pull_event().unwrap(); @@ -311,7 +311,7 @@ fn test_one_timed_buffer_and_eos_roll_up2() { init(); let mut h = gst_check::Harness::new_parse("tttocea608 mode=roll-up2"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); while h.events_in_queue() != 0 { let _event = h.pull_event().unwrap(); @@ -427,7 +427,7 @@ fn test_word_wrap_roll_up() { init(); let mut h = gst_check::Harness::new_parse("tttocea608 mode=roll-up2 origin-column=24"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); while h.events_in_queue() != 0 { let _event = h.pull_event().unwrap(); diff --git a/video/closedcaption/tests/tttocea708.rs b/video/closedcaption/tests/tttocea708.rs index 31a3ef2bf..5a24223f7 100644 --- a/video/closedcaption/tests/tttocea708.rs +++ b/video/closedcaption/tests/tttocea708.rs @@ -37,7 +37,7 @@ fn test_ttcea708_non_timed_buffer() { init(); let mut h = gst_check::Harness::new_parse("tttocea708 mode=pop-on cea608-channel=1"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data,framerate=30/1"); let inbuf = gst::Buffer::from_slice("Hello"); @@ -66,7 +66,7 @@ fn test_tttocea708_one_timed_buffer_and_eos() { init(); let mut h = gst_check::Harness::new_parse("tttocea708 mode=pop-on cea608-channel=1"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data,framerate=30/1"); while h.events_in_queue() != 0 { @@ -162,7 +162,7 @@ fn test_tttocea708_output_gaps() { init(); let mut h = gst_check::Harness::new_parse("tttocea708 mode=pop-on cea608-channel=1"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data,framerate=30/1"); while h.events_in_queue() != 0 { @@ -250,7 +250,7 @@ fn test_tttocea708_large_input() { init(); let mut h = gst_check::Harness::new_parse("tttocea708 mode=roll-up"); - h.set_src_caps_str("text/x-raw"); + h.set_src_caps_str("text/x-raw,format=utf8"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data,framerate=60/1"); while h.events_in_queue() != 0 {