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_SHARED_STATE_H_ | 5 #ifndef MEDIA_GPU_AVDA_SHARED_STATE_H_ |
6 #define MEDIA_GPU_AVDA_SHARED_STATE_H_ | 6 #define MEDIA_GPU_AVDA_SHARED_STATE_H_ |
7 | 7 |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 GLuint attached_service_id); | 40 GLuint attached_service_id); |
41 | 41 |
42 // Context and surface that |surface_texture_| is bound to, if | 42 // Context and surface that |surface_texture_| is bound to, if |
43 // |surface_texture_| is not null. | 43 // |surface_texture_| is not null. |
44 gl::GLContext* context() const { return context_.get(); } | 44 gl::GLContext* context() const { return context_.get(); } |
45 | 45 |
46 gl::GLSurface* surface() const { return surface_.get(); } | 46 gl::GLSurface* surface() const { return surface_.get(); } |
47 | 47 |
48 // Iterates over all known codec images and updates the MediaCodec attached to | 48 // Iterates over all known codec images and updates the MediaCodec attached to |
49 // each one. | 49 // each one. |
50 void CodecChanged(media::MediaCodecBridge* codec); | 50 void CodecChanged(MediaCodecBridge* codec); |
51 | 51 |
52 // Methods for finding and updating the AVDACodecImage associated with a given | 52 // Methods for finding and updating the AVDACodecImage associated with a given |
53 // picture buffer id. GetImageForPicture() will return null for unknown ids. | 53 // picture buffer id. GetImageForPicture() will return null for unknown ids. |
54 // Calling SetImageForPicture() with a nullptr will erase the entry. | 54 // Calling SetImageForPicture() with a nullptr will erase the entry. |
55 void SetImageForPicture(int picture_buffer_id, AVDACodecImage* image); | 55 void SetImageForPicture(int picture_buffer_id, AVDACodecImage* image); |
56 AVDACodecImage* GetImageForPicture(int picture_buffer_id) const; | 56 AVDACodecImage* GetImageForPicture(int picture_buffer_id) const; |
57 | 57 |
58 // Helper method for coordinating the interactions between | 58 // Helper method for coordinating the interactions between |
59 // MediaCodec::ReleaseOutputBuffer() and WaitForFrameAvailable() when | 59 // MediaCodec::ReleaseOutputBuffer() and WaitForFrameAvailable() when |
60 // rendering to a SurfaceTexture; this method should never be called when | 60 // rendering to a SurfaceTexture; this method should never be called when |
61 // rendering to a SurfaceView. | 61 // rendering to a SurfaceView. |
62 // | 62 // |
63 // The release of the codec buffer to the surface texture is asynchronous, by | 63 // The release of the codec buffer to the surface texture is asynchronous, by |
64 // using this helper we can attempt to let this process complete in a non | 64 // using this helper we can attempt to let this process complete in a non |
65 // blocking fashion before the SurfaceTexture is used. | 65 // blocking fashion before the SurfaceTexture is used. |
66 // | 66 // |
67 // Clients should call this method to release the codec buffer for rendering | 67 // Clients should call this method to release the codec buffer for rendering |
68 // and then call WaitForFrameAvailable() before using the SurfaceTexture. In | 68 // and then call WaitForFrameAvailable() before using the SurfaceTexture. In |
69 // the ideal case the SurfaceTexture has already been updated, otherwise the | 69 // the ideal case the SurfaceTexture has already been updated, otherwise the |
70 // method will wait for a pro-rated amount of time based on elapsed time up | 70 // method will wait for a pro-rated amount of time based on elapsed time up |
71 // to a short deadline. | 71 // to a short deadline. |
72 // | 72 // |
73 // Some devices do not reliably notify frame availability, so we use a very | 73 // Some devices do not reliably notify frame availability, so we use a very |
74 // short deadline of only a few milliseconds to avoid indefinite stalls. | 74 // short deadline of only a few milliseconds to avoid indefinite stalls. |
75 void RenderCodecBufferToSurfaceTexture(media::MediaCodecBridge* codec, | 75 void RenderCodecBufferToSurfaceTexture(MediaCodecBridge* codec, |
76 int codec_buffer_index); | 76 int codec_buffer_index); |
77 | 77 |
78 protected: | 78 protected: |
79 virtual ~AVDASharedState(); | 79 virtual ~AVDASharedState(); |
80 | 80 |
81 private: | 81 private: |
82 friend class base::RefCounted<AVDASharedState>; | 82 friend class base::RefCounted<AVDASharedState>; |
83 | 83 |
84 scoped_refptr<gl::SurfaceTexture> surface_texture_; | 84 scoped_refptr<gl::SurfaceTexture> surface_texture_; |
85 | 85 |
(...skipping 15 matching lines...) Expand all Loading... |
101 // if there has been no last call or WaitForFrameAvailable() has been called | 101 // if there has been no last call or WaitForFrameAvailable() has been called |
102 // since the last call. | 102 // since the last call. |
103 base::TimeTicks release_time_; | 103 base::TimeTicks release_time_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(AVDASharedState); | 105 DISALLOW_COPY_AND_ASSIGN(AVDASharedState); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace media | 108 } // namespace media |
109 | 109 |
110 #endif // MEDIA_GPU_AVDA_SHARED_STATE_H_ | 110 #endif // MEDIA_GPU_AVDA_SHARED_STATE_H_ |
OLD | NEW |