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