blob: 8bd27a76247a282500b0cd4e1963f3d114290612 [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) {
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000026 switch (type) {
JT Teh5daeff92018-07-16 17:17:17 +000027 case kVideoCodecH264:
28 RTC_CHECK(rtp_video_header);
ilnik7a3006b2017-05-23 09:34:21 -070029 return new RtpPacketizerH264(max_payload_len, last_packet_reduction_len,
JT Teh5daeff92018-07-16 17:17:17 +000030 rtp_video_header->h264().packetization_mode);
Niels Möller520ca4e2018-06-04 11:14:38 +020031 case kVideoCodecVP8:
JT Teh5daeff92018-07-16 17:17:17 +000032 RTC_CHECK(rtp_video_header);
philipel5ab67a52018-07-05 12:27:04 +020033 return new RtpPacketizerVp8(rtp_video_header->vp8(), max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070034 last_packet_reduction_len);
Niels Möller520ca4e2018-06-04 11:14:38 +020035 case kVideoCodecVP9:
JT Teh5daeff92018-07-16 17:17:17 +000036 RTC_CHECK(rtp_video_header);
philipel5ab67a52018-07-05 12:27:04 +020037 return new RtpPacketizerVp9(rtp_video_header->vp9(), max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070038 last_packet_reduction_len);
Niels Möller520ca4e2018-06-04 11:14:38 +020039 case kVideoCodecGeneric:
ilnik7a3006b2017-05-23 09:34:21 -070040 return new RtpPacketizerGeneric(frame_type, max_payload_len,
41 last_packet_reduction_len);
Niels Möller520ca4e2018-06-04 11:14:38 +020042 default:
hta9aa96882016-12-06 05:36:03 -080043 RTC_NOTREACHED();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000044 }
ilnik7a3006b2017-05-23 09:34:21 -070045 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000046}
47
Niels Möller520ca4e2018-06-04 11:14:38 +020048RtpDepacketizer* RtpDepacketizer::Create(VideoCodecType type) {
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000049 switch (type) {
Niels Möller520ca4e2018-06-04 11:14:38 +020050 case kVideoCodecH264:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000051 return new RtpDepacketizerH264();
Niels Möller520ca4e2018-06-04 11:14:38 +020052 case kVideoCodecVP8:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000053 return new RtpDepacketizerVp8();
Niels Möller520ca4e2018-06-04 11:14:38 +020054 case kVideoCodecVP9:
asaperssonf38ea3c2015-07-28 04:02:54 -070055 return new RtpDepacketizerVp9();
Niels Möller520ca4e2018-06-04 11:14:38 +020056 case kVideoCodecGeneric:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000057 return new RtpDepacketizerGeneric();
Niels Möller520ca4e2018-06-04 11:14:38 +020058 default:
59 RTC_NOTREACHED();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000060 }
ilnik7a3006b2017-05-23 09:34:21 -070061 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000062}
63} // namespace webrtc