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 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ |
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ | 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "content/common/media/video_capture.h" | 10 #include "content/common/media/video_capture.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 : public base::RefCountedThreadSafe<RtcVideoCaptureDelegate>, | 22 : public base::RefCountedThreadSafe<RtcVideoCaptureDelegate>, |
23 public media::VideoCapture::EventHandler { | 23 public media::VideoCapture::EventHandler { |
24 public: | 24 public: |
25 enum CaptureState { | 25 enum CaptureState { |
26 CAPTURE_STOPPED, // The capturer has been stopped or hasn't started yet. | 26 CAPTURE_STOPPED, // The capturer has been stopped or hasn't started yet. |
27 CAPTURE_RUNNING, // The capturer has been started successfully and is now | 27 CAPTURE_RUNNING, // The capturer has been started successfully and is now |
28 // capturing. | 28 // capturing. |
29 CAPTURE_FAILED, // The capturer failed to start. | 29 CAPTURE_FAILED, // The capturer failed to start. |
30 }; | 30 }; |
31 | 31 |
32 typedef base::Callback<void(const media::VideoCapture::VideoFrameBuffer& buf)> | 32 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>&)> |
33 FrameCapturedCallback; | 33 FrameCapturedCallback; |
34 typedef base::Callback<void(CaptureState state)> StateChangeCallback; | 34 typedef base::Callback<void(CaptureState)> StateChangeCallback; |
35 | 35 |
36 RtcVideoCaptureDelegate(const media::VideoCaptureSessionId id, | 36 RtcVideoCaptureDelegate(const media::VideoCaptureSessionId id, |
37 VideoCaptureImplManager* vc_manager); | 37 VideoCaptureImplManager* vc_manager); |
38 | 38 |
39 void StartCapture(const media::VideoCaptureCapability& capability, | 39 void StartCapture(const media::VideoCaptureCapability& capability, |
40 const FrameCapturedCallback& captured_callback, | 40 const FrameCapturedCallback& captured_callback, |
41 const StateChangeCallback& state_callback); | 41 const StateChangeCallback& state_callback); |
42 void StopCapture(); | 42 void StopCapture(); |
43 | 43 |
44 // media::VideoCapture::EventHandler implementation. | 44 // media::VideoCapture::EventHandler implementation. |
45 // These functions are called from a thread owned by |vc_manager_|. | 45 // These functions are called from a thread owned by |vc_manager_|. |
46 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; | 46 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; |
47 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; | 47 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; |
48 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; | 48 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; |
49 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; | 49 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; |
50 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; | 50 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; |
51 virtual void OnBufferReady( | 51 virtual void OnFrameReady( |
52 media::VideoCapture* capture, | 52 media::VideoCapture* capture, |
53 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) OVERRIDE; | 53 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; |
54 virtual void OnDeviceInfoReceived( | 54 virtual void OnDeviceInfoReceived( |
55 media::VideoCapture* capture, | 55 media::VideoCapture* capture, |
56 const media::VideoCaptureParams& device_info) OVERRIDE; | 56 const media::VideoCaptureParams& device_info) OVERRIDE; |
57 virtual void OnDeviceInfoChanged( | 57 virtual void OnDeviceInfoChanged( |
58 media::VideoCapture* capture, | 58 media::VideoCapture* capture, |
59 const media::VideoCaptureParams& device_info) OVERRIDE; | 59 const media::VideoCaptureParams& device_info) OVERRIDE; |
60 | 60 |
61 private: | 61 private: |
62 friend class base::RefCountedThreadSafe<RtcVideoCaptureDelegate>; | 62 friend class base::RefCountedThreadSafe<RtcVideoCaptureDelegate>; |
63 | 63 |
64 virtual ~RtcVideoCaptureDelegate(); | 64 virtual ~RtcVideoCaptureDelegate(); |
65 | 65 |
66 void OnBufferReadyOnCaptureThread( | 66 void OnFrameReadyOnCaptureThread( |
67 media::VideoCapture* capture, | 67 media::VideoCapture* capture, |
68 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf); | 68 const scoped_refptr<media::VideoFrame>& frame); |
69 void OnErrorOnCaptureThread(media::VideoCapture* capture); | 69 void OnErrorOnCaptureThread(media::VideoCapture* capture); |
70 void OnRemovedOnCaptureThread(media::VideoCapture* capture); | 70 void OnRemovedOnCaptureThread(media::VideoCapture* capture); |
71 | 71 |
72 // The id identifies which video capture device is used for this video | 72 // The id identifies which video capture device is used for this video |
73 // capture session. | 73 // capture session. |
74 media::VideoCaptureSessionId session_id_; | 74 media::VideoCaptureSessionId session_id_; |
75 // The video capture manager handles open/close of video capture devices. | 75 // The video capture manager handles open/close of video capture devices. |
76 scoped_refptr<VideoCaptureImplManager> vc_manager_; | 76 scoped_refptr<VideoCaptureImplManager> vc_manager_; |
77 media::VideoCapture* capture_engine_; | 77 media::VideoCapture* capture_engine_; |
78 | 78 |
79 // Accessed on the thread where StartCapture is called. | 79 // Accessed on the thread where StartCapture is called. |
80 bool got_first_frame_; | 80 bool got_first_frame_; |
81 bool error_occured_; | 81 bool error_occured_; |
82 | 82 |
83 // |captured_callback_| is provided to this class in StartCapture and must be | 83 // |captured_callback_| is provided to this class in StartCapture and must be |
84 // valid until StopCapture is called. | 84 // valid until StopCapture is called. |
85 FrameCapturedCallback captured_callback_; | 85 FrameCapturedCallback captured_callback_; |
86 // |state_callback_| is provided to this class in StartCapture and must be | 86 // |state_callback_| is provided to this class in StartCapture and must be |
87 // valid until StopCapture is called. | 87 // valid until StopCapture is called. |
88 StateChangeCallback state_callback_; | 88 StateChangeCallback state_callback_; |
89 // Message loop of the caller of StartCapture. | 89 // Message loop of the caller of StartCapture. |
90 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 90 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
91 }; | 91 }; |
92 | 92 |
93 } // namespace content | 93 } // namespace content |
94 | 94 |
95 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ | 95 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ |
OLD | NEW |