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

Side by Side Diff: talk/session/media/channel.cc

Issue 1327933002: Full impl of NnChannel::SetSendParameters and NnChannel::SetRecvParameters (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Got rid of SetChannelOptions Created 5 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
OLDNEW
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 tc->SignalReadyToSend.disconnect(this); 316 tc->SignalReadyToSend.disconnect(this);
317 } 317 }
318 318
319 bool BaseChannel::Enable(bool enable) { 319 bool BaseChannel::Enable(bool enable) {
320 worker_thread_->Invoke<void>(Bind( 320 worker_thread_->Invoke<void>(Bind(
321 enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w, 321 enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
322 this)); 322 this));
323 return true; 323 return true;
324 } 324 }
325 325
326 bool BaseChannel::MuteStream(uint32 ssrc, bool mute) {
327 return InvokeOnWorker(Bind(&BaseChannel::MuteStream_w, this, ssrc, mute));
328 }
329
330 bool BaseChannel::IsStreamMuted(uint32 ssrc) {
331 return InvokeOnWorker(Bind(&BaseChannel::IsStreamMuted_w, this, ssrc));
332 }
333
334 bool BaseChannel::AddRecvStream(const StreamParams& sp) { 326 bool BaseChannel::AddRecvStream(const StreamParams& sp) {
335 return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp)); 327 return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp));
336 } 328 }
337 329
338 bool BaseChannel::RemoveRecvStream(uint32 ssrc) { 330 bool BaseChannel::RemoveRecvStream(uint32 ssrc) {
339 return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc)); 331 return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc));
340 } 332 }
341 333
342 bool BaseChannel::AddSendStream(const StreamParams& sp) { 334 bool BaseChannel::AddSendStream(const StreamParams& sp) {
343 return InvokeOnWorker( 335 return InvokeOnWorker(
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 void BaseChannel::DisableMedia_w() { 709 void BaseChannel::DisableMedia_w() {
718 ASSERT(worker_thread_ == rtc::Thread::Current()); 710 ASSERT(worker_thread_ == rtc::Thread::Current());
719 if (!enabled_) 711 if (!enabled_)
720 return; 712 return;
721 713
722 LOG(LS_INFO) << "Channel disabled"; 714 LOG(LS_INFO) << "Channel disabled";
723 enabled_ = false; 715 enabled_ = false;
724 ChangeState(); 716 ChangeState();
725 } 717 }
726 718
727 bool BaseChannel::MuteStream_w(uint32 ssrc, bool mute) {
728 ASSERT(worker_thread_ == rtc::Thread::Current());
729 bool ret = media_channel()->MuteStream(ssrc, mute);
730 if (ret) {
731 if (mute)
732 muted_streams_.insert(ssrc);
733 else
734 muted_streams_.erase(ssrc);
735 }
736 return ret;
737 }
738
739 bool BaseChannel::IsStreamMuted_w(uint32 ssrc) {
740 ASSERT(worker_thread_ == rtc::Thread::Current());
741 return muted_streams_.find(ssrc) != muted_streams_.end();
742 }
743
744 void BaseChannel::ChannelWritable_w() { 719 void BaseChannel::ChannelWritable_w() {
745 ASSERT(worker_thread_ == rtc::Thread::Current()); 720 ASSERT(worker_thread_ == rtc::Thread::Current());
746 if (writable_) 721 if (writable_)
747 return; 722 return;
748 723
749 LOG(LS_INFO) << "Channel socket writable (" 724 LOG(LS_INFO) << "Channel socket writable ("
750 << transport_channel_->content_name() << ", " 725 << transport_channel_->content_name() << ", "
751 << transport_channel_->component() << ")" 726 << transport_channel_->component() << ")"
752 << (was_ever_writable_ ? "" : " for the first time"); 727 << (was_ever_writable_ ? "" : " for the first time");
753 728
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 bool VoiceChannel::SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) { 1263 bool VoiceChannel::SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) {
1289 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetRemoteRenderer, 1264 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetRemoteRenderer,
1290 media_channel(), ssrc, renderer)); 1265 media_channel(), ssrc, renderer));
1291 } 1266 }
1292 1267
1293 bool VoiceChannel::SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) { 1268 bool VoiceChannel::SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) {
1294 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetLocalRenderer, 1269 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetLocalRenderer,
1295 media_channel(), ssrc, renderer)); 1270 media_channel(), ssrc, renderer));
1296 } 1271 }
1297 1272
1273 bool VoiceChannel::MuteStream(uint32 ssrc, bool mute,
1274 const AudioOptions* options) {
1275 return InvokeOnWorker(
1276 Bind(&VoiceChannel::MuteStream_w, this, ssrc, mute, options));
1277 }
1278
1279 bool VoiceChannel::IsStreamMuted(uint32 ssrc) {
1280 return InvokeOnWorker(Bind(&VoiceChannel::IsStreamMuted_w, this, ssrc));
1281 }
1282
1298 bool VoiceChannel::SetRingbackTone(const void* buf, int len) { 1283 bool VoiceChannel::SetRingbackTone(const void* buf, int len) {
1299 return InvokeOnWorker(Bind(&VoiceChannel::SetRingbackTone_w, this, buf, len)); 1284 return InvokeOnWorker(Bind(&VoiceChannel::SetRingbackTone_w, this, buf, len));
1300 } 1285 }
1301 1286
1302 // TODO(juberti): Handle early media the right way. We should get an explicit 1287 // TODO(juberti): Handle early media the right way. We should get an explicit
1303 // ringing message telling us to start playing local ringback, which we cancel 1288 // ringing message telling us to start playing local ringback, which we cancel
1304 // if any early media actually arrives. For now, we do the opposite, which is 1289 // if any early media actually arrives. For now, we do the opposite, which is
1305 // to wait 1 second for early media, and start playing local ringback if none 1290 // to wait 1 second for early media, and start playing local ringback if none
1306 // arrives. 1291 // arrives.
1307 void VoiceChannel::SetEarlyMedia(bool enable) { 1292 void VoiceChannel::SetEarlyMedia(bool enable) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 } 1375 }
1391 1376
1392 void VoiceChannel::StopTypingMonitor() { 1377 void VoiceChannel::StopTypingMonitor() {
1393 typing_monitor_.reset(); 1378 typing_monitor_.reset();
1394 } 1379 }
1395 1380
1396 bool VoiceChannel::IsTypingMonitorRunning() const { 1381 bool VoiceChannel::IsTypingMonitorRunning() const {
1397 return typing_monitor_; 1382 return typing_monitor_;
1398 } 1383 }
1399 1384
1400 bool VoiceChannel::MuteStream_w(uint32 ssrc, bool mute) { 1385 bool VoiceChannel::MuteStream_w(uint32 ssrc, bool mute,
1401 bool ret = BaseChannel::MuteStream_w(ssrc, mute); 1386 const AudioOptions* options) {
1402 if (typing_monitor_ && mute) 1387 ASSERT(worker_thread()->IsCurrent());
1388 bool ret = media_channel()->MuteStream(ssrc, mute, options);
1389 if (ret) {
1390 if (mute)
1391 muted_streams_.insert(ssrc);
1392 else
1393 muted_streams_.erase(ssrc);
1394 }
1395 if (typing_monitor_ && mute) {
1403 typing_monitor_->OnChannelMuted(); 1396 typing_monitor_->OnChannelMuted();
1397 }
1404 return ret; 1398 return ret;
1405 } 1399 }
1406 1400
1401 bool VoiceChannel::IsStreamMuted_w(uint32 ssrc) {
1402 ASSERT(worker_thread()->IsCurrent());
1403 return muted_streams_.find(ssrc) != muted_streams_.end();
1404 }
1405
1407 int VoiceChannel::GetInputLevel_w() { 1406 int VoiceChannel::GetInputLevel_w() {
1408 return media_engine_->GetInputLevel(); 1407 return media_engine_->GetInputLevel();
1409 } 1408 }
1410 1409
1411 int VoiceChannel::GetOutputLevel_w() { 1410 int VoiceChannel::GetOutputLevel_w() {
1412 return media_channel()->GetOutputLevel(); 1411 return media_channel()->GetOutputLevel();
1413 } 1412 }
1414 1413
1415 void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) { 1414 void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) {
1416 media_channel()->GetActiveStreams(actives); 1415 media_channel()->GetActiveStreams(actives);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1573
1575 bool VoiceChannel::InsertDtmf_w(uint32 ssrc, int event, int duration, 1574 bool VoiceChannel::InsertDtmf_w(uint32 ssrc, int event, int duration,
1576 int flags) { 1575 int flags) {
1577 if (!enabled()) { 1576 if (!enabled()) {
1578 return false; 1577 return false;
1579 } 1578 }
1580 1579
1581 return media_channel()->InsertDtmf(ssrc, event, duration, flags); 1580 return media_channel()->InsertDtmf(ssrc, event, duration, flags);
1582 } 1581 }
1583 1582
1584 bool VoiceChannel::SetChannelOptions(const AudioOptions& options) {
1585 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOptions,
1586 media_channel(), options));
1587 }
1588
1589 void VoiceChannel::OnMessage(rtc::Message *pmsg) { 1583 void VoiceChannel::OnMessage(rtc::Message *pmsg) {
1590 switch (pmsg->message_id) { 1584 switch (pmsg->message_id) {
1591 case MSG_EARLYMEDIATIMEOUT: 1585 case MSG_EARLYMEDIATIMEOUT:
1592 HandleEarlyMediaTimeout(); 1586 HandleEarlyMediaTimeout();
1593 break; 1587 break;
1594 case MSG_CHANNEL_ERROR: { 1588 case MSG_CHANNEL_ERROR: {
1595 VoiceChannelErrorMessageData* data = 1589 VoiceChannelErrorMessageData* data =
1596 static_cast<VoiceChannelErrorMessageData*>(pmsg->pdata); 1590 static_cast<VoiceChannelErrorMessageData*>(pmsg->pdata);
1597 SignalMediaError(this, data->ssrc, data->error); 1591 SignalMediaError(this, data->ssrc, data->error);
1598 delete data; 1592 delete data;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 &VideoMediaChannel::SendIntraFrame, media_channel())); 1743 &VideoMediaChannel::SendIntraFrame, media_channel()));
1750 return true; 1744 return true;
1751 } 1745 }
1752 1746
1753 bool VideoChannel::RequestIntraFrame() { 1747 bool VideoChannel::RequestIntraFrame() {
1754 worker_thread()->Invoke<void>(Bind( 1748 worker_thread()->Invoke<void>(Bind(
1755 &VideoMediaChannel::RequestIntraFrame, media_channel())); 1749 &VideoMediaChannel::RequestIntraFrame, media_channel()));
1756 return true; 1750 return true;
1757 } 1751 }
1758 1752
1753 bool VideoChannel::MuteStream(uint32 ssrc, bool mute,
1754 const VideoOptions* options) {
1755 return InvokeOnWorker(
1756 Bind(&VideoChannel::MuteStream_w, this, ssrc, mute, options));
1757 }
1758
1759 void VideoChannel::ChangeState() { 1759 void VideoChannel::ChangeState() {
1760 // Render incoming data if we're the active call, and we have the local 1760 // Render incoming data if we're the active call, and we have the local
1761 // content. We receive data on the default channel and multiplexed streams. 1761 // content. We receive data on the default channel and multiplexed streams.
1762 bool recv = IsReadyToReceive(); 1762 bool recv = IsReadyToReceive();
1763 if (!media_channel()->SetRender(recv)) { 1763 if (!media_channel()->SetRender(recv)) {
1764 LOG(LS_ERROR) << "Failed to SetRender on video channel"; 1764 LOG(LS_ERROR) << "Failed to SetRender on video channel";
1765 // TODO(gangji): Report error back to server. 1765 // TODO(gangji): Report error back to server.
1766 } 1766 }
1767 1767
1768 // Send outgoing data if we're the active call, we have the remote content, 1768 // Send outgoing data if we're the active call, we have the remote content,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 data->fps = VideoFormat::IntervalToFps(video_format->interval); 1966 data->fps = VideoFormat::IntervalToFps(video_format->interval);
1967 data->screencast_max_pixels = capturer->screencast_max_pixels(); 1967 data->screencast_max_pixels = capturer->screencast_max_pixels();
1968 } 1968 }
1969 1969
1970 void VideoChannel::OnScreencastWindowEvent_s(uint32 ssrc, 1970 void VideoChannel::OnScreencastWindowEvent_s(uint32 ssrc,
1971 rtc::WindowEvent we) { 1971 rtc::WindowEvent we) {
1972 ASSERT(signaling_thread() == rtc::Thread::Current()); 1972 ASSERT(signaling_thread() == rtc::Thread::Current());
1973 SignalScreencastWindowEvent(ssrc, we); 1973 SignalScreencastWindowEvent(ssrc, we);
1974 } 1974 }
1975 1975
1976 bool VideoChannel::SetChannelOptions(const VideoOptions &options) {
1977 return InvokeOnWorker(Bind(&VideoMediaChannel::SetOptions,
1978 media_channel(), options));
1979 }
1980
1981 void VideoChannel::OnMessage(rtc::Message *pmsg) { 1976 void VideoChannel::OnMessage(rtc::Message *pmsg) {
1982 switch (pmsg->message_id) { 1977 switch (pmsg->message_id) {
1983 case MSG_SCREENCASTWINDOWEVENT: { 1978 case MSG_SCREENCASTWINDOWEVENT: {
1984 const ScreencastEventMessageData* data = 1979 const ScreencastEventMessageData* data =
1985 static_cast<ScreencastEventMessageData*>(pmsg->pdata); 1980 static_cast<ScreencastEventMessageData*>(pmsg->pdata);
1986 OnScreencastWindowEvent_s(data->ssrc, data->event); 1981 OnScreencastWindowEvent_s(data->ssrc, data->event);
1987 delete data; 1982 delete data;
1988 break; 1983 break;
1989 } 1984 }
1990 case MSG_CHANNEL_ERROR: { 1985 case MSG_CHANNEL_ERROR: {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 ASSERT(mode == SrtpFilter::UNPROTECT); 2075 ASSERT(mode == SrtpFilter::UNPROTECT);
2081 // TODO(gangji): Turn on the signaling of replay error once we have 2076 // TODO(gangji): Turn on the signaling of replay error once we have
2082 // switched to the new mechanism for doing video retransmissions. 2077 // switched to the new mechanism for doing video retransmissions.
2083 // OnVideoChannelError(ssrc, VideoMediaChannel::ERROR_PLAY_SRTP_REPLAY); 2078 // OnVideoChannelError(ssrc, VideoMediaChannel::ERROR_PLAY_SRTP_REPLAY);
2084 break; 2079 break;
2085 default: 2080 default:
2086 break; 2081 break;
2087 } 2082 }
2088 } 2083 }
2089 2084
2090
2091 void VideoChannel::GetSrtpCiphers(std::vector<std::string>* ciphers) const { 2085 void VideoChannel::GetSrtpCiphers(std::vector<std::string>* ciphers) const {
2092 GetSupportedVideoCryptoSuites(ciphers); 2086 GetSupportedVideoCryptoSuites(ciphers);
2093 } 2087 }
2094 2088
2089 bool VideoChannel::MuteStream_w(uint32 ssrc, bool mute,
2090 const VideoOptions* options) {
2091 ASSERT(worker_thread()->IsCurrent());
2092 return media_channel()->MuteStream(ssrc, mute, options);
2093 }
2094
2095 DataChannel::DataChannel(rtc::Thread* thread, 2095 DataChannel::DataChannel(rtc::Thread* thread,
2096 DataMediaChannel* media_channel, 2096 DataMediaChannel* media_channel,
2097 BaseSession* session, 2097 BaseSession* session,
2098 const std::string& content_name, 2098 const std::string& content_name,
2099 bool rtcp) 2099 bool rtcp)
2100 : BaseChannel(thread, media_channel, session, content_name, rtcp), 2100 : BaseChannel(thread, media_channel, session, content_name, rtcp),
2101 data_channel_type_(cricket::DCT_NONE), 2101 data_channel_type_(cricket::DCT_NONE),
2102 ready_to_send_data_(false) { 2102 ready_to_send_data_(false) {
2103 } 2103 }
2104 2104
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 return (data_channel_type_ == DCT_RTP); 2428 return (data_channel_type_ == DCT_RTP);
2429 } 2429 }
2430 2430
2431 void DataChannel::OnStreamClosedRemotely(uint32 sid) { 2431 void DataChannel::OnStreamClosedRemotely(uint32 sid) {
2432 rtc::TypedMessageData<uint32>* message = 2432 rtc::TypedMessageData<uint32>* message =
2433 new rtc::TypedMessageData<uint32>(sid); 2433 new rtc::TypedMessageData<uint32>(sid);
2434 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2434 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
2435 } 2435 }
2436 2436
2437 } // namespace cricket 2437 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698