diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c index ebd4808..90a3e52 100644 --- a/app/src/main/cpp/baresip.c +++ b/app/src/main/cpp/baresip.c @@ -497,6 +497,21 @@ JNIEXPORT void JNICALL Java_com_tutpro_baresip_plus_BaresipService_baresipStart( 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; jclass clz = (*env)->GetObjectClass(env, instance); diff --git a/app/src/main/cpp/vidisp.c b/app/src/main/cpp/vidisp.c index 4807134..a4444e1 100644 --- a/app/src/main/cpp/vidisp.c +++ b/app/src/main/cpp/vidisp.c @@ -75,7 +75,7 @@ static void renderer_destroy(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) { 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); if (!err) { LOGW("[SELF] eglSwapBuffers() returned error %s\n", egl_error(eglGetError())); - 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; + int8_t isDisplayActive = 1; + if(ANativeWindow_getWidth(st->window) < 0 || ANativeWindow_getHeight(st->window) < 0) { + isDisplayActive = 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; @@ -939,14 +957,15 @@ JNIEXPORT void JNICALL Java_com_tutpro_baresip_plus_VideoView_set_1surfaceSelf( w = ANativeWindow_getWidth(window_self); h = ANativeWindow_getHeight(window_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_height_self = h; resize_self = true; } } else { - LOGI("[SELF] Releasing windowSelf"); + LOGW("[SELF] Releasing windowSelf"); ANativeWindow_release(window_self); + window_self = NULL; } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/plus/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/plus/BaresipService.kt index 97158db..414b309 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/plus/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/plus/BaresipService.kt @@ -883,14 +883,22 @@ class BaresipService: Service() { if(call != null) { if(camera2 == "plugin") { + BaresipService.cameraFront = false; // Contents Input call.setVideoSource(false) } else { + BaresipService.cameraFront = true; // Camera Input call.setVideoSource(true) } } } } + if(BaresipService.cameraFront) { + Utils.propertySet("sys.ritosip.media.input", "camera") + } else { + Utils.propertySet("sys.ritosip.media.input", "content") + } + delay(100) // 1초마다 실행 val now = LocalDateTime.now() diff --git a/app/src/main/kotlin/com/tutpro/baresip/plus/Config.kt b/app/src/main/kotlin/com/tutpro/baresip/plus/Config.kt index 4cdb38a..0112093 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/plus/Config.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/plus/Config.kt @@ -227,6 +227,12 @@ object Config { config = "${config}video_size " + "${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()) { config = "${config}module avformat.so\n" config = "${config}module selfview.so\n" diff --git a/app/src/main/kotlin/com/tutpro/baresip/plus/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/plus/MainActivity.kt index 9e534ee..8f4000a 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/plus/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/plus/MainActivity.kt @@ -1334,7 +1334,11 @@ class MainActivity : AppCompatActivity() { presentationView?.addView(videoView.standbyView) } catch(e : java.lang.Exception) { } - videoView.standbyView.bringToFront() + if(isCallExist()) { + videoView.surfaceSelfView.bringToFront() + } else { + videoView.standbyView.bringToFront() + } presentation?.show() } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/plus/VideoView.kt b/app/src/main/kotlin/com/tutpro/baresip/plus/VideoView.kt index 2f79413..ad14831 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/plus/VideoView.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/plus/VideoView.kt @@ -95,16 +95,16 @@ class VideoView(val context: Context) { inner class SurfaceHolderCallbackSelf: SurfaceHolder.Callback { 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) { - Log.d(TAG, "SurfaceSelf changed") + Log.w(TAG, "SurfaceSelf changed") set_surfaceSelf(holder.surface) } override fun surfaceDestroyed(holder: SurfaceHolder) { - Log.d(TAG, "SurfaceSelf destroyed") + Log.w(TAG, "SurfaceSelf destroyed") set_surfaceSelf(null) } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e284aaf..3116d4e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -393,7 +393,7 @@ android:layout_marginTop="8dp" android:layout_marginRight="15dp" android:layout_weight="1" - android:text="TextView" + android:text="" android:textAlignment="viewEnd" android:textColor="#FFFFFF" android:textSize="24sp"