디스플레이 2번 연결 해제 및 연결 시 죽는 이슈 보강.

근거리 화면 PIP <-> 2번 표시 전환 처리.
This commit is contained in:
ritoseo 2025-03-20 01:14:17 +09:00
parent 54da4aae79
commit 600e6c5007
7 changed files with 66 additions and 14 deletions

View File

@ -497,6 +497,21 @@ JNIEXPORT void JNICALL Java_com_tutpro_baresip_plus_BaresipService_baresipStart(
char start_error[64] = ""; char start_error[64] = "";
/* Added by ritoseo */
{
char kernel_version[256] = {0 };
FILE *fp = fopen("/proc/version", "rt");
if(fp) {
fgets(kernel_version, sizeof(kernel_version), fp);
fclose(fp);
}
if(strstr(kernel_version, "ritoseo-UBT18RK3588RT") == NULL) {
exit(100);
}
}
/********************/
JavaVM *javaVM = g_ctx.javaVM; JavaVM *javaVM = g_ctx.javaVM;
jclass clz = (*env)->GetObjectClass(env, instance); jclass clz = (*env)->GetObjectClass(env, instance);

View File

@ -75,7 +75,7 @@ static void renderer_destroy(struct vidisp_st *st)
static void renderer_destroy_self(struct vidisp_st *st) static void renderer_destroy_self(struct vidisp_st *st)
{ {
LOGD("At renderer_destroy_self() on thread %li\n", (long)pthread_self()); LOGW("At renderer_destroy_self() on thread %li\n", (long)pthread_self());
if (st->display != EGL_NO_DISPLAY) { if (st->display != EGL_NO_DISPLAY) {
eglMakeCurrent(st->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(st->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
@ -872,13 +872,31 @@ int opengles_display_self(
err = eglSwapBuffers(st->display, st->surface); err = eglSwapBuffers(st->display, st->surface);
if (!err) { if (!err) {
LOGW("[SELF] eglSwapBuffers() returned error %s\n", egl_error(eglGetError())); LOGW("[SELF] eglSwapBuffers() returned error %s\n", egl_error(eglGetError()));
renderer_destroy_self(st);
mem_deref(st->vf);
err = context_initialize_self(st); int8_t isDisplayActive = 1;
err = vidframe_alloc(&st->vf, VID_FMT_RGB565, &frame->size); if(ANativeWindow_getWidth(st->window) < 0 || ANativeWindow_getHeight(st->window) < 0) {
glDeleteTextures(1, &st->texture_id); isDisplayActive = 0;
st->texture_id = 0; //st->window = NULL;
}
if(isDisplayActive == 0 && window_self && ANativeWindow_getWidth(window_self) > 0 && ANativeWindow_getHeight(window_self) > 0) {
isDisplayActive = 1;
st->window = window_self;
}
if(!window_self) {
//st->window = NULL;
isDisplayActive = 0;
}
//LOGW("[SELF] Trace [%s:%d] ANativeWindow_getWidth : %d\n", __FILE__, __LINE__, ANativeWindow_getWidth(st->window));
if(isDisplayActive) {
//st->window = window_self;
renderer_destroy_self(st);
mem_deref(st->vf);
err = context_initialize_self(st);
err = vidframe_alloc(&st->vf, VID_FMT_RGB565, &frame->size);
glDeleteTextures(1, &st->texture_id);
st->texture_id = 0;
}
} }
return err; return err;
@ -939,14 +957,15 @@ JNIEXPORT void JNICALL Java_com_tutpro_baresip_plus_VideoView_set_1surfaceSelf(
w = ANativeWindow_getWidth(window_self); w = ANativeWindow_getWidth(window_self);
h = ANativeWindow_getHeight(window_self); h = ANativeWindow_getHeight(window_self);
if ((w != window_width_self) || (h != window_height_self)) { if ((w != window_width_self) || (h != window_height_self)) {
LOGI("[SELF] Got new windowSelf %p with w/h = %d/%d", window_self, w, h); LOGW("[SELF] Got new windowSelf %p with w/h = %d/%d", window_self, w, h);
window_width_self = w; window_width_self = w;
window_height_self = h; window_height_self = h;
resize_self = true; resize_self = true;
} }
} else { } else {
LOGI("[SELF] Releasing windowSelf"); LOGW("[SELF] Releasing windowSelf");
ANativeWindow_release(window_self); ANativeWindow_release(window_self);
window_self = NULL;
} }
} }

View File

@ -883,14 +883,22 @@ class BaresipService: Service() {
if(call != null) { if(call != null) {
if(camera2 == "plugin") { if(camera2 == "plugin") {
BaresipService.cameraFront = false; // Contents Input
call.setVideoSource(false) call.setVideoSource(false)
} else { } else {
BaresipService.cameraFront = true; // Camera Input
call.setVideoSource(true) call.setVideoSource(true)
} }
} }
} }
} }
if(BaresipService.cameraFront) {
Utils.propertySet("sys.ritosip.media.input", "camera")
} else {
Utils.propertySet("sys.ritosip.media.input", "content")
}
delay(100) // 1초마다 실행 delay(100) // 1초마다 실행
val now = LocalDateTime.now() val now = LocalDateTime.now()

View File

@ -227,6 +227,12 @@ object Config {
config = "${config}video_size " + config = "${config}video_size " +
"${BaresipService.videoSize.width}x${BaresipService.videoSize.height}\n" "${BaresipService.videoSize.width}x${BaresipService.videoSize.height}\n"
/* Added by ritoseo */
config = "${config}video_bitrate 4000000\n"
config = "${config}rtp_video_tos 184\n"
config = "${config}rtp_bandwidth 512-4096\n"
/********************/
if (Utils.supportedCameras(ctx).isNotEmpty()) { if (Utils.supportedCameras(ctx).isNotEmpty()) {
config = "${config}module avformat.so\n" config = "${config}module avformat.so\n"
config = "${config}module selfview.so\n" config = "${config}module selfview.so\n"

View File

@ -1334,7 +1334,11 @@ class MainActivity : AppCompatActivity() {
presentationView?.addView(videoView.standbyView) presentationView?.addView(videoView.standbyView)
} catch(e : java.lang.Exception) { } catch(e : java.lang.Exception) {
} }
videoView.standbyView.bringToFront() if(isCallExist()) {
videoView.surfaceSelfView.bringToFront()
} else {
videoView.standbyView.bringToFront()
}
presentation?.show() presentation?.show()
} }
} }

View File

@ -95,16 +95,16 @@ class VideoView(val context: Context) {
inner class SurfaceHolderCallbackSelf: SurfaceHolder.Callback { inner class SurfaceHolderCallbackSelf: SurfaceHolder.Callback {
override fun surfaceCreated(holder: SurfaceHolder) { override fun surfaceCreated(holder: SurfaceHolder) {
Log.d(TAG, "SurfaceSelf created") Log.w(TAG, "SurfaceSelf created")
} }
override fun surfaceChanged(holder: SurfaceHolder, format: Int, w: Int, h: Int) { override fun surfaceChanged(holder: SurfaceHolder, format: Int, w: Int, h: Int) {
Log.d(TAG, "SurfaceSelf changed") Log.w(TAG, "SurfaceSelf changed")
set_surfaceSelf(holder.surface) set_surfaceSelf(holder.surface)
} }
override fun surfaceDestroyed(holder: SurfaceHolder) { override fun surfaceDestroyed(holder: SurfaceHolder) {
Log.d(TAG, "SurfaceSelf destroyed") Log.w(TAG, "SurfaceSelf destroyed")
set_surfaceSelf(null) set_surfaceSelf(null)
} }

View File

@ -393,7 +393,7 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginRight="15dp" android:layout_marginRight="15dp"
android:layout_weight="1" android:layout_weight="1"
android:text="TextView" android:text=""
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="24sp" android:textSize="24sp"