blob: 54a99c93a1de5fc4dbb62a08536d529242ca9572 [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;
magjed6b272c52016-11-25 02:29:39 -080062 // Registers a receive payload in the payload registry.
63 virtual int32_t RegisterReceivePayload(const VideoCodec& video_codec) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010064
65 // De-registers |payload_type| from the payload registry.
66 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
67
68 // Parses the media specific parts of an RTP packet and updates the receiver
69 // state. This for instance means that any changes in SSRC and payload type is
70 // detected and acted upon.
71 virtual bool IncomingRtpPacket(const RTPHeader& rtp_header,
72 const uint8_t* payload,
73 size_t payload_length,
74 PayloadUnion payload_specific,
75 bool in_order) = 0;
76
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010077 // Gets the last received timestamp. Returns true if a packet has been
78 // received, false otherwise.
79 virtual bool Timestamp(uint32_t* timestamp) const = 0;
80 // Gets the time in milliseconds when the last timestamp was received.
81 // Returns true if a packet has been received, false otherwise.
82 virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0;
83
84 // Returns the remote SSRC of the currently received RTP stream.
85 virtual uint32_t SSRC() const = 0;
86
87 // Returns the current remote CSRCs.
88 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
89
90 // Returns the current energy of the RTP stream received.
91 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010092};
93} // namespace webrtc
94
95#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RECEIVER_H_