Index: media/base/android/android_util.cc |
diff --git a/media/base/android/android_util.cc b/media/base/android/android_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..371f7e56c1cbba63deaffd89955adc220172806e |
--- /dev/null |
+++ b/media/base/android/android_util.cc |
@@ -0,0 +1,27 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "media/base/android/android_util.h" |
+ |
+#include <stddef.h> |
+#include <vector> |
+ |
+#include "base/android/jni_android.h" |
+#include "base/android/jni_array.h" |
+ |
+namespace media { |
+ |
+std::string JavaBytesToString(JNIEnv* env, jbyteArray j_byte_array) { |
+ std::vector<uint8_t> byte_vector; |
+ base::android::JavaByteArrayToByteVector(env, j_byte_array, &byte_vector); |
+ return std::string(byte_vector.begin(), byte_vector.end()); |
+} |
+ |
+JavaObjectPtr CreateJavaObjectPtr(jobject object) { |
+ JavaObjectPtr j_object_ptr(new base::android::ScopedJavaGlobalRef<jobject>()); |
+ j_object_ptr->Reset(base::android::AttachCurrentThread(), object); |
+ return j_object_ptr; |
+} |
+ |
+} // namespace media |