Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / media / capture / video / win / video_capture_device_mf_win.h
blobbaff97f3a36b28c32b9a9eb3f3a0d5f02c78cf36
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.
5 // Windows specific implementation of VideoCaptureDevice.
6 // DirectShow is used for capturing. DirectShow provide its own threads
7 // for capturing.
9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_
10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_
12 #include <mfidl.h>
13 #include <mfreadwrite.h>
15 #include <vector>
17 #include "base/synchronization/lock.h"
18 #include "base/threading/non_thread_safe.h"
19 #include "base/win/scoped_comptr.h"
20 #include "media/base/media_export.h"
21 #include "media/capture/video/video_capture_device.h"
23 interface IMFSourceReader;
25 namespace media {
27 class MFReaderCallback;
29 const DWORD kFirstVideoStream =
30 static_cast<DWORD>(MF_SOURCE_READER_FIRST_VIDEO_STREAM);
32 class MEDIA_EXPORT VideoCaptureDeviceMFWin : public base::NonThreadSafe,
33 public VideoCaptureDevice {
34 public:
35 static bool FormatFromGuid(const GUID& guid, VideoCapturePixelFormat* format);
37 explicit VideoCaptureDeviceMFWin(const Name& device_name);
38 ~VideoCaptureDeviceMFWin() override;
40 // Opens the device driver for this device.
41 bool Init(const base::win::ScopedComPtr<IMFMediaSource>& source);
43 // VideoCaptureDevice implementation.
44 void AllocateAndStart(const VideoCaptureParams& params,
45 scoped_ptr<VideoCaptureDevice::Client> client) override;
46 void StopAndDeAllocate() override;
48 // Captured new video data.
49 void OnIncomingCapturedData(const uint8* data,
50 int length,
51 int rotation,
52 const base::TimeTicks& time_stamp);
54 private:
55 void OnError(HRESULT hr);
57 Name name_;
58 base::win::ScopedComPtr<IMFActivate> device_;
59 scoped_refptr<MFReaderCallback> callback_;
61 base::Lock lock_; // Used to guard the below variables.
62 scoped_ptr<VideoCaptureDevice::Client> client_;
63 base::win::ScopedComPtr<IMFSourceReader> reader_;
64 VideoCaptureFormat capture_format_;
65 bool capture_;
67 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceMFWin);
70 } // namespace media
72 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_