blob: 40145e4978c46b2ea3da306da0491838f29639ea [file] [log] [blame]
wu@webrtc.org822fbd82013-08-15 23:38:54 +00001/*
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_INTERFACE_RTP_RECEIVER_H_
12#define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_
13
14#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
15#include "webrtc/typedefs.h"
16
17namespace webrtc {
18
19class RTPPayloadRegistry;
20
21class 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
36class RtpReceiver {
37 public:
38 // Creates a video-enabled RTP receiver.
39 static RtpReceiver* CreateVideoReceiver(
40 int id, 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 int id, Clock* clock,
48 RtpAudioFeedback* incoming_audio_feedback,
49 RtpData* incoming_payload_callback,
50 RtpFeedback* incoming_messages_callback,
51 RTPPayloadRegistry* rtp_payload_registry);
52
53 virtual ~RtpReceiver() {}
54
55 // Returns a TelephoneEventHandler if available.
56 virtual TelephoneEventHandler* GetTelephoneEventHandler() = 0;
57
58 // Registers a receive payload in the payload registry and notifies the media
59 // receiver strategy.
60 virtual int32_t RegisterReceivePayload(
61 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
62 const int8_t payload_type,
63 const uint32_t frequency,
64 const uint8_t channels,
65 const uint32_t rate) = 0;
66
67 // De-registers |payload_type| from the payload registry.
68 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) = 0;
69
70 // Parses the media specific parts of an RTP packet and updates the receiver
71 // state. This for instance means that any changes in SSRC and payload type is
72 // detected and acted upon.
73 virtual bool IncomingRtpPacket(RTPHeader* rtp_header,
74 const uint8_t* incoming_rtp_packet,
75 int incoming_rtp_packet_length,
76 PayloadUnion payload_specific,
77 bool in_order) = 0;
78
79 // Returns the currently configured NACK method.
80 virtual NACKMethod NACK() const = 0;
81
82 // Turn negative acknowledgement (NACK) requests on/off.
83 virtual int32_t SetNACKStatus(const NACKMethod method,
84 int max_reordering_threshold) = 0;
85
86 // Returns the last received timestamp.
87 virtual uint32_t Timestamp() const = 0;
88 // Returns the time in milliseconds when the last timestamp was received.
89 virtual int32_t LastReceivedTimeMs() const = 0;
90
91 // Returns the remote SSRC of the currently received RTP stream.
92 virtual uint32_t SSRC() const = 0;
93
94 // Returns the current remote CSRCs.
95 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
96
97 // Returns the current energy of the RTP stream received.
98 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
99
100 // Enable/disable RTX and set the SSRC to be used.
101 virtual void SetRTXStatus(bool enable, uint32_t ssrc) = 0;
102
103 // Returns the current RTX status and the SSRC and payload type used.
104 virtual void RTXStatus(bool* enable, uint32_t* ssrc,
105 int* payload_type) const = 0;
106
107 // Sets the RTX payload type.
108 virtual void SetRtxPayloadType(int payload_type) = 0;
109
110 // Returns true if the packet with RTP header |header| is likely to be a
111 // retransmitted packet, false otherwise.
112 virtual bool RetransmitOfOldPacket(const RTPHeader& header, int jitter,
113 int min_rtt) const = 0;
114
115 // Returns true if |sequence_number| is received in order, false otherwise.
116 virtual bool InOrderPacket(const uint16_t sequence_number) const = 0;
117};
118} // namespace webrtc
119
120#endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_