| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MAC_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_MAC_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_MAC_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_MAC_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <CoreVideo/CoreVideo.h> | 8 #include <CoreVideo/CoreVideo.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <list> | 10 #include <list> |
| 11 | 11 |
| 12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "content/common/gpu/media/avc_config_record_builder.h" |
| 16 #include "content/common/gpu/media/h264_parser.h" |
| 15 #include "media/video/video_decode_accelerator.h" | 17 #include "media/video/video_decode_accelerator.h" |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 class RefCountedBytes; | 20 class RefCountedBytes; |
| 19 } | 21 } |
| 20 namespace gfx { | 22 namespace gfx { |
| 21 class GLContext; | 23 class GLContext; |
| 22 class VideoDecodeAccelerationSupport; | 24 class VideoDecodeAccelerationSupport; |
| 23 } | 25 } |
| 24 | 26 |
| 25 class GpuCommandBufferStub; | 27 class GpuCommandBufferStub; |
| 26 | 28 |
| 27 class MacVideoDecodeAccelerator : public media::VideoDecodeAccelerator, | 29 class MacVideoDecodeAccelerator : public media::VideoDecodeAccelerator, |
| 28 public base::NonThreadSafe { | 30 public base::NonThreadSafe { |
| 29 public: | 31 public: |
| 30 // Does not take ownership of |client| which must outlive |*this|. | 32 // Does not take ownership of |client| which must outlive |*this|. |
| 31 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); | 33 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); |
| 32 | 34 |
| 33 // Set the OpenGL context to use. | 35 // Set the OpenGL context to use. |
| 34 void SetCGLContext(CGLContextObj cgl_context); | 36 void SetCGLContext(CGLContextObj cgl_context); |
| 35 | 37 |
| 36 // Set extra data required to initialize the H.264 video decoder. | |
| 37 // TODO(sail): Move this into Initialize. | |
| 38 bool SetConfigInfo(uint32_t frame_width, | |
| 39 uint32_t frame_height, | |
| 40 const std::vector<uint8_t>& avc_data); | |
| 41 | |
| 42 // media::VideoDecodeAccelerator implementation. | 38 // media::VideoDecodeAccelerator implementation. |
| 43 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; | 39 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; |
| 44 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 40 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
| 45 virtual void AssignPictureBuffers( | 41 virtual void AssignPictureBuffers( |
| 46 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 42 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
| 47 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 43 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 48 virtual void Flush() OVERRIDE; | 44 virtual void Flush() OVERRIDE; |
| 49 virtual void Reset() OVERRIDE; | 45 virtual void Reset() OVERRIDE; |
| 50 virtual void Destroy() OVERRIDE; | 46 virtual void Destroy() OVERRIDE; |
| 51 | 47 |
| 52 private: | 48 private: |
| 53 virtual ~MacVideoDecodeAccelerator(); | 49 virtual ~MacVideoDecodeAccelerator(); |
| 54 | 50 |
| 55 // Callback for a completed frame. | 51 // Callback for a completed frame. |
| 56 void OnFrameReady(int32 bitstream_buffer_id, | 52 void OnFrameReady(int32 bitstream_buffer_id, |
| 57 scoped_refptr<base::RefCountedBytes> bytes, | 53 scoped_refptr<base::RefCountedBytes> bytes, |
| 58 CVImageBufferRef image, | 54 CVImageBufferRef image, |
| 59 int status); | 55 int status); |
| 60 | 56 |
| 61 // Sends available decoded frames to the client. | 57 // Sends available decoded frames to the client. |
| 62 void SendImages(); | 58 void SendImages(); |
| 63 | 59 |
| 64 // Stop the component when any error is detected. | 60 // Stop the component when any error is detected. |
| 65 void StopOnError(media::VideoDecodeAccelerator::Error error); | 61 void StopOnError(media::VideoDecodeAccelerator::Error error); |
| 66 | 62 |
| 63 // Create the decoder. |
| 64 bool CreateDecoder(const std::vector<uint8_t>& extra_data); |
| 65 |
| 66 // Send the given NALU to the decoder. |
| 67 void DecodeNALU(const content::H264NALU& nalu, |
| 68 int32 bitstream_buffer_id); |
| 69 |
| 67 // Calls the client's initialize completed callback. | 70 // Calls the client's initialize completed callback. |
| 68 void NotifyInitializeDone(); | 71 void NotifyInitializeDone(); |
| 69 | 72 |
| 70 // Requests pictures from the client. | 73 // Requests pictures from the client. |
| 71 void RequestPictures(); | 74 void RequestPictures(); |
| 72 | 75 |
| 73 // Calls the client's flush completed callback. | 76 // Calls the client's flush completed callback. |
| 74 void NotifyFlushDone(); | 77 void NotifyFlushDone(); |
| 75 | 78 |
| 76 // Calls the client's reset completed callback. | 79 // Calls the client's reset completed callback. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 103 DecodedImageInfo(); | 106 DecodedImageInfo(); |
| 104 ~DecodedImageInfo(); | 107 ~DecodedImageInfo(); |
| 105 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; | 108 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; |
| 106 int32 bitstream_buffer_id; | 109 int32 bitstream_buffer_id; |
| 107 }; | 110 }; |
| 108 std::list<DecodedImageInfo> decoded_images_; | 111 std::list<DecodedImageInfo> decoded_images_; |
| 109 | 112 |
| 110 // The context to use to perform OpenGL operations. | 113 // The context to use to perform OpenGL operations. |
| 111 CGLContextObj cgl_context_; | 114 CGLContextObj cgl_context_; |
| 112 | 115 |
| 113 // The number of bytes used to store the frame buffer size. | 116 // Flag to check if AVC decoder configuration record has been built. |
| 114 size_t nalu_len_field_size_; | 117 bool did_build_config_record_; |
| 115 | 118 |
| 116 // Size of a video frame. | 119 // Parser for the H264 stream. |
| 117 gfx::Size frame_size_; | 120 content::H264Parser h264_parser_; |
| 118 | 121 |
| 119 // Flag to check if pictures have been requested from the client. | 122 // Utility to build the AVC configuration record. |
| 120 bool did_request_pictures_; | 123 content::AVCConfigRecordBuilder config_record_builder_; |
| 121 }; | 124 }; |
| 122 | 125 |
| 123 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ | 126 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ |
| OLD | NEW |