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

Side by Side Diff: content/common/gpu/media/mac_video_decode_accelerator.h

Issue 10388108: Implement media::VideoDecodeAccelerator on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 SetCGLContext(CGLContextObj cgl_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 // Stop the component when any error is detected.
65 void StopOnError(media::VideoDecodeAccelerator::Error error);
66
67 // Calls the client's initialize completed callback.
68 void NotifyInitializeDone();
69
70 // Requests pictures from the client.
71 void RequestPictures();
72
73 // Calls the client's flush completed callback.
74 void NotifyFlushDone();
75
76 // Calls the client's reset completed callback.
77 void NotifyResetDone();
78
79 // Notifies the client that the input buffer identifed by |input_buffer_id|
80 // has been processed.
81 void NotifyInputBufferRead(int input_buffer_id);
82
83 // To expose client callbacks from VideoDecodeAccelerator.
84 Client* client_;
85 // C++ wrapper around the Mac VDA API.
86 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_support_;
87 // Picture buffers that are available for use by the decoder to draw decoded
88 // video frames on.
89 std::list<media::PictureBuffer> available_pictures_;
90
91 // Maps ids to picture buffers that are in use by the client.
92 struct UsedPictureInfo {
93 UsedPictureInfo(const media::PictureBuffer& pic,
94 const base::mac::ScopedCFTypeRef<CVImageBufferRef>& image);
95 ~UsedPictureInfo();
96 const media::PictureBuffer picture_buffer;
97 const base::mac::ScopedCFTypeRef<CVImageBufferRef> image;
98 };
99 std::map<int32, UsedPictureInfo> used_pictures_;
100
101 // List of decoded images waiting to be sent to the client.
102 struct DecodedImageInfo {
103 DecodedImageInfo();
104 ~DecodedImageInfo();
105 base::mac::ScopedCFTypeRef<CVImageBufferRef> image;
106 int32 bitstream_buffer_id;
107 };
108 std::list<DecodedImageInfo> decoded_images_;
109
110 // The context to use to perform OpenGL operations.
111 CGLContextObj cgl_context_;
112
113 // The number of bytes used to store the frame buffer size.
114 size_t nalu_len_field_size_;
115
116 // Size of a video frame.
117 gfx::Size frame_size_;
118
119 // Flag to check if pictures have been requested from the client.
120 bool did_request_pictures_;
121 };
122
123 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698