OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 const VideoCaptureDeliverFrameCB& new_frame_callback, | 39 const VideoCaptureDeliverFrameCB& new_frame_callback, |
40 scoped_refptr<base::SingleThreadTaskRunner> frame_callback_task_runner, | 40 scoped_refptr<base::SingleThreadTaskRunner> frame_callback_task_runner, |
41 const RunningCallback& running_callback) override; | 41 const RunningCallback& running_callback) override; |
42 | 42 |
43 void StopCapture() override; | 43 void StopCapture() override; |
44 | 44 |
45 private: | 45 private: |
46 FRIEND_TEST_ALL_PREFIXES(MediaStreamVideoCapturerSourceTest, Ended); | 46 FRIEND_TEST_ALL_PREFIXES(MediaStreamVideoCapturerSourceTest, Ended); |
47 friend class MockVideoCapturerDelegate; | 47 friend class MockVideoCapturerDelegate; |
48 | 48 |
49 void OnStateUpdateOnRenderThread(VideoCaptureState state); | 49 void OnStateUpdate(VideoCaptureState state); |
50 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats); | 50 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats); |
51 void OnDeviceSupportedFormatsEnumerated( | 51 void OnDeviceSupportedFormatsEnumerated( |
52 const media::VideoCaptureFormats& formats); | 52 const media::VideoCaptureFormats& formats); |
53 | 53 |
54 // The id identifies which video capture device is used for this video | 54 // The id identifies which video capture device is used for this video |
55 // capture session. | 55 // capture session. |
56 media::VideoCaptureSessionId session_id_; | 56 const media::VideoCaptureSessionId session_id_; |
57 base::Closure release_device_cb_; | 57 base::Closure release_device_cb_; |
58 base::Closure stop_capture_cb_; | 58 base::Closure stop_capture_cb_; |
59 | 59 |
60 bool is_screen_cast_; | 60 const bool is_screen_cast_; |
61 | 61 |
62 // |running_callback| is provided to this class in StartCapture and must be | 62 // |running_callback| is provided to this class in StartCapture and must be |
63 // valid until StopCapture is called. | 63 // valid until StopCapture is called. |
64 RunningCallback running_callback_; | 64 RunningCallback running_callback_; |
65 | 65 |
66 VideoCaptureDeviceFormatsCB source_formats_callback_; | 66 VideoCaptureDeviceFormatsCB source_formats_callback_; |
67 | 67 |
68 // Bound to the render thread. | 68 // Bound to the render thread. |
69 base::ThreadChecker thread_checker_; | 69 base::ThreadChecker thread_checker_; |
70 | 70 |
71 base::WeakPtrFactory<VideoCapturerDelegate> weak_factory_; | 71 base::WeakPtrFactory<VideoCapturerDelegate> weak_factory_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(VideoCapturerDelegate); | 73 DISALLOW_COPY_AND_ASSIGN(VideoCapturerDelegate); |
74 }; | 74 }; |
75 | 75 |
76 // Owned by WebMediaStreamSource in Blink as a representation of a video | 76 // Owned by WebMediaStreamSource in Blink as a representation of a video |
77 // stream coming from a camera. | 77 // stream coming from a camera. |
78 // This is a render thread only object. All methods must be called on the | 78 // This is a render thread only object. All methods must be called on the |
79 // render thread. | 79 // render thread. |
80 class CONTENT_EXPORT MediaStreamVideoCapturerSource | 80 class CONTENT_EXPORT MediaStreamVideoCapturerSource |
81 : public MediaStreamVideoSource { | 81 : public MediaStreamVideoSource { |
82 public: | 82 public: |
83 MediaStreamVideoCapturerSource( | 83 MediaStreamVideoCapturerSource( |
84 const SourceStoppedCallback& stop_callback, | 84 const SourceStoppedCallback& stop_callback, |
85 scoped_ptr<media::VideoCapturerSource> delegate); | 85 scoped_ptr<media::VideoCapturerSource> delegate); |
86 | |
87 virtual ~MediaStreamVideoCapturerSource(); | 86 virtual ~MediaStreamVideoCapturerSource(); |
88 | 87 |
89 void SetDeviceInfo(const StreamDeviceInfo& device_info); | 88 void SetDeviceInfo(const StreamDeviceInfo& device_info); |
90 | 89 |
91 protected: | 90 protected: |
92 // Implements MediaStreamVideoSource. | 91 // Implements MediaStreamVideoSource. |
93 void GetCurrentSupportedFormats( | 92 void GetCurrentSupportedFormats( |
94 int max_requested_width, | 93 int max_requested_width, |
95 int max_requested_height, | 94 int max_requested_height, |
96 double max_requested_frame_rate, | 95 double max_requested_frame_rate, |
97 const VideoCaptureDeviceFormatsCB& callback) override; | 96 const VideoCaptureDeviceFormatsCB& callback) override; |
98 | 97 |
99 void StartSourceImpl( | 98 void StartSourceImpl( |
100 const media::VideoCaptureFormat& format, | 99 const media::VideoCaptureFormat& format, |
101 const VideoCaptureDeliverFrameCB& frame_callback) override; | 100 const VideoCaptureDeliverFrameCB& frame_callback) override; |
102 | 101 |
103 void StopSourceImpl() override; | 102 void StopSourceImpl() override; |
104 | 103 |
105 private: | 104 private: |
106 void OnStarted(bool result); | 105 void OnStarted(bool result); |
107 // The delegate that provides video frames. | 106 // The delegate that provides video frames. |
108 scoped_ptr<media::VideoCapturerSource> delegate_; | 107 const scoped_ptr<media::VideoCapturerSource> delegate_; |
109 | 108 |
110 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); | 109 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); |
111 }; | 110 }; |
112 | 111 |
113 } // namespace content | 112 } // namespace content |
114 | 113 |
115 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ | 114 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ |
OLD | NEW |