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 RTC_DCHECK(observer != nullptr); |
kwiberg-webrtc
2017/01/30 10:12:49
RTC_DCHECK_NE? Or will that not compile?
(You cou
nisse-webrtc
2017/01/30 10:58:41
It fails to compile, with errors related to << and
| |
1018 LOG(LS_ERROR) << "GetStats - observer is NULL."; | |
1019 return false; | |
1020 } | |
1021 | 1018 |
1022 stats_->UpdateStats(level); | 1019 stats_->UpdateStats(level); |
1023 // The StatsCollector is used to tell if a track is valid because it may | 1020 // The StatsCollector is used to tell if a track is valid because it may |
1024 // remember tracks that the PeerConnection previously removed. | 1021 // remember tracks that the PeerConnection previously removed. |
1025 if (track && !stats_->IsValidTrack(track->id())) { | 1022 if (track && !stats_->IsValidTrack(track->id())) { |
1026 LOG(LS_WARNING) << "GetStats is called with an invalid track: " | 1023 LOG(LS_WARNING) << "GetStats is called with an invalid track: " |
1027 << track->id(); | 1024 << track->id(); |
1028 return false; | 1025 return false; |
1029 } | 1026 } |
1030 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_GETSTATS, | 1027 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_GETSTATS, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) { | 1087 if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) { |
1091 observer_->OnRenegotiationNeeded(); | 1088 observer_->OnRenegotiationNeeded(); |
1092 } | 1089 } |
1093 | 1090 |
1094 return DataChannelProxy::Create(signaling_thread(), channel.get()); | 1091 return DataChannelProxy::Create(signaling_thread(), channel.get()); |
1095 } | 1092 } |
1096 | 1093 |
1097 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, | 1094 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, |
1098 const MediaConstraintsInterface* constraints) { | 1095 const MediaConstraintsInterface* constraints) { |
1099 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); | 1096 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); |
1100 if (!VERIFY(observer != nullptr)) { | 1097 RTC_DCHECK(observer != nullptr); |
1101 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; | |
1102 return; | |
1103 } | |
1104 RTCOfferAnswerOptions options; | 1098 RTCOfferAnswerOptions options; |
1105 | 1099 |
1106 bool value; | 1100 bool value; |
1107 size_t mandatory_constraints = 0; | 1101 size_t mandatory_constraints = 0; |
1108 | 1102 |
1109 if (FindConstraint(constraints, | 1103 if (FindConstraint(constraints, |
1110 MediaConstraintsInterface::kOfferToReceiveAudio, | 1104 MediaConstraintsInterface::kOfferToReceiveAudio, |
1111 &value, | 1105 &value, |
1112 &mandatory_constraints)) { | 1106 &mandatory_constraints)) { |
1113 options.offer_to_receive_audio = | 1107 options.offer_to_receive_audio = |
(...skipping 28 matching lines...) Expand all Loading... | |
1142 &mandatory_constraints)) { | 1136 &mandatory_constraints)) { |
1143 options.use_rtp_mux = value; | 1137 options.use_rtp_mux = value; |
1144 } | 1138 } |
1145 | 1139 |
1146 CreateOffer(observer, options); | 1140 CreateOffer(observer, options); |
1147 } | 1141 } |
1148 | 1142 |
1149 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, | 1143 void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer, |
1150 const RTCOfferAnswerOptions& options) { | 1144 const RTCOfferAnswerOptions& options) { |
1151 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); | 1145 TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer"); |
1152 if (!VERIFY(observer != nullptr)) { | 1146 RTC_DCHECK(observer != nullptr); |
1153 LOG(LS_ERROR) << "CreateOffer - observer is NULL."; | |
1154 return; | |
1155 } | |
1156 | 1147 |
1157 cricket::MediaSessionOptions session_options; | 1148 cricket::MediaSessionOptions session_options; |
1158 if (!GetOptionsForOffer(options, &session_options)) { | 1149 if (!GetOptionsForOffer(options, &session_options)) { |
1159 std::string error = "CreateOffer called with invalid options."; | 1150 std::string error = "CreateOffer called with invalid options."; |
1160 LOG(LS_ERROR) << error; | 1151 LOG(LS_ERROR) << error; |
1161 PostCreateSessionDescriptionFailure(observer, error); | 1152 PostCreateSessionDescriptionFailure(observer, error); |
1162 return; | 1153 return; |
1163 } | 1154 } |
1164 | 1155 |
1165 session_->CreateOffer(observer, options, session_options); | 1156 session_->CreateOffer(observer, options, session_options); |
1166 } | 1157 } |
1167 | 1158 |
1168 void PeerConnection::CreateAnswer( | 1159 void PeerConnection::CreateAnswer( |
1169 CreateSessionDescriptionObserver* observer, | 1160 CreateSessionDescriptionObserver* observer, |
1170 const MediaConstraintsInterface* constraints) { | 1161 const MediaConstraintsInterface* constraints) { |
1171 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); | 1162 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); |
1172 if (!VERIFY(observer != nullptr)) { | 1163 RTC_DCHECK(observer != nullptr); |
1173 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; | |
1174 return; | |
1175 } | |
1176 | 1164 |
1177 cricket::MediaSessionOptions session_options; | 1165 cricket::MediaSessionOptions session_options; |
1178 if (!GetOptionsForAnswer(constraints, &session_options)) { | 1166 if (!GetOptionsForAnswer(constraints, &session_options)) { |
1179 std::string error = "CreateAnswer called with invalid constraints."; | 1167 std::string error = "CreateAnswer called with invalid constraints."; |
1180 LOG(LS_ERROR) << error; | 1168 LOG(LS_ERROR) << error; |
1181 PostCreateSessionDescriptionFailure(observer, error); | 1169 PostCreateSessionDescriptionFailure(observer, error); |
1182 return; | 1170 return; |
1183 } | 1171 } |
1184 | 1172 |
1185 session_->CreateAnswer(observer, session_options); | 1173 session_->CreateAnswer(observer, session_options); |
1186 } | 1174 } |
1187 | 1175 |
1188 void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer, | 1176 void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer, |
1189 const RTCOfferAnswerOptions& options) { | 1177 const RTCOfferAnswerOptions& options) { |
1190 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); | 1178 TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); |
1191 if (!VERIFY(observer != nullptr)) { | 1179 RTC_DCHECK(observer != nullptr); |
1192 LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; | |
1193 return; | |
1194 } | |
1195 | 1180 |
1196 cricket::MediaSessionOptions session_options; | 1181 cricket::MediaSessionOptions session_options; |
1197 if (!GetOptionsForAnswer(options, &session_options)) { | 1182 if (!GetOptionsForAnswer(options, &session_options)) { |
1198 std::string error = "CreateAnswer called with invalid options."; | 1183 std::string error = "CreateAnswer called with invalid options."; |
1199 LOG(LS_ERROR) << error; | 1184 LOG(LS_ERROR) << error; |
1200 PostCreateSessionDescriptionFailure(observer, error); | 1185 PostCreateSessionDescriptionFailure(observer, error); |
1201 return; | 1186 return; |
1202 } | 1187 } |
1203 | 1188 |
1204 session_->CreateAnswer(observer, session_options); | 1189 session_->CreateAnswer(observer, session_options); |
1205 } | 1190 } |
1206 | 1191 |
1207 void PeerConnection::SetLocalDescription( | 1192 void PeerConnection::SetLocalDescription( |
1208 SetSessionDescriptionObserver* observer, | 1193 SetSessionDescriptionObserver* observer, |
1209 SessionDescriptionInterface* desc) { | 1194 SessionDescriptionInterface* desc) { |
1210 TRACE_EVENT0("webrtc", "PeerConnection::SetLocalDescription"); | 1195 TRACE_EVENT0("webrtc", "PeerConnection::SetLocalDescription"); |
1211 if (IsClosed()) { | 1196 if (IsClosed()) { |
1212 return; | 1197 return; |
1213 } | 1198 } |
1214 if (!VERIFY(observer != nullptr)) { | 1199 RTC_DCHECK(observer != nullptr); |
1215 LOG(LS_ERROR) << "SetLocalDescription - observer is NULL."; | |
1216 return; | |
1217 } | |
1218 if (!desc) { | 1200 if (!desc) { |
1219 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); | 1201 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); |
1220 return; | 1202 return; |
1221 } | 1203 } |
1222 // Update stats here so that we have the most recent stats for tracks and | 1204 // 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. | 1205 // streams that might be removed by updating the session description. |
1224 stats_->UpdateStats(kStatsOutputLevelStandard); | 1206 stats_->UpdateStats(kStatsOutputLevelStandard); |
1225 std::string error; | 1207 std::string error; |
1226 if (!session_->SetLocalDescription(desc, &error)) { | 1208 if (!session_->SetLocalDescription(desc, &error)) { |
1227 PostSetSessionDescriptionFailure(observer, error); | 1209 PostSetSessionDescriptionFailure(observer, error); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1286 session_->MaybeStartGathering(); | 1268 session_->MaybeStartGathering(); |
1287 } | 1269 } |
1288 | 1270 |
1289 void PeerConnection::SetRemoteDescription( | 1271 void PeerConnection::SetRemoteDescription( |
1290 SetSessionDescriptionObserver* observer, | 1272 SetSessionDescriptionObserver* observer, |
1291 SessionDescriptionInterface* desc) { | 1273 SessionDescriptionInterface* desc) { |
1292 TRACE_EVENT0("webrtc", "PeerConnection::SetRemoteDescription"); | 1274 TRACE_EVENT0("webrtc", "PeerConnection::SetRemoteDescription"); |
1293 if (IsClosed()) { | 1275 if (IsClosed()) { |
1294 return; | 1276 return; |
1295 } | 1277 } |
1296 if (!VERIFY(observer != nullptr)) { | 1278 RTC_DCHECK(observer != nullptr); |
1297 LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL."; | |
1298 return; | |
1299 } | |
1300 if (!desc) { | 1279 if (!desc) { |
1301 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); | 1280 PostSetSessionDescriptionFailure(observer, "SessionDescription is NULL."); |
1302 return; | 1281 return; |
1303 } | 1282 } |
1304 // Update stats here so that we have the most recent stats for tracks and | 1283 // 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. | 1284 // streams that might be removed by updating the session description. |
1306 stats_->UpdateStats(kStatsOutputLevelStandard); | 1285 stats_->UpdateStats(kStatsOutputLevelStandard); |
1307 std::string error; | 1286 std::string error; |
1308 if (!session_->SetRemoteDescription(desc, &error)) { | 1287 if (!session_->SetRemoteDescription(desc, &error)) { |
1309 PostSetSessionDescriptionFailure(observer, error); | 1288 PostSetSessionDescriptionFailure(observer, error); |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2183 | 2162 |
2184 // Find new and active data channels. | 2163 // Find new and active data channels. |
2185 for (const cricket::StreamParams& params : streams) { | 2164 for (const cricket::StreamParams& params : streams) { |
2186 // |it->sync_label| is actually the data channel label. The reason is that | 2165 // |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 | 2166 // we use the same naming of data channels as we do for |
2188 // MediaStreams and Tracks. | 2167 // MediaStreams and Tracks. |
2189 // For MediaStreams, the sync_label is the MediaStream label and the | 2168 // For MediaStreams, the sync_label is the MediaStream label and the |
2190 // track label is the same as |streamid|. | 2169 // track label is the same as |streamid|. |
2191 const std::string& channel_label = params.sync_label; | 2170 const std::string& channel_label = params.sync_label; |
2192 auto data_channel_it = rtp_data_channels_.find(channel_label); | 2171 auto data_channel_it = rtp_data_channels_.find(channel_label); |
2193 if (!VERIFY(data_channel_it != rtp_data_channels_.end())) { | 2172 if (data_channel_it == rtp_data_channels_.end()) { |
2173 LOG(LS_ERROR) << "channel label not found"; | |
2194 continue; | 2174 continue; |
2195 } | 2175 } |
2196 // Set the SSRC the data channel should use for sending. | 2176 // Set the SSRC the data channel should use for sending. |
2197 data_channel_it->second->SetSendSsrc(params.first_ssrc()); | 2177 data_channel_it->second->SetSendSsrc(params.first_ssrc()); |
2198 existing_channels.push_back(data_channel_it->first); | 2178 existing_channels.push_back(data_channel_it->first); |
2199 } | 2179 } |
2200 | 2180 |
2201 UpdateClosingRtpDataChannels(existing_channels, true); | 2181 UpdateClosingRtpDataChannels(existing_channels, true); |
2202 } | 2182 } |
2203 | 2183 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2565 | 2545 |
2566 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, | 2546 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, |
2567 int64_t max_size_bytes) { | 2547 int64_t max_size_bytes) { |
2568 return event_log_->StartLogging(file, max_size_bytes); | 2548 return event_log_->StartLogging(file, max_size_bytes); |
2569 } | 2549 } |
2570 | 2550 |
2571 void PeerConnection::StopRtcEventLog_w() { | 2551 void PeerConnection::StopRtcEventLog_w() { |
2572 event_log_->StopLogging(); | 2552 event_log_->StopLogging(); |
2573 } | 2553 } |
2574 } // namespace webrtc | 2554 } // namespace webrtc |
OLD | NEW |