| 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_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ | 9 #ifndef MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
| 10 #define MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ | 10 #define MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 class MFReaderCallback; | 33 class MFReaderCallback; |
| 34 | 34 |
| 35 const DWORD kFirstVideoStream = | 35 const DWORD kFirstVideoStream = |
| 36 static_cast<DWORD>(MF_SOURCE_READER_FIRST_VIDEO_STREAM); | 36 static_cast<DWORD>(MF_SOURCE_READER_FIRST_VIDEO_STREAM); |
| 37 | 37 |
| 38 class CAPTURE_EXPORT VideoCaptureDeviceMFWin : public base::NonThreadSafe, | 38 class CAPTURE_EXPORT VideoCaptureDeviceMFWin : public base::NonThreadSafe, |
| 39 public VideoCaptureDevice { | 39 public VideoCaptureDevice { |
| 40 public: | 40 public: |
| 41 static bool FormatFromGuid(const GUID& guid, VideoPixelFormat* format); | 41 static bool FormatFromGuid(const GUID& guid, VideoPixelFormat* format); |
| 42 | 42 |
| 43 explicit VideoCaptureDeviceMFWin(const Name& device_name); | 43 explicit VideoCaptureDeviceMFWin( |
| 44 const VideoCaptureDeviceDescriptor& device_descriptor); |
| 44 ~VideoCaptureDeviceMFWin() override; | 45 ~VideoCaptureDeviceMFWin() override; |
| 45 | 46 |
| 46 // Opens the device driver for this device. | 47 // Opens the device driver for this device. |
| 47 bool Init(const base::win::ScopedComPtr<IMFMediaSource>& source); | 48 bool Init(const base::win::ScopedComPtr<IMFMediaSource>& source); |
| 48 | 49 |
| 49 // VideoCaptureDevice implementation. | 50 // VideoCaptureDevice implementation. |
| 50 void AllocateAndStart( | 51 void AllocateAndStart( |
| 51 const VideoCaptureParams& params, | 52 const VideoCaptureParams& params, |
| 52 std::unique_ptr<VideoCaptureDevice::Client> client) override; | 53 std::unique_ptr<VideoCaptureDevice::Client> client) override; |
| 53 void StopAndDeAllocate() override; | 54 void StopAndDeAllocate() override; |
| 54 | 55 |
| 55 // Captured new video data. | 56 // Captured new video data. |
| 56 void OnIncomingCapturedData(const uint8_t* data, | 57 void OnIncomingCapturedData(const uint8_t* data, |
| 57 int length, | 58 int length, |
| 58 int rotation, | 59 int rotation, |
| 59 base::TimeTicks reference_time, | 60 base::TimeTicks reference_time, |
| 60 base::TimeDelta timestamp); | 61 base::TimeDelta timestamp); |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 void OnError(const tracked_objects::Location& from_here, HRESULT hr); | 64 void OnError(const tracked_objects::Location& from_here, HRESULT hr); |
| 64 | 65 |
| 65 Name name_; | 66 VideoCaptureDeviceDescriptor descriptor_; |
| 66 base::win::ScopedComPtr<IMFActivate> device_; | 67 base::win::ScopedComPtr<IMFActivate> device_; |
| 67 scoped_refptr<MFReaderCallback> callback_; | 68 scoped_refptr<MFReaderCallback> callback_; |
| 68 | 69 |
| 69 base::Lock lock_; // Used to guard the below variables. | 70 base::Lock lock_; // Used to guard the below variables. |
| 70 std::unique_ptr<VideoCaptureDevice::Client> client_; | 71 std::unique_ptr<VideoCaptureDevice::Client> client_; |
| 71 base::win::ScopedComPtr<IMFSourceReader> reader_; | 72 base::win::ScopedComPtr<IMFSourceReader> reader_; |
| 72 VideoCaptureFormat capture_format_; | 73 VideoCaptureFormat capture_format_; |
| 73 bool capture_; | 74 bool capture_; |
| 74 | 75 |
| 75 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceMFWin); | 76 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceMFWin); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace media | 79 } // namespace media |
| 79 | 80 |
| 80 #endif // MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ | 81 #endif // MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_MF_WIN_H_ |
| OLD | NEW |