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

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

Issue 11418307: Revert 170912 - need more delayloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 11
12 // Avoid including strsafe.h via dshow as it will cause build warnings. 12 // Avoid including strsafe.h via dshow as it will cause build warnings.
13 #define NO_DSHOW_STRSAFE 13 #define NO_DSHOW_STRSAFE
14 #include <dshow.h> 14 #include <dshow.h>
15 15
16 #include <map> 16 #include <map>
17 #include <string> 17 #include <string>
18 18
19 #include "base/threading/non_thread_safe.h" 19 #include "base/threading/non_thread_safe.h"
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "base/win/scoped_comptr.h" 21 #include "base/win/scoped_comptr.h"
22 #include "media/video/capture/video_capture_device.h" 22 #include "media/video/capture/video_capture_device.h"
23 #include "media/video/capture/video_capture_types.h" 23 #include "media/video/capture/video_capture_types.h"
24 #include "media/video/capture/win/capability_list_win.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
30 // All the methods in the class can only be run on a COM initialized thread. 29 // All the methods in the class can only be run on a COM initialized thread.
31 class VideoCaptureDeviceWin 30 class VideoCaptureDeviceWin
32 : public base::NonThreadSafe, 31 : public base::NonThreadSafe,
33 public VideoCaptureDevice, 32 public VideoCaptureDevice,
34 public SinkFilterObserver { 33 public SinkFilterObserver {
35 public: 34 public:
36 explicit VideoCaptureDeviceWin(const Name& device_name); 35 explicit VideoCaptureDeviceWin(const Name& device_name);
37 virtual ~VideoCaptureDeviceWin(); 36 virtual ~VideoCaptureDeviceWin();
38 // Opens the device driver for this device. 37 // Opens the device driver for this device.
39 // This function is used by the static VideoCaptureDevice::Create function. 38 // This function is used by the static VideoCaptureDevice::Create function.
40 bool Init(); 39 bool Init();
41 40
42 // VideoCaptureDevice implementation. 41 // VideoCaptureDevice implementation.
43 virtual void Allocate(int width, 42 virtual void Allocate(int width,
44 int height, 43 int height,
45 int frame_rate, 44 int frame_rate,
46 VideoCaptureDevice::EventHandler* observer) OVERRIDE; 45 VideoCaptureDevice::EventHandler* observer) OVERRIDE;
47 virtual void Start() OVERRIDE; 46 virtual void Start() OVERRIDE;
48 virtual void Stop() OVERRIDE; 47 virtual void Stop() OVERRIDE;
49 virtual void DeAllocate() OVERRIDE; 48 virtual void DeAllocate() OVERRIDE;
50 virtual const Name& device_name() OVERRIDE; 49 virtual const Name& device_name() OVERRIDE;
51 50
52 static void GetDeviceNames(Names* device_names);
53
54 private: 51 private:
55 enum InternalState { 52 enum InternalState {
56 kIdle, // The device driver is opened but camera is not in use. 53 kIdle, // The device driver is opened but camera is not in use.
57 kAllocated, // The camera has been allocated and can be started. 54 kAllocated, // The camera has been allocated and can be started.
58 kCapturing, // Video is being captured. 55 kCapturing, // Video is being captured.
59 kError // Error accessing HW functions. 56 kError // Error accessing HW functions.
60 // User needs to recover by destroying the object. 57 // User needs to recover by destroying the object.
61 }; 58 };
59 typedef std::map<int, VideoCaptureCapability> CapabilityMap;
62 60
63 // Implements SinkFilterObserver. 61 // Implements SinkFilterObserver.
64 virtual void FrameReceived(const uint8* buffer, int length); 62 virtual void FrameReceived(const uint8* buffer, int length);
65 63
66 bool CreateCapabilityMap(); 64 bool CreateCapabilityMap();
65 int GetBestMatchedCapability(int width, int height, int frame_rate);
67 void SetErrorState(const char* reason); 66 void SetErrorState(const char* reason);
68 67
69 Name device_name_; 68 Name device_name_;
70 InternalState state_; 69 InternalState state_;
71 VideoCaptureDevice::EventHandler* observer_; 70 VideoCaptureDevice::EventHandler* observer_;
72 71
73 base::win::ScopedComPtr<IBaseFilter> capture_filter_; 72 base::win::ScopedComPtr<IBaseFilter> capture_filter_;
74 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; 73 base::win::ScopedComPtr<IGraphBuilder> graph_builder_;
75 base::win::ScopedComPtr<IMediaControl> media_control_; 74 base::win::ScopedComPtr<IMediaControl> media_control_;
76 base::win::ScopedComPtr<IPin> input_sink_pin_; 75 base::win::ScopedComPtr<IPin> input_sink_pin_;
77 base::win::ScopedComPtr<IPin> output_capture_pin_; 76 base::win::ScopedComPtr<IPin> output_capture_pin_;
78 // Used when using a MJPEG decoder. 77 // Used when using a MJPEG decoder.
79 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; 78 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_;
80 base::win::ScopedComPtr<IPin> input_mjpg_pin_; 79 base::win::ScopedComPtr<IPin> input_mjpg_pin_;
81 base::win::ScopedComPtr<IPin> output_mjpg_pin_; 80 base::win::ScopedComPtr<IPin> output_mjpg_pin_;
82 81
83 scoped_refptr<SinkFilter> sink_filter_; 82 scoped_refptr<SinkFilter> sink_filter_;
84 83
85 // Map of all capabilities this device support. 84 // Map of all capabilities this device support.
86 CapabilityList capabilities_; 85 CapabilityMap capabilities_;
87 86
88 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); 87 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin);
89 }; 88 };
90 89
91 } // namespace media 90 } // namespace media
92 91
93 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ 92 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_
OLDNEW
« no previous file with comments | « media/video/capture/win/video_capture_device_mf_win.cc ('k') | media/video/capture/win/video_capture_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698