| 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. DirectShow is used for | 5 // Windows specific implementation of VideoCaptureDevice. DirectShow is used for |
| 6 // capturing. DirectShow provide its own threads for capturing. | 6 // capturing. DirectShow provide its own threads for capturing. |
| 7 | 7 |
| 8 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 8 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
| 9 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 9 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
| 10 | 10 |
| 11 // Avoid including strsafe.h via dshow as it will cause build warnings. | 11 // Avoid including strsafe.h via dshow as it will cause build warnings. |
| 12 #define NO_DSHOW_STRSAFE | 12 #define NO_DSHOW_STRSAFE |
| 13 #include <dshow.h> | 13 #include <dshow.h> |
| 14 | 14 |
| 15 #include <map> | 15 #include <map> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "base/win/scoped_comptr.h" | 19 #include "base/win/scoped_comptr.h" |
| 20 #include "media/base/video_capture_types.h" | 20 #include "media/base/video_capture_types.h" |
| 21 #include "media/capture/video/video_capture_device.h" | 21 #include "media/capture/video/video_capture_device.h" |
| 22 #include "media/capture/video/win/capability_list_win.h" | 22 #include "media/capture/video/win/capability_list_win.h" |
| 23 #include "media/capture/video/win/sink_filter_win.h" | 23 #include "media/capture/video/win/sink_filter_win.h" |
| 24 #include "media/capture/video/win/sink_input_pin_win.h" | 24 #include "media/capture/video/win/sink_input_pin_win.h" |
| 25 | 25 |
| 26 namespace tracked_objects { |
| 27 class Location; |
| 28 } // namespace tracked_objects |
| 29 |
| 26 namespace media { | 30 namespace media { |
| 27 | 31 |
| 28 // All the methods in the class can only be run on a COM initialized thread. | 32 // All the methods in the class can only be run on a COM initialized thread. |
| 29 class VideoCaptureDeviceWin : public VideoCaptureDevice, | 33 class VideoCaptureDeviceWin : public VideoCaptureDevice, |
| 30 public SinkFilterObserver { | 34 public SinkFilterObserver { |
| 31 public: | 35 public: |
| 32 // A utility class that wraps the AM_MEDIA_TYPE type and guarantees that | 36 // A utility class that wraps the AM_MEDIA_TYPE type and guarantees that |
| 33 // we free the structure when exiting the scope. DCHECKing is also done to | 37 // we free the structure when exiting the scope. DCHECKing is also done to |
| 34 // avoid memory leaks. | 38 // avoid memory leaks. |
| 35 class ScopedMediaType { | 39 class ScopedMediaType { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 kError // Error accessing HW functions. | 79 kError // Error accessing HW functions. |
| 76 // User needs to recover by destroying the object. | 80 // User needs to recover by destroying the object. |
| 77 }; | 81 }; |
| 78 | 82 |
| 79 // Implements SinkFilterObserver. | 83 // Implements SinkFilterObserver. |
| 80 void FrameReceived(const uint8* buffer, int length, | 84 void FrameReceived(const uint8* buffer, int length, |
| 81 base::TimeTicks timestamp) override; | 85 base::TimeTicks timestamp) override; |
| 82 | 86 |
| 83 bool CreateCapabilityMap(); | 87 bool CreateCapabilityMap(); |
| 84 void SetAntiFlickerInCaptureFilter(const VideoCaptureParams& params); | 88 void SetAntiFlickerInCaptureFilter(const VideoCaptureParams& params); |
| 85 void SetErrorState(const std::string& reason); | 89 void SetErrorState(const tracked_objects::Location& from_here, |
| 90 const std::string& reason); |
| 86 | 91 |
| 87 const Name device_name_; | 92 const Name device_name_; |
| 88 InternalState state_; | 93 InternalState state_; |
| 89 scoped_ptr<VideoCaptureDevice::Client> client_; | 94 scoped_ptr<VideoCaptureDevice::Client> client_; |
| 90 | 95 |
| 91 base::win::ScopedComPtr<IBaseFilter> capture_filter_; | 96 base::win::ScopedComPtr<IBaseFilter> capture_filter_; |
| 92 | 97 |
| 93 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; | 98 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; |
| 94 base::win::ScopedComPtr<ICaptureGraphBuilder2> capture_graph_builder_; | 99 base::win::ScopedComPtr<ICaptureGraphBuilder2> capture_graph_builder_; |
| 95 | 100 |
| 96 base::win::ScopedComPtr<IMediaControl> media_control_; | 101 base::win::ScopedComPtr<IMediaControl> media_control_; |
| 97 base::win::ScopedComPtr<IPin> input_sink_pin_; | 102 base::win::ScopedComPtr<IPin> input_sink_pin_; |
| 98 base::win::ScopedComPtr<IPin> output_capture_pin_; | 103 base::win::ScopedComPtr<IPin> output_capture_pin_; |
| 99 | 104 |
| 100 scoped_refptr<SinkFilter> sink_filter_; | 105 scoped_refptr<SinkFilter> sink_filter_; |
| 101 | 106 |
| 102 // Map of all capabilities this device support. | 107 // Map of all capabilities this device support. |
| 103 CapabilityList capabilities_; | 108 CapabilityList capabilities_; |
| 104 VideoCaptureFormat capture_format_; | 109 VideoCaptureFormat capture_format_; |
| 105 | 110 |
| 106 base::ThreadChecker thread_checker_; | 111 base::ThreadChecker thread_checker_; |
| 107 | 112 |
| 108 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); | 113 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); |
| 109 }; | 114 }; |
| 110 | 115 |
| 111 } // namespace media | 116 } // namespace media |
| 112 | 117 |
| 113 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 118 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
| OLD | NEW |