OLD | NEW |
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 Loading... |
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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 ssl_cipher_suite); | 1987 ssl_cipher_suite); |
2143 } | 1988 } |
2144 } | 1989 } |
2145 | 1990 |
2146 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { | 1991 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { |
2147 RTC_DCHECK(worker_thread()->IsCurrent()); | 1992 RTC_DCHECK(worker_thread()->IsCurrent()); |
2148 media_controller_->call_w()->OnSentPacket(sent_packet); | 1993 media_controller_->call_w()->OnSentPacket(sent_packet); |
2149 } | 1994 } |
2150 | 1995 |
2151 } // namespace webrtc | 1996 } // namespace webrtc |
OLD | NEW |