• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 namespace webrtc {
18 
19 class RTPPayloadRegistry;
20 
21 class TelephoneEventHandler {
22  public:
~TelephoneEventHandler()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 
36 class 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 
~RtpReceiver()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(const RTPHeader& rtp_header,
74                                  const uint8_t* payload,
75                                  int payload_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 void SetNACKStatus(const NACKMethod method) = 0;
84 
85   // Gets the last received timestamp. Returns true if a packet has been
86   // received, false otherwise.
87   virtual bool Timestamp(uint32_t* timestamp) const = 0;
88   // Gets the time in milliseconds when the last timestamp was received.
89   // Returns true if a packet has been received, false otherwise.
90   virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const = 0;
91 
92   // Returns the remote SSRC of the currently received RTP stream.
93   virtual uint32_t SSRC() const = 0;
94 
95   // Returns the current remote CSRCs.
96   virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0;
97 
98   // Returns the current energy of the RTP stream received.
99   virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0;
100 };
101 }  // namespace webrtc
102 
103 #endif  // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_RECEIVER_H_
104