andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 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_VIDEO_ENGINE_VIE_RECEIVER_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_ |
| 13 | |
| 14 | #include <list> |
| 15 | |
pwestin@webrtc.org | 065b64d | 2013-04-02 20:37:14 +0000 | [diff] [blame] | 16 | #include "webrtc/engine_configurations.h" |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 17 | #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" |
pwestin@webrtc.org | 065b64d | 2013-04-02 20:37:14 +0000 | [diff] [blame] | 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" |
wu@webrtc.org | efeb8ce | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 21 | #include "webrtc/video_engine/include/vie_network.h" |
pwestin@webrtc.org | 065b64d | 2013-04-02 20:37:14 +0000 | [diff] [blame] | 22 | #include "webrtc/video_engine/vie_defines.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
| 25 | |
| 26 | class CriticalSectionWrapper; |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 27 | class FecReceiver; |
wu@webrtc.org | 2fae0d1 | 2014-05-14 16:53:51 +0000 | [diff] [blame] | 28 | class RemoteNtpTimeEstimator; |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 29 | class ReceiveStatistics; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 30 | class RemoteBitrateEstimator; |
| 31 | class RtpDump; |
stefan@webrtc.org | 6696fba | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 32 | class RtpHeaderParser; |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 33 | class RTPPayloadRegistry; |
| 34 | class RtpReceiver; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 35 | class RtpRtcp; |
| 36 | class VideoCodingModule; |
jiayl@webrtc.org | d1e7fac | 2014-02-10 19:12:14 +0000 | [diff] [blame] | 37 | struct ReceiveBandwidthEstimatorStats; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 38 | |
pwestin@webrtc.org | 065b64d | 2013-04-02 20:37:14 +0000 | [diff] [blame] | 39 | class ViEReceiver : public RtpData { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 40 | public: |
| 41 | ViEReceiver(const int32_t channel_id, VideoCodingModule* module_vcm, |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 42 | RemoteBitrateEstimator* remote_bitrate_estimator, |
| 43 | RtpFeedback* rtp_feedback); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 44 | ~ViEReceiver(); |
| 45 | |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 46 | bool SetReceiveCodec(const VideoCodec& video_codec); |
| 47 | bool RegisterPayload(const VideoCodec& video_codec); |
| 48 | |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 49 | void SetNackStatus(bool enable, int max_nack_reordering_threshold); |
stefan@webrtc.org | 903e746 | 2014-06-05 08:25:29 +0000 | [diff] [blame] | 50 | void SetRtxPayloadType(int payload_type); |
| 51 | void SetRtxSsrc(uint32_t ssrc); |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 52 | |
| 53 | uint32_t GetRemoteSsrc() const; |
| 54 | int GetCsrcs(uint32_t* csrcs) const; |
| 55 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 56 | void SetRtpRtcpModule(RtpRtcp* module); |
| 57 | |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 58 | RtpReceiver* GetRtpReceiver() const; |
| 59 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 60 | void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules); |
| 61 | |
stefan@webrtc.org | 4e5f983 | 2013-05-29 13:28:21 +0000 | [diff] [blame] | 62 | bool SetReceiveTimestampOffsetStatus(bool enable, int id); |
| 63 | bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id); |
stefan@webrtc.org | 6696fba | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 64 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 65 | void StartReceive(); |
| 66 | void StopReceive(); |
| 67 | |
| 68 | int StartRTPDump(const char file_nameUTF8[1024]); |
| 69 | int StopRTPDump(); |
| 70 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 71 | // Receives packets from external transport. |
wu@webrtc.org | efeb8ce | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 72 | int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length, |
| 73 | const PacketTime& packet_time); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 74 | int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length); |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 75 | virtual bool OnRecoveredPacket(const uint8_t* packet, |
| 76 | int packet_length) OVERRIDE; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 77 | |
| 78 | // Implements RtpData. |
pbos@webrtc.org | 67879bc | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 79 | virtual int32_t OnReceivedPayloadData( |
| 80 | const uint8_t* payload_data, |
| 81 | const uint16_t payload_size, |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 82 | const WebRtcRTPHeader* rtp_header); |
| 83 | |
jiayl@webrtc.org | d1e7fac | 2014-02-10 19:12:14 +0000 | [diff] [blame] | 84 | void GetReceiveBandwidthEstimatorStats( |
| 85 | ReceiveBandwidthEstimatorStats* output) const; |
| 86 | |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 87 | ReceiveStatistics* GetReceiveStatistics() const; |
| 88 | |
solenberg@webrtc.org | 2d3624c | 2014-03-24 20:28:11 +0000 | [diff] [blame] | 89 | void ReceivedBWEPacket(int64_t arrival_time_ms, int payload_size, |
| 90 | const RTPHeader& header); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 91 | private: |
solenberg@webrtc.org | 800136d | 2014-02-11 15:27:49 +0000 | [diff] [blame] | 92 | int InsertRTPPacket(const uint8_t* rtp_packet, int rtp_packet_length, |
wu@webrtc.org | efeb8ce | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 93 | const PacketTime& packet_time); |
sprang@webrtc.org | 7d99cd4 | 2014-01-23 10:00:39 +0000 | [diff] [blame] | 94 | bool ReceivePacket(const uint8_t* packet, |
| 95 | int packet_length, |
| 96 | const RTPHeader& header, |
| 97 | bool in_order); |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 98 | // Parses and handles for instance RTX and RED headers. |
| 99 | // This function assumes that it's being called from only one thread. |
| 100 | bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet, |
| 101 | int packet_length, |
| 102 | const RTPHeader& header); |
solenberg@webrtc.org | 800136d | 2014-02-11 15:27:49 +0000 | [diff] [blame] | 103 | int InsertRTCPPacket(const uint8_t* rtcp_packet, int rtcp_packet_length); |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 104 | bool IsPacketInOrder(const RTPHeader& header) const; |
stefan@webrtc.org | 7e97e4c | 2013-11-08 15:18:52 +0000 | [diff] [blame] | 105 | bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 106 | |
| 107 | scoped_ptr<CriticalSectionWrapper> receive_cs_; |
stefan@webrtc.org | 6696fba | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 108 | scoped_ptr<RtpHeaderParser> rtp_header_parser_; |
wu@webrtc.org | 7fc75bb | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 109 | scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 110 | scoped_ptr<RtpReceiver> rtp_receiver_; |
| 111 | scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 112 | scoped_ptr<FecReceiver> fec_receiver_; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 113 | RtpRtcp* rtp_rtcp_; |
| 114 | std::list<RtpRtcp*> rtp_rtcp_simulcast_; |
| 115 | VideoCodingModule* vcm_; |
| 116 | RemoteBitrateEstimator* remote_bitrate_estimator_; |
| 117 | |
wu@webrtc.org | 2fae0d1 | 2014-05-14 16:53:51 +0000 | [diff] [blame] | 118 | scoped_ptr<RemoteNtpTimeEstimator> ntp_estimator_; |
wu@webrtc.org | 093fc0b | 2014-04-24 22:10:24 +0000 | [diff] [blame] | 119 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 120 | RtpDump* rtp_dump_; |
| 121 | bool receiving_; |
stefan@webrtc.org | db74c61 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 122 | uint8_t restored_packet_[kViEMaxMtu]; |
| 123 | bool restored_packet_in_use_; |
solenberg@webrtc.org | 2d3624c | 2014-03-24 20:28:11 +0000 | [diff] [blame] | 124 | bool receiving_ast_enabled_; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | } // namespace webrt |
| 128 | |
| 129 | #endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_ |