Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 struct CryptoParams; | 54 struct CryptoParams; |
| 55 class MediaContentDescription; | 55 class MediaContentDescription; |
| 56 struct ViewRequest; | 56 struct ViewRequest; |
| 57 | 57 |
| 58 enum SinkType { | 58 enum SinkType { |
| 59 SINK_PRE_CRYPTO, // Sink packets before encryption or after decryption. | 59 SINK_PRE_CRYPTO, // Sink packets before encryption or after decryption. |
| 60 SINK_POST_CRYPTO // Sink packets after encryption or before decryption. | 60 SINK_POST_CRYPTO // Sink packets after encryption or before decryption. |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // BaseChannel contains logic common to voice and video, including | 63 // BaseChannel contains logic common to voice and video, including |
| 64 // enable/mute, marshaling calls to a worker thread, and | 64 // enable, marshaling calls to a worker thread, and |
| 65 // connection and media monitors. | 65 // connection and media monitors. |
| 66 // | 66 // |
| 67 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! | 67 // WARNING! SUBCLASSES MUST CALL Deinit() IN THEIR DESTRUCTORS! |
| 68 // This is required to avoid a data race between the destructor modifying the | 68 // This is required to avoid a data race between the destructor modifying the |
| 69 // vtable, and the media channel's thread using BaseChannel as the | 69 // vtable, and the media channel's thread using BaseChannel as the |
| 70 // NetworkInterface. | 70 // NetworkInterface. |
| 71 | 71 |
| 72 class BaseChannel | 72 class BaseChannel |
| 73 : public rtc::MessageHandler, public sigslot::has_slots<>, | 73 : public rtc::MessageHandler, public sigslot::has_slots<>, |
| 74 public MediaChannel::NetworkInterface, | 74 public MediaChannel::NetworkInterface, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 96 // This function returns true if we are using SRTP. | 96 // This function returns true if we are using SRTP. |
| 97 bool secure() const { return srtp_filter_.IsActive(); } | 97 bool secure() const { return srtp_filter_.IsActive(); } |
| 98 // The following function returns true if we are using | 98 // The following function returns true if we are using |
| 99 // DTLS-based keying. If you turned off SRTP later, however | 99 // DTLS-based keying. If you turned off SRTP later, however |
| 100 // you could have secure() == false and dtls_secure() == true. | 100 // you could have secure() == false and dtls_secure() == true. |
| 101 bool secure_dtls() const { return dtls_keyed_; } | 101 bool secure_dtls() const { return dtls_keyed_; } |
| 102 // This function returns true if we require secure channel for call setup. | 102 // This function returns true if we require secure channel for call setup. |
| 103 bool secure_required() const { return secure_required_; } | 103 bool secure_required() const { return secure_required_; } |
| 104 | 104 |
| 105 bool writable() const { return writable_; } | 105 bool writable() const { return writable_; } |
| 106 bool IsStreamMuted(uint32 ssrc); | |
| 107 | 106 |
| 108 // Activate RTCP mux, regardless of the state so far. Once | 107 // Activate RTCP mux, regardless of the state so far. Once |
| 109 // activated, it can not be deactivated, and if the remote | 108 // activated, it can not be deactivated, and if the remote |
| 110 // description doesn't support RTCP mux, setting the remote | 109 // description doesn't support RTCP mux, setting the remote |
| 111 // description will fail. | 110 // description will fail. |
| 112 void ActivateRtcpMux(); | 111 void ActivateRtcpMux(); |
| 113 bool PushdownLocalDescription(const SessionDescription* local_desc, | 112 bool PushdownLocalDescription(const SessionDescription* local_desc, |
| 114 ContentAction action, | 113 ContentAction action, |
| 115 std::string* error_desc); | 114 std::string* error_desc); |
| 116 bool PushdownRemoteDescription(const SessionDescription* remote_desc, | 115 bool PushdownRemoteDescription(const SessionDescription* remote_desc, |
| 117 ContentAction action, | 116 ContentAction action, |
| 118 std::string* error_desc); | 117 std::string* error_desc); |
| 119 // Channel control | 118 // Channel control |
| 120 bool SetLocalContent(const MediaContentDescription* content, | 119 bool SetLocalContent(const MediaContentDescription* content, |
| 121 ContentAction action, | 120 ContentAction action, |
| 122 std::string* error_desc); | 121 std::string* error_desc); |
| 123 bool SetRemoteContent(const MediaContentDescription* content, | 122 bool SetRemoteContent(const MediaContentDescription* content, |
| 124 ContentAction action, | 123 ContentAction action, |
| 125 std::string* error_desc); | 124 std::string* error_desc); |
| 126 | 125 |
| 127 bool Enable(bool enable); | 126 bool Enable(bool enable); |
| 128 // Mute sending media on the stream with SSRC |ssrc| | |
| 129 // If there is only one sending stream SSRC 0 can be used. | |
| 130 bool MuteStream(uint32 ssrc, bool mute); | |
| 131 | 127 |
| 132 // Multiplexing | 128 // Multiplexing |
| 133 bool AddRecvStream(const StreamParams& sp); | 129 bool AddRecvStream(const StreamParams& sp); |
| 134 bool RemoveRecvStream(uint32 ssrc); | 130 bool RemoveRecvStream(uint32 ssrc); |
| 135 bool AddSendStream(const StreamParams& sp); | 131 bool AddSendStream(const StreamParams& sp); |
| 136 bool RemoveSendStream(uint32 ssrc); | 132 bool RemoveSendStream(uint32 ssrc); |
| 137 | 133 |
| 138 // Monitoring | 134 // Monitoring |
| 139 void StartConnectionMonitor(int cms); | 135 void StartConnectionMonitor(int cms); |
| 140 void StopConnectionMonitor(); | 136 void StopConnectionMonitor(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet); | 216 virtual bool WantsPacket(bool rtcp, rtc::Buffer* packet); |
| 221 void HandlePacket(bool rtcp, rtc::Buffer* packet, | 217 void HandlePacket(bool rtcp, rtc::Buffer* packet, |
| 222 const rtc::PacketTime& packet_time); | 218 const rtc::PacketTime& packet_time); |
| 223 | 219 |
| 224 // Apply the new local/remote session description. | 220 // Apply the new local/remote session description. |
| 225 void OnNewLocalDescription(BaseSession* session, ContentAction action); | 221 void OnNewLocalDescription(BaseSession* session, ContentAction action); |
| 226 void OnNewRemoteDescription(BaseSession* session, ContentAction action); | 222 void OnNewRemoteDescription(BaseSession* session, ContentAction action); |
| 227 | 223 |
| 228 void EnableMedia_w(); | 224 void EnableMedia_w(); |
| 229 void DisableMedia_w(); | 225 void DisableMedia_w(); |
| 230 bool MuteStream_w(uint32 ssrc, bool mute); | |
| 231 bool IsStreamMuted_w(uint32 ssrc); | |
| 232 void ChannelWritable_w(); | 226 void ChannelWritable_w(); |
| 233 void ChannelNotWritable_w(); | 227 void ChannelNotWritable_w(); |
| 234 bool AddRecvStream_w(const StreamParams& sp); | 228 bool AddRecvStream_w(const StreamParams& sp); |
| 235 bool RemoveRecvStream_w(uint32 ssrc); | 229 bool RemoveRecvStream_w(uint32 ssrc); |
| 236 bool AddSendStream_w(const StreamParams& sp); | 230 bool AddSendStream_w(const StreamParams& sp); |
| 237 bool RemoveSendStream_w(uint32 ssrc); | 231 bool RemoveSendStream_w(uint32 ssrc); |
| 238 virtual bool ShouldSetupDtlsSrtp() const; | 232 virtual bool ShouldSetupDtlsSrtp() const; |
| 239 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. | 233 // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. |
| 240 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. | 234 // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. |
| 241 bool SetupDtlsSrtp(bool rtcp_channel); | 235 bool SetupDtlsSrtp(bool rtcp_channel); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 RtcpMuxFilter rtcp_mux_filter_; | 306 RtcpMuxFilter rtcp_mux_filter_; |
| 313 BundleFilter bundle_filter_; | 307 BundleFilter bundle_filter_; |
| 314 rtc::scoped_ptr<ConnectionMonitor> connection_monitor_; | 308 rtc::scoped_ptr<ConnectionMonitor> connection_monitor_; |
| 315 bool enabled_; | 309 bool enabled_; |
| 316 bool writable_; | 310 bool writable_; |
| 317 bool rtp_ready_to_send_; | 311 bool rtp_ready_to_send_; |
| 318 bool rtcp_ready_to_send_; | 312 bool rtcp_ready_to_send_; |
| 319 bool was_ever_writable_; | 313 bool was_ever_writable_; |
| 320 MediaContentDirection local_content_direction_; | 314 MediaContentDirection local_content_direction_; |
| 321 MediaContentDirection remote_content_direction_; | 315 MediaContentDirection remote_content_direction_; |
| 322 std::set<uint32> muted_streams_; | |
| 323 bool has_received_packet_; | 316 bool has_received_packet_; |
| 324 bool dtls_keyed_; | 317 bool dtls_keyed_; |
| 325 bool secure_required_; | 318 bool secure_required_; |
| 326 int rtp_abs_sendtime_extn_id_; | 319 int rtp_abs_sendtime_extn_id_; |
| 327 }; | 320 }; |
| 328 | 321 |
| 329 // VoiceChannel is a specialization that adds support for early media, DTMF, | 322 // VoiceChannel is a specialization that adds support for early media, DTMF, |
| 330 // and input/output level monitoring. | 323 // and input/output level monitoring. |
| 331 class VoiceChannel : public BaseChannel { | 324 class VoiceChannel : public BaseChannel { |
| 332 public: | 325 public: |
| 333 VoiceChannel(rtc::Thread* thread, MediaEngineInterface* media_engine, | 326 VoiceChannel(rtc::Thread* thread, MediaEngineInterface* media_engine, |
| 334 VoiceMediaChannel* channel, BaseSession* session, | 327 VoiceMediaChannel* channel, BaseSession* session, |
| 335 const std::string& content_name, bool rtcp); | 328 const std::string& content_name, bool rtcp); |
| 336 ~VoiceChannel(); | 329 ~VoiceChannel(); |
| 337 bool Init(); | 330 bool Init(); |
| 338 bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer); | 331 bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer); |
| 339 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); | 332 |
| 333 // Configure sending media on the stream with SSRC |ssrc| | |
| 334 // If there is only one sending stream SSRC 0 can be used. | |
| 335 bool SetAudioSend(uint32 ssrc, bool mute, const AudioOptions* options, | |
| 336 AudioRenderer* renderer); | |
| 340 | 337 |
| 341 // downcasts a MediaChannel | 338 // downcasts a MediaChannel |
| 342 virtual VoiceMediaChannel* media_channel() const { | 339 virtual VoiceMediaChannel* media_channel() const { |
| 343 return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel()); | 340 return static_cast<VoiceMediaChannel*>(BaseChannel::media_channel()); |
| 344 } | 341 } |
| 345 | 342 |
| 346 bool SetRingbackTone(const void* buf, int len); | 343 bool SetRingbackTone(const void* buf, int len); |
| 347 void SetEarlyMedia(bool enable); | 344 void SetEarlyMedia(bool enable); |
| 348 // This signal is emitted when we have gone a period of time without | 345 // This signal is emitted when we have gone a period of time without |
| 349 // receiving early media. When received, a UI should start playing its | 346 // receiving early media. When received, a UI should start playing its |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 380 | 377 |
| 381 int GetInputLevel_w(); | 378 int GetInputLevel_w(); |
| 382 int GetOutputLevel_w(); | 379 int GetOutputLevel_w(); |
| 383 void GetActiveStreams_w(AudioInfo::StreamList* actives); | 380 void GetActiveStreams_w(AudioInfo::StreamList* actives); |
| 384 | 381 |
| 385 // Signal errors from VoiceMediaChannel. Arguments are: | 382 // Signal errors from VoiceMediaChannel. Arguments are: |
| 386 // ssrc(uint32), and error(VoiceMediaChannel::Error). | 383 // ssrc(uint32), and error(VoiceMediaChannel::Error). |
| 387 sigslot::signal3<VoiceChannel*, uint32, VoiceMediaChannel::Error> | 384 sigslot::signal3<VoiceChannel*, uint32, VoiceMediaChannel::Error> |
| 388 SignalMediaError; | 385 SignalMediaError; |
| 389 | 386 |
| 390 // Configuration and setting. | |
| 391 bool SetChannelOptions(const AudioOptions& options); | |
| 392 | |
| 393 private: | 387 private: |
| 394 // overrides from BaseChannel | 388 // overrides from BaseChannel |
| 395 virtual void OnChannelRead(TransportChannel* channel, | 389 virtual void OnChannelRead(TransportChannel* channel, |
| 396 const char* data, size_t len, | 390 const char* data, size_t len, |
| 397 const rtc::PacketTime& packet_time, | 391 const rtc::PacketTime& packet_time, |
| 398 int flags); | 392 int flags); |
| 399 virtual void ChangeState(); | 393 virtual void ChangeState(); |
| 400 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); | 394 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); |
| 401 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 395 virtual bool SetLocalContent_w(const MediaContentDescription* content, |
| 402 ContentAction action, | 396 ContentAction action, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 void StartMediaMonitor(int cms); | 467 void StartMediaMonitor(int cms); |
| 474 void StopMediaMonitor(); | 468 void StopMediaMonitor(); |
| 475 sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor; | 469 sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor; |
| 476 sigslot::signal2<uint32, rtc::WindowEvent> SignalScreencastWindowEvent; | 470 sigslot::signal2<uint32, rtc::WindowEvent> SignalScreencastWindowEvent; |
| 477 | 471 |
| 478 bool SendIntraFrame(); | 472 bool SendIntraFrame(); |
| 479 bool RequestIntraFrame(); | 473 bool RequestIntraFrame(); |
| 480 sigslot::signal3<VideoChannel*, uint32, VideoMediaChannel::Error> | 474 sigslot::signal3<VideoChannel*, uint32, VideoMediaChannel::Error> |
| 481 SignalMediaError; | 475 SignalMediaError; |
| 482 | 476 |
| 483 // Configuration and setting. | 477 // Mute sending media on the stream with SSRC |ssrc| |
| 484 bool SetChannelOptions(const VideoOptions& options); | 478 // If there is only one sending stream SSRC 0 can be used. |
|
pthatcher1
2015/09/09 07:16:12
For the audio comment, you call it "configure send
the sun
2015/09/09 09:50:50
Because copy+paste.
| |
| 479 bool SetVideoSend(uint32 ssrc, bool mute, const VideoOptions* options); | |
| 485 | 480 |
| 486 private: | 481 private: |
| 487 typedef std::map<uint32, VideoCapturer*> ScreencastMap; | 482 typedef std::map<uint32, VideoCapturer*> ScreencastMap; |
| 488 struct ScreencastDetailsData; | 483 struct ScreencastDetailsData; |
| 489 | 484 |
| 490 // overrides from BaseChannel | 485 // overrides from BaseChannel |
| 491 virtual void ChangeState(); | 486 virtual void ChangeState(); |
| 492 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); | 487 virtual const ContentInfo* GetFirstContent(const SessionDescription* sdesc); |
| 493 virtual bool SetLocalContent_w(const MediaContentDescription* content, | 488 virtual bool SetLocalContent_w(const MediaContentDescription* content, |
| 494 ContentAction action, | 489 ContentAction action, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 // SetSendParameters. | 649 // SetSendParameters. |
| 655 DataSendParameters last_send_params_; | 650 DataSendParameters last_send_params_; |
| 656 // Last DataRecvParameters sent down to the media_channel() via | 651 // Last DataRecvParameters sent down to the media_channel() via |
| 657 // SetRecvParameters. | 652 // SetRecvParameters. |
| 658 DataRecvParameters last_recv_params_; | 653 DataRecvParameters last_recv_params_; |
| 659 }; | 654 }; |
| 660 | 655 |
| 661 } // namespace cricket | 656 } // namespace cricket |
| 662 | 657 |
| 663 #endif // TALK_SESSION_MEDIA_CHANNEL_H_ | 658 #endif // TALK_SESSION_MEDIA_CHANNEL_H_ |
| OLD | NEW |