Add ICU message format support
[chromium-blink-merge.git] / content / browser / renderer_host / media / video_capture_device_client.h
blob80b8ec4b1010634d0c5c42131ae093f24f6f5632
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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/common/content_export.h"
12 #include "media/capture/video/video_capture_device.h"
14 namespace content {
15 class VideoCaptureBufferPool;
16 class VideoCaptureController;
17 class VideoCaptureGpuJpegDecoder;
19 // Receives events from the VideoCaptureDevice and posts them to a |controller_|
20 // on the IO thread. An instance of this class may safely outlive its target
21 // VideoCaptureController. This is a shallow class meant to convert incoming
22 // frames and holds no significant state.
24 // Methods of this class may be called from any thread, and in practice will
25 // often be called on some auxiliary thread depending on the platform and the
26 // device type; including, for example, the DirectShow thread on Windows, the
27 // v4l2_thread on Linux, and the UI thread for tab capture.
29 // It has an internal ref counted TextureWrapHelper class used to wrap incoming
30 // GpuMemoryBuffers into Texture backed VideoFrames. This class creates and
31 // manages the necessary entities to interact with the GPU process, notably an
32 // offscreen Context to avoid janking the UI thread.
33 class CONTENT_EXPORT VideoCaptureDeviceClient
34 : public media::VideoCaptureDevice::Client,
35 public base::SupportsWeakPtr<VideoCaptureDeviceClient> {
36 public:
37 VideoCaptureDeviceClient(
38 const base::WeakPtr<VideoCaptureController>& controller,
39 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool,
40 const scoped_refptr<base::SingleThreadTaskRunner>& capture_task_runner);
41 ~VideoCaptureDeviceClient() override;
43 // VideoCaptureDevice::Client implementation.
44 void OnIncomingCapturedData(const uint8* data,
45 int length,
46 const media::VideoCaptureFormat& frame_format,
47 int rotation,
48 const base::TimeTicks& timestamp) override;
49 void OnIncomingCapturedYuvData(const uint8* y_data,
50 const uint8* u_data,
51 const uint8* v_data,
52 size_t y_stride,
53 size_t u_stride,
54 size_t v_stride,
55 const media::VideoCaptureFormat& frame_format,
56 int clockwise_rotation,
57 const base::TimeTicks& timestamp) override;
58 scoped_ptr<Buffer> ReserveOutputBuffer(
59 const gfx::Size& dimensions,
60 media::VideoCapturePixelFormat format,
61 media::VideoPixelStorage storage) override;
62 void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer,
63 const media::VideoCaptureFormat& frame_format,
64 const base::TimeTicks& timestamp) override;
65 void OnIncomingCapturedVideoFrame(
66 scoped_ptr<Buffer> buffer,
67 const scoped_refptr<media::VideoFrame>& frame,
68 const base::TimeTicks& timestamp) override;
69 void OnError(const std::string& reason) override;
70 void OnLog(const std::string& message) override;
71 double GetBufferPoolUtilization() const override;
73 private:
74 // The controller to which we post events.
75 const base::WeakPtr<VideoCaptureController> controller_;
77 // Hardware JPEG decoder.
78 scoped_ptr<VideoCaptureGpuJpegDecoder> external_jpeg_decoder_;
80 // Whether |external_jpeg_decoder_| has been initialized.
81 bool external_jpeg_decoder_initialized_;
83 // The pool of shared-memory buffers used for capturing.
84 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_;
86 // Internal delegate for GpuMemoryBuffer-into-VideoFrame wrapping.
87 class TextureWrapHelper;
88 scoped_refptr<TextureWrapHelper> texture_wrap_helper_;
89 // Reference to Capture Thread task runner, where |texture_wrap_helper_|
90 // lives.
91 const scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
93 media::VideoCapturePixelFormat last_captured_pixel_format_;
95 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient);
99 } // namespace content
101 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_