2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-01 18:22:48 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-04-28 23:15:33 -07:00
|
|
|
#ifndef WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_
|
|
|
|
|
#define WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-10-13 15:19:55 +00:00
|
|
|
#include <list>
|
2016-03-01 11:52:33 -08:00
|
|
|
#include <memory>
|
2016-02-26 16:26:20 +01:00
|
|
|
#include <string>
|
2015-11-26 15:24:52 +01:00
|
|
|
#include <vector>
|
2011-10-13 15:19:55 +00:00
|
|
|
|
2016-04-26 08:14:39 -07:00
|
|
|
#include "webrtc/base/constructormagic.h"
|
2016-01-21 23:24:59 +01:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2013-04-02 20:37:14 +00:00
|
|
|
#include "webrtc/engine_configurations.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
|
2016-03-02 15:05:53 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
|
2016-04-25 01:26:26 -07:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
2016-05-03 21:22:04 -07:00
|
|
|
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
2013-04-02 20:37:14 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
2016-05-03 21:22:04 -07:00
|
|
|
#include "webrtc/video_receive_stream.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-11-28 22:39:24 +00:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-09-06 13:40:11 +00:00
|
|
|
class FecReceiver;
|
2016-04-25 01:26:26 -07:00
|
|
|
class PacedSender;
|
|
|
|
|
class PacketRouter;
|
2016-05-06 05:32:22 -07:00
|
|
|
class ProcessThread;
|
2014-05-14 16:53:51 +00:00
|
|
|
class RemoteNtpTimeEstimator;
|
2013-08-15 23:38:54 +00:00
|
|
|
class ReceiveStatistics;
|
2016-05-03 21:22:04 -07:00
|
|
|
class ReceiveStatisticsProxy;
|
2012-09-21 13:20:21 +00:00
|
|
|
class RemoteBitrateEstimator;
|
2016-04-25 01:26:26 -07:00
|
|
|
class RtcpRttStats;
|
2013-05-29 12:12:51 +00:00
|
|
|
class RtpHeaderParser;
|
2013-08-15 23:38:54 +00:00
|
|
|
class RTPPayloadRegistry;
|
|
|
|
|
class RtpReceiver;
|
2016-04-25 01:26:26 -07:00
|
|
|
class Transport;
|
2016-05-06 05:32:22 -07:00
|
|
|
class VieRemb;
|
2016-04-22 18:23:15 +02:00
|
|
|
|
|
|
|
|
namespace vcm {
|
|
|
|
|
class VideoReceiver;
|
|
|
|
|
} // namespace vcm
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-05-03 21:22:04 -07:00
|
|
|
class RtpStreamReceiver : public RtpData, public RtpFeedback,
|
|
|
|
|
public VCMFrameTypeCallback,
|
|
|
|
|
public VCMPacketRequestCallback {
|
2011-11-28 22:39:24 +00:00
|
|
|
public:
|
2016-04-28 23:15:33 -07:00
|
|
|
RtpStreamReceiver(vcm::VideoReceiver* video_receiver,
|
|
|
|
|
RemoteBitrateEstimator* remote_bitrate_estimator,
|
|
|
|
|
Transport* transport,
|
|
|
|
|
RtcpRttStats* rtt_stats,
|
|
|
|
|
PacedSender* paced_sender,
|
2016-05-03 21:22:04 -07:00
|
|
|
PacketRouter* packet_router,
|
2016-05-06 05:32:22 -07:00
|
|
|
VieRemb* remb,
|
2016-05-03 21:22:04 -07:00
|
|
|
const VideoReceiveStream::Config& config,
|
2016-05-06 05:32:22 -07:00
|
|
|
ReceiveStatisticsProxy* receive_stats_proxy,
|
|
|
|
|
ProcessThread* process_thread);
|
2016-04-28 23:15:33 -07:00
|
|
|
~RtpStreamReceiver();
|
2011-11-28 22:39:24 +00:00
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
bool SetReceiveCodec(const VideoCodec& video_codec);
|
|
|
|
|
|
|
|
|
|
uint32_t GetRemoteSsrc() const;
|
|
|
|
|
int GetCsrcs(uint32_t* csrcs) const;
|
|
|
|
|
|
|
|
|
|
RtpReceiver* GetRtpReceiver() const;
|
2016-04-25 01:26:26 -07:00
|
|
|
RtpRtcp* rtp_rtcp() const { return rtp_rtcp_.get(); }
|
2013-08-15 23:38:54 +00:00
|
|
|
|
2011-11-28 22:39:24 +00:00
|
|
|
void StartReceive();
|
|
|
|
|
void StopReceive();
|
|
|
|
|
|
2016-02-08 14:07:14 +01:00
|
|
|
bool DeliverRtp(const uint8_t* rtp_packet,
|
|
|
|
|
size_t rtp_packet_length,
|
|
|
|
|
const PacketTime& packet_time);
|
|
|
|
|
bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length);
|
2011-11-28 22:39:24 +00:00
|
|
|
|
2016-05-06 05:32:22 -07:00
|
|
|
void SignalNetworkState(NetworkState state);
|
|
|
|
|
|
2011-11-28 22:39:24 +00:00
|
|
|
// Implements RtpData.
|
2015-03-04 12:58:35 +00:00
|
|
|
int32_t OnReceivedPayloadData(const uint8_t* payload_data,
|
|
|
|
|
const size_t payload_size,
|
|
|
|
|
const WebRtcRTPHeader* rtp_header) override;
|
|
|
|
|
bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override;
|
2011-11-28 22:39:24 +00:00
|
|
|
|
2016-04-28 23:15:33 -07:00
|
|
|
// Implements RtpFeedback.
|
|
|
|
|
int32_t OnInitializeDecoder(const int8_t payload_type,
|
|
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
|
|
|
|
const int frequency,
|
|
|
|
|
const size_t channels,
|
|
|
|
|
const uint32_t rate) override;
|
|
|
|
|
void OnIncomingSSRCChanged(const uint32_t ssrc) override;
|
|
|
|
|
void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {}
|
|
|
|
|
|
2016-05-03 21:22:04 -07:00
|
|
|
// Implements VCMFrameTypeCallback.
|
|
|
|
|
int32_t RequestKeyFrame() override;
|
|
|
|
|
int32_t SliceLossIndicationRequest(const uint64_t picture_id) override;
|
|
|
|
|
|
2016-05-06 05:32:22 -07:00
|
|
|
bool IsFecEnabled() const;
|
|
|
|
|
bool IsRetransmissionsEnabled() const;
|
|
|
|
|
// Don't use, still experimental.
|
|
|
|
|
void RequestPacketRetransmit(const std::vector<uint16_t>& sequence_numbers);
|
|
|
|
|
|
2016-05-03 21:22:04 -07:00
|
|
|
// Implements VCMPacketRequestCallback.
|
|
|
|
|
int32_t ResendPackets(const uint16_t* sequenceNumbers,
|
|
|
|
|
uint16_t length) override;
|
2015-11-26 15:24:52 +01:00
|
|
|
|
2011-11-28 22:39:24 +00:00
|
|
|
private:
|
2014-01-23 10:00:39 +00:00
|
|
|
bool ReceivePacket(const uint8_t* packet,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t packet_length,
|
2014-01-23 10:00:39 +00:00
|
|
|
const RTPHeader& header,
|
|
|
|
|
bool in_order);
|
2013-09-06 13:40:11 +00:00
|
|
|
// Parses and handles for instance RTX and RED headers.
|
|
|
|
|
// This function assumes that it's being called from only one thread.
|
|
|
|
|
bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t packet_length,
|
2013-09-06 13:40:11 +00:00
|
|
|
const RTPHeader& header);
|
2015-01-28 13:58:27 +00:00
|
|
|
void NotifyReceiverOfFecPacket(const RTPHeader& header);
|
2013-09-06 13:40:11 +00:00
|
|
|
bool IsPacketInOrder(const RTPHeader& header) const;
|
2013-11-08 15:18:52 +00:00
|
|
|
bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
|
2015-01-15 07:40:20 +00:00
|
|
|
void UpdateHistograms();
|
2016-05-06 05:32:22 -07:00
|
|
|
void EnableReceiveRtpHeaderExtension(const std::string& extension, int id);
|
2011-11-28 22:39:24 +00:00
|
|
|
|
2016-03-02 15:05:53 +01:00
|
|
|
Clock* const clock_;
|
2016-05-06 05:32:22 -07:00
|
|
|
const VideoReceiveStream::Config config_;
|
2016-04-22 18:23:15 +02:00
|
|
|
vcm::VideoReceiver* const video_receiver_;
|
2016-03-02 15:05:53 +01:00
|
|
|
RemoteBitrateEstimator* const remote_bitrate_estimator_;
|
2016-04-25 01:26:26 -07:00
|
|
|
PacketRouter* const packet_router_;
|
2016-05-06 05:32:22 -07:00
|
|
|
VieRemb* const remb_;
|
|
|
|
|
ProcessThread* const process_thread_;
|
2016-03-02 15:05:53 +01:00
|
|
|
|
|
|
|
|
RemoteNtpTimeEstimator ntp_estimator_;
|
|
|
|
|
RTPPayloadRegistry rtp_payload_registry_;
|
|
|
|
|
|
|
|
|
|
const std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
|
|
|
|
|
const std::unique_ptr<RtpReceiver> rtp_receiver_;
|
2016-03-01 11:52:33 -08:00
|
|
|
const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
|
|
|
|
|
std::unique_ptr<FecReceiver> fec_receiver_;
|
2014-04-24 22:10:24 +00:00
|
|
|
|
2016-03-02 15:05:53 +01:00
|
|
|
rtc::CriticalSection receive_cs_;
|
|
|
|
|
bool receiving_ GUARDED_BY(receive_cs_);
|
|
|
|
|
uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_);
|
|
|
|
|
bool restored_packet_in_use_ GUARDED_BY(receive_cs_);
|
|
|
|
|
int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_);
|
2016-04-25 01:26:26 -07:00
|
|
|
|
|
|
|
|
const std::unique_ptr<RtpRtcp> rtp_rtcp_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2011-11-28 22:39:24 +00:00
|
|
|
|
2015-11-26 15:24:52 +01:00
|
|
|
} // namespace webrtc
|
2011-11-28 22:39:24 +00:00
|
|
|
|
2016-04-28 23:15:33 -07:00
|
|
|
#endif // WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_
|