Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: media/gpu/vt_video_decode_accelerator_mac.h

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix several more bot-identified build issues Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <queue> 11 #include <queue>
12 12
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "content/common/gpu/media/gpu_video_decode_accelerator_helpers.h"
21 #include "content/common/gpu/media/vt_mac.h"
22 #include "media/filters/h264_parser.h" 20 #include "media/filters/h264_parser.h"
21 #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
22 #include "media/gpu/vt_mac.h"
23 #include "media/video/h264_poc.h" 23 #include "media/video/h264_poc.h"
24 #include "media/video/video_decode_accelerator.h" 24 #include "media/video/video_decode_accelerator.h"
25 #include "ui/gfx/geometry/size.h" 25 #include "ui/gfx/geometry/size.h"
26 #include "ui/gl/gl_context_cgl.h" 26 #include "ui/gl/gl_context_cgl.h"
27 #include "ui/gl/gl_image_io_surface.h" 27 #include "ui/gl/gl_image_io_surface.h"
28 28
29 namespace content { 29 namespace media {
30 30
31 // Preload VideoToolbox libraries, needed for sandbox warmup. 31 // Preload VideoToolbox libraries, needed for sandbox warmup.
32 bool InitializeVideoToolbox(); 32 bool InitializeVideoToolbox();
33 33
34 // VideoToolbox.framework implementation of the VideoDecodeAccelerator 34 // VideoToolbox.framework implementation of the VideoDecodeAccelerator
35 // interface for Mac OS X (currently limited to 10.9+). 35 // interface for Mac OS X (currently limited to 10.9+).
36 class VTVideoDecodeAccelerator : public media::VideoDecodeAccelerator { 36 class VTVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
37 public: 37 public:
38 explicit VTVideoDecodeAccelerator( 38 explicit VTVideoDecodeAccelerator(
39 const MakeGLContextCurrentCallback& make_context_current_cb, 39 const MakeGLContextCurrentCallback& make_context_current_cb,
40 const BindGLImageCallback& bind_image_cb); 40 const BindGLImageCallback& bind_image_cb);
41 41
42 ~VTVideoDecodeAccelerator() override; 42 ~VTVideoDecodeAccelerator() override;
43 43
44 // VideoDecodeAccelerator implementation. 44 // VideoDecodeAccelerator implementation.
45 bool Initialize(const Config& config, Client* client) override; 45 bool Initialize(const Config& config, Client* client) override;
46 void Decode(const media::BitstreamBuffer& bitstream) override; 46 void Decode(const media::BitstreamBuffer& bitstream) override;
47 void AssignPictureBuffers( 47 void AssignPictureBuffers(
48 const std::vector<media::PictureBuffer>& pictures) override; 48 const std::vector<media::PictureBuffer>& pictures) override;
49 void ReusePictureBuffer(int32_t picture_id) override; 49 void ReusePictureBuffer(int32_t picture_id) override;
50 void Flush() override; 50 void Flush() override;
51 void Reset() override; 51 void Reset() override;
52 void Destroy() override; 52 void Destroy() override;
53 bool TryToSetupDecodeOnSeparateThread( 53 bool TryToSetupDecodeOnSeparateThread(
54 const base::WeakPtr<Client>& decode_client, 54 const base::WeakPtr<Client>& decode_client,
55 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) 55 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner)
56 override; 56 override;
57 57
58 // Called by OutputThunk() when VideoToolbox finishes decoding a frame. 58 // Called by OutputThunk() when VideoToolbox finishes decoding a frame.
59 void Output( 59 void Output(void* source_frame_refcon,
60 void* source_frame_refcon, 60 OSStatus status,
61 OSStatus status, 61 CVImageBufferRef image_buffer);
62 CVImageBufferRef image_buffer);
63 62
64 static media::VideoDecodeAccelerator::SupportedProfiles 63 static media::VideoDecodeAccelerator::SupportedProfiles
65 GetSupportedProfiles(); 64 GetSupportedProfiles();
66 65
67 private: 66 private:
68 // Logged to UMA, so never reuse values. Make sure to update 67 // Logged to UMA, so never reuse values. Make sure to update
69 // VTVDASessionFailureType in histograms.xml to match. 68 // VTVDASessionFailureType in histograms.xml to match.
70 enum VTVDASessionFailureType { 69 enum VTVDASessionFailureType {
71 SFT_SUCCESSFULLY_INITIALIZED = 0, 70 SFT_SUCCESSFULLY_INITIALIZED = 0,
72 SFT_PLATFORM_ERROR = 1, 71 SFT_PLATFORM_ERROR = 1,
73 SFT_INVALID_STREAM = 2, 72 SFT_INVALID_STREAM = 2,
74 SFT_UNSUPPORTED_STREAM_PARAMETERS = 3, 73 SFT_UNSUPPORTED_STREAM_PARAMETERS = 3,
75 SFT_DECODE_ERROR = 4, 74 SFT_DECODE_ERROR = 4,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 private: 143 private:
145 DISALLOW_COPY_AND_ASSIGN(PictureInfo); 144 DISALLOW_COPY_AND_ASSIGN(PictureInfo);
146 }; 145 };
147 146
148 // 147 //
149 // Methods for interacting with VideoToolbox. Run on |decoder_thread_|. 148 // Methods for interacting with VideoToolbox. Run on |decoder_thread_|.
150 // 149 //
151 150
152 // Compute the |pic_order_cnt| for a frame. Returns true or calls 151 // Compute the |pic_order_cnt| for a frame. Returns true or calls
153 // NotifyError() before returning false. 152 // NotifyError() before returning false.
154 bool ComputePicOrderCnt( 153 bool ComputePicOrderCnt(const media::H264SPS* sps,
155 const media::H264SPS* sps, 154 const media::H264SliceHeader& slice_hdr,
156 const media::H264SliceHeader& slice_hdr, 155 Frame* frame);
157 Frame* frame);
158 156
159 // Set up VideoToolbox using the current SPS and PPS. Returns true or calls 157 // Set up VideoToolbox using the current SPS and PPS. Returns true or calls
160 // NotifyError() before returning false. 158 // NotifyError() before returning false.
161 bool ConfigureDecoder(); 159 bool ConfigureDecoder();
162 160
163 // Wait for VideoToolbox to output all pending frames. Returns true or calls 161 // Wait for VideoToolbox to output all pending frames. Returns true or calls
164 // NotifyError() before returning false. 162 // NotifyError() before returning false.
165 bool FinishDelayedFrames(); 163 bool FinishDelayedFrames();
166 164
167 // |frame| is owned by |pending_frames_|. 165 // |frame| is owned by |pending_frames_|.
168 void DecodeTask(const media::BitstreamBuffer&, Frame* frame); 166 void DecodeTask(const media::BitstreamBuffer&, Frame* frame);
169 void DecodeDone(Frame* frame); 167 void DecodeDone(Frame* frame);
170 168
171 // 169 //
172 // Methods for interacting with |client_|. Run on |gpu_task_runner_|. 170 // Methods for interacting with |client_|. Run on |gpu_task_runner_|.
173 // 171 //
174 void NotifyError( 172 void NotifyError(Error vda_error_type,
175 Error vda_error_type, 173 VTVDASessionFailureType session_failure_type);
176 VTVDASessionFailureType session_failure_type);
177 174
178 // |type| is the type of task that the flush will complete, one of TASK_FLUSH, 175 // |type| is the type of task that the flush will complete, one of TASK_FLUSH,
179 // TASK_RESET, or TASK_DESTROY. 176 // TASK_RESET, or TASK_DESTROY.
180 void QueueFlush(TaskType type); 177 void QueueFlush(TaskType type);
181 void FlushTask(TaskType type); 178 void FlushTask(TaskType type);
182 void FlushDone(TaskType type); 179 void FlushDone(TaskType type);
183 180
184 // Try to make progress on tasks in the |task_queue_| or sending frames in the 181 // Try to make progress on tasks in the |task_queue_| or sending frames in the
185 // |reorder_queue_|. 182 // |reorder_queue_|.
186 void ProcessWorkQueues(); 183 void ProcessWorkQueues();
(...skipping 15 matching lines...) Expand all
202 199
203 // Queue of pending flush tasks. This is used to drop frames when a reset 200 // Queue of pending flush tasks. This is used to drop frames when a reset
204 // is pending. 201 // is pending.
205 std::queue<TaskType> pending_flush_tasks_; 202 std::queue<TaskType> pending_flush_tasks_;
206 203
207 // Queue of tasks to complete in the GPU thread. 204 // Queue of tasks to complete in the GPU thread.
208 std::queue<Task> task_queue_; 205 std::queue<Task> task_queue_;
209 206
210 // Utility class to define the order of frames in the reorder queue. 207 // Utility class to define the order of frames in the reorder queue.
211 struct FrameOrder { 208 struct FrameOrder {
212 bool operator()( 209 bool operator()(const linked_ptr<Frame>& lhs,
213 const linked_ptr<Frame>& lhs, 210 const linked_ptr<Frame>& rhs) const;
214 const linked_ptr<Frame>& rhs) const;
215 }; 211 };
216 212
217 // Queue of decoded frames in presentation order. 213 // Queue of decoded frames in presentation order.
218 std::priority_queue<linked_ptr<Frame>, 214 std::priority_queue<linked_ptr<Frame>,
219 std::vector<linked_ptr<Frame>>, 215 std::vector<linked_ptr<Frame>>,
220 FrameOrder> reorder_queue_; 216 FrameOrder>
217 reorder_queue_;
221 218
222 // Size of assigned picture buffers. 219 // Size of assigned picture buffers.
223 gfx::Size picture_size_; 220 gfx::Size picture_size_;
224 221
225 // Frames that have not yet been decoded, keyed by bitstream ID; maintains 222 // Frames that have not yet been decoded, keyed by bitstream ID; maintains
226 // ownership of Frame objects while they flow through VideoToolbox. 223 // ownership of Frame objects while they flow through VideoToolbox.
227 std::map<int32_t, linked_ptr<Frame>> pending_frames_; 224 std::map<int32_t, linked_ptr<Frame>> pending_frames_;
228 225
229 // Set of assigned bitstream IDs, so that Destroy() can release them all. 226 // Set of assigned bitstream IDs, so that Destroy() can release them all.
230 std::set<int32_t> assigned_bitstream_ids_; 227 std::set<int32_t> assigned_bitstream_ids_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 base::WeakPtr<VTVideoDecodeAccelerator> weak_this_; 264 base::WeakPtr<VTVideoDecodeAccelerator> weak_this_;
268 base::Thread decoder_thread_; 265 base::Thread decoder_thread_;
269 266
270 // Declared last to ensure that all weak pointers are invalidated before 267 // Declared last to ensure that all weak pointers are invalidated before
271 // other destructors run. 268 // other destructors run.
272 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; 269 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_;
273 270
274 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); 271 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator);
275 }; 272 };
276 273
277 } // namespace content 274 } // namespace media
278 275
279 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ 276 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698