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 |
52 // VideoCaptureDevice::Client implementation. | 57 // VideoCaptureDevice::Client implementation. |
53 void OnIncomingCapturedData(const uint8_t* data, | 58 void OnIncomingCapturedData(const uint8_t* data, |
54 int length, | 59 int length, |
55 const media::VideoCaptureFormat& frame_format, | 60 const media::VideoCaptureFormat& frame_format, |
56 int rotation, | 61 int rotation, |
57 base::TimeTicks reference_time, | 62 base::TimeTicks reference_time, |
58 base::TimeDelta timestamp, | 63 base::TimeDelta timestamp, |
59 int frame_feedback_id = 0) override; | 64 int frame_feedback_id = 0) override; |
60 std::unique_ptr<Buffer> ReserveOutputBuffer(const gfx::Size& dimensions, | 65 Buffer ReserveOutputBuffer(const gfx::Size& dimensions, |
61 media::VideoPixelFormat format, | 66 media::VideoPixelFormat format, |
62 media::VideoPixelStorage storage, | 67 media::VideoPixelStorage storage, |
63 int frame_feedback_id) override; | 68 int frame_feedback_id) override; |
64 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 69 void OnIncomingCapturedBuffer(Buffer buffer, |
65 const VideoCaptureFormat& format, | 70 const VideoCaptureFormat& format, |
66 base::TimeTicks reference_time, | 71 base::TimeTicks reference_time, |
67 base::TimeDelta timestamp) override; | 72 base::TimeDelta timestamp) override; |
68 void OnIncomingCapturedBufferExt( | 73 void OnIncomingCapturedBufferExt( |
69 std::unique_ptr<Buffer> buffer, | 74 Buffer buffer, |
70 const VideoCaptureFormat& format, | 75 const VideoCaptureFormat& format, |
71 base::TimeTicks reference_time, | 76 base::TimeTicks reference_time, |
72 base::TimeDelta timestamp, | 77 base::TimeDelta timestamp, |
73 gfx::Rect visible_rect, | 78 gfx::Rect visible_rect, |
74 const VideoFrameMetadata& additional_metadata) override; | 79 const VideoFrameMetadata& additional_metadata) override; |
75 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( | 80 Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions, |
76 const gfx::Size& dimensions, | 81 media::VideoPixelFormat format, |
77 media::VideoPixelFormat format, | 82 media::VideoPixelStorage storage, |
78 media::VideoPixelStorage storage, | 83 int new_frame_feedback_id) override; |
79 int new_frame_feedback_id) override; | |
80 void OnError(const tracked_objects::Location& from_here, | 84 void OnError(const tracked_objects::Location& from_here, |
81 const std::string& reason) override; | 85 const std::string& reason) override; |
82 void OnLog(const std::string& message) override; | 86 void OnLog(const std::string& message) override; |
83 double GetBufferPoolUtilization() const override; | 87 double GetBufferPoolUtilization() const override; |
84 | 88 |
85 private: | 89 private: |
86 // Reserve output buffer into which I420 contents can be copied directly. | 90 void InitializeI420PlanePointers(const gfx::Size& dimensions, |
87 // The dimensions of the frame is described by |dimensions|, and requested | 91 uint8_t* const data, |
88 // output buffer format is specified by |storage|. The reserved output buffer | 92 uint8_t** y_plane_data, |
89 // is returned; and the pointer to Y plane is stored at [y_plane_data], U | 93 uint8_t** u_plane_data, |
90 // plane is stored at [u_plane_data], V plane is stored at [v_plane_data]. | 94 uint8_t** 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); | |
103 | 95 |
104 // A branch of OnIncomingCapturedData for Y16 frame_format.pixel_format. | 96 // A branch of OnIncomingCapturedData for Y16 frame_format.pixel_format. |
105 void OnIncomingCapturedY16Data(const uint8_t* data, | 97 void OnIncomingCapturedY16Data(const uint8_t* data, |
106 int length, | 98 int length, |
107 const VideoCaptureFormat& frame_format, | 99 const VideoCaptureFormat& frame_format, |
108 base::TimeTicks reference_time, | 100 base::TimeTicks reference_time, |
109 base::TimeDelta timestamp, | 101 base::TimeDelta timestamp, |
110 int frame_feedback_id); | 102 int frame_feedback_id); |
111 | 103 |
112 // The receiver to which we post events. | 104 // The receiver to which we post events. |
(...skipping 17 matching lines...) Expand all Loading... |
130 #endif // DCHECK_IS_ON() | 122 #endif // DCHECK_IS_ON() |
131 | 123 |
132 media::VideoPixelFormat last_captured_pixel_format_; | 124 media::VideoPixelFormat last_captured_pixel_format_; |
133 | 125 |
134 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); | 126 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); |
135 }; | 127 }; |
136 | 128 |
137 } // namespace media | 129 } // namespace media |
138 | 130 |
139 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ | 131 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_CLIENT_H_ |
OLD | NEW |