OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/base/android/dialog_surface_manager.h" | 5 #include "media/base/android/dialog_surface_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/android/build_info.h" | 12 #include "base/android/build_info.h" |
13 #include "base/android/jni_android.h" | 13 #include "base/android/jni_android.h" |
14 #include "base/android/jni_array.h" | 14 #include "base/android/jni_array.h" |
15 #include "base/android/jni_string.h" | 15 #include "base/android/jni_string.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/numerics/safe_conversions.h" | 17 #include "base/numerics/safe_conversions.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "gpu/ipc/common/android/dialog_surface_lookup.h" | 19 #include "gpu/ipc/common/android/dialog_surface_lookup.h" |
20 #include "jni/DialogSurfaceManagerWrapper_jni.h" | 20 #include "jni/DialogSurfaceManagerWrapper_jni.h" |
| 21 #include "media/base/android/dialog_surface_callback.h" |
21 #include "media/base/bit_reader.h" | 22 #include "media/base/bit_reader.h" |
22 #include "media/base/decrypt_config.h" | 23 #include "media/base/decrypt_config.h" |
23 | 24 |
24 using base::android::AttachCurrentThread; | 25 using base::android::AttachCurrentThread; |
25 using base::android::ConvertJavaStringToUTF8; | 26 using base::android::ConvertJavaStringToUTF8; |
26 using base::android::ConvertUTF8ToJavaString; | 27 using base::android::ConvertUTF8ToJavaString; |
27 using base::android::JavaIntArrayToIntVector; | 28 using base::android::JavaIntArrayToIntVector; |
28 using base::android::ScopedJavaGlobalRef; | 29 using base::android::ScopedJavaGlobalRef; |
29 using base::android::ScopedJavaLocalRef; | 30 using base::android::ScopedJavaLocalRef; |
30 | 31 |
(...skipping 24 matching lines...) Expand all Loading... |
55 DialogSurfaceManager::~DialogSurfaceManager() {} | 56 DialogSurfaceManager::~DialogSurfaceManager() {} |
56 | 57 |
57 std::unique_ptr<DialogSurfaceHolder> DialogSurfaceManager::CreateSurface( | 58 std::unique_ptr<DialogSurfaceHolder> DialogSurfaceManager::CreateSurface( |
58 base::ProcessHandle pid, | 59 base::ProcessHandle pid, |
59 int frame_id, | 60 int frame_id, |
60 const Config& config, | 61 const Config& config, |
61 const DialogSurfaceHolder::Callback& callback) { | 62 const DialogSurfaceHolder::Callback& callback) { |
62 JNIEnv* env = AttachCurrentThread(); | 63 JNIEnv* env = AttachCurrentThread(); |
63 CHECK(env); | 64 CHECK(env); |
64 | 65 |
65 // TODO(liberato): wrap the callback here, and send in place of the nullptr. | 66 std::unique_ptr<DialogSurfaceCallback> wrapped_callback( |
66 // This was omitted for the first CL. | 67 new DialogSurfaceCallback(callback)); |
67 | 68 |
68 ScopedJavaGlobalRef<jobject> result( | 69 ScopedJavaGlobalRef<jobject> result( |
69 Java_DialogSurfaceManagerWrapper_createSurface( | 70 Java_DialogSurfaceManagerWrapper_createSurface( |
70 env, j_wrapped_manager_.obj(), pid, frame_id, nullptr, | 71 env, j_wrapped_manager_.obj(), pid, frame_id, wrapped_callback->obj(), |
71 config.rect.x(), config.rect.y(), config.rect.width(), | 72 config.rect.x(), config.rect.y(), config.rect.width(), |
72 config.rect.height())); | 73 config.rect.height())); |
73 // NOTE: result is always null right now. | |
74 | 74 |
75 std::unique_ptr<DialogSurfaceHolder> holder; | 75 std::unique_ptr<DialogSurfaceHolder> holder; |
| 76 if (result.obj() != nullptr) { |
| 77 holder.reset(new DialogSurfaceHolder(result, std::move(wrapped_callback))); |
| 78 } |
76 | 79 |
77 return holder; | 80 return holder; |
78 } | 81 } |
79 | 82 |
80 } // namespace media | 83 } // namespace media |
OLD | NEW |