• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/packet.h"
12 
13 #include "api/rtp_headers.h"
14 
15 namespace webrtc {
16 
VCMPacket()17 VCMPacket::VCMPacket()
18     : payloadType(0),
19       timestamp(0),
20       ntp_time_ms_(0),
21       seqNum(0),
22       dataPtr(NULL),
23       sizeBytes(0),
24       markerBit(false),
25       timesNacked(-1),
26       completeNALU(kNaluUnset),
27       insertStartCode(false),
28       video_header() {
29   video_header.playout_delay = {-1, -1};
30 }
31 
VCMPacket(const uint8_t * ptr,size_t size,const RTPHeader & rtp_header,const RTPVideoHeader & videoHeader,int64_t ntp_time_ms,int64_t receive_time_ms)32 VCMPacket::VCMPacket(const uint8_t* ptr,
33                      size_t size,
34                      const RTPHeader& rtp_header,
35                      const RTPVideoHeader& videoHeader,
36                      int64_t ntp_time_ms,
37                      int64_t receive_time_ms)
38     : payloadType(rtp_header.payloadType),
39       timestamp(rtp_header.timestamp),
40       ntp_time_ms_(ntp_time_ms),
41       seqNum(rtp_header.sequenceNumber),
42       dataPtr(ptr),
43       sizeBytes(size),
44       markerBit(rtp_header.markerBit),
45       timesNacked(-1),
46       completeNALU(kNaluIncomplete),
47       insertStartCode(videoHeader.codec == kVideoCodecH264 &&
48                       videoHeader.is_first_packet_in_frame),
49       video_header(videoHeader),
50       packet_info(rtp_header, receive_time_ms) {
51   if (is_first_packet_in_frame() && markerBit) {
52     completeNALU = kNaluComplete;
53   } else if (is_first_packet_in_frame()) {
54     completeNALU = kNaluStart;
55   } else if (markerBit) {
56     completeNALU = kNaluEnd;
57   } else {
58     completeNALU = kNaluIncomplete;
59   }
60 
61   // TODO(nisse): Delete?
62   // Playout decisions are made entirely based on first packet in a frame.
63   if (!is_first_packet_in_frame()) {
64     video_header.playout_delay = {-1, -1};
65   }
66 }
67 
68 VCMPacket::~VCMPacket() = default;
69 
70 }  // namespace webrtc
71