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

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

Issue 1878883003: Refactor: simplify interface of SenderRtcpSession and CastTransport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 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.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:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 InitializeAudio(const CastTransportRtpConfig& config,
69 const RtcpCastMessageCallback& cast_message_cb, 69 std::unique_ptr<RtcpObserver> rtcp_observer) final;
70 const RtcpRttCallback& rtt_cb,
71 const RtcpPliCallback& pli_cb) final;
72 void InitializeVideo(const CastTransportRtpConfig& config, 70 void InitializeVideo(const CastTransportRtpConfig& config,
73 const RtcpCastMessageCallback& cast_message_cb, 71 std::unique_ptr<RtcpObserver> rtcp_observer) final;
74 const RtcpRttCallback& rtt_cb,
75 const RtcpPliCallback& pli_cb) final;
76 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final; 72 void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final;
77 73
78 void SendSenderReport(uint32_t ssrc, 74 void SendSenderReport(uint32_t ssrc,
79 base::TimeTicks current_time, 75 base::TimeTicks current_time,
80 RtpTimeTicks current_time_as_rtp_timestamp) final; 76 RtpTimeTicks current_time_as_rtp_timestamp) final;
81 77
82 void CancelSendingFrames(uint32_t ssrc, 78 void CancelSendingFrames(uint32_t ssrc,
83 const std::vector<FrameId>& frame_ids) final; 79 const std::vector<FrameId>& frame_ids) final;
84 80
85 void ResendFrameForKickstart(uint32_t ssrc, FrameId frame_id) final; 81 void ResendFrameForKickstart(uint32_t ssrc, FrameId frame_id) final;
(...skipping 24 matching lines...) Expand all
110 void AddCastFeedback(const RtcpCastMessage& cast_message, 106 void AddCastFeedback(const RtcpCastMessage& cast_message,
111 base::TimeDelta target_delay) final; 107 base::TimeDelta target_delay) final;
112 void AddPli(const RtcpPliMessage& pli_message) final; 108 void AddPli(const RtcpPliMessage& pli_message) final;
113 void AddRtcpEvents( 109 void AddRtcpEvents(
114 const ReceiverRtcpEventSubscriber::RtcpEvents& rtcp_events) final; 110 const ReceiverRtcpEventSubscriber::RtcpEvents& rtcp_events) final;
115 void AddRtpReceiverReport( 111 void AddRtpReceiverReport(
116 const RtcpReportBlock& rtp_receiver_report_block) final; 112 const RtcpReportBlock& rtp_receiver_report_block) final;
117 void SendRtcpFromRtpReceiver() final; 113 void SendRtcpFromRtpReceiver() final;
118 114
119 private: 115 private:
116 // Handle received RTCP messages on RTP sender.
117 class RtcpClient;
118
120 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, NacksCancelRetransmits); 119 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, NacksCancelRetransmits);
121 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, CancelRetransmits); 120 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, CancelRetransmits);
122 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, Kickstart); 121 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, Kickstart);
123 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, DedupRetransmissionWithAudio); 122 FRIEND_TEST_ALL_PREFIXES(CastTransportImplTest, DedupRetransmissionWithAudio);
124 123
125 // Resend packets for the stream identified by |ssrc|. 124 // Resend packets for the stream identified by |ssrc|.
126 // 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
127 // frames but not in the list will be dropped. 126 // frames but not in the list will be dropped.
128 // See PacedSender::ResendPackets() to see how |dedup_info| works. 127 // See PacedSender::ResendPackets() to see how |dedup_info| works.
129 void ResendPackets(uint32_t ssrc, 128 void ResendPackets(uint32_t ssrc,
130 const MissingFramesAndPacketsMap& missing_packets, 129 const MissingFramesAndPacketsMap& missing_packets,
131 bool cancel_rtx_if_not_in_list, 130 bool cancel_rtx_if_not_in_list,
132 const DedupInfo& dedup_info); 131 const DedupInfo& dedup_info);
133 132
134 // If |logging_flush_interval| is set, this is called at approximate periodic 133 // If |logging_flush_interval| is set, this is called at approximate periodic
135 // intervals. 134 // intervals.
136 void SendRawEvents(); 135 void SendRawEvents();
137 136
138 // Called when a packet is received. 137 // Called when a packet is received.
139 bool OnReceivedPacket(std::unique_ptr<Packet> packet); 138 bool OnReceivedPacket(std::unique_ptr<Packet> packet);
140 139
141 // Called when a log message is received. 140 // Called when a log message is received.
142 void OnReceivedLogMessage(EventMediaType media_type, 141 void OnReceivedLogMessage(EventMediaType media_type,
143 const RtcpReceiverLogMessage& log); 142 const RtcpReceiverLogMessage& log);
144 143
145 // Called when a RTCP Cast message is received. 144 // Called when a RTCP Cast message is received.
146 void OnReceivedCastMessage(uint32_t ssrc, 145 void OnReceivedCastMessage(uint32_t ssrc,
147 const RtcpCastMessageCallback& cast_message_cb,
148 const RtcpCastMessage& cast_message); 146 const RtcpCastMessage& cast_message);
149 147
150 base::TickClock* const clock_; // Not owned by this class. 148 base::TickClock* const clock_; // Not owned by this class.
151 const base::TimeDelta logging_flush_interval_; 149 const base::TimeDelta logging_flush_interval_;
152 const std::unique_ptr<Client> transport_client_; 150 const std::unique_ptr<Client> transport_client_;
153 const std::unique_ptr<PacketTransport> transport_; 151 const std::unique_ptr<PacketTransport> transport_;
154 const scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; 152 const scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_;
155 153
156 // FrameEvents and PacketEvents pending delivery via raw events callback. 154 // FrameEvents and PacketEvents pending delivery via raw events callback.
157 // Do not add elements to these when |logging_flush_interval| is 155 // Do not add elements to these when |logging_flush_interval| is
158 // |base::TimeDelta()|. 156 // |base::TimeDelta()|.
159 std::vector<FrameEvent> recent_frame_events_; 157 std::vector<FrameEvent> recent_frame_events_;
160 std::vector<PacketEvent> recent_packet_events_; 158 std::vector<PacketEvent> recent_packet_events_;
161 159
162 // Packet sender that performs pacing. 160 // Packet sender that performs pacing.
163 PacedSender pacer_; 161 PacedSender pacer_;
164 162
165 // Packetizer for audio and video frames. 163 // Packetizer for audio and video frames.
166 std::unique_ptr<RtpSender> audio_sender_; 164 std::unique_ptr<RtpSender> audio_sender_;
167 std::unique_ptr<RtpSender> video_sender_; 165 std::unique_ptr<RtpSender> video_sender_;
168 166
169 // Maintains RTCP session for audio and video. 167 // Maintains RTCP session for audio and video.
170 std::unique_ptr<SenderRtcpSession> audio_rtcp_session_; 168 std::unique_ptr<SenderRtcpSession> audio_rtcp_session_;
171 std::unique_ptr<SenderRtcpSession> video_rtcp_session_; 169 std::unique_ptr<SenderRtcpSession> video_rtcp_session_;
172 170
171 // RTCP observer for SenderRtcpSession.
172 std::unique_ptr<RtcpObserver> audio_rtcp_observer_;
173 std::unique_ptr<RtcpObserver> video_rtcp_observer_;
174
173 // Encrypts data in EncodedFrames before they are sent. Note that it's 175 // 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 176 // 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 177 // the main browser process, for security reasons. This helps to mitigate
176 // the damage that could be caused by a compromised renderer process. 178 // the damage that could be caused by a compromised renderer process.
177 TransportEncryptionHandler audio_encryptor_; 179 TransportEncryptionHandler audio_encryptor_;
178 TransportEncryptionHandler video_encryptor_; 180 TransportEncryptionHandler video_encryptor_;
179 181
180 // Right after a frame is sent we record the number of bytes sent to the 182 // 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 183 // socket. We record the corresponding bytes sent for the most recent ACKed
182 // audio packet. 184 // audio packet.
(...skipping 16 matching lines...) Expand all
199 201
200 base::WeakPtrFactory<CastTransportImpl> weak_factory_; 202 base::WeakPtrFactory<CastTransportImpl> weak_factory_;
201 203
202 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl); 204 DISALLOW_COPY_AND_ASSIGN(CastTransportImpl);
203 }; 205 };
204 206
205 } // namespace cast 207 } // namespace cast
206 } // namespace media 208 } // namespace media
207 209
208 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ 210 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_
OLDNEW
« no previous file with comments | « media/cast/net/cast_transport.h ('k') | media/cast/net/cast_transport_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698