Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: content/browser/renderer_host/media/web_contents_video_capture_device.cc

Issue 11298006: Browser-wide audio mirroring for TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Implementation notes: This needs to work on a variety of hardware 5 // Implementation notes: This needs to work on a variety of hardware
6 // configurations where the speed of the CPU and GPU greatly affect overall 6 // configurations where the speed of the CPU and GPU greatly affect overall
7 // performance. Therefore, the process of capturing has been split up into a 7 // performance. Therefore, the process of capturing has been split up into a
8 // pipeline of three stages. Each stage executes on its own thread: 8 // pipeline of three stages. Each stage executes on its own thread:
9 // 9 //
10 // 1. Capture: A bitmap is snapshotted/copied from the RenderView's backing 10 // 1. Capture: A bitmap is snapshotted/copied from the RenderView's backing
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 #include "base/basictypes.h" 46 #include "base/basictypes.h"
47 #include "base/bind.h" 47 #include "base/bind.h"
48 #include "base/bind_helpers.h" 48 #include "base/bind_helpers.h"
49 #include "base/callback_forward.h" 49 #include "base/callback_forward.h"
50 #include "base/debug/trace_event.h" 50 #include "base/debug/trace_event.h"
51 #include "base/logging.h" 51 #include "base/logging.h"
52 #include "base/memory/scoped_ptr.h" 52 #include "base/memory/scoped_ptr.h"
53 #include "base/string_number_conversions.h" 53 #include "base/string_number_conversions.h"
54 #include "base/string_piece.h" 54 #include "base/string_piece.h"
55 #include "base/string_util.h"
55 #include "base/stringprintf.h" 56 #include "base/stringprintf.h"
56 #include "base/synchronization/lock.h" 57 #include "base/synchronization/lock.h"
57 #include "base/threading/thread.h" 58 #include "base/threading/thread.h"
58 #include "base/time.h" 59 #include "base/time.h"
59 #include "content/public/browser/browser_thread.h" 60 #include "content/public/browser/browser_thread.h"
60 #include "content/public/browser/render_process_host.h" 61 #include "content/public/browser/render_process_host.h"
61 #include "content/public/browser/render_view_host.h" 62 #include "content/public/browser/render_view_host.h"
62 #include "content/public/browser/render_widget_host_view.h" 63 #include "content/public/browser/render_widget_host_view.h"
63 #include "content/public/browser/web_contents.h" 64 #include "content/public/browser/web_contents.h"
64 #include "content/public/browser/web_contents_observer.h" 65 #include "content/public/browser/web_contents_observer.h"
66 #include "content/public/common/media_stream_request.h"
65 #include "media/base/bind_to_loop.h" 67 #include "media/base/bind_to_loop.h"
66 #include "media/video/capture/video_capture_types.h" 68 #include "media/video/capture/video_capture_types.h"
67 #include "skia/ext/image_operations.h" 69 #include "skia/ext/image_operations.h"
68 #include "skia/ext/platform_canvas.h" 70 #include "skia/ext/platform_canvas.h"
69 #include "third_party/skia/include/core/SkBitmap.h" 71 #include "third_party/skia/include/core/SkBitmap.h"
70 #include "third_party/skia/include/core/SkColor.h" 72 #include "third_party/skia/include/core/SkColor.h"
71 #include "ui/gfx/rect.h" 73 #include "ui/gfx/rect.h"
72 74
73 // TODO(miu): The caller of Allocate() should use an appropriate heuristic to 75 // TODO(miu): The caller of Allocate() should use an appropriate heuristic to
74 // determine the frame size. For now, hard-code the capture device to 720p 76 // determine the frame size. For now, hard-code the capture device to 720p
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 device_name_.unique_id = "-1:-1"; 965 device_name_.unique_id = "-1:-1";
964 capturer_->InitializeForTesting(test_source, destroy_cb); 966 capturer_->InitializeForTesting(test_source, destroy_cb);
965 } 967 }
966 968
967 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { 969 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() {
968 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; 970 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying.";
969 } 971 }
970 972
971 // static 973 // static
972 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create( 974 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create(
973 const std::string& device_id) { 975 const std::string& device_id_param) {
976 DCHECK(StartsWithASCII(device_id_param,
977 content::kMediaStreamTabDeviceScheme, true));
978 const std::string device_id = device_id_param.substr(
979 strlen(content::kMediaStreamTabDeviceScheme),
980 device_id_param.length());
981
974 // Parse device_id into render_process_id and render_view_id. 982 // Parse device_id into render_process_id and render_view_id.
975 const size_t sep_pos = device_id.find(':'); 983 const size_t sep_pos = device_id.find(':');
976 if (sep_pos == std::string::npos) { 984 if (sep_pos == std::string::npos) {
977 return NULL; 985 return NULL;
978 } 986 }
979 const base::StringPiece component1(device_id.data(), sep_pos); 987 const base::StringPiece component1(device_id.data(), sep_pos);
980 const base::StringPiece component2(device_id.data() + sep_pos + 1, 988 const base::StringPiece component2(device_id.data() + sep_pos + 1,
981 device_id.length() - sep_pos - 1); 989 device_id.length() - sep_pos - 1);
982 int render_process_id = -1; 990 int render_process_id = -1;
983 int render_view_id = -1; 991 int render_view_id = -1;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 capturer_->SetConsumer(NULL); 1033 capturer_->SetConsumer(NULL);
1026 capturer_->DeAllocate(); 1034 capturer_->DeAllocate();
1027 } 1035 }
1028 1036
1029 const media::VideoCaptureDevice::Name& 1037 const media::VideoCaptureDevice::Name&
1030 WebContentsVideoCaptureDevice::device_name() { 1038 WebContentsVideoCaptureDevice::device_name() {
1031 return device_name_; 1039 return device_name_;
1032 } 1040 }
1033 1041
1034 } // namespace content 1042 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698