blob: 056a104de4048057d40e182039f2ddd802cfb1cc [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,
35 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.orga5cb98c2013-05-29 12:12:51 +000045 int SetReceiveTimestampOffsetStatus(bool enable, int id);
46 int SetReceiveAbsoluteSendTimeStatus(bool enable, int id);
47
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
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000064 void OnSendReportReceived(const int32_t id,
65 const uint32_t senderSSRC,
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000066 uint32_t ntp_secs,
67 uint32_t ntp_frac,
68 uint32_t timestamp);
69
mflodman@webrtc.org4fd55272013-02-06 17:46:39 +000070 void EstimatedReceiveBandwidth(unsigned int* available_bandwidth) const;
stefan@webrtc.orgb5865072013-02-01 14:33:42 +000071
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000072 private:
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000073 int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length);
74 int InsertRTCPPacket(const int8_t* rtcp_packet, int rtcp_packet_length);
niklase@google.com470e71d2011-07-07 08:21:25 +000075
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000076 scoped_ptr<CriticalSectionWrapper> receive_cs_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000077 const int32_t channel_id_;
stefan@webrtc.orga5cb98c2013-05-29 12:12:51 +000078 scoped_ptr<RtpHeaderParser> rtp_header_parser_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000079 RtpRtcp* rtp_rtcp_;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000080 std::list<RtpRtcp*> rtp_rtcp_simulcast_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000081 VideoCodingModule* vcm_;
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000082 RemoteBitrateEstimator* remote_bitrate_estimator_;
niklase@google.com470e71d2011-07-07 08:21:25 +000083
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000084 Encryption* external_decryption_;
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000085 uint8_t* decryption_buffer_;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000086 RtpDump* rtp_dump_;
87 bool receiving_;
niklase@google.com470e71d2011-07-07 08:21:25 +000088};
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000089
90} // namespace webrt
91
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +000092#endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_