andrew@webrtc.org | a7b57da | 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 | e561f8c | 2013-04-02 20:37:14 +0000 | [diff] [blame] | 16 | #include "webrtc/engine_configurations.h" |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 17 | #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" |
pwestin@webrtc.org | e561f8c | 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" |
| 21 | #include "webrtc/video_engine/vie_defines.h" |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class CriticalSectionWrapper; |
| 26 | class Encryption; |
stefan@webrtc.org | 5632a64 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 27 | class FecReceiver; |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 28 | class ReceiveStatistics; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 29 | class RemoteBitrateEstimator; |
| 30 | class RtpDump; |
stefan@webrtc.org | 028ec72 | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 31 | class RtpHeaderParser; |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 32 | class RTPPayloadRegistry; |
| 33 | class RtpReceiver; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 34 | class RtpRtcp; |
| 35 | class VideoCodingModule; |
| 36 | |
pwestin@webrtc.org | e561f8c | 2013-04-02 20:37:14 +0000 | [diff] [blame] | 37 | class ViEReceiver : public RtpData { |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 38 | public: |
| 39 | ViEReceiver(const int32_t channel_id, VideoCodingModule* module_vcm, |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 40 | RemoteBitrateEstimator* remote_bitrate_estimator, |
| 41 | RtpFeedback* rtp_feedback); |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 42 | ~ViEReceiver(); |
| 43 | |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 44 | bool SetReceiveCodec(const VideoCodec& video_codec); |
| 45 | bool RegisterPayload(const VideoCodec& video_codec); |
| 46 | |
stefan@webrtc.org | 5632a64 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 47 | void SetNackStatus(bool enable, int max_nack_reordering_threshold); |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 48 | void SetRtxStatus(bool enable, uint32_t ssrc); |
| 49 | void SetRtxPayloadType(uint32_t payload_type); |
| 50 | |
| 51 | uint32_t GetRemoteSsrc() const; |
| 52 | int GetCsrcs(uint32_t* csrcs) const; |
| 53 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 54 | int RegisterExternalDecryption(Encryption* decryption); |
| 55 | int DeregisterExternalDecryption(); |
| 56 | |
| 57 | void SetRtpRtcpModule(RtpRtcp* module); |
| 58 | |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 59 | RtpReceiver* GetRtpReceiver() const; |
| 60 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 61 | void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules); |
| 62 | |
stefan@webrtc.org | 8687453 | 2013-05-29 13:28:21 +0000 | [diff] [blame] | 63 | bool SetReceiveTimestampOffsetStatus(bool enable, int id); |
| 64 | bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id); |
stefan@webrtc.org | 028ec72 | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 65 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 66 | void StartReceive(); |
| 67 | void StopReceive(); |
| 68 | |
| 69 | int StartRTPDump(const char file_nameUTF8[1024]); |
| 70 | int StopRTPDump(); |
| 71 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 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); |
wu@webrtc.org | 55055d2 | 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 | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 77 | |
| 78 | // Implements RtpData. |
pbos@webrtc.org | 2a5d229 | 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 | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 82 | const WebRtcRTPHeader* rtp_header); |
| 83 | |
mflodman@webrtc.org | 89c3de3 | 2013-02-06 17:46:39 +0000 | [diff] [blame] | 84 | void EstimatedReceiveBandwidth(unsigned int* available_bandwidth) const; |
stefan@webrtc.org | 3442158 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 85 | |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 86 | ReceiveStatistics* GetReceiveStatistics() const; |
| 87 | |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 88 | private: |
pbos@webrtc.org | 2a5d229 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 89 | int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length); |
stefan@webrtc.org | 5632a64 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 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, |
| 95 | int packet_length, |
| 96 | const RTPHeader& header); |
pbos@webrtc.org | 2a5d229 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 97 | int InsertRTCPPacket(const int8_t* rtcp_packet, int rtcp_packet_length); |
stefan@webrtc.org | 5632a64 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 98 | bool IsPacketInOrder(const RTPHeader& header) const; |
stefan@webrtc.org | e9274ae | 2013-11-08 15:18:52 +0000 | [diff] [blame] | 99 | bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 100 | |
| 101 | scoped_ptr<CriticalSectionWrapper> receive_cs_; |
| 102 | const int32_t channel_id_; |
stefan@webrtc.org | 028ec72 | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 103 | scoped_ptr<RtpHeaderParser> rtp_header_parser_; |
wu@webrtc.org | 55055d2 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 104 | scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 105 | scoped_ptr<RtpReceiver> rtp_receiver_; |
| 106 | scoped_ptr<ReceiveStatistics> rtp_receive_statistics_; |
stefan@webrtc.org | 5632a64 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 107 | scoped_ptr<FecReceiver> fec_receiver_; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 108 | RtpRtcp* rtp_rtcp_; |
| 109 | std::list<RtpRtcp*> rtp_rtcp_simulcast_; |
| 110 | VideoCodingModule* vcm_; |
| 111 | RemoteBitrateEstimator* remote_bitrate_estimator_; |
| 112 | |
| 113 | Encryption* external_decryption_; |
pbos@webrtc.org | 2a5d229 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 114 | uint8_t* decryption_buffer_; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 115 | RtpDump* rtp_dump_; |
| 116 | bool receiving_; |
stefan@webrtc.org | 5632a64 | 2013-09-06 13:40:11 +0000 | [diff] [blame] | 117 | uint8_t restored_packet_[kViEMaxMtu]; |
| 118 | bool restored_packet_in_use_; |
andrew@webrtc.org | a7b57da | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | } // namespace webrt |
| 122 | |
| 123 | #endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_ |