blob: 4f43fc9d6766378412da8f3f0b5a9fc5bfb0b7d5 [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
mflodman@webrtc.org1b1cd782012-06-28 06:34:08 +000016#include "engine_configurations.h" // NOLINT
17#include "modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
pwestin@webrtc.org684f0572013-03-13 23:20:57 +000018#include "modules/udp_transport/interface/udp_transport.h"
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000019#include "system_wrappers/interface/scoped_ptr.h"
mflodman@webrtc.org1b1cd782012-06-28 06:34:08 +000020#include "typedefs.h" // NOLINT
21#include "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;
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000027class RemoteBitrateEstimator;
niklase@google.com470e71d2011-07-07 08:21:25 +000028class RtpDump;
29class RtpRtcp;
30class VideoCodingModule;
niklase@google.com470e71d2011-07-07 08:21:25 +000031
pwestin@webrtc.org684f0572013-03-13 23:20:57 +000032class ViEReceiver : public UdpTransportData, 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
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000045 void StartReceive();
46 void StopReceive();
niklase@google.com470e71d2011-07-07 08:21:25 +000047
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000048 int StartRTPDump(const char file_nameUTF8[1024]);
49 int StopRTPDump();
niklase@google.com470e71d2011-07-07 08:21:25 +000050
pwestin@webrtc.org684f0572013-03-13 23:20:57 +000051 // Implements UdpTransportData.
52 virtual void IncomingRTPPacket(const WebRtc_Word8* rtp_packet,
53 const WebRtc_Word32 rtp_packet_length,
54 const char* from_ip,
55 const WebRtc_UWord16 from_port);
56 virtual void IncomingRTCPPacket(const WebRtc_Word8* rtcp_packet,
57 const WebRtc_Word32 rtcp_packet_length,
58 const char* from_ip,
59 const WebRtc_UWord16 from_port);
60
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000061 // Receives packets from external transport.
62 int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length);
63 int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length);
niklase@google.com470e71d2011-07-07 08:21:25 +000064
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000065 // Implements RtpData.
66 virtual WebRtc_Word32 OnReceivedPayloadData(
67 const WebRtc_UWord8* payload_data,
68 const WebRtc_UWord16 payload_size,
69 const WebRtcRTPHeader* rtp_header);
niklase@google.com470e71d2011-07-07 08:21:25 +000070
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000071 void OnSendReportReceived(const WebRtc_Word32 id,
72 const WebRtc_UWord32 senderSSRC,
73 uint32_t ntp_secs,
74 uint32_t ntp_frac,
75 uint32_t timestamp);
76
mflodman@webrtc.org4fd55272013-02-06 17:46:39 +000077 void EstimatedReceiveBandwidth(unsigned int* available_bandwidth) const;
stefan@webrtc.orgb5865072013-02-01 14:33:42 +000078
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000079 private:
80 int InsertRTPPacket(const WebRtc_Word8* rtp_packet, int rtp_packet_length);
81 int InsertRTCPPacket(const WebRtc_Word8* rtcp_packet, int rtcp_packet_length);
niklase@google.com470e71d2011-07-07 08:21:25 +000082
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000083 scoped_ptr<CriticalSectionWrapper> receive_cs_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000084 const int32_t channel_id_;
85 RtpRtcp* rtp_rtcp_;
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000086 std::list<RtpRtcp*> rtp_rtcp_simulcast_;
pwestin@webrtc.org2853dde2012-05-11 11:08:54 +000087 VideoCodingModule* vcm_;
stefan@webrtc.org976a7e62012-09-21 13:20:21 +000088 RemoteBitrateEstimator* remote_bitrate_estimator_;
niklase@google.com470e71d2011-07-07 08:21:25 +000089
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000090 Encryption* external_decryption_;
91 WebRtc_UWord8* decryption_buffer_;
92 RtpDump* rtp_dump_;
93 bool receiving_;
niklase@google.com470e71d2011-07-07 08:21:25 +000094};
mflodman@webrtc.orgad4ee362011-11-28 22:39:24 +000095
96} // namespace webrt
97
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +000098#endif // WEBRTC_VIDEO_ENGINE_VIE_RECEIVER_H_