blob: ef03b998b715761d620a79ae909ab5f3cdd8a2ce [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);
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 }
Niels Möller520ca4e2018-06-04 11:14:38 +020043 case kVideoCodecGeneric:
Sami Kalliomäki426a80c2018-08-08 11:37:59 +020044 RTC_CHECK(rtp_video_header);
45 return new RtpPacketizerGeneric(*rtp_video_header, frame_type,
46 max_payload_len,
ilnik7a3006b2017-05-23 09:34:21 -070047 last_packet_reduction_len);
Niels Möller520ca4e2018-06-04 11:14:38 +020048 default:
hta9aa96882016-12-06 05:36:03 -080049 RTC_NOTREACHED();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000050 }
ilnik7a3006b2017-05-23 09:34:21 -070051 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000052}
53
Niels Möller520ca4e2018-06-04 11:14:38 +020054RtpDepacketizer* RtpDepacketizer::Create(VideoCodecType type) {
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000055 switch (type) {
Niels Möller520ca4e2018-06-04 11:14:38 +020056 case kVideoCodecH264:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000057 return new RtpDepacketizerH264();
Niels Möller520ca4e2018-06-04 11:14:38 +020058 case kVideoCodecVP8:
pbos@webrtc.org730d2702014-09-29 08:00:22 +000059 return new RtpDepacketizerVp8();
Niels Möller520ca4e2018-06-04 11:14:38 +020060 case kVideoCodecVP9:
asaperssonf38ea3c2015-07-28 04:02:54 -070061 return new RtpDepacketizerVp9();
Niels Moller1788dcb2018-08-09 06:18:57 +000062 case kVideoCodecGeneric:
Niels Möller0b9e01d2018-08-08 16:50:37 +020063 return new RtpDepacketizerGeneric();
Niels Moller1788dcb2018-08-09 06:18:57 +000064 default:
65 RTC_NOTREACHED();
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000066 }
Niels Moller1788dcb2018-08-09 06:18:57 +000067 return nullptr;
stefan@webrtc.org2ec56062014-07-31 14:59:24 +000068}
69} // namespace webrtc