blob: 904a951433d9858833b833ae8b24908ba83050ba [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"
17#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
18#include "webrtc/system_wrappers/interface/scoped_ptr.h"
19#include "webrtc/typedefs.h"
20#include "webrtc/video_engine/vie_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000022namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
niklase@google.com470e71d2011-07-07 08:21:25 +000024class CriticalSectionWrapper;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000025class Encryption;
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000026class RemoteBitrateEstimator;
niklase@google.com470e71d2011-07-07 08:21:25 +000027class RtpDump;
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000028class RtpHeaderParser;
niklase@google.com470e71d2011-07-07 08:21:25 +000029class RtpRtcp;
30class VideoCodingModule;
niklase@google.com470e71d2011-07-07 08:21:25 +000031
pwestin@webrtc.org82dcc9f2013-04-02 20:37:14 +000032class ViEReceiver : public RtpData {
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000033 public:
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000034 ViEReceiver(const int32_t channel_id, VideoCodingModule* module_vcm,
tnakamura@webrtc.orgaa4d96a2013-07-16 19:25:04 +000035 RemoteBitrateEstimator* remote_bitrate_estimator);
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000036 ~ViEReceiver();
niklase@google.com470e71d2011-07-07 08:21:25 +000037
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000038 int RegisterExternalDecryption(Encryption* decryption);
39 int DeregisterExternalDecryption();
niklase@google.com470e71d2011-07-07 08:21:25 +000040
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000041 void SetRtpRtcpModule(RtpRtcp* module);
42
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000043 void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules);
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +000044
stefan@webrtc.org08994cc2013-05-29 13:28:21 +000045 bool SetReceiveTimestampOffsetStatus(bool enable, int id);
46 bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id);
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000047
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000048 void StartReceive();
49 void StopReceive();
niklase@google.com470e71d2011-07-07 08:21:25 +000050
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000051 int StartRTPDump(const char file_nameUTF8[1024]);
52 int StopRTPDump();
niklase@google.com470e71d2011-07-07 08:21:25 +000053
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000054 // Receives packets from external transport.
55 int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length);
56 int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length);
niklase@google.com470e71d2011-07-07 08:21:25 +000057
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000058 // Implements RtpData.
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000059 virtual int32_t OnReceivedPayloadData(
60 const uint8_t* payload_data,
61 const uint16_t payload_size,
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000062 const WebRtcRTPHeader* rtp_header);
niklase@google.com470e71d2011-07-07 08:21:25 +000063
mflodman@webrtc.org4fd55272013-02-06 17:46:39 +000064 void EstimatedReceiveBandwidth(unsigned int* available_bandwidth) const;
stefan@webrtc.orgb5865072013-02-01 14:33:42 +000065
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000066 private:
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000067 int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length);
68 int InsertRTCPPacket(const int8_t* rtcp_packet, int rtcp_packet_length);
niklase@google.com470e71d2011-07-07 08:21:25 +000069
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000070 scoped_ptr<CriticalSectionWrapper> receive_cs_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000071 const int32_t channel_id_;
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000072 scoped_ptr<RtpHeaderParser> rtp_header_parser_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000073 RtpRtcp* rtp_rtcp_;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000074 std::list<RtpRtcp*> rtp_rtcp_simulcast_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000075 VideoCodingModule* vcm_;
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000076 RemoteBitrateEstimator* remote_bitrate_estimator_;
niklase@google.com470e71d2011-07-07 08:21:25 +000077
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000078 Encryption* external_decryption_;
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000079 uint8_t* decryption_buffer_;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000080 RtpDump* rtp_dump_;
81 bool receiving_;
niklase@google.com470e71d2011-07-07 08:21:25 +000082};
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000083
84} // namespace webrt
85
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +000086#endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_