| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ | 5 #ifndef MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ |
| 6 #define MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ | 6 #define MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "media/gpu/avda_state_provider.h" | 12 #include "media/gpu/avda_state_provider.h" |
| 13 #include "media/gpu/media_gpu_export.h" | 13 #include "media/gpu/media_gpu_export.h" |
| 14 | 14 |
| 15 namespace gpu { | 15 namespace gpu { |
| 16 namespace gles2 { | 16 namespace gles2 { |
| 17 class GLStreamTextureImage; | 17 class GLStreamTextureImage; |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace gl { | 21 namespace gl { |
| 22 class ScopedJavaSurface; | 22 class ScopedJavaSurface; |
| 23 class SurfaceTexture; | 23 class SurfaceTexture; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace media { | 26 namespace media { |
| 27 class AVDACodecImage; |
| 27 class AVDASharedState; | 28 class AVDASharedState; |
| 28 class VideoCodecBridge; | 29 class VideoCodecBridge; |
| 29 | 30 |
| 30 // AVDAPictureBufferManager is used by AVDA to associate its PictureBuffers with | 31 // AVDAPictureBufferManager is used by AVDA to associate its PictureBuffers with |
| 31 // MediaCodec output buffers. It attaches AVDACodecImages to the PictureBuffer | 32 // MediaCodec output buffers. It attaches AVDACodecImages to the PictureBuffer |
| 32 // textures so that when they're used to draw the AVDACodecImage can release the | 33 // textures so that when they're used to draw the AVDACodecImage can release the |
| 33 // MediaCodec buffer to the backing Surface. If the Surface is a SurfaceTexture, | 34 // MediaCodec buffer to the backing Surface. If the Surface is a SurfaceTexture, |
| 34 // the front buffer can then be used to draw without needing to copy the pixels. | 35 // the front buffer can then be used to draw without needing to copy the pixels. |
| 35 // If the Surface is a SurfaceView, the release causes the frame to be displayed | 36 // If the Surface is a SurfaceView, the release causes the frame to be displayed |
| 36 // immediately. | 37 // immediately. |
| 37 class MEDIA_GPU_EXPORT AVDAPictureBufferManager { | 38 class MEDIA_GPU_EXPORT AVDAPictureBufferManager { |
| 38 public: | 39 public: |
| 39 using PictureBufferMap = std::map<int32_t, PictureBuffer>; | 40 using PictureBufferMap = std::map<int32_t, PictureBuffer>; |
| 40 | 41 |
| 41 AVDAPictureBufferManager(); | 42 explicit AVDAPictureBufferManager(AVDAStateProvider* state_provider); |
| 42 virtual ~AVDAPictureBufferManager(); | 43 virtual ~AVDAPictureBufferManager(); |
| 43 | 44 |
| 44 // Must be called before anything else. If |surface_view_id| is |kNoSurfaceID| | 45 // Must be called before anything else. If |surface_id| is |kNoSurfaceID| |
| 45 // then a new SurfaceTexture will be returned. Otherwise, the corresponding | 46 // then a new SurfaceTexture will be returned. Otherwise, the corresponding |
| 46 // SurfaceView will be returned. | 47 // SurfaceView will be returned. |
| 47 gl::ScopedJavaSurface Initialize(AVDAStateProvider* state_provider, | 48 gl::ScopedJavaSurface Initialize(int surface_id); |
| 48 int surface_view_id); | |
| 49 | 49 |
| 50 void Destroy(const PictureBufferMap& buffers); | 50 void Destroy(const PictureBufferMap& buffers); |
| 51 | 51 |
| 52 // Returns the GL texture target that the PictureBuffer textures use. | 52 // Returns the GL texture target that the PictureBuffer textures use. |
| 53 uint32_t GetTextureTarget() const; | 53 uint32_t GetTextureTarget() const; |
| 54 | 54 |
| 55 // Returns the size to use when requesting picture buffers. | 55 // Returns the size to use when requesting picture buffers. |
| 56 gfx::Size GetPictureBufferSize() const; | 56 gfx::Size GetPictureBufferSize() const; |
| 57 | 57 |
| 58 // Sets up |picture_buffer| so that its texture will refer to the image that | 58 // Sets up |picture_buffer| so that its texture will refer to the image that |
| (...skipping 20 matching lines...) Expand all Loading... |
| 79 void CodecChanged(VideoCodecBridge* codec); | 79 void CodecChanged(VideoCodecBridge* codec); |
| 80 | 80 |
| 81 // Whether the pictures buffers are overlayable. | 81 // Whether the pictures buffers are overlayable. |
| 82 bool ArePicturesOverlayable(); | 82 bool ArePicturesOverlayable(); |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 // Release any codec buffer that is associated with the given picture buffer | 85 // Release any codec buffer that is associated with the given picture buffer |
| 86 // back to the codec. It is okay if there is no such buffer. | 86 // back to the codec. It is okay if there is no such buffer. |
| 87 void ReleaseCodecBufferForPicture(const PictureBuffer& picture_buffer); | 87 void ReleaseCodecBufferForPicture(const PictureBuffer& picture_buffer); |
| 88 | 88 |
| 89 gpu::gles2::TextureRef* GetTextureForPicture( | |
| 90 const PictureBuffer& picture_buffer); | |
| 91 | |
| 92 // Sets up the texture references (as found by |picture_buffer|), for the | 89 // Sets up the texture references (as found by |picture_buffer|), for the |
| 93 // specified |image|. If |image| is null, clears any ref on the texture | 90 // specified |image|. If |image| is null, clears any ref on the texture |
| 94 // associated with |picture_buffer|. | 91 // associated with |picture_buffer|. |
| 95 void SetImageForPicture( | 92 void SetImageForPicture(const PictureBuffer& picture_buffer, |
| 96 const PictureBuffer& picture_buffer, | 93 gpu::gles2::GLStreamTextureImage* image); |
| 97 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image); | 94 |
| 95 AVDACodecImage* GetImageForPicture(int picture_buffer_id) const; |
| 98 | 96 |
| 99 scoped_refptr<AVDASharedState> shared_state_; | 97 scoped_refptr<AVDASharedState> shared_state_; |
| 100 | 98 |
| 101 AVDAStateProvider* state_provider_; | 99 AVDAStateProvider* const state_provider_; |
| 102 | 100 |
| 103 // The SurfaceTexture to render to. Non-null after Initialize() if | 101 // The SurfaceTexture to render to. Non-null after Initialize() if |
| 104 // we're not rendering to a SurfaceView. | 102 // we're not rendering to a SurfaceView. |
| 105 scoped_refptr<gl::SurfaceTexture> surface_texture_; | 103 scoped_refptr<gl::SurfaceTexture> surface_texture_; |
| 106 | 104 |
| 107 class OnFrameAvailableHandler; | |
| 108 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; | |
| 109 | |
| 110 VideoCodecBridge* media_codec_; | 105 VideoCodecBridge* media_codec_; |
| 111 | 106 |
| 112 // Picture buffer IDs that are out for display. Stored in order of frames as | 107 // Picture buffer IDs that are out for display. Stored in order of frames as |
| 113 // they are returned from the decoder. | 108 // they are returned from the decoder. |
| 114 std::vector<int32_t> pictures_out_for_display_; | 109 std::vector<int32_t> pictures_out_for_display_; |
| 115 | 110 |
| 111 // Maps a picture buffer id to a AVDACodecImage. |
| 112 std::map<int, scoped_refptr<AVDACodecImage>> codec_images_; |
| 113 |
| 116 DISALLOW_COPY_AND_ASSIGN(AVDAPictureBufferManager); | 114 DISALLOW_COPY_AND_ASSIGN(AVDAPictureBufferManager); |
| 117 }; | 115 }; |
| 118 | 116 |
| 119 } // namespace media | 117 } // namespace media |
| 120 | 118 |
| 121 #endif // MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ | 119 #endif // MEDIA_GPU_AVDA_PICTURE_BUFFER_MANAGER_H_ |
| OLD | NEW |