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

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

Issue 1757843003: Remove CaptureManager and related calls in ChannelManager. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 4 years, 9 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 | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.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 /* 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 22 matching lines...) Expand all
33 bool SetRawAudioSink_w(VoiceMediaChannel* channel, 33 bool SetRawAudioSink_w(VoiceMediaChannel* channel,
34 uint32_t ssrc, 34 uint32_t ssrc,
35 rtc::scoped_ptr<webrtc::AudioSinkInterface>* sink) { 35 rtc::scoped_ptr<webrtc::AudioSinkInterface>* sink) {
36 channel->SetRawAudioSink(ssrc, rtc::ScopedToUnique(std::move(*sink))); 36 channel->SetRawAudioSink(ssrc, rtc::ScopedToUnique(std::move(*sink)));
37 return true; 37 return true;
38 } 38 }
39 } // namespace 39 } // namespace
40 40
41 enum { 41 enum {
42 MSG_EARLYMEDIATIMEOUT = 1, 42 MSG_EARLYMEDIATIMEOUT = 1,
43 MSG_SCREENCASTWINDOWEVENT,
44 MSG_RTPPACKET, 43 MSG_RTPPACKET,
45 MSG_RTCPPACKET, 44 MSG_RTCPPACKET,
46 MSG_CHANNEL_ERROR, 45 MSG_CHANNEL_ERROR,
47 MSG_READYTOSENDDATA, 46 MSG_READYTOSENDDATA,
48 MSG_DATARECEIVED, 47 MSG_DATARECEIVED,
49 MSG_FIRSTPACKETRECEIVED, 48 MSG_FIRSTPACKETRECEIVED,
50 MSG_STREAMCLOSEDREMOTELY, 49 MSG_STREAMCLOSEDREMOTELY,
51 }; 50 };
52 51
53 // Value specified in RFC 5764. 52 // Value specified in RFC 5764.
54 static const char kDtlsSrtpExporterLabel[] = "EXTRACTOR-dtls_srtp"; 53 static const char kDtlsSrtpExporterLabel[] = "EXTRACTOR-dtls_srtp";
55 54
56 static const int kAgcMinus10db = -10; 55 static const int kAgcMinus10db = -10;
57 56
58 static void SafeSetError(const std::string& message, std::string* error_desc) { 57 static void SafeSetError(const std::string& message, std::string* error_desc) {
59 if (error_desc) { 58 if (error_desc) {
60 *error_desc = message; 59 *error_desc = message;
61 } 60 }
62 } 61 }
63 62
64 struct PacketMessageData : public rtc::MessageData { 63 struct PacketMessageData : public rtc::MessageData {
65 rtc::Buffer packet; 64 rtc::Buffer packet;
66 rtc::PacketOptions options; 65 rtc::PacketOptions options;
67 }; 66 };
68 67
69 struct ScreencastEventMessageData : public rtc::MessageData {
70 ScreencastEventMessageData(uint32_t s, rtc::WindowEvent we)
71 : ssrc(s), event(we) {}
72 uint32_t ssrc;
73 rtc::WindowEvent event;
74 };
75
76 struct VoiceChannelErrorMessageData : public rtc::MessageData { 68 struct VoiceChannelErrorMessageData : public rtc::MessageData {
77 VoiceChannelErrorMessageData(uint32_t in_ssrc, 69 VoiceChannelErrorMessageData(uint32_t in_ssrc,
78 VoiceMediaChannel::Error in_error) 70 VoiceMediaChannel::Error in_error)
79 : ssrc(in_ssrc), error(in_error) {} 71 : ssrc(in_ssrc), error(in_error) {}
80 uint32_t ssrc; 72 uint32_t ssrc;
81 VoiceMediaChannel::Error error; 73 VoiceMediaChannel::Error error;
82 }; 74 };
83 75
84 struct VideoChannelErrorMessageData : public rtc::MessageData { 76 struct VideoChannelErrorMessageData : public rtc::MessageData {
85 VideoChannelErrorMessageData(uint32_t in_ssrc, 77 VideoChannelErrorMessageData(uint32_t in_ssrc,
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 1617
1626 VideoChannel::VideoChannel(rtc::Thread* thread, 1618 VideoChannel::VideoChannel(rtc::Thread* thread,
1627 VideoMediaChannel* media_channel, 1619 VideoMediaChannel* media_channel,
1628 TransportController* transport_controller, 1620 TransportController* transport_controller,
1629 const std::string& content_name, 1621 const std::string& content_name,
1630 bool rtcp) 1622 bool rtcp)
1631 : BaseChannel(thread, 1623 : BaseChannel(thread,
1632 media_channel, 1624 media_channel,
1633 transport_controller, 1625 transport_controller,
1634 content_name, 1626 content_name,
1635 rtcp), 1627 rtcp) {}
1636 previous_we_(rtc::WE_CLOSE) {}
1637 1628
1638 bool VideoChannel::Init() { 1629 bool VideoChannel::Init() {
1639 if (!BaseChannel::Init()) { 1630 if (!BaseChannel::Init()) {
1640 return false; 1631 return false;
1641 } 1632 }
1642 return true; 1633 return true;
1643 } 1634 }
1644 1635
1645 VideoChannel::~VideoChannel() { 1636 VideoChannel::~VideoChannel() {
1646 std::vector<uint32_t> screencast_ssrcs;
1647 ScreencastMap::iterator iter;
1648 while (!screencast_capturers_.empty()) {
1649 if (!RemoveScreencast(screencast_capturers_.begin()->first)) {
1650 LOG(LS_ERROR) << "Unable to delete screencast with ssrc "
1651 << screencast_capturers_.begin()->first;
1652 ASSERT(false);
1653 break;
1654 }
1655 }
1656
1657 StopMediaMonitor(); 1637 StopMediaMonitor();
1658 // this can't be done in the base class, since it calls a virtual 1638 // this can't be done in the base class, since it calls a virtual
1659 DisableMedia_w(); 1639 DisableMedia_w();
1660 1640
1661 Deinit(); 1641 Deinit();
1662 } 1642 }
1663 1643
1664 bool VideoChannel::SetSink(uint32_t ssrc, 1644 bool VideoChannel::SetSink(uint32_t ssrc,
1665 rtc::VideoSinkInterface<VideoFrame>* sink) { 1645 rtc::VideoSinkInterface<VideoFrame>* sink) {
1666 worker_thread()->Invoke<void>( 1646 worker_thread()->Invoke<void>(
1667 Bind(&VideoMediaChannel::SetSink, media_channel(), ssrc, sink)); 1647 Bind(&VideoMediaChannel::SetSink, media_channel(), ssrc, sink));
1668 return true; 1648 return true;
1669 } 1649 }
1670 1650
1671 bool VideoChannel::AddScreencast(uint32_t ssrc, VideoCapturer* capturer) {
1672 return worker_thread()->Invoke<bool>(Bind(
1673 &VideoChannel::AddScreencast_w, this, ssrc, capturer));
1674 }
1675
1676 bool VideoChannel::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { 1651 bool VideoChannel::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
1677 return InvokeOnWorker(Bind(&VideoMediaChannel::SetCapturer, 1652 return InvokeOnWorker(Bind(&VideoMediaChannel::SetCapturer,
1678 media_channel(), ssrc, capturer)); 1653 media_channel(), ssrc, capturer));
1679 } 1654 }
1680 1655
1681 bool VideoChannel::RemoveScreencast(uint32_t ssrc) {
1682 return InvokeOnWorker(Bind(&VideoChannel::RemoveScreencast_w, this, ssrc));
1683 }
1684
1685 bool VideoChannel::IsScreencasting() {
1686 return InvokeOnWorker(Bind(&VideoChannel::IsScreencasting_w, this));
1687 }
1688
1689 bool VideoChannel::SetVideoSend(uint32_t ssrc, 1656 bool VideoChannel::SetVideoSend(uint32_t ssrc,
1690 bool mute, 1657 bool mute,
1691 const VideoOptions* options) { 1658 const VideoOptions* options) {
1692 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(), 1659 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
1693 ssrc, mute, options)); 1660 ssrc, mute, options));
1694 } 1661 }
1695 1662
1696 void VideoChannel::ChangeState() { 1663 void VideoChannel::ChangeState() {
1697 // Send outgoing data if we're the active call, we have the remote content, 1664 // Send outgoing data if we're the active call, we have the remote content,
1698 // and we have had some form of connectivity. 1665 // and we have had some form of connectivity.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 1785
1819 if (video->rtp_header_extensions_set()) { 1786 if (video->rtp_header_extensions_set()) {
1820 MaybeCacheRtpAbsSendTimeHeaderExtension(video->rtp_header_extensions()); 1787 MaybeCacheRtpAbsSendTimeHeaderExtension(video->rtp_header_extensions());
1821 } 1788 }
1822 1789
1823 set_remote_content_direction(content->direction()); 1790 set_remote_content_direction(content->direction());
1824 ChangeState(); 1791 ChangeState();
1825 return true; 1792 return true;
1826 } 1793 }
1827 1794
1828 bool VideoChannel::AddScreencast_w(uint32_t ssrc, VideoCapturer* capturer) {
1829 if (screencast_capturers_.find(ssrc) != screencast_capturers_.end()) {
1830 return false;
1831 }
1832 capturer->SignalStateChange.connect(this, &VideoChannel::OnStateChange);
1833 screencast_capturers_[ssrc] = capturer;
1834 return true;
1835 }
1836
1837 bool VideoChannel::RemoveScreencast_w(uint32_t ssrc) {
1838 ScreencastMap::iterator iter = screencast_capturers_.find(ssrc);
1839 if (iter == screencast_capturers_.end()) {
1840 return false;
1841 }
1842 // Clean up VideoCapturer.
1843 delete iter->second;
1844 screencast_capturers_.erase(iter);
1845 return true;
1846 }
1847
1848 bool VideoChannel::IsScreencasting_w() const {
1849 return !screencast_capturers_.empty();
1850 }
1851
1852 void VideoChannel::OnScreencastWindowEvent_s(uint32_t ssrc,
1853 rtc::WindowEvent we) {
1854 ASSERT(signaling_thread() == rtc::Thread::Current());
1855 SignalScreencastWindowEvent(ssrc, we);
1856 }
1857
1858 void VideoChannel::OnMessage(rtc::Message *pmsg) { 1795 void VideoChannel::OnMessage(rtc::Message *pmsg) {
1859 switch (pmsg->message_id) { 1796 switch (pmsg->message_id) {
1860 case MSG_SCREENCASTWINDOWEVENT: {
1861 const ScreencastEventMessageData* data =
1862 static_cast<ScreencastEventMessageData*>(pmsg->pdata);
1863 OnScreencastWindowEvent_s(data->ssrc, data->event);
1864 delete data;
1865 break;
1866 }
1867 case MSG_CHANNEL_ERROR: { 1797 case MSG_CHANNEL_ERROR: {
1868 const VideoChannelErrorMessageData* data = 1798 const VideoChannelErrorMessageData* data =
1869 static_cast<VideoChannelErrorMessageData*>(pmsg->pdata); 1799 static_cast<VideoChannelErrorMessageData*>(pmsg->pdata);
1870 delete data; 1800 delete data;
1871 break; 1801 break;
1872 } 1802 }
1873 default: 1803 default:
1874 BaseChannel::OnMessage(pmsg); 1804 BaseChannel::OnMessage(pmsg);
1875 break; 1805 break;
1876 } 1806 }
1877 } 1807 }
1878 1808
1879 void VideoChannel::OnConnectionMonitorUpdate( 1809 void VideoChannel::OnConnectionMonitorUpdate(
1880 ConnectionMonitor* monitor, const std::vector<ConnectionInfo> &infos) { 1810 ConnectionMonitor* monitor, const std::vector<ConnectionInfo> &infos) {
1881 SignalConnectionMonitor(this, infos); 1811 SignalConnectionMonitor(this, infos);
1882 } 1812 }
1883 1813
1884 // TODO(pthatcher): Look into removing duplicate code between 1814 // TODO(pthatcher): Look into removing duplicate code between
1885 // audio, video, and data, perhaps by using templates. 1815 // audio, video, and data, perhaps by using templates.
1886 void VideoChannel::OnMediaMonitorUpdate( 1816 void VideoChannel::OnMediaMonitorUpdate(
1887 VideoMediaChannel* media_channel, const VideoMediaInfo &info) { 1817 VideoMediaChannel* media_channel, const VideoMediaInfo &info) {
1888 ASSERT(media_channel == this->media_channel()); 1818 ASSERT(media_channel == this->media_channel());
1889 SignalMediaMonitor(this, info); 1819 SignalMediaMonitor(this, info);
1890 } 1820 }
1891 1821
1892 void VideoChannel::OnScreencastWindowEvent(uint32_t ssrc,
1893 rtc::WindowEvent event) {
1894 ScreencastEventMessageData* pdata =
1895 new ScreencastEventMessageData(ssrc, event);
1896 signaling_thread()->Post(this, MSG_SCREENCASTWINDOWEVENT, pdata);
1897 }
1898
1899 void VideoChannel::OnStateChange(VideoCapturer* capturer, CaptureState ev) {
1900 // Map capturer events to window events. In the future we may want to simply
1901 // pass these events up directly.
1902 rtc::WindowEvent we;
1903 if (ev == CS_STOPPED) {
1904 we = rtc::WE_CLOSE;
1905 } else if (ev == CS_PAUSED) {
1906 we = rtc::WE_MINIMIZE;
1907 } else if (ev == CS_RUNNING && previous_we_ == rtc::WE_MINIMIZE) {
1908 we = rtc::WE_RESTORE;
1909 } else {
1910 return;
1911 }
1912 previous_we_ = we;
1913
1914 uint32_t ssrc = 0;
1915 if (!GetLocalSsrc(capturer, &ssrc)) {
1916 return;
1917 }
1918
1919 OnScreencastWindowEvent(ssrc, we);
1920 }
1921
1922 bool VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32_t* ssrc) {
1923 *ssrc = 0;
1924 for (ScreencastMap::iterator iter = screencast_capturers_.begin();
1925 iter != screencast_capturers_.end(); ++iter) {
1926 if (iter->second == capturer) {
1927 *ssrc = iter->first;
1928 return true;
1929 }
1930 }
1931 return false;
1932 }
1933
1934 void VideoChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const { 1822 void VideoChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const {
1935 GetSupportedVideoCryptoSuites(crypto_suites); 1823 GetSupportedVideoCryptoSuites(crypto_suites);
1936 } 1824 }
1937 1825
1938 DataChannel::DataChannel(rtc::Thread* thread, 1826 DataChannel::DataChannel(rtc::Thread* thread,
1939 DataMediaChannel* media_channel, 1827 DataMediaChannel* media_channel,
1940 TransportController* transport_controller, 1828 TransportController* transport_controller,
1941 const std::string& content_name, 1829 const std::string& content_name,
1942 bool rtcp) 1830 bool rtcp)
1943 : BaseChannel(thread, 1831 : BaseChannel(thread,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 return (data_channel_type_ == DCT_RTP) && BaseChannel::ShouldSetupDtlsSrtp(); 2136 return (data_channel_type_ == DCT_RTP) && BaseChannel::ShouldSetupDtlsSrtp();
2249 } 2137 }
2250 2138
2251 void DataChannel::OnStreamClosedRemotely(uint32_t sid) { 2139 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2252 rtc::TypedMessageData<uint32_t>* message = 2140 rtc::TypedMessageData<uint32_t>* message =
2253 new rtc::TypedMessageData<uint32_t>(sid); 2141 new rtc::TypedMessageData<uint32_t>(sid);
2254 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2142 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
2255 } 2143 }
2256 2144
2257 } // namespace cricket 2145 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698