Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [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_INCLUDE_RTP_RECEIVER_H_ |
| 12 | #define MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_ |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 13 | |
hbos | 8d609f6 | 2017-04-10 07:39:05 -0700 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "api/rtpreceiverinterface.h" |
| 17 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 18 | #include "typedefs.h" // NOLINT(build/include) |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
magjed | 56124bd | 2016-11-24 09:34:46 -0800 | [diff] [blame] | 22 | struct CodecInst; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 23 | class RTPPayloadRegistry; |
magjed | 56124bd | 2016-11-24 09:34:46 -0800 | [diff] [blame] | 24 | class VideoCodec; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 25 | |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 26 | class TelephoneEventHandler { |
| 27 | public: |
| 28 | virtual ~TelephoneEventHandler() {} |
| 29 | |
| 30 | // The following three methods implement the TelephoneEventHandler interface. |
| 31 | // Forward DTMFs to decoder for playout. |
| 32 | virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0; |
| 33 | |
| 34 | // Is forwarding of outband telephone events turned on/off? |
| 35 | virtual bool TelephoneEventForwardToDecoder() const = 0; |
| 36 | |
| 37 | // Is TelephoneEvent configured with payload type payload_type |
| 38 | virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0; |
| 39 | }; |
| 40 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 41 | class RtpReceiver { |
| 42 | public: |
| 43 | // Creates a video-enabled RTP receiver. |
| 44 | static RtpReceiver* CreateVideoReceiver( |
| 45 | Clock* clock, |
| 46 | RtpData* incoming_payload_callback, |
| 47 | RtpFeedback* incoming_messages_callback, |
| 48 | RTPPayloadRegistry* rtp_payload_registry); |
| 49 | |
| 50 | // Creates an audio-enabled RTP receiver. |
| 51 | static RtpReceiver* CreateAudioReceiver( |
| 52 | Clock* clock, |
solenberg | 1d03139 | 2016-03-30 02:42:32 -0700 | [diff] [blame] | 53 | RtpData* incoming_payload_callback, |
| 54 | RtpFeedback* incoming_messages_callback, |
| 55 | RTPPayloadRegistry* rtp_payload_registry); |
| 56 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 57 | virtual ~RtpReceiver() {} |
| 58 | |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 59 | // Returns a TelephoneEventHandler if available. |
| 60 | virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0; |
| 61 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 62 | // Registers a receive payload in the payload registry and notifies the media |
| 63 | // receiver strategy. |
magjed | 56124bd | 2016-11-24 09:34:46 -0800 | [diff] [blame] | 64 | virtual int32_t RegisterReceivePayload(const CodecInst& audio_codec) = 0; |
magjed | 6b272c5 | 2016-11-25 02:29:39 -0800 | [diff] [blame] | 65 | // Registers a receive payload in the payload registry. |
| 66 | virtual int32_t RegisterReceivePayload(const VideoCodec& video_codec) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 67 | |
| 68 | // De-registers |payload_type| from the payload registry. |
| 69 | virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0; |
| 70 | |
| 71 | // Parses the media specific parts of an RTP packet and updates the receiver |
| 72 | // state. This for instance means that any changes in SSRC and payload type is |
| 73 | // detected and acted upon. |
| 74 | virtual bool IncomingRtpPacket(const RTPHeader& rtp_header, |
| 75 | const uint8_t* payload, |
| 76 | size_t payload_length, |
| 77 | PayloadUnion payload_specific, |
| 78 | bool in_order) = 0; |
| 79 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 80 | // Gets the last received timestamp. Returns true if a packet has been |
| 81 | // received, false otherwise. |
| 82 | virtual bool Timestamp(uint32_t* timestamp) const = 0; |
| 83 | // Gets the time in milliseconds when the last timestamp was received. |
| 84 | // Returns true if a packet has been received, false otherwise. |
| 85 | virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0; |
| 86 | |
| 87 | // Returns the remote SSRC of the currently received RTP stream. |
| 88 | virtual uint32_t SSRC() const = 0; |
| 89 | |
| 90 | // Returns the current remote CSRCs. |
| 91 | virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0; |
| 92 | |
| 93 | // Returns the current energy of the RTP stream received. |
| 94 | virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0; |
hbos | 8d609f6 | 2017-04-10 07:39:05 -0700 | [diff] [blame] | 95 | |
| 96 | virtual std::vector<RtpSource> GetSources() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 97 | }; |
| 98 | } // namespace webrtc |
| 99 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 100 | #endif // MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_ |