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 #include "media/gpu/avda_shared_state.h" | 5 #include "media/gpu/avda_shared_state.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "media/gpu/avda_codec_image.h" | 9 #include "media/gpu/avda_codec_image.h" |
10 #include "ui/gl/android/surface_texture.h" | 10 #include "ui/gl/android/surface_texture.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 scoped_refptr<gl::SurfaceTexture> surface_texture, | 67 scoped_refptr<gl::SurfaceTexture> surface_texture, |
68 GLuint attached_service_id) { | 68 GLuint attached_service_id) { |
69 surface_texture_ = surface_texture; | 69 surface_texture_ = surface_texture; |
70 surface_texture_service_id_ = attached_service_id; | 70 surface_texture_service_id_ = attached_service_id; |
71 context_ = gl::GLContext::GetCurrent(); | 71 context_ = gl::GLContext::GetCurrent(); |
72 surface_ = gl::GLSurface::GetCurrent(); | 72 surface_ = gl::GLSurface::GetCurrent(); |
73 DCHECK(context_); | 73 DCHECK(context_); |
74 DCHECK(surface_); | 74 DCHECK(surface_); |
75 } | 75 } |
76 | 76 |
77 void AVDASharedState::CodecChanged(media::MediaCodecBridge* codec) { | 77 void AVDASharedState::CodecChanged(MediaCodecBridge* codec) { |
78 for (auto& image_kv : codec_images_) | 78 for (auto& image_kv : codec_images_) |
79 image_kv.second->CodecChanged(codec); | 79 image_kv.second->CodecChanged(codec); |
80 release_time_ = base::TimeTicks(); | 80 release_time_ = base::TimeTicks(); |
81 } | 81 } |
82 | 82 |
83 void AVDASharedState::SetImageForPicture(int picture_buffer_id, | 83 void AVDASharedState::SetImageForPicture(int picture_buffer_id, |
84 AVDACodecImage* image) { | 84 AVDACodecImage* image) { |
85 if (!image) { | 85 if (!image) { |
86 DCHECK(codec_images_.find(picture_buffer_id) != codec_images_.end()); | 86 DCHECK(codec_images_.find(picture_buffer_id) != codec_images_.end()); |
87 codec_images_.erase(picture_buffer_id); | 87 codec_images_.erase(picture_buffer_id); |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 DCHECK(codec_images_.find(picture_buffer_id) == codec_images_.end()); | 91 DCHECK(codec_images_.find(picture_buffer_id) == codec_images_.end()); |
92 codec_images_[picture_buffer_id] = image; | 92 codec_images_[picture_buffer_id] = image; |
93 } | 93 } |
94 | 94 |
95 AVDACodecImage* AVDASharedState::GetImageForPicture( | 95 AVDACodecImage* AVDASharedState::GetImageForPicture( |
96 int picture_buffer_id) const { | 96 int picture_buffer_id) const { |
97 auto it = codec_images_.find(picture_buffer_id); | 97 auto it = codec_images_.find(picture_buffer_id); |
98 return it == codec_images_.end() ? nullptr : it->second; | 98 return it == codec_images_.end() ? nullptr : it->second; |
99 } | 99 } |
100 | 100 |
101 void AVDASharedState::RenderCodecBufferToSurfaceTexture( | 101 void AVDASharedState::RenderCodecBufferToSurfaceTexture( |
102 media::MediaCodecBridge* codec, | 102 MediaCodecBridge* codec, |
103 int codec_buffer_index) { | 103 int codec_buffer_index) { |
104 if (!release_time_.is_null()) | 104 if (!release_time_.is_null()) |
105 WaitForFrameAvailable(); | 105 WaitForFrameAvailable(); |
106 codec->ReleaseOutputBuffer(codec_buffer_index, true); | 106 codec->ReleaseOutputBuffer(codec_buffer_index, true); |
107 release_time_ = base::TimeTicks::Now(); | 107 release_time_ = base::TimeTicks::Now(); |
108 } | 108 } |
109 | 109 |
110 } // namespace media | 110 } // namespace media |
OLD | NEW |