dashdemux: segment template parsing: added support for %d

Added support for %d in template identifier.
Added testcases for %d, %3d, %0-4d identifier formats.
This commit is contained in:
Florin Apostol 2015-09-09 12:36:10 +01:00 committed by Vincent Penquerc'h
parent 933d367440
commit 4eea6c3833
2 changed files with 12 additions and 6 deletions

View file

@ -2968,16 +2968,19 @@ validate_format (const gchar * format)
return FALSE;
p++;
/* Following the % must be a 0, or any of d, x or u.
/* the spec mandates a format like %0[width]d
But we also accept %d, because it doesn't hurt us
*/
/* Following the %, if we have a number, it must start with 0 */
if (g_ascii_isdigit (p[0]) && p[0] != '0')
return FALSE;
/* Following the % must be a number, or any of d, x or u.
* x and u are not part of the spec, but don't hurt us
*/
if (p[0] == '0') {
while (g_ascii_isdigit (*p))
p++;
while (g_ascii_isdigit (*p))
p++;
}
/* After any 0 and alphanumeric values, there must be
* an d, x or u.
*/

View file

@ -2488,10 +2488,13 @@ GST_START_TEST (dash_mpdparser_template_parsing)
{"TestMedia$Bandwidth$$$test", "TestMedia2500$test"}, /* Bandwidth identifier */
{"TestMedia$Time$", "TestMedia100"}, /* Time identifier */
{"TestMedia$Time", NULL}, /* Identifier not finished with $ */
{"Time$Time%d$", "Time100"}, /* usage of %d (no width) */
{"Time$Time%0d$", "Time100"}, /* usage of format smaller than number of digits */
{"Time$Time%01d$", "Time100"}, /* usage of format smaller than number of digits */
{"Time$Time%05d$", "Time00100"}, /* usage of format bigger than number of digits */
{"Time$Time%05dtest$", "Time00100test"}, /* usage extra text in format */
{"Time$Time%3d$", NULL}, /* incorrect format: width does not start with 0 */
{"Time$Time%0-4d$", NULL}, /* incorrect format: width is not a number */
{"Time$Time%0$", NULL}, /* incorrect format: no d, x or u */
{"Time$Time1%01d$", NULL}, /* incorrect format: does not start with % after identifier */
{"$Bandwidth%/init.mp4v", NULL}, /* incorrect identifier: not finished with $ */