OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ | 11 #ifndef WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ |
12 #define WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ | 12 #define WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
| 15 #include <map> |
15 #include <memory> | 16 #include <memory> |
16 #include <string> | 17 #include <string> |
17 #include <vector> | 18 #include <vector> |
18 | 19 |
19 #include "webrtc/base/constructormagic.h" | 20 #include "webrtc/base/constructormagic.h" |
20 #include "webrtc/base/criticalsection.h" | 21 #include "webrtc/base/criticalsection.h" |
| 22 #include "webrtc/modules/include/module_common_types.h" |
21 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 23 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
22 #include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h" | 24 #include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 27 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 28 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h" |
26 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 29 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 30 #include "webrtc/modules/video_coding/packet_buffer.h" |
| 31 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h" |
| 32 #include "webrtc/modules/video_coding/sequence_number_util.h" |
27 #include "webrtc/typedefs.h" | 33 #include "webrtc/typedefs.h" |
28 #include "webrtc/video_receive_stream.h" | 34 #include "webrtc/video_receive_stream.h" |
29 | 35 |
30 namespace webrtc { | 36 namespace webrtc { |
31 | 37 |
| 38 class NackModule; |
32 class PacedSender; | 39 class PacedSender; |
33 class PacketRouter; | 40 class PacketRouter; |
34 class ProcessThread; | 41 class ProcessThread; |
35 class RemoteNtpTimeEstimator; | |
36 class ReceiveStatistics; | 42 class ReceiveStatistics; |
37 class ReceiveStatisticsProxy; | 43 class ReceiveStatisticsProxy; |
38 class RemoteBitrateEstimator; | 44 class RemoteBitrateEstimator; |
| 45 class RemoteNtpTimeEstimator; |
39 class RtcpRttStats; | 46 class RtcpRttStats; |
40 class RtpHeaderParser; | 47 class RtpHeaderParser; |
41 class RTPPayloadRegistry; | 48 class RTPPayloadRegistry; |
42 class RtpReceiver; | 49 class RtpReceiver; |
43 class Transport; | 50 class Transport; |
44 class UlpfecReceiver; | 51 class UlpfecReceiver; |
| 52 class VCMTiming; |
45 class VieRemb; | 53 class VieRemb; |
46 | 54 |
47 namespace vcm { | 55 namespace vcm { |
48 class VideoReceiver; | 56 class VideoReceiver; |
49 } // namespace vcm | 57 } // namespace vcm |
50 | 58 |
51 class RtpStreamReceiver : public RtpData, public RtpFeedback, | 59 class RtpStreamReceiver : public RtpData, |
| 60 public RtpFeedback, |
52 public VCMFrameTypeCallback, | 61 public VCMFrameTypeCallback, |
53 public VCMPacketRequestCallback { | 62 public VCMPacketRequestCallback, |
| 63 public video_coding::OnReceivedFrameCallback, |
| 64 public video_coding::OnCompleteFrameCallback, |
| 65 public CallStatsObserver { |
54 public: | 66 public: |
55 RtpStreamReceiver(vcm::VideoReceiver* video_receiver, | 67 RtpStreamReceiver( |
56 RemoteBitrateEstimator* remote_bitrate_estimator, | 68 vcm::VideoReceiver* video_receiver, |
57 Transport* transport, | 69 RemoteBitrateEstimator* remote_bitrate_estimator, |
58 RtcpRttStats* rtt_stats, | 70 Transport* transport, |
59 PacedSender* paced_sender, | 71 RtcpRttStats* rtt_stats, |
60 PacketRouter* packet_router, | 72 PacedSender* paced_sender, |
61 VieRemb* remb, | 73 PacketRouter* packet_router, |
62 const VideoReceiveStream::Config* config, | 74 VieRemb* remb, |
63 ReceiveStatisticsProxy* receive_stats_proxy, | 75 const VideoReceiveStream::Config* config, |
64 ProcessThread* process_thread, | 76 ReceiveStatisticsProxy* receive_stats_proxy, |
65 RateLimiter* retransmission_rate_limiter); | 77 ProcessThread* process_thread, |
| 78 RateLimiter* retransmission_rate_limiter, |
| 79 NackSender* nack_sender, |
| 80 KeyFrameRequestSender* keyframe_request_sender, |
| 81 video_coding::OnCompleteFrameCallback* complete_frame_callback, |
| 82 VCMTiming* timing); |
66 ~RtpStreamReceiver(); | 83 ~RtpStreamReceiver(); |
67 | 84 |
68 bool SetReceiveCodec(const VideoCodec& video_codec); | 85 bool SetReceiveCodec(const VideoCodec& video_codec); |
69 | 86 |
70 uint32_t GetRemoteSsrc() const; | 87 uint32_t GetRemoteSsrc() const; |
71 int GetCsrcs(uint32_t* csrcs) const; | 88 int GetCsrcs(uint32_t* csrcs) const; |
72 | 89 |
73 RtpReceiver* GetRtpReceiver() const; | 90 RtpReceiver* GetRtpReceiver() const; |
74 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_.get(); } | 91 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_.get(); } |
75 | 92 |
76 void StartReceive(); | 93 void StartReceive(); |
77 void StopReceive(); | 94 void StopReceive(); |
78 | 95 |
79 bool DeliverRtp(const uint8_t* rtp_packet, | 96 bool DeliverRtp(const uint8_t* rtp_packet, |
80 size_t rtp_packet_length, | 97 size_t rtp_packet_length, |
81 const PacketTime& packet_time); | 98 const PacketTime& packet_time); |
82 bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length); | 99 bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length); |
83 | 100 |
| 101 void FrameContinuous(uint16_t seq_num); |
| 102 |
| 103 void FrameDecoded(uint16_t seq_num); |
| 104 |
84 void SignalNetworkState(NetworkState state); | 105 void SignalNetworkState(NetworkState state); |
85 | 106 |
86 // Implements RtpData. | 107 // Implements RtpData. |
87 int32_t OnReceivedPayloadData(const uint8_t* payload_data, | 108 int32_t OnReceivedPayloadData(const uint8_t* payload_data, |
88 size_t payload_size, | 109 size_t payload_size, |
89 const WebRtcRTPHeader* rtp_header) override; | 110 const WebRtcRTPHeader* rtp_header) override; |
90 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override; | 111 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override; |
91 | 112 |
92 // Implements RtpFeedback. | 113 // Implements RtpFeedback. |
93 int32_t OnInitializeDecoder(int8_t payload_type, | 114 int32_t OnInitializeDecoder(int8_t payload_type, |
(...skipping 10 matching lines...) Loading... |
104 | 125 |
105 bool IsFecEnabled() const; | 126 bool IsFecEnabled() const; |
106 bool IsRetransmissionsEnabled() const; | 127 bool IsRetransmissionsEnabled() const; |
107 // Don't use, still experimental. | 128 // Don't use, still experimental. |
108 void RequestPacketRetransmit(const std::vector<uint16_t>& sequence_numbers); | 129 void RequestPacketRetransmit(const std::vector<uint16_t>& sequence_numbers); |
109 | 130 |
110 // Implements VCMPacketRequestCallback. | 131 // Implements VCMPacketRequestCallback. |
111 int32_t ResendPackets(const uint16_t* sequenceNumbers, | 132 int32_t ResendPackets(const uint16_t* sequenceNumbers, |
112 uint16_t length) override; | 133 uint16_t length) override; |
113 | 134 |
| 135 // Implements OnReceivedFrameCallback. |
| 136 void OnReceivedFrame( |
| 137 std::unique_ptr<video_coding::RtpFrameObject> frame) override; |
| 138 |
| 139 // Implements OnCompleteFrameCallback. |
| 140 void OnCompleteFrame( |
| 141 std::unique_ptr<video_coding::FrameObject> frame) override; |
| 142 |
| 143 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 144 |
114 private: | 145 private: |
115 bool ReceivePacket(const uint8_t* packet, | 146 bool ReceivePacket(const uint8_t* packet, |
116 size_t packet_length, | 147 size_t packet_length, |
117 const RTPHeader& header, | 148 const RTPHeader& header, |
118 bool in_order); | 149 bool in_order); |
119 // Parses and handles for instance RTX and RED headers. | 150 // Parses and handles for instance RTX and RED headers. |
120 // This function assumes that it's being called from only one thread. | 151 // This function assumes that it's being called from only one thread. |
121 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet, | 152 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet, |
122 size_t packet_length, | 153 size_t packet_length, |
123 const RTPHeader& header); | 154 const RTPHeader& header); |
(...skipping 20 matching lines...) Loading... |
144 const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; | 175 const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; |
145 std::unique_ptr<UlpfecReceiver> ulpfec_receiver_; | 176 std::unique_ptr<UlpfecReceiver> ulpfec_receiver_; |
146 | 177 |
147 rtc::CriticalSection receive_cs_; | 178 rtc::CriticalSection receive_cs_; |
148 bool receiving_ GUARDED_BY(receive_cs_); | 179 bool receiving_ GUARDED_BY(receive_cs_); |
149 uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_); | 180 uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_); |
150 bool restored_packet_in_use_ GUARDED_BY(receive_cs_); | 181 bool restored_packet_in_use_ GUARDED_BY(receive_cs_); |
151 int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_); | 182 int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_); |
152 | 183 |
153 const std::unique_ptr<RtpRtcp> rtp_rtcp_; | 184 const std::unique_ptr<RtpRtcp> rtp_rtcp_; |
| 185 |
| 186 // Members for the new jitter buffer experiment. |
| 187 bool jitter_buffer_experiment_; |
| 188 video_coding::OnCompleteFrameCallback* complete_frame_callback_; |
| 189 KeyFrameRequestSender* keyframe_request_sender_; |
| 190 VCMTiming* timing_; |
| 191 std::unique_ptr<NackModule> nack_module_; |
| 192 rtc::scoped_refptr<video_coding::PacketBuffer> packet_buffer_; |
| 193 std::unique_ptr<video_coding::RtpFrameReferenceFinder> reference_finder_; |
| 194 rtc::CriticalSection last_seq_num_cs_; |
| 195 std::map<uint16_t, uint16_t, DescendingSeqNumComp<uint16_t>> |
| 196 last_seq_num_for_pic_id_ GUARDED_BY(last_seq_num_cs_); |
| 197 video_coding::H264SpsPpsTracker tracker_; |
154 }; | 198 }; |
155 | 199 |
156 } // namespace webrtc | 200 } // namespace webrtc |
157 | 201 |
158 #endif // WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ | 202 #endif // WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ |
OLD | NEW |