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

Side by Side Diff: media/video/capture/win/video_capture_device_win.h

Issue 10662049: Move the device enumerate/open/close work to device thread from IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Magnus' comments. Created 8 years, 5 months 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 // Windows specific implementation of VideoCaptureDevice. 5 // Windows specific implementation of VideoCaptureDevice.
6 // DirectShow is used for capturing. DirectShow provide its own threads 6 // DirectShow is used for capturing. DirectShow provide its own threads
7 // for capturing. 7 // for capturing.
8 8
9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ 9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_
10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ 10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_
11 #pragma once 11 #pragma once
12 12
13 // Avoid including strsafe.h via dshow as it will cause build warnings. 13 // Avoid including strsafe.h via dshow as it will cause build warnings.
14 #define NO_DSHOW_STRSAFE 14 #define NO_DSHOW_STRSAFE
15 #include <dshow.h> 15 #include <dshow.h>
16 16
17 #include <map> 17 #include <map>
18 #include <string> 18 #include <string>
19 19
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "base/win/scoped_com_initializer.h"
22 #include "base/win/scoped_comptr.h" 21 #include "base/win/scoped_comptr.h"
23 #include "media/video/capture/video_capture_device.h" 22 #include "media/video/capture/video_capture_device.h"
24 #include "media/video/capture/video_capture_types.h" 23 #include "media/video/capture/video_capture_types.h"
25 #include "media/video/capture/win/sink_filter_win.h" 24 #include "media/video/capture/win/sink_filter_win.h"
26 #include "media/video/capture/win/sink_input_pin_win.h" 25 #include "media/video/capture/win/sink_input_pin_win.h"
27 26
28 namespace media { 27 namespace media {
29 28
29 // All the APIs in the class can only be run on a COM initialized thread.
30 class VideoCaptureDeviceWin 30 class VideoCaptureDeviceWin
tommi (sloooow) - chröme 2012/07/02 13:36:36 inherit from base::NonThreadSafe and use CalledOnV
no longer working on chromium 2012/07/04 12:35:25 Done.
31 : public VideoCaptureDevice, 31 : public VideoCaptureDevice,
32 public SinkFilterObserver { 32 public SinkFilterObserver {
33 public: 33 public:
34 explicit VideoCaptureDeviceWin(const Name& device_name); 34 explicit VideoCaptureDeviceWin(const Name& device_name);
35 virtual ~VideoCaptureDeviceWin(); 35 virtual ~VideoCaptureDeviceWin();
36 // Opens the device driver for this device. 36 // Opens the device driver for this device.
37 // This function is used by the static VideoCaptureDevice::Create function. 37 // This function is used by the static VideoCaptureDevice::Create function.
38 bool Init(); 38 bool Init();
39 39
40 // VideoCaptureDevice implementation. 40 // VideoCaptureDevice implementation.
(...skipping 16 matching lines...) Expand all
57 }; 57 };
58 typedef std::map<int, VideoCaptureCapability> CapabilityMap; 58 typedef std::map<int, VideoCaptureCapability> CapabilityMap;
59 59
60 // Implements SinkFilterObserver. 60 // Implements SinkFilterObserver.
61 virtual void FrameReceived(const uint8* buffer, int length); 61 virtual void FrameReceived(const uint8* buffer, int length);
62 62
63 bool CreateCapabilityMap(); 63 bool CreateCapabilityMap();
64 int GetBestMatchedCapability(int width, int height, int frame_rate); 64 int GetBestMatchedCapability(int width, int height, int frame_rate);
65 void SetErrorState(const char* reason); 65 void SetErrorState(const char* reason);
66 66
67 base::win::ScopedCOMInitializer initialize_com_;
68
69 Name device_name_; 67 Name device_name_;
70 InternalState state_; 68 InternalState state_;
71 VideoCaptureDevice::EventHandler* observer_; 69 VideoCaptureDevice::EventHandler* observer_;
72 70
73 base::win::ScopedComPtr<IBaseFilter> capture_filter_; 71 base::win::ScopedComPtr<IBaseFilter> capture_filter_;
74 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; 72 base::win::ScopedComPtr<IGraphBuilder> graph_builder_;
75 base::win::ScopedComPtr<IMediaControl> media_control_; 73 base::win::ScopedComPtr<IMediaControl> media_control_;
76 base::win::ScopedComPtr<IPin> input_sink_pin_; 74 base::win::ScopedComPtr<IPin> input_sink_pin_;
77 base::win::ScopedComPtr<IPin> output_capture_pin_; 75 base::win::ScopedComPtr<IPin> output_capture_pin_;
78 // Used when using a MJPEG decoder. 76 // Used when using a MJPEG decoder.
79 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; 77 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_;
80 base::win::ScopedComPtr<IPin> input_mjpg_pin_; 78 base::win::ScopedComPtr<IPin> input_mjpg_pin_;
81 base::win::ScopedComPtr<IPin> output_mjpg_pin_; 79 base::win::ScopedComPtr<IPin> output_mjpg_pin_;
82 80
83 scoped_refptr<SinkFilter> sink_filter_; 81 scoped_refptr<SinkFilter> sink_filter_;
84 82
85 // Map of all capabilities this device support. 83 // Map of all capabilities this device support.
86 CapabilityMap capabilities_; 84 CapabilityMap capabilities_;
87 85
88 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); 86 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin);
89 }; 87 };
90 88
91 } // namespace media 89 } // namespace media
92 90
93 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ 91 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698