mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Add Stub Android Video Decoder
This commit is contained in:
parent
ad7f46d783
commit
7dc132eecb
4 changed files with 111 additions and 6 deletions
|
@ -1,7 +1,10 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
add_library(chiaki-jni SHARED src/main/cpp/chiaki-jni.c)
|
||||
add_library(chiaki-jni SHARED
|
||||
src/main/cpp/chiaki-jni.c
|
||||
src/main/cpp/video-decoder.h
|
||||
src/main/cpp/video-decoder.c)
|
||||
target_link_libraries(chiaki-jni chiaki-lib)
|
||||
|
||||
find_library(ANDROID_LIB_LOG log)
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include <chiaki/common.h>
|
||||
|
@ -8,6 +25,8 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "video-decoder.h"
|
||||
|
||||
#define LOG_TAG "Chiaki"
|
||||
#define JNI_VERSION JNI_VERSION_1_6
|
||||
|
||||
|
@ -85,6 +104,8 @@ typedef struct android_chiaki_session_t
|
|||
jclass java_session_class;
|
||||
jmethodID java_session_event_login_pin_request_meth;
|
||||
jmethodID java_session_event_quit_meth;
|
||||
|
||||
AndroidChiakiVideoDecoder video_decoder;
|
||||
} AndroidChiakiSession;
|
||||
|
||||
static JNIEnv *attach_thread_jni()
|
||||
|
@ -190,23 +211,28 @@ JNIEXPORT void JNICALL Java_com_metallic_chiaki_lib_ChiakiNative_sessionCreate(J
|
|||
err = CHIAKI_ERR_MEMORY;
|
||||
goto beach;
|
||||
}
|
||||
|
||||
err = chiaki_session_init(&session->session, &connect_info, &global_log);
|
||||
|
||||
memset(session, 0, sizeof(AndroidChiakiSession));
|
||||
err = android_chiaki_video_decoder_init(&session->video_decoder, &global_log);
|
||||
if(err != CHIAKI_ERR_SUCCESS)
|
||||
{
|
||||
session->java_session = NULL;
|
||||
free(session);
|
||||
session = NULL;
|
||||
goto beach;
|
||||
}
|
||||
|
||||
err = chiaki_session_init(&session->session, &connect_info, &global_log);
|
||||
if(err != CHIAKI_ERR_SUCCESS)
|
||||
goto beach;
|
||||
|
||||
session->java_session = E->NewGlobalRef(env, java_session);
|
||||
session->java_session_class = E->GetObjectClass(env, session->java_session);
|
||||
session->java_session_event_login_pin_request_meth = E->GetMethodID(env, session->java_session_class, "eventLoginPinRequest", "(Z)V");
|
||||
session->java_session_event_quit_meth = E->GetMethodID(env, session->java_session_class, "eventQuit", "(ILjava/lang/String;)V");
|
||||
|
||||
chiaki_session_set_event_cb(&session->session, android_chiaki_event_cb, session);
|
||||
chiaki_session_set_video_sample_cb(&session->session, android_chiaki_video_decoder_video_sample, &session->video_decoder);
|
||||
|
||||
beach:
|
||||
beach:
|
||||
free(host_str);
|
||||
E->SetIntField(env, result, E->GetFieldID(env, result_class, "errorCode", "I"), (jint)err);
|
||||
E->SetLongField(env, result, E->GetFieldID(env, result_class, "sessionPtr", "J"), (jlong)session);
|
||||
|
@ -220,6 +246,7 @@ JNIEXPORT void JNICALL Java_com_metallic_chiaki_lib_ChiakiNative_sessionFree(JNI
|
|||
return;
|
||||
chiaki_session_fini(&session->session);
|
||||
free(session);
|
||||
android_chiaki_video_decoder_fini(&session->video_decoder);
|
||||
E->DeleteGlobalRef(env, session->java_session);
|
||||
}
|
||||
|
||||
|
|
38
android/app/src/main/cpp/video-decoder.c
Normal file
38
android/app/src/main/cpp/video-decoder.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "video-decoder.h"
|
||||
|
||||
#include <media/NdkMediaCodec.h>
|
||||
|
||||
ChiakiErrorCode android_chiaki_video_decoder_init(AndroidChiakiVideoDecoder *decoder, ChiakiLog *log)
|
||||
{
|
||||
decoder->log = log;
|
||||
decoder->video_codec = NULL;
|
||||
return chiaki_mutex_init(&decoder->mutex, false);
|
||||
}
|
||||
|
||||
void android_chiaki_video_decoder_fini(AndroidChiakiVideoDecoder *decoder)
|
||||
{
|
||||
chiaki_mutex_fini(&decoder->mutex);
|
||||
}
|
||||
|
||||
void android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, void *user)
|
||||
{
|
||||
AndroidChiakiVideoDecoder *decoder = user;
|
||||
CHIAKI_LOGD(decoder->log, "Got video sample of size %zu", buf_size);
|
||||
}
|
37
android/app/src/main/cpp/video-decoder.h
Normal file
37
android/app/src/main/cpp/video-decoder.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CHIAKI_JNI_VIDEO_DECODER_H
|
||||
#define CHIAKI_JNI_VIDEO_DECODER_H
|
||||
|
||||
#include <chiaki/thread.h>
|
||||
#include <chiaki/log.h>
|
||||
|
||||
typedef struct AMediaCodec AMediaCodec;
|
||||
|
||||
typedef struct android_chiaki_video_decoder_t
|
||||
{
|
||||
ChiakiLog *log;
|
||||
ChiakiMutex mutex;
|
||||
AMediaCodec *video_codec;
|
||||
} AndroidChiakiVideoDecoder;
|
||||
|
||||
ChiakiErrorCode android_chiaki_video_decoder_init(AndroidChiakiVideoDecoder *decoder, ChiakiLog *log);
|
||||
void android_chiaki_video_decoder_fini(AndroidChiakiVideoDecoder *decoder);
|
||||
void android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, void *user);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue