Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: media/cast/net/cast_transport_impl.h

Issue 1905763002: Convert //media/cast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/net/cast_transport_config.h ('k') | media/cast/net/cast_transport_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:
11 // 11 //
12 // CastTransport RTP RTCP 12 // CastTransport RTP RTCP
13 // ------------------------------------------------------------------ 13 // ------------------------------------------------------------------
14 // TransportEncryptionHandler (A/V) 14 // TransportEncryptionHandler (A/V)
15 // RtpSender (A/V) Rtcp (A/V) 15 // RtpSender (A/V) Rtcp (A/V)
16 // PacedSender (Shared) 16 // PacedSender (Shared)
17 // UdpTransport (Shared) 17 // UdpTransport (Shared)
18 // 18 //
19 // There are objects of TransportEncryptionHandler, RtpSender and Rtcp 19 // There are objects of TransportEncryptionHandler, RtpSender and Rtcp
20 // for each audio and video stream. 20 // for each audio and video stream.
21 // PacedSender and UdpTransport are shared between all RTP and RTCP 21 // PacedSender and UdpTransport are shared between all RTP and RTCP
22 // streams. 22 // streams.
23 23
24 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ 24 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_
25 #define MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ 25 #define MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_
26 26
27 #include <stdint.h> 27 #include <stdint.h>
28 28
29 #include <memory>
29 #include <set> 30 #include <set>
30 #include <vector> 31 #include <vector>
31 32
32 #include "base/callback.h" 33 #include "base/callback.h"
33 #include "base/gtest_prod_util.h" 34 #include "base/gtest_prod_util.h"
34 #include "base/macros.h" 35 #include "base/macros.h"
35 #include "base/memory/ref_counted.h" 36 #include "base/memory/ref_counted.h"
36 #include "base/memory/scoped_ptr.h"
37 #include "base/memory/weak_ptr.h" 37 #include "base/memory/weak_ptr.h"
38 #include "base/time/tick_clock.h" 38 #include "base/time/tick_clock.h"
39 #include "base/time/time.h" 39 #include "base/time/time.h"
40 #include "media/cast/common/transport_encryption_handler.h" 40 #include "media/cast/common/transport_encryption_handler.h"
41 #include "media/cast/logging/logging_defines.h" 41 #include "media/cast/logging/logging_defines.h"
42 #include "media/cast/net/cast_transport.h" 42 #include "media/cast/net/cast_transport.h"
43 #include "media/cast/net/cast_transport_config.h" 43 #include "media/cast/net/cast_transport_config.h"
44 #include "media/cast/net/pacing/paced_sender.h" 44 #include "media/cast/net/pacing/paced_sender.h"
45 #include "media/cast/net/rtcp/rtcp_builder.h" 45 #include "media/cast/net/rtcp/rtcp_builder.h"
46 #include "media/cast/net/rtcp/sender_rtcp_session.h" 46 #include "media/cast/net/rtcp/sender_rtcp_session.h"
47 #include "media/cast/net/rtp/rtp_parser.h" 47 #include "media/cast/net/rtp/rtp_parser.h"
48 #include "media/cast/net/rtp/rtp_sender.h" 48 #include "media/cast/net/rtp/rtp_sender.h"
49 #include "net/base/network_interfaces.h" 49 #include "net/base/network_interfaces.h"
50 50
51 namespace media { 51 namespace media {
52 namespace cast { 52 namespace cast {
53 53
54 class UdpTransport; 54 class UdpTransport;
55 55
56 class CastTransportImpl final : public CastTransport { 56 class CastTransportImpl final : public CastTransport {
57 public: 57 public:
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 scoped_ptr<Client> client, 61 std::unique_ptr<Client> client,
62 scoped_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 InitializeAudio(const CastTransportRtpConfig& config,
69 const RtcpCastMessageCallback& cast_message_cb, 69 const RtcpCastMessageCallback& cast_message_cb,
70 const RtcpRttCallback& rtt_cb, 70 const RtcpRttCallback& rtt_cb,
71 const RtcpPliCallback& pli_cb) final; 71 const RtcpPliCallback& pli_cb) final;
72 void InitializeVideo(const CastTransportRtpConfig& config, 72 void InitializeVideo(const CastTransportRtpConfig& config,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void ResendPackets(uint32_t ssrc, 129 void ResendPackets(uint32_t ssrc,
130 const MissingFramesAndPacketsMap& missing_packets, 130 const MissingFramesAndPacketsMap& missing_packets,
131 bool cancel_rtx_if_not_in_list, 131 bool cancel_rtx_if_not_in_list,
132 const DedupInfo& dedup_info); 132 const DedupInfo& dedup_info);
133 133
134 // If |logging_flush_interval| is set, this is called at approximate periodic 134 // If |logging_flush_interval| is set, this is called at approximate periodic
135 // intervals. 135 // intervals.
136 void SendRawEvents(); 136 void SendRawEvents();
137 137
138 // Called when a packet is received. 138 // Called when a packet is received.
139 bool OnReceivedPacket(scoped_ptr<Packet> packet); 139 bool OnReceivedPacket(std::unique_ptr<Packet> packet);
140 140
141 // Called when a log message is received. 141 // Called when a log message is received.
142 void OnReceivedLogMessage(EventMediaType media_type, 142 void OnReceivedLogMessage(EventMediaType media_type,
143 const RtcpReceiverLogMessage& log); 143 const RtcpReceiverLogMessage& log);
144 144
145 // Called when a RTCP Cast message is received. 145 // Called when a RTCP Cast message is received.
146 void OnReceivedCastMessage(uint32_t ssrc, 146 void OnReceivedCastMessage(uint32_t ssrc,
147 const RtcpCastMessageCallback& cast_message_cb, 147 const RtcpCastMessageCallback& cast_message_cb,
148 const RtcpCastMessage& cast_message); 148 const RtcpCastMessage& cast_message);
149 149
150 base::TickClock* const clock_; // Not owned by this class. 150 base::TickClock* const clock_; // Not owned by this class.
151 const base::TimeDelta logging_flush_interval_; 151 const base::TimeDelta logging_flush_interval_;
152 const scoped_ptr<Client> transport_client_; 152 const std::unique_ptr<Client> transport_client_;
153 const scoped_ptr<PacketTransport> transport_; 153 const std::unique_ptr<PacketTransport> transport_;
154 const scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; 154 const scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_;
155 155
156 // FrameEvents and PacketEvents pending delivery via raw events callback. 156 // FrameEvents and PacketEvents pending delivery via raw events callback.
157 // Do not add elements to these when |logging_flush_interval| is 157 // Do not add elements to these when |logging_flush_interval| is
158 // |base::TimeDelta()|. 158 // |base::TimeDelta()|.
159 std::vector<FrameEvent> recent_frame_events_; 159 std::vector<FrameEvent> recent_frame_events_;
160 std::vector<PacketEvent> recent_packet_events_; 160 std::vector<PacketEvent> recent_packet_events_;
161 161
162 // Packet sender that performs pacing. 162 // Packet sender that performs pacing.
163 PacedSender pacer_; 163 PacedSender pacer_;
164 164
165 // Packetizer for audio and video frames. 165 // Packetizer for audio and video frames.
166 scoped_ptr<RtpSender> audio_sender_; 166 std::unique_ptr<RtpSender> audio_sender_;
167 scoped_ptr<RtpSender> video_sender_; 167 std::unique_ptr<RtpSender> video_sender_;
168 168
169 // Maintains RTCP session for audio and video. 169 // Maintains RTCP session for audio and video.
170 scoped_ptr<SenderRtcpSession> audio_rtcp_session_; 170 std::unique_ptr<SenderRtcpSession> audio_rtcp_session_;
171 scoped_ptr<SenderRtcpSession> video_rtcp_session_; 171 std::unique_ptr<SenderRtcpSession> video_rtcp_session_;
172 172
173 // Encrypts data in EncodedFrames before they are sent. Note that it's 173 // Encrypts data in EncodedFrames before they are sent. Note that it's
174 // important for the encryption to happen here, in code that would execute in 174 // important for the encryption to happen here, in code that would execute in
175 // the main browser process, for security reasons. This helps to mitigate 175 // the main browser process, for security reasons. This helps to mitigate
176 // the damage that could be caused by a compromised renderer process. 176 // the damage that could be caused by a compromised renderer process.
177 TransportEncryptionHandler audio_encryptor_; 177 TransportEncryptionHandler audio_encryptor_;
178 TransportEncryptionHandler video_encryptor_; 178 TransportEncryptionHandler video_encryptor_;
179 179
180 // Right after a frame is sent we record the number of bytes sent to the 180 // Right after a frame is sent we record the number of bytes sent to the
181 // socket. We record the corresponding bytes sent for the most recent ACKed 181 // socket. We record the corresponding bytes sent for the most recent ACKed
182 // audio packet. 182 // audio packet.
183 int64_t last_byte_acked_for_audio_; 183 int64_t last_byte_acked_for_audio_;
184 184
185 // Packets that don't match these sender ssrcs are ignored. 185 // Packets that don't match these sender ssrcs are ignored.
186 std::set<uint32_t> valid_sender_ssrcs_; 186 std::set<uint32_t> valid_sender_ssrcs_;
187 187
188 // While non-null, global WiFi behavior modifications are in effect. This is 188 // While non-null, global WiFi behavior modifications are in effect. This is
189 // used, for example, to turn off WiFi scanning that tends to interfere with 189 // used, for example, to turn off WiFi scanning that tends to interfere with
190 // the reliability of UDP packet transmission. 190 // the reliability of UDP packet transmission.
191 scoped_ptr<net::ScopedWifiOptions> wifi_options_autoreset_; 191 std::unique_ptr<net::ScopedWifiOptions> wifi_options_autoreset_;
192 192
193 // Do not initialize the |rtcp_builder_at_rtp_receiver_| if the RTP receiver 193 // Do not initialize the |rtcp_builder_at_rtp_receiver_| if the RTP receiver
194 // SSRC does not match these ssrcs. Only RTP receiver needs to register its 194 // SSRC does not match these ssrcs. Only RTP receiver needs to register its
195 // SSRC in this set. 195 // SSRC in this set.
196 std::set<uint32_t> valid_rtp_receiver_ssrcs_; 196 std::set<uint32_t> valid_rtp_receiver_ssrcs_;
197 197
198 scoped_ptr<RtcpBuilder> rtcp_builder_at_rtp_receiver_; 198 std::unique_ptr<RtcpBuilder> rtcp_builder_at_rtp_receiver_;
199 199
200 base::WeakPtrFactory<CastTransportImpl> weak_factory_; 200 base::WeakPtrFactory<CastTransportImpl> weak_factory_;
201 201
202 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); 202 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl);
203 }; 203 };
204 204
205 } // namespace cast 205 } // namespace cast
206 } // namespace media 206 } // namespace media
207 207
208 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ 208 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_
OLDNEW
« no previous file with comments | « media/cast/net/cast_transport_config.h ('k') | media/cast/net/cast_transport_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698