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