LCOV - code coverage report
Current view: top level - dom/media - VideoTrack.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 41 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim:set ts=2 sw=2 et tw=78: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/HTMLMediaElement.h"
       8             : #include "mozilla/dom/VideoStreamTrack.h"
       9             : #include "mozilla/dom/VideoTrack.h"
      10             : #include "mozilla/dom/VideoTrackBinding.h"
      11             : #include "mozilla/dom/VideoTrackList.h"
      12             : 
      13             : namespace mozilla {
      14             : namespace dom {
      15             : 
      16           0 : VideoTrack::VideoTrack(const nsAString& aId,
      17             :                        const nsAString& aKind,
      18             :                        const nsAString& aLabel,
      19             :                        const nsAString& aLanguage,
      20           0 :                        VideoStreamTrack* aStreamTarck)
      21             :   : MediaTrack(aId, aKind, aLabel, aLanguage)
      22             :   , mSelected(false)
      23           0 :   , mVideoStreamTrack(aStreamTarck)
      24             : {
      25           0 : }
      26             : 
      27           0 : VideoTrack::~VideoTrack()
      28             : {
      29           0 : }
      30             : 
      31           0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(VideoTrack, MediaTrack, mVideoStreamTrack)
      32             : 
      33           0 : NS_IMPL_ADDREF_INHERITED(VideoTrack, MediaTrack)
      34           0 : NS_IMPL_RELEASE_INHERITED(VideoTrack, MediaTrack)
      35           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(VideoTrack)
      36           0 : NS_INTERFACE_MAP_END_INHERITING(MediaTrack)
      37             : 
      38             : JSObject*
      39           0 : VideoTrack::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      40             : {
      41           0 :   return VideoTrackBinding::Wrap(aCx, this, aGivenProto);
      42             : }
      43             : 
      44           0 : void VideoTrack::SetSelected(bool aSelected)
      45             : {
      46           0 :   SetEnabledInternal(aSelected, MediaTrack::DEFAULT);
      47           0 : }
      48             : 
      49             : void
      50           0 : VideoTrack::SetEnabledInternal(bool aEnabled, int aFlags)
      51             : {
      52           0 :   if (aEnabled == mSelected) {
      53           0 :     return;
      54             :   }
      55             : 
      56           0 :   mSelected = aEnabled;
      57             : 
      58             :   // If this VideoTrack is no longer in its original VideoTrackList, then
      59             :   // whether it is selected or not has no effect on its original list.
      60           0 :   if (!mList) {
      61           0 :     return;
      62             :   }
      63             : 
      64           0 :   VideoTrackList& list = static_cast<VideoTrackList&>(*mList);
      65           0 :   if (mSelected) {
      66           0 :     uint32_t curIndex = 0;
      67             : 
      68             :     // Unselect all video tracks except the current one.
      69           0 :     for (uint32_t i = 0; i < list.Length(); ++i) {
      70           0 :       if (list[i] == this) {
      71           0 :         curIndex = i;
      72           0 :         continue;
      73             :       }
      74             : 
      75           0 :       VideoTrack* track = list[i];
      76           0 :       track->SetSelected(false);
      77             :     }
      78             : 
      79             :     // Set the index of selected video track to the current's index.
      80           0 :     list.mSelectedIndex = curIndex;
      81             : 
      82           0 :     HTMLMediaElement* element = mList->GetMediaElement();
      83           0 :     if (element) {
      84           0 :       element->NotifyMediaTrackEnabled(this);
      85             :     }
      86             :   } else {
      87           0 :     list.mSelectedIndex = -1;
      88             : 
      89           0 :     HTMLMediaElement* element = mList->GetMediaElement();
      90           0 :     if (element) {
      91           0 :       element->NotifyMediaTrackDisabled(this);
      92             :     }
      93             :   }
      94             : 
      95             :   // Fire the change event at selection changes on this video track, shall
      96             :   // propose a spec change later.
      97           0 :   if (!(aFlags & MediaTrack::FIRE_NO_EVENTS)) {
      98           0 :     list.CreateAndDispatchChangeEvent();
      99             :   }
     100             : }
     101             : 
     102             : } // namespace dom
     103             : } //namespace mozilla

Generated by: LCOV version 1.13