blob: 7f799bb863846122a968365e70e04f26d7099433 [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
11#include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
12
hta9aa96882016-12-06 05:36:03 -080013#include <utility>
14
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000015#include "webrtc/modules/rtp_rtcp/source/rtp_format_h264.h"
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000016#include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h"
17#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h"
asaperssonf38ea3c2015-07-28 04:02:54 -070018#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h"
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000019
20namespace webrtc {
21RtpPacketizer* RtpPacketizer::Create(RtpVideoCodecTypes 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,
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000024 const RTPVideoTypeHeader* rtp_type_header,
25 FrameType frame_type) {
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000026 switch (type) {
27 case kRtpVideoH264:
hta9aa96882016-12-06 05:36:03 -080028 RTC_CHECK(rtp_type_header);
ilnik7a3006b2017-05-23 09:34:21 -070029 return new RtpPacketizerH264(max_payload_len, last_packet_reduction_len,
hta9aa96882016-12-06 05:36:03 -080030 rtp_type_header->H264.packetization_mode);
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000031 case kRtpVideoVp8:
hta9aa96882016-12-06 05:36:03 -080032 RTC_CHECK(rtp_type_header);
ilnik7a3006b2017-05-23 09:34:21 -070033 return new RtpPacketizerVp8(rtp_type_header->VP8, max_payload_len,
34 last_packet_reduction_len);
asaperssonf38ea3c2015-07-28 04:02:54 -070035 case kRtpVideoVp9:
hta9aa96882016-12-06 05:36:03 -080036 RTC_CHECK(rtp_type_header);
ilnik7a3006b2017-05-23 09:34:21 -070037 return new RtpPacketizerVp9(rtp_type_header->VP9, max_payload_len,
38 last_packet_reduction_len);
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000039 case kRtpVideoGeneric:
ilnik7a3006b2017-05-23 09:34:21 -070040 return new RtpPacketizerGeneric(frame_type, max_payload_len,
41 last_packet_reduction_len);
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000042 case kRtpVideoNone:
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
pbos@webrtc.org730d2702014-09-29 08:00:22 +000048RtpDepacketizer* RtpDepacketizer::Create(RtpVideoCodecTypes type) {
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000049 switch (type) {
50 case kRtpVideoH264:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000051 return new RtpDepacketizerH264();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000052 case kRtpVideoVp8:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000053 return new RtpDepacketizerVp8();
asaperssonf38ea3c2015-07-28 04:02:54 -070054 case kRtpVideoVp9:
55 return new RtpDepacketizerVp9();
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000056 case kRtpVideoGeneric:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000057 return new RtpDepacketizerGeneric();
pbos@webrtc.orgb5e6bfc2014-09-12 11:05:55 +000058 case kRtpVideoNone:
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000059 assert(false);
60 }
ilnik7a3006b2017-05-23 09:34:21 -070061 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000062}
63} // namespace webrtc