blob: 7b9ec0d283596ef10bde59e3b4f36b776e31c5a0 [file] [log] [blame]
philipelc707ab72016-04-01 02:01:54 -07001/*
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
15namespace webrtc {
16namespace video_coding {
17
philipela1059872016-05-09 11:41:48 +020018FrameObject::FrameObject()
19 : picture_id(0),
20 spatial_layer(0),
philipelbe7a9e52016-05-19 12:19:35 +020021 timestamp(0),
philipela1059872016-05-09 11:41:48 +020022 num_references(0),
23 inter_layer_predicted(false) {}
24
philipelc707ab72016-04-01 02:01:54 -070025RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer,
philipel02447bc2016-05-13 06:01:03 -070026 uint16_t first_seq_num,
27 uint16_t last_seq_num)
philipelc707ab72016-04-01 02:01:54 -070028 : packet_buffer_(packet_buffer),
philipel02447bc2016-05-13 06:01:03 -070029 first_seq_num_(first_seq_num),
30 last_seq_num_(last_seq_num) {
31 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num);
32 if (packet) {
33 frame_type_ = packet->frameType;
34 codec_type_ = packet->codec;
35 }
36}
philipelc707ab72016-04-01 02:01:54 -070037
38RtpFrameObject::~RtpFrameObject() {
39 packet_buffer_->ReturnFrame(this);
40}
41
philipelf4139332016-04-20 10:26:34 +020042uint16_t RtpFrameObject::first_seq_num() const {
philipel02447bc2016-05-13 06:01:03 -070043 return first_seq_num_;
philipelc707ab72016-04-01 02:01:54 -070044}
45
philipelf4139332016-04-20 10:26:34 +020046uint16_t RtpFrameObject::last_seq_num() const {
philipel02447bc2016-05-13 06:01:03 -070047 return last_seq_num_;
48}
49
50FrameType RtpFrameObject::frame_type() const {
51 return frame_type_;
52}
53
54VideoCodecType RtpFrameObject::codec_type() const {
55 return codec_type_;
philipelc707ab72016-04-01 02:01:54 -070056}
57
philipelc707ab72016-04-01 02:01:54 -070058bool RtpFrameObject::GetBitstream(uint8_t* destination) const {
59 return packet_buffer_->GetBitstream(*this, destination);
60}
61
philipel02447bc2016-05-13 06:01:03 -070062RTPVideoTypeHeader* RtpFrameObject::GetCodecHeader() const {
63 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_);
64 if (!packet)
65 return nullptr;
66 return &packet->codecSpecificHeader.codecHeader;
67}
68
philipelc707ab72016-04-01 02:01:54 -070069} // namespace video_coding
70} // namespace webrtc