OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Windows specific implementation of VideoCaptureDevice. |
| 6 // DirectShow is used for capturing. DirectShow provide its own threads |
| 7 // for capturing. |
| 8 |
| 9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
| 10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
| 11 |
| 12 #include <mfidl.h> |
| 13 #include <mfreadwrite.h> |
| 14 |
| 15 #include <vector> |
| 16 |
| 17 #include "base/synchronization/lock.h" |
| 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "base/win/scoped_comptr.h" |
| 20 #include "media/video/capture/video_capture_device.h" |
| 21 |
| 22 interface IMFSourceReader; |
| 23 |
| 24 namespace media { |
| 25 |
| 26 class MFReaderCallback; |
| 27 |
| 28 class VideoCaptureDeviceMFWin |
| 29 : public base::NonThreadSafe, |
| 30 public VideoCaptureDevice { |
| 31 public: |
| 32 explicit VideoCaptureDeviceMFWin(const Name& device_name); |
| 33 virtual ~VideoCaptureDeviceMFWin(); |
| 34 |
| 35 // Opens the device driver for this device. |
| 36 // This function is used by the static VideoCaptureDevice::Create function. |
| 37 bool Init(); |
| 38 |
| 39 // VideoCaptureDevice implementation. |
| 40 virtual void Allocate(int width, |
| 41 int height, |
| 42 int frame_rate, |
| 43 VideoCaptureDevice::EventHandler* observer) OVERRIDE; |
| 44 virtual void Start() OVERRIDE; |
| 45 virtual void Stop() OVERRIDE; |
| 46 virtual void DeAllocate() OVERRIDE; |
| 47 virtual const Name& device_name() OVERRIDE; |
| 48 |
| 49 static void GetDeviceNames(Names* device_names); |
| 50 |
| 51 // Captured a new video frame. |
| 52 void OnIncomingCapturedFrame(const uint8* data, int length, |
| 53 const base::Time& time_stamp); |
| 54 |
| 55 private: |
| 56 void OnError(HRESULT hr); |
| 57 |
| 58 Name name_; |
| 59 base::win::ScopedComPtr<IMFActivate> device_; |
| 60 scoped_refptr<MFReaderCallback> callback_; |
| 61 |
| 62 base::Lock lock_; // Used to guard the below variables. |
| 63 VideoCaptureDevice::EventHandler* observer_; |
| 64 base::win::ScopedComPtr<IMFSourceReader> reader_; |
| 65 bool capture_; |
| 66 |
| 67 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceMFWin); |
| 68 }; |
| 69 |
| 70 } // namespace media |
| 71 |
| 72 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
OLD | NEW |