2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_IMPL_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_IMPL_H_
14 #include "webrtc/modules/rtp_rtcp/interface/rtp_receiver.h"
15 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
17 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
18 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
19 #include "webrtc/typedefs.h"
23 class RtpReceiverImpl : public RtpReceiver {
25 // Callbacks passed in here may not be NULL (use Null Object callbacks if you
26 // want callbacks to do nothing). This class takes ownership of the media
27 // receiver but nothing else.
28 RtpReceiverImpl(int32_t id,
30 RtpAudioFeedback* incoming_audio_messages_callback,
31 RtpFeedback* incoming_messages_callback,
32 RTPPayloadRegistry* rtp_payload_registry,
33 RTPReceiverStrategy* rtp_media_receiver);
35 virtual ~RtpReceiverImpl();
37 virtual int32_t RegisterReceivePayload(
38 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
39 const int8_t payload_type,
40 const uint32_t frequency,
41 const uint8_t channels,
42 const uint32_t rate) OVERRIDE;
44 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) OVERRIDE;
46 virtual bool IncomingRtpPacket(
47 const RTPHeader& rtp_header,
48 const uint8_t* payload,
50 PayloadUnion payload_specific,
51 bool in_order) OVERRIDE;
53 virtual NACKMethod NACK() const OVERRIDE;
55 // Turn negative acknowledgement requests on/off.
56 virtual void SetNACKStatus(const NACKMethod method) OVERRIDE;
58 // Returns the last received timestamp.
59 virtual bool Timestamp(uint32_t* timestamp) const OVERRIDE;
60 virtual bool LastReceivedTimeMs(int64_t* receive_time_ms) const OVERRIDE;
62 virtual uint32_t SSRC() const OVERRIDE;
64 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const OVERRIDE;
66 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const OVERRIDE;
68 virtual TelephoneEventHandler* GetTelephoneEventHandler() OVERRIDE;
71 bool HaveReceivedFrame() const;
73 void CheckSSRCChanged(const RTPHeader& rtp_header);
74 void CheckCSRC(const WebRtcRTPHeader& rtp_header);
75 int32_t CheckPayloadChanged(const RTPHeader& rtp_header,
76 const int8_t first_payload_byte,
78 PayloadUnion* payload,
79 bool* should_reset_statistics);
82 RTPPayloadRegistry* rtp_payload_registry_;
83 scoped_ptr<RTPReceiverStrategy> rtp_media_receiver_;
87 RtpFeedback* cb_rtp_feedback_;
89 scoped_ptr<CriticalSectionWrapper> critical_section_rtp_receiver_;
90 int64_t last_receive_time_;
91 uint16_t last_received_payload_length_;
96 uint32_t current_remote_csrc_[kRtpCsrcSize];
98 uint32_t last_received_timestamp_;
99 int64_t last_received_frame_time_ms_;
100 uint16_t last_received_sequence_number_;
102 NACKMethod nack_method_;
104 } // namespace webrtc
105 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_IMPL_H_