示例#1
0
JNIEXPORT void android_media_omxmediaplayer_pause(JNIEnv *env, jobject thiz)
{
	PPLOGI("android_media_omxmediaplayer_pause");
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	mp->pause();
	PPLOGI("paused");
}
示例#2
0
void OMXMediaPlayerListener::notify(int msg, int ext1, int ext2)
{
	PPLOGI("notify() %d %d %d", msg, ext1, ext2);
	JNIEnv *env = getAttachedJNIEnv();
	if (env) {
		env->CallStaticVoidMethod(mClass, fields.post_event, mObject, msg, ext1, ext2, 0);
	}
	else {
		PPLOGE("notify() env is null");
	}
}
示例#3
0
JNIEXPORT void JNICALL android_media_omxmediaplayer_prepareAsync
  (JNIEnv *env, jobject thiz)
{
	PPLOGI("OMXPlayer_prepareAsync");
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	mp->prepareAsync();
}
示例#4
0
JNIEXPORT void JNICALL android_media_omxmediaplayer_setVideoSurface
  (JNIEnv *env, jobject thiz, jobject surface)
{
	PPLOGI("OMXPlayer_setVideoSurface() %p", surface);
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	mp->setVideoSurface((void*)surface);
}
示例#5
0
/*
 * Class:     android_pplive_media_MeetSDK
 * Method:    Convert
 * Signature: ([B[B)I
 */
JNIEXPORT jint JNICALL Java_android_pplive_media_MeetSDK_Convert
(JNIEnv *env, jclass clazz, jbyteArray in_flv, jint in_size, jbyteArray out_ts, jint process_timestamp, jint first_seg)
{
    PPLOGI("Convert()");

    int ret = -1;

    jbyte* flv_data = env->GetByteArrayElements(in_flv, NULL);
    jsize flv_data_size = in_size;//env->GetArrayLength(in_flv);

    jbyte* ts_data = env->GetByteArrayElements(out_ts, NULL);
    jsize ts_data_size = env->GetArrayLength(out_ts);

    PPLOGI("before call my_convert() flv %p %d, ts %p %d", flv_data, flv_data_size, ts_data, ts_data_size);
    bool bRet = convertFun((uint8_t *)flv_data, flv_data_size, (uint8_t *)ts_data, &ts_data_size, process_timestamp, first_seg);
    if (bRet)
        ret = ts_data_size;
    PPLOGI("after call my_convert() %d", ret);

    env->ReleaseByteArrayElements(in_flv, flv_data, 0);
    env->ReleaseByteArrayElements(out_ts, ts_data, 0);
    return ret;
}
示例#6
0
JNIEXPORT jint JNICALL android_media_omxmediaplayer_getDuration
	(JNIEnv *env, jobject thiz)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		PPLOGE("player is null, getDuration failed");
		return 0;
	}
	int msec;
	if (0 != mp->getDuration(&msec)) {
		PPLOGE("getDuration failed");
		msec = 0;
	}
	PPLOGI("getDuration: %d", msec);
	return msec;
}
示例#7
0
/*
 * Class:     com_gotye_meetsdk_player_OMXPlayer
 * Method:    getVideoHeight
 * Signature: ()I
 */
JNIEXPORT jint JNICALL android_media_omxmediaplayer_getVideoHeight
  (JNIEnv *env, jobject thiz)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		PPLOGE("player is null, getVideoHeight failed");
		return 0;
	}
	int h;
	if (0 != mp->getVideoHeight(&h)) {
		PPLOGE("getVideoHeight failed");
		h = 0;
	}
	PPLOGI("getVideoHeight: %d", h);
	return h;
}
示例#8
0
//JNIEXPORT jint JNICALL Java_com_gotye_meetsdk_player_OMXPlayer_getVideoWidth
JNIEXPORT jint JNICALL android_media_omxmediaplayer_getVideoWidth
  (JNIEnv *env, jobject thiz)
{
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		PPLOGE("player is null, getVideoWidth failed");
		return 0;
	}
	int w;
	if (0 != mp->getVideoWidth(&w)) {
		PPLOGE("getVideoWidth failed");
		w = 0;
	}
	PPLOGI("getVideoWidth: %d", w);
	return w;
}
示例#9
0
/*
 * Class:     com_gotye_meetsdk_player_OMXPlayer
 * Method:    _setDataSource
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL android_media_omxmediaplayer_setDataSource
  (JNIEnv *env, jobject thiz, jstring path)
{
	PPLOGI("OMXPlayer_setDataSource()");
	IPlayer* mp = getOMXMediaPlayer(env, thiz);
	if (mp == NULL ) {
		jniThrowException(env, "java/lang/IllegalStateException", NULL);
		return;
	}

	const char *pathStr = env->GetStringUTFChars(path, NULL);
	if (pathStr == NULL) {  // Out of memory
		jniThrowException(env, "java/lang/RuntimeException", "GetStringUTFChars: Out of memory");
		return;
	}
	mp->setDataSource(pathStr);

	// Make sure that local ref is released before a potential exception
	env->ReleaseStringUTFChars(path, pathStr);
}
示例#10
0
int register_android_media_omxplayer(JNIEnv *env)
{
	const char* className = "com/gotye/meetsdk/player/OMXMediaPlayer";
	jclass clazz;

	PPLOGI("Registering %s natives", className);
	clazz = env->FindClass(className);
	if (clazz == NULL) {
		PPLOGE("Native registration unable to find class '%s'", className);
		return -1;
	}

	int result = 0;
	if (env->RegisterNatives(clazz, gOMXplayerMethods, NELEM(gOMXplayerMethods)) < 0) {
		PPLOGE("RegisterNatives failed for '%s'", className);
		result = -1;
	}

	env->DeleteLocalRef(clazz);
	return result;
}
示例#11
0
// callled when new OMXMediaPlayer
JNIEXPORT void JNICALL android_media_omxmediaplayer_setup
  (JNIEnv *env, jobject thiz, jobject weak_this)
{
	PPLOGI("native_setup");

	IPlayer* mp = getOMXPlayerFun((void*)gPlatformInfo);
	if (mp == NULL) {
		jniThrowException(env, "java/lang/RuntimeException", "Create IPlayer failed.");
		return;
	}

	// create new listener and give it to MediaPlayer
	OMXMediaPlayerListener * player_listener = new OMXMediaPlayerListener(env, thiz, weak_this);
	//IPlayer takes responsibility to release listener.
	mp->setListener(player_listener);

	env->SetLongField(thiz, fields.listener, (int64_t)player_listener);

	// Stow our new C++ MediaPlayer in an opaque field in the Java object.
	setOMXMediaPlayer(env, thiz, mp);
	//check if it needs to release old mediaplayer.
}