Chromium Code Reviews| 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 "base/basictypes.h" |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 13 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/threading/thread.h" |
| 13 #include "content/common/gpu/media/vt.h" | |
| 14 #include "media/filters/h264_parser.h" | |
| 14 #include "media/video/video_decode_accelerator.h" | 15 #include "media/video/video_decode_accelerator.h" |
| 15 #include "ui/gl/gl_context_cgl.h" | 16 #include "ui/gl/gl_context_cgl.h" |
| 16 | 17 |
| 18 namespace base { | |
| 19 class SingleThreadTaskRunner; | |
|
scherkus (not reviewing)
2014/07/09 18:32:49
de-indent (we don't indent inside namespaces)
sandersd (OOO until July 31)
2014/07/09 20:07:12
Done.
| |
| 20 } // namespace base | |
| 21 | |
| 17 namespace content { | 22 namespace content { |
| 18 | 23 |
| 19 // (Stub of a) VideoToolbox.framework implementation of the | 24 // VideoToolbox.framework implementation of the VideoDecodeAccelerator |
| 20 // VideoDecodeAccelerator interface for Mac OS X. | 25 // interface for Mac OS X (currently limited to 10.9+). |
| 21 class VTVideoDecodeAccelerator | 26 class VTVideoDecodeAccelerator |
| 22 : public media::VideoDecodeAccelerator, | 27 : public media::VideoDecodeAccelerator, |
| 23 public base::NonThreadSafe { | 28 public base::NonThreadSafe { |
| 24 public: | 29 public: |
| 25 explicit VTVideoDecodeAccelerator(CGLContextObj cgl_context); | 30 explicit VTVideoDecodeAccelerator(CGLContextObj cgl_context); |
| 26 virtual ~VTVideoDecodeAccelerator(); | 31 virtual ~VTVideoDecodeAccelerator(); |
| 27 | 32 |
| 28 // VideoDecodeAccelerator implementation. | 33 // VideoDecodeAccelerator implementation. |
| 29 virtual bool Initialize( | 34 virtual bool Initialize( |
| 30 media::VideoCodecProfile profile, | 35 media::VideoCodecProfile profile, |
| 31 Client* client) OVERRIDE; | 36 Client* client) OVERRIDE; |
| 32 virtual void Decode(const media::BitstreamBuffer& bitstream) OVERRIDE; | 37 virtual void Decode(const media::BitstreamBuffer& bitstream) OVERRIDE; |
| 33 virtual void AssignPictureBuffers( | 38 virtual void AssignPictureBuffers( |
| 34 const std::vector<media::PictureBuffer>& pictures) OVERRIDE; | 39 const std::vector<media::PictureBuffer>& pictures) OVERRIDE; |
| 35 virtual void ReusePictureBuffer(int32_t picture_id) OVERRIDE; | 40 virtual void ReusePictureBuffer(int32_t picture_id) OVERRIDE; |
| 36 virtual void Flush() OVERRIDE; | 41 virtual void Flush() OVERRIDE; |
| 37 virtual void Reset() OVERRIDE; | 42 virtual void Reset() OVERRIDE; |
| 38 virtual void Destroy() OVERRIDE; | 43 virtual void Destroy() OVERRIDE; |
| 39 virtual bool CanDecodeOnIOThread() OVERRIDE; | 44 virtual bool CanDecodeOnIOThread() OVERRIDE; |
| 40 | 45 |
| 46 // Called by VideoToolbox when a frame is decoded. | |
| 47 void Output( | |
| 48 int32_t bitstream_id, | |
| 49 OSStatus status, | |
| 50 VTDecodeInfoFlags info_flags, | |
| 51 CVImageBufferRef image_buffer); | |
| 52 | |
| 41 private: | 53 private: |
| 42 scoped_refptr<base::MessageLoopProxy> loop_proxy_; | 54 // Configure a VideoToolbox decompression session from parameter set NALUs. |
| 55 void ConfigureDecoder( | |
| 56 const std::vector<const uint8_t*>& nalu_data_ptrs, | |
| 57 const std::vector<size_t>& nalu_data_sizes); | |
| 58 | |
| 59 // Decode a frame of bitstream. | |
| 60 void DecodeTask(const media::BitstreamBuffer); | |
| 61 | |
| 62 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; | |
| 43 CGLContextObj cgl_context_; | 63 CGLContextObj cgl_context_; |
| 44 media::VideoDecodeAccelerator::Client* client_; | 64 media::VideoDecodeAccelerator::Client* client_; |
| 65 base::Thread decoder_thread_; | |
| 66 scoped_refptr<base::SingleThreadTaskRunner> decoder_task_runner_; | |
|
scherkus (not reviewing)
2014/07/09 18:32:49
there's no need to maintain an extra task runner r
sandersd (OOO until July 31)
2014/07/09 20:07:12
Done.
It's uglier, but doesn't cause any new wrap
| |
| 67 | |
| 68 // Decoder configuration (used only on decoder thread). | |
| 69 VTDecompressionOutputCallbackRecord callback_; | |
| 70 CMFormatDescriptionRef format_; | |
| 71 VTDecompressionSessionRef session_; | |
| 72 media::H264Parser parser_; | |
| 73 int32_t coded_width_; | |
| 74 int32_t coded_height_; | |
| 45 | 75 |
| 46 // Member variables should appear before the WeakPtrFactory, to ensure | 76 // Member variables should appear before the WeakPtrFactory, to ensure |
| 47 // that any WeakPtrs to Controller are invalidated before its members | 77 // that any WeakPtrs to Controller are invalidated before its members |
| 48 // variable's destructors are executed, rendering them invalid. | 78 // variable's destructors are executed, rendering them invalid. |
| 49 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; | 79 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_factory_; |
| 50 | 80 |
| 51 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); | 81 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); |
| 52 }; | 82 }; |
| 53 | 83 |
| 54 } // namespace content | 84 } // namespace content |
| 55 | 85 |
| 56 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ | 86 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |