2 * Copyright (c) 2012 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_VIDEO_ENGINE_VIE_RECEIVER_H_
12 #define WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_
16 #include "webrtc/engine_configurations.h"
17 #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
18 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
19 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
20 #include "webrtc/typedefs.h"
21 #include "webrtc/video_engine/vie_defines.h"
25 class CriticalSectionWrapper;
28 class ReceiveStatistics;
29 class RemoteBitrateEstimator;
31 class RtpHeaderParser;
32 class RTPPayloadRegistry;
35 class VideoCodingModule;
37 class ViEReceiver : public RtpData {
39 ViEReceiver(const int32_t channel_id, VideoCodingModule* module_vcm,
40 RemoteBitrateEstimator* remote_bitrate_estimator,
41 RtpFeedback* rtp_feedback);
44 bool SetReceiveCodec(const VideoCodec& video_codec);
45 bool RegisterPayload(const VideoCodec& video_codec);
47 void SetNackStatus(bool enable, int max_nack_reordering_threshold);
48 void SetRtxStatus(bool enable, uint32_t ssrc);
49 void SetRtxPayloadType(uint32_t payload_type);
51 uint32_t GetRemoteSsrc() const;
52 int GetCsrcs(uint32_t* csrcs) const;
54 int RegisterExternalDecryption(Encryption* decryption);
55 int DeregisterExternalDecryption();
57 void SetRtpRtcpModule(RtpRtcp* module);
59 RtpReceiver* GetRtpReceiver() const;
61 void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules);
63 bool SetReceiveTimestampOffsetStatus(bool enable, int id);
64 bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id);
69 int StartRTPDump(const char file_nameUTF8[1024]);
72 // Receives packets from external transport.
73 int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length);
74 int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length);
75 virtual bool OnRecoveredPacket(const uint8_t* packet,
76 int packet_length) OVERRIDE;
78 // Implements RtpData.
79 virtual int32_t OnReceivedPayloadData(
80 const uint8_t* payload_data,
81 const uint16_t payload_size,
82 const WebRtcRTPHeader* rtp_header);
84 void EstimatedReceiveBandwidth(unsigned int* available_bandwidth) const;
86 ReceiveStatistics* GetReceiveStatistics() const;
89 int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length);
90 bool ReceivePacket(const uint8_t* packet, int packet_length,
91 const RTPHeader& header, bool in_order);
92 // Parses and handles for instance RTX and RED headers.
93 // This function assumes that it's being called from only one thread.
94 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
96 const RTPHeader& header);
97 int InsertRTCPPacket(const int8_t* rtcp_packet, int rtcp_packet_length);
98 bool IsPacketInOrder(const RTPHeader& header) const;
99 bool IsPacketRetransmitted(const RTPHeader& header) const;
101 scoped_ptr<CriticalSectionWrapper> receive_cs_;
102 const int32_t channel_id_;
103 scoped_ptr<RtpHeaderParser> rtp_header_parser_;
104 scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
105 scoped_ptr<RtpReceiver> rtp_receiver_;
106 scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
107 scoped_ptr<FecReceiver> fec_receiver_;
109 std::list<RtpRtcp*> rtp_rtcp_simulcast_;
110 VideoCodingModule* vcm_;
111 RemoteBitrateEstimator* remote_bitrate_estimator_;
113 Encryption* external_decryption_;
114 uint8_t* decryption_buffer_;
117 uint8_t restored_packet_[kViEMaxMtu];
118 bool restored_packet_in_use_;
123 #endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_