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/include/vie_network.h"
22 #include "webrtc/video_engine/vie_defines.h"
26 class CriticalSectionWrapper;
28 class ReceiveStatistics;
29 class RemoteBitrateEstimator;
31 class RtpHeaderParser;
32 class RTPPayloadRegistry;
35 class VideoCodingModule;
36 struct ReceiveBandwidthEstimatorStats;
38 class ViEReceiver : public RtpData {
40 ViEReceiver(const int32_t channel_id, VideoCodingModule* module_vcm,
41 RemoteBitrateEstimator* remote_bitrate_estimator,
42 RtpFeedback* rtp_feedback);
45 bool SetReceiveCodec(const VideoCodec& video_codec);
46 bool RegisterPayload(const VideoCodec& video_codec);
48 void SetNackStatus(bool enable, int max_nack_reordering_threshold);
49 void SetRtxStatus(bool enable, uint32_t ssrc);
50 void SetRtxPayloadType(uint32_t payload_type);
52 uint32_t GetRemoteSsrc() const;
53 int GetCsrcs(uint32_t* csrcs) const;
55 void SetRtpRtcpModule(RtpRtcp* module);
57 RtpReceiver* GetRtpReceiver() const;
59 void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules);
61 bool SetReceiveTimestampOffsetStatus(bool enable, int id);
62 bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id);
67 int StartRTPDump(const char file_nameUTF8[1024]);
70 // Receives packets from external transport.
71 int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length,
72 const PacketTime& packet_time);
73 int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length);
74 virtual bool OnRecoveredPacket(const uint8_t* packet,
75 int packet_length) OVERRIDE;
77 // Implements RtpData.
78 virtual int32_t OnReceivedPayloadData(
79 const uint8_t* payload_data,
80 const uint16_t payload_size,
81 const WebRtcRTPHeader* rtp_header);
83 void EstimatedReceiveBandwidth(unsigned int* available_bandwidth) const;
85 void GetReceiveBandwidthEstimatorStats(
86 ReceiveBandwidthEstimatorStats* output) const;
88 ReceiveStatistics* GetReceiveStatistics() const;
91 int InsertRTPPacket(const uint8_t* rtp_packet, int rtp_packet_length,
92 const PacketTime& packet_time);
93 bool ReceivePacket(const uint8_t* packet,
95 const RTPHeader& header,
97 // Parses and handles for instance RTX and RED headers.
98 // This function assumes that it's being called from only one thread.
99 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
101 const RTPHeader& header);
102 int InsertRTCPPacket(const uint8_t* rtcp_packet, int rtcp_packet_length);
103 bool IsPacketInOrder(const RTPHeader& header) const;
104 bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
106 scoped_ptr<CriticalSectionWrapper> receive_cs_;
107 const int32_t channel_id_;
108 scoped_ptr<RtpHeaderParser> rtp_header_parser_;
109 scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
110 scoped_ptr<RtpReceiver> rtp_receiver_;
111 scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
112 scoped_ptr<FecReceiver> fec_receiver_;
114 std::list<RtpRtcp*> rtp_rtcp_simulcast_;
115 VideoCodingModule* vcm_;
116 RemoteBitrateEstimator* remote_bitrate_estimator_;
120 uint8_t restored_packet_[kViEMaxMtu];
121 bool restored_packet_in_use_;
126 #endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_