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
|
# File 'lib/dash_timeline_validator/validator.rb', line 5
def self.analyze(manifest, mpd_content)
report = {}
mpd = nil
if DashTimelineValidator::DashFile.uri? manifest
uri = URI(manifest)
report["base_path"] = DashTimelineValidator::Report.report_info("#{uri.scheme}://#{uri.host}#{uri.path.split("/").reverse.drop(1).reverse.join("/")}")
else
report["base_path"] = DashTimelineValidator::Report.report_info(DashTimelineValidator::DashFile::ANALYZER_FOLDER)
end
begin
mpd = Ox.load(mpd_content)
rescue
DashTimelineValidator::Log.error("Error while parsing #{manifest} it might be malformed (a non 2xx response)")
error_exit(report)
end
report["client_wallclock"] = DashTimelineValidator::Report.report_info(client_wallclock(mpd))
report["mpd"] = {}
DashTimelineValidator::Report.fill_report(report["mpd"], mpd.MPD, "type", "static")
DashTimelineValidator::Report.fill_report_mandatory(report["mpd"], mpd.MPD, "minBufferTime", :duration_iso8601_to_i)
if report["mpd"]["type"] == "dynamic"
DashTimelineValidator::Report.fill_report_mandatory(report["mpd"], mpd.MPD, "availabilityStartTime", :time_to_i)
if mpd.MPD.respond_to? "suggestedPresentationDelay"
DashTimelineValidator::Report.fill_report(report["mpd"], mpd.MPD, "suggestedPresentationDelay", 0, :duration_iso8601_to_i)
end
else
DashTimelineValidator::Report.fill_report(report["mpd"], mpd.MPD, "availabilityStartTime", Time.now.iso8601(0), :time_to_i)
end
all_periods = mpd.MPD.nodes.select { |n| n.name == "Period" }
report["mpd"]["periods"] = all_periods.each_with_index.map do |period, index|
DashTimelineValidator::Period.process({root: report, previous: report["mpd"]}, period, index)
end
report
end
|