philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 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/modules/video_coding/frame_object.h" |
| 12 | #include "webrtc/base/criticalsection.h" |
| 13 | #include "webrtc/modules/video_coding/packet_buffer.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | namespace video_coding { |
| 17 | |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 18 | FrameObject::FrameObject() |
| 19 | : picture_id(0), |
| 20 | spatial_layer(0), |
philipel | be7a9e5 | 2016-05-19 12:19:35 +0200 | [diff] [blame] | 21 | timestamp(0), |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 22 | num_references(0), |
| 23 | inter_layer_predicted(false) {} |
| 24 | |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 25 | RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 26 | uint16_t first_seq_num, |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame^] | 27 | uint16_t last_seq_num, |
| 28 | size_t frame_size, |
| 29 | int times_nacked) |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 30 | : packet_buffer_(packet_buffer), |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 31 | first_seq_num_(first_seq_num), |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame^] | 32 | last_seq_num_(last_seq_num), |
| 33 | times_nacked_(times_nacked) { |
| 34 | size = frame_size; |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 35 | VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num); |
| 36 | if (packet) { |
| 37 | frame_type_ = packet->frameType; |
| 38 | codec_type_ = packet->codec; |
| 39 | } |
| 40 | } |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 41 | |
| 42 | RtpFrameObject::~RtpFrameObject() { |
| 43 | packet_buffer_->ReturnFrame(this); |
| 44 | } |
| 45 | |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 46 | uint16_t RtpFrameObject::first_seq_num() const { |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 47 | return first_seq_num_; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 48 | } |
| 49 | |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 50 | uint16_t RtpFrameObject::last_seq_num() const { |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 51 | return last_seq_num_; |
| 52 | } |
| 53 | |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame^] | 54 | int RtpFrameObject::times_nacked() const { |
| 55 | return times_nacked_; |
| 56 | } |
| 57 | |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 58 | FrameType RtpFrameObject::frame_type() const { |
| 59 | return frame_type_; |
| 60 | } |
| 61 | |
| 62 | VideoCodecType RtpFrameObject::codec_type() const { |
| 63 | return codec_type_; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 64 | } |
| 65 | |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 66 | bool RtpFrameObject::GetBitstream(uint8_t* destination) const { |
| 67 | return packet_buffer_->GetBitstream(*this, destination); |
| 68 | } |
| 69 | |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 70 | RTPVideoTypeHeader* RtpFrameObject::GetCodecHeader() const { |
| 71 | VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); |
| 72 | if (!packet) |
| 73 | return nullptr; |
| 74 | return &packet->codecSpecificHeader.codecHeader; |
| 75 | } |
| 76 | |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 77 | } // namespace video_coding |
| 78 | } // namespace webrtc |