| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/mojo/clients/mojo_android_overlay.h" | 5 #include "media/mojo/clients/mojo_android_overlay.h" |
| 6 | 6 |
| 7 #include "services/service_manager/public/cpp/connect.h" | 7 #include "services/service_manager/public/cpp/connect.h" |
| 8 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" | 8 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| 12 MojoAndroidOverlay::MojoAndroidOverlay( | 12 MojoAndroidOverlay::MojoAndroidOverlay( |
| 13 service_manager::mojom::InterfaceProvider* interface_provider, | 13 service_manager::mojom::InterfaceProvider* interface_provider, |
| 14 const AndroidOverlay::Config& config, | 14 AndroidOverlayConfig config, |
| 15 const base::UnguessableToken& routing_token) | 15 const base::UnguessableToken& routing_token) |
| 16 : interface_provider_(interface_provider), config_(config) { | 16 : interface_provider_(interface_provider), config_(std::move(config)) { |
| 17 // Connect to the provider service. | 17 // Connect to the provider service. |
| 18 mojom::AndroidOverlayProviderPtr provider_ptr; | 18 mojom::AndroidOverlayProviderPtr provider_ptr; |
| 19 service_manager::GetInterface<mojom::AndroidOverlayProvider>( | 19 service_manager::GetInterface<mojom::AndroidOverlayProvider>( |
| 20 interface_provider_, &provider_ptr_); | 20 interface_provider_, &provider_ptr_); |
| 21 | 21 |
| 22 // Fill in details of |config| into |mojo_config|. Our caller could do this | 22 // Fill in details of |config| into |mojo_config|. Our caller could do this |
| 23 // too, but since we want to retain |config_| anyway, we do it here. | 23 // too, but since we want to retain |config_| anyway, we do it here. |
| 24 mojom::AndroidOverlayConfigPtr mojo_config = | 24 mojom::AndroidOverlayConfigPtr mojo_config = |
| 25 mojom::AndroidOverlayConfig::New(); | 25 mojom::AndroidOverlayConfig::New(); |
| 26 mojo_config->routing_token = routing_token; | 26 mojo_config->routing_token = routing_token; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 50 } | 50 } |
| 51 | 51 |
| 52 const base::android::JavaRef<jobject>& MojoAndroidOverlay::GetJavaSurface() | 52 const base::android::JavaRef<jobject>& MojoAndroidOverlay::GetJavaSurface() |
| 53 const { | 53 const { |
| 54 return surface_.j_surface(); | 54 return surface_.j_surface(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void MojoAndroidOverlay::OnSurfaceReady(uint64_t surface_key) { | 57 void MojoAndroidOverlay::OnSurfaceReady(uint64_t surface_key) { |
| 58 // TODO(liberato): ask binder for the surface here, and fill in |surface_|. | 58 // TODO(liberato): ask binder for the surface here, and fill in |surface_|. |
| 59 received_surface_ = true; | 59 received_surface_ = true; |
| 60 config_.ready_cb.Run(this); | 60 config_.is_ready(this); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void MojoAndroidOverlay::OnDestroyed() { | 63 void MojoAndroidOverlay::OnDestroyed() { |
| 64 // Note that |overlay_ptr_| might not be bound yet, or we might not have ever | 64 // Note that |overlay_ptr_| might not be bound yet, or we might not have ever |
| 65 // gotten a surface. Regardless, the overlay cannot be used. | 65 // gotten a surface. Regardless, the overlay cannot be used. |
| 66 | 66 |
| 67 if (!received_surface_) | 67 if (!received_surface_) |
| 68 config_.failed_cb.Run(this); | 68 config_.is_failed(this); |
| 69 else | 69 else |
| 70 config_.destroyed_cb.Run(this); | 70 config_.is_destroyed(this); |
| 71 | 71 |
| 72 // Note: we do not delete |overlay_ptr_| here. Our client must delete us to | 72 // Note: we do not delete |overlay_ptr_| here. Our client must delete us to |
| 73 // signal that we should do that, since it still might be in use. | 73 // signal that we should do that, since it still might be in use. |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace media | 76 } // namespace media |
| OLD | NEW |