Shaka Player Embedded
Main Page
Exported Types
+
Tutorials
Basic Tutorial
Network Filters
Internal Docs
+
Internal Class List
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
~
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Typedefs
a
b
d
e
f
h
i
l
m
r
s
t
v
Enumerations
+
Enumerator
a
b
c
d
e
k
n
p
t
v
+
Properties
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
v
w
+
Related Functions
:
a
c
d
g
j
m
o
p
r
s
v
w
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
shaka
src
js
mse
media_source.h
Go to the documentation of this file.
1
// Copyright 2016 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef SHAKA_EMBEDDED_JS_MSE_MEDIA_SOURCE_H_
16
#define SHAKA_EMBEDDED_JS_MSE_MEDIA_SOURCE_H_
17
18
#include <string>
19
#include <unordered_map>
20
21
#include "
shaka/media/demuxer.h
"
22
#include "
shaka/media/media_player.h
"
23
#include "
shaka/optional.h
"
24
#include "
src/core/member.h
"
25
#include "
src/core/ref_ptr.h
"
26
#include "
src/js/events/event_target.h
"
27
#include "
src/mapping/byte_buffer.h
"
28
#include "
src/mapping/enum.h
"
29
#include "
src/mapping/exception_or.h
"
30
#include "
src/media/types.h
"
31
32
namespace
shaka
{
33
namespace
js {
34
namespace
mse {
35
36
class
HTMLMediaElement;
37
class
SourceBuffer;
38
39
40
enum class
MediaSourceReadyState
{
41
CLOSED
,
42
OPEN
,
43
ENDED
,
44
};
45
46
class
MediaSource
:
public
events::EventTarget
,
public
media::Demuxer::Client
{
47
DECLARE_TYPE_INFO
(
MediaSource
);
48
49
public
:
50
MediaSource
();
51
52
static
MediaSource
*
Create
() {
53
return
new
MediaSource
();
54
}
55
56
static
bool
IsTypeSupported(
const
std::string& mime_type);
57
static
RefPtr<MediaSource>
FindMediaSource(
const
std::string& url);
58
59
void
Trace(
memory::HeapTracer
* tracer)
const override
;
60
61
ExceptionOr<RefPtr<SourceBuffer>
> AddSourceBuffer(
const
std::string&
type
);
62
ExceptionOr<void>
EndOfStream(
optional<std::string>
error);
63
64
double
GetDuration()
const
;
65
ExceptionOr<void>
SetDuration(
double
duration);
66
67
69
void
OpenMediaSource(
RefPtr<HTMLMediaElement>
video,
70
media::MediaPlayer
* player);
72
void
CloseMediaSource();
73
74
75
Listener
on_source_open
;
76
Listener
on_source_ended
;
77
Listener
on_source_close
;
78
79
MediaSourceReadyState
ready_state
;
80
const
std::string
url
;
81
82
private
:
83
void
OnLoadedMetaData(
double
duration)
override
;
84
void
OnEncrypted(::
shaka::eme::MediaKeyInitDataType
type,
const
uint8_t* data,
85
size_t
size)
override
;
86
87
Member<SourceBuffer>
audio_buffer_;
88
Member<SourceBuffer>
video_buffer_;
89
Member<HTMLMediaElement>
video_;
90
media::MediaPlayer
* player_;
91
bool
got_loaded_metadata_;
92
93
// A map of every MediaSource object created. These are not traced so they
94
// are weak pointers. Once a MediaSource gets destroyed, it will be removed
95
// from this map by its destructor.
96
static
std::unordered_map<std::string, Member<MediaSource>> media_sources_;
97
};
98
99
class
MediaSourceFactory
100
:
public
BackingObjectFactory
<MediaSource, events::EventTarget> {
101
public
:
102
MediaSourceFactory
();
103
};
104
105
}
// namespace mse
106
}
// namespace js
107
}
// namespace shaka
108
109
DEFINE_ENUM_MAPPING
(
shaka::js::mse
,
MediaSourceReadyState
) {
110
AddMapping(
Enum::CLOSED
,
"closed"
);
111
AddMapping(
Enum::OPEN
,
"open"
);
112
AddMapping(
Enum::ENDED
,
"ended"
);
113
}
114
115
#endif // SHAKA_EMBEDDED_JS_MSE_MEDIA_SOURCE_H_
shaka::ExceptionOr
Definition:
exception_or.h:36
shaka::js::mse::MediaSource::on_source_open
Listener on_source_open
Definition:
media_source.h:75
shaka::media::Demuxer::Client
Definition:
demuxer.h:42
types.h
optional.h
byte_buffer.h
shaka::js::mse::MediaSource::Create
static MediaSource * Create()
Definition:
media_source.h:52
shaka::js::mse::MediaSource::on_source_ended
Listener on_source_ended
Definition:
media_source.h:76
shaka::Member
Definition:
member.h:40
media_player.h
shaka::js::mse::MediaSource::ready_state
MediaSourceReadyState ready_state
Definition:
media_source.h:79
shaka::js::mse
Definition:
media_element.cc:30
shaka::optional< std::string >
shaka::js::mse::MediaSourceFactory
Definition:
media_source.h:99
demuxer.h
ref_ptr.h
shaka::BackingObjectFactory
Definition:
backing_object_factory.h:406
shaka
Definition:
async_results.h:25
shaka::js::mse::MediaSourceReadyState
MediaSourceReadyState
Definition:
media_source.h:40
type
ExceptionCode type
Definition:
dom_exception.cc:37
exception_or.h
enum.h
shaka::memory::HeapTracer
Definition:
heap_tracer.h:85
shaka::js::mse::MediaSourceReadyState::OPEN
shaka::ExceptionOr< void >
Definition:
exception_or.h:41
member.h
shaka::RefPtr
Definition:
ref_ptr.h:43
shaka::media::MediaPlayer
Definition:
media_player.h:184
shaka::js::mse::MediaSource::on_source_close
Listener on_source_close
Definition:
media_source.h:77
shaka::js::events::EventTarget
Definition:
event_target.h:40
shaka::js::mse::MediaSource
Definition:
media_source.h:46
event_target.h
DECLARE_TYPE_INFO
#define DECLARE_TYPE_INFO(type)
Definition:
backing_object.h:39
shaka::eme::MediaKeyInitDataType
MediaKeyInitDataType
Definition:
configuration.h:45
DEFINE_ENUM_MAPPING
DEFINE_ENUM_MAPPING(shaka::js::mse, MediaSourceReadyState)
Definition:
media_source.h:109
shaka::js::mse::MediaSourceReadyState::CLOSED
shaka::js::mse::MediaSourceReadyState::ENDED
shaka::js::mse::MediaSource::url
const std::string url
Definition:
media_source.h:80
Generated by
1.8.13