OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_RELAY_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_RELAY_H_ |
| 7 |
| 8 #include "base/threading/thread.h" |
| 9 #include "base/time.h" |
| 10 #include "content/common/content_export.h" |
| 11 #include "media/base/video_frame.h" |
| 12 #include "media/video/capture/video_capture.h" |
| 13 #include "webkit/media/video_frame_provider.h" |
| 14 |
| 15 namespace base { |
| 16 class MessageLoopProxy; |
| 17 } |
| 18 class VideoCaptureImplManager; |
| 19 |
| 20 // Takes raw frames from video capture engine and passes them to media |
| 21 // player as a video frame provider. |
| 22 class CONTENT_EXPORT VideoCaptureRelay |
| 23 : public webkit_media::VideoFrameProvider, |
| 24 public media::VideoCapture::EventHandler { |
| 25 public: |
| 26 VideoCaptureRelay( |
| 27 media::VideoCaptureSessionId video_stream_id, |
| 28 VideoCaptureImplManager* vc_manager, |
| 29 const media::VideoCaptureCapability& capability, |
| 30 const base::Closure& paint_cb); |
| 31 virtual ~VideoCaptureRelay(); |
| 32 |
| 33 // webkit_media::VideoFrameProvider implementation. |
| 34 virtual void Start() OVERRIDE; |
| 35 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 36 virtual void GetCurrentFrame( |
| 37 scoped_refptr<media::VideoFrame>* frame_out) OVERRIDE; |
| 38 virtual void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame) OVERRIDE; |
| 39 |
| 40 // VideoCapture::EventHandler implementation. |
| 41 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; |
| 42 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; |
| 43 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; |
| 44 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; |
| 45 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; |
| 46 virtual void OnBufferReady( |
| 47 media::VideoCapture* capture, |
| 48 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) OVERRIDE; |
| 49 virtual void OnDeviceInfoReceived( |
| 50 media::VideoCapture* capture, |
| 51 const media::VideoCaptureParams& device_info) OVERRIDE; |
| 52 |
| 53 private: |
| 54 friend class VideoCaptureRelayTest; |
| 55 |
| 56 void StartOnRelayThread(); |
| 57 void StopOnRelayThread(const base::Closure& callback); |
| 58 |
| 59 void OnStoppedOnRelayThread(media::VideoCapture* capture); |
| 60 void OnBufferReadyOnRelayThread( |
| 61 media::VideoCapture* capture, |
| 62 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf); |
| 63 void OnDeviceInfoReceivedOnRelayThread( |
| 64 media::VideoCapture* capture, |
| 65 const media::VideoCaptureParams& device_info); |
| 66 |
| 67 base::Thread thread_; |
| 68 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| 69 base::Lock lock_; |
| 70 scoped_refptr<VideoCaptureImplManager> vc_manager_; |
| 71 media::VideoCaptureCapability capability_; |
| 72 bool is_active_; |
| 73 base::Closure pending_stop_cb_; |
| 74 bool pending_paint_; |
| 75 base::Closure paint_cb_; |
| 76 scoped_refptr<media::VideoFrame> current_frame_; |
| 77 |
| 78 media::VideoCaptureSessionId video_stream_id_; |
| 79 media::VideoCapture* capture_engine_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(VideoCaptureRelay); |
| 82 }; |
| 83 |
| 84 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_RELAY_H_ |
OLD | NEW |