| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 } | 442 } |
| 443 | 443 |
| 444 void MediaStreamImpl::CreateWebKitSourceVector( | 444 void MediaStreamImpl::CreateWebKitSourceVector( |
| 445 const std::string& label, | 445 const std::string& label, |
| 446 const StreamDeviceInfoArray& devices, | 446 const StreamDeviceInfoArray& devices, |
| 447 blink::WebMediaStreamSource::Type type, | 447 blink::WebMediaStreamSource::Type type, |
| 448 blink::WebFrame* frame, | 448 blink::WebFrame* frame, |
| 449 blink::WebVector<blink::WebMediaStreamSource>& webkit_sources) { | 449 blink::WebVector<blink::WebMediaStreamSource>& webkit_sources) { |
| 450 CHECK_EQ(devices.size(), webkit_sources.size()); | 450 CHECK_EQ(devices.size(), webkit_sources.size()); |
| 451 for (size_t i = 0; i < devices.size(); ++i) { | 451 for (size_t i = 0; i < devices.size(); ++i) { |
| 452 const char* track_type = | |
| 453 (type == blink::WebMediaStreamSource::TypeAudio) ? "a" : "v"; | |
| 454 std::string source_id = base::StringPrintf("%s%s%u", label.c_str(), | |
| 455 track_type, | |
| 456 static_cast<unsigned int>(i)); | |
| 457 | |
| 458 const blink::WebMediaStreamSource* existing_source = | 452 const blink::WebMediaStreamSource* existing_source = |
| 459 FindLocalSource(devices[i]); | 453 FindLocalSource(devices[i]); |
| 460 if (existing_source) { | 454 if (existing_source) { |
| 461 webkit_sources[i] = *existing_source; | 455 webkit_sources[i] = *existing_source; |
| 462 DVLOG(1) << "Source already exist. Reusing source with id " | 456 DVLOG(1) << "Source already exist. Reusing source with id " |
| 463 << webkit_sources[i]. id().utf8(); | 457 << webkit_sources[i]. id().utf8(); |
| 464 continue; | 458 continue; |
| 465 } | 459 } |
| 466 webkit_sources[i].initialize( | 460 webkit_sources[i].initialize( |
| 467 UTF8ToUTF16(source_id), | 461 UTF8ToUTF16(devices[i].device.id), |
| 468 type, | 462 type, |
| 469 UTF8ToUTF16(devices[i].device.name)); | 463 UTF8ToUTF16(devices[i].device.name)); |
| 470 MediaStreamSourceExtraData* source_extra_data( | 464 MediaStreamSourceExtraData* source_extra_data( |
| 471 new content::MediaStreamSourceExtraData( | 465 new content::MediaStreamSourceExtraData( |
| 472 devices[i], | 466 devices[i], |
| 473 base::Bind(&MediaStreamImpl::OnLocalSourceStop, AsWeakPtr()))); | 467 base::Bind(&MediaStreamImpl::OnLocalSourceStop, AsWeakPtr()))); |
| 474 // |source_extra_data| is owned by webkit_sources[i]. | 468 // |source_extra_data| is owned by webkit_sources[i]. |
| 475 webkit_sources[i].setExtraData(source_extra_data); | 469 webkit_sources[i].setExtraData(source_extra_data); |
| 476 local_sources_.push_back(LocalStreamSource(frame, webkit_sources[i])); | 470 local_sources_.push_back(LocalStreamSource(frame, webkit_sources[i])); |
| 477 } | 471 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 enable_automatic_output_device_selection( | 885 enable_automatic_output_device_selection( |
| 892 enable_automatic_output_device_selection), | 886 enable_automatic_output_device_selection), |
| 893 frame(frame), | 887 frame(frame), |
| 894 request(request) { | 888 request(request) { |
| 895 } | 889 } |
| 896 | 890 |
| 897 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { | 891 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { |
| 898 } | 892 } |
| 899 | 893 |
| 900 } // namespace content | 894 } // namespace content |
| OLD | NEW |