OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/android_video_decode_accelerator.h" | 5 #include "media/gpu/android_video_decode_accelerator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // SurfaceTexture will quit sending callbacks to coordinate with the | 126 // SurfaceTexture will quit sending callbacks to coordinate with the |
127 // destruction of the AVDA, so we have a separate object that the cb can own. | 127 // destruction of the AVDA, so we have a separate object that the cb can own. |
128 class AndroidVideoDecodeAccelerator::OnFrameAvailableHandler | 128 class AndroidVideoDecodeAccelerator::OnFrameAvailableHandler |
129 : public base::RefCountedThreadSafe<OnFrameAvailableHandler> { | 129 : public base::RefCountedThreadSafe<OnFrameAvailableHandler> { |
130 public: | 130 public: |
131 // We do not retain ownership of |owner|. It must remain valid until | 131 // We do not retain ownership of |owner|. It must remain valid until |
132 // after ClearOwner() is called. This will register with | 132 // after ClearOwner() is called. This will register with |
133 // |surface_texture| to receive OnFrameAvailable callbacks. | 133 // |surface_texture| to receive OnFrameAvailable callbacks. |
134 OnFrameAvailableHandler( | 134 OnFrameAvailableHandler( |
135 AndroidVideoDecodeAccelerator* owner, | 135 AndroidVideoDecodeAccelerator* owner, |
136 const scoped_refptr<gfx::SurfaceTexture>& surface_texture) | 136 const scoped_refptr<gl::SurfaceTexture>& surface_texture) |
137 : owner_(owner) { | 137 : owner_(owner) { |
138 // Note that the callback owns a strong ref to us. | 138 // Note that the callback owns a strong ref to us. |
139 surface_texture->SetFrameAvailableCallbackOnAnyThread( | 139 surface_texture->SetFrameAvailableCallbackOnAnyThread( |
140 base::Bind(&OnFrameAvailableHandler::OnFrameAvailable, | 140 base::Bind(&OnFrameAvailableHandler::OnFrameAvailable, |
141 scoped_refptr<OnFrameAvailableHandler>(this))); | 141 scoped_refptr<OnFrameAvailableHandler>(this))); |
142 } | 142 } |
143 | 143 |
144 // Forget about our owner, which is required before one deletes it. | 144 // Forget about our owner, which is required before one deletes it. |
145 // No further callbacks will happen once this completes. | 145 // No further callbacks will happen once this completes. |
146 void ClearOwner() { | 146 void ClearOwner() { |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 return false; | 519 return false; |
520 } | 520 } |
521 | 521 |
522 on_destroying_surface_cb_ = | 522 on_destroying_surface_cb_ = |
523 base::Bind(&AndroidVideoDecodeAccelerator::OnDestroyingSurface, | 523 base::Bind(&AndroidVideoDecodeAccelerator::OnDestroyingSurface, |
524 weak_this_factory_.GetWeakPtr()); | 524 weak_this_factory_.GetWeakPtr()); |
525 AVDASurfaceTracker::GetInstance()->RegisterOnDestroyingSurfaceCallback( | 525 AVDASurfaceTracker::GetInstance()->RegisterOnDestroyingSurfaceCallback( |
526 on_destroying_surface_cb_); | 526 on_destroying_surface_cb_); |
527 | 527 |
528 // TODO(watk,liberato): move this into the strategy. | 528 // TODO(watk,liberato): move this into the strategy. |
529 scoped_refptr<gfx::SurfaceTexture> surface_texture = | 529 scoped_refptr<gl::SurfaceTexture> surface_texture = |
530 strategy_->GetSurfaceTexture(); | 530 strategy_->GetSurfaceTexture(); |
531 if (surface_texture) { | 531 if (surface_texture) { |
532 on_frame_available_handler_ = | 532 on_frame_available_handler_ = |
533 new OnFrameAvailableHandler(this, surface_texture); | 533 new OnFrameAvailableHandler(this, surface_texture); |
534 } | 534 } |
535 | 535 |
536 // Start the thread for async configuration, even if we don't need it now. | 536 // Start the thread for async configuration, even if we don't need it now. |
537 // ResetCodecState might rebuild the codec later, for example. | 537 // ResetCodecState might rebuild the codec later, for example. |
538 if (!g_avda_timer.Pointer()->StartThread(this)) { | 538 if (!g_avda_timer.Pointer()->StartThread(this)) { |
539 LOG(ERROR) << "Failed to start AVDA thread"; | 539 LOG(ERROR) << "Failed to start AVDA thread"; |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { | 1628 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { |
1629 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1629 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
1630 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1630 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
1631 } | 1631 } |
1632 } | 1632 } |
1633 | 1633 |
1634 return capabilities; | 1634 return capabilities; |
1635 } | 1635 } |
1636 | 1636 |
1637 } // namespace media | 1637 } // namespace media |
OLD | NEW |