rtp_format.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2014 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_RTP_RTCP_SOURCE_RTP_FORMAT_H_
  11. #define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_
  12. #include <stdint.h>
  13. #include <memory>
  14. #include <vector>
  15. #include "absl/types/optional.h"
  16. #include "api/array_view.h"
  17. #include "modules/rtp_rtcp/source/rtp_video_header.h"
  18. namespace webrtc {
  19. class RtpPacketToSend;
  20. class RtpPacketizer {
  21. public:
  22. struct PayloadSizeLimits {
  23. int max_payload_len = 1200;
  24. int first_packet_reduction_len = 0;
  25. int last_packet_reduction_len = 0;
  26. // Reduction len for packet that is first & last at the same time.
  27. int single_packet_reduction_len = 0;
  28. };
  29. // If type is not set, returns a raw packetizer.
  30. static std::unique_ptr<RtpPacketizer> Create(
  31. absl::optional<VideoCodecType> type,
  32. rtc::ArrayView<const uint8_t> payload,
  33. PayloadSizeLimits limits,
  34. // Codec-specific details.
  35. const RTPVideoHeader& rtp_video_header);
  36. virtual ~RtpPacketizer() = default;
  37. // Returns number of remaining packets to produce by the packetizer.
  38. virtual size_t NumPackets() const = 0;
  39. // Get the next payload with payload header.
  40. // Write payload and set marker bit of the |packet|.
  41. // Returns true on success, false otherwise.
  42. virtual bool NextPacket(RtpPacketToSend* packet) = 0;
  43. // Split payload_len into sum of integers with respect to |limits|.
  44. // Returns empty vector on failure.
  45. static std::vector<int> SplitAboutEqually(int payload_len,
  46. const PayloadSizeLimits& limits);
  47. };
  48. } // namespace webrtc
  49. #endif // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_