blob: 06fcdb311eef7dc97783b965ce38d3aef67f329f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Windows specific implementation of VideoCaptureDevice.
// DirectShow is used for capturing. DirectShow provide its own threads
// for capturing.
#ifndef MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_
#define MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_
#include <mfidl.h>
#include <mfreadwrite.h>
#include <stdint.h>
#include <vector>
#include "base/macros.h"
#include "base/sequence_checker.h"
#include "base/synchronization/lock.h"
#include "base/win/scoped_comptr.h"
#include "media/capture/capture_export.h"
#include "media/capture/video/video_capture_device.h"
interface IMFSourceReader;
namespace base {
class Location;
} // namespace base
namespace media {
class MFReaderCallback;
const DWORD kFirstVideoStream =
static_cast<DWORD>(MF_SOURCE_READER_FIRST_VIDEO_STREAM);
class CAPTURE_EXPORT VideoCaptureDeviceMFWin : public VideoCaptureDevice {
public:
static bool FormatFromGuid(const GUID& guid, VideoPixelFormat* format);
explicit VideoCaptureDeviceMFWin(
const VideoCaptureDeviceDescriptor& device_descriptor);
~VideoCaptureDeviceMFWin() override;
// Opens the device driver for this device.
bool Init(const base::win::ScopedComPtr<IMFMediaSource>& source);
// VideoCaptureDevice implementation.
void AllocateAndStart(
const VideoCaptureParams& params,
std::unique_ptr<VideoCaptureDevice::Client> client) override;
void StopAndDeAllocate() override;
// Captured new video data.
void OnIncomingCapturedData(const uint8_t* data,
int length,
int rotation,
base::TimeTicks reference_time,
base::TimeDelta timestamp);
private:
void OnError(const base::Location& from_here, HRESULT hr);
VideoCaptureDeviceDescriptor descriptor_;
base::win::ScopedComPtr<IMFActivate> device_;
scoped_refptr<MFReaderCallback> callback_;
base::Lock lock_; // Used to guard the below variables.
std::unique_ptr<VideoCaptureDevice::Client> client_;
base::win::ScopedComPtr<IMFSourceReader> reader_;
VideoCaptureFormat capture_format_;
bool capture_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceMFWin);
};
} // namespace media
#endif // MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_
|