LCOV - code coverage report
Current view: top level - dom/media/gmp - GMPVideoHost.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 53 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 12 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 "GMPVideoHost.h"
       7             : #include "mozilla/Assertions.h"
       8             : #include "GMPVideoi420FrameImpl.h"
       9             : #include "GMPVideoEncodedFrameImpl.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace gmp {
      13             : 
      14           0 : GMPVideoHostImpl::GMPVideoHostImpl(GMPSharedMemManager* aSharedMemMgr)
      15           0 : : mSharedMemMgr(aSharedMemMgr)
      16             : {
      17           0 : }
      18             : 
      19           0 : GMPVideoHostImpl::~GMPVideoHostImpl()
      20             : {
      21           0 : }
      22             : 
      23             : GMPErr
      24           0 : GMPVideoHostImpl::CreateFrame(GMPVideoFrameFormat aFormat, GMPVideoFrame** aFrame)
      25             : {
      26           0 :   if (!mSharedMemMgr) {
      27           0 :     return GMPGenericErr;
      28             :   }
      29             : 
      30           0 :   if (!aFrame) {
      31           0 :     return GMPGenericErr;
      32             :   }
      33           0 :   *aFrame = nullptr;
      34             : 
      35           0 :   switch (aFormat) {
      36             :     case kGMPI420VideoFrame:
      37           0 :       *aFrame = new GMPVideoi420FrameImpl(this);
      38           0 :       return GMPNoErr;
      39             :     case kGMPEncodedVideoFrame:
      40           0 :       *aFrame = new GMPVideoEncodedFrameImpl(this);
      41           0 :       return GMPNoErr;
      42             :     default:
      43           0 :       NS_NOTREACHED("Unknown frame format!");
      44             :   }
      45             : 
      46           0 :   return GMPGenericErr;
      47             : }
      48             : 
      49             : GMPErr
      50           0 : GMPVideoHostImpl::CreatePlane(GMPPlane** aPlane)
      51             : {
      52           0 :   if (!mSharedMemMgr) {
      53           0 :     return GMPGenericErr;
      54             :   }
      55             : 
      56           0 :   if (!aPlane) {
      57           0 :     return GMPGenericErr;
      58             :   }
      59           0 :   *aPlane = nullptr;
      60             : 
      61           0 :   auto p = new GMPPlaneImpl(this);
      62             : 
      63           0 :   *aPlane = p;
      64             : 
      65           0 :   return GMPNoErr;
      66             : }
      67             : 
      68             : GMPSharedMemManager*
      69           0 : GMPVideoHostImpl::SharedMemMgr()
      70             : {
      71           0 :   return mSharedMemMgr;
      72             : }
      73             : 
      74             : // XXX This should merge with ActorDestroyed
      75             : void
      76           0 : GMPVideoHostImpl::DoneWithAPI()
      77             : {
      78           0 :   ActorDestroyed();
      79           0 : }
      80             : 
      81             : void
      82           0 : GMPVideoHostImpl::ActorDestroyed()
      83             : {
      84           0 :   for (uint32_t i = mPlanes.Length(); i > 0; i--) {
      85           0 :     mPlanes[i - 1]->DoneWithAPI();
      86           0 :     mPlanes.RemoveElementAt(i - 1);
      87             :   }
      88           0 :   for (uint32_t i = mEncodedFrames.Length(); i > 0; i--) {
      89           0 :     mEncodedFrames[i - 1]->DoneWithAPI();
      90           0 :     mEncodedFrames.RemoveElementAt(i - 1);
      91             :   }
      92           0 :   mSharedMemMgr = nullptr;
      93           0 : }
      94             : 
      95             : void
      96           0 : GMPVideoHostImpl::PlaneCreated(GMPPlaneImpl* aPlane)
      97             : {
      98           0 :   mPlanes.AppendElement(aPlane);
      99           0 : }
     100             : 
     101             : void
     102           0 : GMPVideoHostImpl::PlaneDestroyed(GMPPlaneImpl* aPlane)
     103             : {
     104           0 :   MOZ_ALWAYS_TRUE(mPlanes.RemoveElement(aPlane));
     105           0 : }
     106             : 
     107             : void
     108           0 : GMPVideoHostImpl::EncodedFrameCreated(GMPVideoEncodedFrameImpl* aEncodedFrame)
     109             : {
     110           0 :   mEncodedFrames.AppendElement(aEncodedFrame);
     111           0 : }
     112             : 
     113             : void
     114           0 : GMPVideoHostImpl::EncodedFrameDestroyed(GMPVideoEncodedFrameImpl* aFrame)
     115             : {
     116           0 :   MOZ_ALWAYS_TRUE(mEncodedFrames.RemoveElement(aFrame));
     117           0 : }
     118             : 
     119             : } // namespace gmp
     120             : } // namespace mozilla

Generated by: LCOV version 1.13