gecko-dev/netwerk/dash/mpd/nsDASHWebMODParser.h

160 строки
5.7 KiB
C
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*
* nsDASHWebMODParser.h
*****************************************************************************
* Copyrigh(C) 2010 - 2012 Klagenfurt University
*
* Created on: May 1, 2012
* Based on IsoffMainParser.h by:
* Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
* Christian Timmerer <christian.timmerer@itec.uni-klu.ac.at>
* Author:
* Steve Workman <sworkman@mozilla.com>
*
* This Source Code Form Is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*****************************************************************************/
/* DASH - Dynamic Adaptive Streaming over HTTP.
*
* DASH is an adaptive bitrate streaming technology where a multimedia file is
* partitioned into one or more segments and delivered to a client using HTTP.
*
Bug 811381 - Remove ns prefix from media code. r=roc --HG-- rename : content/media/nsAudioAvailableEventManager.cpp => content/media/AudioAvailableEventManager.cpp rename : content/media/nsAudioAvailableEventManager.h => content/media/AudioAvailableEventManager.h rename : content/media/nsAudioStream.cpp => content/media/AudioStream.cpp rename : content/media/nsAudioStream.h => content/media/AudioStream.h rename : content/media/nsMediaCache.cpp => content/media/MediaCache.cpp rename : content/media/nsMediaCache.h => content/media/MediaCache.h rename : content/media/nsBuiltinDecoder.cpp => content/media/MediaDecoder.cpp rename : content/media/nsBuiltinDecoder.h => content/media/MediaDecoder.h rename : content/media/nsBuiltinDecoderReader.cpp => content/media/MediaDecoderReader.cpp rename : content/media/nsBuiltinDecoderReader.h => content/media/MediaDecoderReader.h rename : content/media/nsBuiltinDecoderStateMachine.cpp => content/media/MediaDecoderStateMachine.cpp rename : content/media/nsBuiltinDecoderStateMachine.h => content/media/MediaDecoderStateMachine.h rename : content/media/dash/nsDASHDecoder.cpp => content/media/dash/DASHDecoder.cpp rename : content/media/dash/nsDASHDecoder.h => content/media/dash/DASHDecoder.h rename : content/media/dash/nsDASHReader.cpp => content/media/dash/DASHReader.cpp rename : content/media/dash/nsDASHReader.h => content/media/dash/DASHReader.h rename : content/media/dash/nsDASHRepDecoder.cpp => content/media/dash/DASHRepDecoder.cpp rename : content/media/dash/nsDASHRepDecoder.h => content/media/dash/DASHRepDecoder.h rename : content/media/gstreamer/nsGStreamerDecoder.cpp => content/media/gstreamer/GStreamerDecoder.cpp rename : content/media/gstreamer/nsGStreamerDecoder.h => content/media/gstreamer/GStreamerDecoder.h rename : content/media/gstreamer/nsGStreamerReader.cpp => content/media/gstreamer/GStreamerReader.cpp rename : content/media/gstreamer/nsGStreamerReader.h => content/media/gstreamer/GStreamerReader.h rename : content/media/ogg/nsOggCodecState.cpp => content/media/ogg/OggCodecState.cpp rename : content/media/ogg/nsOggCodecState.h => content/media/ogg/OggCodecState.h rename : content/media/ogg/nsOggDecoder.cpp => content/media/ogg/OggDecoder.cpp rename : content/media/ogg/nsOggDecoder.h => content/media/ogg/OggDecoder.h rename : content/media/ogg/nsOggReader.cpp => content/media/ogg/OggReader.cpp rename : content/media/ogg/nsOggReader.h => content/media/ogg/OggReader.h rename : content/media/omx/nsMediaOmxDecoder.cpp => content/media/omx/MediaOmxDecoder.cpp rename : content/media/omx/nsMediaOmxDecoder.h => content/media/omx/MediaOmxDecoder.h rename : content/media/omx/nsMediaOmxReader.cpp => content/media/omx/MediaOmxReader.cpp rename : content/media/omx/nsMediaOmxReader.h => content/media/omx/MediaOmxReader.h rename : content/media/plugins/nsMediaPluginDecoder.cpp => content/media/plugins/MediaPluginDecoder.cpp rename : content/media/plugins/nsMediaPluginDecoder.h => content/media/plugins/MediaPluginDecoder.h rename : content/media/plugins/nsMediaPluginHost.cpp => content/media/plugins/MediaPluginHost.cpp rename : content/media/plugins/nsMediaPluginHost.h => content/media/plugins/MediaPluginHost.h rename : content/media/plugins/nsMediaPluginReader.cpp => content/media/plugins/MediaPluginReader.cpp rename : content/media/plugins/nsMediaPluginReader.h => content/media/plugins/MediaPluginReader.h rename : content/media/raw/nsRawDecoder.cpp => content/media/raw/RawDecoder.cpp rename : content/media/raw/nsRawDecoder.h => content/media/raw/RawDecoder.h rename : content/media/raw/nsRawReader.cpp => content/media/raw/RawReader.cpp rename : content/media/raw/nsRawReader.h => content/media/raw/RawReader.h rename : content/media/raw/nsRawStructs.h => content/media/raw/RawStructs.h rename : content/media/wave/nsWaveDecoder.cpp => content/media/wave/WaveDecoder.cpp rename : content/media/wave/nsWaveDecoder.h => content/media/wave/WaveDecoder.h rename : content/media/wave/nsWaveReader.cpp => content/media/wave/WaveReader.cpp rename : content/media/wave/nsWaveReader.h => content/media/wave/WaveReader.h rename : content/media/webm/nsWebMBufferedParser.cpp => content/media/webm/WebMBufferedParser.cpp rename : content/media/webm/nsWebMBufferedParser.h => content/media/webm/WebMBufferedParser.h rename : content/media/webm/nsWebMDecoder.cpp => content/media/webm/WebMDecoder.cpp rename : content/media/webm/nsWebMDecoder.h => content/media/webm/WebMDecoder.h rename : content/media/webm/nsWebMReader.cpp => content/media/webm/WebMReader.cpp rename : content/media/webm/nsWebMReader.h => content/media/webm/WebMReader.h
2012-11-14 23:46:40 +04:00
* (see DASHDecoder.cpp for info on DASH interaction with the media engine).
*
* Media Presentation Description (MPD) Parser for WebM On Demand Profile.
*
* Parses DOM built from MPD XML to verify data and populate MPD classes.
* MPD classes used as a metadata source by WebM On Demand Manager.
*
*
* General:
* -- Ignore all elements with @|xlink|.
* -- @|startWithSAP| XXX examine later - defines "Segments starting with
* media stream access points".
* -- @|mimeType| for elements should be 'video/webm' or 'audio/webm'.
*
* |MPD|:
* -- May have |BaseURL|.
* -- @|type| = 'static' only.
*
* |Period|:
* -- no |SegmentList| or |SegmentTemplate|; not just ignored, they shouldn't be
* present.
*
* |AdaptationSet|:
* -- ignore this element if it has a |SegmentList| or |SegmentTemplate|.
* -- ignore this element if @|subsegmentAlignment| is not present or is set
* to false.
* To enable stream switching:
* -- @|subsegmentStartsWithSAP| = 1.
* -- @|segmentAlignment| = true.
* -- @|bitstreamSwitching| = true.
* -- Can have @|width| and @|height|.
* -- Can have @|id|.
* -- Can have @|codecs|, but this should match appropriately with @|mimeType|.
*
* |Representation|:
* -- should contain only one |Segment|, which should be 'Self-Initializing
* Indexed Media Segment'. Note: |Segment|s are generated from |BaseURL|
* elements within a |Representation|.
* -- ignore if @|profiles| is not the same as MPD's @|profiles|.
* -- ignore this element if it has a |SegmentList| or |SegmentTemplate|.
* -- ignore if it does NOT have a |BaseURL|.
* -- ignore if @|subsegmentStartsWithSAP| != 1 and has sibling |Representation|s
* in |AdaptationSet|.
* -- no |IndexSegment|.
*
* |BaseURL|:
* -- no specifics.
*
*
*/
#ifndef DASHWEBMODPARSER_H_
#define DASHWEBMODPARSER_H_
#include "nsCOMPtr.h"
#include "IMPDParser.h"
#include "MPD.h"
#include "Period.h"
#include "AdaptationSet.h"
#include "Representation.h"
#include "SegmentBase.h"
class nsIDOMElement;
namespace mozilla {
namespace net {
class nsDASHWebMODParser : public IMPDParser
{
public:
nsDASHWebMODParser(nsIDOMElement* aRoot);
virtual ~nsDASHWebMODParser();
// Inherited from IMPDParser.
MPD* Parse();
private:
// Parses MPD tag attributes from the DOM.
nsresult VerifyMPDAttributes();
// Parses the |BaseURL| to be used for all other URLs.
nsresult SetMPDBaseUrls(MPD* aMpd);
// Parses all |Period|s in the DOM of the media presentation.
nsresult SetPeriods(MPD* aMpd);
// Parses |AdaptationSet|s of media in the DOM node for the given |Period|.
nsresult SetAdaptationSets(nsIDOMElement* aPeriodNode,
Period* aPeriod,
bool &bIgnoreThisRep);
// Validates the attributes for the given |AdaptationSet| of media.
nsresult ValidateAdaptationSetAttributes(nsIDOMElement* aChild,
bool &bAttributesValid);
// Parses |Representation|s in the DOM for the given |AdaptationSet|.
nsresult SetRepresentations(nsIDOMElement* aAdaptationSetNode,
AdaptationSet* aAdaptationSet,
bool &bIgnoreThisRep);
// Parses |BaseURLs| for the given media |Representation|.
// Note: in practise, this is combined with the |BaseURL| for the |MPD|.
nsresult SetRepresentationBaseUrls(nsIDOMElement* aRepNode,
Representation* aRep,
bool &bIgnoreThisRep);
// Parses the |SegmentBase| for the media |Representation|.
// For WebM OD, there is one |SegmentBase| and one |Segment| per media
// |Representation|.
nsresult SetRepSegmentBase(nsIDOMElement* aRepElem,
Representation* aRep,
bool &bIgnoreThisRep);
// Parses the |InitSegment| for the |SegmentBase|.
// For WebM OD, the |InitSegment| is a range of bytes for each |SegmentBase|.
nsresult SetSegmentBaseInit(nsIDOMElement* aSegBaseElem,
SegmentBase* aSegBase,
bool &bIgnoreThisSegBase);
// Gets an attribute's value from a DOM element.
nsresult GetAttribute(nsIDOMElement* aElem,
const nsAString& aAttribute,
nsAString& aValue);
// Converts a subtring "<time>" in a string of format "PT<time>S" to a double.
nsresult GetTime(nsAString& aTimeStr, double& aTime);
// The root DOM element of the MPD; populated after reading the XML file; used
// to populate the MPD class structure.
nsCOMPtr<nsIDOMElement> mRoot;
};
}//namespace net
}//namespace mozilla
#endif /* DASHWEBMODPARSER_H_ */