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 | #ifndef MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_ |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 13 | |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 14 | #include <string> |
| 15 | |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 16 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "modules/include/module_common_types.h" |
| 18 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 19 | #include "rtc_base/constructormagic.h" |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
danilchap | e545e5d | 2016-12-05 02:26:44 -0800 | [diff] [blame] | 22 | class RtpPacketToSend; |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 23 | |
| 24 | class RtpPacketizer { |
| 25 | public: |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 26 | static RtpPacketizer* Create(VideoCodecType type, |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 27 | size_t max_payload_len, |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 28 | size_t last_packet_reduction_len, |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 29 | const RTPVideoTypeHeader* rtp_type_header, |
| 30 | FrameType frame_type); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 31 | |
| 32 | virtual ~RtpPacketizer() {} |
| 33 | |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 34 | // Returns total number of packets which would be produced by the packetizer. |
| 35 | virtual size_t SetPayloadData( |
| 36 | const uint8_t* payload_data, |
| 37 | size_t payload_size, |
| 38 | const RTPFragmentationHeader* fragmentation) = 0; |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 39 | |
| 40 | // Get the next payload with payload header. |
danilchap | e545e5d | 2016-12-05 02:26:44 -0800 | [diff] [blame] | 41 | // Write payload and set marker bit of the |packet|. |
danilchap | e545e5d | 2016-12-05 02:26:44 -0800 | [diff] [blame] | 42 | // Returns true on success, false otherwise. |
ilnik | 7a3006b | 2017-05-23 09:34:21 -0700 | [diff] [blame] | 43 | virtual bool NextPacket(RtpPacketToSend* packet) = 0; |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 44 | |
pbos@webrtc.org | b5e6bfc | 2014-09-12 11:05:55 +0000 | [diff] [blame] | 45 | virtual std::string ToString() = 0; |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
sprang | 52033d6 | 2016-06-02 02:43:32 -0700 | [diff] [blame] | 48 | // TODO(sprang): Update the depacketizer to return a std::unqie_ptr with a copy |
| 49 | // of the parsed payload, rather than just a pointer into the incoming buffer. |
| 50 | // This way we can move some parsing out from the jitter buffer into here, and |
| 51 | // the jitter buffer can just store that pointer rather than doing a copy there. |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 52 | class RtpDepacketizer { |
| 53 | public: |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 54 | struct ParsedPayload { |
philipel | 011dc64 | 2018-07-04 16:55:55 +0200 | [diff] [blame^] | 55 | RTPVideoHeader& video_header() { return video; } |
| 56 | const RTPVideoHeader& video_header() const { return video; } |
| 57 | RTPVideoHeader video; |
| 58 | |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 59 | const uint8_t* payload; |
| 60 | size_t payload_length; |
pbos@webrtc.org | d42a3ad | 2014-11-07 11:02:12 +0000 | [diff] [blame] | 61 | FrameType frame_type; |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
Niels Möller | 520ca4e | 2018-06-04 11:14:38 +0200 | [diff] [blame] | 64 | static RtpDepacketizer* Create(VideoCodecType type); |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 65 | |
| 66 | virtual ~RtpDepacketizer() {} |
| 67 | |
pbos@webrtc.org | 730d270 | 2014-09-29 08:00:22 +0000 | [diff] [blame] | 68 | // Parses the RTP payload, parsed result will be saved in |parsed_payload|. |
| 69 | virtual bool Parse(ParsedPayload* parsed_payload, |
stefan@webrtc.org | 2ec5606 | 2014-07-31 14:59:24 +0000 | [diff] [blame] | 70 | const uint8_t* payload_data, |
| 71 | size_t payload_data_length) = 0; |
| 72 | }; |
| 73 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 74 | #endif // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H_ |