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/user_media_client_impl.h" | 5 #include "content/renderer/media/user_media_client_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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 DVLOG(1) << "UserMediaClientImpl::OnStreamGenerationFailed(" | 492 DVLOG(1) << "UserMediaClientImpl::OnStreamGenerationFailed(" |
493 << request_id << ")"; | 493 << request_id << ")"; |
494 UserMediaRequestInfo* request_info = FindUserMediaRequestInfo(request_id); | 494 UserMediaRequestInfo* request_info = FindUserMediaRequestInfo(request_id); |
495 if (!request_info) { | 495 if (!request_info) { |
496 // This can happen if the request is canceled or the frame reloads while | 496 // This can happen if the request is canceled or the frame reloads while |
497 // MediaStreamDispatcher is processing the request. | 497 // MediaStreamDispatcher is processing the request. |
498 DVLOG(1) << "Request ID not found"; | 498 DVLOG(1) << "Request ID not found"; |
499 return; | 499 return; |
500 } | 500 } |
501 | 501 |
502 GetUserMediaRequestFailed(&request_info->request, result); | 502 GetUserMediaRequestFailed(&request_info->request, result, ""); |
503 DeleteUserMediaRequestInfo(request_info); | 503 DeleteUserMediaRequestInfo(request_info); |
504 } | 504 } |
505 | 505 |
506 // Callback from MediaStreamDispatcher. | 506 // Callback from MediaStreamDispatcher. |
507 // The browser process has stopped a device used by a MediaStream. | 507 // The browser process has stopped a device used by a MediaStream. |
508 void UserMediaClientImpl::OnDeviceStopped( | 508 void UserMediaClientImpl::OnDeviceStopped( |
509 const std::string& label, | 509 const std::string& label, |
510 const StreamDeviceInfo& device_info) { | 510 const StreamDeviceInfo& device_info) { |
511 DCHECK(CalledOnValidThread()); | 511 DCHECK(CalledOnValidThread()); |
512 DVLOG(1) << "UserMediaClientImpl::OnDeviceStopped(" | 512 DVLOG(1) << "UserMediaClientImpl::OnDeviceStopped(" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 void UserMediaClientImpl::OnCreateNativeTracksCompleted( | 647 void UserMediaClientImpl::OnCreateNativeTracksCompleted( |
648 UserMediaRequestInfo* request, | 648 UserMediaRequestInfo* request, |
649 MediaStreamRequestResult result, | 649 MediaStreamRequestResult result, |
650 const blink::WebString& result_name) { | 650 const blink::WebString& result_name) { |
651 DVLOG(1) << "UserMediaClientImpl::OnCreateNativeTracksComplete(" | 651 DVLOG(1) << "UserMediaClientImpl::OnCreateNativeTracksComplete(" |
652 << "{request_id = " << request->request_id << "} " | 652 << "{request_id = " << request->request_id << "} " |
653 << "{result = " << result << "})"; | 653 << "{result = " << result << "})"; |
654 if (result == content::MEDIA_DEVICE_OK) | 654 if (result == content::MEDIA_DEVICE_OK) |
655 GetUserMediaRequestSucceeded(request->web_stream, &request->request); | 655 GetUserMediaRequestSucceeded(request->web_stream, &request->request); |
656 else | 656 else |
657 GetUserMediaRequestTrackStartedFailed(&request->request, | 657 GetUserMediaRequestFailed(&request->request, result, result_name); |
658 result, | |
659 result_name); | |
660 | 658 |
661 DeleteUserMediaRequestInfo(request); | 659 DeleteUserMediaRequestInfo(request); |
662 } | 660 } |
663 | 661 |
664 void UserMediaClientImpl::OnDevicesEnumerated( | 662 void UserMediaClientImpl::OnDevicesEnumerated( |
665 int request_id, | 663 int request_id, |
666 const StreamDeviceInfoArray& device_array) { | 664 const StreamDeviceInfoArray& device_array) { |
667 DVLOG(1) << "UserMediaClientImpl::OnDevicesEnumerated(" << request_id << ")"; | 665 DVLOG(1) << "UserMediaClientImpl::OnDevicesEnumerated(" << request_id << ")"; |
668 | 666 |
669 MediaDevicesRequestInfo* request = FindMediaDevicesRequestInfo(request_id); | 667 MediaDevicesRequestInfo* request = FindMediaDevicesRequestInfo(request_id); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 void UserMediaClientImpl::GetUserMediaRequestSucceeded( | 715 void UserMediaClientImpl::GetUserMediaRequestSucceeded( |
718 const blink::WebMediaStream& stream, | 716 const blink::WebMediaStream& stream, |
719 blink::WebUserMediaRequest* request_info) { | 717 blink::WebUserMediaRequest* request_info) { |
720 DVLOG(1) << "UserMediaClientImpl::GetUserMediaRequestSucceeded"; | 718 DVLOG(1) << "UserMediaClientImpl::GetUserMediaRequestSucceeded"; |
721 LogUserMediaRequestResult(MEDIA_DEVICE_OK); | 719 LogUserMediaRequestResult(MEDIA_DEVICE_OK); |
722 request_info->requestSucceeded(stream); | 720 request_info->requestSucceeded(stream); |
723 } | 721 } |
724 | 722 |
725 void UserMediaClientImpl::GetUserMediaRequestFailed( | 723 void UserMediaClientImpl::GetUserMediaRequestFailed( |
726 blink::WebUserMediaRequest* request_info, | 724 blink::WebUserMediaRequest* request_info, |
727 MediaStreamRequestResult result) { | 725 MediaStreamRequestResult result, |
| 726 const blink::WebString& result_name) { |
728 LogUserMediaRequestResult(result); | 727 LogUserMediaRequestResult(result); |
729 switch (result) { | 728 switch (result) { |
730 case MEDIA_DEVICE_OK: | 729 case MEDIA_DEVICE_OK: |
| 730 case NUM_MEDIA_REQUEST_RESULTS: |
731 NOTREACHED(); | 731 NOTREACHED(); |
732 break; | 732 return; |
733 case MEDIA_DEVICE_PERMISSION_DENIED: | 733 case MEDIA_DEVICE_PERMISSION_DENIED: |
734 request_info->requestDenied(); | 734 request_info->requestDenied(); |
735 break; | 735 return; |
736 case MEDIA_DEVICE_PERMISSION_DISMISSED: | 736 case MEDIA_DEVICE_PERMISSION_DISMISSED: |
737 request_info->requestFailedUASpecific("PermissionDismissedError"); | 737 request_info->requestFailedUASpecific("PermissionDismissedError"); |
738 break; | 738 return; |
739 case MEDIA_DEVICE_INVALID_STATE: | 739 case MEDIA_DEVICE_INVALID_STATE: |
740 request_info->requestFailedUASpecific("InvalidStateError"); | 740 request_info->requestFailedUASpecific("InvalidStateError"); |
741 break; | 741 return; |
742 case MEDIA_DEVICE_NO_HARDWARE: | 742 case MEDIA_DEVICE_NO_HARDWARE: |
743 request_info->requestFailedUASpecific("DevicesNotFoundError"); | 743 request_info->requestFailedUASpecific("DevicesNotFoundError"); |
744 break; | 744 return; |
745 case MEDIA_DEVICE_INVALID_SECURITY_ORIGIN: | 745 case MEDIA_DEVICE_INVALID_SECURITY_ORIGIN: |
746 request_info->requestFailedUASpecific("InvalidSecurityOriginError"); | 746 request_info->requestFailedUASpecific("InvalidSecurityOriginError"); |
747 break; | 747 return; |
748 case MEDIA_DEVICE_TAB_CAPTURE_FAILURE: | 748 case MEDIA_DEVICE_TAB_CAPTURE_FAILURE: |
749 request_info->requestFailedUASpecific("TabCaptureError"); | 749 request_info->requestFailedUASpecific("TabCaptureError"); |
750 break; | 750 return; |
751 case MEDIA_DEVICE_SCREEN_CAPTURE_FAILURE: | 751 case MEDIA_DEVICE_SCREEN_CAPTURE_FAILURE: |
752 request_info->requestFailedUASpecific("ScreenCaptureError"); | 752 request_info->requestFailedUASpecific("ScreenCaptureError"); |
753 break; | 753 return; |
754 case MEDIA_DEVICE_CAPTURE_FAILURE: | 754 case MEDIA_DEVICE_CAPTURE_FAILURE: |
755 request_info->requestFailedUASpecific("DeviceCaptureError"); | 755 request_info->requestFailedUASpecific("DeviceCaptureError"); |
756 break; | 756 return; |
757 default: | |
758 NOTREACHED(); | |
759 request_info->requestFailed(); | |
760 break; | |
761 } | |
762 } | |
763 | |
764 void UserMediaClientImpl::GetUserMediaRequestTrackStartedFailed( | |
765 blink::WebUserMediaRequest* request_info, | |
766 MediaStreamRequestResult result, | |
767 const blink::WebString& result_name) { | |
768 switch (result) { | |
769 case MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED: | 757 case MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED: |
770 request_info->requestFailedConstraint(result_name); | 758 request_info->requestFailedConstraint(result_name); |
771 break; | 759 return; |
772 case MEDIA_DEVICE_TRACK_START_FAILURE: | 760 case MEDIA_DEVICE_TRACK_START_FAILURE: |
773 request_info->requestFailedUASpecific("TrackStartError"); | 761 request_info->requestFailedUASpecific("TrackStartError"); |
774 break; | 762 return; |
775 default: | 763 case MEDIA_DEVICE_NOT_SUPPORTED: |
776 NOTREACHED(); | 764 request_info->requestFailedUASpecific("MediaDeviceNotSupported"); |
777 request_info->requestFailed(); | 765 return; |
778 break; | 766 case MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN: |
| 767 request_info->requestFailedUASpecific("MediaDeviceFailedDueToShutdown"); |
| 768 return; |
779 } | 769 } |
| 770 NOTREACHED(); |
| 771 request_info->requestFailed(); |
780 } | 772 } |
781 | 773 |
782 void UserMediaClientImpl::EnumerateDevicesSucceded( | 774 void UserMediaClientImpl::EnumerateDevicesSucceded( |
783 blink::WebMediaDevicesRequest* request, | 775 blink::WebMediaDevicesRequest* request, |
784 blink::WebVector<blink::WebMediaDeviceInfo>& devices) { | 776 blink::WebVector<blink::WebMediaDeviceInfo>& devices) { |
785 request->requestSucceeded(devices); | 777 request->requestSucceeded(devices); |
786 } | 778 } |
787 | 779 |
788 void UserMediaClientImpl::EnumerateSourcesSucceded( | 780 void UserMediaClientImpl::EnumerateSourcesSucceded( |
789 blink::WebMediaStreamTrackSourcesRequest* request, | 781 blink::WebMediaStreamTrackSourcesRequest* request, |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 return; | 1054 return; |
1063 } | 1055 } |
1064 } | 1056 } |
1065 } | 1057 } |
1066 | 1058 |
1067 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { | 1059 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { |
1068 return !sources_waiting_for_callback_.empty(); | 1060 return !sources_waiting_for_callback_.empty(); |
1069 } | 1061 } |
1070 | 1062 |
1071 } // namespace content | 1063 } // namespace content |
OLD | NEW |