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

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2016 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             : #include "webrtc/base/checks.h"
      12             : #include "webrtc/modules/video_coding/frame_object.h"
      13             : #include "webrtc/modules/video_coding/packet_buffer.h"
      14             : 
      15             : namespace webrtc {
      16             : namespace video_coding {
      17             : 
      18           0 : FrameObject::FrameObject()
      19             :     : picture_id(0),
      20             :       spatial_layer(0),
      21             :       timestamp(0),
      22             :       num_references(0),
      23           0 :       inter_layer_predicted(false) {}
      24             : 
      25           0 : RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer,
      26             :                                uint16_t first_seq_num,
      27             :                                uint16_t last_seq_num,
      28             :                                size_t frame_size,
      29             :                                int times_nacked,
      30           0 :                                int64_t received_time)
      31             :     : packet_buffer_(packet_buffer),
      32             :       first_seq_num_(first_seq_num),
      33             :       last_seq_num_(last_seq_num),
      34             :       received_time_(received_time),
      35           0 :       times_nacked_(times_nacked) {
      36           0 :   VCMPacket* first_packet = packet_buffer_->GetPacket(first_seq_num);
      37           0 :   RTC_DCHECK(first_packet);
      38             : 
      39             :   // RtpFrameObject members
      40           0 :   frame_type_ = first_packet->frameType;
      41           0 :   codec_type_ = first_packet->codec;
      42             : 
      43             :   // TODO(philipel): Remove when encoded image is replaced by FrameObject.
      44             :   // VCMEncodedFrame members
      45           0 :   CopyCodecSpecific(&first_packet->video_header);
      46           0 :   _completeFrame = true;
      47           0 :   _payloadType = first_packet->payloadType;
      48           0 :   _timeStamp = first_packet->timestamp;
      49           0 :   ntp_time_ms_ = first_packet->ntp_time_ms_;
      50             : 
      51             :   // Since FFmpeg use an optimized bitstream reader that reads in chunks of
      52             :   // 32/64 bits we have to add at least that much padding to the buffer
      53             :   // to make sure the decoder doesn't read out of bounds.
      54             :   // NOTE! EncodedImage::_size is the size of the buffer (think capacity of
      55             :   //       an std::vector) and EncodedImage::_length is the actual size of
      56             :   //       the bitstream (think size of an std::vector).
      57           0 :   if (codec_type_ == kVideoCodecH264)
      58           0 :     _size = frame_size + EncodedImage::kBufferPaddingBytesH264;
      59             :   else
      60           0 :     _size = frame_size;
      61             : 
      62           0 :   _buffer = new uint8_t[_size];
      63           0 :   _length = frame_size;
      64           0 :   _frameType = first_packet->frameType;
      65           0 :   GetBitstream(_buffer);
      66           0 :   _encodedWidth = first_packet->width;
      67           0 :   _encodedHeight = first_packet->height;
      68             : 
      69             :   // FrameObject members
      70           0 :   timestamp = first_packet->timestamp;
      71             : 
      72           0 :   VCMPacket* last_packet = packet_buffer_->GetPacket(last_seq_num);
      73           0 :   RTC_DCHECK(last_packet && last_packet->markerBit);
      74             :   // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
      75             :   // ts_126114v120700p.pdf Section 7.4.5.
      76             :   // The MTSI client shall add the payload bytes as defined in this clause
      77             :   // onto the last RTP packet in each group of packets which make up a key
      78             :   // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265
      79             :   // (HEVC)).
      80           0 :   rotation_ = last_packet->video_header.rotation;
      81           0 :   _rotation_set = true;
      82           0 : }
      83             : 
      84           0 : RtpFrameObject::~RtpFrameObject() {
      85           0 :   packet_buffer_->ReturnFrame(this);
      86           0 : }
      87             : 
      88           0 : uint16_t RtpFrameObject::first_seq_num() const {
      89           0 :   return first_seq_num_;
      90             : }
      91             : 
      92           0 : uint16_t RtpFrameObject::last_seq_num() const {
      93           0 :   return last_seq_num_;
      94             : }
      95             : 
      96           0 : int RtpFrameObject::times_nacked() const {
      97           0 :   return times_nacked_;
      98             : }
      99             : 
     100           0 : FrameType RtpFrameObject::frame_type() const {
     101           0 :   return frame_type_;
     102             : }
     103             : 
     104           0 : VideoCodecType RtpFrameObject::codec_type() const {
     105           0 :   return codec_type_;
     106             : }
     107             : 
     108           0 : bool RtpFrameObject::GetBitstream(uint8_t* destination) const {
     109           0 :   return packet_buffer_->GetBitstream(*this, destination);
     110             : }
     111             : 
     112           0 : uint32_t RtpFrameObject::Timestamp() const {
     113           0 :   return timestamp_;
     114             : }
     115             : 
     116           0 : int64_t RtpFrameObject::ReceivedTime() const {
     117           0 :   return received_time_;
     118             : }
     119             : 
     120           0 : int64_t RtpFrameObject::RenderTime() const {
     121           0 :   return _renderTimeMs;
     122             : }
     123             : 
     124           0 : rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const {
     125           0 :   rtc::CritScope lock(&packet_buffer_->crit_);
     126           0 :   VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_);
     127           0 :   if (!packet)
     128           0 :     return rtc::Optional<RTPVideoTypeHeader>();
     129           0 :   return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader);
     130             : }
     131             : 
     132             : }  // namespace video_coding
     133             : }  // namespace webrtc

Generated by: LCOV version 1.13