LCOV - code coverage report
Current view: top level - dom/media - MediaTrackList.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 11 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 15 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             : #ifndef mozilla_dom_MediaTrackList_h
       8             : #define mozilla_dom_MediaTrackList_h
       9             : 
      10             : #include "mozilla/DOMEventTargetHelper.h"
      11             : 
      12             : namespace mozilla {
      13             : class DOMMediaStream;
      14             : 
      15             : namespace dom {
      16             : 
      17             : class HTMLMediaElement;
      18             : class MediaTrack;
      19             : class AudioTrackList;
      20             : class VideoTrackList;
      21             : class AudioTrack;
      22             : class VideoTrack;
      23             : class VideoStreamTrack;
      24             : 
      25             : /**
      26             :  * Base class of AudioTrackList and VideoTrackList. The AudioTrackList and
      27             :  * VideoTrackList objects represent a dynamic list of zero or more audio and
      28             :  * video tracks respectively.
      29             :  *
      30             :  * When a media element is to forget its media-resource-specific tracks, its
      31             :  * audio track list and video track list will be emptied.
      32             :  */
      33             : class MediaTrackList : public DOMEventTargetHelper
      34             : {
      35             : public:
      36             :   MediaTrackList(nsPIDOMWindowInner* aOwnerWindow, HTMLMediaElement* aMediaElement);
      37             : 
      38             :   NS_DECL_ISUPPORTS_INHERITED
      39           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaTrackList, DOMEventTargetHelper)
      40             : 
      41             :   using DOMEventTargetHelper::DispatchTrustedEvent;
      42             : 
      43             :   // The return value is non-null, assert an error if aIndex is out of bound
      44             :   // for array mTracks.
      45             :   MediaTrack* operator[](uint32_t aIndex);
      46             : 
      47             :   void AddTrack(MediaTrack* aTrack);
      48             : 
      49             :   // In remove track case, the VideoTrackList::mSelectedIndex should be updated
      50             :   // due to mTracks changed. No need to take care this in add track case.
      51             :   virtual void RemoveTrack(const RefPtr<MediaTrack>& aTrack);
      52             : 
      53             :   void RemoveTracks();
      54             : 
      55             :   static already_AddRefed<AudioTrack>
      56             :   CreateAudioTrack(const nsAString& aId,
      57             :                    const nsAString& aKind,
      58             :                    const nsAString& aLabel,
      59             :                    const nsAString& aLanguage,
      60             :                    bool aEnabled);
      61             : 
      62             :   // For the case of src of HTMLMediaElement is non-MediaStream, leave the
      63             :   // aVideoTrack as default(nullptr).
      64             :   static already_AddRefed<VideoTrack>
      65             :   CreateVideoTrack(const nsAString& aId,
      66             :                    const nsAString& aKind,
      67             :                    const nsAString& aLabel,
      68             :                    const nsAString& aLanguage,
      69             :                    VideoStreamTrack* aVideoTrack = nullptr);
      70             : 
      71             :   virtual void EmptyTracks();
      72             : 
      73             :   void CreateAndDispatchChangeEvent();
      74             : 
      75             :   // WebIDL
      76             :   MediaTrack* IndexedGetter(uint32_t aIndex, bool& aFound);
      77             : 
      78             :   MediaTrack* GetTrackById(const nsAString& aId);
      79             : 
      80           0 :   bool IsEmpty() const
      81             :   {
      82           0 :     return mTracks.IsEmpty();
      83             :   }
      84             : 
      85           0 :   uint32_t Length() const
      86             :   {
      87           0 :     return mTracks.Length();
      88             :   }
      89             : 
      90           0 :   IMPL_EVENT_HANDLER(change)
      91           0 :   IMPL_EVENT_HANDLER(addtrack)
      92           0 :   IMPL_EVENT_HANDLER(removetrack)
      93             : 
      94             :   friend class AudioTrack;
      95             :   friend class VideoTrack;
      96             : 
      97             : protected:
      98             :   virtual ~MediaTrackList();
      99             : 
     100             :   void CreateAndDispatchTrackEventRunner(MediaTrack* aTrack,
     101             :                                          const nsAString& aEventName);
     102             : 
     103           0 :   virtual AudioTrackList* AsAudioTrackList() { return nullptr; }
     104             : 
     105           0 :   virtual VideoTrackList* AsVideoTrackList() { return nullptr; }
     106             : 
     107           0 :   HTMLMediaElement* GetMediaElement() { return mMediaElement; }
     108             : 
     109             :   nsTArray<RefPtr<MediaTrack>> mTracks;
     110             :   RefPtr<HTMLMediaElement> mMediaElement;
     111             : };
     112             : 
     113             : } // namespace dom
     114             : } // namespace mozilla
     115             : 
     116             : #endif // mozilla_dom_MediaTrackList_h

Generated by: LCOV version 1.13