OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class CAPTURE_EXPORT VideoCaptureDeviceClient | 42 class CAPTURE_EXPORT VideoCaptureDeviceClient |
43 : public media::VideoCaptureDevice::Client, | 43 : public media::VideoCaptureDevice::Client, |
44 public base::SupportsWeakPtr<VideoCaptureDeviceClient> { | 44 public base::SupportsWeakPtr<VideoCaptureDeviceClient> { |
45 public: | 45 public: |
46 VideoCaptureDeviceClient( | 46 VideoCaptureDeviceClient( |
47 std::unique_ptr<VideoFrameReceiver> receiver, | 47 std::unique_ptr<VideoFrameReceiver> receiver, |
48 scoped_refptr<VideoCaptureBufferPool> buffer_pool, | 48 scoped_refptr<VideoCaptureBufferPool> buffer_pool, |
49 const VideoCaptureJpegDecoderFactoryCB& jpeg_decoder_factory); | 49 const VideoCaptureJpegDecoderFactoryCB& jpeg_decoder_factory); |
50 ~VideoCaptureDeviceClient() override; | 50 ~VideoCaptureDeviceClient() override; |
51 | 51 |
52 static Buffer MakeBufferStruct( | |
53 scoped_refptr<VideoCaptureBufferPool> buffer_pool, | |
54 int buffer_id, | |
55 int frame_feedback_id); | |
56 | |
57 // VideoCaptureDevice::Client implementation. | 52 // VideoCaptureDevice::Client implementation. |
58 void OnIncomingCapturedData(const uint8_t* data, | 53 void OnIncomingCapturedData(const uint8_t* data, |
59 int length, | 54 int length, |
60 const media::VideoCaptureFormat& frame_format, | 55 const media::VideoCaptureFormat& frame_format, |
61 int rotation, | 56 int rotation, |
62 base::TimeTicks reference_time, | 57 base::TimeTicks reference_time, |
63 base::TimeDelta timestamp, | 58 base::TimeDelta timestamp, |
64 int frame_feedback_id = 0) override; | 59 int frame_feedback_id = 0) override; |
65 Buffer ReserveOutputBuffer(const gfx::Size& dimensions, | 60 std::unique_ptr<Buffer> ReserveOutputBuffer(const gfx::Size& dimensions, |
66 media::VideoPixelFormat format, | 61 media::VideoPixelFormat format, |
67 media::VideoPixelStorage storage, | 62 media::VideoPixelStorage storage, |
68 int frame_feedback_id) override; | 63 int frame_feedback_id) override; |
69 void OnIncomingCapturedBuffer(Buffer buffer, | 64 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
70 const VideoCaptureFormat& format, | 65 const VideoCaptureFormat& format, |
71 base::TimeTicks reference_time, | 66 base::TimeTicks reference_time, |
72 base::TimeDelta timestamp) override; | 67 base::TimeDelta timestamp) override; |
73 void OnIncomingCapturedBufferExt( | 68 void OnIncomingCapturedBufferExt( |
74 Buffer buffer, | 69 std::unique_ptr<Buffer> buffer, |
75 const VideoCaptureFormat& format, | 70 const VideoCaptureFormat& format, |
76 base::TimeTicks reference_time, | 71 base::TimeTicks reference_time, |
77 base::TimeDelta timestamp, | 72 base::TimeDelta timestamp, |
78 gfx::Rect visible_rect, | 73 gfx::Rect visible_rect, |
79 const VideoFrameMetadata& additional_metadata) override; | 74 const VideoFrameMetadata& additional_metadata) override; |
80 Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions, | 75 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( |
81 media::VideoPixelFormat format, | 76 const gfx::Size& dimensions, |
82 media::VideoPixelStorage storage, | 77 media::VideoPixelFormat format, |
83 int new_frame_feedback_id) override; | 78 media::VideoPixelStorage storage, |
| 79 int new_frame_feedback_id) override; |
84 void OnError(const tracked_objects::Location& from_here, | 80 void OnError(const tracked_objects::Location& from_here, |
85 const std::string& reason) override; | 81 const std::string& reason) override; |
86 void OnLog(const std::string& message) override; | 82 void OnLog(const std::string& message) override; |
87 double GetBufferPoolUtilization() const override; | 83 double GetBufferPoolUtilization() const override; |
88 | 84 |
89 private: | 85 private: |
90 void InitializeI420PlanePointers(const gfx::Size& dimensions, | 86 // Reserve output buffer into which I420 contents can be copied directly. |
91 uint8_t* const data, | 87 // The dimensions of the frame is described by |dimensions|, and requested |
92 uint8_t** y_plane_data, | 88 // output buffer format is specified by |storage|. The reserved output buffer |
93 uint8_t** u_plane_data, | 89 // is returned; and the pointer to Y plane is stored at [y_plane_data], U |
94 uint8_t** v_plane_data); | 90 // plane is stored at [u_plane_data], V plane is stored at [v_plane_data]. |
| 91 // Returns an nullptr if allocation fails. |
| 92 // |
| 93 // When requested |storage| is PIXEL_STORAGE_CPU, a single shared memory |
| 94 // chunk is reserved. The output buffers stay reserved and mapped for use |
| 95 // until the Buffer objects are destroyed or returned. |
| 96 std::unique_ptr<Buffer> ReserveI420OutputBuffer( |
| 97 const gfx::Size& dimensions, |
| 98 media::VideoPixelStorage storage, |
| 99 int frame_feedback_id, |
| 100 uint8_t** y_plane_data, |
| 101 uint8_t** u_plane_data, |
| 102 uint8_t** v_plane_data); |
95 | 103 |
96 // A branch of OnIncomingCapturedData for Y16 frame_format.pixel_format. | 104 // A branch of OnIncomingCapturedData for Y16 frame_format.pixel_format. |
97 void OnIncomingCapturedY16Data(const uint8_t* data, | 105 void OnIncomingCapturedY16Data(const uint8_t* data, |
98 int length, | 106 int length, |
99 const VideoCaptureFormat& frame_format, | 107 const VideoCaptureFormat& frame_format, |
100 base::TimeTicks reference_time, | 108 base::TimeTicks reference_time, |
101 base::TimeDelta timestamp, | 109 base::TimeDelta timestamp, |
102 int frame_feedback_id); | 110 int frame_feedback_id); |
103 | 111 |
104 // The receiver to which we post events. | 112 // The receiver to which we post events. |
(...skipping 17 matching lines...) Expand all Loading... |
122 #endif // DCHECK_IS_ON() | 130 #endif // DCHECK_IS_ON() |
123 | 131 |
124 media::VideoPixelFormat last_captured_pixel_format_; | 132 media::VideoPixelFormat last_captured_pixel_format_; |
125 | 133 |
126 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); | 134 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); |
127 }; | 135 }; |
128 | 136 |
129 } // namespace media | 137 } // namespace media |
130 | 138 |
131 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 139 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
OLD | NEW |