blob: 63014370e79fcf3cff0232cbe21ef036bbea6cb1 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org39e96592012-03-01 18:22:48 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +000011#ifndef WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_
12#define WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +000014#include <list>
15
pwestin@webrtc.org82dcc9f2013-04-02 20:37:14 +000016#include "webrtc/engine_configurations.h"
wu@webrtc.org822fbd82013-08-15 23:38:54 +000017#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
pwestin@webrtc.org82dcc9f2013-04-02 20:37:14 +000018#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"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000023namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000024
niklase@google.com470e71d2011-07-07 08:21:25 +000025class CriticalSectionWrapper;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000026class Encryption;
wu@webrtc.org822fbd82013-08-15 23:38:54 +000027class ReceiveStatistics;
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000028class RemoteBitrateEstimator;
niklase@google.com470e71d2011-07-07 08:21:25 +000029class RtpDump;
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000030class RtpHeaderParser;
wu@webrtc.org822fbd82013-08-15 23:38:54 +000031class RTPPayloadRegistry;
32class RtpReceiver;
niklase@google.com470e71d2011-07-07 08:21:25 +000033class RtpRtcp;
34class VideoCodingModule;
niklase@google.com470e71d2011-07-07 08:21:25 +000035
pwestin@webrtc.org82dcc9f2013-04-02 20:37:14 +000036class ViEReceiver : public RtpData {
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000037 public:
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000038 ViEReceiver(const int32_t channel_id, VideoCodingModule* module_vcm,
wu@webrtc.org822fbd82013-08-15 23:38:54 +000039 RemoteBitrateEstimator* remote_bitrate_estimator,
40 RtpFeedback* rtp_feedback);
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000041 ~ViEReceiver();
niklase@google.com470e71d2011-07-07 08:21:25 +000042
wu@webrtc.org822fbd82013-08-15 23:38:54 +000043 bool SetReceiveCodec(const VideoCodec& video_codec);
44 bool RegisterPayload(const VideoCodec& video_codec);
45
46 bool SetNackStatus(bool enable, int max_nack_reordering_threshold);
47 void SetRtxStatus(bool enable, uint32_t ssrc);
48 void SetRtxPayloadType(uint32_t payload_type);
49
50 uint32_t GetRemoteSsrc() const;
51 int GetCsrcs(uint32_t* csrcs) const;
52
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000053 int RegisterExternalDecryption(Encryption* decryption);
54 int DeregisterExternalDecryption();
niklase@google.com470e71d2011-07-07 08:21:25 +000055
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000056 void SetRtpRtcpModule(RtpRtcp* module);
57
wu@webrtc.org822fbd82013-08-15 23:38:54 +000058 RtpReceiver* GetRtpReceiver() const;
59
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000060 void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules);
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +000061
stefan@webrtc.org08994cc2013-05-29 13:28:21 +000062 bool SetReceiveTimestampOffsetStatus(bool enable, int id);
63 bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id);
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000064
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000065 void StartReceive();
66 void StopReceive();
niklase@google.com470e71d2011-07-07 08:21:25 +000067
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000068 int StartRTPDump(const char file_nameUTF8[1024]);
69 int StopRTPDump();
niklase@google.com470e71d2011-07-07 08:21:25 +000070
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000071 // Receives packets from external transport.
72 int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length);
73 int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length);
wu@webrtc.org822fbd82013-08-15 23:38:54 +000074 virtual bool OnRecoveredPacket(const uint8_t* packet,
75 int packet_length) OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000076
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000077 // Implements RtpData.
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000078 virtual int32_t OnReceivedPayloadData(
79 const uint8_t* payload_data,
80 const uint16_t payload_size,
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000081 const WebRtcRTPHeader* rtp_header);
niklase@google.com470e71d2011-07-07 08:21:25 +000082
mflodman@webrtc.org4fd55272013-02-06 17:46:39 +000083 void EstimatedReceiveBandwidth(unsigned int* available_bandwidth) const;
stefan@webrtc.orgb5865072013-02-01 14:33:42 +000084
wu@webrtc.org822fbd82013-08-15 23:38:54 +000085 ReceiveStatistics* GetReceiveStatistics() const;
86
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000087 private:
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000088 int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length);
89 int InsertRTCPPacket(const int8_t* rtcp_packet, int rtcp_packet_length);
wu@webrtc.org822fbd82013-08-15 23:38:54 +000090 bool IsPacketRetransmitted(const RTPHeader& header) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000091
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000092 scoped_ptr<CriticalSectionWrapper> receive_cs_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000093 const int32_t channel_id_;
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000094 scoped_ptr<RtpHeaderParser> rtp_header_parser_;
wu@webrtc.org822fbd82013-08-15 23:38:54 +000095 scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
96 scoped_ptr<RtpReceiver> rtp_receiver_;
97 scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000098 RtpRtcp* rtp_rtcp_;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000099 std::list<RtpRtcp*> rtp_rtcp_simulcast_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +0000100 VideoCodingModule* vcm_;
stefan@webrtc.org976a7e62012-09-21 13:20:21 +0000101 RemoteBitrateEstimator* remote_bitrate_estimator_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000102
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +0000103 Encryption* external_decryption_;
pbos@webrtc.orgb238d122013-04-09 13:41:51 +0000104 uint8_t* decryption_buffer_;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +0000105 RtpDump* rtp_dump_;
106 bool receiving_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000107};
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +0000108
109} // namespace webrt
110
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +0000111#endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_