OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This class maintains a transport for audio and video in a Cast Streaming | 5 // This class maintains a transport for audio and video in a Cast Streaming |
6 // session. | 6 // session. |
7 // Audio, video frames and RTCP messages are submitted to this object | 7 // Audio, video frames and RTCP messages are submitted to this object |
8 // and then packetized and paced to the underlying UDP socket. | 8 // and then packetized and paced to the underlying UDP socket. |
9 // | 9 // |
10 // The hierarchy of send transport in a Cast Streaming session: | 10 // The hierarchy of send transport in a Cast Streaming session: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 CastTransportImpl( | 58 CastTransportImpl( |
59 base::TickClock* clock, // Owned by the caller. | 59 base::TickClock* clock, // Owned by the caller. |
60 base::TimeDelta logging_flush_interval, | 60 base::TimeDelta logging_flush_interval, |
61 std::unique_ptr<Client> client, | 61 std::unique_ptr<Client> client, |
62 std::unique_ptr<PacketTransport> transport, | 62 std::unique_ptr<PacketTransport> transport, |
63 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | 63 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); |
64 | 64 |
65 ~CastTransportImpl() final; | 65 ~CastTransportImpl() final; |
66 | 66 |
67 // CastTransport implementation for sending. | 67 // CastTransport implementation for sending. |
68 void InitializeAudio(const CastTransportRtpConfig& config, | 68 void InitializeStream(const CastTransportRtpConfig& config, |
69 std::unique_ptr<RtcpObserver> rtcp_observer) final; | 69 std::unique_ptr<RtcpObserver> rtcp_observer) final; |
70 void InitializeVideo(const CastTransportRtpConfig& config, | |
71 std::unique_ptr<RtcpObserver> rtcp_observer) final; | |
72 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final; | 70 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final; |
73 | 71 |
74 void SendSenderReport(uint32_t ssrc, | 72 void SendSenderReport(uint32_t ssrc, |
75 base::TimeTicks current_time, | 73 base::TimeTicks current_time, |
76 RtpTimeTicks current_time_as_rtp_timestamp) final; | 74 RtpTimeTicks current_time_as_rtp_timestamp) final; |
77 | 75 |
78 void CancelSendingFrames(uint32_t ssrc, | 76 void CancelSendingFrames(uint32_t ssrc, |
79 const std::vector<FrameId>& frame_ids) final; | 77 const std::vector<FrameId>& frame_ids) final; |
80 | 78 |
81 void ResendFrameForKickstart(uint32_t ssrc, FrameId frame_id) final; | 79 void ResendFrameForKickstart(uint32_t ssrc, FrameId frame_id) final; |
(...skipping 27 matching lines...) Expand all Loading... | |
109 void AddRtcpEvents( | 107 void AddRtcpEvents( |
110 const ReceiverRtcpEventSubscriber::RtcpEvents& rtcp_events) final; | 108 const ReceiverRtcpEventSubscriber::RtcpEvents& rtcp_events) final; |
111 void AddRtpReceiverReport( | 109 void AddRtpReceiverReport( |
112 const RtcpReportBlock& rtp_receiver_report_block) final; | 110 const RtcpReportBlock& rtp_receiver_report_block) final; |
113 void SendRtcpFromRtpReceiver() final; | 111 void SendRtcpFromRtpReceiver() final; |
114 | 112 |
115 private: | 113 private: |
116 // Handle received RTCP messages on RTP sender. | 114 // Handle received RTCP messages on RTP sender. |
117 class RtcpClient; | 115 class RtcpClient; |
118 | 116 |
117 struct RtpStreamSession; | |
118 | |
119 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, NacksCancelRetransmits); | 119 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, NacksCancelRetransmits); |
120 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, CancelRetransmits); | 120 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, CancelRetransmits); |
121 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, Kickstart); | 121 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, Kickstart); |
122 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, DedupRetransmissionWithAudio); | 122 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, DedupRetransmissionWithAudio); |
123 | 123 |
124 // Resend packets for the stream identified by |ssrc|. | 124 // Resend packets for the stream identified by |ssrc|. |
125 // If |cancel_rtx_if_not_in_list| is true then transmission of packets for the | 125 // If |cancel_rtx_if_not_in_list| is true then transmission of packets for the |
126 // frames but not in the list will be dropped. | 126 // frames but not in the list will be dropped. |
127 // See PacedSender::ResendPackets() to see how |dedup_info| works. | 127 // See PacedSender::ResendPackets() to see how |dedup_info| works. |
128 void ResendPackets(uint32_t ssrc, | 128 void ResendPackets(uint32_t ssrc, |
(...skipping 24 matching lines...) Expand all Loading... | |
153 | 153 |
154 // FrameEvents and PacketEvents pending delivery via raw events callback. | 154 // FrameEvents and PacketEvents pending delivery via raw events callback. |
155 // Do not add elements to these when |logging_flush_interval| is | 155 // Do not add elements to these when |logging_flush_interval| is |
156 // |base::TimeDelta()|. | 156 // |base::TimeDelta()|. |
157 std::vector<FrameEvent> recent_frame_events_; | 157 std::vector<FrameEvent> recent_frame_events_; |
158 std::vector<PacketEvent> recent_packet_events_; | 158 std::vector<PacketEvent> recent_packet_events_; |
159 | 159 |
160 // Packet sender that performs pacing. | 160 // Packet sender that performs pacing. |
161 PacedSender pacer_; | 161 PacedSender pacer_; |
162 | 162 |
163 // Packetizer for audio and video frames. | |
164 std::unique_ptr<RtpSender> audio_sender_; | |
165 std::unique_ptr<RtpSender> video_sender_; | |
166 | |
167 // Maintains RTCP session for audio and video. | |
168 std::unique_ptr<SenderRtcpSession> audio_rtcp_session_; | |
169 std::unique_ptr<SenderRtcpSession> video_rtcp_session_; | |
170 | |
171 // RTCP observer for SenderRtcpSession. | |
172 std::unique_ptr<RtcpObserver> audio_rtcp_observer_; | |
173 std::unique_ptr<RtcpObserver> video_rtcp_observer_; | |
174 | |
175 // Encrypts data in EncodedFrames before they are sent. Note that it's | |
176 // important for the encryption to happen here, in code that would execute in | |
177 // the main browser process, for security reasons. This helps to mitigate | |
178 // the damage that could be caused by a compromised renderer process. | |
179 TransportEncryptionHandler audio_encryptor_; | |
180 TransportEncryptionHandler video_encryptor_; | |
181 | |
182 // Right after a frame is sent we record the number of bytes sent to the | 163 // Right after a frame is sent we record the number of bytes sent to the |
183 // socket. We record the corresponding bytes sent for the most recent ACKed | 164 // socket. We record the corresponding bytes sent for the most recent ACKed |
184 // audio packet. | 165 // audio packet. |
185 int64_t last_byte_acked_for_audio_; | 166 int64_t last_byte_acked_for_audio_; |
186 | 167 |
187 // Packets that don't match these sender ssrcs are ignored. | 168 // Packets that don't match these sender ssrcs are ignored. |
188 std::set<uint32_t> valid_sender_ssrcs_; | 169 std::set<uint32_t> valid_sender_ssrcs_; |
189 | 170 |
190 // While non-null, global WiFi behavior modifications are in effect. This is | 171 // While non-null, global WiFi behavior modifications are in effect. This is |
191 // used, for example, to turn off WiFi scanning that tends to interfere with | 172 // used, for example, to turn off WiFi scanning that tends to interfere with |
192 // the reliability of UDP packet transmission. | 173 // the reliability of UDP packet transmission. |
193 std::unique_ptr<net::ScopedWifiOptions> wifi_options_autoreset_; | 174 std::unique_ptr<net::ScopedWifiOptions> wifi_options_autoreset_; |
194 | 175 |
195 // Do not initialize the |rtcp_builder_at_rtp_receiver_| if the RTP receiver | 176 // Do not initialize the |rtcp_builder_at_rtp_receiver_| if the RTP receiver |
196 // SSRC does not match these ssrcs. Only RTP receiver needs to register its | 177 // SSRC does not match these ssrcs. Only RTP receiver needs to register its |
197 // SSRC in this set. | 178 // SSRC in this set. |
198 std::set<uint32_t> valid_rtp_receiver_ssrcs_; | 179 std::set<uint32_t> valid_rtp_receiver_ssrcs_; |
199 | 180 |
200 std::unique_ptr<RtcpBuilder> rtcp_builder_at_rtp_receiver_; | 181 std::unique_ptr<RtcpBuilder> rtcp_builder_at_rtp_receiver_; |
201 | 182 |
183 // Records the initialized stream sessions on RTP sender. | |
miu
2016/07/06 21:45:42
Looks like the key is the SSRC. Can you mention th
xjz
2016/07/13 20:31:17
Done.
| |
184 using SessionMap = std::map<uint32_t, std::unique_ptr<RtpStreamSession>>; | |
185 SessionMap sessions_; | |
186 | |
202 base::WeakPtrFactory<CastTransportImpl> weak_factory_; | 187 base::WeakPtrFactory<CastTransportImpl> weak_factory_; |
203 | 188 |
204 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); | 189 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); |
205 }; | 190 }; |
206 | 191 |
207 } // namespace cast | 192 } // namespace cast |
208 } // namespace media | 193 } // namespace media |
209 | 194 |
210 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ | 195 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ |
OLD | NEW |