[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / content / browser / renderer_host / media / video_capture_device_client.h
blob3abfb9575bf2521ac63db7aa5ef506dca2321bcf
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/video/capture/video_capture_device.h"
14 namespace content {
15 class VideoCaptureBufferPool;
16 class VideoCaptureController;
18 // Receives events from the VideoCaptureDevice and posts them to a |controller_|
19 // on the IO thread. An instance of this class may safely outlive its target
20 // VideoCaptureController. This is a shallow class meant to convert incoming
21 // frames and holds no significant state.
23 // Methods of this class may be called from any thread, and in practice will
24 // often be called on some auxiliary thread depending on the platform and the
25 // device type; including, for example, the DirectShow thread on Windows, the
26 // v4l2_thread on Linux, and the UI thread for tab capture.
27 class CONTENT_EXPORT VideoCaptureDeviceClient
28 : public media::VideoCaptureDevice::Client {
29 public:
30 VideoCaptureDeviceClient(
31 const base::WeakPtr<VideoCaptureController>& controller,
32 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool);
33 ~VideoCaptureDeviceClient() override;
35 // VideoCaptureDevice::Client implementation.
36 void OnIncomingCapturedData(const uint8* data,
37 int length,
38 const media::VideoCaptureFormat& frame_format,
39 int rotation,
40 const base::TimeTicks& timestamp) override;
41 void OnIncomingCapturedYuvData(const uint8* y_data,
42 const uint8* u_data,
43 const uint8* v_data,
44 size_t y_stride,
45 size_t u_stride,
46 size_t v_stride,
47 const media::VideoCaptureFormat& frame_format,
48 int clockwise_rotation,
49 const base::TimeTicks& timestamp) override;
50 scoped_refptr<Buffer> ReserveOutputBuffer(media::VideoFrame::Format format,
51 const gfx::Size& size) override;
52 void OnIncomingCapturedVideoFrame(
53 const scoped_refptr<Buffer>& buffer,
54 const scoped_refptr<media::VideoFrame>& frame,
55 const base::TimeTicks& timestamp) override;
56 void OnError(const std::string& reason) override;
57 void OnLog(const std::string& message) override;
59 private:
60 // The controller to which we post events.
61 const base::WeakPtr<VideoCaptureController> controller_;
63 // The pool of shared-memory buffers used for capturing.
64 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_;
66 media::VideoPixelFormat last_captured_pixel_format_;
68 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient);
72 } // namespace content
74 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEVICE_CLIENT_H_