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

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

Issue 7229013: This is the VideoCaptureDevice implementation for windows. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 6 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Windows specific implementation of VideoCaptureDevice.
6 // DirectShow is used for capturing. DirectShow provide it's own threads
7 // for capturing.
8
9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_
10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_
11 #pragma once
12
13 // Avoid including strsafe.h via dshow as it will cause build warnings.
14 #define NO_DSHOW_STRSAFE
15 #include <dshow.h>
16
17 #include <map>
18 #include <string>
19
20 #include "app/win/scoped_com_initializer.h"
21 #include "base/threading/thread.h"
22 #include "base/win/scoped_comptr.h"
23 #include "media/video/capture/video_capture_device.h"
24 #include "media/video/capture/win/sink_filter_win.h"
25
26 namespace media {
27
28 class VideoCaptureDeviceWin
29 : public VideoCaptureDevice,
30 public SinkFilter::SinkFilterObserver {
31 public:
32 explicit VideoCaptureDeviceWin(const Name& device_name);
33 virtual ~VideoCaptureDeviceWin();
34 // Opens the device driver for this device.
35 // This function is used by the static VideoCaptureDevice::Create function.
36 bool Init();
37
38 // VideoCaptureDevice implementation.
39 virtual void Allocate(int width,
40 int height,
41 int frame_rate,
42 VideoCaptureDevice::EventHandler* observer);
43 virtual void Start();
44 virtual void Stop();
45 virtual void DeAllocate();
46 virtual const Name& device_name();
47
48 private:
49 enum InternalState {
50 kIdle, // The device driver is opened but camera is not in use.
scherkus (not reviewing) 2011/06/24 20:15:26 nit: chromium typically uses kCamelCaseStyle for c
Per K 2011/06/27 11:47:50 Ok- Tommy commented on this as well. But "for cons
tommi (sloooow) - chröme 2011/06/27 13:20:37 (I just learned this) According to the style guide
scherkus (not reviewing) 2011/06/27 19:24:01 ok!
51 kAllocated, // The camera has been allocated and can be started.
52 kCapturing, // Video is being captured.
53 kError // Error accessing HW functions.
54 // User needs to recover by destroying the object.
55 };
56 typedef std::map<int, Capability> CapabilityMap;
57
58 // Implements SinkFilterObserver.
59 virtual void FrameReceived(const uint8* buffer, int length);
60
61 bool CreateCapabilityMap();
62 int GetBestMatchedCapability(int width, int height, int frame_rate);
63 void SetErrorState(const char* reason);
64
65 app::win::ScopedCOMInitializer initialize_com_;
66
67 Name device_name_;
68 InternalState state_;
69 VideoCaptureDevice::EventHandler* observer_;
70
71 base::win::ScopedComPtr<IBaseFilter> capture_filter_;
72 base::win::ScopedComPtr<IGraphBuilder> graph_builder_;
73 base::win::ScopedComPtr<IMediaControl> media_control_;
74 base::win::ScopedComPtr<IPin> input_sink_pin_;
75 base::win::ScopedComPtr<IPin> output_capture_pin_;
76 // Used when using a MJPEG decoder.
77 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_;
78 base::win::ScopedComPtr<IPin> input_mjpg_pin_;
79 base::win::ScopedComPtr<IPin> output_mjpg_pin_;
80
81 scoped_refptr<SinkFilter> sink_filter_;
82
83 // Map of all capabilities this device support.
84 CapabilityMap capabilities_;
85
86 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin);
87 };
88
89 } // namespace media
90
91 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698