2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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.
11 #include "webrtc/modules/interface/module_common_types.h"
12 #include "webrtc/modules/video_coding/main/source/packet.h"
18 VCMPacket::VCMPacket()
26 frameType(kFrameEmpty),
27 codec(kVideoCodecUnknown),
29 completeNALU(kNaluUnset),
30 insertStartCode(false),
33 codecSpecificHeader() {
36 VCMPacket::VCMPacket(const uint8_t* ptr,
38 const WebRtcRTPHeader& rtpHeader) :
39 payloadType(rtpHeader.header.payloadType),
40 timestamp(rtpHeader.header.timestamp),
41 seqNum(rtpHeader.header.sequenceNumber),
44 markerBit(rtpHeader.header.markerBit),
46 frameType(rtpHeader.frameType),
47 codec(kVideoCodecUnknown),
48 isFirstPacket(rtpHeader.type.Video.isFirstPacket),
49 completeNALU(kNaluComplete),
50 insertStartCode(false),
51 width(rtpHeader.type.Video.width),
52 height(rtpHeader.type.Video.height),
53 codecSpecificHeader(rtpHeader.type.Video)
55 CopyCodecSpecifics(rtpHeader.type.Video);
58 VCMPacket::VCMPacket(const uint8_t* ptr, uint32_t size, uint16_t seq, uint32_t ts, bool mBit) :
66 frameType(kVideoFrameDelta),
67 codec(kVideoCodecUnknown),
69 completeNALU(kNaluComplete),
70 insertStartCode(false),
76 void VCMPacket::Reset() {
83 frameType = kFrameEmpty;
84 codec = kVideoCodecUnknown;
85 isFirstPacket = false;
86 completeNALU = kNaluUnset;
87 insertStartCode = false;
90 memset(&codecSpecificHeader, 0, sizeof(RTPVideoHeader));
93 void VCMPacket::CopyCodecSpecifics(const RTPVideoHeader& videoHeader)
95 switch(videoHeader.codec)
99 // Handle all packets within a frame as depending on the previous packet
100 // TODO(holmer): This should be changed to make fragments independent
101 // when the VP8 RTP receiver supports fragments.
102 if (isFirstPacket && markerBit)
103 completeNALU = kNaluComplete;
104 else if (isFirstPacket)
105 completeNALU = kNaluStart;
107 completeNALU = kNaluEnd;
109 completeNALU = kNaluIncomplete;
111 codec = kVideoCodecVP8;
116 codec = kVideoCodecUnknown;