2014-07-31 14:59:24 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_
|
|
|
|
|
#define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_
|
2014-07-31 14:59:24 +00:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2018-08-28 19:45:31 +02:00
|
|
|
#include <memory>
|
2018-09-04 16:11:58 +02:00
|
|
|
#include <vector>
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2019-05-23 13:21:12 +02:00
|
|
|
#include "absl/types/optional.h"
|
2018-08-28 19:45:31 +02:00
|
|
|
#include "api/array_view.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_video_header.h"
|
2014-07-31 14:59:24 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2018-10-23 12:03:01 +02:00
|
|
|
|
2016-12-05 02:26:44 -08:00
|
|
|
class RtpPacketToSend;
|
2014-07-31 14:59:24 +00:00
|
|
|
|
|
|
|
|
class RtpPacketizer {
|
|
|
|
|
public:
|
2018-08-28 19:45:31 +02:00
|
|
|
struct PayloadSizeLimits {
|
2018-09-07 10:57:26 +02:00
|
|
|
int max_payload_len = 1200;
|
|
|
|
|
int first_packet_reduction_len = 0;
|
|
|
|
|
int last_packet_reduction_len = 0;
|
2018-10-12 17:51:22 +02:00
|
|
|
// Reduction len for packet that is first & last at the same time.
|
|
|
|
|
int single_packet_reduction_len = 0;
|
2018-08-28 19:45:31 +02:00
|
|
|
};
|
2019-05-23 13:21:12 +02:00
|
|
|
|
|
|
|
|
// If type is not set, returns a raw packetizer.
|
2018-08-28 19:45:31 +02:00
|
|
|
static std::unique_ptr<RtpPacketizer> Create(
|
2019-05-23 13:21:12 +02:00
|
|
|
absl::optional<VideoCodecType> type,
|
2018-08-28 19:45:31 +02:00
|
|
|
rtc::ArrayView<const uint8_t> payload,
|
|
|
|
|
PayloadSizeLimits limits,
|
|
|
|
|
// Codec-specific details.
|
2020-07-21 15:01:50 +02:00
|
|
|
const RTPVideoHeader& rtp_video_header);
|
2014-07-31 14:59:24 +00:00
|
|
|
|
2018-08-28 19:45:31 +02:00
|
|
|
virtual ~RtpPacketizer() = default;
|
2014-07-31 14:59:24 +00:00
|
|
|
|
2018-08-28 19:45:31 +02:00
|
|
|
// Returns number of remaining packets to produce by the packetizer.
|
|
|
|
|
virtual size_t NumPackets() const = 0;
|
2014-07-31 14:59:24 +00:00
|
|
|
|
|
|
|
|
// Get the next payload with payload header.
|
2016-12-05 02:26:44 -08:00
|
|
|
// Write payload and set marker bit of the |packet|.
|
|
|
|
|
// Returns true on success, false otherwise.
|
2017-05-23 09:34:21 -07:00
|
|
|
virtual bool NextPacket(RtpPacketToSend* packet) = 0;
|
2018-09-04 16:11:58 +02:00
|
|
|
|
|
|
|
|
// Split payload_len into sum of integers with respect to |limits|.
|
2018-09-07 10:57:26 +02:00
|
|
|
// Returns empty vector on failure.
|
|
|
|
|
static std::vector<int> SplitAboutEqually(int payload_len,
|
|
|
|
|
const PayloadSizeLimits& limits);
|
2014-07-31 14:59:24 +00:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_
|