Chromium Code Reviews| 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 "content/common/gpu/media/avc_config_record_builder.h" | |
| 15 #include "content/common/gpu/media/h264_parser.h" | |
| 14 #include "media/video/video_decode_accelerator.h" | 16 #include "media/video/video_decode_accelerator.h" |
| 15 | 17 |
| 16 namespace base { | 18 namespace base { |
| 17 class RefCountedBytes; | 19 class RefCountedBytes; |
| 18 } | 20 } |
| 19 namespace gfx { | 21 namespace gfx { |
| 20 class GLContext; | 22 class GLContext; |
| 21 class VideoDecodeAccelerationSupport; | 23 class VideoDecodeAccelerationSupport; |
| 22 } | 24 } |
| 23 | 25 |
| 24 class GpuCommandBufferStub; | 26 class GpuCommandBufferStub; |
| 25 | 27 |
| 26 class MacVideoDecodeAccelerator : public media::VideoDecodeAccelerator { | 28 class MacVideoDecodeAccelerator : public media::VideoDecodeAccelerator { |
| 27 public: | 29 public: |
| 28 // Does not take ownership of |client| which must outlive |*this|. | 30 // Does not take ownership of |client| which must outlive |*this|. |
| 29 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); | 31 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); |
| 30 | 32 |
| 31 // Set the OpenGL context to use. | 33 // Set the OpenGL context to use. |
| 32 void SetGLContext(void* gl_context); | 34 void SetGLContext(void* gl_context); |
| 33 | 35 |
| 34 // Set extra data required to initialize the H.264 video decoder. | |
| 35 // TODO(sail): Move this into Initialize. | |
| 36 bool SetConfigInfo(uint32_t frame_width, | |
| 37 uint32_t frame_height, | |
| 38 const std::vector<uint8_t>& avc_data); | |
| 39 | |
| 40 // media::VideoDecodeAccelerator implementation. | 36 // media::VideoDecodeAccelerator implementation. |
| 41 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; | 37 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; |
| 42 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 38 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
| 43 virtual void AssignPictureBuffers( | 39 virtual void AssignPictureBuffers( |
| 44 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 40 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
| 45 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 41 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 46 virtual void Flush() OVERRIDE; | 42 virtual void Flush() OVERRIDE; |
| 47 virtual void Reset() OVERRIDE; | 43 virtual void Reset() OVERRIDE; |
| 48 virtual void Destroy() OVERRIDE; | 44 virtual void Destroy() OVERRIDE; |
| 49 | 45 |
| 50 private: | 46 private: |
| 51 virtual ~MacVideoDecodeAccelerator(); | 47 virtual ~MacVideoDecodeAccelerator(); |
| 52 | 48 |
| 53 // Callback for a completed frame. | 49 // Callback for a completed frame. |
| 54 void OnFrameReady(int32 bitstream_buffer_id, | 50 void OnFrameReady(int32 bitstream_buffer_id, |
| 55 scoped_refptr<base::RefCountedBytes> bytes, | 51 scoped_refptr<base::RefCountedBytes> bytes, |
| 56 CVImageBufferRef image, | 52 CVImageBufferRef image, |
| 57 int status); | 53 int status); |
| 58 | 54 |
| 59 // Sends available decoded frames to the client. | 55 // Sends available decoded frames to the client. |
| 60 void SendImages(); | 56 void SendImages(); |
| 61 | 57 |
| 62 // Calls the client's flush completed callback. | 58 // Calls the client's flush completed callback. |
| 63 void NotifyFlushDone(); | 59 void NotifyFlushDone(); |
| 64 | 60 |
| 65 // Calls the client's reset completed callback. | 61 // Calls the client's reset completed callback. |
| 66 void NotifyResetDone(); | 62 void NotifyResetDone(); |
| 67 | 63 |
| 64 // Create the decoder. | |
| 65 void CreateDecoder(); | |
| 66 | |
| 67 // Send the given NALU to the decoder. | |
| 68 void DecodeNALU(const content::H264NALU* nalu, | |
|
Ami GONE FROM CHROMIUM
2012/05/23 19:41:19
const* is non-idiomatic in chromium (or google) st
sail
2012/05/28 21:45:46
Done.
| |
| 69 int32 bitstream_buffer_id); | |
| 70 | |
| 71 | |
| 68 // To expose client callbacks from VideoDecodeAccelerator. | 72 // To expose client callbacks from VideoDecodeAccelerator. |
| 69 Client* client_; | 73 Client* client_; |
| 70 // C++ wrapper around the Mac VDA API. | 74 // C++ wrapper around the Mac VDA API. |
| 71 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_; | 75 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_; |
| 72 // Picture buffers that are available for use by the decoder to draw decoded | 76 // Picture buffers that are available for use by the decoder to draw decoded |
| 73 // video frames on. | 77 // video frames on. |
| 74 std::list<media::PictureBuffer> available_pictures_; | 78 std::list<media::PictureBuffer> available_pictures_; |
| 75 | 79 |
| 76 // Maps ids to picture buffers that are in use by the client. | 80 // Maps ids to picture buffers that are in use by the client. |
| 77 struct PendingPictureInfo { | 81 struct PendingPictureInfo { |
| 78 PendingPictureInfo(media::PictureBuffer pic); | 82 PendingPictureInfo(media::PictureBuffer pic); |
| 79 ~PendingPictureInfo(); | 83 ~PendingPictureInfo(); |
| 80 media::PictureBuffer picture_buffer; | 84 media::PictureBuffer picture_buffer; |
| 81 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; | 85 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; |
| 82 }; | 86 }; |
| 83 std::map<int32, PendingPictureInfo> pending_pictures_; | 87 std::map<int32, PendingPictureInfo> pending_pictures_; |
| 84 | 88 |
| 85 // List of decoded images waiting to be sent to the client. | 89 // List of decoded images waiting to be sent to the client. |
| 86 struct DecodedImageInfo { | 90 struct DecodedImageInfo { |
| 87 DecodedImageInfo(); | 91 DecodedImageInfo(); |
| 88 ~DecodedImageInfo(); | 92 ~DecodedImageInfo(); |
| 89 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; | 93 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; |
| 90 int32 bitstream_buffer_id; | 94 int32 bitstream_buffer_id; |
| 91 }; | 95 }; |
| 92 std::list<DecodedImageInfo> decoded_images_; | 96 std::list<DecodedImageInfo> decoded_images_; |
| 93 | 97 |
| 94 // The context to use to perform OpenGL operations. | 98 // The context to use to perform OpenGL operations. |
| 95 CGLContextObj cgl_context_; | 99 CGLContextObj cgl_context_; |
| 96 | 100 |
| 97 // The number of bytes used to store the frame buffer size. | 101 // Flag to check if AVC decoder configuration record has been built. |
| 98 size_t nalu_len_field_size_; | 102 bool did_build_config_record_; |
| 99 | 103 |
| 100 // Width of a video frame. | 104 // Parser for the H264 stream. |
| 101 uint32_t frame_width_; | 105 content::H264Parser h264_parser_; |
| 102 // Height of a video frame. | 106 |
| 103 uint32_t frame_height_; | 107 // Utility to build the AVC configuration record. |
| 104 // Flag to check if pictures have been requested from the client. | 108 content::AVCConfigRecordBuilder config_record_builder_; |
| 105 bool did_request_pictures_; | |
| 106 }; | 109 }; |
| 107 | 110 |
| 108 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ | 111 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ |
| OLD | NEW |