OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "media/base/mac/videotoolbox_glue.h" | 12 #include "media/base/mac/videotoolbox_glue.h" |
13 #include "media/base/mac/videotoolbox_helpers.h" | 13 #include "media/base/mac/videotoolbox_helpers.h" |
14 #include "media/video/video_encode_accelerator.h" | 14 #include "media/video/video_encode_accelerator.h" |
| 15 #include "third_party/webrtc/common_video/include/bitrate_adjuster.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 // VideoToolbox.framework implementation of the VideoEncodeAccelerator | 19 // VideoToolbox.framework implementation of the VideoEncodeAccelerator |
19 // interface for MacOSX. VideoToolbox makes no guarantees that it is thread | 20 // interface for MacOSX. VideoToolbox makes no guarantees that it is thread |
20 // safe, so this object is pinned to the thread on which it is constructed. | 21 // safe, so this object is pinned to the thread on which it is constructed. |
21 class CONTENT_EXPORT VTVideoEncodeAccelerator | 22 class CONTENT_EXPORT VTVideoEncodeAccelerator |
22 : public media::VideoEncodeAccelerator { | 23 : public media::VideoEncodeAccelerator { |
23 public: | 24 public: |
24 VTVideoEncodeAccelerator(); | 25 VTVideoEncodeAccelerator(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void DestroyCompressionSession(); | 101 void DestroyCompressionSession(); |
101 | 102 |
102 // VideoToolboxGlue provides access to VideoToolbox at runtime. | 103 // VideoToolboxGlue provides access to VideoToolbox at runtime. |
103 const VideoToolboxGlue* videotoolbox_glue_; | 104 const VideoToolboxGlue* videotoolbox_glue_; |
104 base::ScopedCFTypeRef<VTCompressionSessionRef> compression_session_; | 105 base::ScopedCFTypeRef<VTCompressionSessionRef> compression_session_; |
105 | 106 |
106 gfx::Size input_visible_size_; | 107 gfx::Size input_visible_size_; |
107 size_t bitstream_buffer_size_; | 108 size_t bitstream_buffer_size_; |
108 int32_t frame_rate_; | 109 int32_t frame_rate_; |
109 int32_t target_bitrate_; | 110 int32_t target_bitrate_; |
| 111 int32_t adjusted_bitrate_; |
| 112 |
| 113 // Bitrate adjuster used to fix VideoToolbox's inconsistent bitrate issues. |
| 114 webrtc::BitrateAdjuster bitrate_adjuster_; |
110 | 115 |
111 // Bitstream buffers ready to be used to return encoded output as a FIFO. | 116 // Bitstream buffers ready to be used to return encoded output as a FIFO. |
112 std::deque<std::unique_ptr<BitstreamBufferRef>> bitstream_buffer_queue_; | 117 std::deque<std::unique_ptr<BitstreamBufferRef>> bitstream_buffer_queue_; |
113 | 118 |
114 // EncodeOutput needs to be copied into a BitstreamBufferRef as a FIFO. | 119 // EncodeOutput needs to be copied into a BitstreamBufferRef as a FIFO. |
115 std::deque<std::unique_ptr<EncodeOutput>> encoder_output_queue_; | 120 std::deque<std::unique_ptr<EncodeOutput>> encoder_output_queue_; |
116 | 121 |
117 // Our original calling task runner for the child thread. | 122 // Our original calling task runner for the child thread. |
118 const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_; | 123 const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_; |
119 | 124 |
(...skipping 16 matching lines...) Expand all Loading... |
136 // other destructors run. | 141 // other destructors run. |
137 base::WeakPtr<VTVideoEncodeAccelerator> encoder_weak_ptr_; | 142 base::WeakPtr<VTVideoEncodeAccelerator> encoder_weak_ptr_; |
138 base::WeakPtrFactory<VTVideoEncodeAccelerator> encoder_task_weak_factory_; | 143 base::WeakPtrFactory<VTVideoEncodeAccelerator> encoder_task_weak_factory_; |
139 | 144 |
140 DISALLOW_COPY_AND_ASSIGN(VTVideoEncodeAccelerator); | 145 DISALLOW_COPY_AND_ASSIGN(VTVideoEncodeAccelerator); |
141 }; | 146 }; |
142 | 147 |
143 } // namespace content | 148 } // namespace content |
144 | 149 |
145 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ | 150 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ |
OLD | NEW |