wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +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 | |
| 11 | #ifndef WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_ |
| 13 | |
| 14 | #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
| 15 | #include "webrtc/typedefs.h" |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | class RTPPayloadRegistry; |
| 20 | |
| 21 | class TelephoneEventHandler { |
| 22 | public: |
| 23 | virtual ~TelephoneEventHandler() {} |
| 24 | |
| 25 | // The following three methods implement the TelephoneEventHandler interface. |
| 26 | // Forward DTMFs to decoder for playout. |
| 27 | virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0; |
| 28 | |
| 29 | // Is forwarding of outband telephone events turned on/off? |
| 30 | virtual bool TelephoneEventForwardToDecoder() const = 0; |
| 31 | |
| 32 | // Is TelephoneEvent configured with payload type payload_type |
| 33 | virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0; |
| 34 | }; |
| 35 | |
| 36 | class RtpReceiver { |
| 37 | public: |
| 38 | // Creates a video-enabled RTP receiver. |
| 39 | static RtpReceiver* CreateVideoReceiver( |
| 40 | int id, Clock* clock, |
| 41 | RtpData* incoming_payload_callback, |
| 42 | RtpFeedback* incoming_messages_callback, |
| 43 | RTPPayloadRegistry* rtp_payload_registry); |
| 44 | |
| 45 | // Creates an audio-enabled RTP receiver. |
| 46 | static RtpReceiver* CreateAudioReceiver( |
| 47 | int id, Clock* clock, |
| 48 | RtpAudioFeedback* incoming_audio_feedback, |
| 49 | RtpData* incoming_payload_callback, |
| 50 | RtpFeedback* incoming_messages_callback, |
| 51 | RTPPayloadRegistry* rtp_payload_registry); |
| 52 | |
| 53 | virtual ~RtpReceiver() {} |
| 54 | |
| 55 | // Returns a TelephoneEventHandler if available. |
| 56 | virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0; |
| 57 | |
| 58 | // Registers a receive payload in the payload registry and notifies the media |
| 59 | // receiver strategy. |
| 60 | virtual int32_t RegisterReceivePayload( |
| 61 | const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 62 | const int8_t payload_type, |
| 63 | const uint32_t frequency, |
| 64 | const uint8_t channels, |
| 65 | const uint32_t rate) = 0; |
| 66 | |
| 67 | // De-registers |payload_type| from the payload registry. |
| 68 | virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0; |
| 69 | |
| 70 | // Parses the media specific parts of an RTP packet and updates the receiver |
| 71 | // state. This for instance means that any changes in SSRC and payload type is |
| 72 | // detected and acted upon. |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame^] | 73 | virtual bool IncomingRtpPacket(const RTPHeader& rtp_header, |
| 74 | const uint8_t* payload, |
| 75 | int payload_length, |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 76 | PayloadUnion payload_specific, |
| 77 | bool in_order) = 0; |
| 78 | |
| 79 | // Returns the currently configured NACK method. |
| 80 | virtual NACKMethod NACK() const = 0; |
| 81 | |
| 82 | // Turn negative acknowledgement (NACK) requests on/off. |
stefan@webrtc.org | 7bb8f02 | 2013-09-06 13:40:11 +0000 | [diff] [blame^] | 83 | virtual void SetNACKStatus(const NACKMethod method) = 0; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 84 | |
| 85 | // Returns the last received timestamp. |
| 86 | virtual uint32_t Timestamp() const = 0; |
| 87 | // Returns the time in milliseconds when the last timestamp was received. |
| 88 | virtual int32_t LastReceivedTimeMs() const = 0; |
| 89 | |
| 90 | // Returns the remote SSRC of the currently received RTP stream. |
| 91 | virtual uint32_t SSRC() const = 0; |
| 92 | |
| 93 | // Returns the current remote CSRCs. |
| 94 | virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0; |
| 95 | |
| 96 | // Returns the current energy of the RTP stream received. |
| 97 | virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 98 | }; |
| 99 | } // namespace webrtc |
| 100 | |
| 101 | #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_ |