netwerk/dash/mpd/AdaptationSet.cpp
author David Zbarsky <dzbarsky@gmail.com>
Sun, 23 Dec 2012 03:22:22 -0500
changeset 126045 9f3051733fec0917d7d4bc30e4a8e7aaca4d7362
parent 124362 a4e5618ca8bbbc990b08f89cd6004fa6f0a667e3
child 126095 372d779d8f2734674f3edd3992f556753a52ec34
permissions -rw-r--r--
Bug 823394 Part 1:Merge nsSVGStylableElement/nsSVGElement and nsIDOMSVGStylable/nsIDOMSVGElement r=bz

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*
 * AdaptationSet.cpp
 *****************************************************************************
 * Copyright(C) 2010 - 2012 Klagenfurt University
 *
 * Created on: Jan 27, 2012
 * Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
 *          Christian Timmerer  <christian.timmerer@itec.uni-klu.ac.at>
 * Contributors:
 *          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.
 *
 * |AdaptationSet|
 *
 * Describes a type of media in a |Period| of time in the media presentation,
 * e.g. an audio or video stream. Direct child of |Period|, which contains 1+
 * available pieces of media, available during that time period.
 * |AdaptationSet| itself contains one or more |Representations| which describe
 * different versions of the media, most commonly different bitrate encodings.
 *
 * Common class used by all DASH Profiles.
 * Populated by implementation of MPD Parser.
 * Used as data source by implementation of MPD Manager.
 *
 * |MPD|
 *  --> |Period|s of time.
 *       --> |AdaptationSet|s for each type or group of media content.
 *            --> |Representation|s of media, encoded with different bitrates.
 *                 --> |Segment|s of media, identified by URL (+optional byte
 *                     range.
 */

#include "AdaptationSet.h"

namespace mozilla {
namespace net {

int32_t
AdaptationSet::GetWidth() const
{
  return mWidth;
}

void
AdaptationSet::SetWidth(int32_t const aWidth)
{
  mWidth = aWidth;
}

int32_t
AdaptationSet::GetHeight() const
{
  return mHeight;
}

void
AdaptationSet::SetHeight(int32_t const aHeight)
{
  mHeight = aHeight;
}

void
AdaptationSet::GetMIMEType(nsAString& aMIMEType) const
{
  aMIMEType = mMIMEType;
}

void
AdaptationSet::SetMIMEType(nsAString const &aMIMEType)
{
  NS_ENSURE_FALSE(aMIMEType.IsEmpty(),);
  mMIMEType = aMIMEType;
}

Representation const *
AdaptationSet::GetRepresentation(uint32_t aIndex) const
{
  NS_ENSURE_TRUE(aIndex < mRepresentations.Length(), nullptr);
  return mRepresentations[aIndex];
}

void
AdaptationSet::AddRepresentation(Representation* aRep)
{
  NS_ENSURE_TRUE(aRep,);
  // Only add if it's not already in the array.
  if (!mRepresentations.Contains(aRep)) {
    mRepresentations.InsertElementSorted(aRep, CompareRepresentationBitrates());
  }
}

uint16_t
AdaptationSet::GetNumRepresentations() const
{
  return mRepresentations.Length();
}

void
AdaptationSet::EnableBitstreamSwitching(bool aEnable)
{
  mIsBitstreamSwitching = aEnable;
}

bool
AdaptationSet::IsBitstreamSwitchingEnabled() const
{
  return mIsBitstreamSwitching;
}

}//namespace net
}//namespace mozilla