forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Representation.h
137 lines (118 loc) · 4.4 KB
/
Representation.h
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
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*
* Representation.h
*****************************************************************************
* Copyrigh(C) 2010 - 2011 Klagenfurt University
*
* Created on: Aug 10, 2010
* 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.
*
* |Representation|
*
* Describes a particular version of a piece of media described in an
* |AdaptationSet|, a common example being a particular bitrate encoding for an
* audio or video stream. Direct child of |AdaptationSet|, which contains 1+
* available |Representation|s of the media.
*
* 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.
*/
#ifndef REPRESENTATION_H_
#define REPRESENTATION_H_
#include "nsAutoPtr.h"
#include "nsString.h"
#include "nsTArray.h"
#include "SegmentBase.h"
namespace mozilla {
namespace net {
class Representation
{
public:
Representation() :
mBitrate(0),
mWidth(0),
mHeight(0),
mSegmentBase(nullptr)
{
MOZ_COUNT_CTOR(Representation);
}
virtual ~Representation() {
MOZ_COUNT_DTOR(Representation);
}
bool operator<(const Representation &other) const {
return this->mBitrate < other.mBitrate;
}
// Gets/Sets @bitrate in kbps.
int64_t const GetBitrate() const;
void SetBitrate(int64_t const aBitrate);
// Gets/Sets @width and @height for the media if it's video.
void SetWidth(int32_t const aWidth);
int32_t const GetWidth() const;
void SetHeight(int32_t const aHeight);
int32_t const GetHeight() const;
// Gets/Adds a |BaseURL| for the media files.
void AddBaseUrl(nsAString const& aUrl);
nsAString const& GetBaseUrl(uint32_t aIndex) const;
bool HasBaseUrls() const { return !mBaseUrls.IsEmpty(); }
// Gets/Sets a base |Segment| for the |Representation|.
SegmentBase const* GetSegmentBase() const;
// Takes ownership of |SegmentBase| to manage deletion.
void SetSegmentBase(SegmentBase* aBase);
private:
// Bitrate of the media in kbps.
int64_t mBitrate;
// Width and height of the media if video.
int32_t mWidth;
int32_t mHeight;
// List of absolute/relative |BaseURL|s which may be used to access the media.
nsTArray<nsString> mBaseUrls;
// The base |Segment| for the |Representation|.
nsAutoPtr<SegmentBase> mSegmentBase;
};
// Comparator allows comparing |Representation|s based on media stream bitrate.
class CompareRepresentationBitrates
{
public:
// Returns true if the elements are equals; false otherwise.
// Note: |Representation| is stored as an array of |nsAutoPtr| in
// |AdaptationSet|, but needs to be compared to regular pointers.
// Hence the left hand side of the function being an
// |nsAutoPtr| and the right being a regular pointer.
bool Equals(const nsAutoPtr<Representation>& a,
const Representation *b) const {
return a == b;
}
// Returns true if (a < b); false otherwise.
// Note: |Representation| is stored as an array of |nsAutoPtr| in
// |AdaptationSet|, but needs to be compared to regular pointers.
// Hence the left hand side of the function being an
// |nsAutoPtr| and the right being a regular pointer.
bool LessThan(const nsAutoPtr<Representation>& a,
const Representation *b) const {
return *a < *b;
}
};
}//namespace net
}//namespace mozilla
#endif /* REPRESENTATION_H_ */