Class: DashTimelineValidator::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/dash_timeline_validator/validator.rb

Class Method Summary collapse

Class Method Details

.analyze(manifest, mpd_content) ⇒ Object



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

.client_wallclock(mpd) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/dash_timeline_validator/validator.rb', line 47

def self.client_wallclock(mpd)
  if mpd.MPD.respond_to? "UTCTiming"
    if mpd.MPD.UTCTiming["schemeIdUri"].eql? "urn:mpeg:dash:utc:direct:2014"
      raw_time = mpd.MPD.UTCTiming["value"]
    elsif mpd.MPD.UTCTiming["schemeIdUri"].eql? "urn:mpeg:dash:utc:http-iso:2014"
      raw_time = Net::HTTP.get(URI.parse(mpd.MPD.UTCTiming["value"]))
    end
  end

  if raw_time.nil?
    return DateTime.now.to_time.to_i
  end

  DateTime.parse(raw_time).to_time.to_i
end