packet.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #ifndef MODULES_VIDEO_CODING_PACKET_H_
  11. #define MODULES_VIDEO_CODING_PACKET_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include "absl/types/optional.h"
  15. #include "api/rtp_headers.h"
  16. #include "api/rtp_packet_info.h"
  17. #include "api/video/video_frame_type.h"
  18. #include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h"
  19. #include "modules/rtp_rtcp/source/rtp_video_header.h"
  20. namespace webrtc {
  21. // Used to indicate if a received packet contain a complete NALU (or equivalent)
  22. enum VCMNaluCompleteness {
  23. kNaluUnset = 0, // Packet has not been filled.
  24. kNaluComplete = 1, // Packet can be decoded as is.
  25. kNaluStart, // Packet contain beginning of NALU
  26. kNaluIncomplete, // Packet is not beginning or end of NALU
  27. kNaluEnd, // Packet is the end of a NALU
  28. };
  29. class VCMPacket {
  30. public:
  31. VCMPacket();
  32. VCMPacket(const uint8_t* ptr,
  33. size_t size,
  34. const RTPHeader& rtp_header,
  35. const RTPVideoHeader& video_header,
  36. int64_t ntp_time_ms,
  37. int64_t receive_time_ms);
  38. ~VCMPacket();
  39. VideoCodecType codec() const { return video_header.codec; }
  40. int width() const { return video_header.width; }
  41. int height() const { return video_header.height; }
  42. bool is_first_packet_in_frame() const {
  43. return video_header.is_first_packet_in_frame;
  44. }
  45. bool is_last_packet_in_frame() const {
  46. return video_header.is_last_packet_in_frame;
  47. }
  48. uint8_t payloadType;
  49. uint32_t timestamp;
  50. // NTP time of the capture time in local timebase in milliseconds.
  51. int64_t ntp_time_ms_;
  52. uint16_t seqNum;
  53. const uint8_t* dataPtr;
  54. size_t sizeBytes;
  55. bool markerBit;
  56. int timesNacked;
  57. VCMNaluCompleteness completeNALU; // Default is kNaluIncomplete.
  58. bool insertStartCode; // True if a start code should be inserted before this
  59. // packet.
  60. RTPVideoHeader video_header;
  61. absl::optional<RtpGenericFrameDescriptor> generic_descriptor;
  62. RtpPacketInfo packet_info;
  63. };
  64. } // namespace webrtc
  65. #endif // MODULES_VIDEO_CODING_PACKET_H_