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 // 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_MF_WIN_H_ | 9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ | 10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
(...skipping 12 matching lines...) Expand all Loading... |
23 interface IMFSourceReader; | 23 interface IMFSourceReader; |
24 | 24 |
25 namespace media { | 25 namespace media { |
26 | 26 |
27 class MFReaderCallback; | 27 class MFReaderCallback; |
28 | 28 |
29 class MEDIA_EXPORT VideoCaptureDeviceMFWin | 29 class MEDIA_EXPORT VideoCaptureDeviceMFWin |
30 : public base::NonThreadSafe, | 30 : public base::NonThreadSafe, |
31 public VideoCaptureDevice { | 31 public VideoCaptureDevice { |
32 public: | 32 public: |
| 33 static bool FormatFromGuid(const GUID& guid, VideoPixelFormat* format); |
| 34 |
33 explicit VideoCaptureDeviceMFWin(const Name& device_name); | 35 explicit VideoCaptureDeviceMFWin(const Name& device_name); |
34 virtual ~VideoCaptureDeviceMFWin(); | 36 virtual ~VideoCaptureDeviceMFWin(); |
35 | 37 |
36 // Opens the device driver for this device. | 38 // Opens the device driver for this device. |
37 // This function is used by the static VideoCaptureDevice::Create function. | 39 bool Init(const base::win::ScopedComPtr<IMFMediaSource>& source); |
38 bool Init(); | |
39 | 40 |
40 // VideoCaptureDevice implementation. | 41 // VideoCaptureDevice implementation. |
41 virtual void AllocateAndStart(const VideoCaptureParams& params, | 42 virtual void AllocateAndStart(const VideoCaptureParams& params, |
42 scoped_ptr<VideoCaptureDevice::Client> client) | 43 scoped_ptr<VideoCaptureDevice::Client> client) |
43 OVERRIDE; | 44 OVERRIDE; |
44 virtual void StopAndDeAllocate() OVERRIDE; | 45 virtual void StopAndDeAllocate() OVERRIDE; |
45 | 46 |
46 // Returns true iff the current platform supports the Media Foundation API | |
47 // and that the DLLs are available. On Vista this API is an optional download | |
48 // but the API is advertised as a part of Windows 7 and onwards. However, | |
49 // we've seen that the required DLLs are not available in some Win7 | |
50 // distributions such as Windows 7 N and Windows 7 KN. | |
51 static bool PlatformSupported(); | |
52 | |
53 static void GetDeviceNames(Names* device_names); | |
54 | |
55 static void GetDeviceSupportedFormats(const Name& device, | |
56 VideoCaptureFormats* formats); | |
57 | |
58 // Captured new video data. | 47 // Captured new video data. |
59 void OnIncomingCapturedData(const uint8* data, | 48 void OnIncomingCapturedData(const uint8* data, |
60 int length, | 49 int length, |
61 int rotation, | 50 int rotation, |
62 const base::TimeTicks& time_stamp); | 51 const base::TimeTicks& time_stamp); |
63 | 52 |
64 private: | 53 private: |
65 void OnError(HRESULT hr); | 54 void OnError(HRESULT hr); |
66 | 55 |
67 Name name_; | 56 Name name_; |
68 base::win::ScopedComPtr<IMFActivate> device_; | 57 base::win::ScopedComPtr<IMFActivate> device_; |
69 scoped_refptr<MFReaderCallback> callback_; | 58 scoped_refptr<MFReaderCallback> callback_; |
70 | 59 |
71 base::Lock lock_; // Used to guard the below variables. | 60 base::Lock lock_; // Used to guard the below variables. |
72 scoped_ptr<VideoCaptureDevice::Client> client_; | 61 scoped_ptr<VideoCaptureDevice::Client> client_; |
73 base::win::ScopedComPtr<IMFSourceReader> reader_; | 62 base::win::ScopedComPtr<IMFSourceReader> reader_; |
74 VideoCaptureFormat capture_format_; | 63 VideoCaptureFormat capture_format_; |
75 bool capture_; | 64 bool capture_; |
76 | 65 |
77 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceMFWin); | 66 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceMFWin); |
78 }; | 67 }; |
79 | 68 |
80 } // namespace media | 69 } // namespace media |
81 | 70 |
82 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ | 71 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
OLD | NEW |