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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 ret.push_back(receiver.get()); | 1007 ret.push_back(receiver.get()); |
1008 } | 1008 } |
1009 return ret; | 1009 return ret; |
1010 } | 1010 } |
1011 | 1011 |
1012 bool PeerConnection::GetStats(StatsObserver* observer, | 1012 bool PeerConnection::GetStats(StatsObserver* observer, |
1013 MediaStreamTrackInterface* track, | 1013 MediaStreamTrackInterface* track, |
1014 StatsOutputLevel level) { | 1014 StatsOutputLevel level) { |
1015 TRACE_EVENT0("webrtc", "PeerConnection::GetStats"); | 1015 TRACE_EVENT0("webrtc", "PeerConnection::GetStats"); |
1016 RTC_DCHECK(signaling_thread()->IsCurrent()); | 1016 RTC_DCHECK(signaling_thread()->IsCurrent()); |
1017 if (!VERIFY(observer != NULL)) { | 1017 if (!observer) { |
1018 LOG(LS_ERROR) << "GetStats - observer is NULL."; | 1018 LOG(LS_ERROR) << "GetStats - observer is NULL."; |
1019 return false; | 1019 return false; |
1020 } | 1020 } |
1021 | 1021 |
1022 stats_->UpdateStats(level); | 1022 stats_->UpdateStats(level); |
1023 // The StatsCollector is used to tell if a track is valid because it may | 1023 // The StatsCollector is used to tell if a track is valid because it may |
1024 // remember tracks that the PeerConnection previously removed. | 1024 // remember tracks that the PeerConnection previously removed. |
1025 if (track && !stats_->IsValidTrack(track->id())) { | 1025 if (track && !stats_->IsValidTrack(track->id())) { |
1026 LOG(LS_WARNING) << "GetStats is called with an invalid track: " | 1026 LOG(LS_WARNING) << "GetStats is called with an invalid track: " |
1027 << track->id(); | 1027 << track->id(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) { | 1090 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) { |
1091 observer_->OnRenegotiationNeeded(); | 1091 observer_->OnRenegotiationNeeded(); |
1092 } | 1092 } |
1093 | 1093 |
1094 return DataChannelProxy::Create(signaling_thread(), channel.get()); | 1094 return DataChannelProxy::Create(signaling_thread(), channel.get()); |
1095 } | 1095 } |
1096 | 1096 |
1097 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, | 1097 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, |
1098 const MediaConstraintsInterface* constraints) { | 1098 const MediaConstraintsInterface* constraints) { |
1099 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); | 1099 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); |
1100 if (!VERIFY(observer != nullptr)) { | 1100 if (!observer) { |
1101 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; | 1101 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; |
1102 return; | 1102 return; |
1103 } | 1103 } |
1104 RTCOfferAnswerOptions options; | 1104 RTCOfferAnswerOptions options; |
1105 | 1105 |
1106 bool value; | 1106 bool value; |
1107 size_t mandatory_constraints = 0; | 1107 size_t mandatory_constraints = 0; |
1108 | 1108 |
1109 if (FindConstraint(constraints, | 1109 if (FindConstraint(constraints, |
1110 MediaConstraintsInterface::kOfferToReceiveAudio, | 1110 MediaConstraintsInterface::kOfferToReceiveAudio, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 &mandatory_constraints)) { | 1142 &mandatory_constraints)) { |
1143 options.use_rtp_mux = value; | 1143 options.use_rtp_mux = value; |
1144 } | 1144 } |
1145 | 1145 |
1146 CreateOffer(observer, options); | 1146 CreateOffer(observer, options); |
1147 } | 1147 } |
1148 | 1148 |
1149 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, | 1149 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, |
1150 const RTCOfferAnswerOptions& options) { | 1150 const RTCOfferAnswerOptions& options) { |
1151 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); | 1151 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); |
1152 if (!VERIFY(observer != nullptr)) { | 1152 if (!observer) { |
1153 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; | 1153 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; |
1154 return; | 1154 return; |
1155 } | 1155 } |
1156 | 1156 |
1157 cricket::MediaSessionOptions session_options; | 1157 cricket::MediaSessionOptions session_options; |
1158 if (!GetOptionsForOffer(options, &session_options)) { | 1158 if (!GetOptionsForOffer(options, &session_options)) { |
1159 std::string error = "CreateOffer called with invalid options."; | 1159 std::string error = "CreateOffer called with invalid options."; |
1160 LOG(LS_ERROR) << error; | 1160 LOG(LS_ERROR) << error; |
1161 PostCreateSessionDescriptionFailure(observer, error); | 1161 PostCreateSessionDescriptionFailure(observer, error); |
1162 return; | 1162 return; |
1163 } | 1163 } |
1164 | 1164 |
1165 session_->CreateOffer(observer, options, session_options); | 1165 session_->CreateOffer(observer, options, session_options); |
1166 } | 1166 } |
1167 | 1167 |
1168 void PeerConnection::CreateAnswer( | 1168 void PeerConnection::CreateAnswer( |
1169 CreateSessionDescriptionObserver* observer, | 1169 CreateSessionDescriptionObserver* observer, |
1170 const MediaConstraintsInterface* constraints) { | 1170 const MediaConstraintsInterface* constraints) { |
1171 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); | 1171 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); |
1172 if (!VERIFY(observer != nullptr)) { | 1172 if (!observer) { |
1173 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; | 1173 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; |
1174 return; | 1174 return; |
1175 } | 1175 } |
1176 | 1176 |
1177 cricket::MediaSessionOptions session_options; | 1177 cricket::MediaSessionOptions session_options; |
1178 if (!GetOptionsForAnswer(constraints, &session_options)) { | 1178 if (!GetOptionsForAnswer(constraints, &session_options)) { |
1179 std::string error = "CreateAnswer called with invalid constraints."; | 1179 std::string error = "CreateAnswer called with invalid constraints."; |
1180 LOG(LS_ERROR) << error; | 1180 LOG(LS_ERROR) << error; |
1181 PostCreateSessionDescriptionFailure(observer, error); | 1181 PostCreateSessionDescriptionFailure(observer, error); |
1182 return; | 1182 return; |
1183 } | 1183 } |
1184 | 1184 |
1185 session_->CreateAnswer(observer, session_options); | 1185 session_->CreateAnswer(observer, session_options); |
1186 } | 1186 } |
1187 | 1187 |
1188 void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer, | 1188 void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer, |
1189 const RTCOfferAnswerOptions& options) { | 1189 const RTCOfferAnswerOptions& options) { |
1190 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); | 1190 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); |
1191 if (!VERIFY(observer != nullptr)) { | 1191 if (!observer) { |
1192 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; | 1192 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; |
1193 return; | 1193 return; |
1194 } | 1194 } |
1195 | 1195 |
1196 cricket::MediaSessionOptions session_options; | 1196 cricket::MediaSessionOptions session_options; |
1197 if (!GetOptionsForAnswer(options, &session_options)) { | 1197 if (!GetOptionsForAnswer(options, &session_options)) { |
1198 std::string error = "CreateAnswer called with invalid options."; | 1198 std::string error = "CreateAnswer called with invalid options."; |
1199 LOG(LS_ERROR) << error; | 1199 LOG(LS_ERROR) << error; |
1200 PostCreateSessionDescriptionFailure(observer, error); | 1200 PostCreateSessionDescriptionFailure(observer, error); |
1201 return; | 1201 return; |
1202 } | 1202 } |
1203 | 1203 |
1204 session_->CreateAnswer(observer, session_options); | 1204 session_->CreateAnswer(observer, session_options); |
1205 } | 1205 } |
1206 | 1206 |
1207 void PeerConnection::SetLocalDescription( | 1207 void PeerConnection::SetLocalDescription( |
1208 SetSessionDescriptionObserver* observer, | 1208 SetSessionDescriptionObserver* observer, |
1209 SessionDescriptionInterface* desc) { | 1209 SessionDescriptionInterface* desc) { |
1210 TRACE_EVENT0("webrtc", "PeerConnection::SetLocalDescription"); | 1210 TRACE_EVENT0("webrtc", "PeerConnection::SetLocalDescription"); |
1211 if (IsClosed()) { | 1211 if (IsClosed()) { |
1212 return; | 1212 return; |
1213 } | 1213 } |
1214 if (!VERIFY(observer != nullptr)) { | 1214 if (!observer) { |
1215 LOG(LS_ERROR) << "SetLocalDescription - observer is NULL."; | 1215 LOG(LS_ERROR) << "SetLocalDescription - observer is NULL."; |
1216 return; | 1216 return; |
1217 } | 1217 } |
1218 if (!desc) { | 1218 if (!desc) { |
1219 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); | 1219 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); |
1220 return; | 1220 return; |
1221 } | 1221 } |
1222 // Update stats here so that we have the most recent stats for tracks and | 1222 // Update stats here so that we have the most recent stats for tracks and |
1223 // streams that might be removed by updating the session description. | 1223 // streams that might be removed by updating the session description. |
1224 stats_->UpdateStats(kStatsOutputLevelStandard); | 1224 stats_->UpdateStats(kStatsOutputLevelStandard); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 session_->MaybeStartGathering(); | 1286 session_->MaybeStartGathering(); |
1287 } | 1287 } |
1288 | 1288 |
1289 void PeerConnection::SetRemoteDescription( | 1289 void PeerConnection::SetRemoteDescription( |
1290 SetSessionDescriptionObserver* observer, | 1290 SetSessionDescriptionObserver* observer, |
1291 SessionDescriptionInterface* desc) { | 1291 SessionDescriptionInterface* desc) { |
1292 TRACE_EVENT0("webrtc", "PeerConnection::SetRemoteDescription"); | 1292 TRACE_EVENT0("webrtc", "PeerConnection::SetRemoteDescription"); |
1293 if (IsClosed()) { | 1293 if (IsClosed()) { |
1294 return; | 1294 return; |
1295 } | 1295 } |
1296 if (!VERIFY(observer != nullptr)) { | 1296 if (!observer) { |
1297 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; | 1297 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; |
1298 return; | 1298 return; |
1299 } | 1299 } |
1300 if (!desc) { | 1300 if (!desc) { |
1301 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); | 1301 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); |
1302 return; | 1302 return; |
1303 } | 1303 } |
1304 // Update stats here so that we have the most recent stats for tracks and | 1304 // Update stats here so that we have the most recent stats for tracks and |
1305 // streams that might be removed by updating the session description. | 1305 // streams that might be removed by updating the session description. |
1306 stats_->UpdateStats(kStatsOutputLevelStandard); | 1306 stats_->UpdateStats(kStatsOutputLevelStandard); |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 | 2183 |
2184 // Find new and active data channels. | 2184 // Find new and active data channels. |
2185 for (const cricket::StreamParams& params : streams) { | 2185 for (const cricket::StreamParams& params : streams) { |
2186 // |it->sync_label| is actually the data channel label. The reason is that | 2186 // |it->sync_label| is actually the data channel label. The reason is that |
2187 // we use the same naming of data channels as we do for | 2187 // we use the same naming of data channels as we do for |
2188 // MediaStreams and Tracks. | 2188 // MediaStreams and Tracks. |
2189 // For MediaStreams, the sync_label is the MediaStream label and the | 2189 // For MediaStreams, the sync_label is the MediaStream label and the |
2190 // track label is the same as |streamid|. | 2190 // track label is the same as |streamid|. |
2191 const std::string& channel_label = params.sync_label; | 2191 const std::string& channel_label = params.sync_label; |
2192 auto data_channel_it = rtp_data_channels_.find(channel_label); | 2192 auto data_channel_it = rtp_data_channels_.find(channel_label); |
2193 if (!VERIFY(data_channel_it != rtp_data_channels_.end())) { | 2193 if (data_channel_it == rtp_data_channels_.end()) { |
| 2194 LOG(LS_ERROR) << "channel label not found"; |
2194 continue; | 2195 continue; |
2195 } | 2196 } |
2196 // Set the SSRC the data channel should use for sending. | 2197 // Set the SSRC the data channel should use for sending. |
2197 data_channel_it->second->SetSendSsrc(params.first_ssrc()); | 2198 data_channel_it->second->SetSendSsrc(params.first_ssrc()); |
2198 existing_channels.push_back(data_channel_it->first); | 2199 existing_channels.push_back(data_channel_it->first); |
2199 } | 2200 } |
2200 | 2201 |
2201 UpdateClosingRtpDataChannels(existing_channels, true); | 2202 UpdateClosingRtpDataChannels(existing_channels, true); |
2202 } | 2203 } |
2203 | 2204 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 | 2566 |
2566 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, | 2567 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, |
2567 int64_t max_size_bytes) { | 2568 int64_t max_size_bytes) { |
2568 return event_log_->StartLogging(file, max_size_bytes); | 2569 return event_log_->StartLogging(file, max_size_bytes); |
2569 } | 2570 } |
2570 | 2571 |
2571 void PeerConnection::StopRtcEventLog_w() { | 2572 void PeerConnection::StopRtcEventLog_w() { |
2572 event_log_->StopLogging(); | 2573 event_log_->StopLogging(); |
2573 } | 2574 } |
2574 } // namespace webrtc | 2575 } // namespace webrtc |
OLD | NEW |