blob: 9738116a1a611d4d145aff2a33c5089a83827f3a [file] [log] [blame]
Henrik Kjellanderff761fb2015-11-04 08:31:52 +01001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
12#define MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010013
hbos8d609f62017-04-10 07:39:05 -070014#include <vector>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/rtpreceiverinterface.h"
17#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020018#include "typedefs.h" // NOLINT(build/include)
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010019
20namespace webrtc {
21
22class RTPPayloadRegistry;
magjed56124bd2016-11-24 09:34:46 -080023class VideoCodec;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010024
danilchap799a9d02016-09-22 03:36:27 -070025class 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 Kjellanderff761fb2015-11-04 08:31:52 +010040class 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,
solenberg1d031392016-03-30 02:42:32 -070052 RtpData* incoming_payload_callback,
53 RtpFeedback* incoming_messages_callback,
54 RTPPayloadRegistry* rtp_payload_registry);
55
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010056 virtual ~RtpReceiver() {}
57
danilchap799a9d02016-09-22 03:36:27 -070058 // Returns a TelephoneEventHandler if available.
59 virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
60
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010061 // Registers a receive payload in the payload registry and notifies the media
62 // receiver strategy.
Karl Wibergc62f6c72017-10-04 12:38:53 +020063 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
magjed6b272c52016-11-25 02:29:39 -080070 // Registers a receive payload in the payload registry.
71 virtual int32_t RegisterReceivePayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010072
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öller22ec9522017-10-05 08:39:15 +020082 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 Kjellanderff761fb2015-11-04 08:31:52 +010093
Niels Möllerc3fa8e12017-10-03 15:28:26 +020094 // 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 Kjellanderff761fb2015-11-04 08:31:52 +010099
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;
hbos8d609f62017-04-10 07:39:05 -0700108
109 virtual std::vector<RtpSource> GetSources() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +0100110};
111} // namespace webrtc
112
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200113#endif // MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_