Shaka Player Embedded
video_element.cc
Go to the documentation of this file.
1 // Copyright 2020 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 
16 
17 #include "src/js/dom/document.h"
18 #include "src/util/macros.h"
19 
20 namespace shaka {
21 namespace js {
22 namespace mse {
23 
25 std::unordered_set<HTMLVideoElement*> HTMLVideoElement::g_video_elements_;
27 
28 DEFINE_STRUCT_SPECIAL_METHODS_COPYABLE(VideoPlaybackQuality);
29 
31  media::MediaPlayer* player)
32  : HTMLMediaElement(document, "video", player) {
33  g_video_elements_.insert(this);
34 }
35 
36 // \cond Doxygen_Skip
37 HTMLVideoElement::~HTMLVideoElement() {
38  g_video_elements_.erase(this);
39 }
40 // \endcond Doxygen_Skip
41 
43  return *g_video_elements_.begin();
44 }
45 
47  if (g_video_elements_.empty())
48  return nullptr;
49  return (*g_video_elements_.begin())->player_;
50 }
51 
53  const {
55  if (player_) {
56  auto temp = player_->VideoPlaybackQuality();
57  ret.totalVideoFrames = temp.total_video_frames;
58  ret.droppedVideoFrames = temp.dropped_video_frames;
59  ret.corruptedVideoFrames = temp.corrupted_video_frames;
60  }
61  return ret;
62 }
63 
64 
66  AddMemberFunction("getVideoPlaybackQuality",
68 }
69 
70 } // namespace mse
71 } // namespace js
72 } // namespace shaka
#define END_ALLOW_COMPLEX_STATICS
Definition: macros.h:43
media::MediaPlayer * player_
static media::MediaPlayer * AnyMediaPlayer()
ExceptionOr< VideoPlaybackQuality > GetVideoPlaybackQuality() const
#define BEGIN_ALLOW_COMPLEX_STATICS
Definition: macros.h:42
virtual VideoPlaybackQuality VideoPlaybackQuality() const =0
static RefPtr< HTMLVideoElement > AnyVideoElement()
END_ALLOW_COMPLEX_STATICS DEFINE_STRUCT_SPECIAL_METHODS_COPYABLE(VideoPlaybackQuality)
HTMLVideoElement(RefPtr< dom::Document > document, media::MediaPlayer *player)