phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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_RECEIVER_STRATEGY_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_STRATEGY_H_ |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "modules/rtp_rtcp/include/rtp_rtcp.h" |
| 15 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 16 | #include "modules/rtp_rtcp/source/rtp_utility.h" |
| 17 | #include "rtc_base/criticalsection.h" |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
magjed | 56124bd | 2016-11-24 09:34:46 -0800 | [diff] [blame] | 21 | struct CodecInst; |
| 22 | |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 23 | // This strategy deals with media-specific RTP packet processing. |
| 24 | // This class is not thread-safe and must be protected by its caller. |
| 25 | class RTPReceiverStrategy { |
| 26 | public: |
andresp@webrtc.org | dc80bae | 2014-04-08 11:06:12 +0000 | [diff] [blame] | 27 | static RTPReceiverStrategy* CreateVideoStrategy(RtpData* data_callback); |
solenberg | 1d03139 | 2016-03-30 02:42:32 -0700 | [diff] [blame] | 28 | static RTPReceiverStrategy* CreateAudioStrategy(RtpData* data_callback); |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 29 | |
Danil Chapovalov | 2a5ce2b | 2018-02-07 09:38:31 +0100 | [diff] [blame] | 30 | virtual ~RTPReceiverStrategy(); |
stefan@webrtc.org | 66b2e5c | 2013-07-05 14:30:48 +0000 | [diff] [blame] | 31 | |
tnakamura@webrtc.org | aa4d96a | 2013-07-16 19:25:04 +0000 | [diff] [blame] | 32 | // Parses the RTP packet and calls the data callback with the payload data. |
| 33 | // Implementations are encouraged to use the provided packet buffer and RTP |
| 34 | // header as arguments to the callback; implementations are also allowed to |
| 35 | // make changes in the data as necessary. The specific_payload argument |
Niels Möller | bbf389c | 2017-09-26 14:05:05 +0200 | [diff] [blame] | 36 | // provides audio or video-specific data. |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 37 | virtual int32_t ParseRtpPacket(WebRtcRTPHeader* rtp_header, |
| 38 | const PayloadUnion& specific_payload, |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 39 | const uint8_t* payload, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 40 | size_t payload_length, |
Niels Möller | bbf389c | 2017-09-26 14:05:05 +0200 | [diff] [blame] | 41 | int64_t timestamp_ms) = 0; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 42 | |
tnakamura@webrtc.org | aa4d96a | 2013-07-16 19:25:04 +0000 | [diff] [blame] | 43 | protected: |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 44 | // The data callback is where we should send received payload data. |
| 45 | // See ParseRtpPacket. This class does not claim ownership of the callback. |
| 46 | // Implementations must NOT hold any critical sections while calling the |
| 47 | // callback. |
| 48 | // |
| 49 | // Note: Implementations may call the callback for other reasons than calls |
| 50 | // to ParseRtpPacket, for instance if the implementation somehow recovers a |
| 51 | // packet. |
danilchap | 6db6cdc | 2015-12-15 02:54:47 -0800 | [diff] [blame] | 52 | explicit RTPReceiverStrategy(RtpData* data_callback); |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 53 | |
danilchap | 7c9426c | 2016-04-14 03:05:31 -0700 | [diff] [blame] | 54 | rtc::CriticalSection crit_sect_; |
phoglund@webrtc.org | a22a9bd | 2013-01-14 10:01:55 +0000 | [diff] [blame] | 55 | RtpData* data_callback_; |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 56 | }; |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 57 | } // namespace webrtc |
| 58 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 59 | #endif // MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_STRATEGY_H_ |