blob: 9db1c63da78976d554d8530e916f017cf99a66be [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
19class RTPPayloadRegistry;
20
danilchap799a9d02016-09-22 03:36:27 -070021class TelephoneEventHandler {
22 public:
23 virtual ~TelephoneEventHandler() {}
24
25 // The following three methods implement the TelephoneEventHandler interface.
26 // Forward DTMFs to decoder for playout.
27 virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
28
29 // Is forwarding of outband telephone events turned on/off?
30 virtual bool TelephoneEventForwardToDecoder() const = 0;
31
32 // Is TelephoneEvent configured with payload type payload_type
33 virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
34};
35
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010036class RtpReceiver {
37 public:
38 // Creates a video-enabled RTP receiver.
39 static RtpReceiver* CreateVideoReceiver(
40 Clock* clock,
41 RtpData* incoming_payload_callback,
42 RtpFeedback* incoming_messages_callback,
43 RTPPayloadRegistry* rtp_payload_registry);
44
45 // Creates an audio-enabled RTP receiver.
46 static RtpReceiver* CreateAudioReceiver(
47 Clock* clock,
solenberg1d031392016-03-30 02:42:32 -070048 RtpData* incoming_payload_callback,
49 RtpFeedback* incoming_messages_callback,
50 RTPPayloadRegistry* rtp_payload_registry);
51
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010052 virtual ~RtpReceiver() {}
53
danilchap799a9d02016-09-22 03:36:27 -070054 // Returns a TelephoneEventHandler if available.
55 virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
56
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010057 // Registers a receive payload in the payload registry and notifies the media
58 // receiver strategy.
59 virtual int32_t RegisterReceivePayload(
60 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
61 const int8_t payload_type,
62 const uint32_t frequency,
Peter Kasting69558702016-01-12 16:26:35 -080063 const size_t channels,
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010064 const uint32_t rate) = 0;
65
66 // De-registers |payload_type| from the payload registry.
67 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
68
69 // Parses the media specific parts of an RTP packet and updates the receiver
70 // state. This for instance means that any changes in SSRC and payload type is
71 // detected and acted upon.
72 virtual bool IncomingRtpPacket(const RTPHeader& rtp_header,
73 const uint8_t* payload,
74 size_t payload_length,
75 PayloadUnion payload_specific,
76 bool in_order) = 0;
77
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010078 // Gets the last received timestamp. Returns true if a packet has been
79 // received, false otherwise.
80 virtual bool Timestamp(uint32_t* timestamp) const = 0;
81 // Gets the time in milliseconds when the last timestamp was received.
82 // Returns true if a packet has been received, false otherwise.
83 virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0;
84
85 // Returns the remote SSRC of the currently received RTP stream.
86 virtual uint32_t SSRC() const = 0;
87
88 // Returns the current remote CSRCs.
89 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
90
91 // Returns the current energy of the RTP stream received.
92 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
93};
94} // namespace webrtc
95
96#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_