LCOV - code coverage report
Current view: directory - content/media - VideoFrameContainer.h (source / functions) Found Hit Coverage
Test: app.info Lines: 2 0 0.0 %
Date: 2012-06-02 Functions: 3 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
       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 file,
       5                 :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6                 : 
       7                 : #ifndef VIDEOFRAMECONTAINER_H_
       8                 : #define VIDEOFRAMECONTAINER_H_
       9                 : 
      10                 : #include "ImageLayers.h"
      11                 : #include "mozilla/Mutex.h"
      12                 : #include "mozilla/TimeStamp.h"
      13                 : #include "nsISupportsImpl.h"
      14                 : #include "gfxPoint.h"
      15                 : 
      16                 : class nsHTMLMediaElement;
      17                 : 
      18                 : namespace mozilla {
      19                 : 
      20                 : /**
      21                 :  * This object is used in the decoder backend threads and the main thread
      22                 :  * to manage the "current video frame" state. This state includes timing data
      23                 :  * and an intrinsic size (see below).
      24                 :  * This has to be a thread-safe object since it's accessed by resource decoders
      25                 :  * and other off-main-thread components. So we can't put this state in the media
      26                 :  * element itself ... well, maybe we could, but it could be risky and/or
      27                 :  * confusing.
      28                 :  */
      29               0 : class VideoFrameContainer {
      30                 : public:
      31                 :   typedef mozilla::layers::ImageContainer ImageContainer;
      32                 :   typedef mozilla::layers::Image Image;
      33                 : 
      34               0 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoFrameContainer)
      35                 : 
      36                 :   VideoFrameContainer(nsHTMLMediaElement* aElement,
      37                 :                       already_AddRefed<ImageContainer> aContainer)
      38                 :     : mElement(aElement),
      39                 :       mImageContainer(aContainer), mMutex("nsVideoFrameContainer"),
      40                 :       mIntrinsicSizeChanged(false), mImageSizeChanged(false)
      41                 :   {
      42                 :     NS_ASSERTION(aElement, "aElement must not be null");
      43                 :     NS_ASSERTION(mImageContainer, "aContainer must not be null");
      44                 :   }
      45                 :   // Call on any thread
      46                 :   void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage,
      47                 :                        TimeStamp aTargetTime);
      48                 :   // Time in seconds by which the last painted video frame was late by.
      49                 :   // E.g. if the last painted frame should have been painted at time t,
      50                 :   // but was actually painted at t+n, this returns n in seconds. Threadsafe.
      51                 :   double GetFrameDelay();
      52                 :   // Call on main thread
      53                 :   void Invalidate();
      54                 :   ImageContainer* GetImageContainer() { return mImageContainer; }
      55                 :   void ForgetElement() { mElement = nsnull; }
      56                 : 
      57                 : protected:
      58                 :   // Non-addreffed pointer to the element. The element calls ForgetElement
      59                 :   // to clear this reference when the element is destroyed.
      60                 :   nsHTMLMediaElement* mElement;
      61                 :   nsRefPtr<ImageContainer> mImageContainer;
      62                 : 
      63                 :   // mMutex protects all the fields below.
      64                 :   Mutex mMutex;
      65                 :   // The intrinsic size is the ideal size which we should render the
      66                 :   // ImageContainer's current Image at.
      67                 :   // This can differ from the Image's actual size when the media resource
      68                 :   // specifies that the Image should be stretched to have the correct aspect
      69                 :   // ratio.
      70                 :   gfxIntSize mIntrinsicSize;
      71                 :   // The time at which the current video frame should have been painted.
      72                 :   // Access protected by mVideoUpdateLock.
      73                 :   TimeStamp mPaintTarget;
      74                 :   // The delay between the last video frame being presented and it being
      75                 :   // painted. This is time elapsed after mPaintTarget until the most recently
      76                 :   // painted frame appeared on screen.
      77                 :   TimeDuration mPaintDelay;
      78                 :   // True when the intrinsic size has been changed by SetCurrentFrame() since
      79                 :   // the last call to Invalidate().
      80                 :   // The next call to Invalidate() will recalculate
      81                 :   // and update the intrinsic size on the element, request a frame reflow and
      82                 :   // then reset this flag.
      83                 :   bool mIntrinsicSizeChanged;
      84                 :   // True when the Image size has changed since the last time Invalidate() was
      85                 :   // called. When set, the next call to Invalidate() will ensure that the
      86                 :   // frame is fully invalidated instead of just invalidating for the image change
      87                 :   // in the ImageLayer.
      88                 :   bool mImageSizeChanged;
      89                 : };
      90                 : 
      91                 : }
      92                 : 
      93                 : #endif /* VIDEOFRAMECONTAINER_H_ */

Generated by: LCOV version 1.7