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 MEDIA_GPU_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ | 5 #ifndef MEDIA_GPU_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ |
6 #define MEDIA_GPU_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ | 6 #define MEDIA_GPU_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" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // Encoding tasks to be run on |encoder_thread_|. | 57 // Encoding tasks to be run on |encoder_thread_|. |
58 void EncodeTask(const scoped_refptr<media::VideoFrame>& frame, | 58 void EncodeTask(const scoped_refptr<media::VideoFrame>& frame, |
59 bool force_keyframe); | 59 bool force_keyframe); |
60 void UseOutputBitstreamBufferTask( | 60 void UseOutputBitstreamBufferTask( |
61 std::unique_ptr<BitstreamBufferRef> buffer_ref); | 61 std::unique_ptr<BitstreamBufferRef> buffer_ref); |
62 void RequestEncodingParametersChangeTask(uint32_t bitrate, | 62 void RequestEncodingParametersChangeTask(uint32_t bitrate, |
63 uint32_t framerate); | 63 uint32_t framerate); |
64 void DestroyTask(); | 64 void DestroyTask(); |
65 | 65 |
| 66 // Helper function to set bitrate. |
| 67 void SetAdjustedBitrate(int32_t bitrate); |
| 68 |
66 // Helper function to notify the client of an error on |client_task_runner_|. | 69 // Helper function to notify the client of an error on |client_task_runner_|. |
67 void NotifyError(media::VideoEncodeAccelerator::Error error); | 70 void NotifyError(media::VideoEncodeAccelerator::Error error); |
68 | 71 |
69 // Compression session callback function to handle compressed frames. | 72 // Compression session callback function to handle compressed frames. |
70 static void CompressionCallback(void* encoder_opaque, | 73 static void CompressionCallback(void* encoder_opaque, |
71 void* request_opaque, | 74 void* request_opaque, |
72 OSStatus status, | 75 OSStatus status, |
73 VTEncodeInfoFlags info, | 76 VTEncodeInfoFlags info, |
74 CMSampleBufferRef sbuf); | 77 CMSampleBufferRef sbuf); |
75 void CompressionCallbackTask(OSStatus status, | 78 void CompressionCallbackTask(OSStatus status, |
(...skipping 24 matching lines...) Expand all Loading... |
100 // encoding work). | 103 // encoding work). |
101 void DestroyCompressionSession(); | 104 void DestroyCompressionSession(); |
102 | 105 |
103 // VideoToolboxGlue provides access to VideoToolbox at runtime. | 106 // VideoToolboxGlue provides access to VideoToolbox at runtime. |
104 const VideoToolboxGlue* videotoolbox_glue_; | 107 const VideoToolboxGlue* videotoolbox_glue_; |
105 base::ScopedCFTypeRef<VTCompressionSessionRef> compression_session_; | 108 base::ScopedCFTypeRef<VTCompressionSessionRef> compression_session_; |
106 | 109 |
107 gfx::Size input_visible_size_; | 110 gfx::Size input_visible_size_; |
108 size_t bitstream_buffer_size_; | 111 size_t bitstream_buffer_size_; |
109 int32_t frame_rate_; | 112 int32_t frame_rate_; |
| 113 int32_t initial_bitrate_; |
110 int32_t target_bitrate_; | 114 int32_t target_bitrate_; |
111 int32_t adjusted_bitrate_; | 115 int32_t encoder_set_bitrate_; |
112 | 116 |
113 // Bitrate adjuster used to fix VideoToolbox's inconsistent bitrate issues. | 117 // Bitrate adjuster used to fix VideoToolbox's inconsistent bitrate issues. |
114 webrtc::BitrateAdjuster bitrate_adjuster_; | 118 webrtc::BitrateAdjuster bitrate_adjuster_; |
115 | 119 |
116 // Bitstream buffers ready to be used to return encoded output as a FIFO. | 120 // Bitstream buffers ready to be used to return encoded output as a FIFO. |
117 std::deque<std::unique_ptr<BitstreamBufferRef>> bitstream_buffer_queue_; | 121 std::deque<std::unique_ptr<BitstreamBufferRef>> bitstream_buffer_queue_; |
118 | 122 |
119 // EncodeOutput needs to be copied into a BitstreamBufferRef as a FIFO. | 123 // EncodeOutput needs to be copied into a BitstreamBufferRef as a FIFO. |
120 std::deque<std::unique_ptr<EncodeOutput>> encoder_output_queue_; | 124 std::deque<std::unique_ptr<EncodeOutput>> encoder_output_queue_; |
121 | 125 |
(...skipping 19 matching lines...) Expand all Loading... |
141 // other destructors run. | 145 // other destructors run. |
142 base::WeakPtr<VTVideoEncodeAccelerator> encoder_weak_ptr_; | 146 base::WeakPtr<VTVideoEncodeAccelerator> encoder_weak_ptr_; |
143 base::WeakPtrFactory<VTVideoEncodeAccelerator> encoder_task_weak_factory_; | 147 base::WeakPtrFactory<VTVideoEncodeAccelerator> encoder_task_weak_factory_; |
144 | 148 |
145 DISALLOW_COPY_AND_ASSIGN(VTVideoEncodeAccelerator); | 149 DISALLOW_COPY_AND_ASSIGN(VTVideoEncodeAccelerator); |
146 }; | 150 }; |
147 | 151 |
148 } // namespace media | 152 } // namespace media |
149 | 153 |
150 #endif // MEDIA_GPU_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ | 154 #endif // MEDIA_GPU_VT_VIDEO_ENCODE_ACCELERATOR_MAC_H_ |
OLD | NEW |