blob: 293181e780baf16649c5282ddd27445325d28ef8 [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) {
Kári Tristan Helgason01a89902018-08-27 13:26:52 +020026 RTC_CHECK(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);
philipel29d88462018-08-08 14:26:00 +020037 case kVideoCodecVP9: {
38 const auto& vp9 =
39 absl::get<RTPVideoHeaderVP9>(rtp_video_header->video_type_header);
40 return new RtpPacketizerVp9(vp9, max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070041 last_packet_reduction_len);
philipel29d88462018-08-08 14:26:00 +020042 }
Kári Tristan Helgason01a89902018-08-27 13:26:52 +020043 default:
Sami Kalliomäki426a80c2018-08-08 11:37:59 +020044 return new RtpPacketizerGeneric(*rtp_video_header, frame_type,
45 max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070046 last_packet_reduction_len);
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000047 }
ilnik7a3006b2017-05-23 09:34:21 -070048 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000049}
50
Niels Möller520ca4e2018-06-04 11:14:38 +020051RtpDepacketizer* RtpDepacketizer::Create(VideoCodecType type) {
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000052 switch (type) {
Niels Möller520ca4e2018-06-04 11:14:38 +020053 case kVideoCodecH264:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000054 return new RtpDepacketizerH264();
Niels Möller520ca4e2018-06-04 11:14:38 +020055 case kVideoCodecVP8:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000056 return new RtpDepacketizerVp8();
Niels Möller520ca4e2018-06-04 11:14:38 +020057 case kVideoCodecVP9:
asaperssonf38ea3c2015-07-28 04:02:54 -070058 return new RtpDepacketizerVp9();
Niels Moller1788dcb2018-08-09 06:18:57 +000059 default:
Niels Möller2ff1f2a2018-08-09 16:16:34 +020060 return new RtpDepacketizerGeneric();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000061 }
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000062}
63} // namespace webrtc