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

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: fix cros build 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 "content/common/content_export.h"
16 #include "media/video/video_decode_accelerator.h"
17
18 namespace base {
19 class RefCountedBytes;
20 }
21 namespace gfx {
22 class GLContext;
23 class VideoDecodeAccelerationSupport;
24 }
25
26 class GpuCommandBufferStub;
27
28 class CONTENT_EXPORT MacVideoDecodeAccelerator
29 : public media::VideoDecodeAccelerator,
30 public base::NonThreadSafe {
31 public:
32 // Does not take ownership of |client| which must outlive |*this|.
33 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client);
34
35 // Set the OpenGL context to use.
36 void SetCGLContext(CGLContextObj cgl_context);
37
38 // Set extra data required to initialize the H.264 video decoder.
39 // TODO(sail): Move this into Initialize.
40 bool SetConfigInfo(uint32_t frame_width,
41 uint32_t frame_height,
42 const std::vector<uint8_t>& avc_data);
43
44 // media::VideoDecodeAccelerator implementation.
45 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
46 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
47 virtual void AssignPictureBuffers(
48 const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
49 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
50 virtual void Flush() OVERRIDE;
51 virtual void Reset() OVERRIDE;
52 virtual void Destroy() OVERRIDE;
53
54 private:
55 virtual ~MacVideoDecodeAccelerator();
56
57 // Callback for a completed frame.
58 void OnFrameReady(int32 bitstream_buffer_id,
59 scoped_refptr<base::RefCountedBytes> bytes,
60 CVImageBufferRef image,
61 int status);
62
63 // Sends available decoded frames to the client.
64 void SendImages();
65
66 // Stop the component when any error is detected.
67 void StopOnError(media::VideoDecodeAccelerator::Error error);
68
69 // Calls the client's initialize completed callback.
70 void NotifyInitializeDone();
71
72 // Requests pictures from the client.
73 void RequestPictures();
74
75 // Calls the client's flush completed callback.
76 void NotifyFlushDone();
77
78 // Calls the client's reset completed callback.
79 void NotifyResetDone();
80
81 // Notifies the client that the input buffer identifed by |input_buffer_id|
82 // has been processed.
83 void NotifyInputBufferRead(int input_buffer_id);
84
85 // To expose client callbacks from VideoDecodeAccelerator.
86 Client* client_;
87 // C++ wrapper around the Mac VDA API.
88 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_support_;
89 // Picture buffers that are available for use by the decoder to draw decoded
90 // video frames on.
91 std::list<media::PictureBuffer> available_pictures_;
92
93 // Maps ids to picture buffers that are in use by the client.
94 struct UsedPictureInfo {
95 UsedPictureInfo(const media::PictureBuffer& pic,
96 const base::mac::ScopedCFTypeRef<CVImageBufferRef>& image);
97 ~UsedPictureInfo();
98 const media::PictureBuffer picture_buffer;
99 const base::mac::ScopedCFTypeRef<CVImageBufferRef> image;
100 };
101 std::map<int32, UsedPictureInfo> used_pictures_;
102
103 // List of decoded images waiting to be sent to the client.
104 struct DecodedImageInfo {
105 DecodedImageInfo();
106 ~DecodedImageInfo();
107 base::mac::ScopedCFTypeRef<CVImageBufferRef> image;
108 int32 bitstream_buffer_id;
109 };
110 std::list<DecodedImageInfo> decoded_images_;
111
112 // The context to use to perform OpenGL operations.
113 CGLContextObj cgl_context_;
114
115 // The number of bytes used to store the frame buffer size.
116 size_t nalu_len_field_size_;
117
118 // Size of a video frame.
119 gfx::Size frame_size_;
120
121 // Flag to check if pictures have been requested from the client.
122 bool did_request_pictures_;
123 };
124
125 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_window_controller_cocoa.mm ('k') | content/common/gpu/media/mac_video_decode_accelerator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698