blob: 0a3e201c749b75cc74bc502afd241b1c9e671e59 [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
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
17namespace webrtc {
18
solenberg1d031392016-03-30 02:42:32 -070019class RtpAudioFeedback;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010020class RTPPayloadRegistry;
21
22class TelephoneEventHandler {
23 public:
24 virtual ~TelephoneEventHandler() {}
25
26 // The following three methods implement the TelephoneEventHandler interface.
27 // Forward DTMFs to decoder for playout.
28 virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
29
30 // Is forwarding of outband telephone events turned on/off?
31 virtual bool TelephoneEventForwardToDecoder() const = 0;
32
33 // Is TelephoneEvent configured with payload type payload_type
34 virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
35};
36
37class RtpReceiver {
38 public:
39 // Creates a video-enabled RTP receiver.
40 static RtpReceiver* CreateVideoReceiver(
41 Clock* clock,
42 RtpData* incoming_payload_callback,
43 RtpFeedback* incoming_messages_callback,
44 RTPPayloadRegistry* rtp_payload_registry);
45
46 // Creates an audio-enabled RTP receiver.
47 static RtpReceiver* CreateAudioReceiver(
48 Clock* clock,
solenberg1d031392016-03-30 02:42:32 -070049 RtpData* incoming_payload_callback,
50 RtpFeedback* incoming_messages_callback,
51 RTPPayloadRegistry* rtp_payload_registry);
52
53 // DEPRECATED: Creates an audio-enabled RTP receiver.
54 // TODO(solenberg): Remove, after updating downstream code.
55 static RtpReceiver* CreateAudioReceiver(
56 Clock* clock,
solenbergb69395b2016-03-16 07:05:17 -070057 RtpAudioFeedback* incoming_audio_feedback,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010058 RtpData* incoming_payload_callback,
59 RtpFeedback* incoming_messages_callback,
60 RTPPayloadRegistry* rtp_payload_registry);
61
62 virtual ~RtpReceiver() {}
63
64 // Returns a TelephoneEventHandler if available.
65 virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
66
67 // Registers a receive payload in the payload registry and notifies the media
68 // receiver strategy.
69 virtual int32_t RegisterReceivePayload(
70 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
71 const int8_t payload_type,
72 const uint32_t frequency,
Peter Kasting69558702016-01-12 16:26:35 -080073 const size_t channels,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010074 const uint32_t rate) = 0;
75
76 // De-registers |payload_type| from the payload registry.
77 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
78
79 // Parses the media specific parts of an RTP packet and updates the receiver
80 // state. This for instance means that any changes in SSRC and payload type is
81 // detected and acted upon.
82 virtual bool IncomingRtpPacket(const RTPHeader& rtp_header,
83 const uint8_t* payload,
84 size_t payload_length,
85 PayloadUnion payload_specific,
86 bool in_order) = 0;
87
88 // Returns the currently configured NACK method.
89 virtual NACKMethod NACK() const = 0;
90
91 // Turn negative acknowledgement (NACK) requests on/off.
92 virtual void SetNACKStatus(const NACKMethod method) = 0;
93
94 // Gets the last received timestamp. Returns true if a packet has been
95 // received, false otherwise.
96 virtual bool Timestamp(uint32_t* timestamp) const = 0;
97 // Gets the time in milliseconds when the last timestamp was received.
98 // Returns true if a packet has been received, false otherwise.
99 virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0;
100
101 // Returns the remote SSRC of the currently received RTP stream.
102 virtual uint32_t SSRC() const = 0;
103
104 // Returns the current remote CSRCs.
105 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
106
107 // Returns the current energy of the RTP stream received.
108 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
109};
110} // namespace webrtc
111
112#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_