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

Side by Side Diff: webrtc/pc/channel.h

Issue 2269173004: Renaming BaseChannel methods and adding comments for added clarity. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | webrtc/pc/channel.cc » ('j') | webrtc/pc/channel.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Forward TransportChannel SignalSentPacket to worker thread. 153 // Forward TransportChannel SignalSentPacket to worker thread.
154 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket; 154 sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
155 155
156 // Only public for unit tests. Otherwise, consider private. 156 // Only public for unit tests. Otherwise, consider private.
157 TransportChannel* transport_channel() const { return transport_channel_; } 157 TransportChannel* transport_channel() const { return transport_channel_; }
158 TransportChannel* rtcp_transport_channel() const { 158 TransportChannel* rtcp_transport_channel() const {
159 return rtcp_transport_channel_; 159 return rtcp_transport_channel_;
160 } 160 }
161 161
162 // Made public for easier testing. 162 // Made public for easier testing.
163 void SetReadyToSend(bool rtcp, bool ready); 163 //
164 // Updates "ready to send" for an individual channel, and informs the media
165 // channel that the transport is ready to send if each channel (in use) is
166 // ready to send. This is more specific than just "writable"; it means the
167 // last send didn't return ENOTCONN.
168 //
169 // This should be called whenever a channel's ready-to-send state changes,
170 // or when RTCP muxing becomes active/inactive.
171 void SetTransportChannelReadyToSend(bool rtcp, bool ready);
164 172
165 // Only public for unit tests. Otherwise, consider protected. 173 // Only public for unit tests. Otherwise, consider protected.
166 int SetOption(SocketType type, rtc::Socket::Option o, int val) 174 int SetOption(SocketType type, rtc::Socket::Option o, int val)
167 override; 175 override;
168 int SetOption_n(SocketType type, rtc::Socket::Option o, int val); 176 int SetOption_n(SocketType type, rtc::Socket::Option o, int val);
169 177
170 SrtpFilter* srtp_filter() { return &srtp_filter_; } 178 SrtpFilter* srtp_filter() { return &srtp_filter_; }
171 179
172 virtual cricket::MediaType media_type() = 0; 180 virtual cricket::MediaType media_type() = 0;
173 181
174 bool SetCryptoOptions(const rtc::CryptoOptions& crypto_options); 182 bool SetCryptoOptions(const rtc::CryptoOptions& crypto_options);
175 183
176 protected: 184 protected:
177 virtual MediaChannel* media_channel() const { return media_channel_; } 185 virtual MediaChannel* media_channel() const { return media_channel_; }
178 // Sets the |transport_channel_| (and |rtcp_transport_channel_|, if |rtcp_| is 186
179 // true). Gets the transport channels from |transport_controller_|. 187 // Sets the |transport_channel_| (and |rtcp_transport_channel_|, if
188 // |rtcp_enabled_| is true). Gets the transport channels from
189 // |transport_controller_|.
180 bool SetTransport_n(const std::string& transport_name); 190 bool SetTransport_n(const std::string& transport_name);
181 191
182 void SetTransportChannel_n(TransportChannel* transport); 192 void SetTransportChannel_n(TransportChannel* transport);
183 void SetRtcpTransportChannel_n(TransportChannel* transport, 193 void SetRtcpTransportChannel_n(TransportChannel* transport,
184 bool update_writablity); 194 bool update_writablity);
185 195
186 bool was_ever_writable() const { return was_ever_writable_; } 196 bool was_ever_writable() const { return was_ever_writable_; }
187 void set_local_content_direction(MediaContentDirection direction) { 197 void set_local_content_direction(MediaContentDirection direction) {
188 local_content_direction_ = direction; 198 local_content_direction_ = direction;
189 } 199 }
190 void set_remote_content_direction(MediaContentDirection direction) { 200 void set_remote_content_direction(MediaContentDirection direction) {
191 remote_content_direction_ = direction; 201 remote_content_direction_ = direction;
192 } 202 }
193 void set_secure_required(bool secure_required) { 203 void set_secure_required(bool secure_required) {
194 secure_required_ = secure_required; 204 secure_required_ = secure_required;
195 } 205 }
196 bool IsReadyToReceive_w() const; 206 // These methods verify that:
197 bool IsReadyToSend_w() const; 207 // * The required content description directions have been set.
208 // * The channel is enabled.
209 // * And for sending:
210 // - The SRTP filter is active if it's needed.
211 // - The transport has been writable before, meaning it should be at least
212 // possible to succeed in sending a packet.
213 //
214 // When any of these properties change, UpdateMediaSendRecvState_w should be
215 // called.
216 bool IsReadyToReceiveMedia_w() const;
217 bool IsReadyToSendMedia_w() const;
198 rtc::Thread* signaling_thread() { 218 rtc::Thread* signaling_thread() {
199 return transport_controller_->signaling_thread(); 219 return transport_controller_->signaling_thread();
200 } 220 }
201 221
202 void ConnectToTransportChannel(TransportChannel* tc); 222 void ConnectToTransportChannel(TransportChannel* tc);
203 void DisconnectFromTransportChannel(TransportChannel* tc); 223 void DisconnectFromTransportChannel(TransportChannel* tc);
204 224
205 void FlushRtcpMessages_n(); 225 void FlushRtcpMessages_n();
206 226
207 // NetworkInterface implementation, called by MediaEngine 227 // NetworkInterface implementation, called by MediaEngine
(...skipping 27 matching lines...) Expand all
235 255
236 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet); 256 virtual bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet);
237 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, 257 void HandlePacket(bool rtcp, rtc::CopyOnWriteBuffer* packet,
238 const rtc::PacketTime& packet_time); 258 const rtc::PacketTime& packet_time);
239 void OnPacketReceived(bool rtcp, 259 void OnPacketReceived(bool rtcp,
240 const rtc::CopyOnWriteBuffer& packet, 260 const rtc::CopyOnWriteBuffer& packet,
241 const rtc::PacketTime& packet_time); 261 const rtc::PacketTime& packet_time);
242 262
243 void EnableMedia_w(); 263 void EnableMedia_w();
244 void DisableMedia_w(); 264 void DisableMedia_w();
265
266 // Performs actions if the RTP/RTCP writable state changed. This should
267 // be called whenever a channel's writable state changes or when RTCP muxing
268 // becomes active/inactive.
245 void UpdateWritableState_n(); 269 void UpdateWritableState_n();
246 void ChannelWritable_n(); 270 void ChannelWritable_n();
247 void ChannelNotWritable_n(); 271 void ChannelNotWritable_n();
272
248 bool AddRecvStream_w(const StreamParams& sp); 273 bool AddRecvStream_w(const StreamParams& sp);
249 bool RemoveRecvStream_w(uint32_t ssrc); 274 bool RemoveRecvStream_w(uint32_t ssrc);
250 bool AddSendStream_w(const StreamParams& sp); 275 bool AddSendStream_w(const StreamParams& sp);
251 bool RemoveSendStream_w(uint32_t ssrc); 276 bool RemoveSendStream_w(uint32_t ssrc);
252 virtual bool ShouldSetupDtlsSrtp_n() const; 277 virtual bool ShouldSetupDtlsSrtp_n() const;
253 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. 278 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters.
254 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. 279 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter.
255 bool SetupDtlsSrtp_n(bool rtcp_channel); 280 bool SetupDtlsSrtp_n(bool rtcp_channel);
256 void MaybeSetupDtlsSrtp_n(); 281 void MaybeSetupDtlsSrtp_n();
257 // Set the DTLS-SRTP cipher policy on this channel as appropriate. 282 // Set the DTLS-SRTP cipher policy on this channel as appropriate.
258 bool SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp); 283 bool SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp);
259 284
260 void ChangeState(); 285 // Should be called whenever the conditions for
261 virtual void ChangeState_w() = 0; 286 // IsReadyToReceiveMedia/IsReadyToSendMedia are satisfied (or unsatisfied).
287 // Updates the send/recv state of the media channel.
288 void UpdateMediaSendRecvState();
289 virtual void UpdateMediaSendRecvState_w() = 0;
262 290
263 // Gets the content info appropriate to the channel (audio or video). 291 // Gets the content info appropriate to the channel (audio or video).
264 virtual const ContentInfo* GetFirstContent( 292 virtual const ContentInfo* GetFirstContent(
265 const SessionDescription* sdesc) = 0; 293 const SessionDescription* sdesc) = 0;
266 bool UpdateLocalStreams_w(const std::vector<StreamParams>& streams, 294 bool UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
267 ContentAction action, 295 ContentAction action,
268 std::string* error_desc); 296 std::string* error_desc);
269 bool UpdateRemoteStreams_w(const std::vector<StreamParams>& streams, 297 bool UpdateRemoteStreams_w(const std::vector<StreamParams>& streams,
270 ContentAction action, 298 ContentAction action,
271 std::string* error_desc); 299 std::string* error_desc);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return worker_thread_->Invoke<bool>(posted_from, functor); 350 return worker_thread_->Invoke<bool>(posted_from, functor);
323 } 351 }
324 352
325 private: 353 private:
326 bool InitNetwork_n(const std::string* bundle_transport_name); 354 bool InitNetwork_n(const std::string* bundle_transport_name);
327 void DisconnectTransportChannels_n(); 355 void DisconnectTransportChannels_n();
328 void DestroyTransportChannels_n(); 356 void DestroyTransportChannels_n();
329 void SignalSentPacket_n(TransportChannel* channel, 357 void SignalSentPacket_n(TransportChannel* channel,
330 const rtc::SentPacket& sent_packet); 358 const rtc::SentPacket& sent_packet);
331 void SignalSentPacket_w(const rtc::SentPacket& sent_packet); 359 void SignalSentPacket_w(const rtc::SentPacket& sent_packet);
332 bool IsTransportReadyToSend_n() const; 360 bool IsReadyToSendMedia_n() const;
333 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id); 361 void CacheRtpAbsSendTimeHeaderExtension_n(int rtp_abs_sendtime_extn_id);
334 362
335 rtc::Thread* const worker_thread_; 363 rtc::Thread* const worker_thread_;
336 rtc::Thread* const network_thread_; 364 rtc::Thread* const network_thread_;
337 rtc::AsyncInvoker invoker_; 365 rtc::AsyncInvoker invoker_;
338 366
339 const std::string content_name_; 367 const std::string content_name_;
340 std::unique_ptr<ConnectionMonitor> connection_monitor_; 368 std::unique_ptr<ConnectionMonitor> connection_monitor_;
341 369
342 // Transport related members that should be accessed from network thread. 370 // Transport related members that should be accessed from network thread.
(...skipping 13 matching lines...) Expand all
356 bool rtp_ready_to_send_ = false; 384 bool rtp_ready_to_send_ = false;
357 bool rtcp_ready_to_send_ = false; 385 bool rtcp_ready_to_send_ = false;
358 bool writable_ = false; 386 bool writable_ = false;
359 bool was_ever_writable_ = false; 387 bool was_ever_writable_ = false;
360 bool has_received_packet_ = false; 388 bool has_received_packet_ = false;
361 bool dtls_keyed_ = false; 389 bool dtls_keyed_ = false;
362 bool secure_required_ = false; 390 bool secure_required_ = false;
363 rtc::CryptoOptions crypto_options_; 391 rtc::CryptoOptions crypto_options_;
364 int rtp_abs_sendtime_extn_id_ = -1; 392 int rtp_abs_sendtime_extn_id_ = -1;
365 393
366 // MediaChannel related members that should be access from worker thread. 394 // MediaChannel related members that should be accessed from the worker
395 // thread.
367 MediaChannel* const media_channel_; 396 MediaChannel* const media_channel_;
368 // Currently enabled_ flag accessed from signaling thread too, but it can 397 // Currently the |enabled_| flag is accessed from the signaling thread as
369 // be changed only when signaling thread does sunchronious call to worker 398 // well, but it can be changed only when signaling thread does a synchronous
370 // thread, so it should be safe. 399 // call to the worker thread, so it should be safe.
371 bool enabled_ = false; 400 bool enabled_ = false;
372 std::vector<StreamParams> local_streams_; 401 std::vector<StreamParams> local_streams_;
373 std::vector<StreamParams> remote_streams_; 402 std::vector<StreamParams> remote_streams_;
374 MediaContentDirection local_content_direction_ = MD_INACTIVE; 403 MediaContentDirection local_content_direction_ = MD_INACTIVE;
375 MediaContentDirection remote_content_direction_ = MD_INACTIVE; 404 MediaContentDirection remote_content_direction_ = MD_INACTIVE;
376 }; 405 };
377 406
378 // VoiceChannel is a specialization that adds support for early media, DTMF, 407 // VoiceChannel is a specialization that adds support for early media, DTMF,
379 // and input/output level monitoring. 408 // and input/output level monitoring.
380 class VoiceChannel : public BaseChannel { 409 class VoiceChannel : public BaseChannel {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 webrtc::RtpParameters parameters); 480 webrtc::RtpParameters parameters);
452 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; } 481 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_AUDIO; }
453 482
454 private: 483 private:
455 // overrides from BaseChannel 484 // overrides from BaseChannel
456 void OnChannelRead(TransportChannel* channel, 485 void OnChannelRead(TransportChannel* channel,
457 const char* data, 486 const char* data,
458 size_t len, 487 size_t len,
459 const rtc::PacketTime& packet_time, 488 const rtc::PacketTime& packet_time,
460 int flags) override; 489 int flags) override;
461 void ChangeState_w() override; 490 void UpdateMediaSendRecvState_w() override;
462 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; 491 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override;
463 bool SetLocalContent_w(const MediaContentDescription* content, 492 bool SetLocalContent_w(const MediaContentDescription* content,
464 ContentAction action, 493 ContentAction action,
465 std::string* error_desc) override; 494 std::string* error_desc) override;
466 bool SetRemoteContent_w(const MediaContentDescription* content, 495 bool SetRemoteContent_w(const MediaContentDescription* content,
467 ContentAction action, 496 ContentAction action,
468 std::string* error_desc) override; 497 std::string* error_desc) override;
469 void HandleEarlyMediaTimeout(); 498 void HandleEarlyMediaTimeout();
470 bool InsertDtmf_w(uint32_t ssrc, int event, int duration); 499 bool InsertDtmf_w(uint32_t ssrc, int event, int duration);
471 bool SetOutputVolume_w(uint32_t ssrc, double volume); 500 bool SetOutputVolume_w(uint32_t ssrc, double volume);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const; 560 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const;
532 bool SetRtpSendParameters(uint32_t ssrc, 561 bool SetRtpSendParameters(uint32_t ssrc,
533 const webrtc::RtpParameters& parameters); 562 const webrtc::RtpParameters& parameters);
534 webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const; 563 webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const;
535 bool SetRtpReceiveParameters(uint32_t ssrc, 564 bool SetRtpReceiveParameters(uint32_t ssrc,
536 const webrtc::RtpParameters& parameters); 565 const webrtc::RtpParameters& parameters);
537 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_VIDEO; } 566 cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_VIDEO; }
538 567
539 private: 568 private:
540 // overrides from BaseChannel 569 // overrides from BaseChannel
541 void ChangeState_w() override; 570 void UpdateMediaSendRecvState_w() override;
542 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; 571 const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override;
543 bool SetLocalContent_w(const MediaContentDescription* content, 572 bool SetLocalContent_w(const MediaContentDescription* content,
544 ContentAction action, 573 ContentAction action,
545 std::string* error_desc) override; 574 std::string* error_desc) override;
546 bool SetRemoteContent_w(const MediaContentDescription* content, 575 bool SetRemoteContent_w(const MediaContentDescription* content,
547 ContentAction action, 576 ContentAction action,
548 std::string* error_desc) override; 577 std::string* error_desc) override;
549 bool GetStats_w(VideoMediaInfo* stats); 578 bool GetStats_w(VideoMediaInfo* stats);
550 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const; 579 webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const;
551 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); 580 bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // Same as SetDataChannelType, but extracts the type from the 685 // Same as SetDataChannelType, but extracts the type from the
657 // DataContentDescription. 686 // DataContentDescription.
658 bool SetDataChannelTypeFromContent(const DataContentDescription* content, 687 bool SetDataChannelTypeFromContent(const DataContentDescription* content,
659 std::string* error_desc); 688 std::string* error_desc);
660 bool SetLocalContent_w(const MediaContentDescription* content, 689 bool SetLocalContent_w(const MediaContentDescription* content,
661 ContentAction action, 690 ContentAction action,
662 std::string* error_desc) override; 691 std::string* error_desc) override;
663 bool SetRemoteContent_w(const MediaContentDescription* content, 692 bool SetRemoteContent_w(const MediaContentDescription* content,
664 ContentAction action, 693 ContentAction action,
665 std::string* error_desc) override; 694 std::string* error_desc) override;
666 void ChangeState_w() override; 695 void UpdateMediaSendRecvState_w() override;
667 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) override; 696 bool WantsPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) override;
668 697
669 void OnMessage(rtc::Message* pmsg) override; 698 void OnMessage(rtc::Message* pmsg) override;
670 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override; 699 void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override;
671 void OnConnectionMonitorUpdate( 700 void OnConnectionMonitorUpdate(
672 ConnectionMonitor* monitor, 701 ConnectionMonitor* monitor,
673 const std::vector<ConnectionInfo>& infos) override; 702 const std::vector<ConnectionInfo>& infos) override;
674 void OnMediaMonitorUpdate(DataMediaChannel* media_channel, 703 void OnMediaMonitorUpdate(DataMediaChannel* media_channel,
675 const DataMediaInfo& info); 704 const DataMediaInfo& info);
676 bool ShouldSetupDtlsSrtp_n() const override; 705 bool ShouldSetupDtlsSrtp_n() const override;
(...skipping 13 matching lines...) Expand all
690 // SetSendParameters. 719 // SetSendParameters.
691 DataSendParameters last_send_params_; 720 DataSendParameters last_send_params_;
692 // Last DataRecvParameters sent down to the media_channel() via 721 // Last DataRecvParameters sent down to the media_channel() via
693 // SetRecvParameters. 722 // SetRecvParameters.
694 DataRecvParameters last_recv_params_; 723 DataRecvParameters last_recv_params_;
695 }; 724 };
696 725
697 } // namespace cricket 726 } // namespace cricket
698 727
699 #endif // WEBRTC_PC_CHANNEL_H_ 728 #endif // WEBRTC_PC_CHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/pc/channel.cc » ('j') | webrtc/pc/channel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698