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-11-15 00:57:57 -08:00
|
|
|
#include <map>
|
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"
|
2016-11-15 00:57:57 -08:00
|
|
|
#include "webrtc/modules/include/module_common_types.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-11-15 00:57:57 -08:00
|
|
|
#include "webrtc/modules/video_coding/h264_sps_pps_tracker.h"
|
2016-05-03 21:22:04 -07:00
|
|
|
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
2016-11-15 00:57:57 -08:00
|
|
|
#include "webrtc/modules/video_coding/packet_buffer.h"
|
|
|
|
|
#include "webrtc/modules/video_coding/rtp_frame_reference_finder.h"
|
|
|
|
|
#include "webrtc/modules/video_coding/sequence_number_util.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
|
|
|
|
2016-11-15 00:57:57 -08:00
|
|
|
class NackModule;
|
2016-04-25 01:26:26 -07:00
|
|
|
class PacedSender;
|
|
|
|
|
class PacketRouter;
|
2016-05-06 05:32:22 -07:00
|
|
|
class ProcessThread;
|
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-11-15 00:57:57 -08:00
|
|
|
class RemoteNtpTimeEstimator;
|
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-10-31 04:51:33 -07:00
|
|
|
class UlpfecReceiver;
|
2016-11-15 00:57:57 -08:00
|
|
|
class VCMTiming;
|
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-11-15 00:57:57 -08:00
|
|
|
class RtpStreamReceiver : public RtpData,
|
|
|
|
|
public RtpFeedback,
|
2016-05-03 21:22:04 -07:00
|
|
|
public VCMFrameTypeCallback,
|
2016-11-15 00:57:57 -08:00
|
|
|
public VCMPacketRequestCallback,
|
|
|
|
|
public video_coding::OnReceivedFrameCallback,
|
|
|
|
|
public video_coding::OnCompleteFrameCallback,
|
|
|
|
|
public CallStatsObserver {
|
2011-11-28 22:39:24 +00:00
|
|
|
public:
|
2016-11-15 00:57:57 -08:00
|
|
|
RtpStreamReceiver(
|
|
|
|
|
vcm::VideoReceiver* video_receiver,
|
|
|
|
|
RemoteBitrateEstimator* remote_bitrate_estimator,
|
|
|
|
|
Transport* transport,
|
|
|
|
|
RtcpRttStats* rtt_stats,
|
|
|
|
|
PacedSender* paced_sender,
|
|
|
|
|
PacketRouter* packet_router,
|
|
|
|
|
VieRemb* remb,
|
|
|
|
|
const VideoReceiveStream::Config* config,
|
|
|
|
|
ReceiveStatisticsProxy* receive_stats_proxy,
|
|
|
|
|
ProcessThread* process_thread,
|
|
|
|
|
RateLimiter* retransmission_rate_limiter,
|
|
|
|
|
NackSender* nack_sender,
|
|
|
|
|
KeyFrameRequestSender* keyframe_request_sender,
|
|
|
|
|
video_coding::OnCompleteFrameCallback* complete_frame_callback,
|
|
|
|
|
VCMTiming* timing);
|
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-11-15 00:57:57 -08:00
|
|
|
void FrameContinuous(uint16_t seq_num);
|
|
|
|
|
|
|
|
|
|
void FrameDecoded(uint16_t seq_num);
|
|
|
|
|
|
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,
|
2016-06-14 12:52:54 +02:00
|
|
|
size_t payload_size,
|
2015-03-04 12:58:35 +00:00
|
|
|
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.
|
2016-07-28 15:19:10 -07:00
|
|
|
int32_t OnInitializeDecoder(int8_t payload_type,
|
2016-04-28 23:15:33 -07:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2016-07-28 15:19:10 -07:00
|
|
|
int frequency,
|
|
|
|
|
size_t channels,
|
|
|
|
|
uint32_t rate) override;
|
|
|
|
|
void OnIncomingSSRCChanged(uint32_t ssrc) override;
|
|
|
|
|
void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override {}
|
2016-04-28 23:15:33 -07:00
|
|
|
|
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
|
|
|
|
2016-11-15 00:57:57 -08:00
|
|
|
// Implements OnReceivedFrameCallback.
|
|
|
|
|
void OnReceivedFrame(
|
|
|
|
|
std::unique_ptr<video_coding::RtpFrameObject> frame) override;
|
|
|
|
|
|
|
|
|
|
// Implements OnCompleteFrameCallback.
|
|
|
|
|
void OnCompleteFrame(
|
|
|
|
|
std::unique_ptr<video_coding::FrameObject> frame) override;
|
|
|
|
|
|
|
|
|
|
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
|
|
|
|
|
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);
|
Remove RED/RTX workaround from sender/receiver and VideoEngine2.
In older Chrome versions, the associated payload type in the RTX header
of retransmitted packets was always set to be the original media payload type,
regardless of the actual payload type of the packet. This meant that packets
encapsulated with RED headers had incorrect payload type information in the
RTX header. Due to an assumption in the receiver, this incorrect payload type
information would effectively be undone, leading to a working system.
Albeit working, this behaviour was undesired, and thus removed. In the interim,
several workarounds were introduced to not destroy interop between old and
new Chrome versions:
(1) https://codereview.webrtc.org/1649493004
- If no payload type mapping existed for RED over RTX, the payload type
of the underlying media would be used.
- If RED had been negotiated, received RTX packets would always be
assumed to contain RED.
(2) https://codereview.webrtc.org/1964473002
- If RED was removed from the remote description answer, it would be
disabled in the local receiver as well.
(3) https://codereview.webrtc.org/2033763002
- If RED was negotiated in the SDP, it would always be used, regardless
if ULPFEC was negotiated and used, or not.
Since the Chrome versions that exhibited the original bug now are very old,
this CL removes the workarounds from (1) and (2). In particular, after this
change, we will have the following behaviour:
- We assume that a payload type mapping for RED over RTX always is set.
If this is not the case, the RTX packet is not sent.
- The associated payload type of received RTX packets will always be obeyed.
- The (non)-existence of RED in the remote description does not affect the
local receiver.
The workaround in (3) still needs to exist, in order to interop with receivers
that did not have the workarounds in (1) and (2) removed. The change in (3)
can be removed in a couple of Chrome versions.
TESTED=Using AppRTC between patched Chrome (connected to ethernet) and standard Chrome M54 (connected to lossy internal Google WiFi), with and without FEC turned off using AppRTC flag. Also using "Munge SDP" sample on patched Chrome over loopback interface, with 100ms delay and 5% packet loss simulated using tc.
BUG=webrtc:6650
Review-Url: https://codereview.webrtc.org/2469093003
Cr-Commit-Position: refs/heads/master@{#15038}
2016-11-11 03:28:30 -08:00
|
|
|
bool IsRedEnabled() const;
|
2011-11-28 22:39:24 +00:00
|
|
|
|
2016-03-02 15:05:53 +01:00
|
|
|
Clock* const clock_;
|
2016-06-10 17:58:01 +02:00
|
|
|
// Ownership of this object lies with VideoReceiveStream, which owns |this|.
|
|
|
|
|
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_;
|
2016-10-31 04:51:33 -07:00
|
|
|
std::unique_ptr<UlpfecReceiver> ulpfec_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_;
|
2016-11-15 00:57:57 -08:00
|
|
|
|
|
|
|
|
// Members for the new jitter buffer experiment.
|
|
|
|
|
bool jitter_buffer_experiment_;
|
|
|
|
|
video_coding::OnCompleteFrameCallback* complete_frame_callback_;
|
|
|
|
|
KeyFrameRequestSender* keyframe_request_sender_;
|
|
|
|
|
VCMTiming* timing_;
|
|
|
|
|
std::unique_ptr<NackModule> nack_module_;
|
|
|
|
|
rtc::scoped_refptr<video_coding::PacketBuffer> packet_buffer_;
|
|
|
|
|
std::unique_ptr<video_coding::RtpFrameReferenceFinder> reference_finder_;
|
|
|
|
|
rtc::CriticalSection last_seq_num_cs_;
|
|
|
|
|
std::map<uint16_t, uint16_t, DescendingSeqNumComp<uint16_t>>
|
|
|
|
|
last_seq_num_for_pic_id_ GUARDED_BY(last_seq_num_cs_);
|
|
|
|
|
video_coding::H264SpsPpsTracker tracker_;
|
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_
|