mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
mpdparser: MS PlayReady ContentProtection parsing
The "pro" (PlayReady Object) element contents are now base64-decoded and properly stored in Protection events. https://bugzilla.gnome.org/show_bug.cgi?id=773936
This commit is contained in:
parent
4899bf0926
commit
dd0c56b4a2
3 changed files with 51 additions and 3 deletions
|
@ -1733,6 +1733,43 @@ error:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_mpdparser_parse_content_protection_node (GList ** list, xmlNode * a_node)
|
||||||
|
{
|
||||||
|
gchar *value = NULL;
|
||||||
|
if (gst_mpdparser_get_xml_prop_string (a_node, "value", &value)) {
|
||||||
|
if (!g_strcmp0 (value, "MSPR 2.0")) {
|
||||||
|
xmlNode *cur_node;
|
||||||
|
for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) {
|
||||||
|
if (cur_node->type == XML_ELEMENT_NODE) {
|
||||||
|
if (xmlStrcmp (cur_node->name, (xmlChar *) "pro") == 0) {
|
||||||
|
gsize decoded_len;
|
||||||
|
GstDescriptorType *new_descriptor;
|
||||||
|
new_descriptor = g_slice_new0 (GstDescriptorType);
|
||||||
|
*list = g_list_append (*list, new_descriptor);
|
||||||
|
|
||||||
|
gst_mpdparser_get_xml_prop_string_stripped (a_node, "schemeIdUri",
|
||||||
|
&new_descriptor->schemeIdUri);
|
||||||
|
|
||||||
|
gst_mpdparser_get_xml_node_content (cur_node,
|
||||||
|
&new_descriptor->value);
|
||||||
|
g_base64_decode_inplace (new_descriptor->value, &decoded_len);
|
||||||
|
*(new_descriptor->value + decoded_len) = '\0';
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gst_mpdparser_parse_descriptor_type_node (list, a_node);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gst_mpdparser_parse_descriptor_type_node (list, a_node);
|
||||||
|
}
|
||||||
|
beach:
|
||||||
|
if (value)
|
||||||
|
g_free (value);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_mpdparser_parse_representation_base_type (GstRepresentationBaseType **
|
gst_mpdparser_parse_representation_base_type (GstRepresentationBaseType **
|
||||||
pointer, xmlNode * a_node)
|
pointer, xmlNode * a_node)
|
||||||
|
@ -1788,7 +1825,7 @@ gst_mpdparser_parse_representation_base_type (GstRepresentationBaseType **
|
||||||
(&representation_base->AudioChannelConfiguration, cur_node);
|
(&representation_base->AudioChannelConfiguration, cur_node);
|
||||||
} else if (xmlStrcmp (cur_node->name,
|
} else if (xmlStrcmp (cur_node->name,
|
||||||
(xmlChar *) "ContentProtection") == 0) {
|
(xmlChar *) "ContentProtection") == 0) {
|
||||||
gst_mpdparser_parse_descriptor_type_node
|
gst_mpdparser_parse_content_protection_node
|
||||||
(&representation_base->ContentProtection, cur_node);
|
(&representation_base->ContentProtection, cur_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1380,6 +1380,9 @@ testContentProtectionDashdemuxSendsEvent (GstAdaptiveDemuxTestEngine * engine,
|
||||||
fail_if (str == NULL);
|
fail_if (str == NULL);
|
||||||
str = strstr (value, "</ContentProtection>");
|
str = strstr (value, "</ContentProtection>");
|
||||||
fail_if (str == NULL);
|
fail_if (str == NULL);
|
||||||
|
} else if (g_strcmp0 (system_id, "9a04f079-9840-4286-ab92-e65be0885f95") == 0) {
|
||||||
|
fail_unless (g_strcmp0 (origin, "dash/mpd") == 0);
|
||||||
|
fail_unless (g_strcmp0 (value, "test") == 0);
|
||||||
} else {
|
} else {
|
||||||
fail ("unexpected content protection event '%s'", system_id);
|
fail ("unexpected content protection event '%s'", system_id);
|
||||||
}
|
}
|
||||||
|
@ -1412,6 +1415,7 @@ GST_START_TEST (testContentProtection)
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
||||||
"<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
|
"<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
|
||||||
" xmlns=\"urn:mpeg:DASH:schema:MPD:2011\""
|
" xmlns=\"urn:mpeg:DASH:schema:MPD:2011\""
|
||||||
|
" xmlns:mspr=\"urn:microsoft:playready\""
|
||||||
" xsi:schemaLocation=\"urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd\""
|
" xsi:schemaLocation=\"urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd\""
|
||||||
" profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\""
|
" profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\""
|
||||||
" type=\"static\""
|
" type=\"static\""
|
||||||
|
@ -1444,6 +1448,9 @@ GST_START_TEST (testContentProtection)
|
||||||
" <mas:MarlinContentId>urn:marlin:kid:02020202020202020202020202020202</mas:MarlinContentId>"
|
" <mas:MarlinContentId>urn:marlin:kid:02020202020202020202020202020202</mas:MarlinContentId>"
|
||||||
" </mas:MarlinContentIds>"
|
" </mas:MarlinContentIds>"
|
||||||
" </ContentProtection>"
|
" </ContentProtection>"
|
||||||
|
" <ContentProtection schemeIdUri=\"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95\" value=\"MSPR 2.0\">"
|
||||||
|
" <mspr:pro>dGVzdA==</mspr:pro>"
|
||||||
|
" </ContentProtection>"
|
||||||
" <Representation id=\"242\""
|
" <Representation id=\"242\""
|
||||||
" codecs=\"vp9\""
|
" codecs=\"vp9\""
|
||||||
" width=\"426\""
|
" width=\"426\""
|
||||||
|
@ -1497,7 +1504,7 @@ GST_START_TEST (testContentProtection)
|
||||||
|
|
||||||
gst_structure_get_uint (testData->countContentProtectionEvents, "video_00",
|
gst_structure_get_uint (testData->countContentProtectionEvents, "video_00",
|
||||||
&event_count);
|
&event_count);
|
||||||
fail_unless (event_count == 2);
|
fail_unless (event_count == 3);
|
||||||
|
|
||||||
g_object_unref (testData);
|
g_object_unref (testData);
|
||||||
if (http_src_test_data.data)
|
if (http_src_test_data.data)
|
||||||
|
|
|
@ -1301,6 +1301,7 @@ GST_START_TEST (dash_mpdparser_contentProtection_no_value)
|
||||||
const gchar *xml =
|
const gchar *xml =
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
"<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
|
"<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
|
||||||
|
" xmlns:mspr=\"urn:microsoft:playready\""
|
||||||
" profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
|
" profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
|
||||||
" <Period>"
|
" <Period>"
|
||||||
" <AdaptationSet>"
|
" <AdaptationSet>"
|
||||||
|
@ -1309,6 +1310,9 @@ GST_START_TEST (dash_mpdparser_contentProtection_no_value)
|
||||||
" <mas:MarlinContentIds>"
|
" <mas:MarlinContentIds>"
|
||||||
" <mas:MarlinContentId>urn:marlin:kid:02020202020202020202020202020202</mas:MarlinContentId>"
|
" <mas:MarlinContentId>urn:marlin:kid:02020202020202020202020202020202</mas:MarlinContentId>"
|
||||||
" </mas:MarlinContentIds>"
|
" </mas:MarlinContentIds>"
|
||||||
|
" </ContentProtection>"
|
||||||
|
" <ContentProtection schemeIdUri=\"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95\" value=\"MSPR 2.0\">"
|
||||||
|
" <mspr:pro>dGVzdA==</mspr:pro>"
|
||||||
" </ContentProtection>" "</AdaptationSet></Period></MPD>";
|
" </ContentProtection>" "</AdaptationSet></Period></MPD>";
|
||||||
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
@ -1321,7 +1325,7 @@ GST_START_TEST (dash_mpdparser_contentProtection_no_value)
|
||||||
periodNode = (GstPeriodNode *) mpdclient->mpd_node->Periods->data;
|
periodNode = (GstPeriodNode *) mpdclient->mpd_node->Periods->data;
|
||||||
adaptationSet = (GstAdaptationSetNode *) periodNode->AdaptationSets->data;
|
adaptationSet = (GstAdaptationSetNode *) periodNode->AdaptationSets->data;
|
||||||
representationBase = adaptationSet->RepresentationBase;
|
representationBase = adaptationSet->RepresentationBase;
|
||||||
assert_equals_int (g_list_length (representationBase->ContentProtection), 2);
|
assert_equals_int (g_list_length (representationBase->ContentProtection), 3);
|
||||||
contentProtection =
|
contentProtection =
|
||||||
(GstDescriptorType *) g_list_nth (representationBase->ContentProtection,
|
(GstDescriptorType *) g_list_nth (representationBase->ContentProtection,
|
||||||
1)->data;
|
1)->data;
|
||||||
|
|
Loading…
Reference in a new issue