-
Notifications
You must be signed in to change notification settings - Fork 4
/
HbbTV_DVB_MPDValidation.php
executable file
·2067 lines (1833 loc) · 136 KB
/
HbbTV_DVB_MPDValidation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$period_count = 0;
$adapt_video_count = 0;
$adapt_audio_count = 0;
$main_audios = array();
$main_audio_found = false;
$main_video_found = false;
$hoh_subtitle_lang = array();
$video_bw = array();
$audio_bw = array();
$subtitle_bw = array();
$associativity = array();
function HbbTV_DVB_mpdvalidator() {
global $session_dir, $mpd_log, $hbbtv_conformance, $dvb_conformance, $mpd_xml, $mpd_xml_report;
$mpdreport = open_file($session_dir . '/' . $mpd_log . '.txt', 'a+b');
if(!$mpdreport)
return;
## Report on profile-specific media types' completeness
DVB_HbbTV_profile_specific_media_types_report($mpdreport);
## Informational cross-profile check
DVB_HbbTV_cross_profile_check($mpdreport);
if($dvb_conformance){
DVB_mpdvalidator($mpdreport);
DVB_mpd_anchor_check($mpdreport);
}
if($hbbtv_conformance){
HbbTV_mpdvalidator($mpdreport);
}
fclose($mpdreport);
## Return 'warning' or 'error' to the mpdprocessing part.
$returnValue="true";
$mpdreportText=file_get_contents($session_dir . '/' . $mpd_log . '.txt');
if(strpos($mpdreportText, '###')!=FALSE)
$returnValue="error";
elseif(strpos($mpdreportText, 'Warning')!=FALSE)
$returnValue="warning";
$mpd_xml = simplexml_load_file($session_dir . '/' . $mpd_xml_report);
$mpd_xml->hbbtv_dvb = $returnValue;
$mpd_xml->asXml($session_dir . '/' . $mpd_xml_report);
return $returnValue;
}
function DVB_HbbTV_profile_specific_media_types_report($mpdreport){
global $mpd_dom, $dvb_conformance, $hbbtv_conformance;
$mpd_profiles = $mpd_dom->getAttribute('profiles');
if($dvb_conformance && (strpos($mpd_dom->getAttribute('profiles'), 'urn:dvb:dash:profile:dvb-dash:2014') === FALSE && strpos($mpd_dom->getAttribute('profiles'), 'urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014') === FALSE && strpos($mpd_dom->getAttribute('profiles'), 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014') === FALSE))
$mpd_profiles .= ',urn:dvb:dash:profile:dvb-dash:2014';
if($hbbtv_conformance && strpos($mpd_dom->getAttribute('profiles'), 'urn:hbbtv:dash:profile:isoff-live:2012') === FALSE)
$mpd_profiles .= ',urn:hbbtv:dash:profile:isoff-live:2012';
$profiles_arr = explode(',', $mpd_profiles);
if(sizeof($profiles_arr) > 1){
## Generate the profile-specific MPDs
foreach($profiles_arr as $profile){
$domDocument = new DOMDocument('1.0');
$domElement = $domDocument->createElement('MPD');
$domElement = $mpd_dom->cloneNode();
$domElement->setAttribute('profiles', $profile);
$domElement = recursive_generate($mpd_dom, $domDocument, $domElement, $profile);
$domDocument->appendChild($domDocument->importNode($domElement, true));
$profile_specific_MPDs[] = $domDocument;
}
## Compare each profile-specific MPD with the original MPD
$mpd_media_types = media_types($mpd_dom);
$ind = 0;
foreach($profile_specific_MPDs as $profile_specific_MPD){
$mpd_media_types_new = media_types($profile_specific_MPD->getElementsByTagName('MPD')->item(0));
$str = '';
foreach($mpd_media_types as $mpd_media_type){
if(!in_array($mpd_media_type, $mpd_media_types_new))
$str = $str . " $mpd_media_type";
}
if($str != '')
fwrite($mpdreport, "###HbbTV-DVB DASH Validation Requirements Conformance violated: Section 'MPD' - media type:$str is missing after the provided MPD is processed for profile: " . $profiles_arr[$ind] . ".\n");
$ind++;
}
}
}
function recursive_generate($node, &$domDocument, &$domElement, $profile){
foreach($node->childNodes as $child){
if($child->nodeType == XML_ELEMENT_NODE){
if($child->getAttribute('profiles') == '' || strpos($child->getAttribute('profiles'), $profile) !== FALSE){
$domchild = $domDocument->createElement($child->nodeName);
$domchild = $child->cloneNode();
$domchild = recursive_generate($child, $domDocument, $domchild, $profile);
$domElement->appendChild($domchild);
}
}
}
return $domElement;
}
function media_types($MPD){
$media_types = array();
$adapts = $MPD->getElementsByTagName('AdaptationSet');
$reps = $MPD->getElementsByTagName('Representation');
$subreps = $MPD->getElementsByTagName('SubRepresentation');
if($adapts->length != 0){
for($i=0; $i<$adapts->length; $i++){
$adapt = $adapts->item($i);
$adapt_contentType = $adapt->getAttribute('contentType');
$adapt_mimeType = $adapt->getAttribute('mimeType');
if($adapt_contentType == 'video' || strpos($adapt_mimeType, 'video') !== FALSE){
$media_types[] = 'video';
}
if($adapt_contentType == 'audio' || strpos($adapt_mimeType, 'audio') !== FALSE){
$media_types[] = 'audio';
}
if($adapt_contentType == 'text' || strpos($adapt_mimeType, 'application') !== FALSE){
$media_types[] = 'subtitle';
}
$contentcomps = $adapt->getElementsByTagName('ContentComponent');
foreach($contentcomps as $contentcomp){
$contentcomp_contentType = $contentcomp->getAttribute('contentType');
if($contentcomp_contentType == 'video'){
$media_types[] = 'video';
}
if($contentcomp_contentType == 'audio'){
$media_types[] = 'audio';
}
if($contentcomp_contentType == 'text'){
$media_types[] = 'subtitle';
}
}
}
}
if($reps->length != 0){
for($i=0; $i<$reps->length; $i++){
$rep = $reps->item($i);
$rep_mimeType = $rep->getAttribute('mimeType');
if(strpos($rep_mimeType, 'video') !== FALSE){
$media_types[] = 'video';
}
if(strpos($rep_mimeType, 'audio') !== FALSE){
$media_types[] = 'audio';
}
if(strpos($rep_mimeType, 'application') !== FALSE){
$media_types[] = 'subtitle';
}
}
}
if($subreps->length != 0){
for($i=0; $i<$subreps->length; $i++){
$subrep = $subreps->item($i);
$subrep_mimeType = $subrep->getAttribute('mimeType');
if(strpos($subrep_mimeType, 'video') !== FALSE){
$media_types[] = 'video';
}
if(strpos($subrep_mimeType, 'audio') !== FALSE){
$media_types[] = 'audio';
}
if(strpos($subrep_mimeType, 'application') !== FALSE){
$media_types[] = 'subtitle';
}
}
}
return array_unique($media_types);
}
function DVB_HbbTV_cross_profile_check($mpdreport){
global $mpd_dom;
$profiles = $mpd_dom->getAttribute('profiles');
$supported_profiles = array('urn:mpeg:dash:profile:isoff-on-demand:2011', 'urn:mpeg:dash:profile:isoff-live:2011',
'urn:mpeg:dash:profile:isoff-main:2011', 'http://dashif.org/guidelines/dash264',
'urn:dvb:dash:profile:dvb-dash:2014', 'urn:hbbtv:dash:profile:isoff-live:2012',
'urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014', 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014');
$profiles_arr = explode(',', $profiles);
foreach($profiles_arr as $profile){
$profile_found = false;
foreach($supported_profiles as $supported_profile){
if(strpos($profile, $supported_profile) !== FALSE)
$profile_found = true;
}
if(!$profile_found)
fwrite($mpdreport, "Information on HbbTV-DVB DASH Validation Requirements conformance: Section 'MPD' - MPD element is scoped by the profile \"$profile\" that the tool is not validating against.\n");
}
}
# // Previous MPD check (6) where the elements that are not used in MPD-level HbbTV profile validation
#function DVB_HbbTV_cross_profile_check($dom, $mpdreport){
# // All the elements here for cross-profile checks exist in DVB but not in HbbTV
# $MPD = $dom->getElementsByTagName('MPD')->item(0);
#
# $BaseURLs = $MPD->getElementsByTagName('BaseURL');
# if($BaseURLs->length != 0)
# fwrite($mpdreport, "Information on DVB-HbbTV conformance: BaseURL element is found in the MPD. This element is scoped by DVB profile that the tool is not validating against.\n");
#
# if($MPD->getAttribute('type') == 'dynamic' || $MPD->getAttribute('availabilityStartTime') != ''){
# $UTCTimings = $MPD->getElementsByTagName('UTCTiming');
# if($UTCTimings->length != 0)
# fwrite($mpdreport, "Information on DVB-HbbTV conformance: UTCTiming element is found in the MPD. This element is scoped by DVB profile that the tool is not validating against.\n");
# }
#
# $periods = $MPD->getElementsByTagName('Period');
# foreach($periods as $period){
# foreach($period->childNodes as $child){
# if($child->nodeName == 'EventStream'){
# fwrite($mpdreport, "Information on DVB-HbbTV conformance: EventStream element is found in the MPD. This element is scoped by DVB profile that the tool is not validating against.\n");
#
# foreach($child->childNodes as $ch){
# if($ch->nodeName == 'Event')
# fwrite($mpdreport, "Information on DVB-HbbTV conformance: Event element is found in the MPD. This element is scoped by DVB profile that the tool is not validating against.\n");
# }
# }
# }
# }
#}
function DVB_mpdvalidator($mpdreport){
global $adapt_video_count, $adapt_audio_count, $main_audio_found, $main_audios, $hoh_subtitle_lang, $period_count,
$audio_bw, $video_bw, $subtitle_bw, $supported_profiles, $mpd_dom, $mpd_url;
global $onRequest_array, $xlink_not_valid_array;
if(!empty($onRequest_array)){
$onRequest_k_v = implode(', ', array_map(
function ($v, $k) { return sprintf(" %s with index (starting from 0) '%s'", $v, $k); },
$onRequest_array,array_keys($onRequest_array)));
fwrite($mpdreport, "###'HbbTV-DVB DASH Validation Requirements check violated for DVB: Section 'xlink' - MPD SHALL NOT have xlink:actuate set to onRequest', found in".$onRequest_k_v."\n");
}
if(!empty($xlink_not_valid_array)){
$xlink_not_valid_k_v = implode(', ', array_map(
function ($v, $k) { return sprintf(" %s with index (starting from 0) '%s'", $v, $k); },
$xlink_not_valid_array,array_keys($xlink_not_valid_array)));
fwrite($mpdreport, "###'HbbTV-DVB DASH Validation Requirements check violated for DVB: Section 'xlink' - MPD invalid xlink:href', found in:".$xlink_not_valid_k_v."\n");
}
TLS_bitrate_check($mpdreport);
$mpd_doc = get_doc($mpd_url);
$mpd_string = $mpd_doc->saveXML();
$mpd_bytes = strlen($mpd_string);
if($mpd_bytes > 256*1024){
fwrite($mpdreport, "###'DVB check violated: Section 4.5- The MPD size after xlink resolution SHALL NOT exceed 256 Kbytes', found " . ($mpd_bytes/1024) . " Kbytes.\n");
}
## Warn on low values of MPD@minimumUpdatePeriod (for now the lowest possible value is assumed to be 1 second)
if($mpd_dom->getAttribute('minimumUpdatePeriod') != ''){
$mup = time_parsing($mpd_dom->getAttribute('minimumUpdatePeriod'));
if($mup < 1)
fwrite($mpdreport, "Warning for HbbTV-DVB DASH Validation Requirements check for DVB: Section 'MPD' - 'MPD@minimumUpdatePeriod has a lower value than 1 second.\n");
}
##
## Information from this part is used for Section 4.1 and 11.1 checks
$profiles = $mpd_dom->getAttribute('profiles');
if(strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:2014') === FALSE && strpos($profiles, 'urn:hbbtv:dash:profile:isoff-live:2012') === FALSE)
fwrite($mpdreport, "###'DVB check violated: Section E.2.1- The MPD SHALL indicate either or both of the following profiles: \"urn:dvb:dash:profile:dvb-dash:2014\" and \"urn:hbbtv:dash:profile:isoff-live:2012\"', specified profile could not be found.\n");
$profile_exists = false;
if(strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:2014') === FALSE && (strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014') === FALSE || strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014') === FALSE))
fwrite($mpdreport, "Warning for DVB check: Section 11.1- 'All Representations that are intended to be decoded and presented by a DVB conformant Player SHOULD be such that they will be inferred to have an @profiles attribute that includes the profile name defined in clause 4.1 as well as either the one defined in 4.2.5 or the one defined in 4.2.8', found profiles: $profiles.\n");
elseif(strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:2014') === TRUE && (strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014') === TRUE || strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014') === TRUE))
$profile_exists = true;
##
## Information from this part is used for Section 11.9.5: relative url warning
$BaseURLs = $mpd_dom->getElementsByTagName('BaseURL');
foreach ($BaseURLs as $BaseURL){
if(!isAbsoluteURL($BaseURL->nodeValue)){
if($BaseURL->getAttribute('serviceLocation') != '' && $BaseURL->getAttribute('priority') != '' && $BaseURL->getAttribute('weight') != '')
fwrite($mpdreport, "Warning for DVB check: Section 11.9.5- 'Where BaseURLs contain relative URLs, these SHOULD NOT include @serviceLocation, @priority or @weight attributes', however found in this MPD.\n");
}
}
##
## Verifying the DVB Metric reporting mechanism according to Section 10.12.3
$metrics = $mpd_dom->getElementsByTagName('Metrics');
if($metrics->length != 0){
foreach($metrics as $metric){
$reportings = $metric->getElementsByTagName('Reporting');
if($reportings->length != 0){
foreach($reportings as $reporting){
if($reporting->getAttribute('schemeIdUri') == 'urn:dvb:dash:reporting:2014' && $reporting->getAttribute('value') == 1){
if($reporting->getAttribute('reportingUrl') == '' && $reporting->getAttribute('dvb:reportingUrl') == '')
fwrite($mpdreport, "Information on DVB conformance: Section 10.12.3 - Where DVB Metric reporting mechanism is indicated in a Reporting descriptor, it SHALL have the @reportingUrl attribute.\n");
else{
if(!isAbsoluteURL($reporting->getAttribute('reportingUrl')) && !isAbsoluteURL($reporting->getAttribute('dvb:reportingUrl')))
fwrite($mpdreport, "Information on DVB conformance: Section 10.12.3 - value of the @reportingUrl attribute in the Reporting descriptor needs to be and absolute HTTP or HTTPS URL.\n");
}
if($reporting->getAttribute('probability') != ''){
$probability = $reporting->getAttribute('probability');
if(!(((string) (int) $probability === $probability) && ($probability <= 1000) && ($probability >= 1)))
fwrite($mpdreport, "Information on DVB conformance: Section 10.12.3 - value of the @probability attribute in the Reporting descriptor needs to be a positive integer between 0 and 1000.\n");
}
if($reporting->getAttribute('dvb:probability') != ''){
$probability = $reporting->getAttribute('dvb:probability');
if(!(((string) (int) $probability === $probability) && ($probability <= 1000) && ($probability >= 1)))
fwrite($mpdreport, "Information on DVB conformance: Section 10.12.3 - value of the @probability attribute in the Reporting descriptor needs to be a positive integer between 0 and 1000.\n");
}
}
}
}
}
}
##
$cenc = $mpd_dom->getAttribute('xmlns:cenc');
// Periods within MPD
$period_count = 0;
$video_service = false;
$type = $mpd_dom->getAttribute('type');
$AST = $mpd_dom->getAttribute('availabilityStartTime');
if($type == 'dynamic' || $AST != ''){
$UTCTimings = $mpd_dom->getElementsByTagName('UTCTiming');
$acceptedTimingURIs = array('urn:mpeg:dash:utc:ntp:2014',
'urn:mpeg:dash:utc:http-head:2014',
'urn:mpeg:dash:utc:http-xsdate:2014',
'urn:mpeg:dash:utc:http-iso:2014',
'urn:mpeg:dash:utc:http-ntp:2014');
$utc_info = '';
if($UTCTimings->length == 0)
fwrite($mpdreport, "Warning for DVB check: Section 4.7.2- 'If the MPD is dynamic or if the MPD@availabilityStartTime is present then the MPD SHOULD countain at least one UTCTiming element with the @schemeIdUri attribute set to one of the following: ".join(', ', $acceptedTimingURIs)." ', UTCTiming element could not be found in the provided MPD.\n");
else{
foreach($UTCTimings as $UTCTiming){
if(!(in_array($UTCTiming->getAttribute('schemeIdUri'), $acceptedTimingURIs)))
$utc_info .= 'wrong ';
}
if($utc_info != '')
fwrite($mpdreport, "Warning for DVB check: Section 4.7.2- 'If the MPD is dynamic or if the MPD@availabilityStartTime is present then the MPD SHOULD countain at least one UTCTiming element with the @schemeIdUri attribute set to one of the following: ".join(', ', $acceptedTimingURIs)." ', could not be found in the provided MPD.\n");
}
}
foreach($mpd_dom->childNodes as $node){
if($node->nodeName == 'Period'){
$period_count++;
$adapt_video_count = 0;
$main_video_found = false;
$main_audio_found = false;
foreach ($node->childNodes as $child){
if($child->nodeName == 'SegmentList')
fwrite($mpdreport, "###'DVB check violated: Section 4.2.2- The Period.SegmentList SHALL not be present', but found in Period $period_count.\n");
if($child->nodeName == 'EventStream'){
DVB_event_checks($child, $mpdreport);
}
if($child->nodename == 'SegmentTemplate'){
if(strpos($profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014') === TRUE)
fwrite($mpdreport, "###'DVB check violated: Section 4.2.6- The Period.SegmentTemplate SHALL not be present for Period elements conforming to On Demand profile', but found in Period $period_count.\n");
}
}
// Adaptation Sets within each Period
$adapts = $node->getElementsByTagName('AdaptationSet');
$adapts_len = $adapts->length;
if($adapts_len > 16)
fwrite($mpdreport, "###'DVB check violated: Section 4.5- The MPD has a maximum of 16 adaptation sets per period', found $adapts_len in Period $period_count.\n");
$audio_adapts = array();
for($i=0; $i<$adapts_len; $i++){
$adapt = $adapts->item($i);
$video_found = false;
$audio_found = false;
$adapt_profile_exists = false;
$adapt_profiles = $adapt->getAttribute('profiles');
if($profile_exists && $adapt_profiles != ''){
if(strpos($adapt_profiles, 'urn:dvb:dash:profile:dvb-dash:2014') === FALSE && (strpos($adapt_profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014') === FALSE || strpos($adapt_profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014') === FALSE))
fwrite($mpdreport, "Warning for DVB check: Section 11.1- 'All Representations that are intended to be decoded and presented by a DVB conformant Player SHOULD be such that they will be inferred to have an @profiles attribute that includes the profile name defined in clause 4.1 as well as either the one defined in 4.2.5 or the one defined in 4.2.8', found profiles: $adapt_profiles.\n");
else
$adapt_profile_exists = true;
}
$reps = $adapt->getElementsByTagName('Representation');
$reps_len = $reps->length;
if($reps_len > 16)
fwrite($mpdreport, "###'DVB check violated: Section 4.5- The MPD has a maximum of 16 representations per adaptation set', found $reps_len in Period $period_count Adaptation Set " . ($i+1) . ".\n");
$contentTemp_vid_found = false;
$contentTemp_aud_found = false;
foreach ($adapt->childNodes as $ch){
if($ch->nodeName == 'ContentComponent'){
if($ch->getAttribute('contentType') == 'video')
$contentTemp_vid_found = true;
if($ch->getAttribute('contentType') == 'audio')
$contentTemp_aud_found = true;
}
if($ch->nodeName == 'Representation'){
if($profile_exists && ($adapt_profiles == '' || $adapt_profile_exists)){
$rep_profile_exists = false;
$rep_profiles = $ch->getAttribute('profiles');
if($rep_profiles != ''){
if(strpos($rep_profiles, 'urn:dvb:dash:profile:dvb-dash:2014') === FALSE && (strpos($rep_profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014') === FALSE || strpos($rep_profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014') === FALSE))
fwrite($mpdreport, "Warning for DVB check: Section 11.1- 'All Representations that are intended to be decoded and presented by a DVB conformant Player SHOULD be such that they will be inferred to have an @profiles attribute that includes the profile name defined in clause 4.1 as well as either the one defined in 4.2.5 or the one defined in 4.2.8', found profiles: $rep_profiles.\n");
else
$rep_profile_exists = true;
}
}
if(strpos($ch->getAttribute('mimeType'), 'video') !== FALSE)
$video_found = true;
if(strpos($ch->getAttribute('mimeType'), 'audio') !== FALSE)
$audio_found = true;
if($profile_exists && ($adapt_profiles == '' || $adapt_profile_exists) && ($rep_profiles == '' || $rep_profile_exists)){
foreach($ch->childNodes as $c){
if($c->nodeName == 'SubRepresentation'){
$subrep_profiles = $c->getAttribute('profiles');
if($subrep_profiles != ''){
if(strpos($subrep_profiles, 'urn:dvb:dash:profile:dvb-dash:2014') === FALSE && (strpos($subrep_profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014') === FALSE || strpos($subrep_profiles, 'urn:dvb:dash:profile:dvb-dash:isoff-ext-on-demand:2014') === FALSE))
fwrite($mpdreport, "Warning for DVB check: Section 11.1- 'All Representations that are intended to be decoded and presented by a DVB conformant Player SHOULD be such that they will be inferred to have an @profiles attribute that includes the profile name defined in clause 4.1 as well as either the one defined in 4.2.5 or the one defined in 4.2.8', found profiles: $subrep_profiles.\n");
}
}
}
}
}
}
if($adapt->getAttribute('contentType') == 'video' || $contentTemp_vid_found || $video_found || strpos($adapt->getAttribute('mimeType'), 'video') !== FALSE){
$video_service = true;
DVB_video_checks($adapt, $reps, $mpdreport, $i, $contentTemp_vid_found);
if($contentTemp_aud_found){
DVB_audio_checks($adapt, $reps, $mpdreport, $i, $contentTemp_aud_found);
}
}
elseif($adapt->getAttribute('contentType') == 'audio' || $contentTemp_aud_found || $audio_found || strpos($adapt->getAttribute('mimeType'), 'audio') !== FALSE){
DVB_audio_checks($adapt, $reps, $mpdreport, $i, $contentTemp_aud_found);
if($contentTemp_vid_found){
DVB_video_checks($adapt, $reps, $mpdreport, $i, $contentTemp_vid_found);
}
$audio_adapts[] = $adapt;
}
else{
DVB_subtitle_checks($adapt, $reps, $mpdreport, $i);
}
if($adapt_video_count > 1 && $main_video_found == false)
fwrite($mpdreport, "###'DVB check violated: Section 4.2.2- If a Period element contains multiple Adaptation Sets with @contentType=\"video\" then at least one Adaptation Set SHALL contain a Role element with @schemeIdUri=\"urn:mpeg:dash:role:2011\" and @value=\"main\"', could not be found in Period $period_count.\n");
DVB_content_protection($adapt, $reps, $mpdreport, $i, $cenc);
}
if($video_service){
StreamBandwidthCheck($mpdreport);
}
## Section 6.6.3 - Check for Audio Fallback Operation
if(!empty($audio_adapts) && sizeof($audio_adapts) > 1){
FallbackOperationCheck($audio_adapts, $mpdreport);
}
##
## Section 7.1.2 Table 11 - First Row "Hard of Hearing"
if($main_audio_found){
if(!empty($hoh_subtitle_lang)){
$main_lang = array();
foreach($main_audios as $main_audio){
if($main_audio->getAttribute('lang') != '')
$main_lang[] = $main_audio->getAttribute('lang');
}
foreach($hoh_subtitle_lang as $hoh_lang){
if(!empty($main_lang)){
if(!in_array($hoh_lang, $main_lang))
fwrite($mpdreport, "###'DVB check violated: Section 7.1.2- According to Table 11, when hard of hearing subtitle type is signalled the @lang attribute of the subtitle representation SHALL be the same as the main audio for the programme', @lang attributes do not match in Period $period_count.\n");
}
}
}
}
##
}
if($period_count > 64)
fwrite($mpdreport, "###'DVB check violated: Section 4.5- The MPD has a maximum of 64 periods after xlink resolution', found $period_count.\n");
}
DVB_associated_adaptation_sets_check($mpdreport);
if($adapt_audio_count > 1 && $main_audio_found == false)
fwrite($mpdreport, "###'DVB check violated: Section 6.1.2- If there is more than one audio Adaptation Set in a DASH Presentation then at least one of them SHALL be tagged with an @value set to \"main\"', could not be found in Period $period_count.\n");
}
function FallbackOperationCheck($audio_adapts, $mpdreport){
global $period_count;
$len = sizeof($audio_adapts);
for($i=0; $i<$len; $i++){
$audio_adapt_i = $audio_adapts[$i];
$supps_i = $audio_adapt_i->getElementsByTagName('SupplementalProperty');
$value = '';
foreach($supps_i as $supp_i){
if($supp_i->getAttribute('schemeIdUri') == 'urn:dvb:dash:fallback_adaptation_set:2014'){
$value = $supp_i->getAttribute('value');
}
}
if($value != ''){
$string_info = '';
for($j=0; $j<$len; $j++){
if($j != $i){
$audio_adapt_j = $audio_adapts[$j];
$id = $audio_adapt_j->getAttribute('id');
if($value == $id)
$string_info .= 'yes ';
}
}
if($string_info == '')
fwrite($mpdreport, "###'DVB check violated: Section 6.6.3- The (SupplementalProperty) descriptor SHALL have the @schemeIdUri attibute set to \"urn:dvb:dash:fallback_adaptation_set:2014\" and the @value attribute equal to the @id attribute of the Adaptation Set for which it supports the falling back operation', fallback operation is signalled via SupplementalProperty but the value does not match with any audio Adaptation Set @id in Period $period_count.\n");
else{
$role_i = $audio_adapt_i->getElementsByTagName('Role')->item(0);
$role_j = $audio_adapt_j->getElementsByTagName('Role')->item(0);
if($role_i->getAttribute('schemeIdUri') != $role_j->getAttribute('schemeIdUri') || $role_i->getAttribute('value') != $role_j->getAttribute('value'))
fwrite($mpdreport, "###'DVB check violated: Section 6.6.3- An additional low bit rate fallback Adaptation Set SHALL also be tagged with the same role as the Adaptation Set which it provides the fallback option for', roles are not the same in Period $period_count.\n");
}
}
}
}
function DVB_associated_adaptation_sets_check($mpdreport){
global $mpd_dom;
$periods = $mpd_dom->getElementsByTagName('Period');
$period_cnt = $periods->length;
for($i=0; $i<$period_cnt; $i++){
$period1 = $periods->item($i);
$assets1 = $period1->getElementsByTagName('AssetIdentifier');
if($assets1->length != 0){
for($j=$i+1; $j<$period_cnt; $j++){
$period2 = $periods->item($j);
$assets2 = $period2->getElementsByTagName('AssetIdentifier');
if($assets2->length != 0){
$assetCheck = checkAssetIdentifiers($assets1, $assets2);
if($assetCheck === TRUE){
checkAdaptationSetsIds($period1->getElementsByTagName('AdaptationSet'), $period2->getElementsByTagName('AdaptationSet'), $i, $j, $mpdreport);
}
}
}
}
}
}
function checkAssetIdentifiers($assets1, $assets2){
$return = FALSE;
$len1 = $assets1->length;
$len2 = $assets2->length;
for($i=0; $i<$len1; $i++){
$asset1 = $assets1->item($i);
for($j=0; $j<$len2; $j++){
$asset2 = $assets2->item($j);
if(nodes_equal($asset1, $asset2)){
return TRUE;
}
}
}
return $return;
}
function checkAdaptationSetsIds($adapts1, $adapts2, $periodId1, $periodId2, $mpdreport){
global $associativity;
$len1 = $adapts1->length;
$len2 = $adapts2->length;
$associativity_local = array();
for($i=0; $i<$len1; $i++){
$adapt1 = $adapts1->item($i);
$id1 = $adapt1->getAttribute('id');
for($j=0; $j<$len2; $j++){
$adapt2 = $adapts2->item($j);
$id2 = $adapt2->getAttribute('id');
$is_associative = true;
if($id1 != '' && $id2 != '' && $id1 == $id2){
# Section 10.5.2.2 - Check the DVB requirements for Associated Adaptation Sets
// @lang
$lang1 = $adapt1->getAttribute('lang');
$lang2 = $adapt2->getAttribute('lang');
if($lang1 != '' && $lang2 != '' && $lang1 != $lang2){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then the language as decribed by the @lang attribute SHALL be identical for the two Adaptation Sets', not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// @contentType
$contentType1 = $adapt1->getAttribute('contentType');
$contentType2 = $adapt2->getAttribute('contentType');
if($contentType1 != '' && $contentType2 != '' && $contentType1 != $contentType2){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then the media content component type decribed by the @contentType attribute SHALL be identical for the two Adaptation Sets', not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// @par
$par1 = $adapt1->getAttribute('par');
$par2 = $adapt2->getAttribute('par');
if($par1 != '' && $par2 != '' && $par1 != $par2){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then the picture aspect ratio decribed by the @par attribute SHALL be identical for the two Adaptation Sets', not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// Role
$roles1 = $adapt1->getElementsByTagName('Role');
$roles2 = $adapt2->getElementsByTagName('Role');
$roles1_cnt = $roles1->length;
$roles2_cnt = $roles2->length;
if($roles1_cnt != $roles2_cnt){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then any role properties as decribed by the Role elements SHALL be identical for the two Adaptation Sets', not identical number of Role elements found for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
else{
for($r=0; $r<$roles1_cnt; $r++){
if(!nodes_equal($roles1->item($r), $roles2->item($r))){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then any role properties as decribed by the Role element SHALL be identical for the two Adaptation Sets', not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
}
}
// Accessibility
$accessibility1 = $adapt1->getElementsByTagName('Accessibility');
$accessibility2 = $adapt2->getElementsByTagName('Accessibility');
$accessibility1_cnt = $accessibility1->length;
$accessibility2_cnt = $accessibility2->length;
if($accessibility1_cnt != $accessibility2_cnt){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then any accessibility properties as decribed by the Role elements SHALL be identical for the two Adaptation Sets', not identical number of Role elements found for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
else{
for($a=0; $a<$accessibility1_cnt; $a++){
if(!nodes_equal($accessibility1->item($a), $accessibility2->item($a))){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then any accessibility properties as decribed by the Role element SHALL be identical for the two Adaptation Sets', not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
}
}
// Viewpoint
$viewpoint1 = $adapt1->getElementsByTagName('Viewpoint');
$viewpoint2 = $adapt2->getElementsByTagName('Viewpoint');
$viewpoint1_cnt = $viewpoint1->length;
$viewpoint2_cnt = $viewpoint2->length;
if($viewpoint1_cnt != $viewpoint2_cnt){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then any viewpoint properties as decribed by the Role elements SHALL be identical for the two Adaptation Sets', not identical number of Role elements found for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
else{
for($v=0; $v<$viewpoint1_cnt; $v++){
if(!nodes_equal($viewpoint1->item($v), $viewpoint2->item($v))){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then any viewpoint properties as decribed by the Role element SHALL be identical for the two Adaptation Sets', not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
}
}
// Table 3 for Audio Adaptation Sets
$mimeType1 = $adapt1->getAttribute('mimeType');
$mimeType2 = $adapt2->getAttribute('mimeType');
$isaudio = ((strpos($mimeType1, 'audio') !== FALSE) | $contentType1 == 'audio') & ((strpos($mimeType2, 'audio') !== FALSE) | $contentType2 == 'audio');
if($mimeType1 == '' || $mimeType2 == ''){
$reps1 = $adapt1->getElementsByTagName('Representation');
$reps2 = $adapt1->getElementsByTagName('Representation');
if($reps1->length == $reps2->length){
for($r=0; $r<$reps1->length; $r++){
$rep1 = $reps1->item($r);
$rep2 = $reps2->item($r);
$isaudio |= ((strpos($rep1->getAttribute('mimeType'), 'audio') !== FALSE) & (strpos($rep2->getAttribute('mimeType'), 'audio') !== FALSE));
}
}
}
if($isaudio){
// Adaptation Set level
$mimeTypeExists = 0;
$codecsExits = 0;
$audioSamplingRateExists = 0;
$audioChannelConfigurationExits = 0;
// @mimeType
if($mimeType1 != '' && $mimeType2 != '' && $mimeType1 != $mimeType2){
$mimeTypeExists = 1;
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', @mimeType is not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// @codecs
$codecs1 = $adapt1->getAttribute('codecs');
$codecs2 = $adapt2->getAttribute('codecs');
if($codecs1 != '' && $codecs2 != '' && $codecs1 != $codecs2){
$codecsExits = 1;
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', @codecs is not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// @audioSamplingRate
$audioSamplingRate1 = $adapt1->getAttribute('audioSamplingRate');
$audioSamplingRate2 = $adapt2->getAttribute('audioSamplingRate');
if($audioSamplingRate1 != '' && $audioSamplingRate2 != '' && $audioSamplingRate1 != $audioSamplingRate2){
$audioSamplingRateExists = 1;
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', @audioSamplingRate is not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// AudioChannelConfiguration
$audioChannelConfiguration1 = $adapt1->getElementsByTagName('AudioChannelConfiguration');
$audioChannelConfiguration2 = $adapt2->getElementsByTagName('AudioChannelConfiguration');
$audioChannelConfiguration1_cnt = $audioChannelConfiguration1->length;
$audioChannelConfiguration2_cnt = $audioChannelConfiguration2->length;
if($audioChannelConfiguration1_cnt != $audioChannelConfiguration2_cnt){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', not identical number of AudioChannelConfiguration elements found for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
else{
for($a=0; $a<$audioChannelConfiguration1_cnt; $a++){
$audioChannelConfigurationExits = 1;
if(!nodes_equal($audioChannelConfiguration1->item($a), $audioChannelConfiguration2->item($a))){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', AudioChannelConfiguration is not identical for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
}
}
// Representation Set level
$allExitst = $mimeTypeExists & $codecsExits & $audioSamplingRateExists & $audioChannelConfigurationExits;
if(!$allExitst){
if($reps1->length != $reps2->length){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', not identical number of AudioChannelConfiguration elements found for Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
else{
for($r=0; $r<$reps1->length; $r++){
$rep1 = $reps1->item($r);
$rep2 = $reps2->item($r);
// @mimeType
$mimeType1 = $rep1->getAttribute('mimeType');
$mimeType2 = $rep2->getAttribute('mimeType');
if(!$mimeTypeExists && $mimeType1 != '' && $mimeType2 != '' && $mimeType1 != $mimeType2){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', @mimeType is not identical for Representation " . ($r+1) . " Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Representation " . ($r+1) . " Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// @codecs
$codecs1 = $rep1->getAttribute('codecs');
$codecs2 = $rep2->getAttribute('codecs');
if(!$codecsExits && $codecs1 != '' && $codecs2 != '' && $codecs1 != $codecs2){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', @codecs is not identical for Representation " . ($r+1) . " Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Representation " . ($r+1) . " Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// @audioSamplingRate
$audioSamplingRate1 = $rep1->getAttribute('audioSamplingRate');
$audioSamplingRate2 = $rep2->getAttribute('audioSamplingRate');
if(!$audioSamplingRateExists && $audioSamplingRate1 != '' && $audioSamplingRate2 != '' && $audioSamplingRate1 != $audioSamplingRate2){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', @audioSamplingRate is not identical for Representation " . ($r+1) . " Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Representation " . ($r+1) . " Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
// AudioChannelConfiguration
$audioChannelConfiguration1 = $rep1->getElementsByTagName('AudioChannelConfiguration');
$audioChannelConfiguration2 = $rep2->getElementsByTagName('AudioChannelConfiguration');
$audioChannelConfiguration1_cnt = $audioChannelConfiguration1->length;
$audioChannelConfiguration2_cnt = $audioChannelConfiguration2->length;
if(!$audioChannelConfigurationExits){
if($audioChannelConfiguration1_cnt != $audioChannelConfiguration2_cnt){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', not identical number of AudioChannelConfiguration elements found for Representation " . ($r+1) . " Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Representation " . ($r+1) . " Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
else{
for($a=0; $a<$audioChannelConfiguration1_cnt; $a++){
if(!nodes_equal($audioChannelConfiguration1->item($a), $audioChannelConfiguration2->item($a))){
fwrite($mpdreport, "###'DVB check violated: Section 10.5.2.2- If Adaptation Sets in two different Periods are associated, then for audio Adaptation Sets all values and presence of all attributes and elements listed in Table 3 SHALL be identical for the two Adaptation Sets', AudioChannelConfiguration is not identical for Representation " . ($r+1) . " Adaptation Set " . ($i+1) . " in Period " . ($periodId1+1) . " and Representation " . ($r+1) . " Adaptation Set " . ($j+1) . " in Period " . ($periodId2+1) . ".\n");
$is_associative = false;
}
}
}
}
}
}
}
}
}
else{
$is_associative = false;
}
if($is_associative)
$associativity[] = "$periodId1 $i $periodId2 $j";
}
}
}
function StreamBandwidthCheck($mpdreport){
global $video_bw, $audio_bw, $subtitle_bw;
for($v=0; $v<sizeof($video_bw); $v++){
for($a=0; $a<sizeof($audio_bw); $a++){
if(!empty($subtitle_bw)){
for($s=0; $s<sizeof($subtitle_bw); $s++){
$total_bw = $video_bw[$v] + $subtitle_bw[$s] + $audio_bw[$a];
if($audio_bw[$a] > 0.2*$total_bw)
fwrite($mpdreport, "Warning for DVB check: Section 11.3.0- 'If the service being delivered is a video service, then audio SHOULD be 20% or less of the total stream bandwidth', exceeding stream found with bandwidth properties: video " . $video_bw[$v] . ", audio " . $audio_bw[$a] . ", subtitle " . $subtitle_bw[$s] . "\n");
}
}
else{
$total_bw = $video_bw[$v] + $audio_bw[$a];
if($audio_bw[$a] > 0.2*$total_bw)
fwrite($mpdreport, "Warning for DVB check: Section 11.3.0- 'If the service being delivered is a video service, then audio SHOULD be 20% or less of the total stream bandwidth', exceeding stream found with bandwidth properties: video " . $video_bw[$v] . ", audio " . $audio_bw[$a] . "\n");
}
}
}
$video_bw = array();
$audio_bw = array();
$subtitle_bw = array();
}
function DVB_event_checks($possible_event, $mpdreport){
global $period_count;
if($possible_event->getAttribute('schemeIdUri') == 'urn:dvb:iptv:cpm:2014'){
if($possible_event->getAttribute('value') == '1'){
$events = $possible_event->getElementsByTagName('Event');
foreach ($events as $event){
if($event->getAttribute('presentationTime') == '')
fwrite($mpdreport, "###'DVB check violated: Section 9.1.2.1- The events associated with the @schemeIdUri attribute \"urn:dvb:iptv:cpm:2014\" and with @value attribute of \"1\", the presentationTime attribute of an MPD event SHALL be set', not set accordingly in Period $period_count.\n");
$event_value = $event->nodeValue;
if($event_value != ''){
$event_str = '<doc>' . $event_value . '</doc>';
$event_xml = simplexml_load_string($event_str);
if($event_xml === FALSE)
fwrite($mpdreport, "###'DVB check violated: Section 9.1.2.2- In order to carry XML structured data within the string value of an MPD Event element, the data SHALL be escaped or placed in a CDATA section in accordance with the XML specification 1.0', not done accordingly in Period $period_count.\n");
else{
foreach ($event_xml as $broadcastevent){
$name = $broadcastevent->getName();
if($name != 'BroadcastEvent')
fwrite($mpdreport, "###'DVB check violated: Section 9.1.2.2- The format of the event payload carrying content programme metadata SHALL be one or more TV-Anytime BroadcastEvent elements that form a valid TVAnytime XML document', not set accordingly in Period $period_count.\n");
}
}
}
}
}
}
}
function DVB_video_checks($adapt, $reps, $mpdreport, $i, $contentTemp_vid_found){
global $adapt_video_count, $main_video_found, $period_count, $video_bw;
## Information from this part is used for Section 4.2.2 check about multiple Adaptation Sets with video as contentType
if($adapt->getAttribute('contentType') == 'video'){
$adapt_video_count++;
}
$ids = array();
foreach ($adapt->childNodes as $ch){
if($ch->nodeName == 'Role'){
if($adapt->getAttribute('contentType') == 'video'){
if($ch->getAttribute('schemeIdUri') == 'urn:mpeg:dash:role:2011' && $ch->getAttribute('value') == 'main')
$main_video_found = true;
}
}
if($ch->nodeName == 'ContentComponent'){
if($ch->getAttribute('contentType') == 'video')
$ids[] = $ch->getAttribute('id');
}
if($ch->nodeName == 'SupplementalProperty'){
if($ch->getAttribute('schemeIdUri') == 'urn:dvb:dash:fontdownload:2014' && $ch->getAttribute('value') == '1'){
if(($ch->getAttribute('url') != '' || $ch->getAttribute('dvburl') != '') && ($ch->getAttribute('fontFamily') != '' || $ch->getAttribute('dvb:fontFamily') != '') && ($ch->getAttribute('mimeType') != '' || $ch->getAttribute('dvb:mimeType') != ''))
fwrite($mpdreport, "###'DVB check violated: Section 7.2.1.1- For DVB font download for subtitles, a descriptor with these properties SHALL only be placed within an Adaptation Set containing subtitle Representations', found SupplementalProperty element signaling downloadable fonts in video Adaptation Set in Period $period_count Adaptation Set " . ($i+1) . ".\n");
}
}
if($ch->nodeName == 'EssentialProperty'){
if($ch->getAttribute('schemeIdUri') == 'urn:dvb:dash:fontdownload:2014' && $ch->getAttribute('value') == '1'){
if(($ch->getAttribute('url') != '' || $ch->getAttribute('dvburl') != '') && ($ch->getAttribute('fontFamily') != '' || $ch->getAttribute('dvb:fontFamily') != '') && ($ch->getAttribute('mimeType') != '' || $ch->getAttribute('dvb:mimeType') != ''))
fwrite($mpdreport, "###'DVB check violated: Section 7.2.1.1- For DVB font download for subtitles, a descriptor with these properties SHALL only be placed within an Adaptation Set containing subtitle Representations', found EssentialProperty element signaling downloadable fonts in video Adaptation Set in Period $period_count Adaptation Set " . ($i+1) . ".\n");
}
}
}
##
$adapt_width_present = true;
$adapt_height_present = true;
$adapt_frameRate_present = true;
if($adapt->getAttribute('width') == '')
$adapt_width_present = false;
if($adapt->getAttribute('height') == '')
$adapt_height_present = false;
if($adapt->getAttribute('frameRate') == '')
$adapt_frameRate_present = false;
$adapt_codecs = $adapt->getAttribute('codecs');
$reps_len = $reps->length;
$reps_codecs = array();
$subreps_codecs = array();
for($j=0; $j<$reps_len; $j++){
$rep = $reps->item($j);
## Information from this part is used for Section 4.4 check
$reps_width[] = $rep->getAttribute('width');
$reps_height[] = $rep->getAttribute('height');
$reps_frameRate[] = $rep->getAttribute('frameRate');
$reps_scanType[] = $rep->getAttribute('scanType');
if($adapt->getAttribute('contentType') == 'video'){
if($adapt_width_present == false && $rep->getAttribute('width') == '')
fwrite($mpdreport, "###'DVB check violated: Section 4.4- For any Representation within an Adaptation Set with @contentType=\"video\" @width attribute SHALL be present if not in the AdaptationSet element', could not be found in neither Period $period_count Adaptation Set " . ($i+1) . " nor Period $period_count Adaptation Set " . ($i+1) . " Representation " . ($j+1) . ".\n");
if($adapt_height_present == false && $rep->getAttribute('height') == '')
fwrite($mpdreport, "###'DVB check violated: Section 4.4- For any Representation within an Adaptation Set with @contentType=\"video\" @height attribute SHALL be present if not in the AdaptationSet element', could not be found in neither Period $period_count Adaptation Set " . ($i+1) . " nor Period $period_count Adaptation Set " . ($i+1) . " Representation " . ($j+1) . ".\n");
if($adapt_frameRate_present == false && $rep->getAttribute('frameRate') == '')
fwrite($mpdreport, "###'DVB check violated: Section 4.4- For any Representation within an Adaptation Set with @contentType=\"video\" @frameRate attribute SHALL be present if not in the AdaptationSet element', could not be found in neither Period $period_count Adaptation Set " . ($i+1) . " nor Period $period_count Adaptation Set " . ($i+1) . " Representation " . ($j+1) . ".\n");
if($adapt->getAttribute('sar') == '' && $rep->getAttribute('sar') == '')
fwrite($mpdreport, "Warning for DVB check: Section 4.4- 'For any Representation within an Adaptation Set with @contentType=\"video\" @sar attribute SHOULD be present or inherited from the Adaptation Set', could not be found in neither Period $period_count Adaptation Set " . ($i+1) . " nor Period $period_count Adaptation Set " . ($i+1) . " Representation " . ($j+1) . ".\n");
}
##
$reps_codecs[] = $rep->getAttribute('codecs');
$subreps = $rep->getElementsByTagName('SubRepresentation');
for($k=0; $k<$subreps->length; $k++){
$subrep = $subreps->item($k);
$subreps_codecs[] = $subrep->getAttribute('codecs');
##Information from this part is for Section 11.3.0: audio stream bandwidth percentage
if($contentTemp_vid_found){
if(in_array($subrep->getAttribute('contentComponent'), $ids)){
$video_bw[] = ($rep->getAttribute('bandwidth') != '') ? (float)($rep->getAttribute('bandwidth')) : (float)($ch->getAttribute('bandwidth'));
}
}
##
}
#Information from this part is for Section 11.3.0: audio stream bandwidth percentage
if(!$contentTemp_vid_found){
$video_bw[] = (float)($rep->getAttribute('bandwidth'));
}
##
}
## Information from this part is used for Section 5.1 AVC codecs
if((strpos($adapt_codecs, 'avc') !== FALSE)){
$codec_parts = array();
$codecs = explode(',', $adapt_codecs);
foreach($codecs as $codec){
if(strpos($codec, 'avc') !== FALSE){
$codec_parts = explode('.', $codec);
$pcl = strlen($codec_parts[1]);
if($pcl != 6)
fwrite($mpdreport, "###'DVB check violated: Section 5.1.3- If (AVC video codec is) present the value of @codecs attribute SHALL be set in accordance with RFC 6381, clause 3.3', not found or not complete within Period $period_count Adaptation Set " . ($i+1) . ".\n");
}