1 /* 2 * Copyright (c) 2013 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_SOURCE_RTP_RECEIVER_IMPL_H_ 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_IMPL_H_ 13 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" 20 21 namespace webrtc { 22 23 class RtpReceiverImpl : public RtpReceiver { 24 public: 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, 29 Clock* clock, 30 RtpAudioFeedback* incoming_audio_messages_callback, 31 RtpFeedback* incoming_messages_callback, 32 RTPPayloadRegistry* rtp_payload_registry, 33 RTPReceiverStrategy* rtp_media_receiver); 34 35 virtual ~RtpReceiverImpl(); 36 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; 43 44 virtual int32_t DeRegisterReceivePayload(const int8_t payload_type) OVERRIDE; 45 46 virtual bool IncomingRtpPacket( 47 const RTPHeader& rtp_header, 48 const uint8_t* payload, 49 int payload_length, 50 PayloadUnion payload_specific, 51 bool in_order) OVERRIDE; 52 53 virtual NACKMethod NACK() const OVERRIDE; 54 55 // Turn negative acknowledgement requests on/off. 56 virtual void SetNACKStatus(const NACKMethod method) OVERRIDE; 57 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; 61 62 virtual uint32_t SSRC() const OVERRIDE; 63 64 virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const OVERRIDE; 65 66 virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const OVERRIDE; 67 68 virtual TelephoneEventHandler* GetTelephoneEventHandler() OVERRIDE; 69 70 private: 71 bool HaveReceivedFrame() const; 72 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, 77 bool& is_red, 78 PayloadUnion* payload, 79 bool* should_reset_statistics); 80 81 Clock* clock_; 82 RTPPayloadRegistry* rtp_payload_registry_; 83 scoped_ptr<RTPReceiverStrategy> rtp_media_receiver_; 84 85 int32_t id_; 86 87 RtpFeedback* cb_rtp_feedback_; 88 89 scoped_ptr<CriticalSectionWrapper> critical_section_rtp_receiver_; 90 int64_t last_receive_time_; 91 uint16_t last_received_payload_length_; 92 93 // SSRCs. 94 uint32_t ssrc_; 95 uint8_t num_csrcs_; 96 uint32_t current_remote_csrc_[kRtpCsrcSize]; 97 98 uint32_t last_received_timestamp_; 99 int64_t last_received_frame_time_ms_; 100 uint16_t last_received_sequence_number_; 101 102 NACKMethod nack_method_; 103 }; 104 } // namespace webrtc 105 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_RECEIVER_IMPL_H_ 106