blob: 799d6b64c399a6d5bb0f28fbe478aad4d9b0a789 [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
magjed56124bd2016-11-24 09:34:46 -080019struct CodecInst;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010020class RTPPayloadRegistry;
magjed56124bd2016-11-24 09:34:46 -080021class VideoCodec;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010022
danilchap799a9d02016-09-22 03:36:27 -070023class TelephoneEventHandler {
24 public:
25 virtual ~TelephoneEventHandler() {}
26
27 // The following three methods implement the TelephoneEventHandler interface.
28 // Forward DTMFs to decoder for playout.
29 virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
30
31 // Is forwarding of outband telephone events turned on/off?
32 virtual bool TelephoneEventForwardToDecoder() const = 0;
33
34 // Is TelephoneEvent configured with payload type payload_type
35 virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
36};
37
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010038class RtpReceiver {
39 public:
40 // Creates a video-enabled RTP receiver.
41 static RtpReceiver* CreateVideoReceiver(
42 Clock* clock,
43 RtpData* incoming_payload_callback,
44 RtpFeedback* incoming_messages_callback,
45 RTPPayloadRegistry* rtp_payload_registry);
46
47 // Creates an audio-enabled RTP receiver.
48 static RtpReceiver* CreateAudioReceiver(
49 Clock* clock,
solenberg1d031392016-03-30 02:42:32 -070050 RtpData* incoming_payload_callback,
51 RtpFeedback* incoming_messages_callback,
52 RTPPayloadRegistry* rtp_payload_registry);
53
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010054 virtual ~RtpReceiver() {}
55
danilchap799a9d02016-09-22 03:36:27 -070056 // Returns a TelephoneEventHandler if available.
57 virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
58
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010059 // Registers a receive payload in the payload registry and notifies the media
60 // receiver strategy.
magjed56124bd2016-11-24 09:34:46 -080061 virtual int32_t RegisterReceivePayload(const CodecInst& audio_codec) = 0;
62 // TODO(magjed): Remove once external code is updated.
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010063 virtual int32_t RegisterReceivePayload(
64 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
65 const int8_t payload_type,
66 const uint32_t frequency,
Peter Kasting69558702016-01-12 16:26:35 -080067 const size_t channels,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010068 const uint32_t rate) = 0;
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,
79 PayloadUnion payload_specific,
80 bool in_order) = 0;
81
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010082 // Gets the last received timestamp. Returns true if a packet has been
83 // received, false otherwise.
84 virtual bool Timestamp(uint32_t* timestamp) const = 0;
85 // Gets the time in milliseconds when the last timestamp was received.
86 // Returns true if a packet has been received, false otherwise.
87 virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0;
88
89 // Returns the remote SSRC of the currently received RTP stream.
90 virtual uint32_t SSRC() const = 0;
91
92 // Returns the current remote CSRCs.
93 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
94
95 // Returns the current energy of the RTP stream received.
96 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
97};
98} // namespace webrtc
99
100#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_