| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "media/base/video_frame.h" | 16 #include "media/base/video_frame.h" |
| 17 #include "media/base/video_frame_pool.h" | 17 #include "media/base/video_frame_pool.h" |
| 18 #include "media/capture/video_capture_types.h" | 18 #include "media/capture/video_capture_types.h" |
| 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 19 #include "third_party/webrtc/media/base/videocapturer.h" | 20 #include "third_party/webrtc/media/base/videocapturer.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| 23 // WebRtcVideoCapturerAdapter implements a simple cricket::VideoCapturer that is | 24 // WebRtcVideoCapturerAdapter implements a simple cricket::VideoCapturer that is |
| 24 // used for VideoCapturing in libJingle and especially in PeerConnections. | 25 // used for VideoCapturing in libJingle and especially in PeerConnections. |
| 25 // The class is created and destroyed on the main render thread. | 26 // The class is created and destroyed on the main render thread. |
| 26 // PeerConnection access cricket::VideoCapturer from a libJingle worker thread. | 27 // PeerConnection access cricket::VideoCapturer from a libJingle worker thread. |
| 27 // An instance of WebRtcVideoCapturerAdapter is owned by an instance of | 28 // An instance of WebRtcVideoCapturerAdapter is owned by an instance of |
| 28 // webrtc::VideoTrackSourceInterface in libJingle. The implementation of | 29 // webrtc::VideoTrackSourceInterface in libJingle. The implementation of |
| 29 // webrtc::VideoTrackSourceInterface guarantees that this object is not deleted | 30 // webrtc::VideoTrackSourceInterface guarantees that this object is not deleted |
| 30 // while it is still used in libJingle. | 31 // while it is still used in libJingle. |
| 31 class CONTENT_EXPORT WebRtcVideoCapturerAdapter | 32 class CONTENT_EXPORT WebRtcVideoCapturerAdapter |
| 32 : NON_EXPORTED_BASE(public cricket::VideoCapturer) { | 33 : NON_EXPORTED_BASE(public cricket::VideoCapturer) { |
| 33 public: | 34 public: |
| 34 explicit WebRtcVideoCapturerAdapter(bool is_screencast); | 35 WebRtcVideoCapturerAdapter( |
| 36 bool is_screencast, |
| 37 blink::WebMediaStreamTrack::ContentHintType content_hint); |
| 35 ~WebRtcVideoCapturerAdapter() override; | 38 ~WebRtcVideoCapturerAdapter() override; |
| 36 | 39 |
| 37 // OnFrameCaptured delivers video frames to libjingle. It must be called on | 40 // OnFrameCaptured delivers video frames to libjingle. It must be called on |
| 38 // libjingles worker thread. | 41 // libjingles worker thread. |
| 39 // This method is virtual for testing purposes. | 42 // This method is virtual for testing purposes. |
| 40 virtual void OnFrameCaptured(const scoped_refptr<media::VideoFrame>& frame); | 43 virtual void OnFrameCaptured(const scoped_refptr<media::VideoFrame>& frame); |
| 41 | 44 |
| 45 void SetContentHint(blink::WebMediaStreamTrack::ContentHintType content_hint); |
| 46 |
| 42 private: | 47 private: |
| 43 // cricket::VideoCapturer implementation. | 48 // cricket::VideoCapturer implementation. |
| 44 // These methods are accessed from a libJingle worker thread. | 49 // These methods are accessed from a libJingle worker thread. |
| 45 cricket::CaptureState Start( | 50 cricket::CaptureState Start( |
| 46 const cricket::VideoFormat& capture_format) override; | 51 const cricket::VideoFormat& capture_format) override; |
| 47 void Stop() override; | 52 void Stop() override; |
| 48 bool IsRunning() override; | 53 bool IsRunning() override; |
| 49 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override; | 54 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override; |
| 50 bool GetBestCaptureFormat(const cricket::VideoFormat& desired, | 55 bool GetBestCaptureFormat(const cricket::VideoFormat& desired, |
| 51 cricket::VideoFormat* best_format) override; | 56 cricket::VideoFormat* best_format) override; |
| 52 bool IsScreencast() const override; | 57 bool IsScreencast() const override; |
| 53 | 58 |
| 59 bool ShouldAdaptResolution() const; |
| 60 |
| 54 // Helper class used for copying texture backed frames. | 61 // Helper class used for copying texture backed frames. |
| 55 class TextureFrameCopier; | 62 class TextureFrameCopier; |
| 56 const scoped_refptr<TextureFrameCopier> texture_copier_; | 63 const scoped_refptr<TextureFrameCopier> texture_copier_; |
| 57 | 64 |
| 58 // |thread_checker_| is bound to the libjingle worker thread. | 65 // |thread_checker_| is bound to the libjingle worker thread. |
| 59 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
| 60 | 67 |
| 61 const bool is_screencast_; | 68 const bool is_screencast_; |
| 69 blink::WebMediaStreamTrack::ContentHintType content_hint_; |
| 62 bool running_; | 70 bool running_; |
| 63 | 71 |
| 64 media::VideoFramePool scaled_frame_pool_; | 72 media::VideoFramePool scaled_frame_pool_; |
| 65 | 73 |
| 66 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoCapturerAdapter); | 74 DISALLOW_COPY_AND_ASSIGN(WebRtcVideoCapturerAdapter); |
| 67 }; | 75 }; |
| 68 | 76 |
| 69 } // namespace content | 77 } // namespace content |
| 70 | 78 |
| 71 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ | 79 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ |
| OLD | NEW |