Chromium Code Reviews| 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 CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ | 5 #ifndef MEDIA_GPU_AVDA_SHARED_STATE_H_ |
| 6 #define CONTENT_COMMON_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" |
| 11 #include "media/base/android/sdk_media_codec_bridge.h" | 11 #include "media/base/android/sdk_media_codec_bridge.h" |
| 12 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
| 13 #include "ui/gl/gl_image.h" | 13 #include "ui/gl/gl_image.h" |
| 14 #include "ui/gl/gl_surface.h" | 14 #include "ui/gl/gl_surface.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 70 |
| 71 // Call this when the SurfaceTexture is attached to a GL context. This will | 71 // Call this when the SurfaceTexture is attached to a GL context. This will |
| 72 // update surface_texture_is_attached(), and set the context() and surface() | 72 // update surface_texture_is_attached(), and set the context() and surface() |
| 73 // to match. | 73 // to match. |
| 74 void DidAttachSurfaceTexture(); | 74 void DidAttachSurfaceTexture(); |
| 75 | 75 |
| 76 // Call this when the SurfaceTexture is detached from its GL context. This | 76 // Call this when the SurfaceTexture is detached from its GL context. This |
| 77 // will cause us to forget the last binding. | 77 // will cause us to forget the last binding. |
| 78 void DidDetachSurfaceTexture(); | 78 void DidDetachSurfaceTexture(); |
| 79 | 79 |
| 80 // Helper method for coordinating the interactions between | |
| 81 // MediaCodec::ReleaseOutputBuffer() and WaitForFrameAvailable() when | |
| 82 // rendering to a SurfaceTexture; this method should | |
|
watk
2016/05/02 23:32:34
Comment abruptly ends :)
DaleCurtis
2016/05/03 00:17:54
Done.
| |
| 83 // | |
| 84 // The release of the codec buffer to the surface texture is asynchronous, by | |
| 85 // by using this helper we can attempt to let this process complete in a non | |
|
watk
2016/05/02 23:32:34
delete one "by"
DaleCurtis
2016/05/03 00:17:54
You passed the if if test!
| |
| 86 // blocking fashion before the SurfaceTexture is used. | |
| 87 // | |
| 88 // Clients should call this method to release the codec buffer for rendering | |
| 89 // and then call WaitForFrameAvailable() before using the SurfaceTexture. In | |
| 90 // the ideal case the SurfaceTexture has already been updated, otherwise the | |
| 91 // method will wait for a pro-rated amount of time based on elapsed time up | |
| 92 // to a short deadline. | |
| 93 // | |
| 94 // Some devices do not reliably notify frame availability, so we use a very | |
| 95 // short deadline of only a few milliseconds to avoid indefinite stalls. | |
| 96 void RenderCodecBufferToSurfaceTexture(media::MediaCodecBridge* codec, | |
| 97 int codec_buffer_index); | |
| 98 | |
| 80 protected: | 99 protected: |
| 81 virtual ~AVDASharedState(); | 100 virtual ~AVDASharedState(); |
| 82 | 101 |
| 83 private: | 102 private: |
| 84 friend class base::RefCounted<AVDASharedState>; | 103 friend class base::RefCounted<AVDASharedState>; |
| 85 | 104 |
| 86 // Platform gl texture Id for |surface_texture_|. This will be zero if | 105 // Platform gl texture Id for |surface_texture_|. This will be zero if |
| 87 // and only if |texture_owner_| is null. | 106 // and only if |texture_owner_| is null. |
| 88 // TODO(liberato): This should be GLuint, but we don't seem to have the type. | 107 // TODO(liberato): This should be GLuint, but we don't seem to have the type. |
| 89 GLint surface_texture_service_id_; | 108 GLint surface_texture_service_id_; |
| 90 | 109 |
| 91 // For signalling OnFrameAvailable(). | 110 // For signalling OnFrameAvailable(). |
| 92 base::WaitableEvent frame_available_event_; | 111 base::WaitableEvent frame_available_event_; |
| 93 | 112 |
| 94 // True if and only if the surface texture is currently attached. | 113 // True if and only if the surface texture is currently attached. |
| 95 bool surface_texture_is_attached_; | 114 bool surface_texture_is_attached_; |
| 96 | 115 |
| 97 // Context and surface that the surface texture is attached to, if it is | 116 // Context and surface that the surface texture is attached to, if it is |
| 98 // currently attached. | 117 // currently attached. |
| 99 scoped_refptr<gfx::GLContext> context_; | 118 scoped_refptr<gfx::GLContext> context_; |
| 100 scoped_refptr<gfx::GLSurface> surface_; | 119 scoped_refptr<gfx::GLSurface> surface_; |
| 101 | 120 |
| 102 // Maps a picture buffer id to a AVDACodecImage. | 121 // Maps a picture buffer id to a AVDACodecImage. |
| 103 std::map<int, AVDACodecImage*> codec_images_; | 122 std::map<int, AVDACodecImage*> codec_images_; |
| 104 | 123 |
| 124 // The time of the last call to RenderCodecBufferToSurfaceTexture(), null if | |
| 125 // there has been no last call. | |
| 126 base::TimeTicks release_time_; | |
| 127 | |
| 105 DISALLOW_COPY_AND_ASSIGN(AVDASharedState); | 128 DISALLOW_COPY_AND_ASSIGN(AVDASharedState); |
| 106 }; | 129 }; |
| 107 | 130 |
| 108 } // namespace media | 131 } // namespace media |
| 109 | 132 |
| 110 #endif // CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_ | 133 #endif // MEDIA_GPU_AVDA_SHARED_STATE_H_ |
| OLD | NEW |