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 "media/video/video_decode_accelerator.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class RefCountedBytes; | |
| 18 } | |
| 19 namespace gfx { | |
| 20 class GLContext; | |
| 21 class VideoDecodeAccelerationSupport; | |
| 22 } | |
| 23 | |
| 24 class GpuCommandBufferStub; | |
| 25 | |
| 26 class MacVideoDecodeAccelerator : public media::VideoDecodeAccelerator { | |
|
Ami GONE FROM CHROMIUM
2012/05/17 21:44:47
Impl has a refreshing lack of mention of threads.
sail
2012/05/23 23:02:29
Done.
Ahh, sorry, forgot to comment on your previ
| |
| 27 public: | |
| 28 // Does not take ownership of |client| which must outlive |*this|. | |
| 29 MacVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); | |
| 30 | |
| 31 // Set the OpenGL context to use. | |
| 32 void SetGLContext(void* gl_context); | |
| 33 | |
| 34 // Set extra data required to initialize the H.264 video decoder. | |
| 35 // TODO(sail): Move this into Initialize. | |
| 36 bool SetConfigInfo(uint32_t frame_width, | |
| 37 uint32_t frame_height, | |
| 38 const std::vector<uint8_t>& avc_data); | |
| 39 | |
| 40 // media::VideoDecodeAccelerator implementation. | |
| 41 virtual bool Initialize(media::VideoCodecProfile profile) OVERRIDE; | |
| 42 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | |
| 43 virtual void AssignPictureBuffers( | |
| 44 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | |
| 45 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | |
| 46 virtual void Flush() OVERRIDE; | |
| 47 virtual void Reset() OVERRIDE; | |
| 48 virtual void Destroy() OVERRIDE; | |
| 49 | |
| 50 private: | |
| 51 virtual ~MacVideoDecodeAccelerator(); | |
| 52 | |
| 53 // Callback for a completed frame. | |
| 54 void OnFrameReady(int32 bitstream_buffer_id, | |
| 55 scoped_refptr<base::RefCountedBytes> bytes, | |
| 56 CVImageBufferRef image, | |
| 57 int status); | |
| 58 | |
| 59 // Sends available decoded frames to the client. | |
| 60 void SendImages(); | |
| 61 | |
| 62 // Calls the client's flush completed callback. | |
| 63 void NotifyFlushDone(); | |
| 64 | |
| 65 // Calls the client's reset completed callback. | |
| 66 void NotifyResetDone(); | |
| 67 | |
| 68 // To expose client callbacks from VideoDecodeAccelerator. | |
| 69 Client* client_; | |
| 70 // C++ wrapper around the Mac VDA API. | |
| 71 scoped_refptr<gfx::VideoDecodeAccelerationSupport> vda_; | |
|
Ami GONE FROM CHROMIUM
2012/05/17 21:44:47
Does VDAS need to be ref-counted (as opposed to no
Ami GONE FROM CHROMIUM
2012/05/17 21:44:47
Ouch; the name "vda_" makes me think of the interf
sail
2012/05/23 23:02:29
Done.
sail
2012/05/23 23:02:29
Yea, this needs to be refcounted. It's referenced
| |
| 72 // Picture buffers that are available for use by the decoder to draw decoded | |
| 73 // video frames on. | |
| 74 std::list<media::PictureBuffer> available_pictures_; | |
| 75 | |
| 76 // Maps ids to picture buffers that are in use by the client. | |
| 77 struct PendingPictureInfo { | |
|
Ami GONE FROM CHROMIUM
2012/05/17 21:44:47
s/pending/used/g (here and below) to parallel "ava
sail
2012/05/23 23:02:29
Done.
| |
| 78 PendingPictureInfo(media::PictureBuffer pic); | |
| 79 ~PendingPictureInfo(); | |
| 80 media::PictureBuffer picture_buffer; | |
| 81 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; | |
| 82 }; | |
| 83 std::map<int32, PendingPictureInfo> pending_pictures_; | |
| 84 | |
| 85 // List of decoded images waiting to be sent to the client. | |
| 86 struct DecodedImageInfo { | |
| 87 DecodedImageInfo(); | |
|
Ami GONE FROM CHROMIUM
2012/05/17 21:44:47
unnecessary?
sail
2012/05/23 23:02:29
Because of DecodedImageInfo::image the compiler co
| |
| 88 ~DecodedImageInfo(); | |
| 89 base::mac::ScopedCFTypeRef<CVImageBufferRef> image; | |
| 90 int32 bitstream_buffer_id; | |
| 91 }; | |
| 92 std::list<DecodedImageInfo> decoded_images_; | |
| 93 | |
| 94 // The context to use to perform OpenGL operations. | |
| 95 CGLContextObj cgl_context_; | |
| 96 | |
| 97 // The number of bytes used to store the frame buffer size. | |
| 98 size_t nalu_len_field_size_; | |
| 99 | |
| 100 // Width of a video frame. | |
| 101 uint32_t frame_width_; | |
|
Ami GONE FROM CHROMIUM
2012/05/17 21:44:47
unsigned is the devil.
In this case use gfx::Size
sail
2012/05/23 23:02:29
Done.
| |
| 102 // Height of a video frame. | |
| 103 uint32_t frame_height_; | |
| 104 // Flag to check if pictures have been requested from the client. | |
| 105 bool did_request_pictures_; | |
| 106 }; | |
| 107 | |
| 108 #endif // CONTENT_COMMON_GPU_MEDIA_VIDEO_DECODE_ACCELERATOR_MAC_H_ | |
| OLD | NEW |