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 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/vt_mac.h" | 20 #include "content/common/gpu/media/vt_mac.h" |
| 21 #include "content/public/common/gpu_video_decode_accelerator_helpers.h" |
21 #include "media/filters/h264_parser.h" | 22 #include "media/filters/h264_parser.h" |
22 #include "media/video/h264_poc.h" | 23 #include "media/video/h264_poc.h" |
23 #include "media/video/video_decode_accelerator.h" | 24 #include "media/video/video_decode_accelerator.h" |
24 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
25 #include "ui/gl/gl_context_cgl.h" | 26 #include "ui/gl/gl_context_cgl.h" |
26 #include "ui/gl/gl_image_io_surface.h" | 27 #include "ui/gl/gl_image_io_surface.h" |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 // Preload VideoToolbox libraries, needed for sandbox warmup. | 31 // Preload VideoToolbox libraries, needed for sandbox warmup. |
31 bool InitializeVideoToolbox(); | 32 bool InitializeVideoToolbox(); |
32 | 33 |
33 // VideoToolbox.framework implementation of the VideoDecodeAccelerator | 34 // VideoToolbox.framework implementation of the VideoDecodeAccelerator |
34 // interface for Mac OS X (currently limited to 10.9+). | 35 // interface for Mac OS X (currently limited to 10.9+). |
35 class VTVideoDecodeAccelerator : public media::VideoDecodeAccelerator { | 36 class VTVideoDecodeAccelerator : public media::VideoDecodeAccelerator { |
36 public: | 37 public: |
37 explicit VTVideoDecodeAccelerator( | 38 explicit VTVideoDecodeAccelerator( |
38 const base::Callback<bool(void)>& make_context_current, | 39 const gpu_vda_helpers::MakeGLContextCurrentCb& make_context_current_cb, |
39 const base::Callback< | 40 const gpu_vda_helpers::BindGLImageCb& bind_image_cb); |
40 void(uint32_t, uint32_t, scoped_refptr<gl::GLImage>)>& bind_image); | 41 |
41 ~VTVideoDecodeAccelerator() override; | 42 ~VTVideoDecodeAccelerator() override; |
42 | 43 |
43 // VideoDecodeAccelerator implementation. | 44 // VideoDecodeAccelerator implementation. |
44 bool Initialize(const Config& config, Client* client) override; | 45 bool Initialize(const Config& config, Client* client) override; |
45 void Decode(const media::BitstreamBuffer& bitstream) override; | 46 void Decode(const media::BitstreamBuffer& bitstream) override; |
46 void AssignPictureBuffers( | 47 void AssignPictureBuffers( |
47 const std::vector<media::PictureBuffer>& pictures) override; | 48 const std::vector<media::PictureBuffer>& pictures) override; |
48 void ReusePictureBuffer(int32_t picture_id) override; | 49 void ReusePictureBuffer(int32_t picture_id) override; |
49 void Flush() override; | 50 void Flush() override; |
50 void Reset() override; | 51 void Reset() override; |
51 void Destroy() override; | 52 void Destroy() override; |
52 bool CanDecodeOnIOThread() override; | 53 bool TryInitializeDecodeOnSeparateThread( |
| 54 const base::WeakPtr<Client>& decode_client, |
| 55 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
| 56 override; |
53 | 57 |
54 // Called by OutputThunk() when VideoToolbox finishes decoding a frame. | 58 // Called by OutputThunk() when VideoToolbox finishes decoding a frame. |
55 void Output( | 59 void Output( |
56 void* source_frame_refcon, | 60 void* source_frame_refcon, |
57 OSStatus status, | 61 OSStatus status, |
58 CVImageBufferRef image_buffer); | 62 CVImageBufferRef image_buffer); |
59 | 63 |
60 static media::VideoDecodeAccelerator::SupportedProfiles | 64 static media::VideoDecodeAccelerator::SupportedProfiles |
61 GetSupportedProfiles(); | 65 GetSupportedProfiles(); |
62 | 66 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 186 |
183 // These methods returns true if a task was completed, false otherwise. | 187 // These methods returns true if a task was completed, false otherwise. |
184 bool ProcessTaskQueue(); | 188 bool ProcessTaskQueue(); |
185 bool ProcessReorderQueue(); | 189 bool ProcessReorderQueue(); |
186 bool ProcessFrame(const Frame& frame); | 190 bool ProcessFrame(const Frame& frame); |
187 bool SendFrame(const Frame& frame); | 191 bool SendFrame(const Frame& frame); |
188 | 192 |
189 // | 193 // |
190 // GPU thread state. | 194 // GPU thread state. |
191 // | 195 // |
192 base::Callback<bool(void)> make_context_current_; | 196 gpu_vda_helpers::MakeGLContextCurrentCb make_context_current_cb_; |
193 base::Callback<void(uint32_t, uint32_t, scoped_refptr<gl::GLImage>)> | 197 gpu_vda_helpers::BindGLImageCb bind_image_cb_; |
194 bind_image_; | |
195 media::VideoDecodeAccelerator::Client* client_; | 198 media::VideoDecodeAccelerator::Client* client_; |
196 State state_; | 199 State state_; |
197 | 200 |
198 // Queue of pending flush tasks. This is used to drop frames when a reset | 201 // Queue of pending flush tasks. This is used to drop frames when a reset |
199 // is pending. | 202 // is pending. |
200 std::queue<TaskType> pending_flush_tasks_; | 203 std::queue<TaskType> pending_flush_tasks_; |
201 | 204 |
202 // Queue of tasks to complete in the GPU thread. | 205 // Queue of tasks to complete in the GPU thread. |
203 std::queue<Task> task_queue_; | 206 std::queue<Task> task_queue_; |
204 | 207 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // Declared last to ensure that all weak pointers are invalidated before | 267 // Declared last to ensure that all weak pointers are invalidated before |
265 // other destructors run. | 268 // other destructors run. |
266 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; | 269 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; |
267 | 270 |
268 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); | 271 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); |
269 }; | 272 }; |
270 | 273 |
271 } // namespace content | 274 } // namespace content |
272 | 275 |
273 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ | 276 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |