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 | |
| 11 | #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" |
| 12 | |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 13 | #include <utility> |
| 14 | |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 15 | #include "webrtc/modules/rtp_rtcp/source/rtp_format_h264.h" |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h" |
| 17 | #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h" |
asapersson | f38ea3c | 2015-07-28 04:02:54 -0700 | [diff] [blame] | 18 | #include "webrtc/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 { |
| 21 | RtpPacketizer* RtpPacketizer::Create(RtpVideoCodecTypes 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, |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 24 | const RTPVideoTypeHeader* rtp_type_header, |
| 25 | FrameType frame_type) { |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 26 | switch (type) { |
| 27 | case kRtpVideoH264: |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 28 | RTC_CHECK(rtp_type_header); |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 29 | return new RtpPacketizerH264(max_payload_len, last_packet_reduction_len, |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 30 | rtp_type_header->H264.packetization_mode); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 31 | case kRtpVideoVp8: |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 32 | RTC_CHECK(rtp_type_header); |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 33 | return new RtpPacketizerVp8(rtp_type_header->VP8, max_payload_len, |
| 34 | last_packet_reduction_len); |
asapersson | f38ea3c | 2015-07-28 04:02:54 -0700 | [diff] [blame] | 35 | case kRtpVideoVp9: |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 36 | RTC_CHECK(rtp_type_header); |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 37 | return new RtpPacketizerVp9(rtp_type_header->VP9, max_payload_len, |
| 38 | last_packet_reduction_len); |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 39 | case kRtpVideoGeneric: |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 40 | return new RtpPacketizerGeneric(frame_type, max_payload_len, |
| 41 | last_packet_reduction_len); |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 42 | case kRtpVideoNone: |
hta | 9aa9688 | 2016-12-06 05:36:03 -0800 | [diff] [blame] | 43 | RTC_NOTREACHED(); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 44 | } |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 45 | return nullptr; |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 46 | } |
| 47 | |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 48 | RtpDepacketizer* RtpDepacketizer::Create(RtpVideoCodecTypes type) { |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 49 | switch (type) { |
| 50 | case kRtpVideoH264: |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 51 | return new RtpDepacketizerH264(); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 52 | case kRtpVideoVp8: |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 53 | return new RtpDepacketizerVp8(); |
asapersson | f38ea3c | 2015-07-28 04:02:54 -0700 | [diff] [blame] | 54 | case kRtpVideoVp9: |
| 55 | return new RtpDepacketizerVp9(); |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 56 | case kRtpVideoGeneric: |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 57 | return new RtpDepacketizerGeneric(); |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 58 | case kRtpVideoNone: |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 59 | assert(false); |
| 60 | } |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 61 | return nullptr; |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 62 | } |
| 63 | } // namespace webrtc |