Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2dc18b0 authored by Marco Nelissen's avatar Marco Nelissen Committed by Android (Google) Code Review
Browse files

Merge "Remove MediaPlayer2"

parents 3d091d1e a523204f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2,9 +2,7 @@
// libmediadrm
//

// TODO: change it back to cc_library_shared when MediaPlayer2 switches to
// using NdkMediaDrm, instead of MediaDrm.java.
cc_library {
cc_library_shared {
    name: "libmediadrm",

    srcs: [

media/libmediaplayer2/Android.bp

deleted100644 → 0
+0 −129
Original line number Diff line number Diff line
cc_library_headers {
    name: "libmediaplayer2_headers",
    vendor_available: true,
    export_include_dirs: ["include"],
}

cc_library_static {
    name: "libmediaplayer2",

    srcs: [
        "MediaPlayer2AudioOutput.cpp",
        "mediaplayer2.cpp",
    ],

    shared_libs: [
        "libandroid_runtime",
        "libaudioclient",
        "libbinder",
        "libbinder_ndk",
        "libcutils",
        "libgui",
        "liblog",
        "libmedia_omx",
        "libui",
        "libutils",

        "libcrypto",
        "libmediametrics",
        "libmediandk",
        "libmediandk_utils",
        "libmediautils",
        "libmemunreachable",
        "libnativewindow",
        "libpowermanager",
        "libstagefright_httplive",
    ],

    export_shared_lib_headers: [
        "libaudioclient",
        "libbinder",
        "libgui",
        "libmedia_omx",
    ],

    header_libs: [
        "media_plugin_headers",
    ],

    include_dirs: [
        "frameworks/base/core/jni",
    ],

    static_libs: [
        "libmedia_helper",
        "libmediaplayer2-protos",
        "libmedia_player2_util",
        "libprotobuf-cpp-lite",
        "libstagefright_foundation_without_imemory",
        "libstagefright_nuplayer2",
        "libstagefright_player2",
        "libstagefright_rtsp",
        "libstagefright_timedtext2",
        "libmedia2_jni_core",
    ],

    export_include_dirs: [
        "include",
    ],

    cflags: [
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wall",
    ],

    sanitize: {
        misc_undefined: [
            "unsigned-integer-overflow",
            "signed-integer-overflow",
        ],
        cfi: true,
    },
}

cc_library {
    name: "libmedia2_jni_core",

    srcs: [
        "JavaVMHelper.cpp",
        "JAudioTrack.cpp",
        "JMedia2HTTPService.cpp",
        "JMedia2HTTPConnection.cpp",
    ],

    header_libs: [
        "libbinder_headers",
        "libnativehelper_header_only",
    ],

    shared_libs: [
        "liblog",
        "libutils",
        "libdl",
    ],

    include_dirs: [
        "frameworks/av/media/libmedia/include",
        "frameworks/base/core/jni",
    ],

    export_include_dirs: [
        "include",
    ],

    cflags: [
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wall",
    ],

    sanitize: {
        misc_undefined: [
            "unsigned-integer-overflow",
            "signed-integer-overflow",
        ],
        cfi: true,
    },

}
+0 −768

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −179
Original line number Diff line number Diff line
/*
 * Copyright 2017, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "JMedia2HTTPConnection"
#include <utils/Log.h>

#include <mediaplayer2/JavaVMHelper.h>
#include <mediaplayer2/JMedia2HTTPConnection.h>
#include <media/stagefright/foundation/ADebug.h>
#include <nativehelper/scoped_local_ref.h>

#include "log/log.h"
#include "jni.h"

namespace android {

static const size_t kBufferSize = 32768;

JMedia2HTTPConnection::JMedia2HTTPConnection(JNIEnv *env, jobject thiz) {
    mMedia2HTTPConnectionObj = env->NewGlobalRef(thiz);
    CHECK(mMedia2HTTPConnectionObj != NULL);

    ScopedLocalRef<jclass> media2HTTPConnectionClass(
            env, env->GetObjectClass(mMedia2HTTPConnectionObj));
    CHECK(media2HTTPConnectionClass.get() != NULL);

    mConnectMethod = env->GetMethodID(
            media2HTTPConnectionClass.get(),
            "connect",
            "(Ljava/lang/String;Ljava/lang/String;)Z");
    CHECK(mConnectMethod != NULL);

    mDisconnectMethod = env->GetMethodID(
            media2HTTPConnectionClass.get(),
            "disconnect",
            "()V");
    CHECK(mDisconnectMethod != NULL);

    mReadAtMethod = env->GetMethodID(
            media2HTTPConnectionClass.get(),
            "readAt",
            "(J[BI)I");
    CHECK(mReadAtMethod != NULL);

    mGetSizeMethod = env->GetMethodID(
            media2HTTPConnectionClass.get(),
            "getSize",
            "()J");
    CHECK(mGetSizeMethod != NULL);

    mGetMIMETypeMethod = env->GetMethodID(
            media2HTTPConnectionClass.get(),
            "getMIMEType",
            "()Ljava/lang/String;");
    CHECK(mGetMIMETypeMethod != NULL);

    mGetUriMethod = env->GetMethodID(
            media2HTTPConnectionClass.get(),
            "getUri",
            "()Ljava/lang/String;");
    CHECK(mGetUriMethod != NULL);

    ScopedLocalRef<jbyteArray> tmp(
        env, env->NewByteArray(kBufferSize));
    mByteArrayObj = (jbyteArray)env->NewGlobalRef(tmp.get());
    CHECK(mByteArrayObj != NULL);
}

JMedia2HTTPConnection::~JMedia2HTTPConnection() {
    JNIEnv *env = JavaVMHelper::getJNIEnv();
    env->DeleteGlobalRef(mMedia2HTTPConnectionObj);
    env->DeleteGlobalRef(mByteArrayObj);
}

bool JMedia2HTTPConnection::connect(
        const char *uri, const KeyedVector<String8, String8> *headers) {
    String8 tmp("");
    if (headers != NULL) {
        for (size_t i = 0; i < headers->size(); ++i) {
            tmp.append(headers->keyAt(i));
            tmp.append(String8(": "));
            tmp.append(headers->valueAt(i));
            tmp.append(String8("\r\n"));
        }
    }

    JNIEnv* env = JavaVMHelper::getJNIEnv();
    jstring juri = env->NewStringUTF(uri);
    jstring jheaders = env->NewStringUTF(tmp.string());

    jboolean ret =
        env->CallBooleanMethod(mMedia2HTTPConnectionObj, mConnectMethod, juri, jheaders);

    env->DeleteLocalRef(juri);
    env->DeleteLocalRef(jheaders);

    return (bool)ret;
}

void JMedia2HTTPConnection::disconnect() {
    JNIEnv* env = JavaVMHelper::getJNIEnv();
    env->CallVoidMethod(mMedia2HTTPConnectionObj, mDisconnectMethod);
}

ssize_t JMedia2HTTPConnection::readAt(off64_t offset, void *data, size_t size) {
    JNIEnv* env = JavaVMHelper::getJNIEnv();

    if (size > kBufferSize) {
        size = kBufferSize;
    }

    jint n = env->CallIntMethod(
            mMedia2HTTPConnectionObj, mReadAtMethod, (jlong)offset, mByteArrayObj, (jint)size);

    if (n > 0) {
        env->GetByteArrayRegion(
                mByteArrayObj,
                0,
                n,
                (jbyte *)data);
    }

    return n;
}

off64_t JMedia2HTTPConnection::getSize() {
    JNIEnv* env = JavaVMHelper::getJNIEnv();
    return (off64_t)(env->CallLongMethod(mMedia2HTTPConnectionObj, mGetSizeMethod));
}

status_t JMedia2HTTPConnection::getMIMEType(String8 *mimeType) {
    JNIEnv* env = JavaVMHelper::getJNIEnv();
    jstring jmime = (jstring)env->CallObjectMethod(mMedia2HTTPConnectionObj, mGetMIMETypeMethod);
    jboolean flag = env->ExceptionCheck();
    if (flag) {
        env->ExceptionClear();
        return UNKNOWN_ERROR;
    }

    const char *str = env->GetStringUTFChars(jmime, 0);
    if (str != NULL) {
        *mimeType = String8(str);
    } else {
        *mimeType = "application/octet-stream";
    }
    env->ReleaseStringUTFChars(jmime, str);
    return OK;
}

status_t JMedia2HTTPConnection::getUri(String8 *uri) {
    JNIEnv* env = JavaVMHelper::getJNIEnv();
    jstring juri = (jstring)env->CallObjectMethod(mMedia2HTTPConnectionObj, mGetUriMethod);
    jboolean flag = env->ExceptionCheck();
    if (flag) {
        env->ExceptionClear();
        return UNKNOWN_ERROR;
    }

    const char *str = env->GetStringUTFChars(juri, 0);
    *uri = String8(str);
    env->ReleaseStringUTFChars(juri, str);
    return OK;
}

}  // namespace android
+0 −59
Original line number Diff line number Diff line
/*
 * Copyright 2017, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "JMedia2HTTPService"
#include <utils/Log.h>

#include <jni.h>

#include <mediaplayer2/JavaVMHelper.h>
#include <mediaplayer2/JMedia2HTTPService.h>
#include <mediaplayer2/JMedia2HTTPConnection.h>
#include <media/stagefright/foundation/ADebug.h>

#include <nativehelper/scoped_local_ref.h>

namespace android {

JMedia2HTTPService::JMedia2HTTPService(JNIEnv *env, jobject thiz) {
    mMedia2HTTPServiceObj = env->NewGlobalRef(thiz);
    CHECK(mMedia2HTTPServiceObj != NULL);

    ScopedLocalRef<jclass> media2HTTPServiceClass(env, env->GetObjectClass(mMedia2HTTPServiceObj));
    CHECK(media2HTTPServiceClass.get() != NULL);

    mMakeHTTPConnectionMethod = env->GetMethodID(
            media2HTTPServiceClass.get(),
            "makeHTTPConnection",
            "()Landroid/media/Media2HTTPConnection;");
    CHECK(mMakeHTTPConnectionMethod != NULL);
}

JMedia2HTTPService::~JMedia2HTTPService() {
    JNIEnv *env = JavaVMHelper::getJNIEnv();
    env->DeleteGlobalRef(mMedia2HTTPServiceObj);
}

sp<MediaHTTPConnection> JMedia2HTTPService::makeHTTPConnection() {
    JNIEnv* env = JavaVMHelper::getJNIEnv();
    jobject media2HTTPConnectionObj =
        env->CallObjectMethod(mMedia2HTTPServiceObj, mMakeHTTPConnectionMethod);

    return new JMedia2HTTPConnection(env, media2HTTPConnectionObj);
}

}  // namespace android
Loading