Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_MEDIA_MAC_VIDEO_DECODE_ACCELERATOR_H_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_MAC_VIDEO_DECODE_ACCELERATOR_H_ | |
| 7 | |
| 8 #include <CoreVideo/CoreVideo.h> | |
| 9 #include <map> | |
| 10 #include <list> | |
| 11 | |
| 12 #include "base/mac/scoped_cftyperef.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/threading/non_thread_safe.h" | |
| 15 #include "media/video/video_decode_accelerator.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class RefCountedBytes; | |
| 19 } | |
| 20 namespace gfx { | |
| 21 class GLContext; | |
| 22 class VideoDecodeAccelerationSupport; | |
| 23 } | |
| 24 | |
| 25 class GpuCommandBufferStub; | |
| 26 | |
| 27 class MacVideoDecodeAccelerator : public media::VideoDecodeAccelerator, | |
| 28 public base::NonThreadSafe { | |
| 29 public: | |
| 30 // Does not take ownership of |client| which must outlive |*this|. | |
| 31 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); | |
| 32 | |
| 33 // Set the OpenGL context to use. | |
| 34 void SetGLContext(void* gl_context); | |
| 35 | |
| 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. | |
| 43 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; | |
| 44 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | |
| 45 virtual void AssignPictureBuffers( | |
| 46 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | |
| 47 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | |
| 48 virtual void Flush() OVERRIDE; | |
| 49 virtual void Reset() OVERRIDE; | |
| 50 virtual void Destroy() OVERRIDE; | |
| 51 | |
| 52 private: | |
| 53 virtual ~MacVideoDecodeAccelerator(); | |
| 54 | |
| 55 // Callback for a completed frame. | |
| 56 void OnFrameReady(int32 bitstream_buffer_id, | |
| 57 scoped_refptr<base::RefCountedBytes> bytes, | |
| 58 CVImageBufferRef image, | |
| 59 int status); | |
| 60 | |
| 61 // Sends available decoded frames to the client. | |
| 62 void SendImages(); | |
| 63 | |
| 64 // Calls the client's initialize completed callback. | |
| 65 void NotifyInitializeDone(); | |
| 66 | |
| 67 // Calls the client's flush completed callback. | |
| 68 void NotifyFlushDone(); | |
| 69 | |
| 70 // Calls the client's reset completed callback. | |
| 71 void NotifyResetDone(); | |
| 72 | |
| 73 // To expose client callbacks from VideoDecodeAccelerator. | |
| 74 Client* client_; | |
| 75 // C++ wrapper around the Mac VDA API. | |
| 76 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_support_; | |
| 77 // Picture buffers that are available for use by the decoder to draw decoded | |
| 78 // video frames on. | |
| 79 std::list<media::PictureBuffer> available_pictures_; | |
| 80 | |
| 81 // Maps ids to picture buffers that are in use by the client. | |
| 82 struct UsedPictureInfo { | |
| 83 UsedPictureInfo(const media::PictureBuffer& pic, | |
| 84 const base::mac::ScopedCFTypeRef<CVImageBufferRef>& image); | |
| 85 ~UsedPictureInfo(); | |
| 86 media::PictureBuffer picture_buffer; | |
|
Ami GONE FROM CHROMIUM
2012/05/24 21:30:30
Can this and the next field be const?
sail
2012/05/29 03:45:01
Done.
| |
| 87 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; | |
| 88 }; | |
| 89 std::map<int32, UsedPictureInfo> used_pictures_; | |
| 90 | |
| 91 // List of decoded images waiting to be sent to the client. | |
| 92 struct DecodedImageInfo { | |
| 93 DecodedImageInfo(); | |
| 94 ~DecodedImageInfo(); | |
| 95 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; | |
| 96 int32 bitstream_buffer_id; | |
| 97 }; | |
| 98 std::list<DecodedImageInfo> decoded_images_; | |
| 99 | |
| 100 // The context to use to perform OpenGL operations. | |
| 101 CGLContextObj cgl_context_; | |
| 102 | |
| 103 // The number of bytes used to store the frame buffer size. | |
| 104 size_t nalu_len_field_size_; | |
| 105 | |
| 106 // Size of a video frame. | |
| 107 gfx::Size frame_size_; | |
| 108 | |
| 109 // Flag to check if pictures have been requested from the client. | |
| 110 bool did_request_pictures_; | |
| 111 }; | |
| 112 | |
| 113 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ | |
| OLD | NEW |