1 /* GStreamer unit test for MPEG-DASH
3 * Copyright (c) <2015> YouView TV Ltd
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #include "../../ext/adaptivedemux2/dash/gstmpdparser.c"
22 #include "../../ext/adaptivedemux2/dash/gstxmlhelper.c"
23 #include "../../ext/adaptivedemux2/dash/gstmpdhelper.c"
24 #include "../../ext/adaptivedemux2/dash/gstmpdnode.c"
25 #include "../../ext/adaptivedemux2/dash/gstmpdrepresentationbasenode.c"
26 #include "../../ext/adaptivedemux2/dash/gstmpdmultsegmentbasenode.c"
27 #include "../../ext/adaptivedemux2/dash/gstmpdrootnode.c"
28 #include "../../ext/adaptivedemux2/dash/gstmpdbaseurlnode.c"
29 #include "../../ext/adaptivedemux2/dash/gstmpdutctimingnode.c"
30 #include "../../ext/adaptivedemux2/dash/gstmpdmetricsnode.c"
31 #include "../../ext/adaptivedemux2/dash/gstmpdmetricsrangenode.c"
32 #include "../../ext/adaptivedemux2/dash/gstmpdsnode.c"
33 #include "../../ext/adaptivedemux2/dash/gstmpdsegmenttimelinenode.c"
34 #include "../../ext/adaptivedemux2/dash/gstmpdsegmenttemplatenode.c"
35 #include "../../ext/adaptivedemux2/dash/gstmpdsegmenturlnode.c"
36 #include "../../ext/adaptivedemux2/dash/gstmpdsegmentlistnode.c"
37 #include "../../ext/adaptivedemux2/dash/gstmpdsegmentbasenode.c"
38 #include "../../ext/adaptivedemux2/dash/gstmpdperiodnode.c"
39 #include "../../ext/adaptivedemux2/dash/gstmpdsubrepresentationnode.c"
40 #include "../../ext/adaptivedemux2/dash/gstmpdrepresentationnode.c"
41 #include "../../ext/adaptivedemux2/dash/gstmpdcontentcomponentnode.c"
42 #include "../../ext/adaptivedemux2/dash/gstmpdadaptationsetnode.c"
43 #include "../../ext/adaptivedemux2/dash/gstmpdsubsetnode.c"
44 #include "../../ext/adaptivedemux2/dash/gstmpdprograminformationnode.c"
45 #include "../../ext/adaptivedemux2/dash/gstmpdlocationnode.c"
46 #include "../../ext/adaptivedemux2/dash/gstmpdreportingnode.c"
47 #include "../../ext/adaptivedemux2/dash/gstmpdurltypenode.c"
48 #include "../../ext/adaptivedemux2/dash/gstmpddescriptortypenode.c"
49 #include "../../ext/adaptivedemux2/dash/gstmpdclient.c"
50 #undef GST_CAT_DEFAULT
52 #include <gst/check/gstcheck.h>
54 GST_DEBUG_CATEGORY (gst_dash_demux2_debug);
57 * Linker liked to complain about missing downloadhelper_* symbols.
58 * The tests below don't actually use them, so this stub is intended to
59 * get rid of those warnings. Linker doesn't seem to complain anymore.
62 downloadhelper_fetch_uri (DownloadHelper * dh, const gchar * uri,
63 const gchar * referer, DownloadFlags flags, GError ** err)
65 g_assert_not_reached ();
69 * compute the number of milliseconds contained in a duration value specified by
70 * year, month, day, hour, minute, second, millisecond
72 * This function must use the same conversion algorithm implemented in
73 * gst_xml_helper_get_prop_duration from gstmpdparser.c file.
76 duration_to_ms (guint year, guint month, guint day, guint hour, guint minute,
77 guint second, guint millisecond)
79 guint64 days = (guint64) year * 365 + (guint64) month * 30 + day;
80 guint64 hours = days * 24 + hour;
81 guint64 minutes = hours * 60 + minute;
82 guint64 seconds = minutes * 60 + second;
83 guint64 ms = seconds * 1000 + millisecond;
88 duration_to_clocktime (guint year, guint month, guint day, guint hour,
89 guint minute, guint second, guint millisecond)
91 return (GST_MSECOND * duration_to_ms (year, month, day, hour, minute, second,
96 * Test to ensure a simple mpd file successfully parses.
99 GST_START_TEST (dash_mpdparser_validsimplempd)
102 "<?xml version=\"1.0\"?>"
103 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
104 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\"> </MPD>";
107 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
109 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
110 assert_equals_int (ret, TRUE);
112 /* check that unset elements with default values are properly configured */
113 assert_equals_int (mpdclient->mpd_root_node->type, GST_MPD_FILE_TYPE_STATIC);
115 gst_mpd_client2_free (mpdclient);
121 * Test parsing the MPD attributes.
124 GST_START_TEST (dash_mpdparser_mpd)
126 GstDateTime *availabilityStartTime;
127 GstDateTime *availabilityEndTime;
129 "<?xml version=\"1.0\"?>"
130 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
131 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
132 " schemaLocation=\"TestSchemaLocation\""
133 " xmlns:xsi=\"TestNamespaceXSI\""
134 " xmlns:ext=\"TestNamespaceEXT\""
137 " availabilityStartTime=\"2015-03-24T1:10:50\""
138 " availabilityEndTime=\"2015-03-24T1:10:50.123456\""
139 " mediaPresentationDuration=\"P0Y1M2DT12H10M20.5S\""
140 " minimumUpdatePeriod=\"P0Y1M2DT12H10M20.5S\""
141 " minBufferTime=\"P0Y1M2DT12H10M20.5S\""
142 " timeShiftBufferDepth=\"P0Y1M2DT12H10M20.5S\""
143 " suggestedPresentationDelay=\"P0Y1M2DT12H10M20.5S\""
144 " maxSegmentDuration=\"P0Y1M2DT12H10M20.5S\""
145 " maxSubsegmentDuration=\"P0Y1M2DT12H10M20.5S\"></MPD>";
148 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
150 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
151 assert_equals_int (ret, TRUE);
153 assert_equals_string (mpdclient->mpd_root_node->default_namespace,
154 "urn:mpeg:dash:schema:mpd:2011");
155 assert_equals_string (mpdclient->mpd_root_node->namespace_xsi,
157 assert_equals_string (mpdclient->mpd_root_node->namespace_ext,
159 assert_equals_string (mpdclient->mpd_root_node->schemaLocation,
160 "TestSchemaLocation");
161 assert_equals_string (mpdclient->mpd_root_node->id, "testId");
163 assert_equals_int (mpdclient->mpd_root_node->type, GST_MPD_FILE_TYPE_STATIC);
165 availabilityStartTime = mpdclient->mpd_root_node->availabilityStartTime;
166 assert_equals_int (gst_date_time_get_year (availabilityStartTime), 2015);
167 assert_equals_int (gst_date_time_get_month (availabilityStartTime), 3);
168 assert_equals_int (gst_date_time_get_day (availabilityStartTime), 24);
169 assert_equals_int (gst_date_time_get_hour (availabilityStartTime), 1);
170 assert_equals_int (gst_date_time_get_minute (availabilityStartTime), 10);
171 assert_equals_int (gst_date_time_get_second (availabilityStartTime), 50);
172 assert_equals_int (gst_date_time_get_microsecond (availabilityStartTime), 0);
174 availabilityEndTime = mpdclient->mpd_root_node->availabilityEndTime;
175 assert_equals_int (gst_date_time_get_year (availabilityEndTime), 2015);
176 assert_equals_int (gst_date_time_get_month (availabilityEndTime), 3);
177 assert_equals_int (gst_date_time_get_day (availabilityEndTime), 24);
178 assert_equals_int (gst_date_time_get_hour (availabilityEndTime), 1);
179 assert_equals_int (gst_date_time_get_minute (availabilityEndTime), 10);
180 assert_equals_int (gst_date_time_get_second (availabilityEndTime), 50);
181 assert_equals_int (gst_date_time_get_microsecond (availabilityEndTime),
184 assert_equals_uint64 (mpdclient->mpd_root_node->mediaPresentationDuration,
185 duration_to_ms (0, 1, 2, 12, 10, 20, 500));
187 assert_equals_uint64 (mpdclient->mpd_root_node->minimumUpdatePeriod,
188 duration_to_ms (0, 1, 2, 12, 10, 20, 500));
190 assert_equals_uint64 (mpdclient->mpd_root_node->minBufferTime,
191 duration_to_ms (0, 1, 2, 12, 10, 20, 500));
193 assert_equals_uint64 (mpdclient->mpd_root_node->timeShiftBufferDepth,
194 duration_to_ms (0, 1, 2, 12, 10, 20, 500));
196 assert_equals_uint64 (mpdclient->mpd_root_node->suggestedPresentationDelay,
197 duration_to_ms (0, 1, 2, 12, 10, 20, 500));
199 assert_equals_uint64 (mpdclient->mpd_root_node->maxSegmentDuration,
200 duration_to_ms (0, 1, 2, 12, 10, 20, 500));
202 assert_equals_uint64 (mpdclient->mpd_root_node->maxSubsegmentDuration,
203 duration_to_ms (0, 1, 2, 12, 10, 20, 500));
205 gst_mpd_client2_free (mpdclient);
211 * Test parsing the ProgramInformation attributes
214 GST_START_TEST (dash_mpdparser_programInformation)
216 GstMPDProgramInformationNode *program;
218 "<?xml version=\"1.0\"?>"
219 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
220 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
221 " <ProgramInformation lang=\"en\""
222 " moreInformationURL=\"TestMoreInformationUrl\">"
223 " <Title>TestTitle</Title>"
224 " <Source>TestSource</Source>"
225 " <Copyright>TestCopyright</Copyright>"
226 " </ProgramInformation> </MPD>";
229 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
231 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
232 assert_equals_int (ret, TRUE);
235 (GstMPDProgramInformationNode *) mpdclient->mpd_root_node->ProgramInfos->
237 assert_equals_string (program->lang, "en");
238 assert_equals_string (program->moreInformationURL, "TestMoreInformationUrl");
239 assert_equals_string (program->Title, "TestTitle");
240 assert_equals_string (program->Source, "TestSource");
241 assert_equals_string (program->Copyright, "TestCopyright");
243 gst_mpd_client2_free (mpdclient);
249 * Test parsing the BaseURL attributes
252 GST_START_TEST (dash_mpdparser_baseURL)
254 GstMPDBaseURLNode *baseURL;
256 "<?xml version=\"1.0\"?>"
257 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
258 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
259 " <BaseURL serviceLocation=\"TestServiceLocation\""
260 " byteRange=\"TestByteRange\">TestBaseURL</BaseURL></MPD>";
263 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
265 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
266 assert_equals_int (ret, TRUE);
268 baseURL = (GstMPDBaseURLNode *) mpdclient->mpd_root_node->BaseURLs->data;
269 assert_equals_string (baseURL->baseURL, "TestBaseURL");
270 assert_equals_string (baseURL->serviceLocation, "TestServiceLocation");
271 assert_equals_string (baseURL->byteRange, "TestByteRange");
273 gst_mpd_client2_free (mpdclient);
279 * Test parsing the Location attributes
282 GST_START_TEST (dash_mpdparser_location)
284 GstMPDLocationNode *location;
286 "<?xml version=\"1.0\"?>"
287 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
288 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
289 " <Location>TestLocation</Location></MPD>";
292 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
294 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
295 assert_equals_int (ret, TRUE);
297 location = (GstMPDLocationNode *) mpdclient->mpd_root_node->Locations->data;
298 assert_equals_string (location->location, "TestLocation");
300 gst_mpd_client2_free (mpdclient);
306 * Test parsing Metrics attributes
309 GST_START_TEST (dash_mpdparser_metrics)
311 GstMPDMetricsNode *metricsNode;
313 "<?xml version=\"1.0\"?>"
314 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
315 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
316 " <Metrics metrics=\"TestMetric\"></Metrics></MPD>";
319 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
321 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
322 assert_equals_int (ret, TRUE);
324 metricsNode = (GstMPDMetricsNode *) mpdclient->mpd_root_node->Metrics->data;
325 assert_equals_string (metricsNode->metrics, "TestMetric");
327 gst_mpd_client2_free (mpdclient);
333 * Test parsing Metrics Range attributes
336 GST_START_TEST (dash_mpdparser_metrics_range)
338 GstMPDMetricsNode *metricsNode;
339 GstMPDMetricsRangeNode *metricsRangeNode;
341 "<?xml version=\"1.0\"?>"
342 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
343 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
345 " <Range starttime=\"P0Y1M2DT12H10M20.5S\""
346 " duration=\"P0Y1M2DT12H10M20.1234567S\">"
347 " </Range></Metrics></MPD>";
350 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
352 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
353 assert_equals_int (ret, TRUE);
355 metricsNode = (GstMPDMetricsNode *) mpdclient->mpd_root_node->Metrics->data;
356 assert_equals_pointer (metricsNode->metrics, NULL);
358 (GstMPDMetricsRangeNode *) metricsNode->MetricsRanges->data;
359 assert_equals_uint64 (metricsRangeNode->starttime, duration_to_ms (0, 1, 2,
361 assert_equals_uint64 (metricsRangeNode->duration, duration_to_ms (0, 1, 2, 12,
364 gst_mpd_client2_free (mpdclient);
370 * Test parsing Metrics Reporting attributes
373 GST_START_TEST (dash_mpdparser_metrics_reporting)
375 GstMPDMetricsNode *metricsNode;
377 "<?xml version=\"1.0\"?>"
378 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
379 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
380 " <Metrics><Reporting></Reporting></Metrics></MPD>";
383 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
385 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
386 assert_equals_int (ret, TRUE);
388 metricsNode = (GstMPDMetricsNode *) mpdclient->mpd_root_node->Metrics->data;
389 assert_equals_pointer (metricsNode->metrics, NULL);
391 gst_mpd_client2_free (mpdclient);
397 * Test parsing Period attributes
400 GST_START_TEST (dash_mpdparser_period)
402 GstMPDPeriodNode *periodNode;
404 "<?xml version=\"1.0\"?>"
405 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
406 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
407 " <Period id=\"TestId\""
408 " start=\"P0Y1M2DT12H10M20.1234567S\""
409 " duration=\"P0Y1M2DT12H10M20.7654321S\""
410 " bitstreamSwitching=\"true\"></Period></MPD>";
413 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
415 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
416 assert_equals_int (ret, TRUE);
418 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
419 assert_equals_string (periodNode->id, "TestId");
420 assert_equals_uint64 (periodNode->start,
421 duration_to_ms (0, 1, 2, 12, 10, 20, 123));
422 assert_equals_uint64 (periodNode->duration,
423 duration_to_ms (0, 1, 2, 12, 10, 20, 765));
424 assert_equals_int (periodNode->bitstreamSwitching, 1);
426 gst_mpd_client2_free (mpdclient);
432 * Test parsing Period baseURL attributes
435 GST_START_TEST (dash_mpdparser_period_baseURL)
437 GstMPDPeriodNode *periodNode;
438 GstMPDBaseURLNode *baseURL;
440 "<?xml version=\"1.0\"?>"
441 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
442 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
444 " <BaseURL serviceLocation=\"TestServiceLocation\""
445 " byteRange=\"TestByteRange\">TestBaseURL</BaseURL>"
449 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
451 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
452 assert_equals_int (ret, TRUE);
454 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
455 baseURL = (GstMPDBaseURLNode *) periodNode->BaseURLs->data;
456 assert_equals_string (baseURL->baseURL, "TestBaseURL");
457 assert_equals_string (baseURL->serviceLocation, "TestServiceLocation");
458 assert_equals_string (baseURL->byteRange, "TestByteRange");
460 gst_mpd_client2_free (mpdclient);
466 * Test parsing Period SegmentBase attributes
469 GST_START_TEST (dash_mpdparser_period_segmentBase)
471 GstMPDPeriodNode *periodNode;
472 GstMPDSegmentBaseNode *segmentBase;
474 "<?xml version=\"1.0\"?>"
475 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
476 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
478 " <SegmentBase timescale=\"123456\""
479 " presentationTimeOffset=\"123456789\""
480 " indexRange=\"100-200\""
481 " indexRangeExact=\"true\">"
482 " </SegmentBase></Period></MPD>";
485 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
487 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
488 assert_equals_int (ret, TRUE);
490 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
491 segmentBase = periodNode->SegmentBase;
492 assert_equals_uint64 (segmentBase->timescale, 123456);
493 assert_equals_uint64 (segmentBase->presentationTimeOffset, 123456789);
494 assert_equals_uint64 (segmentBase->indexRange->first_byte_pos, 100);
495 assert_equals_uint64 (segmentBase->indexRange->last_byte_pos, 200);
496 assert_equals_int (segmentBase->indexRangeExact, 1);
498 gst_mpd_client2_free (mpdclient);
504 * Test parsing Period SegmentBase Initialization attributes
507 GST_START_TEST (dash_mpdparser_period_segmentBase_initialization)
509 GstMPDPeriodNode *periodNode;
510 GstMPDSegmentBaseNode *segmentBase;
511 GstMPDURLTypeNode *initialization;
513 "<?xml version=\"1.0\"?>"
514 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
515 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
518 " <Initialisation sourceURL=\"TestSourceURL\""
519 " range=\"100-200\">"
520 " </Initialisation></SegmentBase></Period></MPD>";
523 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
525 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
526 assert_equals_int (ret, TRUE);
528 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
529 segmentBase = periodNode->SegmentBase;
530 initialization = segmentBase->Initialization;
531 assert_equals_string (initialization->sourceURL, "TestSourceURL");
532 assert_equals_uint64 (initialization->range->first_byte_pos, 100);
533 assert_equals_uint64 (initialization->range->last_byte_pos, 200);
535 gst_mpd_client2_free (mpdclient);
541 * Test parsing Period SegmentBase RepresentationIndex attributes
544 GST_START_TEST (dash_mpdparser_period_segmentBase_representationIndex)
546 GstMPDPeriodNode *periodNode;
547 GstMPDSegmentBaseNode *segmentBase;
548 GstMPDURLTypeNode *representationIndex;
550 "<?xml version=\"1.0\"?>"
551 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
552 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
555 " <RepresentationIndex sourceURL=\"TestSourceURL\""
556 " range=\"100-200\">"
557 " </RepresentationIndex></SegmentBase></Period></MPD>";
560 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
562 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
563 assert_equals_int (ret, TRUE);
565 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
566 segmentBase = periodNode->SegmentBase;
567 representationIndex = segmentBase->RepresentationIndex;
568 assert_equals_string (representationIndex->sourceURL, "TestSourceURL");
569 assert_equals_uint64 (representationIndex->range->first_byte_pos, 100);
570 assert_equals_uint64 (representationIndex->range->last_byte_pos, 200);
572 gst_mpd_client2_free (mpdclient);
578 * Test parsing Period SegmentList attributes
581 GST_START_TEST (dash_mpdparser_period_segmentList)
583 GstMPDPeriodNode *periodNode;
584 GstMPDSegmentListNode *segmentList;
586 "<?xml version=\"1.0\"?>"
587 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
588 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
589 " <Period><SegmentList duration=\"1\"></SegmentList></Period></MPD>";
592 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
594 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
595 assert_equals_int (ret, TRUE);
597 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
598 segmentList = periodNode->SegmentList;
599 fail_if (segmentList == NULL);
601 gst_mpd_client2_free (mpdclient);
607 * Test parsing Period SegmentList MultipleSegmentBaseType attributes
610 GST_START_TEST (dash_mpdparser_period_segmentList_multipleSegmentBaseType)
612 GstMPDPeriodNode *periodNode;
613 GstMPDSegmentListNode *segmentList;
616 "<?xml version=\"1.0\"?>"
617 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
618 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
620 " <SegmentList duration=\"10\""
621 " startNumber=\"11\">"
622 " </SegmentList></Period></MPD>";
625 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
627 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
628 assert_equals_int (ret, TRUE);
630 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
631 segmentList = periodNode->SegmentList;
633 assert_equals_uint64 (GST_MPD_MULT_SEGMENT_BASE_NODE (segmentList)->duration,
635 assert_equals_uint64 (GST_MPD_MULT_SEGMENT_BASE_NODE
636 (segmentList)->startNumber, 11);
638 gst_mpd_client2_free (mpdclient);
644 * Test parsing Period SegmentList MultipleSegmentBaseType SegmentBaseType
648 (dash_mpdparser_period_segmentList_multipleSegmentBaseType_segmentBaseType)
650 GstMPDPeriodNode *periodNode;
651 GstMPDSegmentListNode *segmentList;
652 GstMPDSegmentBaseNode *segmentBase;
654 "<?xml version=\"1.0\"?>"
655 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
656 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
658 " <SegmentList timescale=\"10\""
660 " presentationTimeOffset=\"11\""
661 " indexRange=\"20-21\""
662 " indexRangeExact=\"false\">"
663 " </SegmentList></Period></MPD>";
666 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
668 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
669 assert_equals_int (ret, TRUE);
671 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
672 segmentList = periodNode->SegmentList;
673 segmentBase = GST_MPD_MULT_SEGMENT_BASE_NODE (segmentList)->SegmentBase;
674 assert_equals_uint64 (segmentBase->timescale, 10);
675 assert_equals_uint64 (segmentBase->presentationTimeOffset, 11);
676 assert_equals_uint64 (segmentBase->indexRange->first_byte_pos, 20);
677 assert_equals_uint64 (segmentBase->indexRange->last_byte_pos, 21);
678 assert_equals_int (segmentBase->indexRangeExact, FALSE);
680 gst_mpd_client2_free (mpdclient);
686 * Test parsing Period SegmentList MultipleSegmentBaseType SegmentTimeline
690 (dash_mpdparser_period_segmentList_multipleSegmentBaseType_segmentTimeline)
692 GstMPDPeriodNode *periodNode;
693 GstMPDSegmentListNode *segmentList;
694 GstMPDSegmentTimelineNode *segmentTimeline;
696 "<?xml version=\"1.0\"?>"
697 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
698 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
702 " </SegmentTimeline></SegmentList></Period></MPD>";
705 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
707 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
708 assert_equals_int (ret, TRUE);
710 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
711 segmentList = periodNode->SegmentList;
713 GST_MPD_MULT_SEGMENT_BASE_NODE (segmentList)->SegmentTimeline;
714 fail_if (segmentTimeline == NULL);
716 gst_mpd_client2_free (mpdclient);
722 * Test parsing Period SegmentList MultipleSegmentBaseType SegmentTimeline S
726 (dash_mpdparser_period_segmentList_multipleSegmentBaseType_segmentTimeline_s)
728 GstMPDPeriodNode *periodNode;
729 GstMPDSegmentListNode *segmentList;
730 GstMPDSegmentTimelineNode *segmentTimeline;
733 "<?xml version=\"1.0\"?>"
734 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
735 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
739 " <S t=\"1\" d=\"2\" r=\"3\">"
740 " </S></SegmentTimeline></SegmentList></Period></MPD>";
743 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
745 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
746 assert_equals_int (ret, TRUE);
748 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
749 segmentList = periodNode->SegmentList;
751 GST_MPD_MULT_SEGMENT_BASE_NODE (segmentList)->SegmentTimeline;
752 sNode = (GstMPDSNode *) g_queue_peek_head (&segmentTimeline->S);
753 assert_equals_uint64 (sNode->t, 1);
754 assert_equals_uint64 (sNode->d, 2);
755 assert_equals_uint64 (sNode->r, 3);
757 gst_mpd_client2_free (mpdclient);
763 * Test parsing Period SegmentList MultipleSegmentBaseType BitstreamSwitching
767 (dash_mpdparser_period_segmentList_multipleSegmentBaseType_bitstreamSwitching)
769 GstMPDPeriodNode *periodNode;
770 GstMPDSegmentListNode *segmentList;
771 GstMPDURLTypeNode *bitstreamSwitching;
773 "<?xml version=\"1.0\"?>"
774 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
775 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
777 " <SegmentList duration=\"0\">"
778 " <BitstreamSwitching sourceURL=\"TestSourceURL\""
779 " range=\"100-200\">"
780 " </BitstreamSwitching></SegmentList></Period></MPD>";
783 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
785 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
786 assert_equals_int (ret, TRUE);
788 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
789 segmentList = periodNode->SegmentList;
792 GST_MPD_MULT_SEGMENT_BASE_NODE (segmentList)->BitstreamSwitching;
793 assert_equals_string (bitstreamSwitching->sourceURL, "TestSourceURL");
794 assert_equals_uint64 (bitstreamSwitching->range->first_byte_pos, 100);
795 assert_equals_uint64 (bitstreamSwitching->range->last_byte_pos, 200);
797 gst_mpd_client2_free (mpdclient);
803 * Test parsing Period SegmentList SegmentURL attributes
806 GST_START_TEST (dash_mpdparser_period_segmentList_segmentURL)
808 GstMPDPeriodNode *periodNode;
809 GstMPDSegmentListNode *segmentList;
810 GstMPDSegmentURLNode *segmentURL;
812 "<?xml version=\"1.0\"?>"
813 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
814 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
816 " <SegmentList duration=\"1\">"
817 " <SegmentURL media=\"TestMedia\""
818 " mediaRange=\"100-200\""
819 " index=\"TestIndex\""
820 " indexRange=\"300-400\">"
821 " </SegmentURL></SegmentList></Period></MPD>";
824 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
826 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
827 assert_equals_int (ret, TRUE);
829 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
830 segmentList = periodNode->SegmentList;
831 segmentURL = (GstMPDSegmentURLNode *) segmentList->SegmentURL->data;
832 assert_equals_string (segmentURL->media, "TestMedia");
833 assert_equals_uint64 (segmentURL->mediaRange->first_byte_pos, 100);
834 assert_equals_uint64 (segmentURL->mediaRange->last_byte_pos, 200);
835 assert_equals_string (segmentURL->index, "TestIndex");
836 assert_equals_uint64 (segmentURL->indexRange->first_byte_pos, 300);
837 assert_equals_uint64 (segmentURL->indexRange->last_byte_pos, 400);
839 gst_mpd_client2_free (mpdclient);
845 * Test parsing Period SegmentTemplate attributes
848 GST_START_TEST (dash_mpdparser_period_segmentTemplate)
850 GstMPDPeriodNode *periodNode;
851 GstMPDSegmentTemplateNode *segmentTemplate;
853 "<?xml version=\"1.0\"?>"
854 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
855 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
857 " <SegmentTemplate media=\"TestMedia\""
859 " index=\"TestIndex\""
860 " initialization=\"TestInitialization\""
861 " bitstreamSwitching=\"TestBitstreamSwitching\">"
862 " </SegmentTemplate></Period></MPD>";
865 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
867 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
868 assert_equals_int (ret, TRUE);
870 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
871 segmentTemplate = periodNode->SegmentTemplate;
872 assert_equals_string (segmentTemplate->media, "TestMedia");
873 assert_equals_string (segmentTemplate->index, "TestIndex");
874 assert_equals_string (segmentTemplate->initialization, "TestInitialization");
875 assert_equals_string (segmentTemplate->bitstreamSwitching,
876 "TestBitstreamSwitching");
878 gst_mpd_client2_free (mpdclient);
884 * Test parsing Period SegmentTemplate attributes where a
885 * presentationTimeOffset attribute has been specified
888 GST_START_TEST (dash_mpdparser_period_segmentTemplateWithPresentationTimeOffset)
891 "<?xml version=\"1.0\"?>"
892 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
893 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
894 " <Period start=\"PT1M\" duration=\"PT40S\">"
896 " bitstreamSwitching=\"false\""
897 " mimeType=\"video/mp4\""
898 " contentType=\"video\">"
899 " <SegmentTemplate media=\"$RepresentationID$/TestMedia-$Time$.mp4\""
900 " index=\"$RepresentationID$/TestIndex.mp4\""
902 " presentationTimeOffset=\"6000\""
903 " initialization=\"$RepresentationID$/TestInitialization\""
904 " bitstreamSwitching=\"true\">"
906 " <S d=\"400\" r=\"9\" t=\"100\"/>"
907 " </SegmentTimeline></SegmentTemplate>"
908 " <Representation bandwidth=\"95866\" frameRate=\"90000/3600\""
909 " id=\"vrep\" /></AdaptationSet></Period></MPD>";
912 GList *adaptationSets;
913 GstMPDAdaptationSetNode *adapt_set;
914 GstActiveStream *activeStream;
915 GstMediaFragmentInfo fragment;
916 GstClockTime expectedDuration;
917 GstClockTime expectedTimestamp;
918 GstMPDClient2 *mpdclient;
919 GstMPDPeriodNode *periodNode;
920 GstMPDSegmentTemplateNode *segmentTemplate;
922 mpdclient = gst_mpd_client2_new ();
923 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
924 assert_equals_int (ret, TRUE);
927 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
929 assert_equals_int (ret, TRUE);
932 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
934 fail_if (periodNode == NULL);
936 /* get the list of adaptation sets of the first period */
937 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
938 fail_if (adaptationSets == NULL);
940 /* setup streaming from the first adaptation set */
941 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
942 fail_if (adapt_set == NULL);
943 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
944 assert_equals_int (ret, TRUE);
945 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
946 fail_if (activeStream == NULL);
948 segmentTemplate = adapt_set->SegmentTemplate;
949 fail_if (segmentTemplate == NULL);
950 assert_equals_string (segmentTemplate->media,
951 "$RepresentationID$/TestMedia-$Time$.mp4");
952 assert_equals_string (segmentTemplate->index,
953 "$RepresentationID$/TestIndex.mp4");
954 assert_equals_string (segmentTemplate->initialization,
955 "$RepresentationID$/TestInitialization");
956 assert_equals_string (segmentTemplate->bitstreamSwitching, "true");
958 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
959 assert_equals_int (ret, TRUE);
960 expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 4, 0);
961 /* start = Period@start + S@t - presentationTimeOffset */
962 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 1, 0);
963 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
964 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
965 /* the $Time$ expansion uses the @t value, without including
966 Period@start or presentationTimeOffset */
967 assert_equals_string (fragment.uri, "/vrep/TestMedia-100.mp4");
968 gst_mpdparser_media_fragment_info_clear (&fragment);
970 gst_mpd_client2_free (mpdclient);
976 * Test parsing Period SegmentTemplate MultipleSegmentBaseType attributes
979 GST_START_TEST (dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType)
981 GstMPDPeriodNode *periodNode;
982 GstMPDSegmentTemplateNode *segmentTemplate;
984 "<?xml version=\"1.0\"?>"
985 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
986 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
988 " <SegmentTemplate duration=\"10\""
989 " startNumber=\"11\">"
990 " </SegmentTemplate></Period></MPD>";
993 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
995 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
996 assert_equals_int (ret, TRUE);
998 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
999 segmentTemplate = periodNode->SegmentTemplate;
1001 assert_equals_uint64 (GST_MPD_MULT_SEGMENT_BASE_NODE
1002 (segmentTemplate)->duration, 10);
1003 assert_equals_uint64 (GST_MPD_MULT_SEGMENT_BASE_NODE
1004 (segmentTemplate)->startNumber, 11);
1006 gst_mpd_client2_free (mpdclient);
1012 * Test parsing Period SegmentTemplate MultipleSegmentBaseType SegmentBaseType
1016 (dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_segmentBaseType)
1018 GstMPDPeriodNode *periodNode;
1019 GstMPDSegmentTemplateNode *segmentTemplate;
1020 GstMPDSegmentBaseNode *segmentBase;
1022 "<?xml version=\"1.0\"?>"
1023 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1024 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1026 " <SegmentTemplate timescale=\"123456\""
1028 " presentationTimeOffset=\"123456789\""
1029 " indexRange=\"100-200\""
1030 " indexRangeExact=\"true\">"
1031 " </SegmentTemplate></Period></MPD>";
1034 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1036 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1037 assert_equals_int (ret, TRUE);
1039 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1040 segmentTemplate = periodNode->SegmentTemplate;
1041 segmentBase = GST_MPD_MULT_SEGMENT_BASE_NODE (segmentTemplate)->SegmentBase;
1042 assert_equals_uint64 (segmentBase->timescale, 123456);
1043 assert_equals_uint64 (segmentBase->presentationTimeOffset, 123456789);
1044 assert_equals_uint64 (segmentBase->indexRange->first_byte_pos, 100);
1045 assert_equals_uint64 (segmentBase->indexRange->last_byte_pos, 200);
1046 assert_equals_int (segmentBase->indexRangeExact, TRUE);
1048 gst_mpd_client2_free (mpdclient);
1054 * Test parsing Period SegmentTemplate MultipleSegmentBaseType SegmentTimeline
1058 (dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_segmentTimeline)
1060 GstMPDPeriodNode *periodNode;
1061 GstMPDSegmentTemplateNode *segmentTemplate;
1062 GstMPDSegmentTimelineNode *segmentTimeline;
1064 "<?xml version=\"1.0\"?>"
1065 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1066 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1068 " <SegmentTemplate>"
1069 " <SegmentTimeline>"
1070 " </SegmentTimeline></SegmentTemplate></Period></MPD>";
1073 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1075 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1076 assert_equals_int (ret, TRUE);
1078 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1079 segmentTemplate = periodNode->SegmentTemplate;
1081 segmentTimeline = (GstMPDSegmentTimelineNode *)
1082 GST_MPD_MULT_SEGMENT_BASE_NODE (segmentTemplate)->SegmentTimeline;
1083 fail_if (segmentTimeline == NULL);
1085 gst_mpd_client2_free (mpdclient);
1091 * Test parsing Period SegmentTemplate MultipleSegmentBaseType SegmentTimeline
1095 (dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_segmentTimeline_s)
1097 GstMPDPeriodNode *periodNode;
1098 GstMPDSegmentTemplateNode *segmentTemplate;
1099 GstMPDSegmentTimelineNode *segmentTimeline;
1102 "<?xml version=\"1.0\"?>"
1103 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1104 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1106 " <SegmentTemplate>"
1107 " <SegmentTimeline>"
1108 " <S t=\"1\" d=\"2\" r=\"3\">"
1109 " </S></SegmentTimeline></SegmentTemplate></Period></MPD>";
1112 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1114 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1115 assert_equals_int (ret, TRUE);
1117 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1118 segmentTemplate = periodNode->SegmentTemplate;
1119 segmentTimeline = (GstMPDSegmentTimelineNode *)
1120 GST_MPD_MULT_SEGMENT_BASE_NODE (segmentTemplate)->SegmentTimeline;
1121 sNode = (GstMPDSNode *) g_queue_peek_head (&segmentTimeline->S);
1122 assert_equals_uint64 (sNode->t, 1);
1123 assert_equals_uint64 (sNode->d, 2);
1124 assert_equals_uint64 (sNode->r, 3);
1126 gst_mpd_client2_free (mpdclient);
1132 * Test parsing Period SegmentTemplate MultipleSegmentBaseType
1133 * BitstreamSwitching attributes
1136 (dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_bitstreamSwitching)
1138 GstMPDPeriodNode *periodNode;
1139 GstMPDSegmentTemplateNode *segmentTemplate;
1140 GstMPDURLTypeNode *bitstreamSwitching;
1142 "<?xml version=\"1.0\"?>"
1143 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1144 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1146 " <SegmentTemplate duration=\"1\">"
1147 " <BitstreamSwitching sourceURL=\"TestSourceURL\""
1148 " range=\"100-200\">"
1149 " </BitstreamSwitching></SegmentTemplate></Period></MPD>";
1152 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1154 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1155 assert_equals_int (ret, TRUE);
1157 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1158 segmentTemplate = periodNode->SegmentTemplate;
1159 bitstreamSwitching =
1160 GST_MPD_MULT_SEGMENT_BASE_NODE (segmentTemplate)->BitstreamSwitching;
1161 assert_equals_string (bitstreamSwitching->sourceURL, "TestSourceURL");
1162 assert_equals_uint64 (bitstreamSwitching->range->first_byte_pos, 100);
1163 assert_equals_uint64 (bitstreamSwitching->range->last_byte_pos, 200);
1165 gst_mpd_client2_free (mpdclient);
1171 * Test parsing Period AdaptationSet attributes
1174 GST_START_TEST (dash_mpdparser_period_adaptationSet)
1176 GstMPDPeriodNode *periodNode;
1177 GstMPDAdaptationSetNode *adaptationSet;
1179 "<?xml version=\"1.0\"?>"
1180 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1181 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1183 " <AdaptationSet id=\"7\""
1186 " contentType=\"TestContentType\""
1188 " minBandwidth=\"100\""
1189 " maxBandwidth=\"200\""
1190 " minWidth=\"1000\""
1191 " maxWidth=\"2000\""
1192 " minHeight=\"1100\""
1193 " maxHeight=\"2100\""
1194 " minFrameRate=\"25/123\""
1195 " maxFrameRate=\"26\""
1196 " segmentAlignment=\"2\""
1197 " subsegmentAlignment=\"false\""
1198 " subsegmentStartsWithSAP=\"6\""
1199 " bitstreamSwitching=\"false\">"
1200 " </AdaptationSet></Period></MPD>";
1203 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1205 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1206 assert_equals_int (ret, TRUE);
1208 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1209 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1210 assert_equals_uint64 (adaptationSet->id, 7);
1211 assert_equals_uint64 (adaptationSet->group, 8);
1212 assert_equals_string (adaptationSet->lang, "en");
1213 assert_equals_string (adaptationSet->contentType, "TestContentType");
1214 assert_equals_uint64 (adaptationSet->par->num, 4);
1215 assert_equals_uint64 (adaptationSet->par->den, 3);
1216 assert_equals_uint64 (adaptationSet->minBandwidth, 100);
1217 assert_equals_uint64 (adaptationSet->maxBandwidth, 200);
1218 assert_equals_uint64 (adaptationSet->minWidth, 1000);
1219 assert_equals_uint64 (adaptationSet->maxWidth, 2000);
1220 assert_equals_uint64 (adaptationSet->minHeight, 1100);
1221 assert_equals_uint64 (adaptationSet->maxHeight, 2100);
1222 assert_equals_uint64 (GST_MPD_REPRESENTATION_BASE_NODE
1223 (adaptationSet)->minFrameRate->num, 25);
1224 assert_equals_uint64 (GST_MPD_REPRESENTATION_BASE_NODE
1225 (adaptationSet)->minFrameRate->den, 123);
1226 assert_equals_uint64 (GST_MPD_REPRESENTATION_BASE_NODE
1227 (adaptationSet)->maxFrameRate->num, 26);
1228 assert_equals_uint64 (GST_MPD_REPRESENTATION_BASE_NODE
1229 (adaptationSet)->maxFrameRate->den, 1);
1230 assert_equals_int (adaptationSet->segmentAlignment->flag, 1);
1231 assert_equals_uint64 (adaptationSet->segmentAlignment->value, 2);
1232 assert_equals_int (adaptationSet->subsegmentAlignment->flag, 0);
1233 assert_equals_uint64 (adaptationSet->subsegmentAlignment->value, 0);
1234 assert_equals_int (adaptationSet->subsegmentStartsWithSAP, 6);
1235 assert_equals_int (adaptationSet->bitstreamSwitching, 0);
1237 gst_mpd_client2_free (mpdclient);
1243 * Test parsing Period AdaptationSet RepresentationBase attributes
1246 GST_START_TEST (dash_mpdparser_period_adaptationSet_representationBase)
1248 GstMPDPeriodNode *periodNode;
1249 GstMPDAdaptationSetNode *adaptationSet;
1250 GstMPDRepresentationBaseNode *representationBase;
1252 "<?xml version=\"1.0\"?>"
1253 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1254 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1256 " <AdaptationSet profiles=\"TestProfiles\""
1260 " frameRate=\"30/40\""
1261 " audioSamplingRate=\"TestAudioSamplingRate\""
1262 " mimeType=\"TestMimeType\""
1263 " segmentProfiles=\"TestSegmentProfiles\""
1264 " codecs=\"TestCodecs\""
1265 " maximumSAPPeriod=\"3.4\""
1266 " startWithSAP=\"0\""
1267 " maxPlayoutRate=\"1.2\""
1268 " codingDependency=\"false\""
1269 " scanType=\"progressive\">"
1270 " </AdaptationSet></Period></MPD>";
1273 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1275 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1276 assert_equals_int (ret, TRUE);
1278 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1279 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1280 representationBase = GST_MPD_REPRESENTATION_BASE_NODE (adaptationSet);
1281 assert_equals_string (representationBase->profiles, "TestProfiles");
1282 assert_equals_uint64 (representationBase->width, 100);
1283 assert_equals_uint64 (representationBase->height, 200);
1284 assert_equals_uint64 (representationBase->sar->num, 10);
1285 assert_equals_uint64 (representationBase->sar->den, 20);
1286 assert_equals_uint64 (representationBase->frameRate->num, 30);
1287 assert_equals_uint64 (representationBase->frameRate->den, 40);
1288 assert_equals_string (representationBase->audioSamplingRate,
1289 "TestAudioSamplingRate");
1290 assert_equals_string (representationBase->mimeType, "TestMimeType");
1291 assert_equals_string (representationBase->segmentProfiles,
1292 "TestSegmentProfiles");
1293 assert_equals_string (representationBase->codecs, "TestCodecs");
1294 assert_equals_float (representationBase->maximumSAPPeriod, 3.4);
1295 assert_equals_int (representationBase->startWithSAP, GST_SAP_TYPE_0);
1296 assert_equals_float (representationBase->maxPlayoutRate, 1.2);
1297 assert_equals_float (representationBase->codingDependency, 0);
1298 assert_equals_string (representationBase->scanType, "progressive");
1300 gst_mpd_client2_free (mpdclient);
1306 * Test parsing Period AdaptationSet RepresentationBase FramePacking attributes
1310 (dash_mpdparser_period_adaptationSet_representationBase_framePacking) {
1311 GstMPDPeriodNode *periodNode;
1312 GstMPDAdaptationSetNode *adaptationSet;
1313 GstMPDRepresentationBaseNode *representationBase;
1314 GstMPDDescriptorTypeNode *framePacking;
1316 "<?xml version=\"1.0\"?>"
1317 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1318 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1321 " <FramePacking schemeIdUri=\"TestSchemeIdUri\""
1322 " value=\"TestValue\">"
1323 " </FramePacking></AdaptationSet></Period></MPD>";
1326 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1328 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1329 assert_equals_int (ret, TRUE);
1331 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1332 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1333 representationBase = GST_MPD_REPRESENTATION_BASE_NODE (adaptationSet);
1335 (GstMPDDescriptorTypeNode *) representationBase->FramePacking->data;
1336 assert_equals_string (framePacking->schemeIdUri, "TestSchemeIdUri");
1337 assert_equals_string (framePacking->value, "TestValue");
1339 gst_mpd_client2_free (mpdclient);
1345 * Test parsing Period AdaptationSet RepresentationBase
1346 * AudioChannelConfiguration attributes
1349 (dash_mpdparser_period_adaptationSet_representationBase_audioChannelConfiguration)
1351 GstMPDPeriodNode *periodNode;
1352 GstMPDAdaptationSetNode *adaptationSet;
1353 GstMPDRepresentationBaseNode *representationBase;
1354 GstMPDDescriptorTypeNode *audioChannelConfiguration;
1356 "<?xml version=\"1.0\"?>"
1357 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1358 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1361 " <AudioChannelConfiguration schemeIdUri=\"TestSchemeIdUri\""
1362 " value=\"TestValue\">"
1363 " </AudioChannelConfiguration></AdaptationSet></Period></MPD>";
1366 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1368 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1369 assert_equals_int (ret, TRUE);
1371 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1372 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1373 representationBase = GST_MPD_REPRESENTATION_BASE_NODE (adaptationSet);
1374 audioChannelConfiguration = (GstMPDDescriptorTypeNode *)
1375 representationBase->AudioChannelConfiguration->data;
1376 assert_equals_string (audioChannelConfiguration->schemeIdUri,
1378 assert_equals_string (audioChannelConfiguration->value, "TestValue");
1380 gst_mpd_client2_free (mpdclient);
1386 * Test parsing Period AdaptationSet RepresentationBase ContentProtection
1390 (dash_mpdparser_period_adaptationSet_representationBase_contentProtection) {
1391 GstMPDPeriodNode *periodNode;
1392 GstMPDAdaptationSetNode *adaptationSet;
1393 GstMPDRepresentationBaseNode *representationBase;
1394 GstMPDDescriptorTypeNode *contentProtection;
1396 "<?xml version=\"1.0\"?>"
1397 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1398 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1401 " <ContentProtection schemeIdUri=\"TestSchemeIdUri\""
1402 " value=\"TestValue\">"
1403 " </ContentProtection></AdaptationSet></Period></MPD>";
1406 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1408 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1409 assert_equals_int (ret, TRUE);
1411 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1412 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1413 representationBase = GST_MPD_REPRESENTATION_BASE_NODE (adaptationSet);
1415 (GstMPDDescriptorTypeNode *) representationBase->ContentProtection->data;
1416 assert_equals_string (contentProtection->schemeIdUri, "TestSchemeIdUri");
1417 assert_equals_string (contentProtection->value, "TestValue");
1419 gst_mpd_client2_free (mpdclient);
1425 * Test parsing ContentProtection element that has no value attribute
1427 GST_START_TEST (dash_mpdparser_contentProtection_no_value)
1429 GstMPDPeriodNode *periodNode;
1430 GstMPDAdaptationSetNode *adaptationSet;
1431 GstMPDRepresentationBaseNode *representationBase;
1432 GstMPDDescriptorTypeNode *contentProtection;
1434 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
1435 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1436 " xmlns:mspr=\"urn:microsoft:playready\""
1437 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1440 " <ContentProtection schemeIdUri=\"urn:mpeg:dash:mp4protection:2011\" value=\"cenc\"/>"
1441 " <ContentProtection xmlns:mas=\"urn:marlin:mas:1-0:services:schemas:mpd\" schemeIdUri=\"urn:uuid:5e629af5-38da-4063-8977-97ffbd9902d4\">"
1442 " <mas:MarlinContentIds>"
1443 " <mas:MarlinContentId>urn:marlin:kid:02020202020202020202020202020202</mas:MarlinContentId>"
1444 " </mas:MarlinContentIds>"
1445 " </ContentProtection>"
1446 " <ContentProtection schemeIdUri=\"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95\" value=\"MSPR 2.0\">"
1447 " <mspr:pro>dGVzdA==</mspr:pro>"
1448 " </ContentProtection>" "</AdaptationSet></Period></MPD>";
1451 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1454 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1455 assert_equals_int (ret, TRUE);
1457 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1458 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1459 representationBase = GST_MPD_REPRESENTATION_BASE_NODE (adaptationSet);
1460 assert_equals_int (g_list_length (representationBase->ContentProtection), 3);
1461 contentProtection = (GstMPDDescriptorTypeNode *)
1462 g_list_nth (representationBase->ContentProtection, 1)->data;
1463 assert_equals_string (contentProtection->schemeIdUri,
1464 "urn:uuid:5e629af5-38da-4063-8977-97ffbd9902d4");
1465 fail_if (contentProtection->value == NULL);
1466 /* We can't do a simple compare of value (which should be an XML dump
1467 of the ContentProtection element), because the whitespace
1468 formatting from xmlDump might differ between versions of libxml */
1469 str = strstr (contentProtection->value, "<ContentProtection");
1470 fail_if (str == NULL);
1471 str = strstr (contentProtection->value, "<mas:MarlinContentIds>");
1472 fail_if (str == NULL);
1473 str = strstr (contentProtection->value, "<mas:MarlinContentId>");
1474 fail_if (str == NULL);
1476 strstr (contentProtection->value,
1477 "urn:marlin:kid:02020202020202020202020202020202");
1478 fail_if (str == NULL);
1479 str = strstr (contentProtection->value, "</ContentProtection>");
1480 fail_if (str == NULL);
1481 gst_mpd_client2_free (mpdclient);
1487 * Test parsing ContentProtection element that has no value attribute
1488 * nor an XML encoding
1490 GST_START_TEST (dash_mpdparser_contentProtection_no_value_no_encoding)
1492 GstMPDPeriodNode *periodNode;
1493 GstMPDAdaptationSetNode *adaptationSet;
1494 GstMPDRepresentationBaseNode *representationBase;
1495 GstMPDDescriptorTypeNode *contentProtection;
1497 "<?xml version=\"1.0\"?>"
1498 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1499 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1502 " <ContentProtection schemeIdUri=\"urn:mpeg:dash:mp4protection:2011\" value=\"cenc\"/>"
1503 " <ContentProtection xmlns:mas=\"urn:marlin:mas:1-0:services:schemas:mpd\" schemeIdUri=\"urn:uuid:5e629af5-38da-4063-8977-97ffbd9902d4\">"
1504 " <mas:MarlinContentIds>"
1505 " <mas:MarlinContentId>urn:marlin:kid:02020202020202020202020202020202</mas:MarlinContentId>"
1506 " </mas:MarlinContentIds>"
1507 " </ContentProtection>" "</AdaptationSet></Period></MPD>";
1510 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1512 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1513 assert_equals_int (ret, TRUE);
1515 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1516 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1517 representationBase = GST_MPD_REPRESENTATION_BASE_NODE (adaptationSet);
1518 assert_equals_int (g_list_length (representationBase->ContentProtection), 2);
1519 contentProtection = (GstMPDDescriptorTypeNode *)
1520 g_list_nth (representationBase->ContentProtection, 1)->data;
1521 assert_equals_string (contentProtection->schemeIdUri,
1522 "urn:uuid:5e629af5-38da-4063-8977-97ffbd9902d4");
1523 fail_if (contentProtection->value == NULL);
1524 gst_mpd_client2_free (mpdclient);
1530 * Test parsing Period AdaptationSet Accessibility attributes
1533 GST_START_TEST (dash_mpdparser_period_adaptationSet_accessibility)
1535 GstMPDPeriodNode *periodNode;
1536 GstMPDAdaptationSetNode *adaptationSet;
1537 GstMPDDescriptorTypeNode *accessibility;
1539 "<?xml version=\"1.0\"?>"
1540 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1541 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1544 " <Accessibility schemeIdUri=\"TestSchemeIdUri\""
1545 " value=\"TestValue\">"
1546 " </Accessibility></AdaptationSet></Period></MPD>";
1549 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1551 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1552 assert_equals_int (ret, TRUE);
1554 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1555 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1557 (GstMPDDescriptorTypeNode *) adaptationSet->Accessibility->data;
1558 assert_equals_string (accessibility->schemeIdUri, "TestSchemeIdUri");
1559 assert_equals_string (accessibility->value, "TestValue");
1561 gst_mpd_client2_free (mpdclient);
1567 * Test parsing Period AdaptationSet Role attributes
1570 GST_START_TEST (dash_mpdparser_period_adaptationSet_role)
1572 GstMPDPeriodNode *periodNode;
1573 GstMPDAdaptationSetNode *adaptationSet;
1574 GstMPDDescriptorTypeNode *role;
1576 "<?xml version=\"1.0\"?>"
1577 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1578 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1581 " <Role schemeIdUri=\"TestSchemeIdUri\""
1582 " value=\"TestValue\">"
1583 " </Role></AdaptationSet></Period></MPD>";
1586 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1588 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1589 assert_equals_int (ret, TRUE);
1591 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1592 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1593 role = (GstMPDDescriptorTypeNode *) adaptationSet->Role->data;
1594 assert_equals_string (role->schemeIdUri, "TestSchemeIdUri");
1595 assert_equals_string (role->value, "TestValue");
1597 gst_mpd_client2_free (mpdclient);
1603 * Test parsing Period AdaptationSet Rating attributes
1606 GST_START_TEST (dash_mpdparser_period_adaptationSet_rating)
1608 GstMPDPeriodNode *periodNode;
1609 GstMPDAdaptationSetNode *adaptationSet;
1610 GstMPDDescriptorTypeNode *rating;
1612 "<?xml version=\"1.0\"?>"
1613 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1614 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1617 " <Rating schemeIdUri=\"TestSchemeIdUri\""
1618 " value=\"TestValue\">"
1619 " </Rating></AdaptationSet></Period></MPD>";
1622 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1624 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1625 assert_equals_int (ret, TRUE);
1627 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1628 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1629 rating = (GstMPDDescriptorTypeNode *) adaptationSet->Rating->data;
1630 assert_equals_string (rating->schemeIdUri, "TestSchemeIdUri");
1631 assert_equals_string (rating->value, "TestValue");
1633 gst_mpd_client2_free (mpdclient);
1639 * Test parsing Period AdaptationSet Viewpoint attributes
1642 GST_START_TEST (dash_mpdparser_period_adaptationSet_viewpoint)
1644 GstMPDPeriodNode *periodNode;
1645 GstMPDAdaptationSetNode *adaptationSet;
1646 GstMPDDescriptorTypeNode *viewpoint;
1648 "<?xml version=\"1.0\"?>"
1649 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1650 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1653 " <Viewpoint schemeIdUri=\"TestSchemeIdUri\""
1654 " value=\"TestValue\">"
1655 " </Viewpoint></AdaptationSet></Period></MPD>";
1658 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1660 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1661 assert_equals_int (ret, TRUE);
1663 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1664 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1665 viewpoint = (GstMPDDescriptorTypeNode *) adaptationSet->Viewpoint->data;
1666 assert_equals_string (viewpoint->schemeIdUri, "TestSchemeIdUri");
1667 assert_equals_string (viewpoint->value, "TestValue");
1669 gst_mpd_client2_free (mpdclient);
1675 * Test parsing Period AdaptationSet ContentComponent attributes
1678 GST_START_TEST (dash_mpdparser_period_adaptationSet_contentComponent)
1680 GstMPDPeriodNode *periodNode;
1681 GstMPDAdaptationSetNode *adaptationSet;
1682 GstMPDContentComponentNode *contentComponent;
1684 "<?xml version=\"1.0\"?>"
1685 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1686 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1689 " <ContentComponent id=\"1\""
1691 " contentType=\"TestContentType\""
1693 " </ContentComponent></AdaptationSet></Period></MPD>";
1696 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1698 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1699 assert_equals_int (ret, TRUE);
1701 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1702 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1703 contentComponent = (GstMPDContentComponentNode *)
1704 adaptationSet->ContentComponents->data;
1705 assert_equals_uint64 (contentComponent->id, 1);
1706 assert_equals_string (contentComponent->lang, "en");
1707 assert_equals_string (contentComponent->contentType, "TestContentType");
1708 assert_equals_uint64 (contentComponent->par->num, 10);
1709 assert_equals_uint64 (contentComponent->par->den, 20);
1711 gst_mpd_client2_free (mpdclient);
1717 * Test parsing Period AdaptationSet ContentComponent Accessibility attributes
1721 (dash_mpdparser_period_adaptationSet_contentComponent_accessibility) {
1722 GstMPDPeriodNode *periodNode;
1723 GstMPDAdaptationSetNode *adaptationSet;
1724 GstMPDContentComponentNode *contentComponent;
1725 GstMPDDescriptorTypeNode *accessibility;
1727 "<?xml version=\"1.0\"?>"
1728 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1729 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1732 " <ContentComponent>"
1733 " <Accessibility schemeIdUri=\"TestSchemeIdUri\""
1734 " value=\"TestValue\">"
1736 " </ContentComponent></AdaptationSet></Period></MPD>";
1739 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1741 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1742 assert_equals_int (ret, TRUE);
1744 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1745 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1746 contentComponent = (GstMPDContentComponentNode *)
1747 adaptationSet->ContentComponents->data;
1749 (GstMPDDescriptorTypeNode *) contentComponent->Accessibility->data;
1750 assert_equals_string (accessibility->schemeIdUri, "TestSchemeIdUri");
1751 assert_equals_string (accessibility->value, "TestValue");
1753 gst_mpd_client2_free (mpdclient);
1759 * Test parsing Period AdaptationSet ContentComponent Role attributes
1762 GST_START_TEST (dash_mpdparser_period_adaptationSet_contentComponent_role)
1764 GstMPDPeriodNode *periodNode;
1765 GstMPDAdaptationSetNode *adaptationSet;
1766 GstMPDContentComponentNode *contentComponent;
1767 GstMPDDescriptorTypeNode *role;
1769 "<?xml version=\"1.0\"?>"
1770 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1771 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1774 " <ContentComponent>"
1775 " <Role schemeIdUri=\"TestSchemeIdUri\""
1776 " value=\"TestValue\">"
1777 " </Role></ContentComponent></AdaptationSet></Period></MPD>";
1780 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1782 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1783 assert_equals_int (ret, TRUE);
1785 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1786 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1787 contentComponent = (GstMPDContentComponentNode *)
1788 adaptationSet->ContentComponents->data;
1789 role = (GstMPDDescriptorTypeNode *) contentComponent->Role->data;
1790 assert_equals_string (role->schemeIdUri, "TestSchemeIdUri");
1791 assert_equals_string (role->value, "TestValue");
1793 gst_mpd_client2_free (mpdclient);
1799 * Test parsing Period AdaptationSet ContentComponent Rating attributes
1802 GST_START_TEST (dash_mpdparser_period_adaptationSet_contentComponent_rating)
1804 GstMPDPeriodNode *periodNode;
1805 GstMPDAdaptationSetNode *adaptationSet;
1806 GstMPDContentComponentNode *contentComponent;
1807 GstMPDDescriptorTypeNode *rating;
1809 "<?xml version=\"1.0\"?>"
1810 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1811 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1814 " <ContentComponent>"
1815 " <Rating schemeIdUri=\"TestSchemeIdUri\""
1816 " value=\"TestValue\">"
1818 " </ContentComponent></AdaptationSet></Period></MPD>";
1821 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1823 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1824 assert_equals_int (ret, TRUE);
1826 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1827 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1828 contentComponent = (GstMPDContentComponentNode *)
1829 adaptationSet->ContentComponents->data;
1830 rating = (GstMPDDescriptorTypeNode *) contentComponent->Rating->data;
1831 assert_equals_string (rating->schemeIdUri, "TestSchemeIdUri");
1832 assert_equals_string (rating->value, "TestValue");
1834 gst_mpd_client2_free (mpdclient);
1840 * Test parsing Period AdaptationSet ContentComponent Viewpoint attributes
1843 GST_START_TEST (dash_mpdparser_period_adaptationSet_contentComponent_viewpoint)
1845 GstMPDPeriodNode *periodNode;
1846 GstMPDAdaptationSetNode *adaptationSet;
1847 GstMPDContentComponentNode *contentComponent;
1848 GstMPDDescriptorTypeNode *viewpoint;
1850 "<?xml version=\"1.0\"?>"
1851 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1852 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1855 " <ContentComponent>"
1856 " <Viewpoint schemeIdUri=\"TestSchemeIdUri\""
1857 " value=\"TestValue\">"
1859 " </ContentComponent></AdaptationSet></Period></MPD>";
1862 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1864 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1865 assert_equals_int (ret, TRUE);
1867 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1868 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1869 contentComponent = (GstMPDContentComponentNode *)
1870 adaptationSet->ContentComponents->data;
1871 viewpoint = (GstMPDDescriptorTypeNode *) contentComponent->Viewpoint->data;
1872 assert_equals_string (viewpoint->schemeIdUri, "TestSchemeIdUri");
1873 assert_equals_string (viewpoint->value, "TestValue");
1875 gst_mpd_client2_free (mpdclient);
1881 * Test parsing Period AdaptationSet BaseURL attributes
1884 GST_START_TEST (dash_mpdparser_period_adaptationSet_baseURL)
1886 GstMPDPeriodNode *periodNode;
1887 GstMPDAdaptationSetNode *adaptationSet;
1888 GstMPDBaseURLNode *baseURL;
1890 "<?xml version=\"1.0\"?>"
1891 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1892 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1895 " <BaseURL serviceLocation=\"TestServiceLocation\""
1896 " byteRange=\"TestByteRange\">TestBaseURL</BaseURL>"
1897 " </AdaptationSet></Period></MPD>";
1900 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1902 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1903 assert_equals_int (ret, TRUE);
1905 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1906 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1907 baseURL = (GstMPDBaseURLNode *) adaptationSet->BaseURLs->data;
1908 assert_equals_string (baseURL->baseURL, "TestBaseURL");
1909 assert_equals_string (baseURL->serviceLocation, "TestServiceLocation");
1910 assert_equals_string (baseURL->byteRange, "TestByteRange");
1912 gst_mpd_client2_free (mpdclient);
1918 * Test parsing Period AdaptationSet SegmentBase attributes
1921 GST_START_TEST (dash_mpdparser_period_adaptationSet_segmentBase)
1923 GstMPDPeriodNode *periodNode;
1924 GstMPDAdaptationSetNode *adaptationSet;
1925 GstMPDSegmentBaseNode *segmentBase;
1927 "<?xml version=\"1.0\"?>"
1928 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1929 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1932 " <SegmentBase timescale=\"123456\""
1933 " presentationTimeOffset=\"123456789\""
1934 " indexRange=\"100-200\""
1935 " indexRangeExact=\"true\">"
1936 " </SegmentBase></AdaptationSet></Period></MPD>";
1939 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1941 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1942 assert_equals_int (ret, TRUE);
1944 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1945 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1946 segmentBase = adaptationSet->SegmentBase;
1947 assert_equals_uint64 (segmentBase->timescale, 123456);
1948 assert_equals_uint64 (segmentBase->presentationTimeOffset, 123456789);
1949 assert_equals_uint64 (segmentBase->indexRange->first_byte_pos, 100);
1950 assert_equals_uint64 (segmentBase->indexRange->last_byte_pos, 200);
1951 assert_equals_int (segmentBase->indexRangeExact, TRUE);
1953 gst_mpd_client2_free (mpdclient);
1959 * Test parsing Period AdaptationSet SegmentBase Initialization attributes
1962 GST_START_TEST (dash_mpdparser_period_adaptationSet_segmentBase_initialization)
1964 GstMPDPeriodNode *periodNode;
1965 GstMPDAdaptationSetNode *adaptationSet;
1966 GstMPDSegmentBaseNode *segmentBase;
1967 GstMPDURLTypeNode *initialization;
1969 "<?xml version=\"1.0\"?>"
1970 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
1971 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
1975 " <Initialisation sourceURL=\"TestSourceURL\""
1976 " range=\"100-200\">"
1977 " </Initialisation></SegmentBase></AdaptationSet></Period></MPD>";
1980 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
1982 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
1983 assert_equals_int (ret, TRUE);
1985 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
1986 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
1987 segmentBase = adaptationSet->SegmentBase;
1988 initialization = segmentBase->Initialization;
1989 assert_equals_string (initialization->sourceURL, "TestSourceURL");
1990 assert_equals_uint64 (initialization->range->first_byte_pos, 100);
1991 assert_equals_uint64 (initialization->range->last_byte_pos, 200);
1993 gst_mpd_client2_free (mpdclient);
1999 * Test parsing Period AdaptationSet SegmentBase RepresentationIndex attributes
2003 (dash_mpdparser_period_adaptationSet_segmentBase_representationIndex) {
2004 GstMPDPeriodNode *periodNode;
2005 GstMPDAdaptationSetNode *adaptationSet;
2006 GstMPDSegmentBaseNode *segmentBase;
2007 GstMPDURLTypeNode *representationIndex;
2009 "<?xml version=\"1.0\"?>"
2010 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2011 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2015 " <RepresentationIndex sourceURL=\"TestSourceURL\""
2016 " range=\"100-200\">"
2017 " </RepresentationIndex>"
2018 " </SegmentBase></AdaptationSet></Period></MPD>";
2021 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2023 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2024 assert_equals_int (ret, TRUE);
2026 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2027 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2028 segmentBase = adaptationSet->SegmentBase;
2029 representationIndex = segmentBase->RepresentationIndex;
2030 assert_equals_string (representationIndex->sourceURL, "TestSourceURL");
2031 assert_equals_uint64 (representationIndex->range->first_byte_pos, 100);
2032 assert_equals_uint64 (representationIndex->range->last_byte_pos, 200);
2034 gst_mpd_client2_free (mpdclient);
2040 * Test parsing Period AdaptationSet SegmentList attributes
2043 GST_START_TEST (dash_mpdparser_period_adaptationSet_segmentList)
2045 GstMPDPeriodNode *periodNode;
2046 GstMPDAdaptationSetNode *adaptationSet;
2047 GstMPDSegmentListNode *segmentList;
2049 "<?xml version=\"1.0\"?>"
2050 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2051 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2054 " <SegmentList duration=\"1\"></SegmentList></AdaptationSet></Period></MPD>";
2057 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2059 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2060 assert_equals_int (ret, TRUE);
2062 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2063 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2064 segmentList = adaptationSet->SegmentList;
2065 fail_if (segmentList == NULL);
2067 gst_mpd_client2_free (mpdclient);
2073 * Test parsing Period AdaptationSet SegmentTemplate attributes
2076 GST_START_TEST (dash_mpdparser_period_adaptationSet_segmentTemplate)
2078 GstMPDPeriodNode *periodNode;
2079 GstMPDAdaptationSetNode *adaptationSet;
2080 GstMPDSegmentTemplateNode *segmentTemplate;
2082 "<?xml version=\"1.0\"?>"
2083 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2084 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2087 " <SegmentTemplate media=\"TestMedia\""
2089 " index=\"TestIndex\""
2090 " initialization=\"TestInitialization\""
2091 " bitstreamSwitching=\"TestBitstreamSwitching\">"
2092 " </SegmentTemplate></AdaptationSet></Period></MPD>";
2095 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2097 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2098 assert_equals_int (ret, TRUE);
2100 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2101 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2102 segmentTemplate = adaptationSet->SegmentTemplate;
2103 assert_equals_string (segmentTemplate->media, "TestMedia");
2104 assert_equals_string (segmentTemplate->index, "TestIndex");
2105 assert_equals_string (segmentTemplate->initialization, "TestInitialization");
2106 assert_equals_string (segmentTemplate->bitstreamSwitching,
2107 "TestBitstreamSwitching");
2109 gst_mpd_client2_free (mpdclient);
2116 (dash_mpdparser_period_adaptationSet_representation_segmentTemplate_inherit)
2118 GstMPDPeriodNode *periodNode;
2119 GstMPDAdaptationSetNode *adaptationSet;
2120 GstMPDRepresentationNode *representation;
2121 GstMPDSegmentTemplateNode *segmentTemplate;
2123 "<?xml version=\"1.0\"?>"
2124 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2125 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2127 " <SegmentTemplate media=\"ParentMedia\" duration=\"1\" "
2128 " initialization=\"ParentInitialization\">"
2129 " </SegmentTemplate>"
2131 " <Representation id=\"1\" bandwidth=\"5000\">"
2132 " <SegmentTemplate media=\"TestMedia\""
2133 " index=\"TestIndex\""
2134 " bitstreamSwitching=\"TestBitstreamSwitching\">"
2135 " </SegmentTemplate></Representation></AdaptationSet></Period></MPD>";
2138 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2140 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2141 assert_equals_int (ret, TRUE);
2143 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2144 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2146 (GstMPDRepresentationNode *) adaptationSet->Representations->data;
2147 segmentTemplate = representation->SegmentTemplate;
2148 assert_equals_string (segmentTemplate->media, "TestMedia");
2149 assert_equals_string (segmentTemplate->index, "TestIndex");
2150 assert_equals_string (segmentTemplate->initialization,
2151 "ParentInitialization");
2152 assert_equals_string (segmentTemplate->bitstreamSwitching,
2153 "TestBitstreamSwitching");
2155 gst_mpd_client2_free (mpdclient);
2161 (dash_mpdparser_period_adaptationSet_representation_segmentBase_inherit) {
2162 GstMPDPeriodNode *periodNode;
2163 GstMPDAdaptationSetNode *adaptationSet;
2164 GstMPDRepresentationNode *representation;
2165 GstMPDSegmentBaseNode *segmentBase;
2167 "<?xml version=\"1.0\"?>"
2168 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2169 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2171 " <SegmentBase timescale=\"123456\""
2172 " presentationTimeOffset=\"123456789\""
2173 " indexRange=\"100-200\""
2174 " indexRangeExact=\"true\">"
2175 " <Initialisation sourceURL=\"TestSourceURL\""
2176 " range=\"100-200\" />"
2179 " <Representation id=\"1\" bandwidth=\"5000\">"
2181 " </SegmentBase></Representation></AdaptationSet></Period></MPD>";
2184 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2186 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2187 assert_equals_int (ret, TRUE);
2189 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2190 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2192 (GstMPDRepresentationNode *) adaptationSet->Representations->data;
2193 segmentBase = representation->SegmentBase;
2194 assert_equals_int (segmentBase->timescale, 123456);
2196 gst_mpd_client2_free (mpdclient);
2202 * Test parsing Period AdaptationSet SegmentTemplate attributes with
2205 GST_START_TEST (dash_mpdparser_adapt_repr_segmentTemplate_inherit)
2207 GstMPDPeriodNode *periodNode;
2208 GstMPDAdaptationSetNode *adaptationSet;
2209 GstMPDSegmentTemplateNode *segmentTemplate;
2210 GstMPDRepresentationNode *representation;
2211 GstMPDSegmentBaseNode *segmentBase;
2213 "<?xml version=\"1.0\"?>"
2214 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2215 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2216 " <Period duration=\"PT0H5M0.000S\">"
2217 " <AdaptationSet maxWidth=\"1280\" maxHeight=\"720\" maxFrameRate=\"50\">"
2218 " <SegmentTemplate initialization=\"set1_init.mp4\"/>"
2219 " <Representation id=\"1\" mimeType=\"video/mp4\" codecs=\"avc1.640020\" "
2220 " width=\"1280\" height=\"720\" frameRate=\"50\" bandwidth=\"30000\">"
2221 " <SegmentTemplate timescale=\"12800\" media=\"track1_$Number$.m4s\" startNumber=\"1\" duration=\"25600\"/>"
2222 " </Representation></AdaptationSet></Period></MPD>";
2225 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2227 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2228 assert_equals_int (ret, TRUE);
2230 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2231 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2232 representation = (GstMPDRepresentationNode *)
2233 adaptationSet->Representations->data;
2234 segmentTemplate = representation->SegmentTemplate;
2235 fail_if (segmentTemplate == NULL);
2236 segmentBase = GST_MPD_MULT_SEGMENT_BASE_NODE (segmentTemplate)->SegmentBase;
2238 assert_equals_uint64 (segmentBase->timescale, 12800);
2239 assert_equals_uint64 (GST_MPD_MULT_SEGMENT_BASE_NODE
2240 (segmentTemplate)->duration, 25600);
2241 assert_equals_uint64 (GST_MPD_MULT_SEGMENT_BASE_NODE
2242 (segmentTemplate)->startNumber, 1);
2243 assert_equals_string (segmentTemplate->media, "track1_$Number$.m4s");
2244 assert_equals_string (segmentTemplate->initialization, "set1_init.mp4");
2246 gst_mpd_client2_free (mpdclient);
2251 * Test parsing Period AdaptationSet SegmentTemplate attributes with
2254 GST_START_TEST (dash_mpdparser_period_adaptationSet_segmentTemplate_inherit)
2256 GstMPDPeriodNode *periodNode;
2257 GstMPDAdaptationSetNode *adaptationSet;
2258 GstMPDSegmentTemplateNode *segmentTemplate;
2260 "<?xml version=\"1.0\"?>"
2261 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2262 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2264 " <SegmentTemplate media=\"ParentMedia\" duration=\"1\" "
2265 " initialization=\"ParentInitialization\">"
2266 " </SegmentTemplate>"
2268 " <SegmentTemplate media=\"TestMedia\""
2270 " index=\"TestIndex\""
2271 " bitstreamSwitching=\"TestBitstreamSwitching\">"
2272 " </SegmentTemplate></AdaptationSet></Period></MPD>";
2275 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2277 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2278 assert_equals_int (ret, TRUE);
2280 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2281 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2282 segmentTemplate = adaptationSet->SegmentTemplate;
2283 assert_equals_string (segmentTemplate->media, "TestMedia");
2284 assert_equals_string (segmentTemplate->index, "TestIndex");
2285 assert_equals_string (segmentTemplate->initialization,
2286 "ParentInitialization");
2287 assert_equals_string (segmentTemplate->bitstreamSwitching,
2288 "TestBitstreamSwitching");
2290 gst_mpd_client2_free (mpdclient);
2296 * Test parsing Period AdaptationSet Representation attributes
2299 GST_START_TEST (dash_mpdparser_period_adaptationSet_representation)
2301 GstMPDPeriodNode *periodNode;
2302 GstMPDAdaptationSetNode *adaptationSet;
2303 GstMPDRepresentationNode *representation;
2305 "<?xml version=\"1.0\"?>"
2306 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2307 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2310 " <Representation id=\"Test_Id\""
2311 " bandwidth=\"100\""
2312 " qualityRanking=\"200\""
2313 " dependencyId=\"one two three\""
2314 " mediaStreamStructureId=\"\">"
2315 " </Representation></AdaptationSet></Period></MPD>";
2318 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2320 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2321 assert_equals_int (ret, TRUE);
2323 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2324 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2325 representation = (GstMPDRepresentationNode *)
2326 adaptationSet->Representations->data;
2327 assert_equals_string (representation->id, "Test_Id");
2328 assert_equals_uint64 (representation->bandwidth, 100);
2329 assert_equals_uint64 (representation->qualityRanking, 200);
2330 assert_equals_string (representation->dependencyId[0], "one");
2331 assert_equals_string (representation->dependencyId[1], "two");
2332 assert_equals_string (representation->dependencyId[2], "three");
2333 assert_equals_pointer (representation->dependencyId[3], NULL);
2334 assert_equals_pointer (representation->mediaStreamStructureId[0], NULL);
2336 gst_mpd_client2_free (mpdclient);
2342 * Test parsing Period AdaptationSet Representation RepresentationBaseType attributes
2346 (dash_mpdparser_period_adaptationSet_representation_representationBase) {
2347 GstMPDPeriodNode *periodNode;
2348 GstMPDAdaptationSetNode *adaptationSet;
2349 GstMPDRepresentationNode *representation;
2352 "<?xml version=\"1.0\"?>"
2353 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2354 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2357 " <Representation id=\"1\" bandwidth=\"250000\">"
2358 " </Representation></AdaptationSet></Period></MPD>";
2361 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2363 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2364 assert_equals_int (ret, TRUE);
2366 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2367 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2368 representation = (GstMPDRepresentationNode *)
2369 adaptationSet->Representations->data;
2371 fail_if (representation == NULL);
2373 gst_mpd_client2_free (mpdclient);
2379 * Test parsing Period AdaptationSet Representation BaseURL attributes
2382 GST_START_TEST (dash_mpdparser_period_adaptationSet_representation_baseURL)
2384 GstMPDPeriodNode *periodNode;
2385 GstMPDAdaptationSetNode *adaptationSet;
2386 GstMPDRepresentationNode *representation;
2387 GstMPDBaseURLNode *baseURL;
2389 "<?xml version=\"1.0\"?>"
2390 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2391 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2394 " <Representation id=\"1\" bandwidth=\"250000\">"
2395 " <BaseURL serviceLocation=\"TestServiceLocation\""
2396 " byteRange=\"TestByteRange\">TestBaseURL</BaseURL>"
2397 " </Representation></AdaptationSet></Period></MPD>";
2400 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2402 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2403 assert_equals_int (ret, TRUE);
2405 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2406 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2407 representation = (GstMPDRepresentationNode *)
2408 adaptationSet->Representations->data;
2409 baseURL = (GstMPDBaseURLNode *) representation->BaseURLs->data;
2410 assert_equals_string (baseURL->baseURL, "TestBaseURL");
2411 assert_equals_string (baseURL->serviceLocation, "TestServiceLocation");
2412 assert_equals_string (baseURL->byteRange, "TestByteRange");
2414 gst_mpd_client2_free (mpdclient);
2420 * Test parsing Period AdaptationSet Representation SubRepresentation attributes
2424 (dash_mpdparser_period_adaptationSet_representation_subRepresentation) {
2425 GstMPDPeriodNode *periodNode;
2426 GstMPDAdaptationSetNode *adaptationSet;
2427 GstMPDRepresentationNode *representation;
2428 GstMPDSubRepresentationNode *subRepresentation;
2430 "<?xml version=\"1.0\"?>"
2431 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2432 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2435 " <Representation id=\"1\" bandwidth=\"250000\">"
2436 " <SubRepresentation level=\"100\""
2437 " dependencyLevel=\"1 2 3\""
2438 " bandwidth=\"200\""
2439 " contentComponent=\"content1 content2\">"
2440 " </SubRepresentation>"
2441 " </Representation></AdaptationSet></Period></MPD>";
2444 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2446 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2447 assert_equals_int (ret, TRUE);
2449 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2450 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2451 representation = (GstMPDRepresentationNode *)
2452 adaptationSet->Representations->data;
2453 subRepresentation = (GstMPDSubRepresentationNode *)
2454 representation->SubRepresentations->data;
2455 assert_equals_uint64 (subRepresentation->level, 100);
2456 assert_equals_uint64 (subRepresentation->dependencyLevel_size, 3);
2457 assert_equals_uint64 (subRepresentation->dependencyLevel[0], 1);
2458 assert_equals_uint64 (subRepresentation->dependencyLevel[1], 2);
2459 assert_equals_uint64 (subRepresentation->dependencyLevel[2], 3);
2460 assert_equals_uint64 (subRepresentation->bandwidth, 200);
2461 assert_equals_string (subRepresentation->contentComponent[0], "content1");
2462 assert_equals_string (subRepresentation->contentComponent[1], "content2");
2463 assert_equals_pointer (subRepresentation->contentComponent[2], NULL);
2465 gst_mpd_client2_free (mpdclient);
2471 * Test parsing Period AdaptationSet Representation SubRepresentation
2472 * RepresentationBase attributes
2475 (dash_mpdparser_period_adaptationSet_representation_subRepresentation_representationBase)
2477 GstMPDPeriodNode *periodNode;
2478 GstMPDAdaptationSetNode *adaptationSet;
2479 GstMPDRepresentationNode *representation;
2480 GstMPDSubRepresentationNode *subRepresentation;
2483 "<?xml version=\"1.0\"?>"
2484 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2485 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2488 " <Representation id=\"1\" bandwidth=\"250000\">"
2489 " <SubRepresentation>"
2490 " </SubRepresentation>"
2491 " </Representation></AdaptationSet></Period></MPD>";
2494 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2496 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2497 assert_equals_int (ret, TRUE);
2499 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2500 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2501 representation = (GstMPDRepresentationNode *)
2502 adaptationSet->Representations->data;
2503 subRepresentation = (GstMPDSubRepresentationNode *)
2504 representation->SubRepresentations->data;
2506 fail_if (subRepresentation == NULL);
2508 gst_mpd_client2_free (mpdclient);
2514 * Test parsing Period AdaptationSet Representation SegmentBase attributes
2517 GST_START_TEST (dash_mpdparser_period_adaptationSet_representation_segmentBase)
2519 GstMPDPeriodNode *periodNode;
2520 GstMPDAdaptationSetNode *adaptationSet;
2521 GstMPDRepresentationNode *representation;
2522 GstMPDSegmentBaseNode *segmentBase;
2524 "<?xml version=\"1.0\"?>"
2525 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2526 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2529 " <Representation id=\"1\" bandwidth=\"250000\">"
2532 " </Representation></AdaptationSet></Period></MPD>";
2535 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2537 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2538 assert_equals_int (ret, TRUE);
2540 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2541 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2542 representation = (GstMPDRepresentationNode *)
2543 adaptationSet->Representations->data;
2544 segmentBase = representation->SegmentBase;
2545 fail_if (segmentBase == NULL);
2547 gst_mpd_client2_free (mpdclient);
2553 * Test parsing Period AdaptationSet Representation SegmentList attributes
2556 GST_START_TEST (dash_mpdparser_period_adaptationSet_representation_segmentList)
2558 GstMPDPeriodNode *periodNode;
2559 GstMPDAdaptationSetNode *adaptationSet;
2560 GstMPDRepresentationNode *representation;
2561 GstMPDSegmentListNode *segmentList;
2563 "<?xml version=\"1.0\"?>"
2564 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2565 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2568 " <Representation id=\"1\" bandwidth=\"250000\">"
2569 " <SegmentList duration=\"1\">"
2571 " </Representation></AdaptationSet></Period></MPD>";
2574 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2576 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2577 assert_equals_int (ret, TRUE);
2579 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2580 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2581 representation = (GstMPDRepresentationNode *)
2582 adaptationSet->Representations->data;
2583 segmentList = representation->SegmentList;
2584 fail_if (segmentList == NULL);
2586 gst_mpd_client2_free (mpdclient);
2592 * Test parsing Period AdaptationSet Representation SegmentTemplate attributes
2596 (dash_mpdparser_period_adaptationSet_representation_segmentTemplate) {
2597 GstMPDPeriodNode *periodNode;
2598 GstMPDAdaptationSetNode *adaptationSet;
2599 GstMPDRepresentationNode *representation;
2600 GstMPDSegmentTemplateNode *segmentTemplate;
2602 "<?xml version=\"1.0\"?>"
2603 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2604 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2607 " <Representation id=\"1\" bandwidth=\"250000\">"
2608 " <SegmentTemplate duration=\"1\">"
2609 " </SegmentTemplate>"
2610 " </Representation></AdaptationSet></Period></MPD>";
2613 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2615 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2616 assert_equals_int (ret, TRUE);
2618 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2619 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
2620 representation = (GstMPDRepresentationNode *)
2621 adaptationSet->Representations->data;
2622 segmentTemplate = representation->SegmentTemplate;
2623 fail_if (segmentTemplate == NULL);
2625 gst_mpd_client2_free (mpdclient);
2631 * Test parsing Period Subset attributes
2634 GST_START_TEST (dash_mpdparser_period_subset)
2636 GstMPDPeriodNode *periodNode;
2637 GstMPDSubsetNode *subset;
2639 "<?xml version=\"1.0\"?>"
2640 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2641 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2642 " <Period><Subset contains=\"1 2 3\"></Subset></Period></MPD>";
2645 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2647 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2648 assert_equals_int (ret, TRUE);
2650 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
2651 subset = (GstMPDSubsetNode *) periodNode->Subsets->data;
2652 assert_equals_uint64 (subset->contains_size, 3);
2653 assert_equals_uint64 (subset->contains[0], 1);
2654 assert_equals_uint64 (subset->contains[1], 2);
2655 assert_equals_uint64 (subset->contains[2], 3);
2657 gst_mpd_client2_free (mpdclient);
2663 * Test parsing UTCTiming elements
2666 GST_START_TEST (dash_mpdparser_utctiming)
2669 "<?xml version=\"1.0\"?>"
2670 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2671 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2672 "<UTCTiming schemeIdUri=\"urn:mpeg:dash:utc:http-xsdate:2014\" value=\"http://time.akamai.com/?iso http://example.time/xsdate\"/>"
2673 "<UTCTiming schemeIdUri=\"urn:mpeg:dash:utc:direct:2014\" value=\"2002-05-30T09:30:10Z \"/>"
2674 "<UTCTiming schemeIdUri=\"urn:mpeg:dash:utc:ntp:2014\" value=\"0.europe.pool.ntp.org 1.europe.pool.ntp.org 2.europe.pool.ntp.org 3.europe.pool.ntp.org\"/>"
2677 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2678 GstMPDUTCTimingType selected_method;
2681 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2683 assert_equals_int (ret, TRUE);
2684 fail_if (mpdclient->mpd_root_node == NULL);
2685 fail_if (mpdclient->mpd_root_node->UTCTimings == NULL);
2686 assert_equals_int (g_list_length (mpdclient->mpd_root_node->UTCTimings), 3);
2688 gst_mpd_client2_get_utc_timing_sources (mpdclient,
2689 GST_MPD_UTCTIMING_TYPE_HTTP_XSDATE, &selected_method);
2690 fail_if (urls == NULL);
2691 assert_equals_int (selected_method, GST_MPD_UTCTIMING_TYPE_HTTP_XSDATE);
2692 assert_equals_int (g_strv_length (urls), 2);
2693 assert_equals_string (urls[0], "http://time.akamai.com/?iso");
2694 assert_equals_string (urls[1], "http://example.time/xsdate");
2696 gst_mpd_client2_get_utc_timing_sources (mpdclient,
2697 GST_MPD_UTCTIMING_TYPE_HTTP_XSDATE | GST_MPD_UTCTIMING_TYPE_HTTP_ISO,
2699 fail_if (urls == NULL);
2700 assert_equals_int (selected_method, GST_MPD_UTCTIMING_TYPE_HTTP_XSDATE);
2702 gst_mpd_client2_get_utc_timing_sources (mpdclient,
2703 GST_MPD_UTCTIMING_TYPE_DIRECT, NULL);
2704 fail_if (urls == NULL);
2705 assert_equals_int (g_strv_length (urls), 1);
2706 assert_equals_string (urls[0], "2002-05-30T09:30:10Z ");
2708 gst_mpd_client2_get_utc_timing_sources (mpdclient,
2709 GST_MPD_UTCTIMING_TYPE_HTTP_XSDATE | GST_MPD_UTCTIMING_TYPE_DIRECT,
2711 fail_if (urls == NULL);
2712 assert_equals_int (selected_method, GST_MPD_UTCTIMING_TYPE_HTTP_XSDATE);
2714 gst_mpd_client2_get_utc_timing_sources (mpdclient,
2715 GST_MPD_UTCTIMING_TYPE_NTP, &selected_method);
2716 fail_if (urls == NULL);
2717 assert_equals_int (selected_method, GST_MPD_UTCTIMING_TYPE_NTP);
2718 assert_equals_int (g_strv_length (urls), 4);
2719 assert_equals_string (urls[0], "0.europe.pool.ntp.org");
2720 assert_equals_string (urls[1], "1.europe.pool.ntp.org");
2721 assert_equals_string (urls[2], "2.europe.pool.ntp.org");
2722 assert_equals_string (urls[3], "3.europe.pool.ntp.org");
2723 gst_mpd_client2_free (mpdclient);
2729 * Test parsing invalid UTCTiming values:
2730 * - elements with no schemeIdUri property should be rejected
2731 * - elements with no value property should be rejected
2732 * - elements with unrecognised UTCTiming scheme should be rejected
2733 * - elements with empty values should be rejected
2736 GST_START_TEST (dash_mpdparser_utctiming_invalid_value)
2739 "<?xml version=\"1.0\"?>"
2740 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2741 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2742 "<UTCTiming invalid_schemeIdUri=\"dummy.uri.scheme\" value=\"dummy value\"/>"
2743 "<UTCTiming schemeIdUri=\"urn:mpeg:dash:utc:ntp:2014\" invalid_value=\"dummy value\"/>"
2744 "<UTCTiming schemeIdUri=\"dummy.uri.scheme\" value=\"dummy value\"/>"
2745 "<UTCTiming schemeIdUri=\"urn:mpeg:dash:utc:ntp:2014\" value=\"\"/>"
2748 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2750 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2752 assert_equals_int (ret, TRUE);
2753 fail_if (mpdclient->mpd_root_node == NULL);
2754 fail_if (mpdclient->mpd_root_node->UTCTimings != NULL);
2755 gst_mpd_client2_free (mpdclient);
2761 * Test parsing the type property: value "dynamic"
2764 GST_START_TEST (dash_mpdparser_type_dynamic)
2769 "<?xml version=\"1.0\"?>"
2770 "<MPD type=\"dynamic\" xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2771 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\"> </MPD>";
2774 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2776 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2777 assert_equals_int (ret, TRUE);
2779 isLive = gst_mpd_client2_is_live (mpdclient);
2780 assert_equals_int (isLive, 1);
2782 gst_mpd_client2_free (mpdclient);
2788 * Validate gst_mpdparser_build_URL_from_template function
2791 GST_START_TEST (dash_mpdparser_template_parsing)
2793 const gchar *id = "TestId";
2795 guint bandwidth = 2500;
2801 const gchar *urlTemplate;
2802 const gchar *expectedResponse;
2805 /* various test scenarios to attempt */
2806 struct TestUrl testUrl[] = {
2807 {"", NULL}, /* empty string for template */
2808 {"$$", "$"}, /* escaped $ */
2809 {"Number", "Number"}, /* string similar with an identifier, but without $ */
2810 {"Number$Number$", "Number7"}, /* Number identifier */
2811 {"Number$Number$$$", "Number7$"}, /* Number identifier followed by $$ */
2812 {"Number$Number$Number$Number$", "Number7Number7"}, /* series of "Number" string and Number identifier */
2813 {"Representation$RepresentationID$", "RepresentationTestId"}, /* RepresentationID identifier */
2814 {"TestMedia$Bandwidth$$$test", "TestMedia2500$test"}, /* Bandwidth identifier */
2815 {"TestMedia$Time$", "TestMedia100"}, /* Time identifier */
2816 {"TestMedia$Time", NULL}, /* Identifier not finished with $ */
2817 {"Time$Time%d$", NULL}, /* usage of %d (no width) */
2818 {"Time$Time%0d$", "Time100"}, /* usage of format smaller than number of digits */
2819 {"Time$Time%01d$", "Time100"}, /* usage of format smaller than number of digits */
2820 {"Time$Time%05d$", "Time00100"}, /* usage of format bigger than number of digits */
2821 {"Time$Time%05dtest$", "Time00100test"}, /* usage extra text in format */
2822 {"Time$Time%3d$", NULL}, /* incorrect format: width does not start with 0 */
2823 {"Time$Time%0-4d$", NULL}, /* incorrect format: width is not a number */
2824 {"Time$Time%0$", NULL}, /* incorrect format: no d, x or u */
2825 {"Time$Time1%01d$", NULL}, /* incorrect format: does not start with % after identifier */
2826 {"$Bandwidth%/init.mp4v", NULL}, /* incorrect identifier: not finished with $ */
2827 {"$Number%/$Time$.mp4v", NULL}, /* incorrect number of $ separators */
2828 {"$RepresentationID1$", NULL}, /* incorrect identifier */
2829 {"$Bandwidth1$", NULL}, /* incorrect identifier */
2830 {"$Number1$", NULL}, /* incorrect identifier */
2831 {"$RepresentationID%01d$", NULL}, /* incorrect format: RepresentationID does not support formatting */
2832 {"Time$Time%05u$", NULL}, /* %u format */
2833 {"Time$Time%05x$", NULL}, /* %x format */
2834 {"Time$Time%05utest$", NULL}, /* %u format followed by text */
2835 {"Time$Time%05xtest$", NULL}, /* %x format followed by text */
2836 {"Time$Time%05xtest%$", NULL}, /* second % character in format */
2839 guint count = sizeof (testUrl) / sizeof (testUrl[0]);
2842 for (i = 0; i < count; i++) {
2844 gst_mpdparser_build_URL_from_template (testUrl[i].urlTemplate, id,
2845 number, bandwidth, time);
2846 assert_equals_string (result, testUrl[i].expectedResponse);
2854 * Test handling isoff ondemand profile
2857 GST_START_TEST (dash_mpdparser_isoff_ondemand_profile)
2859 gboolean hasOnDemandProfile;
2862 "<?xml version=\"1.0\"?>"
2863 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2864 " profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"></MPD>";
2867 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2869 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2870 assert_equals_int (ret, TRUE);
2872 hasOnDemandProfile = gst_mpd_client2_has_isoff_ondemand_profile (mpdclient);
2873 assert_equals_int (hasOnDemandProfile, 1);
2875 gst_mpd_client2_free (mpdclient);
2881 * Test handling GstDateTime
2884 GST_START_TEST (dash_mpdparser_GstDateTime)
2893 time1 = gst_date_time_new_from_iso8601_string ("2012-06-23T23:30:59Z");
2894 time2 = gst_date_time_new_from_iso8601_string ("2012-06-23T23:31:00Z");
2896 delta = gst_mpd_client2_calculate_time_difference (time1, time2);
2897 assert_equals_int64 (delta, 1 * GST_SECOND);
2899 time3 = gst_mpd_client2_add_time_difference (time1, delta);
2901 /* convert to GDateTime in order to compare time2 and time 3 */
2902 g_time2 = gst_date_time_to_g_date_time (time2);
2903 g_time3 = gst_date_time_to_g_date_time (time3);
2904 fail_if (g_date_time_compare (g_time2, g_time3) != 0);
2906 gst_date_time_unref (time1);
2907 gst_date_time_unref (time2);
2908 gst_date_time_unref (time3);
2909 g_date_time_unref (g_time2);
2910 g_date_time_unref (g_time3);
2916 * Test bitstreamSwitching inheritance from Period to AdaptationSet
2918 * Description of bistreamSwitching attribute in Period:
2919 * "When set to ‘true’, this is equivalent as if the
2920 * AdaptationSet@bitstreamSwitching for each Adaptation Set contained in this
2921 * Period is set to 'true'. In this case, the AdaptationSet@bitstreamSwitching
2922 * attribute shall not be set to 'false' for any Adaptation Set in this Period"
2925 GST_START_TEST (dash_mpdparser_bitstreamSwitching_inheritance)
2927 GList *adaptationSets;
2928 GstMPDAdaptationSetNode *adapt_set;
2929 guint activeStreams;
2930 GstActiveStream *activeStream;
2933 gboolean bitstreamSwitchingFlag;
2936 "<?xml version=\"1.0\"?>"
2937 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
2938 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
2939 " <Period id=\"Period0\""
2940 " duration=\"P0Y0M1DT1H1M1S\""
2941 " bitstreamSwitching=\"true\">"
2942 " <AdaptationSet id=\"1\""
2943 " mimeType=\"video/mp4\">"
2944 " <Representation id=\"1\" bandwidth=\"250000\">"
2945 " </Representation>"
2947 " <AdaptationSet id=\"2\""
2948 " mimeType=\"audio\""
2949 " bitstreamSwitching=\"false\">"
2950 " <Representation id=\"2\" bandwidth=\"250000\">"
2951 " </Representation></AdaptationSet></Period></MPD>";
2954 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
2956 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
2957 assert_equals_int (ret, TRUE);
2959 /* process the xml data */
2961 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
2963 assert_equals_int (ret, TRUE);
2965 /* get the list of adaptation sets of the first period */
2966 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
2967 fail_if (adaptationSets == NULL);
2969 /* setup streaming from the first adaptation set */
2970 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
2971 fail_if (adapt_set == NULL);
2972 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
2973 assert_equals_int (ret, TRUE);
2975 /* setup streaming from the second adaptation set */
2976 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 1);
2977 fail_if (adapt_set == NULL);
2978 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
2979 assert_equals_int (ret, TRUE);
2981 /* 2 active streams */
2982 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
2983 assert_equals_int (activeStreams, 2);
2985 /* get details of the first active stream */
2986 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
2987 fail_if (activeStream == NULL);
2989 assert_equals_int (activeStream->mimeType, GST_STREAM_VIDEO);
2990 caps = gst_mpd_client2_get_stream_caps (activeStream);
2991 fail_unless (caps != NULL);
2992 s = gst_caps_get_structure (caps, 0);
2993 assert_equals_string (gst_structure_get_name (s), "video/quicktime");
2994 gst_caps_unref (caps);
2996 /* inherited from Period's bitstreamSwitching */
2997 bitstreamSwitchingFlag =
2998 gst_mpd_client2_get_bitstream_switching_flag (activeStream);
2999 assert_equals_int (bitstreamSwitchingFlag, TRUE);
3001 /* get details of the second active stream */
3002 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 1);
3003 fail_if (activeStream == NULL);
3005 assert_equals_int (activeStream->mimeType, GST_STREAM_AUDIO);
3006 caps = gst_mpd_client2_get_stream_caps (activeStream);
3007 fail_unless (caps != NULL);
3008 s = gst_caps_get_structure (caps, 0);
3009 assert_equals_string (gst_structure_get_name (s), "audio");
3010 gst_caps_unref (caps);
3012 /* set to FALSE in our example, but overwritten to TRUE by Period's
3013 * bitstreamSwitching
3015 bitstreamSwitchingFlag =
3016 gst_mpd_client2_get_bitstream_switching_flag (activeStream);
3017 assert_equals_int (bitstreamSwitchingFlag, TRUE);
3019 gst_mpd_client2_free (mpdclient);
3025 * Test various duration formats
3027 GST_START_TEST (dash_mpdparser_various_duration_formats)
3029 GstMPDPeriodNode *periodNode;
3031 "<?xml version=\"1.0\"?>"
3032 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3033 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
3034 " availabilityStartTime=\"2015-03-24T0:0:0\""
3035 " mediaPresentationDuration=\"P100Y\">"
3036 " <Period id=\"Period0\" start=\"PT1S\"></Period>"
3037 " <Period id=\"Period1\" start=\"PT1.5S\"></Period>"
3038 " <Period id=\"Period2\" start=\"PT1,7S\"></Period>"
3039 " <Period id=\"Period3\" start=\"PT1M\"></Period>"
3040 " <Period id=\"Period4\" start=\"PT1H\"></Period>"
3041 " <Period id=\"Period5\" start=\"P1D\"></Period>"
3042 " <Period id=\"Period6\" start=\"P1M\"></Period>"
3043 " <Period id=\"Period7\" start=\"P1Y\"></Period></MPD>";
3046 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3048 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3049 assert_equals_int (ret, TRUE);
3052 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3054 assert_equals_int (ret, TRUE);
3057 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3059 assert_equals_string (periodNode->id, "Period0");
3060 assert_equals_uint64 (periodNode->start,
3061 duration_to_ms (0, 0, 0, 0, 0, 1, 0));
3064 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3066 assert_equals_string (periodNode->id, "Period1");
3067 assert_equals_uint64 (periodNode->start,
3068 duration_to_ms (0, 0, 0, 0, 0, 1, 500));
3071 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3073 assert_equals_string (periodNode->id, "Period2");
3074 assert_equals_uint64 (periodNode->start,
3075 duration_to_ms (0, 0, 0, 0, 0, 1, 700));
3078 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3080 assert_equals_string (periodNode->id, "Period3");
3081 assert_equals_uint64 (periodNode->start,
3082 duration_to_ms (0, 0, 0, 0, 1, 0, 0));
3085 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3087 assert_equals_string (periodNode->id, "Period4");
3088 assert_equals_uint64 (periodNode->start,
3089 duration_to_ms (0, 0, 0, 1, 0, 0, 0));
3092 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3094 assert_equals_string (periodNode->id, "Period5");
3095 assert_equals_uint64 (periodNode->start,
3096 duration_to_ms (0, 0, 1, 0, 0, 0, 0));
3099 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3101 assert_equals_string (periodNode->id, "Period6");
3102 assert_equals_uint64 (periodNode->start,
3103 duration_to_ms (0, 1, 0, 0, 0, 0, 0));
3106 (GstMPDPeriodNode *) g_list_nth_data (mpdclient->mpd_root_node->Periods,
3108 assert_equals_string (periodNode->id, "Period7");
3109 assert_equals_uint64 (periodNode->start,
3110 duration_to_ms (1, 0, 0, 0, 0, 0, 0));
3112 gst_mpd_client2_free (mpdclient);
3118 * Test media presentation setup
3121 GST_START_TEST (dash_mpdparser_setup_media_presentation)
3124 "<?xml version=\"1.0\"?>"
3125 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3126 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3127 " <Period id=\"Period0\""
3128 " duration=\"P0Y0M1DT1H1M1S\"></Period></MPD>";
3131 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3133 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3134 assert_equals_int (ret, TRUE);
3136 /* process the xml data */
3138 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3140 assert_equals_int (ret, TRUE);
3142 gst_mpd_client2_free (mpdclient);
3148 * Test setting a stream
3151 GST_START_TEST (dash_mpdparser_setup_streaming)
3153 GList *adaptationSets;
3154 GstMPDAdaptationSetNode *adapt_set;
3157 "<?xml version=\"1.0\"?>"
3158 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3159 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3160 " <Period id=\"Period0\""
3161 " duration=\"P0Y0M1DT1H1M1S\">"
3162 " <AdaptationSet id=\"1\""
3163 " mimeType=\"video/mp4\">"
3164 " <Representation id=\"1\" bandwidth=\"250000\">"
3165 " </Representation></AdaptationSet></Period></MPD>";
3168 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3170 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3171 assert_equals_int (ret, TRUE);
3173 /* process the xml data */
3175 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3177 assert_equals_int (ret, TRUE);
3179 /* get the first adaptation set of the first period */
3180 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
3181 fail_if (adaptationSets == NULL);
3182 adapt_set = (GstMPDAdaptationSetNode *) adaptationSets->data;
3183 fail_if (adapt_set == NULL);
3185 /* setup streaming from the adaptation set */
3186 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
3187 assert_equals_int (ret, TRUE);
3189 gst_mpd_client2_free (mpdclient);
3195 * Test handling Period selection
3198 GST_START_TEST (dash_mpdparser_period_selection)
3200 const gchar *periodName;
3204 "<?xml version=\"1.0\"?>"
3205 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3206 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
3207 " mediaPresentationDuration=\"P0Y0M1DT1H4M3S\">"
3208 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\"></Period>"
3209 " <Period id=\"Period1\"></Period>"
3210 " <Period id=\"Period2\" start=\"P0Y0M1DT1H3M3S\"></Period></MPD>";
3213 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3215 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3216 assert_equals_int (ret, TRUE);
3218 /* period_idx should be 0 and we should have no active periods */
3219 assert_equals_uint64 (mpdclient->period_idx, 0);
3220 fail_unless (mpdclient->periods == NULL);
3222 /* process the xml data */
3224 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3226 assert_equals_int (ret, TRUE);
3228 /* check the periods */
3229 fail_unless (mpdclient->periods != NULL);
3230 periodName = gst_mpd_client2_get_period_id (mpdclient);
3231 assert_equals_string (periodName, "Period0");
3233 ret = gst_mpd_client2_set_period_index (mpdclient, 1);
3234 assert_equals_int (ret, TRUE);
3235 periodName = gst_mpd_client2_get_period_id (mpdclient);
3236 assert_equals_string (periodName, "Period1");
3238 ret = gst_mpd_client2_set_period_index (mpdclient, 2);
3239 assert_equals_int (ret, TRUE);
3240 periodName = gst_mpd_client2_get_period_id (mpdclient);
3241 assert_equals_string (periodName, "Period2");
3243 ret = gst_mpd_client2_has_next_period (mpdclient);
3244 assert_equals_int (ret, FALSE);
3245 ret = gst_mpd_client2_has_previous_period (mpdclient);
3246 assert_equals_int (ret, TRUE);
3248 ret = gst_mpd_client2_set_period_index (mpdclient, 0);
3249 assert_equals_int (ret, TRUE);
3250 ret = gst_mpd_client2_has_next_period (mpdclient);
3251 assert_equals_int (ret, TRUE);
3252 ret = gst_mpd_client2_has_previous_period (mpdclient);
3253 assert_equals_int (ret, FALSE);
3255 ret = gst_mpd_client2_set_period_id (mpdclient, "Period1");
3256 assert_equals_int (ret, TRUE);
3257 periodIndex = gst_mpd_client2_get_period_index (mpdclient);
3258 assert_equals_uint64 (periodIndex, 1);
3260 gst_mpd_client2_free (mpdclient);
3266 * Test handling Period selection based on time
3269 GST_START_TEST (dash_mpdparser_get_period_at_time)
3275 "<?xml version=\"1.0\"?>"
3276 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3277 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
3278 " availabilityStartTime=\"2015-03-24T0:0:0\""
3279 " mediaPresentationDuration=\"P0Y0M1DT1H4M3S\">"
3280 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\"></Period>"
3281 " <Period id=\"Period1\"></Period>"
3282 " <Period id=\"Period2\" start=\"P0Y0M1DT1H3M3S\"></Period></MPD>";
3285 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3287 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3288 assert_equals_int (ret, TRUE);
3290 /* process the xml data */
3292 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3294 assert_equals_int (ret, TRUE);
3296 /* request period for a time before availabilityStartTime, expect period index 0 */
3297 time = gst_date_time_new_from_iso8601_string ("2015-03-23T23:30:59Z");
3298 periodIndex = gst_mpd_client2_get_period_index_at_time (mpdclient, time);
3299 gst_date_time_unref (time);
3300 assert_equals_int (periodIndex, 0);
3302 /* request period for a time from period 0 */
3303 time = gst_date_time_new_from_iso8601_string ("2015-03-24T23:30:59Z");
3304 periodIndex = gst_mpd_client2_get_period_index_at_time (mpdclient, time);
3305 gst_date_time_unref (time);
3306 assert_equals_int (periodIndex, 0);
3308 /* request period for a time from period 1 */
3309 time = gst_date_time_new_from_iso8601_string ("2015-03-25T1:1:1Z");
3310 periodIndex = gst_mpd_client2_get_period_index_at_time (mpdclient, time);
3311 gst_date_time_unref (time);
3312 assert_equals_int (periodIndex, 1);
3314 /* request period for a time from period 2 */
3315 time = gst_date_time_new_from_iso8601_string ("2015-03-25T1:3:3Z");
3316 periodIndex = gst_mpd_client2_get_period_index_at_time (mpdclient, time);
3317 gst_date_time_unref (time);
3318 assert_equals_int (periodIndex, 2);
3320 /* request period for a time after mediaPresentationDuration, expect period index G_MAXUINT */
3321 time = gst_date_time_new_from_iso8601_string ("2015-03-25T1:4:3Z");
3322 periodIndex = gst_mpd_client2_get_period_index_at_time (mpdclient, time);
3323 gst_date_time_unref (time);
3324 assert_equals_int (periodIndex, G_MAXUINT);
3326 gst_mpd_client2_free (mpdclient);
3332 * Test handling Adaptation sets
3335 GST_START_TEST (dash_mpdparser_adaptationSet_handling)
3337 const gchar *periodName;
3338 guint adaptation_sets_count;
3339 GList *adaptationSets, *it;
3343 "<?xml version=\"1.0\"?>"
3344 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3345 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3346 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3347 " <AdaptationSet id=\"1\"></AdaptationSet>"
3349 " <Period id=\"Period1\" duration=\"P0Y0M1DT1H1M1S\">"
3350 " <AdaptationSet id=\"10\"></AdaptationSet>"
3351 " <AdaptationSet id=\"11\"></AdaptationSet></Period></MPD>";
3354 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3356 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3357 assert_equals_int (ret, TRUE);
3359 /* process the xml data */
3361 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3363 assert_equals_int (ret, TRUE);
3365 /* period0 has 1 adaptation set */
3366 fail_unless (mpdclient->periods != NULL);
3367 periodName = gst_mpd_client2_get_period_id (mpdclient);
3368 assert_equals_string (periodName, "Period0");
3369 adaptation_sets_count = gst_mpd_client2_get_nb_adaptationSet (mpdclient);
3370 assert_equals_int (adaptation_sets_count, 1);
3372 /* period1 has 2 adaptation set */
3373 ret = gst_mpd_client2_set_period_id (mpdclient, "Period1");
3374 assert_equals_int (ret, TRUE);
3375 adaptation_sets_count = gst_mpd_client2_get_nb_adaptationSet (mpdclient);
3376 assert_equals_int (adaptation_sets_count, 2);
3378 /* check the id for the 2 adaptation sets from period 1 */
3379 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
3380 fail_if (adaptationSets == NULL);
3382 for (it = adaptationSets; it; it = g_list_next (it)) {
3383 GstMPDAdaptationSetNode *adapt_set;
3384 adapt_set = (GstMPDAdaptationSetNode *) it->data;
3385 fail_if (adapt_set == NULL);
3387 assert_equals_int (adapt_set->id, 10 + count);
3391 gst_mpd_client2_free (mpdclient);
3397 * Test handling Representation selection
3400 GST_START_TEST (dash_mpdparser_representation_selection)
3402 GList *adaptationSets;
3403 GstMPDAdaptationSetNode *adaptationSetNode;
3404 GList *representations;
3405 gint represendationIndex;
3408 "<?xml version=\"1.0\"?>"
3409 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3410 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3411 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3412 " <AdaptationSet id=\"1\" mimeType=\"video/mp4\">"
3413 " <Representation id=\"v0\" bandwidth=\"500000\"></Representation>"
3414 " <Representation id=\"v1\" bandwidth=\"250000\"></Representation>"
3415 " </AdaptationSet></Period></MPD>";
3418 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3420 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3421 assert_equals_int (ret, TRUE);
3423 /* process the xml data */
3425 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3427 assert_equals_int (ret, TRUE);
3429 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
3430 fail_if (adaptationSets == NULL);
3432 adaptationSetNode = adaptationSets->data;
3433 fail_if (adaptationSetNode == NULL);
3434 assert_equals_int (adaptationSetNode->id, 1);
3436 representations = adaptationSetNode->Representations;
3437 fail_if (representations == NULL);
3439 represendationIndex =
3440 gst_mpd_client2_get_rep_idx_with_min_bandwidth (representations);
3441 assert_equals_int (represendationIndex, 1);
3443 represendationIndex =
3444 gst_mpd_client2_get_rep_idx_with_max_bandwidth (representations, 0, 0, 0,
3446 assert_equals_int (represendationIndex, 1);
3448 represendationIndex =
3449 gst_mpd_client2_get_rep_idx_with_max_bandwidth (representations, 100000,
3451 assert_equals_int (represendationIndex, -1);
3453 represendationIndex =
3454 gst_mpd_client2_get_rep_idx_with_max_bandwidth (representations, 300000,
3456 assert_equals_int (represendationIndex, 1);
3458 represendationIndex =
3459 gst_mpd_client2_get_rep_idx_with_max_bandwidth (representations, 500000,
3461 assert_equals_int (represendationIndex, 0);
3463 gst_mpd_client2_free (mpdclient);
3469 * Test handling Active stream selection
3472 GST_START_TEST (dash_mpdparser_activeStream_selection)
3474 GList *adaptationSets;
3475 GstMPDAdaptationSetNode *adapt_set;
3476 guint activeStreams;
3477 GstActiveStream *activeStream;
3480 "<?xml version=\"1.0\"?>"
3481 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3482 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3483 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3484 " <AdaptationSet id=\"1\" mimeType=\"video/mp4\">"
3485 " <Representation id=\"1\" bandwidth=\"250000\">"
3486 " </Representation>"
3488 " <AdaptationSet id=\"2\" mimeType=\"audio\">"
3489 " <Representation id=\"2\" bandwidth=\"250000\">"
3490 " </Representation>"
3492 " <AdaptationSet id=\"3\" mimeType=\"application\">"
3493 " <Representation id=\"3\" bandwidth=\"250000\">"
3494 " </Representation></AdaptationSet></Period></MPD>";
3497 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3499 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3500 assert_equals_int (ret, TRUE);
3502 /* process the xml data */
3504 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3506 assert_equals_int (ret, TRUE);
3508 /* get the list of adaptation sets of the first period */
3509 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
3510 fail_if (adaptationSets == NULL);
3512 /* no active streams yet */
3513 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
3514 assert_equals_int (activeStreams, 0);
3516 /* setup streaming from the first adaptation set */
3517 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
3518 fail_if (adapt_set == NULL);
3519 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
3520 assert_equals_int (ret, TRUE);
3522 /* 1 active streams */
3523 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
3524 assert_equals_int (activeStreams, 1);
3526 /* setup streaming from the second adaptation set */
3527 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 1);
3528 fail_if (adapt_set == NULL);
3529 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
3530 assert_equals_int (ret, TRUE);
3532 /* 2 active streams */
3533 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
3534 assert_equals_int (activeStreams, 2);
3536 /* setup streaming from the third adaptation set */
3537 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 2);
3538 fail_if (adapt_set == NULL);
3539 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
3540 assert_equals_int (ret, TRUE);
3542 /* 3 active streams */
3543 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
3544 assert_equals_int (activeStreams, 3);
3546 /* get details of the first active stream */
3547 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
3548 fail_if (activeStream == NULL);
3549 assert_equals_int (activeStream->mimeType, GST_STREAM_VIDEO);
3551 /* get details of the second active stream */
3552 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 1);
3553 fail_if (activeStream == NULL);
3554 assert_equals_int (activeStream->mimeType, GST_STREAM_AUDIO);
3556 /* get details of the third active stream */
3557 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 2);
3558 fail_if (activeStream == NULL);
3559 assert_equals_int (activeStream->mimeType, GST_STREAM_APPLICATION);
3561 gst_mpd_client2_free (mpdclient);
3567 * Test getting Active stream parameters
3570 GST_START_TEST (dash_mpdparser_activeStream_parameters)
3572 GList *adaptationSets;
3573 GstMPDAdaptationSetNode *adapt_set;
3574 guint activeStreams;
3575 GstActiveStream *activeStream;
3578 gboolean bitstreamSwitchingFlag;
3579 guint videoStreamWidth;
3580 guint videoStreamHeight;
3581 guint audioStreamRate;
3582 guint audioChannelsCount;
3585 "<?xml version=\"1.0\"?>"
3586 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3587 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3588 " <Period id=\"Period0\""
3589 " duration=\"P0Y0M1DT1H1M1S\">"
3590 " <AdaptationSet id=\"1\""
3591 " mimeType=\"video/mp4\""
3594 " bitstreamSwitching=\"true\""
3595 " audioSamplingRate=\"48000\">"
3596 " <Representation id=\"1\" bandwidth=\"250000\">"
3597 " </Representation></AdaptationSet></Period></MPD>";
3600 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3602 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3603 assert_equals_int (ret, TRUE);
3605 /* process the xml data */
3607 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3609 assert_equals_int (ret, TRUE);
3611 /* get the list of adaptation sets of the first period */
3612 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
3613 fail_if (adaptationSets == NULL);
3615 /* setup streaming from the first adaptation set */
3616 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
3617 fail_if (adapt_set == NULL);
3618 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
3619 assert_equals_int (ret, TRUE);
3621 /* 1 active streams */
3622 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
3623 assert_equals_int (activeStreams, 1);
3625 /* get details of the first active stream */
3626 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
3627 fail_if (activeStream == NULL);
3629 assert_equals_int (activeStream->mimeType, GST_STREAM_VIDEO);
3630 caps = gst_mpd_client2_get_stream_caps (activeStream);
3631 fail_unless (caps != NULL);
3632 s = gst_caps_get_structure (caps, 0);
3633 assert_equals_string (gst_structure_get_name (s), "video/quicktime");
3634 gst_caps_unref (caps);
3636 bitstreamSwitchingFlag =
3637 gst_mpd_client2_get_bitstream_switching_flag (activeStream);
3638 assert_equals_int (bitstreamSwitchingFlag, 1);
3640 videoStreamWidth = gst_mpd_client2_get_video_stream_width (activeStream);
3641 assert_equals_int (videoStreamWidth, 320);
3643 videoStreamHeight = gst_mpd_client2_get_video_stream_height (activeStream);
3644 assert_equals_int (videoStreamHeight, 240);
3646 audioStreamRate = gst_mpd_client2_get_audio_stream_rate (activeStream);
3647 assert_equals_int (audioStreamRate, 48000);
3649 audioChannelsCount =
3650 gst_mpd_client2_get_audio_stream_num_channels (activeStream);
3651 assert_equals_int (audioChannelsCount, 0);
3653 gst_mpd_client2_free (mpdclient);
3659 * Test getting number and list of audio languages
3662 GST_START_TEST (dash_mpdparser_get_audio_languages)
3664 GList *adaptationSets;
3665 GstMPDAdaptationSetNode *adapt_set;
3666 guint activeStreams;
3667 guint adaptationSetsCount;
3668 GList *languages = NULL;
3669 guint languagesCount;
3672 "<?xml version=\"1.0\"?>"
3673 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3674 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3675 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3676 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
3677 " <Representation id=\"1\" bandwidth=\"250000\">"
3678 " </Representation>"
3680 " <AdaptationSet id=\"2\" mimeType=\"video/mp4\">"
3681 " <Representation id=\"2\" bandwidth=\"250000\">"
3682 " </Representation>"
3684 " <AdaptationSet id=\"3\" mimeType=\"audio\" lang=\"fr\">"
3685 " <Representation id=\"3\" bandwidth=\"250000\">"
3686 " </Representation></AdaptationSet></Period></MPD>";
3689 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3692 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3693 assert_equals_int (ret, TRUE);
3695 /* process the xml data */
3697 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3699 assert_equals_int (ret, TRUE);
3701 /* get the list of adaptation sets of the first period */
3702 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
3703 fail_if (adaptationSets == NULL);
3705 /* setup streaming from all adaptation sets */
3706 adaptationSetsCount = gst_mpd_client2_get_nb_adaptationSet (mpdclient);
3707 for (i = 0; i < adaptationSetsCount; i++) {
3708 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, i);
3709 fail_if (adapt_set == NULL);
3710 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
3711 assert_equals_int (ret, TRUE);
3713 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
3714 assert_equals_int (activeStreams, adaptationSetsCount);
3717 gst_mpd_client2_get_list_and_nb_of_audio_language (mpdclient, &languages);
3718 assert_equals_int (languagesCount, 2);
3719 assert_equals_string ((gchar *) g_list_nth_data (languages, 0), "en");
3720 assert_equals_string ((gchar *) g_list_nth_data (languages, 1), "fr");
3722 g_list_free (languages);
3724 gst_mpd_client2_free (mpdclient);
3730 * Tests getting the base URL
3733 static GstMPDClient2 *
3734 setup_mpd_client (const gchar * xml)
3736 GList *adaptationSets;
3737 GstMPDAdaptationSetNode *adapt_set;
3738 guint activeStreams;
3739 guint adaptationSetsCount;
3741 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
3744 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
3745 assert_equals_int (ret, TRUE);
3747 /* process the xml data */
3749 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
3751 assert_equals_int (ret, TRUE);
3753 /* get the list of adaptation sets of the first period */
3754 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
3755 fail_if (adaptationSets == NULL);
3757 /* setup streaming from all adaptation sets */
3758 adaptationSetsCount = gst_mpd_client2_get_nb_adaptationSet (mpdclient);
3759 for (i = 0; i < adaptationSetsCount; i++) {
3760 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, i);
3761 fail_if (adapt_set == NULL);
3762 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
3763 assert_equals_int (ret, TRUE);
3765 activeStreams = gst_mpd_client2_get_nb_active_stream (mpdclient);
3766 assert_equals_int (activeStreams, adaptationSetsCount);
3771 GST_START_TEST (dash_mpdparser_get_baseURL1)
3773 const gchar *baseURL;
3775 "<?xml version=\"1.0\"?>"
3776 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3777 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3778 " <BaseURL>http://example.com/</BaseURL>"
3779 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3780 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
3781 " <Representation id=\"1\" bandwidth=\"250000\">"
3782 " </Representation></AdaptationSet></Period></MPD>";
3784 GstMPDClient2 *mpdclient = setup_mpd_client (xml);
3786 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
3787 fail_if (baseURL == NULL);
3788 assert_equals_string (baseURL, "http://example.com/");
3790 gst_mpd_client2_free (mpdclient);
3796 GST_START_TEST (dash_mpdparser_get_baseURL2)
3798 const gchar *baseURL;
3800 "<?xml version=\"1.0\"?>"
3801 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3802 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3803 " <BaseURL>mpd_base_url/</BaseURL>"
3804 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3805 " <BaseURL> /period_base_url/</BaseURL>"
3806 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
3807 " <BaseURL>adaptation_base_url</BaseURL>"
3808 " <Representation id=\"1\" bandwidth=\"250000\">"
3809 " <BaseURL>representation_base_url</BaseURL>"
3810 " </Representation></AdaptationSet></Period></MPD>";
3812 GstMPDClient2 *mpdclient = setup_mpd_client (xml);
3814 /* test baseURL. Its value should be computed like this:
3815 * - start with xml url (null)
3816 * - set it to the value from MPD's BaseURL element: "mpd_base_url/"
3817 * - update the value with BaseURL element from Period. Because Period's
3818 * baseURL is absolute (starts with /) it will overwrite the current value
3819 * for baseURL. So, baseURL becomes "/period_base_url/"
3820 * - update the value with BaseURL element from AdaptationSet. Because this
3821 * is a relative url, it will update the current value. baseURL becomes
3822 * "/period_base_url/adaptation_base_url"
3823 * - update the value with BaseURL element from Representation. Because this
3824 * is a relative url, it will update the current value. Because the current
3825 * value does not end in /, everything after the last / will be overwritten.
3826 * baseURL becomes "/period_base_url/representation_base_url"
3828 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
3829 fail_if (baseURL == NULL);
3830 assert_equals_string (baseURL, "/period_base_url/representation_base_url");
3832 gst_mpd_client2_free (mpdclient);
3838 GST_START_TEST (dash_mpdparser_get_baseURL3)
3840 const gchar *baseURL;
3842 "<?xml version=\"1.0\"?>"
3843 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3844 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3845 " <BaseURL>mpd_base_url/</BaseURL>"
3846 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3847 " <BaseURL> /period_base_url/</BaseURL>"
3848 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
3849 " <BaseURL>adaptation_base_url</BaseURL>"
3850 " <Representation id=\"1\" bandwidth=\"250000\">"
3851 " <BaseURL>/representation_base_url</BaseURL>"
3852 " </Representation></AdaptationSet></Period></MPD>";
3854 GstMPDClient2 *mpdclient = setup_mpd_client (xml);
3856 /* test baseURL. Its value should be computed like this:
3857 * - start with xml url (null)
3858 * - set it to the value from MPD's BaseURL element: "mpd_base_url/"
3859 * - update the value with BaseURL element from Period. Because Period's
3860 * baseURL is absolute (starts with /) it will overwrite the current value
3861 * for baseURL. So, baseURL becomes "/period_base_url/"
3862 * - update the value with BaseURL element from AdaptationSet. Because this
3863 * is a relative url, it will update the current value. baseURL becomes
3864 * "/period_base_url/adaptation_base_url"
3865 * - update the value with BaseURL element from Representation. Because this
3866 * is an absolute url, it will replace everything again"
3868 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
3869 fail_if (baseURL == NULL);
3870 assert_equals_string (baseURL, "/representation_base_url");
3872 gst_mpd_client2_free (mpdclient);
3878 GST_START_TEST (dash_mpdparser_get_baseURL4)
3880 const gchar *baseURL;
3882 "<?xml version=\"1.0\"?>"
3883 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3884 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3885 " <BaseURL>mpd_base_url/</BaseURL>"
3886 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3887 " <BaseURL> /period_base_url/</BaseURL>"
3888 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
3889 " <BaseURL>adaptation_base_url/</BaseURL>"
3890 " <Representation id=\"1\" bandwidth=\"250000\">"
3891 " <BaseURL>representation_base_url/</BaseURL>"
3892 " </Representation></AdaptationSet></Period></MPD>";
3894 GstMPDClient2 *mpdclient = setup_mpd_client (xml);
3896 /* test baseURL. Its value should be computed like this:
3897 * - start with xml url (null)
3898 * - set it to the value from MPD's BaseURL element: "mpd_base_url/"
3899 * - update the value with BaseURL element from Period. Because Period's
3900 * baseURL is absolute (starts with /) it will overwrite the current value
3901 * for baseURL. So, baseURL becomes "/period_base_url/"
3902 * - update the value with BaseURL element from AdaptationSet. Because this
3903 * is a relative url, it will update the current value. baseURL becomes
3904 * "/period_base_url/adaptation_base_url/"
3905 * - update the value with BaseURL element from Representation. Because this
3906 * is an relative url, it will update the current value."
3908 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
3909 fail_if (baseURL == NULL);
3910 assert_equals_string (baseURL,
3911 "/period_base_url/adaptation_base_url/representation_base_url/");
3913 gst_mpd_client2_free (mpdclient);
3918 /* test multiple BaseUrl entries per section */
3919 GST_START_TEST (dash_mpdparser_get_baseURL5)
3921 GstMPDPeriodNode *periodNode;
3922 GstMPDAdaptationSetNode *adaptationSet;
3923 GstMPDRepresentationNode *representation;
3924 const gchar *baseURL;
3925 GstMPDBaseURLNode *gstBaseURL;
3928 "<?xml version=\"1.0\"?>"
3929 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
3930 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
3931 " <BaseURL>/mpd_base_url1/</BaseURL>"
3932 " <BaseURL>/mpd_base_url2/</BaseURL>"
3933 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
3934 " <BaseURL> period_base_url1/</BaseURL>"
3935 " <BaseURL> period_base_url2/</BaseURL>"
3936 " <BaseURL> period_base_url3/</BaseURL>"
3937 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
3938 " <BaseURL>adaptation_base_url1/</BaseURL>"
3939 " <BaseURL>adaptation_base_url2/</BaseURL>"
3940 " <BaseURL>adaptation_base_url3/</BaseURL>"
3941 " <BaseURL>adaptation_base_url4/</BaseURL>"
3942 " <Representation id=\"1\" bandwidth=\"250000\">"
3943 " <BaseURL>representation_base_url1/</BaseURL>"
3944 " <BaseURL>representation_base_url2/</BaseURL>"
3945 " <BaseURL>representation_base_url3/</BaseURL>"
3946 " <BaseURL>representation_base_url4/</BaseURL>"
3947 " <BaseURL>representation_base_url5/</BaseURL>"
3948 " </Representation></AdaptationSet></Period></MPD>";
3950 GstMPDClient2 *mpdclient = setup_mpd_client (xml);
3952 assert_equals_int (g_list_length (mpdclient->mpd_root_node->BaseURLs), 2);
3953 gstBaseURL = g_list_nth_data (mpdclient->mpd_root_node->BaseURLs, 0);
3954 assert_equals_string (gstBaseURL->baseURL, "/mpd_base_url1/");
3955 gstBaseURL = g_list_nth_data (mpdclient->mpd_root_node->BaseURLs, 1);
3956 assert_equals_string (gstBaseURL->baseURL, "/mpd_base_url2/");
3958 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
3959 assert_equals_int (g_list_length (periodNode->BaseURLs), 3);
3960 gstBaseURL = g_list_nth_data (periodNode->BaseURLs, 0);
3961 assert_equals_string (gstBaseURL->baseURL, " period_base_url1/");
3962 gstBaseURL = g_list_nth_data (periodNode->BaseURLs, 1);
3963 assert_equals_string (gstBaseURL->baseURL, " period_base_url2/");
3964 gstBaseURL = g_list_nth_data (periodNode->BaseURLs, 2);
3965 assert_equals_string (gstBaseURL->baseURL, " period_base_url3/");
3967 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
3968 assert_equals_int (g_list_length (adaptationSet->BaseURLs), 4);
3969 gstBaseURL = g_list_nth_data (adaptationSet->BaseURLs, 0);
3970 assert_equals_string (gstBaseURL->baseURL, "adaptation_base_url1/");
3971 gstBaseURL = g_list_nth_data (adaptationSet->BaseURLs, 1);
3972 assert_equals_string (gstBaseURL->baseURL, "adaptation_base_url2/");
3973 gstBaseURL = g_list_nth_data (adaptationSet->BaseURLs, 2);
3974 assert_equals_string (gstBaseURL->baseURL, "adaptation_base_url3/");
3975 gstBaseURL = g_list_nth_data (adaptationSet->BaseURLs, 3);
3976 assert_equals_string (gstBaseURL->baseURL, "adaptation_base_url4/");
3978 representation = (GstMPDRepresentationNode *)
3979 adaptationSet->Representations->data;
3980 assert_equals_int (g_list_length (representation->BaseURLs), 5);
3981 gstBaseURL = g_list_nth_data (representation->BaseURLs, 0);
3982 assert_equals_string (gstBaseURL->baseURL, "representation_base_url1/");
3983 gstBaseURL = g_list_nth_data (representation->BaseURLs, 1);
3984 assert_equals_string (gstBaseURL->baseURL, "representation_base_url2/");
3985 gstBaseURL = g_list_nth_data (representation->BaseURLs, 2);
3986 assert_equals_string (gstBaseURL->baseURL, "representation_base_url3/");
3987 gstBaseURL = g_list_nth_data (representation->BaseURLs, 3);
3988 assert_equals_string (gstBaseURL->baseURL, "representation_base_url4/");
3989 gstBaseURL = g_list_nth_data (representation->BaseURLs, 4);
3990 assert_equals_string (gstBaseURL->baseURL, "representation_base_url5/");
3992 /* test baseURL. Its value should be computed like this:
3993 * - start with xml url (null)
3994 * - set it to the value from MPD's BaseURL element: "/mpd_base_url1/"
3995 * - update the value with BaseURL element from Period. Because this
3996 * is a relative url, it will update the current value. baseURL becomes
3997 * "/mpd_base_url1/period_base_url1/"
3998 * - update the value with BaseURL element from AdaptationSet. Because this
3999 * is a relative url, it will update the current value. baseURL becomes
4000 * "/mpd_base_url1/period_base_url1/adaptation_base_url1/"
4001 * - update the value with BaseURL element from Representation. Because this
4002 * is an relative url, it will update the current value."
4004 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
4005 fail_if (baseURL == NULL);
4006 assert_equals_string (baseURL,
4007 "/mpd_base_url1/period_base_url1/adaptation_base_url1/representation_base_url1/");
4009 gst_mpd_client2_free (mpdclient);
4014 /* test no BaseURL */
4015 GST_START_TEST (dash_mpdparser_get_baseURL6)
4017 const gchar *baseURL;
4019 "<?xml version=\"1.0\"?>"
4020 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4021 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
4022 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
4023 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
4024 " <Representation id=\"1\" bandwidth=\"250000\">"
4025 " </Representation></AdaptationSet></Period></MPD>";
4027 GstMPDClient2 *mpdclient = setup_mpd_client (xml);
4029 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
4030 fail_if (baseURL == NULL);
4031 assert_equals_string (baseURL, "");
4033 gst_mpd_client2_free (mpdclient);
4038 /* BaseURL: test that the path is made absolute (a / is prepended if needed */
4039 GST_START_TEST (dash_mpdparser_get_baseURL7)
4041 const gchar *baseURL;
4043 "<?xml version=\"1.0\"?>"
4044 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4045 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
4046 " <BaseURL>x/example.com/</BaseURL>"
4047 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
4048 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
4049 " <Representation id=\"1\" bandwidth=\"250000\">"
4050 " </Representation></AdaptationSet></Period></MPD>";
4052 GstMPDClient2 *mpdclient;
4054 mpdclient = setup_mpd_client (xml);
4056 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
4057 fail_if (baseURL == NULL);
4058 assert_equals_string (baseURL, "/x/example.com/");
4060 gst_mpd_client2_free (mpdclient);
4065 /* BaseURL: test that a / is not prepended if the string contains ':'
4066 * This tests uris with schema present */
4067 GST_START_TEST (dash_mpdparser_get_baseURL8)
4069 const gchar *baseURL;
4071 "<?xml version=\"1.0\"?>"
4072 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4073 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
4074 " <BaseURL>x:y/example.com/</BaseURL>"
4075 " <Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
4076 " <AdaptationSet id=\"1\" mimeType=\"audio\" lang=\"en\">"
4077 " <Representation id=\"1\" bandwidth=\"250000\">"
4078 " </Representation></AdaptationSet></Period></MPD>";
4080 GstMPDClient2 *mpdclient = setup_mpd_client (xml);
4082 baseURL = gst_mpd_client2_get_baseURL (mpdclient, 0);
4083 fail_if (baseURL == NULL);
4084 assert_equals_string (baseURL, "x:y/example.com/");
4086 gst_mpd_client2_free (mpdclient);
4092 * Test getting mediaPresentationDuration
4095 GST_START_TEST (dash_mpdparser_get_mediaPresentationDuration)
4097 GstClockTime mediaPresentationDuration;
4100 "<?xml version=\"1.0\"?>"
4101 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4102 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4103 " mediaPresentationDuration=\"P0Y0M0DT0H0M3S\"></MPD>";
4106 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4108 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4109 assert_equals_int (ret, TRUE);
4111 mediaPresentationDuration =
4112 gst_mpd_client2_get_media_presentation_duration (mpdclient);
4113 assert_equals_uint64 (mediaPresentationDuration, 3000000000);
4115 gst_mpd_client2_free (mpdclient);
4121 * Test getting streamPresentationOffset
4124 GST_START_TEST (dash_mpdparser_get_streamPresentationOffset)
4126 GList *adaptationSets;
4127 GstMPDAdaptationSetNode *adapt_set;
4128 GstClockTime offset;
4130 "<?xml version=\"1.0\"?>"
4131 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4132 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4133 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4135 " <AdaptationSet mimeType=\"video/mp4\">"
4136 " <SegmentBase timescale=\"1000\" presentationTimeOffset=\"3000\">"
4138 " <Representation id=\"1\" bandwidth=\"250000\">"
4139 " </Representation></AdaptationSet></Period></MPD>";
4142 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4144 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4145 assert_equals_int (ret, TRUE);
4147 /* process the xml data */
4149 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4151 assert_equals_int (ret, TRUE);
4153 /* get the list of adaptation sets of the first period */
4154 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4155 fail_if (adaptationSets == NULL);
4157 /* setup streaming from the first adaptation set */
4158 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4159 fail_if (adapt_set == NULL);
4160 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4161 assert_equals_int (ret, TRUE);
4163 /* test the stream presentation time offset */
4164 offset = gst_mpd_client2_get_stream_presentation_offset (mpdclient, 0);
4165 /* seems to be set only for template segments, so here it is 0 */
4166 assert_equals_int (offset, 0);
4168 gst_mpd_client2_free (mpdclient);
4174 * Test handling segments
4177 GST_START_TEST (dash_mpdparser_segments)
4179 GList *adaptationSets;
4180 GstMPDAdaptationSetNode *adapt_set;
4181 gboolean hasNextSegment;
4182 GstActiveStream *activeStream;
4184 GstDateTime *segmentAvailability;
4185 GstDateTime *gst_time;
4189 "<?xml version=\"1.0\"?>"
4190 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4192 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4193 " availabilityStartTime=\"2015-03-24T0:0:0\""
4194 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4195 " <Period id=\"Period0\" start=\"P0Y0M0DT0H0M10S\">"
4196 " <AdaptationSet mimeType=\"video/mp4\">"
4197 " <Representation id=\"1\" bandwidth=\"250000\">"
4198 " <SegmentList duration=\"45\">"
4199 " <SegmentURL media=\"TestMedia1\""
4200 " mediaRange=\"10-20\""
4201 " index=\"TestIndex1\""
4202 " indexRange=\"30-40\">"
4204 " <SegmentURL media=\"TestMedia2\""
4205 " mediaRange=\"20-30\""
4206 " index=\"TestIndex2\""
4207 " indexRange=\"40-50\">"
4210 " </Representation></AdaptationSet></Period></MPD>";
4213 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4215 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4216 assert_equals_int (ret, TRUE);
4218 /* process the xml data */
4220 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4222 assert_equals_int (ret, TRUE);
4224 /* get the list of adaptation sets of the first period */
4225 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4226 fail_if (adaptationSets == NULL);
4228 /* setup streaming from the first adaptation set */
4229 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4230 fail_if (adapt_set == NULL);
4231 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4232 assert_equals_int (ret, TRUE);
4234 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
4235 fail_if (activeStream == NULL);
4237 /* segment_index 0, segment_count 2.
4238 * Has next segment and can advance to next segment
4241 gst_mpd_client2_has_next_segment (mpdclient, activeStream, TRUE);
4242 assert_equals_int (hasNextSegment, 1);
4243 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
4244 assert_equals_int (flow, GST_FLOW_OK);
4246 /* segment_index 1, segment_count 2.
4247 * Does not have next segment and can not advance to next segment
4250 gst_mpd_client2_has_next_segment (mpdclient, activeStream, TRUE);
4251 assert_equals_int (hasNextSegment, 0);
4252 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
4253 assert_equals_int (flow, GST_FLOW_EOS);
4255 /* go to first segment */
4256 gst_mpd_client2_seek_to_first_segment (mpdclient);
4258 /* segment_index 0, segment_count 2.
4259 * Has next segment and can advance to next segment
4262 gst_mpd_client2_has_next_segment (mpdclient, activeStream, TRUE);
4263 assert_equals_int (hasNextSegment, 1);
4264 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
4265 assert_equals_int (flow, GST_FLOW_OK);
4267 /* segment_index 1, segment_count 2
4268 * Does not have next segment
4271 gst_mpd_client2_has_next_segment (mpdclient, activeStream, TRUE);
4272 assert_equals_int (hasNextSegment, 0);
4274 /* segment index is still 1 */
4276 gst_mpd_client2_has_next_segment (mpdclient, activeStream, TRUE);
4277 assert_equals_int (hasNextSegment, 0);
4279 /* each segment has a duration of 0 hours, 0 min 45 seconds
4280 * segment index is 1.
4281 * Start time is at the beginning of segment 1, so 1 * segment_duration = 1 * 45s
4282 * Availability start time is at the end of the segment, so we add duration (45s)
4283 * We also add period start time (10s)
4284 * So, availability start time for segment 1 is: 10 (period start) +
4285 * 45 (segment start) + 45 (duration) = 1'40s
4287 segmentAvailability =
4288 gst_mpd_client2_get_next_segment_availability_start_time (mpdclient,
4290 assert_equals_int (gst_date_time_get_year (segmentAvailability), 2015);
4291 assert_equals_int (gst_date_time_get_month (segmentAvailability), 3);
4292 assert_equals_int (gst_date_time_get_day (segmentAvailability), 24);
4293 assert_equals_int (gst_date_time_get_hour (segmentAvailability), 0);
4294 assert_equals_int (gst_date_time_get_minute (segmentAvailability), 1);
4295 assert_equals_int (gst_date_time_get_second (segmentAvailability), 40);
4296 gst_date_time_unref (segmentAvailability);
4299 gst_time = gst_date_time_new_from_iso8601_string ("2015-03-24T0:0:20Z");
4300 g_time = gst_date_time_to_g_date_time (gst_time);
4301 ret = gst_mpd_client2_seek_to_time (mpdclient, g_time);
4302 assert_equals_int (ret, 1);
4303 gst_date_time_unref (gst_time);
4304 g_date_time_unref (g_time);
4306 /* segment index is now 0 */
4308 gst_mpd_client2_has_next_segment (mpdclient, activeStream, TRUE);
4309 assert_equals_int (hasNextSegment, 1);
4311 gst_mpd_client2_free (mpdclient);
4317 * Test handling headers
4320 GST_START_TEST (dash_mpdparser_headers)
4322 GList *adaptationSets;
4323 GstMPDAdaptationSetNode *adapt_set;
4329 "<?xml version=\"1.0\"?>"
4330 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4332 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4333 " availabilityStartTime=\"2015-03-24T0:0:0\""
4334 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4335 " <Period id=\"Period0\">"
4336 " <AdaptationSet mimeType=\"video/mp4\">"
4337 " <Representation id=\"1\" bandwidth=\"250000\">"
4338 " <SegmentBase indexRange=\"10-20\">"
4339 " <Initialization sourceURL=\"TestSourceUrl\""
4340 " range=\"100-200\">"
4341 " </Initialization>"
4342 " <RepresentationIndex sourceURL=\"TestSourceIndex\">"
4343 " </RepresentationIndex>"
4345 " </Representation></AdaptationSet></Period></MPD>";
4348 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4350 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4351 assert_equals_int (ret, TRUE);
4353 /* process the xml data */
4355 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4357 assert_equals_int (ret, TRUE);
4359 /* get the list of adaptation sets of the first period */
4360 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4361 fail_if (adaptationSets == NULL);
4363 /* setup streaming from the first adaptation set */
4364 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4365 fail_if (adapt_set == NULL);
4366 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4367 assert_equals_int (ret, TRUE);
4369 /* get segment url and range from segment Initialization */
4371 gst_mpd_client2_get_next_header (mpdclient, &uri, 0, &range_start,
4373 assert_equals_int (ret, TRUE);
4374 assert_equals_string (uri, "TestSourceUrl");
4375 assert_equals_int64 (range_start, 100);
4376 assert_equals_int64 (range_end, 200);
4379 /* get segment url and range from segment indexRange */
4381 gst_mpd_client2_get_next_header_index (mpdclient, &uri, 0, &range_start,
4383 assert_equals_int (ret, TRUE);
4384 assert_equals_string (uri, "TestSourceIndex");
4385 assert_equals_int64 (range_start, 10);
4386 assert_equals_int64 (range_end, 20);
4389 gst_mpd_client2_free (mpdclient);
4395 * Test handling fragments
4398 GST_START_TEST (dash_mpdparser_fragments)
4400 GList *adaptationSets;
4401 GstMPDAdaptationSetNode *adapt_set;
4402 GstMediaFragmentInfo fragment;
4403 GstActiveStream *activeStream;
4404 GstClockTime nextFragmentDuration;
4405 GstClockTime nextFragmentTimestamp;
4406 GstClockTime nextFragmentTimestampEnd;
4407 GstClockTime periodStartTime;
4408 GstClockTime expectedDuration;
4409 GstClockTime expectedTimestamp;
4410 GstClockTime expectedTimestampEnd;
4413 "<?xml version=\"1.0\"?>"
4414 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4415 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4416 " availabilityStartTime=\"2015-03-24T0:0:0\""
4417 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4418 " <Period id=\"Period0\" start=\"P0Y0M0DT0H0M10S\">"
4419 " <AdaptationSet mimeType=\"video/mp4\">"
4420 " <Representation id=\"1\" bandwidth=\"250000\">"
4421 " </Representation></AdaptationSet></Period></MPD>";
4424 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4426 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4427 assert_equals_int (ret, TRUE);
4429 /* process the xml data */
4431 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4433 assert_equals_int (ret, TRUE);
4435 /* get the list of adaptation sets of the first period */
4436 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4437 fail_if (adaptationSets == NULL);
4439 /* setup streaming from the first adaptation set */
4440 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4441 fail_if (adapt_set == NULL);
4442 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4443 assert_equals_int (ret, TRUE);
4444 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
4445 fail_if (activeStream == NULL);
4447 /* expected duration of the next fragment */
4448 expectedDuration = duration_to_ms (0, 0, 0, 3, 3, 20, 0);
4449 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 0, 0);
4450 expectedTimestampEnd = duration_to_ms (0, 0, 0, 3, 3, 20, 0);
4452 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
4453 assert_equals_int (ret, TRUE);
4454 assert_equals_string (fragment.uri, "");
4455 assert_equals_int64 (fragment.range_start, 0);
4456 assert_equals_int64 (fragment.range_end, -1);
4457 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
4458 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
4459 gst_mpdparser_media_fragment_info_clear (&fragment);
4461 periodStartTime = gst_mpd_client2_get_period_start_time (mpdclient);
4462 assert_equals_uint64 (periodStartTime, 10 * GST_SECOND);
4464 nextFragmentDuration =
4465 gst_mpd_client2_get_next_fragment_duration (mpdclient, activeStream);
4466 assert_equals_uint64 (nextFragmentDuration, expectedDuration * GST_MSECOND);
4469 gst_mpd_client2_get_next_fragment_timestamp (mpdclient, 0,
4470 &nextFragmentTimestamp);
4471 assert_equals_int (ret, TRUE);
4472 assert_equals_uint64 (nextFragmentTimestamp, expectedTimestamp * GST_MSECOND);
4475 gst_mpd_client2_get_last_fragment_timestamp_end (mpdclient, 0,
4476 &nextFragmentTimestampEnd);
4477 assert_equals_int (ret, TRUE);
4478 assert_equals_uint64 (nextFragmentTimestampEnd,
4479 expectedTimestampEnd * GST_MSECOND);
4481 gst_mpd_client2_free (mpdclient);
4487 * Test inheriting segmentBase from parent
4490 GST_START_TEST (dash_mpdparser_inherited_segmentBase)
4492 GstMPDPeriodNode *periodNode;
4493 GstMPDSegmentBaseNode *segmentBase;
4494 GstMPDAdaptationSetNode *adaptationSet;
4495 GstMPDRepresentationNode *representation;
4497 "<?xml version=\"1.0\"?>"
4498 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4499 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
4502 " <SegmentBase timescale=\"100\">"
4504 " <Representation id=\"1\" bandwidth=\"250000\">"
4505 " <SegmentBase timescale=\"200\">"
4507 " </Representation></AdaptationSet></Period></MPD>";
4510 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4512 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4513 assert_equals_int (ret, TRUE);
4515 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
4516 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
4517 representation = (GstMPDRepresentationNode *)
4518 adaptationSet->Representations->data;
4520 /* test segment base from adaptation set */
4521 segmentBase = adaptationSet->SegmentBase;
4522 assert_equals_uint64 (segmentBase->timescale, 100);
4524 /* test segment base from representation */
4525 segmentBase = representation->SegmentBase;
4526 assert_equals_uint64 (segmentBase->timescale, 200);
4528 gst_mpd_client2_free (mpdclient);
4534 * Test inheriting segmentURL from parent
4537 GST_START_TEST (dash_mpdparser_inherited_segmentURL)
4539 GList *adaptationSets;
4540 GstMPDAdaptationSetNode *adapt_set;
4541 GstActiveStream *activeStream;
4542 GstMediaFragmentInfo fragment;
4543 GstClockTime expectedDuration;
4544 GstClockTime expectedTimestamp;
4548 "<?xml version=\"1.0\"?>"
4549 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4550 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4551 " availabilityStartTime=\"2015-03-24T0:0:0\""
4552 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4554 " <AdaptationSet mimeType=\"video/mp4\">"
4555 " <SegmentList duration=\"100\">"
4556 " <SegmentURL media=\"TestMediaAdaptation\""
4557 " mediaRange=\"10-20\""
4558 " index=\"TestIndexAdaptation\""
4559 " indexRange=\"30-40\">"
4562 " <Representation id=\"1\" bandwidth=\"250000\">"
4563 " <SegmentList duration=\"110\">"
4564 " <SegmentURL media=\"TestMediaRep\""
4565 " mediaRange=\"100-200\""
4566 " index=\"TestIndexRep\""
4567 " indexRange=\"300-400\">"
4570 " </Representation></AdaptationSet></Period></MPD>";
4573 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4575 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4576 assert_equals_int (ret, TRUE);
4578 /* process the xml data */
4580 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4582 assert_equals_int (ret, TRUE);
4584 /* get the list of adaptation sets of the first period */
4585 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4586 fail_if (adaptationSets == NULL);
4588 /* setup streaming from the first adaptation set */
4589 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4590 fail_if (adapt_set == NULL);
4591 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4592 assert_equals_int (ret, TRUE);
4594 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
4595 fail_if (activeStream == NULL);
4597 /* expected duration of the next fragment
4598 * Segment duration was set to 100 in AdaptationSet and to 110 in Representation
4599 * We expect duration to be 110
4601 expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 110, 0);
4602 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 0, 0);
4604 /* the representation contains 1 segment (the one from Representation) */
4606 /* check first segment */
4607 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
4608 assert_equals_int (ret, TRUE);
4609 assert_equals_string (fragment.uri, "/TestMediaRep");
4610 assert_equals_int64 (fragment.range_start, 100);
4611 assert_equals_int64 (fragment.range_end, 200);
4612 assert_equals_string (fragment.index_uri, "/TestIndexRep");
4613 assert_equals_int64 (fragment.index_range_start, 300);
4614 assert_equals_int64 (fragment.index_range_end, 400);
4615 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
4616 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
4617 gst_mpdparser_media_fragment_info_clear (&fragment);
4619 /* try to advance to next segment. Should fail */
4620 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
4621 assert_equals_int (flow, GST_FLOW_EOS);
4623 gst_mpd_client2_free (mpdclient);
4632 GST_START_TEST (dash_mpdparser_segment_list)
4634 GList *adaptationSets;
4635 GstMPDAdaptationSetNode *adapt_set;
4636 GstActiveStream *activeStream;
4637 GstMediaFragmentInfo fragment;
4638 GstClockTime expectedDuration;
4639 GstClockTime expectedTimestamp;
4641 "<?xml version=\"1.0\"?>"
4642 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4643 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4644 " availabilityStartTime=\"2015-03-24T0:0:0\""
4645 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4646 " <Period start=\"P0Y0M0DT0H0M10S\">"
4647 " <AdaptationSet mimeType=\"video/mp4\">"
4648 " <Representation id=\"1\" bandwidth=\"250000\">"
4649 " <SegmentList duration=\"12000\">"
4650 " <SegmentURL media=\"TestMedia\""
4651 " mediaRange=\"100-200\""
4652 " index=\"TestIndex\""
4653 " indexRange=\"300-400\">"
4656 " </Representation></AdaptationSet></Period></MPD>";
4659 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4661 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4662 assert_equals_int (ret, TRUE);
4664 /* process the xml data */
4666 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4668 assert_equals_int (ret, TRUE);
4670 /* get the list of adaptation sets of the first period */
4671 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4672 fail_if (adaptationSets == NULL);
4674 /* setup streaming from the first adaptation set */
4675 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4676 fail_if (adapt_set == NULL);
4677 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4678 assert_equals_int (ret, TRUE);
4680 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
4681 fail_if (activeStream == NULL);
4683 /* expected duration of the next fragment
4684 * Segment duration was set larger than period duration (12000 vs 11000).
4685 * We expect it to be limited to period duration.
4687 expectedDuration = duration_to_ms (0, 0, 0, 3, 3, 20, 0);
4688 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 10, 0);
4690 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
4691 assert_equals_int (ret, TRUE);
4692 assert_equals_string (fragment.uri, "/TestMedia");
4693 assert_equals_int64 (fragment.range_start, 100);
4694 assert_equals_int64 (fragment.range_end, 200);
4695 assert_equals_string (fragment.index_uri, "/TestIndex");
4696 assert_equals_int64 (fragment.index_range_start, 300);
4697 assert_equals_int64 (fragment.index_range_end, 400);
4698 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
4699 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
4701 gst_mpdparser_media_fragment_info_clear (&fragment);
4703 gst_mpd_client2_free (mpdclient);
4709 * Test segment template
4712 GST_START_TEST (dash_mpdparser_segment_template)
4714 GList *adaptationSets;
4715 GstMPDAdaptationSetNode *adapt_set;
4716 GstActiveStream *activeStream;
4717 GstMediaFragmentInfo fragment;
4718 GstClockTime expectedDuration;
4719 GstClockTime expectedTimestamp;
4720 GstClockTime periodStartTime;
4721 GstClockTime offset;
4722 GstClockTime lastFragmentTimestampEnd;
4724 "<?xml version=\"1.0\"?>"
4725 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4726 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4727 " availabilityStartTime=\"2015-03-24T0:0:0\""
4728 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4729 " <Period start=\"P0Y0M0DT0H0M10S\">"
4730 " <AdaptationSet mimeType=\"video/mp4\">"
4731 " <Representation id=\"repId\" bandwidth=\"250000\">"
4732 " <SegmentTemplate duration=\"12000\""
4733 " presentationTimeOffset=\"15\""
4734 " media=\"TestMedia_rep=$RepresentationID$number=$Number$bandwidth=$Bandwidth$time=$Time$\""
4735 " index=\"TestIndex\">"
4736 " </SegmentTemplate>"
4737 " </Representation></AdaptationSet></Period></MPD>";
4740 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4742 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4743 assert_equals_int (ret, TRUE);
4745 /* process the xml data */
4747 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4749 assert_equals_int (ret, TRUE);
4751 /* get the list of adaptation sets of the first period */
4752 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4753 fail_if (adaptationSets == NULL);
4755 /* setup streaming from the first adaptation set */
4756 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4757 fail_if (adapt_set == NULL);
4758 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4759 assert_equals_int (ret, TRUE);
4761 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
4762 fail_if (activeStream == NULL);
4764 /* expected duration of the next fragment
4765 * Segment duration was set larger than period duration (12000 vs 11000).
4766 * We expect it to not be limited to period duration.
4768 expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 12000, 0);
4770 /* while the period starts at 10ms, the fragment timestamp is supposed to be
4771 * 0ms. timestamps are starting from 0 at every period, and only the overall
4772 * composition of periods should consider the period start timestamp. In
4773 * dashdemux this is done by mapping the 0 fragment timestamp to a stream
4774 * time equal to the period start time.
4776 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 0, 0);
4778 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
4779 assert_equals_int (ret, TRUE);
4780 assert_equals_string (fragment.uri,
4781 "/TestMedia_rep=repIdnumber=1bandwidth=250000time=0");
4782 assert_equals_int64 (fragment.range_start, 0);
4783 assert_equals_int64 (fragment.range_end, -1);
4784 assert_equals_string (fragment.index_uri, "/TestIndex");
4785 assert_equals_int64 (fragment.index_range_start, 0);
4786 assert_equals_int64 (fragment.index_range_end, -1);
4787 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
4788 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
4790 periodStartTime = gst_mpd_client2_get_period_start_time (mpdclient);
4791 assert_equals_uint64 (periodStartTime, 10 * GST_SECOND);
4793 offset = gst_mpd_client2_get_stream_presentation_offset (mpdclient, 0);
4794 assert_equals_uint64 (offset, 15 * GST_SECOND);
4796 gst_mpdparser_media_fragment_info_clear (&fragment);
4799 * Period starts at 10s.
4800 * MPD has a duration of 3h3m30s, so period duration is 3h3m20s.
4801 * We expect the last fragment to end at period start + period duration: 3h3m30s
4803 expectedTimestamp = duration_to_ms (0, 0, 0, 3, 3, 30, 0);
4804 ret = gst_mpd_client2_get_last_fragment_timestamp_end (mpdclient, 0,
4805 &lastFragmentTimestampEnd);
4806 assert_equals_int (ret, TRUE);
4807 assert_equals_uint64 (lastFragmentTimestampEnd,
4808 expectedTimestamp * GST_MSECOND);
4810 gst_mpd_client2_free (mpdclient);
4816 * Test segment timeline
4819 GST_START_TEST (dash_mpdparser_segment_timeline)
4821 GList *adaptationSets;
4822 GstMPDAdaptationSetNode *adapt_set;
4823 GstActiveStream *activeStream;
4824 GstMediaFragmentInfo fragment;
4825 GstClockTime expectedDuration;
4826 GstClockTime expectedTimestamp;
4828 GstDateTime *segmentAvailability;
4831 "<?xml version=\"1.0\"?>"
4832 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
4833 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
4834 " availabilityStartTime=\"2015-03-24T0:0:0\""
4835 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
4836 " <Period start=\"P0Y0M0DT0H0M10S\">"
4837 " <AdaptationSet mimeType=\"video/mp4\">"
4839 " <SegmentTimeline>"
4840 " <S t=\"10\" d=\"20\" r=\"30\"></S>"
4841 " </SegmentTimeline>"
4843 " <Representation id=\"1\" bandwidth=\"250000\">"
4845 " <SegmentTimeline>"
4846 " <S t=\"3\" d=\"2\" r=\"1\"></S>"
4847 " <S t=\"10\" d=\"3\" r=\"0\"></S>"
4848 " </SegmentTimeline>"
4849 " <SegmentURL media=\"TestMedia0\""
4850 " index=\"TestIndex0\">"
4852 " <SegmentURL media=\"TestMedia1\""
4853 " index=\"TestIndex1\">"
4856 " </Representation></AdaptationSet></Period></MPD>";
4859 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
4861 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
4862 assert_equals_int (ret, TRUE);
4864 /* process the xml data */
4866 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
4868 assert_equals_int (ret, TRUE);
4870 /* get the list of adaptation sets of the first period */
4871 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
4872 fail_if (adaptationSets == NULL);
4874 /* setup streaming from the first adaptation set */
4875 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
4876 fail_if (adapt_set == NULL);
4877 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
4878 assert_equals_int (ret, TRUE);
4880 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
4881 fail_if (activeStream == NULL);
4883 /* expected duration of the next fragment */
4884 expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 2, 0);
4885 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 13, 0);
4887 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
4888 assert_equals_int (ret, TRUE);
4889 assert_equals_string (fragment.uri, "/TestMedia0");
4890 assert_equals_string (fragment.index_uri, "/TestIndex0");
4891 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
4892 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
4893 gst_mpdparser_media_fragment_info_clear (&fragment);
4895 /* first segment starts at 3s and has a duration of 2s.
4896 * We also add period start time (10s) so we expect a segment availability
4899 segmentAvailability =
4900 gst_mpd_client2_get_next_segment_availability_start_time (mpdclient,
4902 fail_unless (segmentAvailability != NULL);
4903 assert_equals_int (gst_date_time_get_year (segmentAvailability), 2015);
4904 assert_equals_int (gst_date_time_get_month (segmentAvailability), 3);
4905 assert_equals_int (gst_date_time_get_day (segmentAvailability), 24);
4906 assert_equals_int (gst_date_time_get_hour (segmentAvailability), 0);
4907 assert_equals_int (gst_date_time_get_minute (segmentAvailability), 0);
4908 assert_equals_int (gst_date_time_get_second (segmentAvailability), 15);
4909 gst_date_time_unref (segmentAvailability);
4911 /* advance to next segment */
4912 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
4913 assert_equals_int (flow, GST_FLOW_OK);
4915 /* second segment starts after first ends */
4916 expectedTimestamp = expectedTimestamp + expectedDuration;
4918 /* check second segment.
4919 * It is a repeat of first segmentURL, because "r" in SegmentTimeline is 1
4921 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
4922 assert_equals_int (ret, TRUE);
4923 assert_equals_string (fragment.uri, "/TestMedia0");
4924 assert_equals_string (fragment.index_uri, "/TestIndex0");
4925 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
4926 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
4927 gst_mpdparser_media_fragment_info_clear (&fragment);
4929 /* first segment starts at 3s and has a duration of 2s.
4930 * Second segment starts when the first ends (5s) and has a duration of 2s,
4932 * We also add period start time (10s) so we expect a segment availability
4935 segmentAvailability =
4936 gst_mpd_client2_get_next_segment_availability_start_time (mpdclient,
4938 fail_unless (segmentAvailability != NULL);
4939 assert_equals_int (gst_date_time_get_year (segmentAvailability), 2015);
4940 assert_equals_int (gst_date_time_get_month (segmentAvailability), 3);
4941 assert_equals_int (gst_date_time_get_day (segmentAvailability), 24);
4942 assert_equals_int (gst_date_time_get_hour (segmentAvailability), 0);
4943 assert_equals_int (gst_date_time_get_minute (segmentAvailability), 0);
4944 assert_equals_int (gst_date_time_get_second (segmentAvailability), 17);
4945 gst_date_time_unref (segmentAvailability);
4947 /* advance to next segment */
4948 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
4949 assert_equals_int (flow, GST_FLOW_OK);
4951 /* third segment has a small gap after the second ends (t=10) */
4952 expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 3, 0);
4953 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 20, 0);
4955 /* check third segment */
4956 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
4957 assert_equals_int (ret, TRUE);
4958 assert_equals_string (fragment.uri, "/TestMedia1");
4959 assert_equals_string (fragment.index_uri, "/TestIndex1");
4960 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
4961 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
4962 gst_mpdparser_media_fragment_info_clear (&fragment);
4964 /* Third segment starts at 10s and has a duration of 3s so it ends at 13s.
4965 * We also add period start time (10s) so we expect a segment availability
4968 segmentAvailability =
4969 gst_mpd_client2_get_next_segment_availability_start_time (mpdclient,
4971 fail_unless (segmentAvailability != NULL);
4972 assert_equals_int (gst_date_time_get_year (segmentAvailability), 2015);
4973 assert_equals_int (gst_date_time_get_month (segmentAvailability), 3);
4974 assert_equals_int (gst_date_time_get_day (segmentAvailability), 24);
4975 assert_equals_int (gst_date_time_get_hour (segmentAvailability), 0);
4976 assert_equals_int (gst_date_time_get_minute (segmentAvailability), 0);
4977 assert_equals_int (gst_date_time_get_second (segmentAvailability), 23);
4978 gst_date_time_unref (segmentAvailability);
4980 gst_mpd_client2_free (mpdclient);
4986 * Test SegmentList with multiple inherited segmentURLs
4989 GST_START_TEST (dash_mpdparser_multiple_inherited_segmentURL)
4991 GList *adaptationSets;
4992 GstMPDAdaptationSetNode *adapt_set;
4993 GstActiveStream *activeStream;
4994 GstMediaFragmentInfo fragment;
4995 GstClockTime expectedDuration;
4996 GstClockTime expectedTimestamp;
5000 * Period duration is 30 seconds
5001 * Period start is 10 seconds. Thus, period duration is 20 seconds.
5003 * There are 2 segments in the AdaptationSet segment list and 2 in the
5004 * Representation's segment list.
5005 * Segment duration is 5s for the Adaptation segments and 8s for
5006 * Representation segments.
5007 * Separately, each segment list (duration 2*5=10 or 2*8=16) fits comfortably
5008 * in the Period's 20s duration.
5010 * We expect the Representation segments to overwrite the AdaptationSet segments.
5013 "<?xml version=\"1.0\"?>"
5014 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5015 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5016 " availabilityStartTime=\"2015-03-24T0:0:0\""
5017 " mediaPresentationDuration=\"P0Y0M0DT0H0M30S\">"
5019 " <AdaptationSet mimeType=\"video/mp4\">"
5020 " <SegmentList duration=\"5\">"
5022 " media=\"TestMedia0\" mediaRange=\"10-20\""
5023 " index=\"TestIndex0\" indexRange=\"100-200\""
5026 " media=\"TestMedia1\" mediaRange=\"20-30\""
5027 " index=\"TestIndex1\" indexRange=\"200-300\""
5030 " <Representation id=\"1\" bandwidth=\"250000\">"
5031 " <SegmentList duration=\"8\">"
5033 " media=\"TestMedia2\" mediaRange=\"30-40\""
5034 " index=\"TestIndex2\" indexRange=\"300-400\""
5037 " media=\"TestMedia3\" mediaRange=\"40-50\""
5038 " index=\"TestIndex3\" indexRange=\"400-500\""
5041 " </Representation></AdaptationSet></Period></MPD>";
5044 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5046 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5047 assert_equals_int (ret, TRUE);
5049 /* process the xml data */
5051 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5053 assert_equals_int (ret, TRUE);
5055 /* get the list of adaptation sets of the first period */
5056 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
5057 fail_if (adaptationSets == NULL);
5059 /* setup streaming from the first adaptation set */
5060 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
5061 fail_if (adapt_set == NULL);
5062 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
5063 assert_equals_int (ret, TRUE);
5065 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
5066 fail_if (activeStream == NULL);
5068 expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 8, 0);
5069 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 0, 0);
5071 /* the representation contains 2 segments defined in the Representation
5073 * Both will have the duration specified in the Representation (8)
5076 /* check first segment */
5077 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
5078 assert_equals_int (ret, TRUE);
5079 assert_equals_string (fragment.uri, "/TestMedia2");
5080 assert_equals_int64 (fragment.range_start, 30);
5081 assert_equals_int64 (fragment.range_end, 40);
5082 assert_equals_string (fragment.index_uri, "/TestIndex2");
5083 assert_equals_int64 (fragment.index_range_start, 300);
5084 assert_equals_int64 (fragment.index_range_end, 400);
5085 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
5086 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
5087 gst_mpdparser_media_fragment_info_clear (&fragment);
5089 /* advance to next segment */
5090 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
5091 assert_equals_int (flow, GST_FLOW_OK);
5093 /* second segment starts after previous ends */
5094 expectedTimestamp = expectedTimestamp + expectedDuration;
5096 /* check second segment */
5097 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
5098 assert_equals_int (ret, TRUE);
5099 assert_equals_string (fragment.uri, "/TestMedia3");
5100 assert_equals_int64 (fragment.range_start, 40);
5101 assert_equals_int64 (fragment.range_end, 50);
5102 assert_equals_string (fragment.index_uri, "/TestIndex3");
5103 assert_equals_int64 (fragment.index_range_start, 400);
5104 assert_equals_int64 (fragment.index_range_end, 500);
5105 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
5106 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
5107 gst_mpdparser_media_fragment_info_clear (&fragment);
5109 /* try to advance to the next segment. There isn't any, so it should fail */
5110 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
5111 assert_equals_int (flow, GST_FLOW_EOS);
5113 gst_mpd_client2_free (mpdclient);
5119 * Test SegmentList with multiple segmentURL
5122 GST_START_TEST (dash_mpdparser_multipleSegmentURL)
5124 GList *adaptationSets;
5125 GstMPDAdaptationSetNode *adapt_set;
5126 GstActiveStream *activeStream;
5127 GstMediaFragmentInfo fragment;
5128 GstClockTime expectedDuration;
5129 GstClockTime expectedTimestamp;
5133 * Period duration is 30 seconds
5134 * Period start is 10 seconds. Thus, period duration is 20 seconds.
5136 * Segment duration is 25 seconds. There are 2 segments in the list.
5137 * We expect first segment to have a duration of 20 seconds (limited by the period)
5138 * and the second segment to not exist.
5141 "<?xml version=\"1.0\"?>"
5142 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5143 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5144 " availabilityStartTime=\"2015-03-24T0:0:0\""
5145 " mediaPresentationDuration=\"P0Y0M0DT0H0M30S\">"
5146 "<Period start=\"P0Y0M0DT0H0M10S\">"
5147 " <AdaptationSet mimeType=\"video/mp4\">"
5148 " <Representation id=\"1\" bandwidth=\"250000\">"
5149 " <SegmentList duration=\"25\">"
5151 " media=\"TestMedia0\" mediaRange=\"10-20\""
5152 " index=\"TestIndex0\" indexRange=\"100-200\""
5155 " media=\"TestMedia1\" mediaRange=\"20-30\""
5156 " index=\"TestIndex1\" indexRange=\"200-300\""
5159 " </Representation></AdaptationSet></Period></MPD>";
5162 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5164 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5165 assert_equals_int (ret, TRUE);
5167 /* process the xml data */
5169 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5171 assert_equals_int (ret, TRUE);
5173 /* get the list of adaptation sets of the first period */
5174 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
5175 fail_if (adaptationSets == NULL);
5177 /* setup streaming from the first adaptation set */
5178 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
5179 fail_if (adapt_set == NULL);
5180 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
5181 assert_equals_int (ret, TRUE);
5183 activeStream = gst_mpd_client2_get_active_stream_by_index (mpdclient, 0);
5184 fail_if (activeStream == NULL);
5186 expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 20, 0);
5187 expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 10, 0);
5189 /* the representation contains 2 segments. The first is partially
5190 * clipped, and the second entirely (and thus discarded).
5193 /* check first segment */
5194 ret = gst_mpd_client2_get_next_fragment (mpdclient, 0, &fragment);
5195 assert_equals_int (ret, TRUE);
5196 assert_equals_string (fragment.uri, "/TestMedia0");
5197 assert_equals_int64 (fragment.range_start, 10);
5198 assert_equals_int64 (fragment.range_end, 20);
5199 assert_equals_string (fragment.index_uri, "/TestIndex0");
5200 assert_equals_int64 (fragment.index_range_start, 100);
5201 assert_equals_int64 (fragment.index_range_end, 200);
5202 assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND);
5203 assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND);
5204 gst_mpdparser_media_fragment_info_clear (&fragment);
5206 /* advance to next segment */
5207 flow = gst_mpd_client2_advance_segment (mpdclient, activeStream, TRUE);
5208 assert_equals_int (flow, GST_FLOW_EOS);
5210 gst_mpd_client2_free (mpdclient);
5216 * Test parsing empty xml string
5219 GST_START_TEST (dash_mpdparser_missing_xml)
5221 const gchar *xml = "";
5224 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5226 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5227 assert_equals_int (ret, FALSE);
5229 gst_mpd_client2_free (mpdclient);
5235 * Test parsing an xml with no mpd tag
5238 GST_START_TEST (dash_mpdparser_missing_mpd)
5240 const gchar *xml = "<?xml version=\"1.0\"?>";
5243 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5245 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5246 assert_equals_int (ret, FALSE);
5248 gst_mpd_client2_free (mpdclient);
5254 * Test parsing an MPD with a wrong end tag
5256 GST_START_TEST (dash_mpdparser_no_end_tag)
5259 "<?xml version=\"1.0\"?>"
5260 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5261 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\"> </NPD>";
5264 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5266 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5267 assert_equals_int (ret, FALSE);
5269 gst_mpd_client2_free (mpdclient);
5275 * Test parsing an MPD with no default namespace
5277 GST_START_TEST (dash_mpdparser_no_default_namespace)
5280 "<?xml version=\"1.0\"?>"
5281 "<MPD profiles=\"urn:mpeg:dash:profile:isoff-main:2011\"></MPD>";
5284 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5286 ret = gst_mpd_client2_parse (mpdclient, xml, strlen (xml));
5287 assert_equals_int (ret, TRUE);
5289 gst_mpd_client2_free (mpdclient);
5295 * Test handling wrong period duration during attempts to
5296 * infer a period duration from the start time of the next period
5298 GST_START_TEST (dash_mpdparser_wrong_period_duration_inferred_from_next_period)
5300 const gchar *periodName;
5303 "<?xml version=\"1.0\"?>"
5304 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5305 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5306 " availabilityStartTime=\"2015-03-24T0:0:0\""
5307 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
5308 " <Period id=\"Period0\" duration=\"P0Y0M0DT1H1M0S\"></Period>"
5309 " <Period id=\"Period1\"></Period>"
5310 " <Period id=\"Period2\" start=\"P0Y0M0DT0H0M10S\"></Period></MPD>";
5313 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5315 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5316 assert_equals_int (ret, TRUE);
5318 /* period_idx should be 0 and we should have no active periods */
5319 assert_equals_uint64 (mpdclient->period_idx, 0);
5320 fail_unless (mpdclient->periods == NULL);
5322 /* process the xml data */
5324 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5326 assert_equals_int (ret, TRUE);
5328 /* Period0 should be present */
5329 fail_unless (mpdclient->periods != NULL);
5330 periodName = gst_mpd_client2_get_period_id (mpdclient);
5331 assert_equals_string (periodName, "Period0");
5333 /* Period1 should not be present due to wrong duration */
5334 ret = gst_mpd_client2_set_period_index (mpdclient, 1);
5335 assert_equals_int (ret, FALSE);
5337 gst_mpd_client2_free (mpdclient);
5343 * Test handling wrong period duration during attempts to
5344 * infer a period duration from the mediaPresentationDuration
5347 (dash_mpdparser_wrong_period_duration_inferred_from_next_mediaPresentationDuration)
5350 "<?xml version=\"1.0\"?>"
5351 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5352 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5353 " availabilityStartTime=\"2015-03-24T0:0:0\""
5354 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
5355 " <Period id=\"Period0\" start=\"P0Y0M0DT4H0M0S\"></Period></MPD>";
5358 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5360 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5361 assert_equals_int (ret, TRUE);
5363 /* period_idx should be 0 and we should have no active periods */
5364 assert_equals_uint64 (mpdclient->period_idx, 0);
5365 fail_unless (mpdclient->periods == NULL);
5367 /* process the xml data
5368 * should fail due to wrong duration in Period0 (start > mediaPresentationDuration)
5371 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5373 assert_equals_int (ret, FALSE);
5375 gst_mpd_client2_free (mpdclient);
5380 GST_START_TEST (dash_mpdparser_whitespace_strings)
5382 fail_unless (_mpd_helper_validate_no_whitespace ("") == TRUE);
5383 fail_unless (_mpd_helper_validate_no_whitespace ("/") == TRUE);
5384 fail_unless (_mpd_helper_validate_no_whitespace (" ") == FALSE);
5385 fail_unless (_mpd_helper_validate_no_whitespace ("aaaaaaaa ") == FALSE);
5386 fail_unless (_mpd_helper_validate_no_whitespace ("a\ta") == FALSE);
5387 fail_unless (_mpd_helper_validate_no_whitespace ("a\ra") == FALSE);
5388 fail_unless (_mpd_helper_validate_no_whitespace ("a\na") == FALSE);
5393 GST_START_TEST (dash_mpdparser_rfc1738_strings)
5395 fail_unless (gst_mpdparser_validate_rfc1738_url ("/") == TRUE);
5396 fail_unless (gst_mpdparser_validate_rfc1738_url (" ") == FALSE);
5397 fail_unless (gst_mpdparser_validate_rfc1738_url ("aaaaaaaa ") == FALSE);
5399 fail_unless (gst_mpdparser_validate_rfc1738_url ("") == TRUE);
5400 fail_unless (gst_mpdparser_validate_rfc1738_url ("a") == TRUE);
5401 fail_unless (gst_mpdparser_validate_rfc1738_url
5402 (";:@&=aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789$-_.+!*'(),%AA")
5404 fail_unless (gst_mpdparser_validate_rfc1738_url
5405 (";:@&=aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789$-_.+!*'(),/%AA")
5407 fail_unless (gst_mpdparser_validate_rfc1738_url
5408 (";:@&=aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789$-_.+!*'(),% ")
5410 fail_unless (gst_mpdparser_validate_rfc1738_url ("%AA") == TRUE);
5411 fail_unless (gst_mpdparser_validate_rfc1738_url ("%A") == FALSE);
5412 fail_unless (gst_mpdparser_validate_rfc1738_url ("%") == FALSE);
5413 fail_unless (gst_mpdparser_validate_rfc1738_url ("%XA") == FALSE);
5414 fail_unless (gst_mpdparser_validate_rfc1738_url ("%AX") == FALSE);
5415 fail_unless (gst_mpdparser_validate_rfc1738_url ("%XX") == FALSE);
5416 fail_unless (gst_mpdparser_validate_rfc1738_url ("\001") == FALSE);
5422 * Test negative period duration
5424 GST_START_TEST (dash_mpdparser_negative_period_duration)
5427 "<?xml version=\"1.0\"?>"
5428 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5429 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5430 " availabilityStartTime=\"2015-03-24T0:0:0\""
5431 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
5432 " <Period id=\"Period0\""
5433 " start=\"P0Y0M0DT1H0M0S\""
5434 " duration=\"-PT10S\">"
5435 " </Period><Period id=\"Period1\"></Period></MPD>";
5438 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5440 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5441 assert_equals_int (ret, TRUE);
5443 /* process the xml data
5444 * should fail due to negative duration of Period0
5447 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5449 assert_equals_int (ret, FALSE);
5451 gst_mpd_client2_free (mpdclient);
5457 * Test parsing negative values from attributes that should be unsigned
5460 GST_START_TEST (dash_mpdparser_read_unsigned_from_negative_values)
5462 GstMPDPeriodNode *periodNode;
5463 GstMPDSegmentBaseNode *segmentBase;
5464 GstMPDAdaptationSetNode *adaptationSet;
5465 GstMPDRepresentationNode *representation;
5466 GstMPDSubRepresentationNode *subRepresentation;
5469 "<?xml version=\"1.0\"?>"
5470 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5471 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5472 " availabilityStartTime=\"2015--1-13T12:25:37\">"
5473 " <Period start=\"-P-2015Y\" duration=\"-P-5M\">"
5474 " <SegmentBase presentationTimeOffset=\"-10\""
5476 " indexRange=\"1--10\">"
5478 " <AdaptationSet par=\"-1:7\""
5479 " minFrameRate=\" -1\""
5480 " segmentAlignment=\"-4\">"
5481 " <Representation id=\"1\" bandwidth=\"250000\">"
5482 " <SubRepresentation dependencyLevel=\"1 -2 3\">"
5483 " </SubRepresentation>"
5484 " </Representation></AdaptationSet></Period></MPD>";
5487 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5489 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5490 assert_equals_int (ret, TRUE);
5492 periodNode = (GstMPDPeriodNode *) mpdclient->mpd_root_node->Periods->data;
5493 segmentBase = periodNode->SegmentBase;
5494 adaptationSet = (GstMPDAdaptationSetNode *) periodNode->AdaptationSets->data;
5495 representation = (GstMPDRepresentationNode *)
5496 adaptationSet->Representations->data;
5497 subRepresentation = (GstMPDSubRepresentationNode *)
5498 representation->SubRepresentations->data;
5500 /* availabilityStartTime parsing should fail */
5501 fail_if (mpdclient->mpd_root_node->availabilityStartTime != NULL);
5503 /* Period start parsing should fail */
5504 assert_equals_int64 (periodNode->start, -1);
5506 /* Period duration parsing should fail */
5507 assert_equals_int64 (periodNode->duration, -1);
5509 /* expect negative value to be rejected and presentationTimeOffset to be 0 */
5510 assert_equals_uint64 (segmentBase->presentationTimeOffset, 0);
5511 assert_equals_uint64 (segmentBase->timescale, 1);
5512 fail_if (segmentBase->indexRange != NULL);
5514 /* par ratio parsing should fail */
5515 fail_if (adaptationSet->par != NULL);
5517 /* minFrameRate parsing should fail */
5518 fail_if (GST_MPD_REPRESENTATION_BASE_NODE (adaptationSet)->minFrameRate !=
5521 /* segmentAlignment parsing should fail */
5522 fail_if (adaptationSet->segmentAlignment != NULL);
5524 /* dependency level parsing should fail */
5525 fail_if (subRepresentation->dependencyLevel != NULL);
5527 gst_mpd_client2_free (mpdclient);
5533 * Test negative mediaPresentationDuration duration
5535 GST_START_TEST (dash_mpdparser_negative_mediaPresentationDuration)
5538 "<?xml version=\"1.0\"?>"
5539 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5540 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5541 " availabilityStartTime=\"2015-03-24T0:0:0\""
5542 " mediaPresentationDuration=\"-P0Y0M0DT3H3M30S\">"
5543 " <Period id=\"Period0\" start=\"P0Y0M0DT1H0M0S\"></Period></MPD>";
5546 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5548 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5549 assert_equals_int (ret, TRUE);
5551 /* process the xml data
5552 * should fail due to negative duration of mediaPresentationDuration
5555 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5557 assert_equals_int (ret, FALSE);
5559 gst_mpd_client2_free (mpdclient);
5565 * Test parsing an MPD with no profiles
5567 GST_START_TEST (dash_mpdparser_no_profiles)
5570 "<?xml version=\"1.0\"?>"
5571 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\"></MPD>";
5574 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5576 ret = gst_mpd_client2_parse (mpdclient, xml, strlen (xml));
5578 assert_equals_int (ret, TRUE);
5580 gst_mpd_client2_free (mpdclient);
5586 * Test S node list greater than SegmentURL list
5589 GST_START_TEST (dash_mpdparser_unmatched_segmentTimeline_segmentURL)
5591 GList *adaptationSets;
5592 GstMPDAdaptationSetNode *adapt_set;
5595 "<?xml version=\"1.0\"?>"
5596 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5597 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5598 " availabilityStartTime=\"2015-03-24T0:0:0\""
5599 " mediaPresentationDuration=\"P0Y0M0DT3H3M30S\">"
5600 " <Period start=\"P0Y0M0DT0H0M10S\">"
5601 " <AdaptationSet mimeType=\"video/mp4\">"
5602 " <Representation id=\"1\" bandwidth=\"250000\">"
5604 " <SegmentTimeline>"
5605 " <S t=\"3\" d=\"2\" r=\"1\"></S>"
5606 " <S t=\"10\" d=\"3\" r=\"0\"></S>"
5607 " </SegmentTimeline>"
5608 " <SegmentURL media=\"TestMedia0\""
5609 " index=\"TestIndex0\">"
5612 " </Representation></AdaptationSet></Period></MPD>";
5615 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5617 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5618 assert_equals_int (ret, TRUE);
5620 /* process the xml data */
5622 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5624 assert_equals_int (ret, TRUE);
5626 /* get the list of adaptation sets of the first period */
5627 adaptationSets = gst_mpd_client2_get_adaptation_sets (mpdclient);
5628 fail_if (adaptationSets == NULL);
5630 adapt_set = (GstMPDAdaptationSetNode *) g_list_nth_data (adaptationSets, 0);
5631 fail_if (adapt_set == NULL);
5633 /* setup streaming from the first adaptation set.
5634 * Should fail because the second S node does not have a matching
5637 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set);
5638 assert_equals_int (ret, FALSE);
5640 gst_mpd_client2_free (mpdclient);
5646 * Test parsing of the default presentation delay property
5648 GST_START_TEST (dash_mpdparser_default_presentation_delay)
5651 "<?xml version=\"1.0\"?>"
5652 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5653 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5654 " maxSegmentDuration=\"PT2S\">"
5655 " <Period id=\"Period0\" start=\"P0S\"></Period></MPD>";
5658 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5661 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5662 assert_equals_int (ret, TRUE);
5663 value = gst_mpd_client2_parse_default_presentation_delay (mpdclient, "5s");
5664 assert_equals_int64 (value, 5000);
5665 value = gst_mpd_client2_parse_default_presentation_delay (mpdclient, "5S");
5666 assert_equals_int64 (value, 5000);
5668 gst_mpd_client2_parse_default_presentation_delay (mpdclient, "5 seconds");
5669 assert_equals_int64 (value, 5000);
5671 gst_mpd_client2_parse_default_presentation_delay (mpdclient, "2500ms");
5672 assert_equals_int64 (value, 2500);
5673 value = gst_mpd_client2_parse_default_presentation_delay (mpdclient, "3f");
5674 assert_equals_int64 (value, 6000);
5675 value = gst_mpd_client2_parse_default_presentation_delay (mpdclient, "3F");
5676 assert_equals_int64 (value, 6000);
5677 value = gst_mpd_client2_parse_default_presentation_delay (mpdclient, "");
5678 assert_equals_int64 (value, 0);
5679 value = gst_mpd_client2_parse_default_presentation_delay (mpdclient, "10");
5680 assert_equals_int64 (value, 0);
5682 gst_mpd_client2_parse_default_presentation_delay (mpdclient,
5684 assert_equals_int64 (value, 0);
5686 gst_mpd_client2_free (mpdclient);
5691 GST_START_TEST (dash_mpdparser_duration)
5695 fail_unless (_mpd_helper_parse_duration ("", &v) == FALSE);
5696 fail_unless (_mpd_helper_parse_duration (" ", &v) == FALSE);
5697 fail_unless (_mpd_helper_parse_duration ("0", &v) == FALSE);
5698 fail_unless (_mpd_helper_parse_duration ("D-1", &v) == FALSE);
5699 fail_unless (_mpd_helper_parse_duration ("T", &v) == FALSE);
5701 fail_unless (_mpd_helper_parse_duration ("P", &v) == TRUE);
5702 fail_unless (_mpd_helper_parse_duration ("PT", &v) == TRUE);
5703 fail_unless (_mpd_helper_parse_duration ("PX", &v) == FALSE);
5704 fail_unless (_mpd_helper_parse_duration ("PPT", &v) == FALSE);
5705 fail_unless (_mpd_helper_parse_duration ("PTT", &v) == FALSE);
5707 fail_unless (_mpd_helper_parse_duration ("P1D", &v) == TRUE);
5708 fail_unless (_mpd_helper_parse_duration ("P1D1D", &v) == FALSE);
5709 fail_unless (_mpd_helper_parse_duration ("P1D1M", &v) == FALSE);
5710 fail_unless (_mpd_helper_parse_duration ("P1M1D", &v) == TRUE);
5711 fail_unless (_mpd_helper_parse_duration ("P1M1D1M", &v) == FALSE);
5712 fail_unless (_mpd_helper_parse_duration ("P1M1D1D", &v) == FALSE);
5714 fail_unless (_mpd_helper_parse_duration ("P0M0D", &v) == TRUE);
5715 fail_unless (_mpd_helper_parse_duration ("P-1M", &v) == FALSE);
5716 fail_unless (_mpd_helper_parse_duration ("P15M", &v) == FALSE);
5717 fail_unless (_mpd_helper_parse_duration ("P-1D", &v) == FALSE);
5718 fail_unless (_mpd_helper_parse_duration ("P35D", &v) == FALSE);
5719 fail_unless (_mpd_helper_parse_duration ("P-1Y", &v) == FALSE);
5720 fail_unless (_mpd_helper_parse_duration ("PT-1H", &v) == FALSE);
5721 fail_unless (_mpd_helper_parse_duration ("PT25H", &v) == FALSE);
5722 fail_unless (_mpd_helper_parse_duration ("PT-1M", &v) == FALSE);
5723 fail_unless (_mpd_helper_parse_duration ("PT65M", &v) == FALSE);
5724 fail_unless (_mpd_helper_parse_duration ("PT-1S", &v) == FALSE);
5725 /* seconds are allowed to be larger than 60 */
5726 fail_unless (_mpd_helper_parse_duration ("PT65S", &v) == TRUE);
5728 fail_unless (_mpd_helper_parse_duration ("PT1.1H", &v) == FALSE);
5729 fail_unless (_mpd_helper_parse_duration ("PT1-1H", &v) == FALSE);
5730 fail_unless (_mpd_helper_parse_duration ("PT1-H", &v) == FALSE);
5731 fail_unless (_mpd_helper_parse_duration ("PT-H", &v) == FALSE);
5732 fail_unless (_mpd_helper_parse_duration ("PTH", &v) == FALSE);
5733 fail_unless (_mpd_helper_parse_duration ("PT0", &v) == FALSE);
5734 fail_unless (_mpd_helper_parse_duration ("PT1.1S", &v) == TRUE);
5735 fail_unless (_mpd_helper_parse_duration ("PT1.1.1S", &v) == FALSE);
5737 fail_unless (_mpd_helper_parse_duration ("P585Y", &v) == FALSE);
5738 fail_unless (_mpd_helper_parse_duration ("P584Y", &v) == TRUE);
5740 fail_unless (_mpd_helper_parse_duration (" P10DT8H", &v) == TRUE);
5741 fail_unless (_mpd_helper_parse_duration ("P10D T8H", &v) == FALSE);
5742 fail_unless (_mpd_helper_parse_duration ("P10DT8H ", &v) == TRUE);
5748 * Test that the maximum_segment_duration correctly implements the
5749 * rules in the DASH specification
5751 GST_START_TEST (dash_mpdparser_maximum_segment_duration)
5753 const gchar *xml_template =
5754 "<?xml version=\"1.0\"?>"
5755 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5756 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5757 " availabilityStartTime=\"2015-03-24T0:0:0\""
5759 " mediaPresentationDuration=\"P100Y\">"
5760 " <Period id=\"Period0\" start=\"PT0S\">"
5761 " <AdaptationSet mimeType=\"video/mp4\" >"
5762 " <SegmentTemplate timescale=\"90000\" initialization=\"$RepresentationID$/Header.m4s\" media=\"$RepresentationID$/$Number$.m4s\" duration=\"360000\" />"
5763 " <Representation id=\"video1\" width=\"576\" height=\"324\" frameRate=\"25\" sar=\"1:1\" bandwidth=\"900000\" codecs=\"avc1.4D401E\"/>"
5765 " <AdaptationSet mimeType=\"audio/mp4\" >"
5766 " <SegmentTemplate timescale=\"90000\" initialization=\"$RepresentationID$/Header.m4s\" media=\"$RepresentationID$/$Number$.m4s\" duration=\"340000\" />"
5767 " <Representation id=\"audio1\" audioSamplingRate=\"22050\" bandwidth=\"29600\" codecs=\"mp4a.40.2\">"
5768 " <AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"2\"/>"
5769 " </Representation>" " </AdaptationSet>" " </Period></MPD>";
5771 GstMPDClient2 *mpdclient;
5774 GList *adapt_sets, *iter;
5776 xml = g_strdup_printf (xml_template, "maxSegmentDuration=\"PT4.5S\"");
5777 mpdclient = gst_mpd_client2_new ();
5778 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5780 assert_equals_int (ret, TRUE);
5782 assert_equals_uint64 (mpdclient->mpd_root_node->maxSegmentDuration,
5783 duration_to_ms (0, 0, 0, 0, 0, 4, 500));
5784 dur = gst_mpd_client2_get_maximum_segment_duration (mpdclient);
5785 assert_equals_uint64 (dur, duration_to_clocktime (0, 0, 0, 0, 0, 4, 500));
5786 gst_mpd_client2_free (mpdclient);
5788 /* now parse without the maxSegmentDuration attribute, to check that
5789 gst_mpd_client2_get_maximum_segment_duration uses the maximum
5790 duration of any segment
5792 xml = g_strdup_printf (xml_template, "");
5793 mpdclient = gst_mpd_client2_new ();
5794 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5796 assert_equals_int (ret, TRUE);
5798 gst_mpd_client2_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
5800 assert_equals_int (ret, TRUE);
5801 adapt_sets = gst_mpd_client2_get_adaptation_sets (mpdclient);
5802 for (iter = adapt_sets; iter; iter = g_list_next (iter)) {
5803 GstMPDAdaptationSetNode *adapt_set_node = iter->data;
5805 ret = gst_mpd_client2_setup_streaming (mpdclient, adapt_set_node);
5806 assert_equals_int (ret, TRUE);
5808 dur = gst_mpd_client2_get_maximum_segment_duration (mpdclient);
5809 assert_equals_uint64 (dur, duration_to_clocktime (0, 0, 0, 0, 0, 4, 0));
5810 gst_mpd_client2_free (mpdclient);
5816 * Test parsing xsd:datetime with timezoneoffset.
5819 GST_START_TEST (dash_mpdparser_datetime_with_tz_offset)
5821 GstDateTime *availabilityStartTime;
5822 GstDateTime *availabilityEndTime;
5824 "<?xml version=\"1.0\"?>"
5825 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5826 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5827 " schemaLocation=\"TestSchemaLocation\""
5828 " xmlns:xsi=\"TestNamespaceXSI\""
5829 " xmlns:ext=\"TestNamespaceEXT\""
5832 " availabilityStartTime=\"2015-03-24T1:10:50+08:00\""
5833 " availabilityEndTime=\"2015-03-24T1:10:50.123456-04:30\""
5834 " mediaPresentationDuration=\"P0Y1M2DT12H10M20.5S\""
5835 " minimumUpdatePeriod=\"P0Y1M2DT12H10M20.5S\""
5836 " minBufferTime=\"P0Y1M2DT12H10M20.5S\""
5837 " timeShiftBufferDepth=\"P0Y1M2DT12H10M20.5S\""
5838 " suggestedPresentationDelay=\"P0Y1M2DT12H10M20.5S\""
5839 " maxSegmentDuration=\"P0Y1M2DT12H10M20.5S\""
5840 " maxSubsegmentDuration=\"P0Y1M2DT12H10M20.5S\"></MPD>";
5843 GstMPDClient2 *mpdclient = gst_mpd_client2_new ();
5845 ret = gst_mpd_client2_parse (mpdclient, xml, (gint) strlen (xml));
5846 assert_equals_int (ret, TRUE);
5848 availabilityStartTime = mpdclient->mpd_root_node->availabilityStartTime;
5849 assert_equals_int (gst_date_time_get_year (availabilityStartTime), 2015);
5850 assert_equals_int (gst_date_time_get_month (availabilityStartTime), 3);
5851 assert_equals_int (gst_date_time_get_day (availabilityStartTime), 24);
5852 assert_equals_int (gst_date_time_get_hour (availabilityStartTime), 1);
5853 assert_equals_int (gst_date_time_get_minute (availabilityStartTime), 10);
5854 assert_equals_int (gst_date_time_get_second (availabilityStartTime), 50);
5855 assert_equals_int (gst_date_time_get_microsecond (availabilityStartTime), 0);
5856 assert_equals_float (gst_date_time_get_time_zone_offset
5857 (availabilityStartTime), 8.0);
5859 availabilityEndTime = mpdclient->mpd_root_node->availabilityEndTime;
5860 assert_equals_int (gst_date_time_get_year (availabilityEndTime), 2015);
5861 assert_equals_int (gst_date_time_get_month (availabilityEndTime), 3);
5862 assert_equals_int (gst_date_time_get_day (availabilityEndTime), 24);
5863 assert_equals_int (gst_date_time_get_hour (availabilityEndTime), 1);
5864 assert_equals_int (gst_date_time_get_minute (availabilityEndTime), 10);
5865 assert_equals_int (gst_date_time_get_second (availabilityEndTime), 50);
5866 assert_equals_int (gst_date_time_get_microsecond (availabilityEndTime),
5868 assert_equals_float (gst_date_time_get_time_zone_offset (availabilityEndTime),
5871 gst_mpd_client2_free (mpdclient);
5877 * Test generate xml content.
5880 GST_START_TEST (dash_mpdparser_check_mpd_xml_generator)
5883 "<?xml version=\"1.0\"?>"
5884 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
5885 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
5886 " schemaLocation=\"TestSchemaLocation\""
5887 " xmlns:xsi=\"TestNamespaceXSI\""
5888 " xmlns:ext=\"TestNamespaceEXT\""
5891 " availabilityStartTime=\"2015-03-24T1:10:50+08:00\""
5892 " availabilityEndTime=\"2015-03-24T1:10:50.123456-04:30\""
5893 " mediaPresentationDuration=\"P0Y1M2DT12H10M20.5S\""
5894 " minimumUpdatePeriod=\"P0Y1M2DT12H10M20.5S\""
5895 " minBufferTime=\"P0Y1M2DT12H10M20.5S\""
5896 " timeShiftBufferDepth=\"P0Y1M2DT12H10M20.5S\""
5897 " suggestedPresentationDelay=\"P0Y1M2DT12H10M20.5S\""
5898 " maxSegmentDuration=\"P0Y1M2DT12H10M20.5S\""
5899 " maxSubsegmentDuration=\"P0Y1M2DT12H10M20.5S\">"
5900 " <BaseURL serviceLocation=\"TestServiceLocation\""
5901 " byteRange=\"TestByteRange\">TestBaseURL</BaseURL>"
5902 " <Location>TestLocation</Location>"
5903 " <ProgramInformation lang=\"en\""
5904 " moreInformationURL=\"TestMoreInformationUrl\">"
5905 " <Title>TestTitle</Title>"
5906 " <Source>TestSource</Source>"
5907 " <Copyright>TestCopyright</Copyright>"
5908 " </ProgramInformation>"
5909 " <Metrics metrics=\"TestMetric\"><Range starttime=\"P0Y1M2DT12H10M20.5S\""
5910 " duration=\"P0Y1M2DT12H10M20.1234567S\">"
5911 " </Range></Metrics>"
5914 " <Representation id=\"1\" bandwidth=\"250000\">"
5915 " <SegmentTemplate duration=\"1\">"
5916 " </SegmentTemplate>"
5917 " </Representation></AdaptationSet></Period>" " </MPD>";
5922 GstMPDClient2 *first_mpdclient = NULL;
5923 GstMPDClient2 *second_mpdclient = NULL;
5924 GstMPDBaseURLNode *first_baseURL, *second_baseURL;
5925 GstMPDLocationNode *first_location, *second_location;
5926 GstMPDProgramInformationNode *first_prog_info, *second_prog_info;
5927 GstMPDMetricsNode *first_metrics, *second_metrics;
5928 GstMPDMetricsRangeNode *first_metrics_range, *second_metrics_range;
5930 first_mpdclient = gst_mpd_client2_new ();
5932 ret = gst_mpd_client2_parse (first_mpdclient, xml, (gint) strlen (xml));
5933 assert_equals_int (ret, TRUE);
5936 gst_mpd_client2_get_xml_content (first_mpdclient, &new_xml,
5938 assert_equals_int (ret, TRUE);
5940 second_mpdclient = gst_mpd_client2_new ();
5942 ret = gst_mpd_client2_parse (second_mpdclient, new_xml, new_xml_size);
5943 assert_equals_int (ret, TRUE);
5946 /* assert that parameters are equal */
5947 assert_equals_string (first_mpdclient->mpd_root_node->default_namespace,
5948 second_mpdclient->mpd_root_node->default_namespace);
5949 assert_equals_string (first_mpdclient->mpd_root_node->namespace_xsi,
5950 second_mpdclient->mpd_root_node->namespace_xsi);
5951 assert_equals_string (first_mpdclient->mpd_root_node->namespace_ext,
5952 second_mpdclient->mpd_root_node->namespace_ext);
5953 assert_equals_string (first_mpdclient->mpd_root_node->schemaLocation,
5954 second_mpdclient->mpd_root_node->schemaLocation);
5955 assert_equals_string (first_mpdclient->mpd_root_node->id,
5956 second_mpdclient->mpd_root_node->id);
5957 assert_equals_string (first_mpdclient->mpd_root_node->profiles,
5958 second_mpdclient->mpd_root_node->profiles);
5959 assert_equals_uint64 (first_mpdclient->
5960 mpd_root_node->mediaPresentationDuration,
5961 second_mpdclient->mpd_root_node->mediaPresentationDuration);
5962 assert_equals_uint64 (first_mpdclient->mpd_root_node->minimumUpdatePeriod,
5963 second_mpdclient->mpd_root_node->minimumUpdatePeriod);
5964 assert_equals_uint64 (first_mpdclient->mpd_root_node->minBufferTime,
5965 second_mpdclient->mpd_root_node->minBufferTime);
5966 assert_equals_uint64 (first_mpdclient->mpd_root_node->timeShiftBufferDepth,
5967 second_mpdclient->mpd_root_node->timeShiftBufferDepth);
5968 assert_equals_uint64 (first_mpdclient->
5969 mpd_root_node->suggestedPresentationDelay,
5970 second_mpdclient->mpd_root_node->suggestedPresentationDelay);
5971 assert_equals_uint64 (first_mpdclient->mpd_root_node->maxSegmentDuration,
5972 second_mpdclient->mpd_root_node->maxSegmentDuration);
5973 assert_equals_uint64 (first_mpdclient->mpd_root_node->maxSubsegmentDuration,
5974 second_mpdclient->mpd_root_node->maxSubsegmentDuration);
5978 (GstMPDBaseURLNode *) first_mpdclient->mpd_root_node->BaseURLs->data;
5980 (GstMPDBaseURLNode *) second_mpdclient->mpd_root_node->BaseURLs->data;
5981 assert_equals_string (first_baseURL->baseURL, second_baseURL->baseURL);
5982 assert_equals_string (first_baseURL->serviceLocation,
5983 second_baseURL->serviceLocation);
5984 assert_equals_string (first_baseURL->byteRange, second_baseURL->byteRange);
5988 (GstMPDLocationNode *) first_mpdclient->mpd_root_node->Locations->data;
5990 (GstMPDLocationNode *) second_mpdclient->mpd_root_node->Locations->data;
5991 assert_equals_string (first_location->location, second_location->location);
5993 /* ProgramInformation */
5995 (GstMPDProgramInformationNode *) first_mpdclient->mpd_root_node->
5998 (GstMPDProgramInformationNode *) second_mpdclient->mpd_root_node->
6000 assert_equals_string (first_prog_info->lang, second_prog_info->lang);
6001 assert_equals_string (first_prog_info->moreInformationURL,
6002 second_prog_info->moreInformationURL);
6003 assert_equals_string (first_prog_info->Title, second_prog_info->Title);
6004 assert_equals_string (first_prog_info->Source, second_prog_info->Source);
6005 assert_equals_string (first_prog_info->Copyright,
6006 second_prog_info->Copyright);
6010 (GstMPDMetricsNode *) first_mpdclient->mpd_root_node->Metrics->data;
6012 (GstMPDMetricsNode *) second_mpdclient->mpd_root_node->Metrics->data;
6013 assert_equals_string (first_metrics->metrics, second_metrics->metrics);
6016 first_metrics_range =
6017 (GstMPDMetricsRangeNode *) first_metrics->MetricsRanges->data;
6018 second_metrics_range =
6019 (GstMPDMetricsRangeNode *) second_metrics->MetricsRanges->data;
6020 assert_equals_uint64 (first_metrics_range->starttime,
6021 second_metrics_range->starttime);
6022 assert_equals_uint64 (first_metrics_range->duration,
6023 second_metrics_range->duration);
6025 gst_mpd_client2_free (first_mpdclient);
6026 gst_mpd_client2_free (second_mpdclient);
6032 * Test add mpd content with mpd_client set methods
6035 GST_START_TEST (dash_mpdparser_check_mpd_client_set_methods)
6038 "<?xml version=\"1.0\"?>"
6039 "<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
6040 " profiles=\"urn:mpeg:dash:profile:isoff-main:2011\""
6041 " schemaLocation=\"TestSchemaLocation\""
6042 " xmlns:xsi=\"TestNamespaceXSI\""
6043 " xmlns:ext=\"TestNamespaceEXT\""
6046 " availabilityStartTime=\"2015-03-24T1:10:50+08:00\""
6047 " availabilityEndTime=\"2015-03-24T1:10:50.123456-04:30\""
6048 " mediaPresentationDuration=\"P0Y1M2DT12H10M20.5S\""
6049 " minimumUpdatePeriod=\"P0Y1M2DT12H10M20.5S\""
6050 " minBufferTime=\"P0Y1M2DT12H10M20.5S\""
6051 " timeShiftBufferDepth=\"P0Y1M2DT12H10M20.5S\""
6052 " suggestedPresentationDelay=\"P0Y1M2DT12H10M20.5S\""
6053 " maxSegmentDuration=\"P0Y1M2DT12H10M20.5S\""
6054 " maxSubsegmentDuration=\"P0Y1M2DT12H10M20.5S\">"
6055 " <BaseURL serviceLocation=\"TestServiceLocation\""
6056 " byteRange=\"TestByteRange\">TestBaseURL</BaseURL>"
6057 " <Location>TestLocation</Location>"
6058 " <ProgramInformation lang=\"en\""
6059 " moreInformationURL=\"TestMoreInformationUrl\">"
6060 " <Title>TestTitle</Title>"
6061 " <Source>TestSource</Source>"
6062 " <Copyright>TestCopyright</Copyright>"
6063 " </ProgramInformation>"
6064 " <Metrics metrics=\"TestMetric\"><Range starttime=\"P0Y1M2DT12H10M20.5S\""
6065 " duration=\"P0Y1M2DT12H10M20.1234567S\">"
6066 " </Range></Metrics>"
6067 " <Period id=\"TestId\" start=\"PT1M\" duration=\"PT40S\""
6068 " bitstreamSwitching=\"true\">"
6069 " <AdaptationSet id=\"9\" contentType=\"video\" mimeType=\"video\">"
6070 " <Representation id=\"audio_1\" "
6071 " bandwidth=\"100\""
6072 " qualityRanking=\"200\""
6076 " audioSamplingRate=\"44100\""
6077 " mimeType=\"audio/mp4\">"
6078 " <SegmentList duration=\"15\" startNumber=\"11\">"
6079 " <SegmentURL media=\"segment001.ts\"></SegmentURL>"
6080 " <SegmentURL media=\"segment002.ts\"></SegmentURL>"
6082 " </Representation></AdaptationSet></Period>" " </MPD>";
6085 guint adaptation_set_id;
6086 gchar *representation_id;
6087 GstMPDClient2 *first_mpdclient = NULL;
6088 GstMPDClient2 *second_mpdclient = NULL;
6089 GstMPDBaseURLNode *first_baseURL, *second_baseURL;
6090 GstMPDPeriodNode *first_period, *second_period;
6091 GstMPDAdaptationSetNode *first_adap_set, *second_adap_set;
6092 GstMPDRepresentationNode *first_rep, *second_rep;
6093 GstMPDSegmentListNode *first_seg_list, *second_seg_list;
6094 GstMPDSegmentURLNode *first_seg_url, *second_seg_url;
6096 first_mpdclient = gst_mpd_client2_new ();
6098 ret = gst_mpd_client2_parse (first_mpdclient, xml, (gint) strlen (xml));
6099 assert_equals_int (ret, TRUE);
6101 second_mpdclient = gst_mpd_client2_new ();
6102 gst_mpd_client2_set_root_node (second_mpdclient,
6103 "default-namespace", "urn:mpeg:dash:schema:mpd:2011",
6104 "profiles", "urn:mpeg:dash:profile:isoff-main:2011",
6105 "schema-location", "TestSchemaLocation",
6106 "namespace-xsi", "TestNamespaceXSI",
6107 "namespace-ext", "TestNamespaceEXT", "id", "testId", NULL);
6108 gst_mpd_client2_add_baseurl_node (second_mpdclient,
6109 "url", "TestBaseURL",
6110 "service-location", "TestServiceLocation",
6111 "byte-range", "TestByteRange", NULL);
6112 period_id = gst_mpd_client2_set_period_node (second_mpdclient, (gchar *) "TestId", "start", (guint64) 60000, // ms
6113 "duration", (guint64) 40000, "bitstream-switching", 1, NULL);
6115 gst_mpd_client2_set_adaptation_set_node (second_mpdclient, period_id, 9,
6116 "content-type", "video", "mime-type", "video", NULL);
6119 gst_mpd_client2_set_representation_node (second_mpdclient, period_id,
6120 adaptation_set_id, (gchar *) "audio_1", "bandwidth", 100,
6121 "quality-ranking", 200, "mime-type", "audio/mp4", "width", 640, "height",
6122 480, "codecs", "avc1", "audio-sampling-rate", 44100, NULL);
6124 gst_mpd_client2_set_segment_list (second_mpdclient, period_id,
6125 adaptation_set_id, representation_id, "duration", 15, "start-number", 11,
6127 gst_mpd_client2_add_segment_url (second_mpdclient, period_id,
6128 adaptation_set_id, representation_id, "media", "segment001.ts", NULL);
6129 gst_mpd_client2_add_segment_url (second_mpdclient, period_id,
6130 adaptation_set_id, representation_id, "media", "segment002.ts", NULL);
6132 /* assert that parameters are equal */
6133 assert_equals_string (first_mpdclient->mpd_root_node->default_namespace,
6134 second_mpdclient->mpd_root_node->default_namespace);
6135 assert_equals_string (first_mpdclient->mpd_root_node->namespace_xsi,
6136 second_mpdclient->mpd_root_node->namespace_xsi);
6137 assert_equals_string (first_mpdclient->mpd_root_node->namespace_ext,
6138 second_mpdclient->mpd_root_node->namespace_ext);
6139 assert_equals_string (first_mpdclient->mpd_root_node->schemaLocation,
6140 second_mpdclient->mpd_root_node->schemaLocation);
6141 assert_equals_string (first_mpdclient->mpd_root_node->id,
6142 second_mpdclient->mpd_root_node->id);
6143 assert_equals_string (first_mpdclient->mpd_root_node->profiles,
6144 second_mpdclient->mpd_root_node->profiles);
6149 (GstMPDBaseURLNode *) first_mpdclient->mpd_root_node->BaseURLs->data;
6151 (GstMPDBaseURLNode *) second_mpdclient->mpd_root_node->BaseURLs->data;
6152 assert_equals_string (first_baseURL->baseURL, second_baseURL->baseURL);
6153 assert_equals_string (first_baseURL->serviceLocation,
6154 second_baseURL->serviceLocation);
6155 assert_equals_string (first_baseURL->byteRange, second_baseURL->byteRange);
6159 (GstMPDPeriodNode *) first_mpdclient->mpd_root_node->Periods->data;
6161 (GstMPDPeriodNode *) second_mpdclient->mpd_root_node->Periods->data;
6163 assert_equals_string (first_period->id, second_period->id);
6164 assert_equals_int64 (first_period->start, second_period->start);
6165 assert_equals_int64 (first_period->duration, second_period->duration);
6166 assert_equals_int (first_period->bitstreamSwitching,
6167 second_period->bitstreamSwitching);
6169 /* Adaptation set */
6171 (GstMPDAdaptationSetNode *) first_period->AdaptationSets->data;
6173 (GstMPDAdaptationSetNode *) second_period->AdaptationSets->data;
6175 assert_equals_int (first_adap_set->id, second_adap_set->id);
6176 assert_equals_string (first_adap_set->contentType,
6177 second_adap_set->contentType);
6178 assert_equals_string (GST_MPD_REPRESENTATION_BASE_NODE
6179 (first_adap_set)->mimeType,
6180 GST_MPD_REPRESENTATION_BASE_NODE (second_adap_set)->mimeType);
6182 /* Representation */
6184 (GstMPDRepresentationNode *) first_adap_set->Representations->data;
6186 (GstMPDRepresentationNode *) second_adap_set->Representations->data;
6187 assert_equals_string (first_rep->id, second_rep->id);
6188 assert_equals_int (first_rep->bandwidth, second_rep->bandwidth);
6189 assert_equals_int (first_rep->qualityRanking, second_rep->qualityRanking);
6190 assert_equals_string (GST_MPD_REPRESENTATION_BASE_NODE (first_rep)->mimeType,
6191 GST_MPD_REPRESENTATION_BASE_NODE (second_rep)->mimeType);
6193 assert_equals_int (GST_MPD_REPRESENTATION_BASE_NODE (first_rep)->width,
6194 GST_MPD_REPRESENTATION_BASE_NODE (second_rep)->width);
6196 assert_equals_int (GST_MPD_REPRESENTATION_BASE_NODE (first_rep)->height,
6197 GST_MPD_REPRESENTATION_BASE_NODE (second_rep)->height);
6199 assert_equals_string (GST_MPD_REPRESENTATION_BASE_NODE (first_rep)->codecs,
6200 GST_MPD_REPRESENTATION_BASE_NODE (second_rep)->codecs);
6202 assert_equals_string (GST_MPD_REPRESENTATION_BASE_NODE
6203 (first_rep)->audioSamplingRate,
6204 GST_MPD_REPRESENTATION_BASE_NODE (second_rep)->audioSamplingRate);
6207 first_seg_list = (GstMPDSegmentListNode *) first_rep->SegmentList;
6208 second_seg_list = (GstMPDSegmentListNode *) second_rep->SegmentList;
6209 assert_equals_int (GST_MPD_MULT_SEGMENT_BASE_NODE (first_seg_list)->duration,
6210 GST_MPD_MULT_SEGMENT_BASE_NODE (second_seg_list)->duration);
6211 assert_equals_int (GST_MPD_MULT_SEGMENT_BASE_NODE
6212 (first_seg_list)->startNumber,
6213 GST_MPD_MULT_SEGMENT_BASE_NODE (second_seg_list)->startNumber);
6215 first_seg_url = (GstMPDSegmentURLNode *) first_seg_list->SegmentURL->data;
6216 second_seg_url = (GstMPDSegmentURLNode *) second_seg_list->SegmentURL->data;
6218 assert_equals_string (first_seg_url->media, second_seg_url->media);
6221 gst_mpd_client2_free (first_mpdclient);
6222 gst_mpd_client2_free (second_mpdclient);
6228 * create a test suite containing all dash testcases
6233 Suite *s = suite_create ("dash");
6234 TCase *tc_simpleMPD = tcase_create ("simpleMPD");
6235 TCase *tc_complexMPD = tcase_create ("complexMPD");
6236 TCase *tc_negativeTests = tcase_create ("negativeTests");
6237 TCase *tc_stringTests = tcase_create ("stringTests");
6238 TCase *tc_duration = tcase_create ("duration");
6240 GST_DEBUG_CATEGORY_INIT (gst_dash_demux2_debug, "gst_dash_demux2_debug", 0,
6241 "mpeg dashdemux2 tests");
6243 /* test parsing the simplest possible mpd */
6244 tcase_add_test (tc_simpleMPD, dash_mpdparser_validsimplempd);
6246 /* test parsing the simplest possible mpd */
6247 tcase_add_test (tc_simpleMPD, dash_mpdparser_check_mpd_xml_generator);
6249 /* test mpd client set methods */
6250 tcase_add_test (tc_simpleMPD, dash_mpdparser_check_mpd_client_set_methods);
6252 /* tests parsing attributes from each element type */
6253 tcase_add_test (tc_simpleMPD, dash_mpdparser_mpd);
6254 tcase_add_test (tc_simpleMPD, dash_mpdparser_datetime_with_tz_offset);
6255 tcase_add_test (tc_simpleMPD, dash_mpdparser_programInformation);
6256 tcase_add_test (tc_simpleMPD, dash_mpdparser_baseURL);
6257 tcase_add_test (tc_simpleMPD, dash_mpdparser_location);
6258 tcase_add_test (tc_simpleMPD, dash_mpdparser_metrics);
6259 tcase_add_test (tc_simpleMPD, dash_mpdparser_metrics_range);
6260 tcase_add_test (tc_simpleMPD, dash_mpdparser_metrics_reporting);
6261 tcase_add_test (tc_simpleMPD, dash_mpdparser_period);
6262 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_baseURL);
6263 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_segmentBase);
6264 tcase_add_test (tc_simpleMPD,
6265 dash_mpdparser_period_segmentBase_initialization);
6266 tcase_add_test (tc_simpleMPD,
6267 dash_mpdparser_period_segmentBase_representationIndex);
6268 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_segmentList);
6269 tcase_add_test (tc_simpleMPD,
6270 dash_mpdparser_period_segmentList_multipleSegmentBaseType);
6271 tcase_add_test (tc_simpleMPD,
6272 dash_mpdparser_period_segmentList_multipleSegmentBaseType_segmentBaseType);
6273 tcase_add_test (tc_simpleMPD,
6274 dash_mpdparser_period_segmentList_multipleSegmentBaseType_segmentTimeline);
6275 tcase_add_test (tc_simpleMPD,
6276 dash_mpdparser_period_segmentList_multipleSegmentBaseType_segmentTimeline_s);
6277 tcase_add_test (tc_simpleMPD,
6278 dash_mpdparser_period_segmentList_multipleSegmentBaseType_bitstreamSwitching);
6279 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_segmentList_segmentURL);
6280 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_segmentTemplate);
6281 tcase_add_test (tc_simpleMPD,
6282 dash_mpdparser_period_segmentTemplateWithPresentationTimeOffset);
6283 tcase_add_test (tc_simpleMPD,
6284 dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType);
6285 tcase_add_test (tc_simpleMPD,
6286 dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_segmentBaseType);
6287 tcase_add_test (tc_simpleMPD,
6288 dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_segmentTimeline);
6289 tcase_add_test (tc_simpleMPD,
6290 dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_segmentTimeline_s);
6291 tcase_add_test (tc_simpleMPD,
6292 dash_mpdparser_period_segmentTemplate_multipleSegmentBaseType_bitstreamSwitching);
6293 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_adaptationSet);
6294 tcase_add_test (tc_simpleMPD,
6295 dash_mpdparser_period_adaptationSet_representationBase);
6296 tcase_add_test (tc_simpleMPD,
6297 dash_mpdparser_period_adaptationSet_representationBase_framePacking);
6298 tcase_add_test (tc_simpleMPD,
6299 dash_mpdparser_adapt_repr_segmentTemplate_inherit);
6300 tcase_add_test (tc_simpleMPD,
6301 dash_mpdparser_period_adaptationSet_representationBase_audioChannelConfiguration);
6302 tcase_add_test (tc_simpleMPD,
6303 dash_mpdparser_period_adaptationSet_representationBase_contentProtection);
6304 tcase_add_test (tc_simpleMPD, dash_mpdparser_contentProtection_no_value);
6305 tcase_add_test (tc_simpleMPD,
6306 dash_mpdparser_contentProtection_no_value_no_encoding);
6307 tcase_add_test (tc_simpleMPD,
6308 dash_mpdparser_period_adaptationSet_accessibility);
6309 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_adaptationSet_role);
6310 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_adaptationSet_rating);
6311 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_adaptationSet_viewpoint);
6312 tcase_add_test (tc_simpleMPD,
6313 dash_mpdparser_period_adaptationSet_contentComponent);
6314 tcase_add_test (tc_simpleMPD,
6315 dash_mpdparser_period_adaptationSet_contentComponent_accessibility);
6316 tcase_add_test (tc_simpleMPD,
6317 dash_mpdparser_period_adaptationSet_contentComponent_role);
6318 tcase_add_test (tc_simpleMPD,
6319 dash_mpdparser_period_adaptationSet_contentComponent_rating);
6320 tcase_add_test (tc_simpleMPD,
6321 dash_mpdparser_period_adaptationSet_contentComponent_viewpoint);
6322 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_adaptationSet_baseURL);
6323 tcase_add_test (tc_simpleMPD,
6324 dash_mpdparser_period_adaptationSet_segmentBase);
6325 tcase_add_test (tc_simpleMPD,
6326 dash_mpdparser_period_adaptationSet_segmentBase_initialization);
6327 tcase_add_test (tc_simpleMPD,
6328 dash_mpdparser_period_adaptationSet_segmentBase_representationIndex);
6329 tcase_add_test (tc_simpleMPD,
6330 dash_mpdparser_period_adaptationSet_segmentList);
6331 tcase_add_test (tc_simpleMPD,
6332 dash_mpdparser_period_adaptationSet_segmentTemplate);
6333 tcase_add_test (tc_simpleMPD,
6334 dash_mpdparser_period_adaptationSet_segmentTemplate_inherit);
6335 tcase_add_test (tc_simpleMPD,
6336 dash_mpdparser_period_adaptationSet_representation);
6337 tcase_add_test (tc_simpleMPD,
6338 dash_mpdparser_period_adaptationSet_representation_representationBase);
6339 tcase_add_test (tc_simpleMPD,
6340 dash_mpdparser_period_adaptationSet_representation_baseURL);
6341 tcase_add_test (tc_simpleMPD,
6342 dash_mpdparser_period_adaptationSet_representation_subRepresentation);
6343 tcase_add_test (tc_simpleMPD,
6344 dash_mpdparser_period_adaptationSet_representation_subRepresentation_representationBase);
6345 tcase_add_test (tc_simpleMPD,
6346 dash_mpdparser_period_adaptationSet_representation_segmentBase);
6347 tcase_add_test (tc_simpleMPD,
6348 dash_mpdparser_period_adaptationSet_representation_segmentList);
6349 tcase_add_test (tc_simpleMPD,
6350 dash_mpdparser_period_adaptationSet_representation_segmentTemplate);
6351 tcase_add_test (tc_simpleMPD,
6352 dash_mpdparser_period_adaptationSet_representation_segmentTemplate_inherit);
6353 tcase_add_test (tc_simpleMPD,
6354 dash_mpdparser_period_adaptationSet_representation_segmentBase_inherit);
6355 tcase_add_test (tc_simpleMPD, dash_mpdparser_period_subset);
6356 tcase_add_test (tc_simpleMPD, dash_mpdparser_utctiming);
6357 tcase_add_test (tc_simpleMPD, dash_mpdparser_utctiming_invalid_value);
6359 /* tests checking other possible values for attributes */
6360 tcase_add_test (tc_simpleMPD, dash_mpdparser_type_dynamic);
6361 tcase_add_test (tc_simpleMPD, dash_mpdparser_template_parsing);
6362 tcase_add_test (tc_simpleMPD, dash_mpdparser_isoff_ondemand_profile);
6363 tcase_add_test (tc_simpleMPD, dash_mpdparser_GstDateTime);
6364 tcase_add_test (tc_simpleMPD, dash_mpdparser_bitstreamSwitching_inheritance);
6365 tcase_add_test (tc_simpleMPD, dash_mpdparser_various_duration_formats);
6366 tcase_add_test (tc_simpleMPD, dash_mpdparser_default_presentation_delay);
6368 /* tests checking the MPD management
6369 * (eg. setting active streams, obtaining attributes values)
6371 tcase_add_test (tc_complexMPD, dash_mpdparser_setup_media_presentation);
6372 tcase_add_test (tc_complexMPD, dash_mpdparser_setup_streaming);
6373 tcase_add_test (tc_complexMPD, dash_mpdparser_period_selection);
6374 tcase_add_test (tc_complexMPD, dash_mpdparser_get_period_at_time);
6375 tcase_add_test (tc_complexMPD, dash_mpdparser_adaptationSet_handling);
6376 tcase_add_test (tc_complexMPD, dash_mpdparser_representation_selection);
6377 tcase_add_test (tc_complexMPD, dash_mpdparser_multipleSegmentURL);
6378 tcase_add_test (tc_complexMPD, dash_mpdparser_activeStream_selection);
6379 tcase_add_test (tc_complexMPD, dash_mpdparser_activeStream_parameters);
6380 tcase_add_test (tc_complexMPD, dash_mpdparser_get_audio_languages);
6381 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL1);
6382 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL2);
6383 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL3);
6384 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL4);
6385 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL5);
6386 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL6);
6387 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL7);
6388 tcase_add_test (tc_complexMPD, dash_mpdparser_get_baseURL8);
6389 tcase_add_test (tc_complexMPD, dash_mpdparser_get_mediaPresentationDuration);
6390 tcase_add_test (tc_complexMPD, dash_mpdparser_get_streamPresentationOffset);
6391 tcase_add_test (tc_complexMPD, dash_mpdparser_segments);
6392 tcase_add_test (tc_complexMPD, dash_mpdparser_headers);
6393 tcase_add_test (tc_complexMPD, dash_mpdparser_fragments);
6394 tcase_add_test (tc_complexMPD, dash_mpdparser_inherited_segmentBase);
6395 tcase_add_test (tc_complexMPD, dash_mpdparser_inherited_segmentURL);
6396 tcase_add_test (tc_complexMPD, dash_mpdparser_segment_list);
6397 tcase_add_test (tc_complexMPD, dash_mpdparser_segment_template);
6398 tcase_add_test (tc_complexMPD, dash_mpdparser_segment_timeline);
6399 tcase_add_test (tc_complexMPD, dash_mpdparser_multiple_inherited_segmentURL);
6401 /* tests checking the parsing of missing/incomplete attributes of xml */
6402 tcase_add_test (tc_negativeTests, dash_mpdparser_missing_xml);
6403 tcase_add_test (tc_negativeTests, dash_mpdparser_missing_mpd);
6404 tcase_add_test (tc_negativeTests, dash_mpdparser_no_end_tag);
6405 tcase_add_test (tc_negativeTests, dash_mpdparser_no_profiles);
6406 tcase_add_test (tc_negativeTests, dash_mpdparser_no_default_namespace);
6407 tcase_add_test (tc_negativeTests,
6408 dash_mpdparser_wrong_period_duration_inferred_from_next_period);
6409 tcase_add_test (tc_negativeTests,
6410 dash_mpdparser_wrong_period_duration_inferred_from_next_mediaPresentationDuration);
6411 tcase_add_test (tc_negativeTests, dash_mpdparser_negative_period_duration);
6412 tcase_add_test (tc_negativeTests,
6413 dash_mpdparser_read_unsigned_from_negative_values);
6414 tcase_add_test (tc_negativeTests,
6415 dash_mpdparser_negative_mediaPresentationDuration);
6416 tcase_add_test (tc_negativeTests,
6417 dash_mpdparser_unmatched_segmentTimeline_segmentURL);
6419 tcase_add_test (tc_stringTests, dash_mpdparser_whitespace_strings);
6420 tcase_add_test (tc_stringTests, dash_mpdparser_rfc1738_strings);
6422 tcase_add_test (tc_duration, dash_mpdparser_duration);
6423 tcase_add_test (tc_duration, dash_mpdparser_maximum_segment_duration);
6425 suite_add_tcase (s, tc_simpleMPD);
6426 suite_add_tcase (s, tc_complexMPD);
6427 suite_add_tcase (s, tc_negativeTests);
6428 suite_add_tcase (s, tc_stringTests);
6429 suite_add_tcase (s, tc_duration);
6434 GST_CHECK_MAIN (dash);