OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ | 5 #ifndef MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ |
6 #define MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ | 6 #define MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "media/cast/cast_environment.h" | 15 #include "media/cast/cast_environment.h" |
15 #include "media/cast/sender/size_adaptable_video_encoder_base.h" | 16 #include "media/cast/sender/size_adaptable_video_encoder_base.h" |
16 #include "media/cast/sender/video_encoder.h" | 17 #include "media/cast/sender/video_encoder.h" |
17 #include "media/video/video_encode_accelerator.h" | 18 #include "media/video/video_encode_accelerator.h" |
18 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 namespace cast { | 22 namespace cast { |
22 | 23 |
(...skipping 29 matching lines...) Expand all Loading... |
52 class VEAClientImpl; | 53 class VEAClientImpl; |
53 | 54 |
54 // Method invoked by the CreateVideoEncodeAcceleratorCallback to construct a | 55 // Method invoked by the CreateVideoEncodeAcceleratorCallback to construct a |
55 // VEAClientImpl to own and interface with a new |vea|. Upon return, | 56 // VEAClientImpl to own and interface with a new |vea|. Upon return, |
56 // |client_| holds a reference to the new VEAClientImpl. | 57 // |client_| holds a reference to the new VEAClientImpl. |
57 void OnCreateVideoEncodeAccelerator( | 58 void OnCreateVideoEncodeAccelerator( |
58 const VideoSenderConfig& video_config, | 59 const VideoSenderConfig& video_config, |
59 uint32_t first_frame_id, | 60 uint32_t first_frame_id, |
60 const StatusChangeCallback& status_change_cb, | 61 const StatusChangeCallback& status_change_cb, |
61 scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner, | 62 scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner, |
62 scoped_ptr<media::VideoEncodeAccelerator> vea); | 63 std::unique_ptr<media::VideoEncodeAccelerator> vea); |
63 | 64 |
64 const scoped_refptr<CastEnvironment> cast_environment_; | 65 const scoped_refptr<CastEnvironment> cast_environment_; |
65 const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_; | 66 const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_; |
66 | 67 |
67 // The size of the visible region of the video frames to be encoded. | 68 // The size of the visible region of the video frames to be encoded. |
68 const gfx::Size frame_size_; | 69 const gfx::Size frame_size_; |
69 | 70 |
70 int bit_rate_; | 71 int bit_rate_; |
71 bool key_frame_requested_; | 72 bool key_frame_requested_; |
72 | 73 |
(...skipping 13 matching lines...) Expand all Loading... |
86 SizeAdaptableExternalVideoEncoder( | 87 SizeAdaptableExternalVideoEncoder( |
87 const scoped_refptr<CastEnvironment>& cast_environment, | 88 const scoped_refptr<CastEnvironment>& cast_environment, |
88 const VideoSenderConfig& video_config, | 89 const VideoSenderConfig& video_config, |
89 const StatusChangeCallback& status_change_cb, | 90 const StatusChangeCallback& status_change_cb, |
90 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, | 91 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
91 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb); | 92 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb); |
92 | 93 |
93 ~SizeAdaptableExternalVideoEncoder() final; | 94 ~SizeAdaptableExternalVideoEncoder() final; |
94 | 95 |
95 protected: | 96 protected: |
96 scoped_ptr<VideoEncoder> CreateEncoder() final; | 97 std::unique_ptr<VideoEncoder> CreateEncoder() final; |
97 | 98 |
98 private: | 99 private: |
99 // Special callbacks needed by media::cast::ExternalVideoEncoder. | 100 // Special callbacks needed by media::cast::ExternalVideoEncoder. |
100 // TODO(miu): Remove these. http://crbug.com/454029 | 101 // TODO(miu): Remove these. http://crbug.com/454029 |
101 const CreateVideoEncodeAcceleratorCallback create_vea_cb_; | 102 const CreateVideoEncodeAcceleratorCallback create_vea_cb_; |
102 const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_; | 103 const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_; |
103 | 104 |
104 DISALLOW_COPY_AND_ASSIGN(SizeAdaptableExternalVideoEncoder); | 105 DISALLOW_COPY_AND_ASSIGN(SizeAdaptableExternalVideoEncoder); |
105 }; | 106 }; |
106 | 107 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 static double ComputeEntropyFromHistogram(const int* histogram, | 147 static double ComputeEntropyFromHistogram(const int* histogram, |
147 size_t num_buckets, | 148 size_t num_buckets, |
148 int num_samples); | 149 int num_samples); |
149 | 150 |
150 // Map the |shannon_entropy| to its corresponding software VP8 quantizer. | 151 // Map the |shannon_entropy| to its corresponding software VP8 quantizer. |
151 static double ToQuantizerEstimate(double shannon_entropy); | 152 static double ToQuantizerEstimate(double shannon_entropy); |
152 | 153 |
153 // A cache of a subset of rows of pixels from the last frame examined. This | 154 // A cache of a subset of rows of pixels from the last frame examined. This |
154 // is used to compute the entropy of the difference between frames, which in | 155 // is used to compute the entropy of the difference between frames, which in |
155 // turn is used to compute the entropy and quantizer. | 156 // turn is used to compute the entropy and quantizer. |
156 scoped_ptr<uint8_t[]> last_frame_pixel_buffer_; | 157 std::unique_ptr<uint8_t[]> last_frame_pixel_buffer_; |
157 gfx::Size last_frame_size_; | 158 gfx::Size last_frame_size_; |
158 | 159 |
159 DISALLOW_COPY_AND_ASSIGN(QuantizerEstimator); | 160 DISALLOW_COPY_AND_ASSIGN(QuantizerEstimator); |
160 }; | 161 }; |
161 | 162 |
162 } // namespace cast | 163 } // namespace cast |
163 } // namespace media | 164 } // namespace media |
164 | 165 |
165 #endif // MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ | 166 #endif // MEDIA_CAST_SENDER_EXTERNAL_VIDEO_ENCODER_H_ |
OLD | NEW |