2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This file contains the declaration of the VP8 packetizer class.
|
|
|
|
|
* A packetizer object is created for each encoded video frame. The
|
|
|
|
|
* constructor is called with the payload data and size,
|
|
|
|
|
* together with the fragmentation information and a packetizer mode
|
|
|
|
|
* of choice. Alternatively, if no fragmentation info is available, the
|
|
|
|
|
* second constructor can be used with only payload data and size; in that
|
2012-02-23 18:52:53 +00:00
|
|
|
* case the mode kEqualSize is used.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* After creating the packetizer, the method NextPacket is called
|
|
|
|
|
* repeatedly to get all packets for the frame. The method returns
|
|
|
|
|
* false as long as there are more packets left to fetch.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_H_
|
|
|
|
|
#define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <cstdint>
|
2012-01-18 08:21:15 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
2018-09-04 16:11:58 +02:00
|
|
|
#include "absl/container/inlined_vector.h"
|
|
|
|
|
#include "api/array_view.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_format.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
|
|
|
|
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-06 15:56:18 +00:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// Packetizer for VP8.
|
2014-07-31 14:59:24 +00:00
|
|
|
class RtpPacketizerVp8 : public RtpPacketizer {
|
2011-12-06 15:56:18 +00:00
|
|
|
public:
|
2017-10-27 10:19:44 +02:00
|
|
|
// Initialize with payload from encoder.
|
2011-12-06 15:56:18 +00:00
|
|
|
// The payload_data must be exactly one encoded VP8 frame.
|
2018-08-30 11:14:05 +02:00
|
|
|
RtpPacketizerVp8(rtc::ArrayView<const uint8_t> payload,
|
|
|
|
|
PayloadSizeLimits limits,
|
|
|
|
|
const RTPVideoHeaderVP8& hdr_info);
|
2013-07-31 15:17:19 +00:00
|
|
|
|
2018-02-07 09:38:31 +01:00
|
|
|
~RtpPacketizerVp8() override;
|
2014-07-31 14:59:24 +00:00
|
|
|
|
2022-01-21 09:49:39 +09:00
|
|
|
RtpPacketizerVp8(const RtpPacketizerVp8&) = delete;
|
|
|
|
|
RtpPacketizerVp8& operator=(const RtpPacketizerVp8&) = delete;
|
|
|
|
|
|
2018-08-28 19:45:31 +02:00
|
|
|
size_t NumPackets() const override;
|
2011-12-06 15:56:18 +00:00
|
|
|
|
|
|
|
|
// Get the next payload with VP8 payload header.
|
2021-07-28 23:57:33 +02:00
|
|
|
// Write payload and set marker bit of the `packet`.
|
2016-12-05 02:26:44 -08:00
|
|
|
// Returns true on success, false otherwise.
|
2017-05-23 09:34:21 -07:00
|
|
|
bool NextPacket(RtpPacketToSend* packet) override;
|
2014-09-12 11:05:55 +00:00
|
|
|
|
2011-12-06 15:56:18 +00:00
|
|
|
private:
|
2018-09-04 16:11:58 +02:00
|
|
|
// VP8 header can use up to 6 bytes.
|
|
|
|
|
using RawHeader = absl::InlinedVector<uint8_t, 6>;
|
|
|
|
|
static RawHeader BuildHeader(const RTPVideoHeaderVP8& header);
|
|
|
|
|
|
|
|
|
|
RawHeader hdr_;
|
|
|
|
|
rtc::ArrayView<const uint8_t> remaining_payload_;
|
2018-09-07 10:57:26 +02:00
|
|
|
std::vector<int> payload_sizes_;
|
|
|
|
|
std::vector<int>::const_iterator current_packet_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2014-09-12 11:05:55 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_H_
|