Skip to content

Commit 103f69f

Browse files
committed
Import "qtdemux: No need for new "application/x-cbcs" caps"
1 parent 651c8d6 commit 103f69f

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From d5e65505935e27e9737cf6dfa6dc2bc3bbbe3e47 Mon Sep 17 00:00:00 2001
2+
From: Yacine Bandou <[email protected]>
3+
Date: Mon, 21 Jun 2021 13:47:50 +0200
4+
Subject: [PATCH] qtdemux: No need for new "application/x-cbcs" caps
5+
6+
Instead of using the new "application/x-cbcs" caps, we are just adding
7+
a new structure field "ciphe-mode", to indicate which encryption scheme
8+
is used: "cenc", "cbcs", "cbc1" or "cens".
9+
10+
Similarly for the protection metadata, we add the "cipher-mode" field
11+
to specify the encryption mode with which the buffers are encrypted.
12+
13+
"cenc": AES-CTR (no pattern)
14+
"cbc1": AES-CBC (no pattern)
15+
"cens": AES-CTR (pattern specified)
16+
"cbcs": AES-CBC (pattern specified, using a constant IV)
17+
18+
Currently only "cenc" and "cbcs" are supported.
19+
20+
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1013>
21+
---
22+
gst/isomp4/qtdemux.c | 22 ++++++++++++----------
23+
1 file changed, 12 insertions(+), 10 deletions(-)
24+
25+
diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
26+
index 47bd6fe83..910cd0d95 100644
27+
--- a/gst/isomp4/qtdemux.c
28+
+++ b/gst/isomp4/qtdemux.c
29+
@@ -2883,15 +2883,12 @@ qtdemux_update_default_sample_cenc_settings (GstQTDemux * qtdemux,
30+
guint crypt_byte_block, guint skip_byte_block, guint8 constant_iv_size,
31+
const guint8 * constant_iv)
32+
{
33+
- const gchar *protection_scheme_type_mime =
34+
- protection_scheme_type ==
35+
- FOURCC_cbcs ? "application/x-cbcs" : "application/x-cenc";
36+
GstBuffer *kid_buf = gst_buffer_new_allocate (NULL, 16, NULL);
37+
gst_buffer_fill (kid_buf, 0, kid, 16);
38+
if (info->default_properties)
39+
gst_structure_free (info->default_properties);
40+
info->default_properties =
41+
- gst_structure_new (protection_scheme_type_mime,
42+
+ gst_structure_new ("application/x-cenc",
43+
"iv_size", G_TYPE_UINT, iv_size,
44+
"encrypted", G_TYPE_BOOLEAN, (is_encrypted == 1),
45+
"kid", GST_TYPE_BUFFER, kid_buf, NULL);
46+
@@ -2913,6 +2910,11 @@ qtdemux_update_default_sample_cenc_settings (GstQTDemux * qtdemux,
47+
NULL);
48+
gst_buffer_unref (constant_iv_buf);
49+
}
50+
+ gst_structure_set (info->default_properties, "cipher-mode",
51+
+ G_TYPE_STRING, "cbcs", NULL);
52+
+ } else {
53+
+ gst_structure_set (info->default_properties, "cipher-mode",
54+
+ G_TYPE_STRING, "cenc", NULL);
55+
}
56+
}
57+
58+
@@ -3971,7 +3973,7 @@ qtdemux_gst_structure_free (GstStructure * gststructure)
59+
}
60+
61+
/* Parses auxiliary information relating to samples protected using
62+
- * Common Encryption (cenc and cbcs); the format of this information
63+
+ * Common Encryption (cenc); the format of this information
64+
* is defined in ISO/IEC 23001-7. Returns TRUE if successful; FALSE
65+
* otherwise. */
66+
static gboolean
67+
@@ -8546,13 +8548,13 @@ gst_qtdemux_configure_protected_caps (GstQTDemux * qtdemux,
68+
}
69+
70+
s = gst_caps_get_structure (CUR_STREAM (stream)->caps, 0);
71+
- if (!gst_structure_has_name (s, "application/x-cenc")
72+
- && !gst_structure_has_name (s, "application/x-cbcs")) {
73+
+ if (!gst_structure_has_name (s, "application/x-cenc")) {
74+
gst_structure_set (s,
75+
"original-media-type", G_TYPE_STRING, gst_structure_get_name (s), NULL);
76+
- gst_structure_set_name (s,
77+
- stream->protection_scheme_type ==
78+
- FOURCC_cbcs ? "application/x-cbcs" : "application/x-cenc");
79+
+ gst_structure_set (s, "cipher-mode", G_TYPE_STRING,
80+
+ (stream->protection_scheme_type == FOURCC_cbcs) ? "cbcs" : "cenc",
81+
+ NULL);
82+
+ gst_structure_set_name (s, "application/x-cenc");
83+
}
84+
85+
if (qtdemux->protection_system_ids == NULL) {
86+
--
87+
2.30.2
88+

0 commit comments

Comments
 (0)