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> |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 class GpuCommandBufferStub; | 28 class GpuCommandBufferStub; |
29 | 29 |
30 class CONTENT_EXPORT MacVideoDecodeAccelerator | 30 class CONTENT_EXPORT MacVideoDecodeAccelerator |
31 : public media::VideoDecodeAccelerator, | 31 : public media::VideoDecodeAccelerator, |
32 public base::NonThreadSafe { | 32 public base::NonThreadSafe { |
33 public: | 33 public: |
34 // Does not take ownership of |client| which must outlive |*this|. | 34 // Does not take ownership of |client| which must outlive |*this|. |
35 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); | 35 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); |
| 36 virtual ~MacVideoDecodeAccelerator(); |
36 | 37 |
37 // Set the OpenGL context to use. | 38 // Set the OpenGL context to use. |
38 void SetCGLContext(CGLContextObj cgl_context); | 39 void SetCGLContext(CGLContextObj cgl_context); |
39 | 40 |
40 // media::VideoDecodeAccelerator implementation. | 41 // media::VideoDecodeAccelerator implementation. |
41 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; | 42 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; |
42 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 43 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
43 virtual void AssignPictureBuffers( | 44 virtual void AssignPictureBuffers( |
44 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 45 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
45 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 46 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
46 virtual void Flush() OVERRIDE; | 47 virtual void Flush() OVERRIDE; |
47 virtual void Reset() OVERRIDE; | 48 virtual void Reset() OVERRIDE; |
48 virtual void Destroy() OVERRIDE; | 49 virtual void Destroy() OVERRIDE; |
49 | 50 |
50 private: | 51 private: |
51 virtual ~MacVideoDecodeAccelerator(); | |
52 | 52 |
53 // Callback for a completed frame. | 53 // Callback for a completed frame. |
54 void OnFrameReady(int32 bitstream_buffer_id, | 54 void OnFrameReady(int32 bitstream_buffer_id, |
55 scoped_refptr<base::RefCountedBytes> bytes, | 55 scoped_refptr<base::RefCountedBytes> bytes, |
56 CVImageBufferRef image, | 56 CVImageBufferRef image, |
57 int status); | 57 int status); |
58 | 58 |
59 // Sends available decoded frames to the client. | 59 // Sends available decoded frames to the client. |
60 void SendImages(); | 60 void SendImages(); |
61 | 61 |
(...skipping 16 matching lines...) Expand all Loading... |
78 // Calls the client's flush completed callback. | 78 // Calls the client's flush completed callback. |
79 void NotifyFlushDone(); | 79 void NotifyFlushDone(); |
80 | 80 |
81 // Calls the client's reset completed callback. | 81 // Calls the client's reset completed callback. |
82 void NotifyResetDone(); | 82 void NotifyResetDone(); |
83 | 83 |
84 // Notifies the client that the input buffer identifed by |input_buffer_id| | 84 // Notifies the client that the input buffer identifed by |input_buffer_id| |
85 // has been processed. | 85 // has been processed. |
86 void NotifyInputBufferRead(int input_buffer_id); | 86 void NotifyInputBufferRead(int input_buffer_id); |
87 | 87 |
| 88 // Helper for Destroy(), doing all the actual work except for deleting self. |
| 89 void Cleanup(); |
| 90 |
88 // To expose client callbacks from VideoDecodeAccelerator. | 91 // To expose client callbacks from VideoDecodeAccelerator. |
89 Client* client_; | 92 Client* client_; |
90 // C++ wrapper around the Mac VDA API. | 93 // C++ wrapper around the Mac VDA API. |
91 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_support_; | 94 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_support_; |
92 // Picture buffers that are available for use by the decoder to draw decoded | 95 // Picture buffers that are available for use by the decoder to draw decoded |
93 // video frames on. | 96 // video frames on. |
94 std::list<media::PictureBuffer> available_pictures_; | 97 std::list<media::PictureBuffer> available_pictures_; |
95 | 98 |
96 // Maps ids to picture buffers that are in use by the client. | 99 // Maps ids to picture buffers that are in use by the client. |
97 struct UsedPictureInfo { | 100 struct UsedPictureInfo { |
(...skipping 26 matching lines...) Expand all Loading... |
124 // Utility to build the AVC configuration record. | 127 // Utility to build the AVC configuration record. |
125 content::AVCConfigRecordBuilder config_record_builder_; | 128 content::AVCConfigRecordBuilder config_record_builder_; |
126 | 129 |
127 // Maps a bitstream ID to the number of NALUs that are being decoded for | 130 // Maps a bitstream ID to the number of NALUs that are being decoded for |
128 // that bitstream. This is used to ensure that NotifyEndOfBitstreamBuffer() | 131 // that bitstream. This is used to ensure that NotifyEndOfBitstreamBuffer() |
129 // is called after all NALUs contained in a bitstream have been decoded. | 132 // is called after all NALUs contained in a bitstream have been decoded. |
130 std::map<int32, int> bitstream_nalu_count_; | 133 std::map<int32, int> bitstream_nalu_count_; |
131 }; | 134 }; |
132 | 135 |
133 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ | 136 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ |
OLD | NEW |