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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
27 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 27 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
28 #include "webrtc/typedefs.h" | 28 #include "webrtc/typedefs.h" |
29 #include "webrtc/video_receive_stream.h" | 29 #include "webrtc/video_receive_stream.h" |
30 | 30 |
31 namespace webrtc { | 31 namespace webrtc { |
32 | 32 |
33 class FecReceiver; | 33 class FecReceiver; |
34 class PacedSender; | 34 class PacedSender; |
35 class PacketRouter; | 35 class PacketRouter; |
| 36 class ProcessThread; |
36 class RemoteNtpTimeEstimator; | 37 class RemoteNtpTimeEstimator; |
37 class ReceiveStatistics; | 38 class ReceiveStatistics; |
38 class ReceiveStatisticsProxy; | 39 class ReceiveStatisticsProxy; |
39 class RemoteBitrateEstimator; | 40 class RemoteBitrateEstimator; |
40 class RtcpRttStats; | 41 class RtcpRttStats; |
41 class RtpHeaderParser; | 42 class RtpHeaderParser; |
42 class RTPPayloadRegistry; | 43 class RTPPayloadRegistry; |
43 class RtpReceiver; | 44 class RtpReceiver; |
44 class Transport; | 45 class Transport; |
| 46 class VieRemb; |
45 | 47 |
46 namespace vcm { | 48 namespace vcm { |
47 class VideoReceiver; | 49 class VideoReceiver; |
48 } // namespace vcm | 50 } // namespace vcm |
49 | 51 |
50 class RtpStreamReceiver : public RtpData, public RtpFeedback, | 52 class RtpStreamReceiver : public RtpData, public RtpFeedback, |
51 public VCMFrameTypeCallback, | 53 public VCMFrameTypeCallback, |
52 public VCMPacketRequestCallback { | 54 public VCMPacketRequestCallback { |
53 public: | 55 public: |
54 RtpStreamReceiver(vcm::VideoReceiver* video_receiver, | 56 RtpStreamReceiver(vcm::VideoReceiver* video_receiver, |
55 RemoteBitrateEstimator* remote_bitrate_estimator, | 57 RemoteBitrateEstimator* remote_bitrate_estimator, |
56 Transport* transport, | 58 Transport* transport, |
57 RtcpRttStats* rtt_stats, | 59 RtcpRttStats* rtt_stats, |
58 PacedSender* paced_sender, | 60 PacedSender* paced_sender, |
59 PacketRouter* packet_router, | 61 PacketRouter* packet_router, |
| 62 VieRemb* remb, |
60 const VideoReceiveStream::Config& config, | 63 const VideoReceiveStream::Config& config, |
61 ReceiveStatisticsProxy* receive_stats_proxy); | 64 ReceiveStatisticsProxy* receive_stats_proxy, |
| 65 ProcessThread* process_thread); |
62 ~RtpStreamReceiver(); | 66 ~RtpStreamReceiver(); |
63 | 67 |
64 bool SetReceiveCodec(const VideoCodec& video_codec); | 68 bool SetReceiveCodec(const VideoCodec& video_codec); |
65 | 69 |
66 void SetRtxPayloadType(int payload_type, int associated_payload_type); | |
67 // If set to true, the RTX payload type mapping supplied in | |
68 // |SetRtxPayloadType| will be used when restoring RTX packets. Without it, | |
69 // RTX packets will always be restored to the last non-RTX packet payload type | |
70 // received. | |
71 void SetUseRtxPayloadMappingOnRestore(bool val); | |
72 void SetRtxSsrc(uint32_t ssrc); | |
73 bool GetRtxSsrc(uint32_t* ssrc) const; | |
74 | |
75 bool IsFecEnabled() const; | |
76 | |
77 uint32_t GetRemoteSsrc() const; | 70 uint32_t GetRemoteSsrc() const; |
78 int GetCsrcs(uint32_t* csrcs) const; | 71 int GetCsrcs(uint32_t* csrcs) const; |
79 | 72 |
80 RtpReceiver* GetRtpReceiver() const; | 73 RtpReceiver* GetRtpReceiver() const; |
81 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_.get(); } | 74 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_.get(); } |
82 | 75 |
83 void EnableReceiveRtpHeaderExtension(const std::string& extension, int id); | |
84 | |
85 void StartReceive(); | 76 void StartReceive(); |
86 void StopReceive(); | 77 void StopReceive(); |
87 | 78 |
88 bool DeliverRtp(const uint8_t* rtp_packet, | 79 bool DeliverRtp(const uint8_t* rtp_packet, |
89 size_t rtp_packet_length, | 80 size_t rtp_packet_length, |
90 const PacketTime& packet_time); | 81 const PacketTime& packet_time); |
91 bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length); | 82 bool DeliverRtcp(const uint8_t* rtcp_packet, size_t rtcp_packet_length); |
92 | 83 |
| 84 void SignalNetworkState(NetworkState state); |
| 85 |
93 // Implements RtpData. | 86 // Implements RtpData. |
94 int32_t OnReceivedPayloadData(const uint8_t* payload_data, | 87 int32_t OnReceivedPayloadData(const uint8_t* payload_data, |
95 const size_t payload_size, | 88 const size_t payload_size, |
96 const WebRtcRTPHeader* rtp_header) override; | 89 const WebRtcRTPHeader* rtp_header) override; |
97 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override; | 90 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override; |
98 | 91 |
99 // Implements RtpFeedback. | 92 // Implements RtpFeedback. |
100 int32_t OnInitializeDecoder(const int8_t payload_type, | 93 int32_t OnInitializeDecoder(const int8_t payload_type, |
101 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 94 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
102 const int frequency, | 95 const int frequency, |
103 const size_t channels, | 96 const size_t channels, |
104 const uint32_t rate) override; | 97 const uint32_t rate) override; |
105 void OnIncomingSSRCChanged(const uint32_t ssrc) override; | 98 void OnIncomingSSRCChanged(const uint32_t ssrc) override; |
106 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {} | 99 void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {} |
107 | 100 |
108 // Implements VCMFrameTypeCallback. | 101 // Implements VCMFrameTypeCallback. |
109 int32_t RequestKeyFrame() override; | 102 int32_t RequestKeyFrame() override; |
110 int32_t SliceLossIndicationRequest(const uint64_t picture_id) override; | 103 int32_t SliceLossIndicationRequest(const uint64_t picture_id) override; |
111 | 104 |
| 105 bool IsFecEnabled() const; |
| 106 bool IsRetransmissionsEnabled() const; |
| 107 void RequestPacketRetransmit(const std::vector<uint16_t>& sequence_numbers); |
| 108 |
112 // Implements VCMPacketRequestCallback. | 109 // Implements VCMPacketRequestCallback. |
113 int32_t ResendPackets(const uint16_t* sequenceNumbers, | 110 int32_t ResendPackets(const uint16_t* sequenceNumbers, |
114 uint16_t length) override; | 111 uint16_t length) override; |
115 | 112 |
116 ReceiveStatistics* GetReceiveStatistics() const; | |
117 | |
118 private: | 113 private: |
119 bool ReceivePacket(const uint8_t* packet, | 114 bool ReceivePacket(const uint8_t* packet, |
120 size_t packet_length, | 115 size_t packet_length, |
121 const RTPHeader& header, | 116 const RTPHeader& header, |
122 bool in_order); | 117 bool in_order); |
123 // Parses and handles for instance RTX and RED headers. | 118 // Parses and handles for instance RTX and RED headers. |
124 // This function assumes that it's being called from only one thread. | 119 // This function assumes that it's being called from only one thread. |
125 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet, | 120 bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet, |
126 size_t packet_length, | 121 size_t packet_length, |
127 const RTPHeader& header); | 122 const RTPHeader& header); |
128 void NotifyReceiverOfFecPacket(const RTPHeader& header); | 123 void NotifyReceiverOfFecPacket(const RTPHeader& header); |
129 bool IsPacketInOrder(const RTPHeader& header) const; | 124 bool IsPacketInOrder(const RTPHeader& header) const; |
130 bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; | 125 bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; |
131 void UpdateHistograms(); | 126 void UpdateHistograms(); |
| 127 void EnableReceiveRtpHeaderExtension(const std::string& extension, int id); |
132 | 128 |
133 Clock* const clock_; | 129 Clock* const clock_; |
| 130 const VideoReceiveStream::Config config_; |
134 vcm::VideoReceiver* const video_receiver_; | 131 vcm::VideoReceiver* const video_receiver_; |
135 RemoteBitrateEstimator* const remote_bitrate_estimator_; | 132 RemoteBitrateEstimator* const remote_bitrate_estimator_; |
136 PacketRouter* const packet_router_; | 133 PacketRouter* const packet_router_; |
| 134 VieRemb* const remb_; |
| 135 ProcessThread* const process_thread_; |
137 | 136 |
138 RemoteNtpTimeEstimator ntp_estimator_; | 137 RemoteNtpTimeEstimator ntp_estimator_; |
139 RTPPayloadRegistry rtp_payload_registry_; | 138 RTPPayloadRegistry rtp_payload_registry_; |
140 | 139 |
141 const std::unique_ptr<RtpHeaderParser> rtp_header_parser_; | 140 const std::unique_ptr<RtpHeaderParser> rtp_header_parser_; |
142 const std::unique_ptr<RtpReceiver> rtp_receiver_; | 141 const std::unique_ptr<RtpReceiver> rtp_receiver_; |
143 const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; | 142 const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; |
144 std::unique_ptr<FecReceiver> fec_receiver_; | 143 std::unique_ptr<FecReceiver> fec_receiver_; |
145 | 144 |
146 rtc::CriticalSection receive_cs_; | 145 rtc::CriticalSection receive_cs_; |
147 bool receiving_ GUARDED_BY(receive_cs_); | 146 bool receiving_ GUARDED_BY(receive_cs_); |
148 uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_); | 147 uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_); |
149 bool restored_packet_in_use_ GUARDED_BY(receive_cs_); | 148 bool restored_packet_in_use_ GUARDED_BY(receive_cs_); |
150 int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_); | 149 int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_); |
151 | 150 |
152 const std::unique_ptr<RtpRtcp> rtp_rtcp_; | 151 const std::unique_ptr<RtpRtcp> rtp_rtcp_; |
153 }; | 152 }; |
154 | 153 |
155 } // namespace webrtc | 154 } // namespace webrtc |
156 | 155 |
157 #endif // WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ | 156 #endif // WEBRTC_VIDEO_RTP_STREAM_RECEIVER_H_ |
OLD | NEW |