Delete RtpDepacketizer::Create factory

Bug: webrtc:11152
Change-Id: I09824b97506a11f917cd71f2f0d30306538eee13
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/163023
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30178}
This commit is contained in:
Danil Chapovalov
2020-01-07 10:36:49 +01:00
committed by Commit Bot
parent 0b3a6e383e
commit 57218b4e22
5 changed files with 11 additions and 40 deletions

View File

@ -14,7 +14,8 @@
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "modules/rtp_rtcp/source/rtp_format.h"
#include "modules/rtp_rtcp/source/rtp_depacketizer_av1.h"
#include "modules/rtp_rtcp/source/rtp_format_h264.h"
#include "modules/rtp_rtcp/source/video_rtp_depacketizer.h"
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h"
#include "modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.h"
@ -28,18 +29,15 @@ namespace {
// Wrapper over legacy RtpDepacketizer interface.
// TODO(bugs.webrtc.org/11152): Delete when all RtpDepacketizers updated to
// the VideoRtpDepacketizer interface.
class LegacyRtpDepacketizer : public VideoRtpDepacketizer {
template <typename Depacketizer>
class Legacy : public VideoRtpDepacketizer {
public:
explicit LegacyRtpDepacketizer(VideoCodecType codec) : codec_(codec) {}
~LegacyRtpDepacketizer() override = default;
absl::optional<ParsedRtpPayload> Parse(
rtc::CopyOnWriteBuffer rtp_payload) override {
auto depacketizer = absl::WrapUnique(RtpDepacketizer::Create(codec_));
RTC_CHECK(depacketizer);
Depacketizer depacketizer;
RtpDepacketizer::ParsedPayload parsed_payload;
if (!depacketizer->Parse(&parsed_payload, rtp_payload.cdata(),
rtp_payload.size())) {
if (!depacketizer.Parse(&parsed_payload, rtp_payload.cdata(),
rtp_payload.size())) {
return absl::nullopt;
}
absl::optional<ParsedRtpPayload> result(absl::in_place);
@ -48,9 +46,6 @@ class LegacyRtpDepacketizer : public VideoRtpDepacketizer {
parsed_payload.payload_length);
return result;
}
private:
const VideoCodecType codec_;
};
} // namespace
@ -59,13 +54,13 @@ std::unique_ptr<VideoRtpDepacketizer> CreateVideoRtpDepacketizer(
VideoCodecType codec) {
switch (codec) {
case kVideoCodecH264:
return std::make_unique<LegacyRtpDepacketizer>(codec);
return std::make_unique<Legacy<RtpDepacketizerH264>>();
case kVideoCodecVP8:
return std::make_unique<VideoRtpDepacketizerVp8>();
case kVideoCodecVP9:
return std::make_unique<VideoRtpDepacketizerVp9>();
case kVideoCodecAV1:
return std::make_unique<LegacyRtpDepacketizer>(codec);
return std::make_unique<Legacy<RtpDepacketizerAv1>>();
case kVideoCodecGeneric:
case kVideoCodecMultiplex:
return std::make_unique<VideoRtpDepacketizerGeneric>();

View File

@ -13,7 +13,6 @@
#include <memory>
#include "absl/types/variant.h"
#include "modules/rtp_rtcp/source/rtp_depacketizer_av1.h"
#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"
@ -143,24 +142,4 @@ std::vector<int> RtpPacketizer::SplitAboutEqually(
return result;
}
RtpDepacketizer* RtpDepacketizer::Create(absl::optional<VideoCodecType> type) {
if (!type) {
// Use raw depacketizer.
return new RtpDepacketizerGeneric(/*generic_header_enabled=*/false);
}
switch (*type) {
case kVideoCodecH264:
return new RtpDepacketizerH264();
case kVideoCodecVP8:
return new RtpDepacketizerVp8();
case kVideoCodecVP9:
return new RtpDepacketizerVp9();
case kVideoCodecAV1:
return new RtpDepacketizerAv1();
default:
return new RtpDepacketizerGeneric(/*generic_header_enabled=*/true);
}
}
} // namespace webrtc

View File

@ -76,9 +76,6 @@ class RtpDepacketizer {
size_t payload_length;
};
// If type is not set, returns a raw depacketizer.
static RtpDepacketizer* Create(absl::optional<VideoCodecType> type);
virtual ~RtpDepacketizer() {}
// Parses the RTP payload, parsed result will be saved in |parsed_payload|.

View File

@ -514,7 +514,7 @@ struct H264ParsedPayload : public RtpDepacketizer::ParsedPayload {
class RtpDepacketizerH264Test : public ::testing::Test {
protected:
RtpDepacketizerH264Test()
: depacketizer_(RtpDepacketizer::Create(kVideoCodecH264)) {}
: depacketizer_(std::make_unique<RtpDepacketizerH264>()) {}
void ExpectPacket(H264ParsedPayload* parsed_payload,
const uint8_t* data,

View File

@ -174,7 +174,7 @@ TEST(RtpPacketizerVp8Test, TIDAndKeyIdx) {
class RtpDepacketizerVp8Test : public ::testing::Test {
protected:
RtpDepacketizerVp8Test()
: depacketizer_(RtpDepacketizer::Create(kVideoCodecVP8)) {}
: depacketizer_(std::make_unique<RtpDepacketizerVp8>()) {}
void ExpectPacket(RtpDepacketizer::ParsedPayload* parsed_payload,
const uint8_t* data,