OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_VIDEO_CAPTURE_MODULE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MODULE_IMPL_H_ |
6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MODULE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MODULE_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "media/video/capture/video_capture.h" | 10 #include "media/video/capture/video_capture.h" |
11 #include "third_party/webrtc/common_types.h" | 11 #include "third_party/webrtc/common_types.h" |
12 #include "third_party/webrtc/modules/video_capture/main/interface/video_capture_
defines.h" | 12 #include "third_party/webrtc/modules/video_capture/main/interface/video_capture_
defines.h" |
13 #include "third_party/webrtc/modules/video_capture/main/source/video_capture_imp
l.h" | 13 #include "third_party/webrtc/modules/video_capture/main/source/video_capture_imp
l.h" |
14 | 14 |
15 class VideoCaptureImplManager; | 15 class VideoCaptureImplManager; |
16 | 16 |
17 // An implementation of webrtc::VideoCaptureModule takes raw frames from video | 17 // An implementation of webrtc::VideoCaptureModule takes raw frames from video |
18 // capture engine and passed them to webrtc VideoEngine. | 18 // capture engine and passed them to webrtc VideoEngine. |
19 class VideoCaptureModuleImpl | 19 class VideoCaptureModuleImpl |
20 : public webrtc::videocapturemodule::VideoCaptureImpl, | 20 : public webrtc::videocapturemodule::VideoCaptureImpl, |
21 public media::VideoCapture::EventHandler { | 21 public media::VideoCapture::EventHandler { |
22 public: | 22 public: |
23 VideoCaptureModuleImpl(const media::VideoCaptureSessionId id, | 23 VideoCaptureModuleImpl(const media::VideoCaptureSessionId id, |
24 VideoCaptureImplManager* vc_manager); | 24 VideoCaptureImplManager* vc_manager); |
25 virtual ~VideoCaptureModuleImpl(); | 25 // Implement reference counting. This make it possible to reference the |
| 26 // object from both Chromium and WebRtc. |
| 27 virtual int32_t AddRef() OVERRIDE; |
| 28 virtual int32_t Release() OVERRIDE; |
26 | 29 |
27 // Override webrtc::videocapturemodule::VideoCaptureImpl implementation. | 30 // Override webrtc::videocapturemodule::VideoCaptureImpl implementation. |
28 virtual WebRtc_Word32 StartCapture( | 31 virtual WebRtc_Word32 StartCapture( |
29 const webrtc::VideoCaptureCapability& capability) OVERRIDE; | 32 const webrtc::VideoCaptureCapability& capability) OVERRIDE; |
30 virtual WebRtc_Word32 StopCapture() OVERRIDE; | 33 virtual WebRtc_Word32 StopCapture() OVERRIDE; |
31 virtual bool CaptureStarted() OVERRIDE; | 34 virtual bool CaptureStarted() OVERRIDE; |
32 virtual WebRtc_Word32 CaptureSettings( | 35 virtual WebRtc_Word32 CaptureSettings( |
33 webrtc::VideoCaptureCapability& settings) OVERRIDE; | 36 webrtc::VideoCaptureCapability& settings) OVERRIDE; |
34 | 37 |
35 // media::VideoCapture::EventHandler implementation. | 38 // media::VideoCapture::EventHandler implementation. |
36 virtual void OnStarted(media::VideoCapture* capture); | 39 virtual void OnStarted(media::VideoCapture* capture); |
37 virtual void OnStopped(media::VideoCapture* capture); | 40 virtual void OnStopped(media::VideoCapture* capture); |
38 virtual void OnPaused(media::VideoCapture* capture); | 41 virtual void OnPaused(media::VideoCapture* capture); |
39 virtual void OnError(media::VideoCapture* capture, int error_code); | 42 virtual void OnError(media::VideoCapture* capture, int error_code); |
40 virtual void OnBufferReady( | 43 virtual void OnBufferReady( |
41 media::VideoCapture* capture, | 44 media::VideoCapture* capture, |
42 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf); | 45 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf); |
43 virtual void OnDeviceInfoReceived( | 46 virtual void OnDeviceInfoReceived( |
44 media::VideoCapture* capture, | 47 media::VideoCapture* capture, |
45 const media::VideoCaptureParams& device_info); | 48 const media::VideoCaptureParams& device_info); |
46 | 49 |
47 private: | 50 private: |
| 51 virtual ~VideoCaptureModuleImpl(); |
48 void Init(); | 52 void Init(); |
49 | 53 |
50 void StartCaptureOnCaptureThread( | 54 void StartCaptureOnCaptureThread( |
51 const webrtc::VideoCaptureCapability& capability); | 55 const webrtc::VideoCaptureCapability& capability); |
52 void StopCaptureOnCaptureThread(); | 56 void StopCaptureOnCaptureThread(); |
53 void StartCaptureInternal(const webrtc::VideoCaptureCapability& capability); | 57 void StartCaptureInternal(const webrtc::VideoCaptureCapability& capability); |
54 | 58 |
55 void OnStoppedOnCaptureThread(media::VideoCapture* capture); | 59 void OnStoppedOnCaptureThread(media::VideoCapture* capture); |
56 void OnBufferReadyOnCaptureThread( | 60 void OnBufferReadyOnCaptureThread( |
57 media::VideoCapture* capture, | 61 media::VideoCapture* capture, |
(...skipping 11 matching lines...) Expand all Loading... |
69 WebRtc_UWord32 width_; | 73 WebRtc_UWord32 width_; |
70 WebRtc_UWord32 height_; | 74 WebRtc_UWord32 height_; |
71 WebRtc_Word32 frame_rate_; | 75 WebRtc_Word32 frame_rate_; |
72 webrtc::RawVideoType video_type_; | 76 webrtc::RawVideoType video_type_; |
73 webrtc::VideoCaptureCapability frameInfo_; | 77 webrtc::VideoCaptureCapability frameInfo_; |
74 base::Time start_time_; | 78 base::Time start_time_; |
75 // The video capture module generating raw frame data. | 79 // The video capture module generating raw frame data. |
76 media::VideoCapture* capture_engine_; | 80 media::VideoCapture* capture_engine_; |
77 bool pending_start_; | 81 bool pending_start_; |
78 webrtc::VideoCaptureCapability pending_cap_; | 82 webrtc::VideoCaptureCapability pending_cap_; |
| 83 int ref_count_; |
79 | 84 |
80 DISALLOW_COPY_AND_ASSIGN(VideoCaptureModuleImpl); | 85 DISALLOW_COPY_AND_ASSIGN(VideoCaptureModuleImpl); |
81 }; | 86 }; |
82 | 87 |
83 DISABLE_RUNNABLE_METHOD_REFCOUNT(VideoCaptureModuleImpl); | 88 DISABLE_RUNNABLE_METHOD_REFCOUNT(VideoCaptureModuleImpl); |
84 | 89 |
85 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MODULE_IMPL_H_ | 90 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_MODULE_IMPL_H_ |
OLD | NEW |