Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1112)

Unified Diff: content/common/gpu/media/video_decode_accelerator_mac.h

Issue 10388108: Implement media::VideoDecodeAccelerator on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/video_decode_accelerator_mac.h
diff --git a/content/common/gpu/media/video_decode_accelerator_mac.h b/content/common/gpu/media/video_decode_accelerator_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..9269f6ff0ae6d144e77294397efc49e505e50886
--- /dev/null
+++ b/content/common/gpu/media/video_decode_accelerator_mac.h
@@ -0,0 +1,109 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_
+#define CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_
+
+#include <CoreVideo/CoreVideo.h>
+#include <map>
+#include <list>
+
+#include "base/mac/scoped_refptr_cftype.h"
+#include "base/memory/ref_counted.h"
+#include "media/video/video_decode_accelerator.h"
+
+namespace base {
+class RefCountedBytes;
+}
+namespace gfx {
+class GLContext;
+class VideoDecodeAccelerationSupport;
+}
+
+class GpuCommandBufferStub;
+
+class VideoDecodeAcceleratorMac : public media::VideoDecodeAccelerator {
Ami GONE FROM CHROMIUM 2012/05/15 17:55:22 FWIW, the other VDA's follow the convention FooVDA
sail 2012/05/15 23:53:31 Done.
+ public:
+ // Does not take ownership of |client| which must outlive |*this|.
+ VideoDecodeAcceleratorMac(media::VideoDecodeAccelerator::Client* client);
+
+ // Set the OpenGL context to use.
+ void SetGLContext(void* gl_context);
+
+ // Set extra data required to initialize the H.264 video decoder.
+ // TODO(sail): Move this into Initialize.
Ami GONE FROM CHROMIUM 2012/05/15 17:55:22 Initialize() is a member of the VDA interface, and
sail 2012/05/15 23:53:31 These are the dimensions stored in the extra_data(
+ bool SetConfigInfo(uint32_t frame_width,
+ uint32_t frame_height,
+ const std::vector<uint8_t>& avc_data);
+
+ // media::VideoDecodeAccelerator implementation.
+ virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
+ virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
+ virtual void AssignPictureBuffers(
+ const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
+ virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
+ virtual void Flush() OVERRIDE;
+ virtual void Reset() OVERRIDE;
+ virtual void Destroy() OVERRIDE;
+
+ private:
+ virtual ~VideoDecodeAcceleratorMac();
+
+ // Callback for a completed frame.
+ void OnFrameReady(int32 bitstream_buffer_id,
+ scoped_refptr<base::RefCountedBytes> bytes,
+ CVImageBufferRef image,
+ int status);
+
+ // Sends available decoded frames to the client.
+ void SendImages();
+
+ // Calls the client's flush completed callback.
+ void NotifyFlushDone();
+
+ // Calls the client's reset completed callback.
+ void NotifyResetDone();
+
+ // To expose client callbacks from VideoDecodeAccelerator.
+ Client* client_;
+ // C++ wrapper around the Mac VDA API.
+ scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_;
+ // Picture buffers that are available for use by the decoder to draw decoded
+ // video frames on.
+ std::list<media::PictureBuffer> available_pictures_;
+
+ // Maps ids to picture buffers that are in use by the client.
+ struct PendingPictureInfo {
+ PendingPictureInfo(media::PictureBuffer pic,
+ CVImageBufferRef image);
+ ~PendingPictureInfo();
+ media::PictureBuffer picture_buffer;
+ base::mac::scoped_refptr_cftype<CVImageBufferRef> image;
+ };
+ std::map<int32, PendingPictureInfo> pending_pictures_;
+
+ // List of decoded images waiting to be sent to the client.
+ struct DecodedImageInfo {
+ DecodedImageInfo();
+ ~DecodedImageInfo();
+ base::mac::scoped_refptr_cftype<CVImageBufferRef> image;
+ int32 bitstream_buffer_id;
+ };
+ std::list<DecodedImageInfo> decoded_images_;
+
+ // The context to use to perform OpenGL operations.
+ CGLContextObj cgl_context_;
+
+ // The number of bytes used to store the frame buffer size.
+ size_t nalu_len_field_size_;
+
+ // Width of a video frame.
+ uint32_t frame_width_;
+ // Height of a video frame.
+ uint32_t frame_height_;
+ // Flag to check if pictures have been requested from the client.
+ bool did_request_pictures_;
+};
+
+#endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698