blob: 95bade62fe638e7217c30e174388388c94290aa6 [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
hbos8d609f62017-04-10 07:39:05 -070014#include <vector>
15
16#include "webrtc/api/rtpreceiverinterface.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010017#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
18#include "webrtc/typedefs.h"
19
20namespace webrtc {
21
magjed56124bd2016-11-24 09:34:46 -080022struct CodecInst;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010023class RTPPayloadRegistry;
magjed56124bd2016-11-24 09:34:46 -080024class VideoCodec;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010025
danilchap799a9d02016-09-22 03:36:27 -070026class TelephoneEventHandler {
27 public:
28 virtual ~TelephoneEventHandler() {}
29
30 // The following three methods implement the TelephoneEventHandler interface.
31 // Forward DTMFs to decoder for playout.
32 virtual void SetTelephoneEventForwardToDecoder(bool forward_to_decoder) = 0;
33
34 // Is forwarding of outband telephone events turned on/off?
35 virtual bool TelephoneEventForwardToDecoder() const = 0;
36
37 // Is TelephoneEvent configured with payload type payload_type
38 virtual bool TelephoneEventPayloadType(const int8_t payload_type) const = 0;
39};
40
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010041class RtpReceiver {
42 public:
43 // Creates a video-enabled RTP receiver.
44 static RtpReceiver* CreateVideoReceiver(
45 Clock* clock,
46 RtpData* incoming_payload_callback,
47 RtpFeedback* incoming_messages_callback,
48 RTPPayloadRegistry* rtp_payload_registry);
49
50 // Creates an audio-enabled RTP receiver.
51 static RtpReceiver* CreateAudioReceiver(
52 Clock* clock,
solenberg1d031392016-03-30 02:42:32 -070053 RtpData* incoming_payload_callback,
54 RtpFeedback* incoming_messages_callback,
55 RTPPayloadRegistry* rtp_payload_registry);
56
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010057 virtual ~RtpReceiver() {}
58
danilchap799a9d02016-09-22 03:36:27 -070059 // Returns a TelephoneEventHandler if available.
60 virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
61
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010062 // Registers a receive payload in the payload registry and notifies the media
63 // receiver strategy.
magjed56124bd2016-11-24 09:34:46 -080064 virtual int32_t RegisterReceivePayload(const CodecInst& audio_codec) = 0;
magjed6b272c52016-11-25 02:29:39 -080065 // Registers a receive payload in the payload registry.
66 virtual int32_t RegisterReceivePayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010067
68 // De-registers |payload_type| from the payload registry.
69 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
70
71 // Parses the media specific parts of an RTP packet and updates the receiver
72 // state. This for instance means that any changes in SSRC and payload type is
73 // detected and acted upon.
74 virtual bool IncomingRtpPacket(const RTPHeader& rtp_header,
75 const uint8_t* payload,
76 size_t payload_length,
77 PayloadUnion payload_specific,
78 bool in_order) = 0;
79
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010080 // Gets the last received timestamp. Returns true if a packet has been
81 // received, false otherwise.
82 virtual bool Timestamp(uint32_t* timestamp) const = 0;
83 // Gets the time in milliseconds when the last timestamp was received.
84 // Returns true if a packet has been received, false otherwise.
85 virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0;
86
87 // Returns the remote SSRC of the currently received RTP stream.
88 virtual uint32_t SSRC() const = 0;
89
90 // Returns the current remote CSRCs.
91 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
92
93 // Returns the current energy of the RTP stream received.
94 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
hbos8d609f62017-04-10 07:39:05 -070095
96 virtual std::vector<RtpSource> GetSources() const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010097};
98} // namespace webrtc
99
100#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_