blob: 3f2038e1c642946201d07a157f2bb4aef7e37b08 [file] [log] [blame]
stefan@webrtc.org2ec56062014-07-31 14:59:24 +00001/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/rtp_rtcp/source/rtp_format.h"
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000012
hta9aa96882016-12-06 05:36:03 -080013#include <utility>
14
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "modules/rtp_rtcp/source/rtp_format_h264.h"
16#include "modules/rtp_rtcp/source/rtp_format_video_generic.h"
17#include "modules/rtp_rtcp/source/rtp_format_vp8.h"
18#include "modules/rtp_rtcp/source/rtp_format_vp9.h"
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000019
20namespace webrtc {
Niels Möller520ca4e2018-06-04 11:14:38 +020021RtpPacketizer* RtpPacketizer::Create(VideoCodecType type,
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000022 size_t max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070023 size_t last_packet_reduction_len,
philipel5ab67a52018-07-05 12:27:04 +020024 const RTPVideoHeader* rtp_video_header,
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000025 FrameType frame_type) {
philipel7d745e52018-08-02 14:03:53 +020026 RTC_CHECK(type == kVideoCodecGeneric || rtp_video_header);
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000027 switch (type) {
philipel7d745e52018-08-02 14:03:53 +020028 case kVideoCodecH264: {
29 const auto& h264 =
30 absl::get<RTPVideoHeaderH264>(rtp_video_header->video_type_header);
ilnik7a3006b2017-05-23 09:34:21 -070031 return new RtpPacketizerH264(max_payload_len, last_packet_reduction_len,
philipel7d745e52018-08-02 14:03:53 +020032 h264.packetization_mode);
33 }
Niels Möller520ca4e2018-06-04 11:14:38 +020034 case kVideoCodecVP8:
philipel5ab67a52018-07-05 12:27:04 +020035 return new RtpPacketizerVp8(rtp_video_header->vp8(), max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070036 last_packet_reduction_len);
Niels Möller520ca4e2018-06-04 11:14:38 +020037 case kVideoCodecVP9:
philipel5ab67a52018-07-05 12:27:04 +020038 return new RtpPacketizerVp9(rtp_video_header->vp9(), max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070039 last_packet_reduction_len);
Niels Möller520ca4e2018-06-04 11:14:38 +020040 case kVideoCodecGeneric:
ilnik7a3006b2017-05-23 09:34:21 -070041 return new RtpPacketizerGeneric(frame_type, max_payload_len,
42 last_packet_reduction_len);
Niels Möller520ca4e2018-06-04 11:14:38 +020043 default:
hta9aa96882016-12-06 05:36:03 -080044 RTC_NOTREACHED();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000045 }
ilnik7a3006b2017-05-23 09:34:21 -070046 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000047}
48
Niels Möller520ca4e2018-06-04 11:14:38 +020049RtpDepacketizer* RtpDepacketizer::Create(VideoCodecType type) {
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000050 switch (type) {
Niels Möller520ca4e2018-06-04 11:14:38 +020051 case kVideoCodecH264:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000052 return new RtpDepacketizerH264();
Niels Möller520ca4e2018-06-04 11:14:38 +020053 case kVideoCodecVP8:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000054 return new RtpDepacketizerVp8();
Niels Möller520ca4e2018-06-04 11:14:38 +020055 case kVideoCodecVP9:
asaperssonf38ea3c2015-07-28 04:02:54 -070056 return new RtpDepacketizerVp9();
Niels Moller1788dcb2018-08-09 06:18:57 +000057 case kVideoCodecGeneric:
Niels Möller0b9e01d2018-08-08 16:50:37 +020058 return new RtpDepacketizerGeneric();
Niels Moller1788dcb2018-08-09 06:18:57 +000059 default:
60 RTC_NOTREACHED();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000061 }
Niels Moller1788dcb2018-08-09 06:18:57 +000062 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000063}
64} // namespace webrtc