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

Side by Side Diff: webrtc/api/webrtcsession.cc

Issue 2046173002: Use VoiceChannel/VideoChannel directly from RtpSender/RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moving code that needs to execute out of RTC_DCHECKs. Created 4 years, 5 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/api/webrtcsession.h ('k') | webrtc/api/webrtcsession_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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 } 1162 }
1163 return webrtc::GetTrackIdBySsrc(remote_desc_->description(), ssrc, track_id); 1163 return webrtc::GetTrackIdBySsrc(remote_desc_->description(), ssrc, track_id);
1164 } 1164 }
1165 1165
1166 std::string WebRtcSession::BadStateErrMsg(State state) { 1166 std::string WebRtcSession::BadStateErrMsg(State state) {
1167 std::ostringstream desc; 1167 std::ostringstream desc;
1168 desc << "Called in wrong state: " << GetStateString(state); 1168 desc << "Called in wrong state: " << GetStateString(state);
1169 return desc.str(); 1169 return desc.str();
1170 } 1170 }
1171 1171
1172 void WebRtcSession::SetAudioPlayout(uint32_t ssrc, bool enable) {
1173 ASSERT(signaling_thread()->IsCurrent());
1174 if (!voice_channel_) {
1175 LOG(LS_ERROR) << "SetAudioPlayout: No audio channel exists.";
1176 return;
1177 }
1178 if (!voice_channel_->SetOutputVolume(ssrc, enable ? 1 : 0)) {
1179 // Allow that SetOutputVolume fail if |enable| is false but assert
1180 // otherwise. This in the normal case when the underlying media channel has
1181 // already been deleted.
1182 ASSERT(enable == false);
1183 }
1184 }
1185
1186 void WebRtcSession::SetAudioSend(uint32_t ssrc,
1187 bool enable,
1188 const cricket::AudioOptions& options,
1189 cricket::AudioSource* source) {
1190 ASSERT(signaling_thread()->IsCurrent());
1191 if (!voice_channel_) {
1192 LOG(LS_ERROR) << "SetAudioSend: No audio channel exists.";
1193 return;
1194 }
1195 if (!voice_channel_->SetAudioSend(ssrc, enable, &options, source)) {
1196 LOG(LS_ERROR) << "SetAudioSend: ssrc is incorrect: " << ssrc;
1197 }
1198 }
1199
1200 void WebRtcSession::SetAudioPlayoutVolume(uint32_t ssrc, double volume) {
1201 ASSERT(signaling_thread()->IsCurrent());
1202 ASSERT(volume >= 0 && volume <= 10);
1203 if (!voice_channel_) {
1204 LOG(LS_ERROR) << "SetAudioPlayoutVolume: No audio channel exists.";
1205 return;
1206 }
1207
1208 if (!voice_channel_->SetOutputVolume(ssrc, volume)) {
1209 ASSERT(false);
1210 }
1211 }
1212
1213 void WebRtcSession::SetRawAudioSink(uint32_t ssrc,
1214 std::unique_ptr<AudioSinkInterface> sink) {
1215 ASSERT(signaling_thread()->IsCurrent());
1216 if (!voice_channel_)
1217 return;
1218
1219 voice_channel_->SetRawAudioSink(ssrc, std::move(sink));
1220 }
1221
1222 RtpParameters WebRtcSession::GetAudioRtpSendParameters(uint32_t ssrc) const {
1223 ASSERT(signaling_thread()->IsCurrent());
1224 if (voice_channel_) {
1225 return voice_channel_->GetRtpSendParameters(ssrc);
1226 }
1227 return RtpParameters();
1228 }
1229
1230 bool WebRtcSession::SetAudioRtpSendParameters(uint32_t ssrc,
1231 const RtpParameters& parameters) {
1232 ASSERT(signaling_thread()->IsCurrent());
1233 if (!voice_channel_) {
1234 return false;
1235 }
1236 return voice_channel_->SetRtpSendParameters(ssrc, parameters);
1237 }
1238
1239 RtpParameters WebRtcSession::GetAudioRtpReceiveParameters(uint32_t ssrc) const {
1240 ASSERT(signaling_thread()->IsCurrent());
1241 if (voice_channel_) {
1242 return voice_channel_->GetRtpReceiveParameters(ssrc);
1243 }
1244 return RtpParameters();
1245 }
1246
1247 bool WebRtcSession::SetAudioRtpReceiveParameters(
1248 uint32_t ssrc,
1249 const RtpParameters& parameters) {
1250 ASSERT(signaling_thread()->IsCurrent());
1251 if (!voice_channel_) {
1252 return false;
1253 }
1254 return voice_channel_->SetRtpReceiveParameters(ssrc, parameters);
1255 }
1256
1257 void WebRtcSession::SetVideoPlayout(
1258 uint32_t ssrc,
1259 bool enable,
1260 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) {
1261 ASSERT(signaling_thread()->IsCurrent());
1262 if (!video_channel_) {
1263 LOG(LS_WARNING) << "SetVideoPlayout: No video channel exists.";
1264 return;
1265 }
1266 if (!video_channel_->SetSink(ssrc, enable ? sink : NULL)) {
1267 // Allow that SetSink fail if |sink| is NULL but assert otherwise.
1268 // This in the normal case when the underlying media channel has already
1269 // been deleted.
1270 ASSERT(sink == NULL);
1271 }
1272 }
1273
1274 void WebRtcSession::SetVideoSend(
1275 uint32_t ssrc,
1276 bool enable,
1277 const cricket::VideoOptions* options,
1278 rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
1279 ASSERT(signaling_thread()->IsCurrent());
1280 if (!video_channel_) {
1281 LOG(LS_WARNING) << "SetVideoSend: No video channel exists.";
1282 return;
1283 }
1284 if (!video_channel_->SetVideoSend(ssrc, enable, options, source)) {
1285 // Allow that MuteStream fail if |enable| is false and |source| is NULL but
1286 // assert otherwise. This in the normal case when the underlying media
1287 // channel has already been deleted.
1288 ASSERT(enable == false && source == nullptr);
1289 }
1290 }
1291
1292 RtpParameters WebRtcSession::GetVideoRtpSendParameters(uint32_t ssrc) const {
1293 ASSERT(signaling_thread()->IsCurrent());
1294 if (video_channel_) {
1295 return video_channel_->GetRtpSendParameters(ssrc);
1296 }
1297 return RtpParameters();
1298 }
1299
1300 bool WebRtcSession::SetVideoRtpSendParameters(uint32_t ssrc,
1301 const RtpParameters& parameters) {
1302 ASSERT(signaling_thread()->IsCurrent());
1303 if (!video_channel_) {
1304 return false;
1305 }
1306 return video_channel_->SetRtpSendParameters(ssrc, parameters);
1307 }
1308
1309 RtpParameters WebRtcSession::GetVideoRtpReceiveParameters(uint32_t ssrc) const {
1310 ASSERT(signaling_thread()->IsCurrent());
1311 if (video_channel_) {
1312 return video_channel_->GetRtpReceiveParameters(ssrc);
1313 }
1314 return RtpParameters();
1315 }
1316
1317 bool WebRtcSession::SetVideoRtpReceiveParameters(
1318 uint32_t ssrc,
1319 const RtpParameters& parameters) {
1320 ASSERT(signaling_thread()->IsCurrent());
1321 if (!video_channel_) {
1322 return false;
1323 }
1324 return video_channel_->SetRtpReceiveParameters(ssrc, parameters);
1325 }
1326
1327 bool WebRtcSession::CanInsertDtmf(const std::string& track_id) { 1172 bool WebRtcSession::CanInsertDtmf(const std::string& track_id) {
1328 ASSERT(signaling_thread()->IsCurrent()); 1173 ASSERT(signaling_thread()->IsCurrent());
1329 if (!voice_channel_) { 1174 if (!voice_channel_) {
1330 LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists."; 1175 LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists.";
1331 return false; 1176 return false;
1332 } 1177 }
1333 uint32_t send_ssrc = 0; 1178 uint32_t send_ssrc = 0;
1334 // The Dtmf is negotiated per channel not ssrc, so we only check if the ssrc 1179 // The Dtmf is negotiated per channel not ssrc, so we only check if the ssrc
1335 // exists. 1180 // exists.
1336 if (!local_desc_ || 1181 if (!local_desc_ ||
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 bundle_transport, create_rtcp_transport_channel, audio_options_)); 1605 bundle_transport, create_rtcp_transport_channel, audio_options_));
1761 if (!voice_channel_) { 1606 if (!voice_channel_) {
1762 return false; 1607 return false;
1763 } 1608 }
1764 if (require_rtcp_mux) { 1609 if (require_rtcp_mux) {
1765 voice_channel_->ActivateRtcpMux(); 1610 voice_channel_->ActivateRtcpMux();
1766 } 1611 }
1767 1612
1768 voice_channel_->SignalDtlsSetupFailure.connect( 1613 voice_channel_->SignalDtlsSetupFailure.connect(
1769 this, &WebRtcSession::OnDtlsSetupFailure); 1614 this, &WebRtcSession::OnDtlsSetupFailure);
1770 voice_channel_->SignalFirstPacketReceived.connect(
1771 this, &WebRtcSession::OnChannelFirstPacketReceived);
1772 1615
1773 SignalVoiceChannelCreated(); 1616 SignalVoiceChannelCreated();
1774 voice_channel_->SignalSentPacket.connect(this, 1617 voice_channel_->SignalSentPacket.connect(this,
1775 &WebRtcSession::OnSentPacket_w); 1618 &WebRtcSession::OnSentPacket_w);
1776 return true; 1619 return true;
1777 } 1620 }
1778 1621
1779 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, 1622 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content,
1780 const std::string* bundle_transport) { 1623 const std::string* bundle_transport) {
1781 bool require_rtcp_mux = 1624 bool require_rtcp_mux =
1782 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; 1625 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire;
1783 bool create_rtcp_transport_channel = !require_rtcp_mux; 1626 bool create_rtcp_transport_channel = !require_rtcp_mux;
1784 video_channel_.reset(channel_manager_->CreateVideoChannel( 1627 video_channel_.reset(channel_manager_->CreateVideoChannel(
1785 media_controller_, transport_controller_.get(), content->name, 1628 media_controller_, transport_controller_.get(), content->name,
1786 bundle_transport, create_rtcp_transport_channel, video_options_)); 1629 bundle_transport, create_rtcp_transport_channel, video_options_));
1787 if (!video_channel_) { 1630 if (!video_channel_) {
1788 return false; 1631 return false;
1789 } 1632 }
1790 if (require_rtcp_mux) { 1633 if (require_rtcp_mux) {
1791 video_channel_->ActivateRtcpMux(); 1634 video_channel_->ActivateRtcpMux();
1792 } 1635 }
1793 video_channel_->SignalDtlsSetupFailure.connect( 1636 video_channel_->SignalDtlsSetupFailure.connect(
1794 this, &WebRtcSession::OnDtlsSetupFailure); 1637 this, &WebRtcSession::OnDtlsSetupFailure);
1795 video_channel_->SignalFirstPacketReceived.connect(
1796 this, &WebRtcSession::OnChannelFirstPacketReceived);
1797 1638
1798 SignalVideoChannelCreated(); 1639 SignalVideoChannelCreated();
1799 video_channel_->SignalSentPacket.connect(this, 1640 video_channel_->SignalSentPacket.connect(this,
1800 &WebRtcSession::OnSentPacket_w); 1641 &WebRtcSession::OnSentPacket_w);
1801 return true; 1642 return true;
1802 } 1643 }
1803 1644
1804 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, 1645 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content,
1805 const std::string* bundle_transport) { 1646 const std::string* bundle_transport) {
1806 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); 1647 bool sctp = (data_channel_type_ == cricket::DCT_SCTP);
(...skipping 21 matching lines...) Expand all
1828 SignalDataChannelCreated(); 1669 SignalDataChannelCreated();
1829 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); 1670 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w);
1830 return true; 1671 return true;
1831 } 1672 }
1832 1673
1833 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { 1674 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) {
1834 SetError(ERROR_TRANSPORT, 1675 SetError(ERROR_TRANSPORT,
1835 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); 1676 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp);
1836 } 1677 }
1837 1678
1838 void WebRtcSession::OnChannelFirstPacketReceived(
1839 cricket::BaseChannel* channel) {
1840 ASSERT(signaling_thread()->IsCurrent());
1841
1842 if (!received_first_audio_packet_ &&
1843 channel->media_type() == cricket::MEDIA_TYPE_AUDIO) {
1844 received_first_audio_packet_ = true;
1845 SignalFirstAudioPacketReceived();
1846 } else if (!received_first_video_packet_ &&
1847 channel->media_type() == cricket::MEDIA_TYPE_VIDEO) {
1848 received_first_video_packet_ = true;
1849 SignalFirstVideoPacketReceived();
1850 }
1851 }
1852
1853 void WebRtcSession::OnDataChannelMessageReceived( 1679 void WebRtcSession::OnDataChannelMessageReceived(
1854 cricket::DataChannel* channel, 1680 cricket::DataChannel* channel,
1855 const cricket::ReceiveDataParams& params, 1681 const cricket::ReceiveDataParams& params,
1856 const rtc::CopyOnWriteBuffer& payload) { 1682 const rtc::CopyOnWriteBuffer& payload) {
1857 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP); 1683 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP);
1858 if (params.type == cricket::DMT_CONTROL && IsOpenMessage(payload)) { 1684 if (params.type == cricket::DMT_CONTROL && IsOpenMessage(payload)) {
1859 // Received OPEN message; parse and signal that a new data channel should 1685 // Received OPEN message; parse and signal that a new data channel should
1860 // be created. 1686 // be created.
1861 std::string label; 1687 std::string label;
1862 InternalDataChannelInit config; 1688 InternalDataChannelInit config;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 ssl_cipher_suite); 1987 ssl_cipher_suite);
2162 } 1988 }
2163 } 1989 }
2164 1990
2165 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { 1991 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) {
2166 RTC_DCHECK(worker_thread()->IsCurrent()); 1992 RTC_DCHECK(worker_thread()->IsCurrent());
2167 media_controller_->call_w()->OnSentPacket(sent_packet); 1993 media_controller_->call_w()->OnSentPacket(sent_packet);
2168 } 1994 }
2169 1995
2170 } // namespace webrtc 1996 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/api/webrtcsession_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698