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/browser/renderer_host/media/media_stream_manager.h" | 5 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/win/scoped_com_initializer.h" | |
| 14 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 13 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 15 #include "content/browser/renderer_host/media/media_stream_device_settings.h" | 14 #include "content/browser/renderer_host/media/media_stream_device_settings.h" |
| 16 #include "content/browser/renderer_host/media/media_stream_requester.h" | 15 #include "content/browser/renderer_host/media/media_stream_requester.h" |
| 17 #include "content/browser/renderer_host/media/video_capture_manager.h" | 16 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 18 #include "content/common/media/media_stream_options.h" | 17 #include "content/common/media/media_stream_options.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/media_observer.h" | 20 #include "content/public/browser/media_observer.h" |
| 22 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 23 | 22 |
| 23 #if defined(OS_WIN) | |
| 24 #include "base/win/scoped_com_initializer.h" | |
| 25 #endif | |
| 26 | |
| 24 using content::BrowserThread; | 27 using content::BrowserThread; |
| 25 | 28 |
| 26 namespace media_stream { | 29 namespace media_stream { |
| 27 | 30 |
| 28 // Creates a random label used to identify requests. | 31 // Creates a random label used to identify requests. |
| 29 static std::string RandomLabel() { | 32 static std::string RandomLabel() { |
| 30 // An earlier PeerConnection spec, | 33 // An earlier PeerConnection spec, |
| 31 // http://dev.w3.org/2011/webrtc/editor/webrtc.html, specified the | 34 // http://dev.w3.org/2011/webrtc/editor/webrtc.html, specified the |
| 32 // MediaStream::label alphabet as containing 36 characters from | 35 // MediaStream::label alphabet as containing 36 characters from |
| 33 // range: U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E, | 36 // range: U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 44 return label; | 47 return label; |
| 45 } | 48 } |
| 46 | 49 |
| 47 // Helper to verify if a media stream type is part of options or not. | 50 // Helper to verify if a media stream type is part of options or not. |
| 48 static bool Requested(const StreamOptions& options, | 51 static bool Requested(const StreamOptions& options, |
| 49 MediaStreamType stream_type) { | 52 MediaStreamType stream_type) { |
| 50 return (options.audio_type == stream_type || | 53 return (options.audio_type == stream_type || |
| 51 options.video_type == stream_type); | 54 options.video_type == stream_type); |
| 52 } | 55 } |
| 53 | 56 |
| 54 DeviceThread::DeviceThread(const char* name) | 57 #if defined(OS_WIN) |
|
cpu_(ooo_6.6-7.5)
2012/10/01 19:47:27
does block 58-62 need to be ifdef(os_win) ?
Peter Kasting
2012/10/01 20:23:17
Yes, see the header file changes.
| |
| 55 : base::Thread(name) { | 58 DeviceThread::DeviceThread(const char* name) : base::Thread(name) { |
| 56 } | 59 } |
| 57 | 60 |
| 58 DeviceThread::~DeviceThread() { | 61 DeviceThread::~DeviceThread() { |
| 59 Stop(); | |
|
cpu_(ooo_6.6-7.5)
2012/10/01 19:47:27
did you mean to remove this stop()?
I don't see a
Peter Kasting
2012/10/01 20:23:17
I did mean to remove it, because the superclass de
| |
| 60 } | 62 } |
| 61 | 63 |
| 62 void DeviceThread::Init() { | 64 void DeviceThread::Init() { |
| 63 using base::win::ScopedCOMInitializer; | 65 com_initializer_.reset(new base::win::ScopedCOMInitializer( |
| 64 // Enter the multi-threaded apartment. | 66 base::win::ScopedCOMInitializer::kMTA)); |
| 65 com_initializer_.reset(new ScopedCOMInitializer(ScopedCOMInitializer::kMTA)); | |
| 66 } | 67 } |
| 67 | 68 |
| 68 void DeviceThread::CleanUp() { | 69 void DeviceThread::CleanUp() { |
| 69 com_initializer_.reset(); | 70 com_initializer_.reset(); |
| 70 } | 71 } |
| 72 #endif | |
| 71 | 73 |
| 72 // TODO(xians): Merge DeviceRequest with MediaStreamRequest. | 74 // TODO(xians): Merge DeviceRequest with MediaStreamRequest. |
| 73 struct MediaStreamManager::DeviceRequest { | 75 struct MediaStreamManager::DeviceRequest { |
| 74 enum RequestState { | 76 enum RequestState { |
| 75 STATE_NOT_REQUESTED = 0, | 77 STATE_NOT_REQUESTED = 0, |
| 76 STATE_REQUESTED, | 78 STATE_REQUESTED, |
| 77 STATE_PENDING_APPROVAL, | 79 STATE_PENDING_APPROVAL, |
| 78 STATE_OPENING, | 80 STATE_OPENING, |
| 79 STATE_DONE, | 81 STATE_DONE, |
| 80 STATE_ERROR | 82 STATE_ERROR |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 902 it != requests_.end(); ++it) { | 904 it != requests_.end(); ++it) { |
| 903 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && | 905 if (it->second.type == DeviceRequest::ENUMERATE_DEVICES && |
| 904 Requested(it->second.options, stream_type)) { | 906 Requested(it->second.options, stream_type)) { |
| 905 return true; | 907 return true; |
| 906 } | 908 } |
| 907 } | 909 } |
| 908 return false; | 910 return false; |
| 909 } | 911 } |
| 910 | 912 |
| 911 } // namespace media_stream | 913 } // namespace media_stream |
| OLD | NEW |