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