2019-12-05 16:24:04 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "modules/rtp_rtcp/source/create_video_rtp_depacketizer.h"
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
#include "absl/memory/memory.h"
|
|
|
|
|
#include "absl/types/optional.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/video_rtp_depacketizer.h"
|
2020-01-10 17:26:53 +01:00
|
|
|
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_av1.h"
|
2019-12-23 13:14:28 +01:00
|
|
|
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h"
|
2020-01-09 18:55:02 +01:00
|
|
|
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_h264.h"
|
2019-12-11 11:24:37 +01:00
|
|
|
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.h"
|
2019-12-16 13:19:28 +01:00
|
|
|
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.h"
|
2019-12-05 16:24:04 +01:00
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/copy_on_write_buffer.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
// Wrapper over legacy RtpDepacketizer interface.
|
|
|
|
|
// TODO(bugs.webrtc.org/11152): Delete when all RtpDepacketizers updated to
|
|
|
|
|
// the VideoRtpDepacketizer interface.
|
2020-01-07 10:36:49 +01:00
|
|
|
template <typename Depacketizer>
|
|
|
|
|
class Legacy : public VideoRtpDepacketizer {
|
2019-12-05 16:24:04 +01:00
|
|
|
public:
|
|
|
|
|
absl::optional<ParsedRtpPayload> Parse(
|
|
|
|
|
rtc::CopyOnWriteBuffer rtp_payload) override {
|
2020-01-07 10:36:49 +01:00
|
|
|
Depacketizer depacketizer;
|
2019-12-05 16:24:04 +01:00
|
|
|
RtpDepacketizer::ParsedPayload parsed_payload;
|
2020-01-07 10:36:49 +01:00
|
|
|
if (!depacketizer.Parse(&parsed_payload, rtp_payload.cdata(),
|
|
|
|
|
rtp_payload.size())) {
|
2019-12-05 16:24:04 +01:00
|
|
|
return absl::nullopt;
|
|
|
|
|
}
|
|
|
|
|
absl::optional<ParsedRtpPayload> result(absl::in_place);
|
|
|
|
|
result->video_header = parsed_payload.video;
|
|
|
|
|
result->video_payload.SetData(parsed_payload.payload,
|
|
|
|
|
parsed_payload.payload_length);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<VideoRtpDepacketizer> CreateVideoRtpDepacketizer(
|
|
|
|
|
VideoCodecType codec) {
|
2019-12-11 11:24:37 +01:00
|
|
|
switch (codec) {
|
2019-12-23 13:14:28 +01:00
|
|
|
case kVideoCodecH264:
|
2020-01-07 10:36:49 +01:00
|
|
|
return std::make_unique<Legacy<RtpDepacketizerH264>>();
|
2019-12-11 11:24:37 +01:00
|
|
|
case kVideoCodecVP8:
|
|
|
|
|
return std::make_unique<VideoRtpDepacketizerVp8>();
|
2019-12-16 13:19:28 +01:00
|
|
|
case kVideoCodecVP9:
|
|
|
|
|
return std::make_unique<VideoRtpDepacketizerVp9>();
|
2019-12-23 13:14:28 +01:00
|
|
|
case kVideoCodecAV1:
|
2020-01-10 17:26:53 +01:00
|
|
|
return std::make_unique<VideoRtpDepacketizerAv1>();
|
2019-12-23 13:14:28 +01:00
|
|
|
case kVideoCodecGeneric:
|
|
|
|
|
case kVideoCodecMultiplex:
|
|
|
|
|
return std::make_unique<VideoRtpDepacketizerGeneric>();
|
2019-12-11 11:24:37 +01:00
|
|
|
}
|
2019-12-05 16:24:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|