LCOV - code coverage report
Current view: top level - dom/media - VideoTrackList.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 33 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 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             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "mozilla/dom/VideoTrack.h"
       7             : #include "mozilla/dom/VideoTrackList.h"
       8             : #include "mozilla/dom/VideoTrackListBinding.h"
       9             : 
      10             : namespace mozilla {
      11             : namespace dom {
      12             : 
      13             : JSObject*
      14           0 : VideoTrackList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      15             : {
      16           0 :   return VideoTrackListBinding::Wrap(aCx, this, aGivenProto);
      17             : }
      18             : 
      19             : VideoTrack*
      20           0 : VideoTrackList::operator[](uint32_t aIndex)
      21             : {
      22           0 :   MediaTrack* track = MediaTrackList::operator[](aIndex);
      23           0 :   return track->AsVideoTrack();
      24             : }
      25             : 
      26             : void
      27           0 : VideoTrackList::RemoveTrack(const RefPtr<MediaTrack>& aTrack)
      28             : {
      29             :   // we need to find the video track before |MediaTrackList::RemoveTrack|. Or
      30             :   // mSelectedIndex will not be valid. The check of mSelectedIndex == -1
      31             :   // need to be done after RemoveTrack. Also the call of
      32             :   // |MediaTrackList::RemoveTrack| is necessary even when mSelectedIndex = -1.
      33             :   bool found;
      34           0 :   VideoTrack* selectedVideoTrack = IndexedGetter(mSelectedIndex, found);
      35           0 :   MediaTrackList::RemoveTrack(aTrack);
      36           0 :   if (mSelectedIndex == -1) {
      37             :     // There was no selected track and we don't select another track on removal.
      38           0 :     return;
      39             :   }
      40           0 :   MOZ_ASSERT(found, "When mSelectedIndex is set it should point to a track");
      41           0 :   MOZ_ASSERT(selectedVideoTrack, "The mSelectedIndex should be set to video track only");
      42             : 
      43             :   // Let the caller of RemoveTrack deal with choosing the new selected track if
      44             :   // it removes the currently-selected track.
      45           0 :   if (aTrack == selectedVideoTrack) {
      46           0 :     mSelectedIndex = -1;
      47           0 :     return;
      48             :   }
      49             : 
      50             :   // The removed track was not the selected track and there is a
      51             :   // currently-selected video track. We need to find the new location of the
      52             :   // selected track.
      53           0 :   for (size_t ix = 0; ix < mTracks.Length(); ix++) {
      54           0 :     if (mTracks[ix] == selectedVideoTrack) {
      55           0 :       mSelectedIndex = ix;
      56           0 :       return;
      57             :     }
      58             :   }
      59             : }
      60             : 
      61             : void
      62           0 : VideoTrackList::EmptyTracks()
      63             : {
      64           0 :   mSelectedIndex = -1;
      65           0 :   MediaTrackList::EmptyTracks();
      66           0 : }
      67             : 
      68           0 : VideoTrack* VideoTrackList::GetSelectedTrack()
      69             : {
      70           0 :   if (mSelectedIndex < 0 || static_cast<size_t>(mSelectedIndex) >= mTracks.Length()) {
      71           0 :     return nullptr;
      72             :   }
      73             : 
      74           0 :   return operator[](mSelectedIndex);
      75             : }
      76             : 
      77             : VideoTrack*
      78           0 : VideoTrackList::IndexedGetter(uint32_t aIndex, bool& aFound)
      79             : {
      80           0 :   MediaTrack* track = MediaTrackList::IndexedGetter(aIndex, aFound);
      81           0 :   return track ? track->AsVideoTrack() : nullptr;
      82             : }
      83             : 
      84             : VideoTrack*
      85           0 : VideoTrackList::GetTrackById(const nsAString& aId)
      86             : {
      87           0 :   MediaTrack* track = MediaTrackList::GetTrackById(aId);
      88           0 :   return track ? track->AsVideoTrack() : nullptr;
      89             : }
      90             : 
      91             : } // namespace dom
      92             : } // namespace mozilla

Generated by: LCOV version 1.13