packet.cc (2243B)
1 /* 2 * Copyright (c) 2011 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 "modules/video_coding/deprecated/packet.h" 12 13 #include <cstddef> 14 #include <cstdint> 15 #include <optional> 16 17 #include "api/rtp_headers.h" 18 #include "api/units/timestamp.h" 19 #include "api/video/video_codec_type.h" 20 #include "modules/rtp_rtcp/source/rtp_video_header.h" 21 22 namespace webrtc { 23 24 VCMPacket::VCMPacket() 25 : payloadType(0), 26 timestamp(0), 27 ntp_time_ms_(0), 28 seqNum(0), 29 dataPtr(nullptr), 30 sizeBytes(0), 31 markerBit(false), 32 timesNacked(-1), 33 completeNALU(kNaluUnset), 34 insertStartCode(false), 35 video_header() {} 36 37 VCMPacket::VCMPacket(const uint8_t* ptr, 38 size_t size, 39 const RTPHeader& rtp_header, 40 const RTPVideoHeader& videoHeader, 41 int64_t ntp_time_ms, 42 Timestamp receive_time) 43 : payloadType(rtp_header.payloadType), 44 timestamp(rtp_header.timestamp), 45 ntp_time_ms_(ntp_time_ms), 46 seqNum(rtp_header.sequenceNumber), 47 dataPtr(ptr), 48 sizeBytes(size), 49 markerBit(rtp_header.markerBit), 50 timesNacked(-1), 51 completeNALU(kNaluIncomplete), 52 insertStartCode(videoHeader.codec == kVideoCodecH264 && 53 videoHeader.is_first_packet_in_frame), 54 video_header(videoHeader), 55 packet_info(rtp_header, receive_time) { 56 if (is_first_packet_in_frame() && markerBit) { 57 completeNALU = kNaluComplete; 58 } else if (is_first_packet_in_frame()) { 59 completeNALU = kNaluStart; 60 } else if (markerBit) { 61 completeNALU = kNaluEnd; 62 } else { 63 completeNALU = kNaluIncomplete; 64 } 65 66 // Playout decisions are made entirely based on first packet in a frame. 67 if (!is_first_packet_in_frame()) { 68 video_header.playout_delay = std::nullopt; 69 } 70 } 71 72 VCMPacket::~VCMPacket() = default; 73 74 } // namespace webrtc