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_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop/message_loop_proxy.h" | |
12 #include "base/threading/thread_checker.h" | |
11 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
12 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
13 #include "media/video/capture/video_capture_types.h" | 15 #include "media/video/capture/video_capture_types.h" |
14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" | 16 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 // WebRtcVideoCapturerAdapter implements a simple cricket::VideoCapturer that is | 20 // WebRtcVideoCapturerAdapter implements a simple cricket::VideoCapturer that is |
19 // used for VideoCapturing in libJingle and especially in PeerConnections. | 21 // used for VideoCapturing in libJingle and especially in PeerConnections. |
20 // The class is created and destroyed on the main render thread. | 22 // The class is created and destroyed on the main render thread. |
21 // PeerConnection access cricket::VideoCapturer from a libJingle worker thread. | 23 // PeerConnection access cricket::VideoCapturer from a libJingle worker thread. |
22 class CONTENT_EXPORT WebRtcVideoCapturerAdapter | 24 class CONTENT_EXPORT WebRtcVideoCapturerAdapter |
23 : NON_EXPORTED_BASE(public cricket::VideoCapturer) { | 25 : NON_EXPORTED_BASE(public cricket::VideoCapturer) { |
24 public: | 26 public: |
25 explicit WebRtcVideoCapturerAdapter(bool is_screencast); | 27 WebRtcVideoCapturerAdapter( |
28 const scoped_refptr<base::MessageLoopProxy>& worker_thread_proxy, | |
29 bool is_screencast); | |
26 virtual ~WebRtcVideoCapturerAdapter(); | 30 virtual ~WebRtcVideoCapturerAdapter(); |
27 | 31 |
32 // OnFrameCaptured delivers video frames to libjingle. It should be called on | |
tommi (sloooow) - chröme
2014/05/12 14:20:41
nit: It must be called on
(right?)
perkj_chrome
2014/05/12 15:39:51
Done.
| |
33 // libjingles worker thread. | |
28 // This method is virtual for testing purposes. | 34 // This method is virtual for testing purposes. |
29 virtual void OnFrameCaptured(const scoped_refptr<media::VideoFrame>& frame); | 35 virtual void OnFrameCaptured(const scoped_refptr<media::VideoFrame>& frame); |
30 | 36 |
31 private: | 37 private: |
32 // cricket::VideoCapturer implementation. | 38 // cricket::VideoCapturer implementation. |
33 // These methods are accessed from a libJingle worker thread. | 39 // These methods are accessed from a libJingle worker thread. |
34 virtual cricket::CaptureState Start( | 40 virtual cricket::CaptureState Start( |
35 const cricket::VideoFormat& capture_format) OVERRIDE; | 41 const cricket::VideoFormat& capture_format) OVERRIDE; |
36 virtual void Stop() OVERRIDE; | 42 virtual void Stop() OVERRIDE; |
37 virtual bool IsRunning() OVERRIDE; | 43 virtual bool IsRunning() OVERRIDE; |
38 virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) OVERRIDE; | 44 virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) OVERRIDE; |
39 virtual bool GetBestCaptureFormat(const cricket::VideoFormat& desired, | 45 virtual bool GetBestCaptureFormat(const cricket::VideoFormat& desired, |
40 cricket::VideoFormat* best_format) OVERRIDE; | 46 cricket::VideoFormat* best_format) OVERRIDE; |
41 virtual bool IsScreencast() const OVERRIDE; | 47 virtual bool IsScreencast() const OVERRIDE; |
42 | 48 |
43 void UpdateI420Buffer(const scoped_refptr<media::VideoFrame>& src); | 49 void UpdateI420Buffer(const scoped_refptr<media::VideoFrame>& src); |
44 | 50 |
45 private: | 51 private: |
52 // |thread_checker_| is bound to the main render thread. | |
53 base::ThreadChecker thread_checker_; | |
54 // |worker_thread_proxy_| is used to ensure methods are called on the | |
55 // libjingle worker thread. | |
56 scoped_refptr<base::MessageLoopProxy> worker_thread_proxy_; | |
57 | |
46 const bool is_screencast_; | 58 const bool is_screencast_; |
47 bool running_; | 59 bool running_; |
48 base::TimeDelta first_frame_timestamp_; | 60 base::TimeDelta first_frame_timestamp_; |
49 // |buffer_| used if cropping is needed. It is created only if needed and | 61 // |buffer_| used if cropping is needed. It is created only if needed and |
50 // owned by WebRtcVideoCapturerAdapter. If its created, it exists until | 62 // owned by WebRtcVideoCapturerAdapter. If its created, it exists until |
51 // WebRtcVideoCapturerAdapter is destroyed. | 63 // WebRtcVideoCapturerAdapter is destroyed. |
52 uint8* buffer_; | 64 uint8* buffer_; |
53 size_t buffer_size_; | 65 size_t buffer_size_; |
54 scoped_ptr<cricket::CapturedFrame> captured_frame_; | 66 scoped_ptr<cricket::CapturedFrame> captured_frame_; |
55 | 67 |
56 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoCapturerAdapter); | 68 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoCapturerAdapter); |
57 }; | 69 }; |
58 | 70 |
59 } // namespace content | 71 } // namespace content |
60 | 72 |
61 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ | 73 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ |
OLD | NEW |