stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/rtp_rtcp/source/rtp_format.h" |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 12 | |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 13 | #include <utility> |
| 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #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.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 21 | RtpPacketizer* RtpPacketizer::Create(VideoCodecType type, |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 22 | size_t max_payload_len, |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 23 | size_t last_packet_reduction_len, |
philipel | 5ab67a5 | 2018-07-05 12:27:04 +0200 | [diff] [blame] | 24 | const RTPVideoHeader* rtp_video_header, |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 25 | FrameType frame_type) { |
philipel | 7d745e5 | 2018-08-02 14:03:53 +0200 | [diff] [blame] | 26 | RTC_CHECK(type == kVideoCodecGeneric || rtp_video_header); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 27 | switch (type) { |
philipel | 7d745e5 | 2018-08-02 14:03:53 +0200 | [diff] [blame] | 28 | case kVideoCodecH264: { |
| 29 | const auto& h264 = |
| 30 | absl::get<RTPVideoHeaderH264>(rtp_video_header->video_type_header); |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 31 | return new RtpPacketizerH264(max_payload_len, last_packet_reduction_len, |
philipel | 7d745e5 | 2018-08-02 14:03:53 +0200 | [diff] [blame] | 32 | h264.packetization_mode); |
| 33 | } |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 34 | case kVideoCodecVP8: |
philipel | 5ab67a5 | 2018-07-05 12:27:04 +0200 | [diff] [blame] | 35 | return new RtpPacketizerVp8(rtp_video_header->vp8(), max_payload_len, |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 36 | last_packet_reduction_len); |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 37 | case kVideoCodecVP9: |
philipel | 5ab67a5 | 2018-07-05 12:27:04 +0200 | [diff] [blame] | 38 | return new RtpPacketizerVp9(rtp_video_header->vp9(), max_payload_len, |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 39 | last_packet_reduction_len); |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 40 | case kVideoCodecGeneric: |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 41 | return new RtpPacketizerGeneric(frame_type, max_payload_len, |
| 42 | last_packet_reduction_len); |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 43 | default: |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 44 | RTC_NOTREACHED(); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 45 | } |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 46 | return nullptr; |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 49 | RtpDepacketizer* RtpDepacketizer::Create(VideoCodecType type) { |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 50 | switch (type) { |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 51 | case kVideoCodecH264: |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 52 | return new RtpDepacketizerH264(); |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 53 | case kVideoCodecVP8: |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 54 | return new RtpDepacketizerVp8(); |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 55 | case kVideoCodecVP9: |
asapersson | f38ea3c | 2015-07-28 04:02:54 -0700 | [diff] [blame] | 56 | return new RtpDepacketizerVp9(); |
Niels Moller | 1788dcb | 2018-08-09 06:18:57 +0000 | [diff] [blame] | 57 | case kVideoCodecGeneric: |
Niels Möller | 0b9e01d | 2018-08-08 16:50:37 +0200 | [diff] [blame] | 58 | return new RtpDepacketizerGeneric(); |
Niels Moller | 1788dcb | 2018-08-09 06:18:57 +0000 | [diff] [blame] | 59 | default: |
| 60 | RTC_NOTREACHED(); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 61 | } |
Niels Moller | 1788dcb | 2018-08-09 06:18:57 +0000 | [diff] [blame] | 62 | return nullptr; |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 63 | } |
| 64 | } // namespace webrtc |