Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1382 | 1382 |
| 1383 void VoiceChannel::SetRawAudioSink( | 1383 void VoiceChannel::SetRawAudioSink( |
| 1384 uint32_t ssrc, | 1384 uint32_t ssrc, |
| 1385 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { | 1385 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { |
| 1386 // We need to work around Bind's lack of support for scoped_ptr and ownership | 1386 // We need to work around Bind's lack of support for scoped_ptr and ownership |
| 1387 // passing. So we invoke to our own little routine that gets a pointer to | 1387 // passing. So we invoke to our own little routine that gets a pointer to |
| 1388 // our local variable. This is OK since we're synchronously invoking. | 1388 // our local variable. This is OK since we're synchronously invoking. |
| 1389 InvokeOnWorker(Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink)); | 1389 InvokeOnWorker(Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink)); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 webrtc::RTCRtpParameters VoiceChannel::GetRtpParameters(uint32_t ssrc) { | |
| 1393 webrtc::RTCRtpParameters parameters; | |
| 1394 InvokeOnWorker( | |
| 1395 Bind(&VoiceChannel::GetRtpParameters_w, this, ssrc, ¶meters)); | |
| 1396 return parameters; | |
| 1397 } | |
| 1398 | |
| 1399 bool VoiceChannel::GetRtpParameters_w(uint32_t ssrc, | |
| 1400 webrtc::RTCRtpParameters* parameters) { | |
| 1401 *parameters = media_channel()->GetRtpParameters(ssrc); | |
| 1402 return true; | |
|
pthatcher1
2016/03/12 01:21:04
Just make it a void if it can't fail.
skvlad
2016/03/15 21:18:18
For some reason I saw the definition of InvokeOnWo
| |
| 1403 } | |
| 1404 | |
| 1405 bool VoiceChannel::SetRtpParameters( | |
| 1406 uint32_t ssrc, | |
| 1407 const webrtc::RTCRtpParameters& parameters) { | |
| 1408 return InvokeOnWorker( | |
| 1409 Bind(&VoiceChannel::SetRtpParameters_w, this, ssrc, parameters)); | |
| 1410 } | |
| 1411 | |
| 1412 bool VoiceChannel::SetRtpParameters_w(uint32_t ssrc, | |
| 1413 webrtc::RTCRtpParameters parameters) { | |
| 1414 return media_channel()->SetRtpParameters(ssrc, parameters); | |
| 1415 } | |
| 1416 | |
| 1392 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) { | 1417 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) { |
| 1393 return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats, | 1418 return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats, |
| 1394 media_channel(), stats)); | 1419 media_channel(), stats)); |
| 1395 } | 1420 } |
| 1396 | 1421 |
| 1397 void VoiceChannel::StartMediaMonitor(int cms) { | 1422 void VoiceChannel::StartMediaMonitor(int cms) { |
| 1398 media_monitor_.reset(new VoiceMediaMonitor(media_channel(), worker_thread(), | 1423 media_monitor_.reset(new VoiceMediaMonitor(media_channel(), worker_thread(), |
| 1399 rtc::Thread::Current())); | 1424 rtc::Thread::Current())); |
| 1400 media_monitor_->SignalUpdate.connect( | 1425 media_monitor_->SignalUpdate.connect( |
| 1401 this, &VoiceChannel::OnMediaMonitorUpdate); | 1426 this, &VoiceChannel::OnMediaMonitorUpdate); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1537 | 1562 |
| 1538 if (!SetRtpTransportParameters_w(content, action, CS_REMOTE, error_desc)) { | 1563 if (!SetRtpTransportParameters_w(content, action, CS_REMOTE, error_desc)) { |
| 1539 return false; | 1564 return false; |
| 1540 } | 1565 } |
| 1541 | 1566 |
| 1542 AudioSendParameters send_params = last_send_params_; | 1567 AudioSendParameters send_params = last_send_params_; |
| 1543 RtpSendParametersFromMediaDescription(audio, &send_params); | 1568 RtpSendParametersFromMediaDescription(audio, &send_params); |
| 1544 if (audio->agc_minus_10db()) { | 1569 if (audio->agc_minus_10db()) { |
| 1545 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); | 1570 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); |
| 1546 } | 1571 } |
| 1547 if (!media_channel()->SetSendParameters(send_params)) { | 1572 |
| 1573 bool parameters_applied = ApplySendParameters(send_params); | |
| 1574 if (!parameters_applied) { | |
| 1548 SafeSetError("Failed to set remote audio description send parameters.", | 1575 SafeSetError("Failed to set remote audio description send parameters.", |
| 1549 error_desc); | 1576 error_desc); |
| 1550 return false; | 1577 return false; |
| 1551 } | 1578 } |
| 1552 last_send_params_ = send_params; | 1579 last_send_params_ = send_params; |
| 1553 | 1580 |
| 1554 // TODO(pthatcher): Move remote streams into AudioRecvParameters, | 1581 // TODO(pthatcher): Move remote streams into AudioRecvParameters, |
| 1555 // and only give it to the media channel once we have a local | 1582 // and only give it to the media channel once we have a local |
| 1556 // description too (without a local description, we won't be able to | 1583 // description too (without a local description, we won't be able to |
| 1557 // recv them anyway). | 1584 // recv them anyway). |
| 1558 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { | 1585 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { |
| 1559 SafeSetError("Failed to set remote audio description streams.", error_desc); | 1586 SafeSetError("Failed to set remote audio description streams.", error_desc); |
| 1560 return false; | 1587 return false; |
| 1561 } | 1588 } |
| 1562 | 1589 |
| 1563 if (audio->rtp_header_extensions_set()) { | 1590 if (audio->rtp_header_extensions_set()) { |
| 1564 MaybeCacheRtpAbsSendTimeHeaderExtension(audio->rtp_header_extensions()); | 1591 MaybeCacheRtpAbsSendTimeHeaderExtension(audio->rtp_header_extensions()); |
| 1565 } | 1592 } |
| 1566 | 1593 |
| 1567 set_remote_content_direction(content->direction()); | 1594 set_remote_content_direction(content->direction()); |
| 1568 ChangeState(); | 1595 ChangeState(); |
| 1569 return true; | 1596 return true; |
| 1570 } | 1597 } |
| 1571 | 1598 |
| 1599 bool VoiceChannel::ApplySendParameters(const AudioSendParameters& parameters) { | |
| 1600 return media_channel()->SetSendParameters(parameters); | |
|
pthatcher1
2016/03/12 01:21:04
Why was this moved to a separate method?
skvlad
2016/03/15 21:18:18
Oops, this is a leftover from an earlier version w
| |
| 1601 } | |
| 1602 | |
| 1572 void VoiceChannel::HandleEarlyMediaTimeout() { | 1603 void VoiceChannel::HandleEarlyMediaTimeout() { |
| 1573 // This occurs on the main thread, not the worker thread. | 1604 // This occurs on the main thread, not the worker thread. |
| 1574 if (!received_media_) { | 1605 if (!received_media_) { |
| 1575 LOG(LS_INFO) << "No early media received before timeout"; | 1606 LOG(LS_INFO) << "No early media received before timeout"; |
| 1576 SignalEarlyMediaTimeout(this); | 1607 SignalEarlyMediaTimeout(this); |
| 1577 } | 1608 } |
| 1578 } | 1609 } |
| 1579 | 1610 |
| 1580 bool VoiceChannel::InsertDtmf_w(uint32_t ssrc, | 1611 bool VoiceChannel::InsertDtmf_w(uint32_t ssrc, |
| 1581 int event, | 1612 int event, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1686 return InvokeOnWorker(Bind(&VideoChannel::IsScreencasting_w, this)); | 1717 return InvokeOnWorker(Bind(&VideoChannel::IsScreencasting_w, this)); |
| 1687 } | 1718 } |
| 1688 | 1719 |
| 1689 bool VideoChannel::SetVideoSend(uint32_t ssrc, | 1720 bool VideoChannel::SetVideoSend(uint32_t ssrc, |
| 1690 bool mute, | 1721 bool mute, |
| 1691 const VideoOptions* options) { | 1722 const VideoOptions* options) { |
| 1692 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(), | 1723 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(), |
| 1693 ssrc, mute, options)); | 1724 ssrc, mute, options)); |
| 1694 } | 1725 } |
| 1695 | 1726 |
| 1727 webrtc::RTCRtpParameters VideoChannel::GetRtpParameters(uint32_t ssrc) { | |
| 1728 webrtc::RTCRtpParameters parameters; | |
| 1729 InvokeOnWorker( | |
| 1730 Bind(&VideoChannel::GetRtpParameters_w, this, ssrc, ¶meters)); | |
| 1731 return parameters; | |
| 1732 } | |
| 1733 | |
| 1734 bool VideoChannel::GetRtpParameters_w(uint32_t ssrc, | |
| 1735 webrtc::RTCRtpParameters* parameters) { | |
| 1736 *parameters = media_channel()->GetRtpParameters(ssrc); | |
| 1737 return true; | |
|
pthatcher1
2016/03/12 01:21:04
same here
skvlad
2016/03/15 21:18:18
Done.
| |
| 1738 } | |
| 1739 | |
| 1740 bool VideoChannel::SetRtpParameters( | |
| 1741 uint32_t ssrc, | |
| 1742 const webrtc::RTCRtpParameters& parameters) { | |
| 1743 return InvokeOnWorker( | |
| 1744 Bind(&VideoChannel::SetRtpParameters_w, this, ssrc, parameters)); | |
| 1745 } | |
| 1746 | |
| 1747 bool VideoChannel::SetRtpParameters_w(uint32_t ssrc, | |
| 1748 webrtc::RTCRtpParameters parameters) { | |
| 1749 return media_channel()->SetRtpParameters(ssrc, parameters); | |
| 1750 } | |
| 1696 void VideoChannel::ChangeState() { | 1751 void VideoChannel::ChangeState() { |
| 1697 // Send outgoing data if we're the active call, we have the remote content, | 1752 // Send outgoing data if we're the active call, we have the remote content, |
| 1698 // and we have had some form of connectivity. | 1753 // and we have had some form of connectivity. |
| 1699 bool send = IsReadyToSend(); | 1754 bool send = IsReadyToSend(); |
| 1700 if (!media_channel()->SetSend(send)) { | 1755 if (!media_channel()->SetSend(send)) { |
| 1701 LOG(LS_ERROR) << "Failed to SetSend on video channel"; | 1756 LOG(LS_ERROR) << "Failed to SetSend on video channel"; |
| 1702 // TODO(gangji): Report error back to server. | 1757 // TODO(gangji): Report error back to server. |
| 1703 } | 1758 } |
| 1704 | 1759 |
| 1705 LOG(LS_INFO) << "Changing video state, send=" << send; | 1760 LOG(LS_INFO) << "Changing video state, send=" << send; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1793 | 1848 |
| 1794 if (!SetRtpTransportParameters_w(content, action, CS_REMOTE, error_desc)) { | 1849 if (!SetRtpTransportParameters_w(content, action, CS_REMOTE, error_desc)) { |
| 1795 return false; | 1850 return false; |
| 1796 } | 1851 } |
| 1797 | 1852 |
| 1798 VideoSendParameters send_params = last_send_params_; | 1853 VideoSendParameters send_params = last_send_params_; |
| 1799 RtpSendParametersFromMediaDescription(video, &send_params); | 1854 RtpSendParametersFromMediaDescription(video, &send_params); |
| 1800 if (video->conference_mode()) { | 1855 if (video->conference_mode()) { |
| 1801 send_params.conference_mode = true; | 1856 send_params.conference_mode = true; |
| 1802 } | 1857 } |
| 1803 if (!media_channel()->SetSendParameters(send_params)) { | 1858 |
| 1859 bool parameters_applied = ApplySendParameters(send_params); | |
| 1860 | |
| 1861 if (!parameters_applied) { | |
| 1804 SafeSetError("Failed to set remote video description send parameters.", | 1862 SafeSetError("Failed to set remote video description send parameters.", |
| 1805 error_desc); | 1863 error_desc); |
| 1806 return false; | 1864 return false; |
| 1807 } | 1865 } |
| 1808 last_send_params_ = send_params; | 1866 last_send_params_ = send_params; |
| 1809 | 1867 |
| 1810 // TODO(pthatcher): Move remote streams into VideoRecvParameters, | 1868 // TODO(pthatcher): Move remote streams into VideoRecvParameters, |
| 1811 // and only give it to the media channel once we have a local | 1869 // and only give it to the media channel once we have a local |
| 1812 // description too (without a local description, we won't be able to | 1870 // description too (without a local description, we won't be able to |
| 1813 // recv them anyway). | 1871 // recv them anyway). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1848 bool VideoChannel::IsScreencasting_w() const { | 1906 bool VideoChannel::IsScreencasting_w() const { |
| 1849 return !screencast_capturers_.empty(); | 1907 return !screencast_capturers_.empty(); |
| 1850 } | 1908 } |
| 1851 | 1909 |
| 1852 void VideoChannel::OnScreencastWindowEvent_s(uint32_t ssrc, | 1910 void VideoChannel::OnScreencastWindowEvent_s(uint32_t ssrc, |
| 1853 rtc::WindowEvent we) { | 1911 rtc::WindowEvent we) { |
| 1854 ASSERT(signaling_thread() == rtc::Thread::Current()); | 1912 ASSERT(signaling_thread() == rtc::Thread::Current()); |
| 1855 SignalScreencastWindowEvent(ssrc, we); | 1913 SignalScreencastWindowEvent(ssrc, we); |
| 1856 } | 1914 } |
| 1857 | 1915 |
| 1916 bool VideoChannel::ApplySendParameters(const VideoSendParameters& parameters) { | |
| 1917 return media_channel()->SetSendParameters(parameters); | |
| 1918 } | |
|
pthatcher1
2016/03/12 01:21:04
same here
skvlad
2016/03/15 21:18:18
Done.
| |
| 1919 | |
| 1858 void VideoChannel::OnMessage(rtc::Message *pmsg) { | 1920 void VideoChannel::OnMessage(rtc::Message *pmsg) { |
| 1859 switch (pmsg->message_id) { | 1921 switch (pmsg->message_id) { |
| 1860 case MSG_SCREENCASTWINDOWEVENT: { | 1922 case MSG_SCREENCASTWINDOWEVENT: { |
| 1861 const ScreencastEventMessageData* data = | 1923 const ScreencastEventMessageData* data = |
| 1862 static_cast<ScreencastEventMessageData*>(pmsg->pdata); | 1924 static_cast<ScreencastEventMessageData*>(pmsg->pdata); |
| 1863 OnScreencastWindowEvent_s(data->ssrc, data->event); | 1925 OnScreencastWindowEvent_s(data->ssrc, data->event); |
| 1864 delete data; | 1926 delete data; |
| 1865 break; | 1927 break; |
| 1866 } | 1928 } |
| 1867 case MSG_CHANNEL_ERROR: { | 1929 case MSG_CHANNEL_ERROR: { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2248 return (data_channel_type_ == DCT_RTP) && BaseChannel::ShouldSetupDtlsSrtp(); | 2310 return (data_channel_type_ == DCT_RTP) && BaseChannel::ShouldSetupDtlsSrtp(); |
| 2249 } | 2311 } |
| 2250 | 2312 |
| 2251 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { | 2313 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { |
| 2252 rtc::TypedMessageData<uint32_t>* message = | 2314 rtc::TypedMessageData<uint32_t>* message = |
| 2253 new rtc::TypedMessageData<uint32_t>(sid); | 2315 new rtc::TypedMessageData<uint32_t>(sid); |
| 2254 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); | 2316 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); |
| 2255 } | 2317 } |
| 2256 | 2318 |
| 2257 } // namespace cricket | 2319 } // namespace cricket |
| OLD | NEW |