| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 UserMediaRequestInfo(int request_id, | 241 UserMediaRequestInfo(int request_id, |
| 242 const blink::WebUserMediaRequest& request, | 242 const blink::WebUserMediaRequest& request, |
| 243 bool is_processing_user_gesture, | 243 bool is_processing_user_gesture, |
| 244 const url::Origin& security_origin); | 244 const url::Origin& security_origin); |
| 245 | 245 |
| 246 void StartAudioTrack(const blink::WebMediaStreamTrack& track, | 246 void StartAudioTrack(const blink::WebMediaStreamTrack& track, |
| 247 bool is_pending); | 247 bool is_pending); |
| 248 | 248 |
| 249 blink::WebMediaStreamTrack CreateAndStartVideoTrack( | 249 blink::WebMediaStreamTrack CreateAndStartVideoTrack( |
| 250 const blink::WebMediaStreamSource& source, | 250 const blink::WebMediaStreamSource& source); |
| 251 const blink::WebMediaConstraints& constraints); | |
| 252 | 251 |
| 253 // Triggers |callback| when all sources used in this request have either | 252 // Triggers |callback| when all sources used in this request have either |
| 254 // successfully started, or a source has failed to start. | 253 // successfully started, or a source has failed to start. |
| 255 void CallbackOnTracksStarted(const ResourcesReady& callback); | 254 void CallbackOnTracksStarted(const ResourcesReady& callback); |
| 256 | 255 |
| 257 bool HasPendingSources() const; | 256 bool HasPendingSources() const; |
| 258 | 257 |
| 259 // Called when a local audio source has finished (or failed) initializing. | 258 // Called when a local audio source has finished (or failed) initializing. |
| 260 void OnAudioSourceStarted(MediaStreamSource* source, | 259 void OnAudioSourceStarted(MediaStreamSource* source, |
| 261 MediaStreamRequestResult result, | 260 MediaStreamRequestResult result, |
| 262 const blink::WebString& result_name); | 261 const blink::WebString& result_name); |
| 263 | 262 |
| 264 int request_id() const { return request_id_; } | 263 int request_id() const { return request_id_; } |
| 265 | 264 |
| 266 State state() const { return state_; } | 265 State state() const { return state_; } |
| 267 void set_state(State state) { state_ = state; } | 266 void set_state(State state) { state_ = state; } |
| 268 | 267 |
| 269 bool enable_automatic_output_device_selection() const { | 268 bool enable_automatic_output_device_selection() const { |
| 270 return enable_automatic_output_device_selection_; | 269 return enable_automatic_output_device_selection_; |
| 271 } | 270 } |
| 272 void set_enable_automatic_output_device_selection(bool value) { | 271 void set_enable_automatic_output_device_selection(bool value) { |
| 273 enable_automatic_output_device_selection_ = value; | 272 enable_automatic_output_device_selection_ = value; |
| 274 } | 273 } |
| 274 const VideoCaptureSettings& video_capture_settings() const { |
| 275 return video_capture_settings_; |
| 276 } |
| 277 void SetVideoCaptureSettings(const VideoCaptureSettings& settings, |
| 278 bool is_content_capture) { |
| 279 DCHECK(settings.HasValue()); |
| 280 is_video_content_capture_ = is_content_capture; |
| 281 video_capture_settings_ = settings; |
| 282 } |
| 275 | 283 |
| 276 blink::WebMediaStream* web_stream() { return &web_stream_; } | 284 blink::WebMediaStream* web_stream() { return &web_stream_; } |
| 277 | 285 |
| 278 const blink::WebUserMediaRequest& request() const { return request_; } | 286 const blink::WebUserMediaRequest& request() const { return request_; } |
| 279 | 287 |
| 280 StreamControls* stream_controls() { return &stream_controls_; } | 288 StreamControls* stream_controls() { return &stream_controls_; } |
| 281 | 289 |
| 282 bool is_processing_user_gesture() const { | 290 bool is_processing_user_gesture() const { |
| 283 return is_processing_user_gesture_; | 291 return is_processing_user_gesture_; |
| 284 } | 292 } |
| 285 | 293 |
| 286 const url::Origin& security_origin() const { return security_origin_; } | 294 const url::Origin& security_origin() const { return security_origin_; } |
| 287 | 295 |
| 288 private: | 296 private: |
| 289 void OnTrackStarted(MediaStreamSource* source, | 297 void OnTrackStarted(MediaStreamSource* source, |
| 290 MediaStreamRequestResult result, | 298 MediaStreamRequestResult result, |
| 291 const blink::WebString& result_name); | 299 const blink::WebString& result_name); |
| 292 | 300 |
| 293 // Cheks if the sources for all tracks have been started and if so, | 301 // Cheks if the sources for all tracks have been started and if so, |
| 294 // invoke the |ready_callback_|. Note that the caller should expect | 302 // invoke the |ready_callback_|. Note that the caller should expect |
| 295 // that |this| might be deleted when the function returns. | 303 // that |this| might be deleted when the function returns. |
| 296 void CheckAllTracksStarted(); | 304 void CheckAllTracksStarted(); |
| 297 | 305 |
| 298 const int request_id_; | 306 const int request_id_; |
| 299 State state_; | 307 State state_; |
| 300 bool enable_automatic_output_device_selection_; | 308 bool enable_automatic_output_device_selection_; |
| 309 VideoCaptureSettings video_capture_settings_; |
| 310 bool is_video_content_capture_; |
| 301 blink::WebMediaStream web_stream_; | 311 blink::WebMediaStream web_stream_; |
| 302 const blink::WebUserMediaRequest request_; | 312 const blink::WebUserMediaRequest request_; |
| 303 StreamControls stream_controls_; | 313 StreamControls stream_controls_; |
| 304 const bool is_processing_user_gesture_; | 314 const bool is_processing_user_gesture_; |
| 305 const url::Origin security_origin_; | 315 const url::Origin security_origin_; |
| 306 ResourcesReady ready_callback_; | 316 ResourcesReady ready_callback_; |
| 307 MediaStreamRequestResult request_result_; | 317 MediaStreamRequestResult request_result_; |
| 308 blink::WebString request_result_name_; | 318 blink::WebString request_result_name_; |
| 309 // Sources used in this request. | 319 // Sources used in this request. |
| 310 std::vector<blink::WebMediaStreamSource> sources_; | 320 std::vector<blink::WebMediaStreamSource> sources_; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 MediaStreamRequestResult result = | 516 MediaStreamRequestResult result = |
| 507 failed_constraint_name.isEmpty() | 517 failed_constraint_name.isEmpty() |
| 508 ? MEDIA_DEVICE_NO_HARDWARE | 518 ? MEDIA_DEVICE_NO_HARDWARE |
| 509 : MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED; | 519 : MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED; |
| 510 GetUserMediaRequestFailed(user_media_request, result, | 520 GetUserMediaRequestFailed(user_media_request, result, |
| 511 failed_constraint_name); | 521 failed_constraint_name); |
| 512 return; | 522 return; |
| 513 } | 523 } |
| 514 current_request_info_->stream_controls()->video.device_id = | 524 current_request_info_->stream_controls()->video.device_id = |
| 515 settings.device_id(); | 525 settings.device_id(); |
| 526 current_request_info_->SetVideoCaptureSettings( |
| 527 settings, false /* is_content_capture */); |
| 516 GenerateStreamForCurrentRequestInfo(); | 528 GenerateStreamForCurrentRequestInfo(); |
| 517 } | 529 } |
| 518 | 530 |
| 519 void UserMediaClientImpl::FinalizeSelectVideoContentSettings( | 531 void UserMediaClientImpl::FinalizeSelectVideoContentSettings( |
| 520 const blink::WebUserMediaRequest& user_media_request, | 532 const blink::WebUserMediaRequest& user_media_request, |
| 521 const VideoCaptureSettings& settings) { | 533 const VideoCaptureSettings& settings) { |
| 522 DCHECK(CalledOnValidThread()); | 534 DCHECK(CalledOnValidThread()); |
| 523 if (!IsCurrentRequestInfo(user_media_request)) | 535 if (!IsCurrentRequestInfo(user_media_request)) |
| 524 return; | 536 return; |
| 525 | 537 |
| 526 if (!settings.HasValue()) { | 538 if (!settings.HasValue()) { |
| 527 blink::WebString failed_constraint_name = | 539 blink::WebString failed_constraint_name = |
| 528 blink::WebString::fromASCII(settings.failed_constraint_name()); | 540 blink::WebString::fromASCII(settings.failed_constraint_name()); |
| 529 DCHECK(!failed_constraint_name.isEmpty()); | 541 DCHECK(!failed_constraint_name.isEmpty()); |
| 530 blink::WebString device_id_constraint_name = blink::WebString::fromASCII( | 542 blink::WebString device_id_constraint_name = blink::WebString::fromASCII( |
| 531 user_media_request.videoConstraints().basic().deviceId.name()); | 543 user_media_request.videoConstraints().basic().deviceId.name()); |
| 532 GetUserMediaRequestFailed(user_media_request, | 544 GetUserMediaRequestFailed(user_media_request, |
| 533 MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED, | 545 MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED, |
| 534 failed_constraint_name); | 546 failed_constraint_name); |
| 535 return; | 547 return; |
| 536 } | 548 } |
| 537 current_request_info_->stream_controls()->video.device_id = | 549 current_request_info_->stream_controls()->video.device_id = |
| 538 settings.device_id(); | 550 settings.device_id(); |
| 551 current_request_info_->SetVideoCaptureSettings(settings, |
| 552 true /* is_content_capture */); |
| 539 GenerateStreamForCurrentRequestInfo(); | 553 GenerateStreamForCurrentRequestInfo(); |
| 540 } | 554 } |
| 541 | 555 |
| 542 void UserMediaClientImpl::GenerateStreamForCurrentRequestInfo() { | 556 void UserMediaClientImpl::GenerateStreamForCurrentRequestInfo() { |
| 543 DCHECK(CalledOnValidThread()); | 557 DCHECK(CalledOnValidThread()); |
| 544 DCHECK(current_request_info_); | 558 DCHECK(current_request_info_); |
| 545 | 559 |
| 546 WebRtcLogMessage(base::StringPrintf( | 560 WebRtcLogMessage(base::StringPrintf( |
| 547 "MSI::requestUserMedia. request_id=%d" | 561 "MSI::requestUserMedia. request_id=%d" |
| 548 ", audio source id=%s" | 562 ", audio source id=%s" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 658 |
| 645 DCHECK(!current_request_info_->request().isNull()); | 659 DCHECK(!current_request_info_->request().isNull()); |
| 646 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector( | 660 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector( |
| 647 audio_array.size()); | 661 audio_array.size()); |
| 648 CreateAudioTracks(audio_array, | 662 CreateAudioTracks(audio_array, |
| 649 current_request_info_->request().audioConstraints(), | 663 current_request_info_->request().audioConstraints(), |
| 650 &audio_track_vector); | 664 &audio_track_vector); |
| 651 | 665 |
| 652 blink::WebVector<blink::WebMediaStreamTrack> video_track_vector( | 666 blink::WebVector<blink::WebMediaStreamTrack> video_track_vector( |
| 653 video_array.size()); | 667 video_array.size()); |
| 654 CreateVideoTracks(video_array, | 668 CreateVideoTracks(video_array, &video_track_vector); |
| 655 current_request_info_->request().videoConstraints(), | |
| 656 &video_track_vector); | |
| 657 | 669 |
| 658 blink::WebString blink_id = blink::WebString::fromUTF8(label); | 670 blink::WebString blink_id = blink::WebString::fromUTF8(label); |
| 659 current_request_info_->web_stream()->initialize(blink_id, audio_track_vector, | 671 current_request_info_->web_stream()->initialize(blink_id, audio_track_vector, |
| 660 video_track_vector); | 672 video_track_vector); |
| 661 current_request_info_->web_stream()->setExtraData(new MediaStream()); | 673 current_request_info_->web_stream()->setExtraData(new MediaStream()); |
| 662 | 674 |
| 663 // Wait for the tracks to be started successfully or to fail. | 675 // Wait for the tracks to be started successfully or to fail. |
| 664 current_request_info_->CallbackOnTracksStarted( | 676 current_request_info_->CallbackOnTracksStarted( |
| 665 base::Bind(&UserMediaClientImpl::OnCreateNativeTracksCompleted, | 677 base::Bind(&UserMediaClientImpl::OnCreateNativeTracksCompleted, |
| 666 weak_factory_.GetWeakPtr(), label)); | 678 weak_factory_.GetWeakPtr(), label)); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 return; | 795 return; |
| 784 } | 796 } |
| 785 // By creating |source| it is guaranteed that the blink::WebMediaStreamSource | 797 // By creating |source| it is guaranteed that the blink::WebMediaStreamSource |
| 786 // object is valid during the cleanup. | 798 // object is valid during the cleanup. |
| 787 blink::WebMediaStreamSource source(*source_ptr); | 799 blink::WebMediaStreamSource source(*source_ptr); |
| 788 StopLocalSource(source, false); | 800 StopLocalSource(source, false); |
| 789 RemoveLocalSource(source); | 801 RemoveLocalSource(source); |
| 790 } | 802 } |
| 791 | 803 |
| 792 blink::WebMediaStreamSource UserMediaClientImpl::InitializeVideoSourceObject( | 804 blink::WebMediaStreamSource UserMediaClientImpl::InitializeVideoSourceObject( |
| 793 const StreamDeviceInfo& device, | 805 const StreamDeviceInfo& device) { |
| 794 const blink::WebMediaConstraints& constraints) { | |
| 795 DCHECK(CalledOnValidThread()); | 806 DCHECK(CalledOnValidThread()); |
| 807 DCHECK(current_request_info_); |
| 796 | 808 |
| 797 blink::WebMediaStreamSource source = FindOrInitializeSourceObject(device); | 809 blink::WebMediaStreamSource source = FindOrInitializeSourceObject(device); |
| 798 if (!source.getExtraData()) { | 810 if (!source.getExtraData()) { |
| 799 source.setExtraData(CreateVideoSource( | 811 source.setExtraData(CreateVideoSource( |
| 800 device, base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, | 812 device, base::Bind(&UserMediaClientImpl::OnLocalSourceStopped, |
| 801 weak_factory_.GetWeakPtr()))); | 813 weak_factory_.GetWeakPtr()))); |
| 802 local_sources_.push_back(source); | 814 local_sources_.push_back(source); |
| 803 } | 815 } |
| 804 return source; | 816 return source; |
| 805 } | 817 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource( | 873 ProcessedLocalAudioSource* source = new ProcessedLocalAudioSource( |
| 862 RenderFrameObserver::routing_id(), device, constraints, source_ready, | 874 RenderFrameObserver::routing_id(), device, constraints, source_ready, |
| 863 dependency_factory_); | 875 dependency_factory_); |
| 864 return source; | 876 return source; |
| 865 } | 877 } |
| 866 | 878 |
| 867 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource( | 879 MediaStreamVideoSource* UserMediaClientImpl::CreateVideoSource( |
| 868 const StreamDeviceInfo& device, | 880 const StreamDeviceInfo& device, |
| 869 const MediaStreamSource::SourceStoppedCallback& stop_callback) { | 881 const MediaStreamSource::SourceStoppedCallback& stop_callback) { |
| 870 DCHECK(CalledOnValidThread()); | 882 DCHECK(CalledOnValidThread()); |
| 871 content::MediaStreamVideoCapturerSource* ret = | 883 DCHECK(current_request_info_); |
| 872 new content::MediaStreamVideoCapturerSource(stop_callback, device, | 884 if (IsOldVideoConstraints()) { |
| 873 render_frame()); | 885 return new MediaStreamVideoCapturerSource(stop_callback, device, |
| 874 return ret; | 886 render_frame()); |
| 887 } |
| 888 |
| 889 DCHECK(current_request_info_->video_capture_settings().HasValue()); |
| 890 return new MediaStreamVideoCapturerSource( |
| 891 stop_callback, device, |
| 892 current_request_info_->video_capture_settings().capture_params(), |
| 893 render_frame()); |
| 875 } | 894 } |
| 876 | 895 |
| 877 void UserMediaClientImpl::CreateVideoTracks( | 896 void UserMediaClientImpl::CreateVideoTracks( |
| 878 const StreamDeviceInfoArray& devices, | 897 const StreamDeviceInfoArray& devices, |
| 879 const blink::WebMediaConstraints& constraints, | |
| 880 blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks) { | 898 blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks) { |
| 881 DCHECK(CalledOnValidThread()); | 899 DCHECK(CalledOnValidThread()); |
| 882 DCHECK(current_request_info_); | 900 DCHECK(current_request_info_); |
| 883 DCHECK_EQ(devices.size(), webkit_tracks->size()); | 901 DCHECK_EQ(devices.size(), webkit_tracks->size()); |
| 884 | 902 |
| 885 for (size_t i = 0; i < devices.size(); ++i) { | 903 for (size_t i = 0; i < devices.size(); ++i) { |
| 886 blink::WebMediaStreamSource source = | 904 blink::WebMediaStreamSource source = |
| 887 InitializeVideoSourceObject(devices[i], constraints); | 905 InitializeVideoSourceObject(devices[i]); |
| 888 (*webkit_tracks)[i] = | 906 (*webkit_tracks)[i] = |
| 889 current_request_info_->CreateAndStartVideoTrack(source, constraints); | 907 current_request_info_->CreateAndStartVideoTrack(source); |
| 890 } | 908 } |
| 891 } | 909 } |
| 892 | 910 |
| 893 void UserMediaClientImpl::CreateAudioTracks( | 911 void UserMediaClientImpl::CreateAudioTracks( |
| 894 const StreamDeviceInfoArray& devices, | 912 const StreamDeviceInfoArray& devices, |
| 895 const blink::WebMediaConstraints& constraints, | 913 const blink::WebMediaConstraints& constraints, |
| 896 blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks) { | 914 blink::WebVector<blink::WebMediaStreamTrack>* webkit_tracks) { |
| 897 DCHECK(CalledOnValidThread()); | 915 DCHECK(CalledOnValidThread()); |
| 898 DCHECK(current_request_info_); | 916 DCHECK(current_request_info_); |
| 899 DCHECK_EQ(devices.size(), webkit_tracks->size()); | 917 DCHECK_EQ(devices.size(), webkit_tracks->size()); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 } | 1286 } |
| 1269 | 1287 |
| 1270 UserMediaClientImpl::UserMediaRequestInfo::UserMediaRequestInfo( | 1288 UserMediaClientImpl::UserMediaRequestInfo::UserMediaRequestInfo( |
| 1271 int request_id, | 1289 int request_id, |
| 1272 const blink::WebUserMediaRequest& request, | 1290 const blink::WebUserMediaRequest& request, |
| 1273 bool is_processing_user_gesture, | 1291 bool is_processing_user_gesture, |
| 1274 const url::Origin& security_origin) | 1292 const url::Origin& security_origin) |
| 1275 : request_id_(request_id), | 1293 : request_id_(request_id), |
| 1276 state_(State::NOT_SENT_FOR_GENERATION), | 1294 state_(State::NOT_SENT_FOR_GENERATION), |
| 1277 enable_automatic_output_device_selection_(false), | 1295 enable_automatic_output_device_selection_(false), |
| 1296 is_video_content_capture_(false), |
| 1278 request_(request), | 1297 request_(request), |
| 1279 is_processing_user_gesture_(is_processing_user_gesture), | 1298 is_processing_user_gesture_(is_processing_user_gesture), |
| 1280 security_origin_(security_origin), | 1299 security_origin_(security_origin), |
| 1281 request_result_(MEDIA_DEVICE_OK), | 1300 request_result_(MEDIA_DEVICE_OK), |
| 1282 request_result_name_("") {} | 1301 request_result_name_("") {} |
| 1283 | 1302 |
| 1284 void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack( | 1303 void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack( |
| 1285 const blink::WebMediaStreamTrack& track, | 1304 const blink::WebMediaStreamTrack& track, |
| 1286 bool is_pending) { | 1305 bool is_pending) { |
| 1287 DCHECK(track.source().getType() == blink::WebMediaStreamSource::TypeAudio); | 1306 DCHECK(track.source().getType() == blink::WebMediaStreamSource::TypeAudio); |
| 1288 MediaStreamAudioSource* native_source = | 1307 MediaStreamAudioSource* native_source = |
| 1289 MediaStreamAudioSource::From(track.source()); | 1308 MediaStreamAudioSource::From(track.source()); |
| 1290 // Add the source as pending since OnTrackStarted will expect it to be there. | 1309 // Add the source as pending since OnTrackStarted will expect it to be there. |
| 1291 sources_waiting_for_callback_.push_back(native_source); | 1310 sources_waiting_for_callback_.push_back(native_source); |
| 1292 | 1311 |
| 1293 sources_.push_back(track.source()); | 1312 sources_.push_back(track.source()); |
| 1294 bool connected = native_source->ConnectToTrack(track); | 1313 bool connected = native_source->ConnectToTrack(track); |
| 1295 if (!is_pending) { | 1314 if (!is_pending) { |
| 1296 OnTrackStarted( | 1315 OnTrackStarted( |
| 1297 native_source, | 1316 native_source, |
| 1298 connected ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE, ""); | 1317 connected ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE, ""); |
| 1299 } | 1318 } |
| 1300 } | 1319 } |
| 1301 | 1320 |
| 1302 blink::WebMediaStreamTrack | 1321 blink::WebMediaStreamTrack |
| 1303 UserMediaClientImpl::UserMediaRequestInfo::CreateAndStartVideoTrack( | 1322 UserMediaClientImpl::UserMediaRequestInfo::CreateAndStartVideoTrack( |
| 1304 const blink::WebMediaStreamSource& source, | 1323 const blink::WebMediaStreamSource& source) { |
| 1305 const blink::WebMediaConstraints& constraints) { | |
| 1306 DCHECK(source.getType() == blink::WebMediaStreamSource::TypeVideo); | 1324 DCHECK(source.getType() == blink::WebMediaStreamSource::TypeVideo); |
| 1325 DCHECK(request_.video()); |
| 1326 DCHECK(video_capture_settings_.HasValue()); |
| 1307 MediaStreamVideoSource* native_source = | 1327 MediaStreamVideoSource* native_source = |
| 1308 MediaStreamVideoSource::GetVideoSource(source); | 1328 MediaStreamVideoSource::GetVideoSource(source); |
| 1309 DCHECK(native_source); | 1329 DCHECK(native_source); |
| 1310 sources_.push_back(source); | 1330 sources_.push_back(source); |
| 1311 sources_waiting_for_callback_.push_back(native_source); | 1331 sources_waiting_for_callback_.push_back(native_source); |
| 1332 if (IsOldVideoConstraints()) { |
| 1333 return MediaStreamVideoTrack::CreateVideoTrack( |
| 1334 native_source, request_.videoConstraints(), |
| 1335 base::Bind(&UserMediaClientImpl::UserMediaRequestInfo::OnTrackStarted, |
| 1336 AsWeakPtr()), |
| 1337 true); |
| 1338 } |
| 1312 return MediaStreamVideoTrack::CreateVideoTrack( | 1339 return MediaStreamVideoTrack::CreateVideoTrack( |
| 1313 native_source, constraints, base::Bind( | 1340 native_source, video_capture_settings_.track_adapter_settings(), |
| 1314 &UserMediaClientImpl::UserMediaRequestInfo::OnTrackStarted, | 1341 video_capture_settings_.noise_reduction(), is_video_content_capture_, |
| 1315 AsWeakPtr()), | 1342 video_capture_settings_.min_frame_rate(), |
| 1343 base::Bind(&UserMediaClientImpl::UserMediaRequestInfo::OnTrackStarted, |
| 1344 AsWeakPtr()), |
| 1316 true); | 1345 true); |
| 1317 } | 1346 } |
| 1318 | 1347 |
| 1319 void UserMediaClientImpl::UserMediaRequestInfo::CallbackOnTracksStarted( | 1348 void UserMediaClientImpl::UserMediaRequestInfo::CallbackOnTracksStarted( |
| 1320 const ResourcesReady& callback) { | 1349 const ResourcesReady& callback) { |
| 1321 DCHECK(ready_callback_.is_null()); | 1350 DCHECK(ready_callback_.is_null()); |
| 1322 ready_callback_ = callback; | 1351 ready_callback_ = callback; |
| 1323 CheckAllTracksStarted(); | 1352 CheckAllTracksStarted(); |
| 1324 } | 1353 } |
| 1325 | 1354 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 const blink::WebString& result_name) { | 1390 const blink::WebString& result_name) { |
| 1362 // Check if we're waiting to be notified of this source. If not, then we'll | 1391 // Check if we're waiting to be notified of this source. If not, then we'll |
| 1363 // ignore the notification. | 1392 // ignore the notification. |
| 1364 auto found = std::find(sources_waiting_for_callback_.begin(), | 1393 auto found = std::find(sources_waiting_for_callback_.begin(), |
| 1365 sources_waiting_for_callback_.end(), source); | 1394 sources_waiting_for_callback_.end(), source); |
| 1366 if (found != sources_waiting_for_callback_.end()) | 1395 if (found != sources_waiting_for_callback_.end()) |
| 1367 OnTrackStarted(source, result, result_name); | 1396 OnTrackStarted(source, result, result_name); |
| 1368 } | 1397 } |
| 1369 | 1398 |
| 1370 } // namespace content | 1399 } // namespace content |
| OLD | NEW |