LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/api/video - video_frame.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 18 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #ifndef WEBRTC_API_VIDEO_VIDEO_FRAME_H_
      12             : #define WEBRTC_API_VIDEO_VIDEO_FRAME_H_
      13             : 
      14             : #include <stdint.h>
      15             : 
      16             : #include "webrtc/api/video/video_rotation.h"
      17             : #include "webrtc/api/video/video_frame_buffer.h"
      18             : 
      19             : // TODO(nisse): Transition hack, some downstream applications expect
      20             : // that including this file also defines base/timeutils.h constants.
      21             : // Delete after applications are fixed to include the right headers.
      22             : #include "webrtc/base/timeutils.h"
      23             : 
      24             : namespace webrtc {
      25             : 
      26           0 : class VideoFrame {
      27             :  public:
      28           0 :   VideoFrame() {
      29           0 :     video_frame_buffer_ = nullptr;
      30           0 :     timestamp_rtp_ = 0;
      31           0 :     timestamp_us_ = 0;
      32           0 :     ntp_time_ms_ = 0;
      33           0 :     rotation_ = kVideoRotation_0;
      34           0 :   }
      35             : 
      36             :   // TODO(nisse): This constructor is consistent with the now deleted
      37             :   // cricket::WebRtcVideoFrame. We should consider whether or not we
      38             :   // want to stick to this style and deprecate the other constructor.
      39             :   VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
      40             :              webrtc::VideoRotation rotation,
      41             :              int64_t timestamp_us);
      42             : 
      43             :   // Preferred constructor.
      44             :   VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
      45             :              uint32_t timestamp,
      46             :              int64_t render_time_ms,
      47             :              VideoRotation rotation);
      48             : 
      49             :   ~VideoFrame();
      50             : 
      51             :   // Support move and copy.
      52             :   VideoFrame(const VideoFrame&);
      53             :   VideoFrame(VideoFrame&&);
      54             :   VideoFrame& operator=(const VideoFrame&);
      55             :   VideoFrame& operator=(VideoFrame&&);
      56             : 
      57             :   // Get frame width.
      58             :   int width() const;
      59             : 
      60             :   // Get frame height.
      61             :   int height() const;
      62             : 
      63             :   // System monotonic clock, same timebase as rtc::TimeMicros().
      64           0 :   int64_t timestamp_us() const { return timestamp_us_; }
      65           0 :   void set_timestamp_us(int64_t timestamp_us) { timestamp_us_ = timestamp_us; }
      66             : 
      67             :   // TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame
      68             :   // merge, timestamps other than timestamp_us will likely be
      69             :   // deprecated.
      70             : 
      71             :   // Set frame timestamp (90kHz).
      72           0 :   void set_timestamp(uint32_t timestamp) { timestamp_rtp_ = timestamp; }
      73             : 
      74             :   // Get frame timestamp (90kHz).
      75           0 :   uint32_t timestamp() const { return timestamp_rtp_; }
      76             : 
      77             :   // For now, transport_frame_id and rtp timestamp are the same.
      78             :   // TODO(nisse): Must be handled differently for QUIC.
      79             :   uint32_t transport_frame_id() const { return timestamp(); }
      80             : 
      81             :   // Set capture ntp time in milliseconds.
      82           0 :   void set_ntp_time_ms(int64_t ntp_time_ms) { ntp_time_ms_ = ntp_time_ms; }
      83             : 
      84             :   // Get capture ntp time in milliseconds.
      85           0 :   int64_t ntp_time_ms() const { return ntp_time_ms_; }
      86             : 
      87             :   // Naming convention for Coordination of Video Orientation. Please see
      88             :   // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
      89             :   //
      90             :   // "pending rotation" or "pending" = a frame that has a VideoRotation > 0.
      91             :   //
      92             :   // "not pending" = a frame that has a VideoRotation == 0.
      93             :   //
      94             :   // "apply rotation" = modify a frame from being "pending" to being "not
      95             :   //                    pending" rotation (a no-op for "unrotated").
      96             :   //
      97           0 :   VideoRotation rotation() const { return rotation_; }
      98           0 :   void set_rotation(VideoRotation rotation) { rotation_ = rotation; }
      99             : 
     100             :   // Set render time in milliseconds.
     101             :   void set_render_time_ms(int64_t render_time_ms);
     102             : 
     103             :   // Get render time in milliseconds.
     104             :   int64_t render_time_ms() const;
     105             : 
     106             :   // Return the underlying buffer. Never nullptr for a properly
     107             :   // initialized VideoFrame.
     108             :   rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const;
     109             : 
     110             :   // TODO(nisse): Deprecated.
     111             :   // Return true if the frame is stored in a texture.
     112           0 :   bool is_texture() const {
     113           0 :     return video_frame_buffer()->native_handle() != nullptr;
     114             :   }
     115             : 
     116             :  private:
     117             :   // An opaque reference counted handle that stores the pixel data.
     118             :   rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
     119             :   uint32_t timestamp_rtp_;
     120             :   int64_t ntp_time_ms_;
     121             :   int64_t timestamp_us_;
     122             :   VideoRotation rotation_;
     123             : };
     124             : 
     125             : }  // namespace webrtc
     126             : 
     127             : #endif  // WEBRTC_API_VIDEO_VIDEO_FRAME_H_

Generated by: LCOV version 1.13