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 | |
| 22 | class RTPPayloadRegistry; |
magjed | 56124bd | 2016-11-24 09:34:46 -0800 | [diff] [blame] | 23 | class VideoCodec; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 24 | |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 25 | class TelephoneEventHandler { |
| 26 | public: |
| 27 | virtual ~TelephoneEventHandler() {} |
| 28 | |
| 29 | // The following three methods implement the TelephoneEventHandler interface. |
| 30 | // Forward DTMFs to decoder for playout. |
| 31 | virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0; |
| 32 | |
| 33 | // Is forwarding of outband telephone events turned on/off? |
| 34 | virtual bool TelephoneEventForwardToDecoder() const = 0; |
| 35 | |
| 36 | // Is TelephoneEvent configured with payload type payload_type |
| 37 | virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0; |
| 38 | }; |
| 39 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 40 | class RtpReceiver { |
| 41 | public: |
| 42 | // Creates a video-enabled RTP receiver. |
| 43 | static RtpReceiver* CreateVideoReceiver( |
| 44 | Clock* clock, |
| 45 | RtpData* incoming_payload_callback, |
| 46 | RtpFeedback* incoming_messages_callback, |
| 47 | RTPPayloadRegistry* rtp_payload_registry); |
| 48 | |
| 49 | // Creates an audio-enabled RTP receiver. |
| 50 | static RtpReceiver* CreateAudioReceiver( |
| 51 | Clock* clock, |
solenberg | 1d03139 | 2016-03-30 02:42:32 -0700 | [diff] [blame] | 52 | RtpData* incoming_payload_callback, |
| 53 | RtpFeedback* incoming_messages_callback, |
| 54 | RTPPayloadRegistry* rtp_payload_registry); |
| 55 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 56 | virtual ~RtpReceiver() {} |
| 57 | |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 58 | // Returns a TelephoneEventHandler if available. |
| 59 | virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0; |
| 60 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 61 | // Registers a receive payload in the payload registry and notifies the media |
| 62 | // receiver strategy. |
Karl Wiberg | c62f6c7 | 2017-10-04 12:38:53 +0200 | [diff] [blame] | 63 | virtual int32_t RegisterReceivePayload( |
| 64 | int payload_type, |
| 65 | const SdpAudioFormat& audio_format) = 0; |
| 66 | |
| 67 | // Deprecated version of the above. |
| 68 | int32_t RegisterReceivePayload(const CodecInst& audio_codec); |
| 69 | |
magjed | 6b272c5 | 2016-11-25 02:29:39 -0800 | [diff] [blame] | 70 | // Registers a receive payload in the payload registry. |
| 71 | virtual int32_t RegisterReceivePayload(const VideoCodec& video_codec) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 72 | |
| 73 | // De-registers |payload_type| from the payload registry. |
| 74 | virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0; |
| 75 | |
| 76 | // Parses the media specific parts of an RTP packet and updates the receiver |
| 77 | // state. This for instance means that any changes in SSRC and payload type is |
| 78 | // detected and acted upon. |
| 79 | virtual bool IncomingRtpPacket(const RTPHeader& rtp_header, |
| 80 | const uint8_t* payload, |
| 81 | size_t payload_length, |
Niels Möller | 22ec952 | 2017-10-05 08:39:15 +0200 | [diff] [blame^] | 82 | PayloadUnion payload_specific) = 0; |
| 83 | // TODO(nisse): Deprecated version, delete as soon as downstream |
| 84 | // applications are updated. |
| 85 | bool IncomingRtpPacket(const RTPHeader& rtp_header, |
| 86 | const uint8_t* payload, |
| 87 | size_t payload_length, |
| 88 | PayloadUnion payload_specific, |
| 89 | bool in_order /* Ignored */) { |
| 90 | return IncomingRtpPacket(rtp_header, payload, payload_length, |
| 91 | payload_specific); |
| 92 | } |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 93 | |
Niels Möller | c3fa8e1 | 2017-10-03 15:28:26 +0200 | [diff] [blame] | 94 | // Gets the RTP timestamp and the corresponding monotonic system |
| 95 | // time for the most recent in-order packet. Returns true on |
| 96 | // success, false if no packet has been received. |
| 97 | virtual bool GetLatestTimestamps(uint32_t* timestamp, |
| 98 | int64_t* receive_time_ms) const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 99 | |
| 100 | // Returns the remote SSRC of the currently received RTP stream. |
| 101 | virtual uint32_t SSRC() const = 0; |
| 102 | |
| 103 | // Returns the current remote CSRCs. |
| 104 | virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0; |
| 105 | |
| 106 | // Returns the current energy of the RTP stream received. |
| 107 | virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0; |
hbos | 8d609f6 | 2017-04-10 07:39:05 -0700 | [diff] [blame] | 108 | |
| 109 | virtual std::vector<RtpSource> GetSources() const = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 110 | }; |
| 111 | } // namespace webrtc |
| 112 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 113 | #endif // MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_ |