blob: 9aa2d5ce08c4ee88bb2ea5db81888f91099e3dd5 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_PACKET_H_
12#define MODULES_VIDEO_CODING_PACKET_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
16
17#include "absl/types/optional.h"
Niels Möller075e7fd2019-03-12 12:29:22 +010018#include "api/rtp_headers.h"
Chen Xingf00bf422019-06-20 10:05:55 +020019#include "api/rtp_packet_info.h"
Johannes Kronf7de74c2021-04-30 13:10:56 +020020#include "api/units/timestamp.h"
Niels Möller8f7ce222019-03-21 15:43:58 +010021#include "api/video/video_frame_type.h"
philipel2837edc2018-10-02 13:55:47 +020022#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h"
Yves Gerey3e707812018-11-28 16:47:49 +010023#include "modules/rtp_rtcp/source/rtp_video_header.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000024
pbos@webrtc.org3004c792013-05-07 12:36:21 +000025namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000026
Niels Möller075e7fd2019-03-12 12:29:22 +010027// Used to indicate if a received packet contain a complete NALU (or equivalent)
28enum VCMNaluCompleteness {
29 kNaluUnset = 0, // Packet has not been filled.
30 kNaluComplete = 1, // Packet can be decoded as is.
31 kNaluStart, // Packet contain beginning of NALU
32 kNaluIncomplete, // Packet is not beginning or end of NALU
33 kNaluEnd, // Packet is the end of a NALU
34};
35
pbos@webrtc.org3004c792013-05-07 12:36:21 +000036class VCMPacket {
philipel9d3ab612015-12-21 04:12:39 -080037 public:
38 VCMPacket();
Niels Möller0cb858c2019-03-06 14:09:54 +010039
philipel9d3ab612015-12-21 04:12:39 -080040 VCMPacket(const uint8_t* ptr,
Niels Möller0cb858c2019-03-06 14:09:54 +010041 size_t size,
42 const RTPHeader& rtp_header,
43 const RTPVideoHeader& video_header,
Chen Xingf00bf422019-06-20 10:05:55 +020044 int64_t ntp_time_ms,
Johannes Kronf7de74c2021-04-30 13:10:56 +020045 Timestamp receive_time);
niklase@google.com470e71d2011-07-07 08:21:25 +000046
philipel2837edc2018-10-02 13:55:47 +020047 ~VCMPacket();
48
Niels Möllerd5e02f02019-02-20 13:12:21 +010049 VideoCodecType codec() const { return video_header.codec; }
50 int width() const { return video_header.width; }
51 int height() const { return video_header.height; }
52
53 bool is_first_packet_in_frame() const {
54 return video_header.is_first_packet_in_frame;
55 }
56 bool is_last_packet_in_frame() const {
57 return video_header.is_last_packet_in_frame;
58 }
59
philipel9d3ab612015-12-21 04:12:39 -080060 uint8_t payloadType;
61 uint32_t timestamp;
62 // NTP time of the capture time in local timebase in milliseconds.
63 int64_t ntp_time_ms_;
64 uint16_t seqNum;
65 const uint8_t* dataPtr;
66 size_t sizeBytes;
67 bool markerBit;
philipel5ceaaae2016-05-24 10:20:47 +020068 int timesNacked;
niklase@google.com470e71d2011-07-07 08:21:25 +000069
philipel9d3ab612015-12-21 04:12:39 -080070 VCMNaluCompleteness completeNALU; // Default is kNaluIncomplete.
71 bool insertStartCode; // True if a start code should be inserted before this
72 // packet.
isheriff6b4b5f32016-06-08 00:24:21 -070073 RTPVideoHeader video_header;
philipel2837edc2018-10-02 13:55:47 +020074 absl::optional<RtpGenericFrameDescriptor> generic_descriptor;
niklase@google.com470e71d2011-07-07 08:21:25 +000075
Chen Xingf00bf422019-06-20 10:05:55 +020076 RtpPacketInfo packet_info;
niklase@google.com470e71d2011-07-07 08:21:25 +000077};
78
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000079} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020080#endif // MODULES_VIDEO_CODING_PACKET_H_