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