| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_TEXTURE_WRAPPER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_TEXTURE_WRAPPER_H_ |
| 7 |
| 8 #include "base/memory/linked_ptr.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "content/browser/renderer_host/media/video_capture_device_client.h" |
| 13 #include "content/common/content_export.h" |
| 14 #include "media/video/capture/video_capture_device.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 // VideoCaptureDeviceClient derived class for copying incoming memory-backed |
| 19 // video data into a GpuMemoryBuffer (in turn into a VideoFrame), and sending it |
| 20 // to |controller_|. Construction happens on IO Thread, whereas calls to |
| 21 // OnIncomingCapturedData() come from wherever capture happens which might be, |
| 22 // and often is, an OS thread different from Device Thread. |
| 23 // |
| 24 // It has an internal ref counted TextureWrapperDelegate class used to do all |
| 25 // the work. This class creates and manages the necessary interactions with the |
| 26 // GPU process for the texture uploading. This delegate is needed since the |
| 27 // frame producer needs to own us, but we need to launch PostTask()s. |
| 28 // |
| 29 // TODO(mcasas): ctor |frame_format| is used for early GpuMemoryBuffer pool |
| 30 // allocation, but VideoCaptureDevices might provide a different resolution when |
| 31 // calling OnIncomingCapturedData(). What should we do then...? |
| 32 |
| 33 class CONTENT_EXPORT VideoCaptureTextureWrapper final |
| 34 : public VideoCaptureDeviceClient { |
| 35 public: |
| 36 VideoCaptureTextureWrapper( |
| 37 const base::WeakPtr<VideoCaptureController>& controller, |
| 38 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool, |
| 39 const scoped_refptr<base::SingleThreadTaskRunner>& capture_task_runner, |
| 40 const media::VideoCaptureFormat& capture_format); |
| 41 ~VideoCaptureTextureWrapper() override; |
| 42 |
| 43 // Single media::VideoCaptureDevice::Client overriden method. |
| 44 void OnIncomingCapturedData(const uint8* data, |
| 45 int length, |
| 46 const media::VideoCaptureFormat& frame_format, |
| 47 int clockwise_rotation, |
| 48 const base::TimeTicks& timestamp) override; |
| 49 |
| 50 private: |
| 51 class TextureWrapperDelegate; |
| 52 // Internal delegate doing most of the work. |
| 53 scoped_refptr<TextureWrapperDelegate> wrapper_delegate_; |
| 54 // Reference to Capture Thread task runner. |
| 55 const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(VideoCaptureTextureWrapper); |
| 58 }; |
| 59 |
| 60 } // namespace content |
| 61 |
| 62 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_TEXTURE_WRAPPER_H_ |
| OLD | NEW |