Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/media_stream_impl.h" | 5 #include "content/renderer/media/media_stream_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 WebRtcLogMessage(base::StringPrintf( | 173 WebRtcLogMessage(base::StringPrintf( |
| 174 "MSI::requestUserMedia. request_id=%d" | 174 "MSI::requestUserMedia. request_id=%d" |
| 175 ", audio source id=%s mandatory= %s " | 175 ", audio source id=%s mandatory= %s " |
| 176 ", video source id=%s mandatory= %s", | 176 ", video source id=%s mandatory= %s", |
| 177 request_id, | 177 request_id, |
| 178 audio_device_id.c_str(), | 178 audio_device_id.c_str(), |
| 179 mandatory_audio ? "true":"false", | 179 mandatory_audio ? "true":"false", |
| 180 video_device_id.c_str(), | 180 video_device_id.c_str(), |
| 181 mandatory_video ? "true":"false")); | 181 mandatory_video ? "true":"false")); |
| 182 | 182 |
| 183 LogUserMediaRequestEvent(USERMEDIAREQUEST_CREATED); | |
| 183 user_media_requests_.push_back( | 184 user_media_requests_.push_back( |
| 184 new UserMediaRequestInfo(request_id, user_media_request, | 185 new UserMediaRequestInfo(request_id, user_media_request, |
| 185 enable_automatic_output_device_selection)); | 186 enable_automatic_output_device_selection)); |
| 186 | 187 |
| 187 media_stream_dispatcher_->GenerateStream( | 188 media_stream_dispatcher_->GenerateStream( |
| 188 request_id, | 189 request_id, |
| 189 weak_factory_.GetWeakPtr(), | 190 weak_factory_.GetWeakPtr(), |
| 190 options, | 191 options, |
| 191 security_origin); | 192 security_origin); |
| 192 } | 193 } |
| 193 | 194 |
| 194 void MediaStreamImpl::cancelUserMediaRequest( | 195 void MediaStreamImpl::cancelUserMediaRequest( |
| 195 const blink::WebUserMediaRequest& user_media_request) { | 196 const blink::WebUserMediaRequest& user_media_request) { |
| 196 DCHECK(CalledOnValidThread()); | 197 DCHECK(CalledOnValidThread()); |
| 197 UserMediaRequestInfo* request = FindUserMediaRequestInfo(user_media_request); | 198 UserMediaRequestInfo* request = FindUserMediaRequestInfo(user_media_request); |
| 198 if (request) { | 199 if (request) { |
| 199 // We can't abort the stream generation process. | 200 // We can't abort the stream generation process. |
| 200 // Instead, erase the request. Once the stream is generated we will stop the | 201 // Instead, erase the request. Once the stream is generated we will stop the |
| 201 // stream if the request does not exist. | 202 // stream if the request does not exist. |
| 203 LogUserMediaRequestEvent(USERMEDIAREQUEST_CANCELLED); | |
| 202 DeleteUserMediaRequestInfo(request); | 204 DeleteUserMediaRequestInfo(request); |
| 203 } | 205 } |
| 204 } | 206 } |
| 205 | 207 |
| 206 void MediaStreamImpl::requestMediaDevices( | 208 void MediaStreamImpl::requestMediaDevices( |
| 207 const blink::WebMediaDevicesRequest& media_devices_request) { | 209 const blink::WebMediaDevicesRequest& media_devices_request) { |
| 208 UpdateWebRTCMethodCount(WEBKIT_GET_MEDIA_DEVICES); | 210 UpdateWebRTCMethodCount(WEBKIT_GET_MEDIA_DEVICES); |
| 209 DCHECK(CalledOnValidThread()); | 211 DCHECK(CalledOnValidThread()); |
| 210 | 212 |
| 211 int audio_input_request_id = g_next_request_id++; | 213 int audio_input_request_id = g_next_request_id++; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 << request_id << ")"; | 344 << request_id << ")"; |
| 343 UserMediaRequestInfo* request_info = FindUserMediaRequestInfo(request_id); | 345 UserMediaRequestInfo* request_info = FindUserMediaRequestInfo(request_id); |
| 344 if (!request_info) { | 346 if (!request_info) { |
| 345 // This can happen if the request is canceled or the frame reloads while | 347 // This can happen if the request is canceled or the frame reloads while |
| 346 // MediaStreamDispatcher is processing the request. | 348 // MediaStreamDispatcher is processing the request. |
| 347 DVLOG(1) << "Request ID not found"; | 349 DVLOG(1) << "Request ID not found"; |
| 348 return; | 350 return; |
| 349 } | 351 } |
| 350 | 352 |
| 351 GetUserMediaRequestFailed(&request_info->request, result); | 353 GetUserMediaRequestFailed(&request_info->request, result); |
| 354 LogUserMediaRequestResult(result); | |
| 352 DeleteUserMediaRequestInfo(request_info); | 355 DeleteUserMediaRequestInfo(request_info); |
| 353 } | 356 } |
| 354 | 357 |
| 355 // Callback from MediaStreamDispatcher. | 358 // Callback from MediaStreamDispatcher. |
| 356 // The browser process has stopped a device used by a MediaStream. | 359 // The browser process has stopped a device used by a MediaStream. |
| 357 void MediaStreamImpl::OnDeviceStopped( | 360 void MediaStreamImpl::OnDeviceStopped( |
| 358 const std::string& label, | 361 const std::string& label, |
| 359 const StreamDeviceInfo& device_info) { | 362 const StreamDeviceInfo& device_info) { |
| 360 DCHECK(CalledOnValidThread()); | 363 DCHECK(CalledOnValidThread()); |
| 361 DVLOG(1) << "MediaStreamImpl::OnDeviceStopped(" | 364 DVLOG(1) << "MediaStreamImpl::OnDeviceStopped(" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 UserMediaRequestInfo* request, | 499 UserMediaRequestInfo* request, |
| 497 content::MediaStreamRequestResult result) { | 500 content::MediaStreamRequestResult result) { |
| 498 DVLOG(1) << "MediaStreamImpl::OnCreateNativeTracksComplete(" | 501 DVLOG(1) << "MediaStreamImpl::OnCreateNativeTracksComplete(" |
| 499 << "{request_id = " << request->request_id << "} " | 502 << "{request_id = " << request->request_id << "} " |
| 500 << "{result = " << result << "})"; | 503 << "{result = " << result << "})"; |
| 501 if (result == content::MEDIA_DEVICE_OK) | 504 if (result == content::MEDIA_DEVICE_OK) |
| 502 GetUserMediaRequestSucceeded(request->web_stream, &request->request); | 505 GetUserMediaRequestSucceeded(request->web_stream, &request->request); |
| 503 else | 506 else |
| 504 GetUserMediaRequestFailed(&request->request, result); | 507 GetUserMediaRequestFailed(&request->request, result); |
| 505 | 508 |
| 509 LogUserMediaRequestResult(result); | |
| 506 DeleteUserMediaRequestInfo(request); | 510 DeleteUserMediaRequestInfo(request); |
| 507 } | 511 } |
| 508 | 512 |
| 509 void MediaStreamImpl::OnDevicesEnumerated( | 513 void MediaStreamImpl::OnDevicesEnumerated( |
| 510 int request_id, | 514 int request_id, |
| 511 const StreamDeviceInfoArray& device_array) { | 515 const StreamDeviceInfoArray& device_array) { |
| 512 DVLOG(1) << "MediaStreamImpl::OnDevicesEnumerated(" << request_id << ")"; | 516 DVLOG(1) << "MediaStreamImpl::OnDevicesEnumerated(" << request_id << ")"; |
| 513 | 517 |
| 514 MediaDevicesRequestInfo* request = FindMediaDevicesRequestInfo(request_id); | 518 MediaDevicesRequestInfo* request = FindMediaDevicesRequestInfo(request_id); |
| 515 DCHECK(request); | 519 DCHECK(request); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 DVLOG(1) << "MediaStreamImpl@" << this << "::FrameWillClose: " | 755 DVLOG(1) << "MediaStreamImpl@" << this << "::FrameWillClose: " |
| 752 << "Cancel user media request " << (*request_it)->request_id; | 756 << "Cancel user media request " << (*request_it)->request_id; |
| 753 // If the request is not generated, it means that a request | 757 // If the request is not generated, it means that a request |
| 754 // has been sent to the MediaStreamDispatcher to generate a stream | 758 // has been sent to the MediaStreamDispatcher to generate a stream |
| 755 // but MediaStreamDispatcher has not yet responded and we need to cancel | 759 // but MediaStreamDispatcher has not yet responded and we need to cancel |
| 756 // the request. | 760 // the request. |
| 757 if (!(*request_it)->generated) { | 761 if (!(*request_it)->generated) { |
| 758 media_stream_dispatcher_->CancelGenerateStream( | 762 media_stream_dispatcher_->CancelGenerateStream( |
| 759 (*request_it)->request_id, weak_factory_.GetWeakPtr()); | 763 (*request_it)->request_id, weak_factory_.GetWeakPtr()); |
| 760 } | 764 } |
| 765 LogUserMediaRequestEvent(USERMEDIAREQUEST_NO_RESPONSE); | |
|
vrk (LEFT CHROMIUM)
2014/08/04 18:22:17
There are a few different "no response" events tha
| |
| 761 request_it = user_media_requests_.erase(request_it); | 766 request_it = user_media_requests_.erase(request_it); |
| 762 } | 767 } |
| 763 | 768 |
| 764 // Loop through all current local sources and stop the sources. | 769 // Loop through all current local sources and stop the sources. |
| 765 LocalStreamSources::iterator sources_it = local_sources_.begin(); | 770 LocalStreamSources::iterator sources_it = local_sources_.begin(); |
| 766 while (sources_it != local_sources_.end()) { | 771 while (sources_it != local_sources_.end()) { |
| 767 StopLocalSource(*sources_it, true); | 772 StopLocalSource(*sources_it, true); |
| 768 sources_it = local_sources_.erase(sources_it); | 773 sources_it = local_sources_.erase(sources_it); |
| 769 } | 774 } |
| 770 } | 775 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 902 sources_.begin(); | 907 sources_.begin(); |
| 903 it != sources_.end(); ++it) { | 908 it != sources_.end(); ++it) { |
| 904 if (source.id() == it->id()) { | 909 if (source.id() == it->id()) { |
| 905 sources_.erase(it); | 910 sources_.erase(it); |
| 906 return; | 911 return; |
| 907 } | 912 } |
| 908 } | 913 } |
| 909 } | 914 } |
| 910 | 915 |
| 911 } // namespace content | 916 } // namespace content |
| OLD | NEW |