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
|
|
|
#include "modules/rtp_rtcp/source/rtp_format.h"
|
2014-07-31 14:59:24 +00:00
|
|
|
|
2016-12-06 05:36:03 -08:00
|
|
|
#include <utility>
|
|
|
|
|
|
2018-08-28 19:45:31 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_format_h264.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtp_format_video_generic.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtp_format_vp8.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtp_format_vp9.h"
|
2014-07-31 14:59:24 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2018-08-28 19:45:31 +02:00
|
|
|
|
|
|
|
|
std::unique_ptr<RtpPacketizer> RtpPacketizer::Create(
|
|
|
|
|
VideoCodecType type,
|
|
|
|
|
rtc::ArrayView<const uint8_t> payload,
|
|
|
|
|
PayloadSizeLimits limits,
|
|
|
|
|
// Codec-specific details.
|
|
|
|
|
const RTPVideoHeader& rtp_video_header,
|
|
|
|
|
FrameType frame_type,
|
|
|
|
|
const RTPFragmentationHeader* fragmentation) {
|
2014-07-31 14:59:24 +00:00
|
|
|
switch (type) {
|
2018-08-02 14:03:53 +02:00
|
|
|
case kVideoCodecH264: {
|
|
|
|
|
const auto& h264 =
|
2018-08-28 19:45:31 +02:00
|
|
|
absl::get<RTPVideoHeaderH264>(rtp_video_header.video_type_header);
|
|
|
|
|
auto packetizer = absl::make_unique<RtpPacketizerH264>(
|
|
|
|
|
limits.max_payload_len, limits.last_packet_reduction_len,
|
|
|
|
|
h264.packetization_mode);
|
|
|
|
|
packetizer->SetPayloadData(payload.data(), payload.size(), fragmentation);
|
|
|
|
|
return std::move(packetizer);
|
|
|
|
|
}
|
|
|
|
|
case kVideoCodecVP8: {
|
|
|
|
|
const auto& vp8 =
|
|
|
|
|
absl::get<RTPVideoHeaderVP8>(rtp_video_header.video_type_header);
|
|
|
|
|
auto packetizer = absl::make_unique<RtpPacketizerVp8>(
|
|
|
|
|
vp8, limits.max_payload_len, limits.last_packet_reduction_len);
|
|
|
|
|
packetizer->SetPayloadData(payload.data(), payload.size(), nullptr);
|
|
|
|
|
return std::move(packetizer);
|
2018-08-02 14:03:53 +02:00
|
|
|
}
|
2018-08-08 14:26:00 +02:00
|
|
|
case kVideoCodecVP9: {
|
|
|
|
|
const auto& vp9 =
|
2018-08-28 19:45:31 +02:00
|
|
|
absl::get<RTPVideoHeaderVP9>(rtp_video_header.video_type_header);
|
|
|
|
|
auto packetizer = absl::make_unique<RtpPacketizerVp9>(
|
|
|
|
|
vp9, limits.max_payload_len, limits.last_packet_reduction_len);
|
|
|
|
|
packetizer->SetPayloadData(payload.data(), payload.size(), nullptr);
|
|
|
|
|
return std::move(packetizer);
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
auto packetizer = absl::make_unique<RtpPacketizerGeneric>(
|
|
|
|
|
rtp_video_header, frame_type, limits.max_payload_len,
|
|
|
|
|
limits.last_packet_reduction_len);
|
|
|
|
|
packetizer->SetPayloadData(payload.data(), payload.size(), nullptr);
|
|
|
|
|
return std::move(packetizer);
|
2018-08-08 14:26:00 +02:00
|
|
|
}
|
2014-07-31 14:59:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 11:14:38 +02:00
|
|
|
RtpDepacketizer* RtpDepacketizer::Create(VideoCodecType type) {
|
2014-07-31 14:59:24 +00:00
|
|
|
switch (type) {
|
2018-06-04 11:14:38 +02:00
|
|
|
case kVideoCodecH264:
|
2014-09-29 08:00:22 +00:00
|
|
|
return new RtpDepacketizerH264();
|
2018-06-04 11:14:38 +02:00
|
|
|
case kVideoCodecVP8:
|
2014-09-29 08:00:22 +00:00
|
|
|
return new RtpDepacketizerVp8();
|
2018-06-04 11:14:38 +02:00
|
|
|
case kVideoCodecVP9:
|
2015-07-28 04:02:54 -07:00
|
|
|
return new RtpDepacketizerVp9();
|
2018-08-09 06:18:57 +00:00
|
|
|
default:
|
2018-08-09 16:16:34 +02:00
|
|
|
return new RtpDepacketizerGeneric();
|
2014-07-31 14:59:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // namespace webrtc
|