summaryrefslogtreecommitdiff
path: root/src/fruits
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-08-26 17:56:52 -0400
committerAndrew Opalach <andrew@akon.city> 2026-08-26 17:56:52 -0400
commit197d41a3e23cab35848f623c6133baccc62aacbe (patch)
tree04943c1de9653de53615e10ced1eab07c2562325 /src/fruits
parent6094c907b26e21f13373bae6bf3306dbae40af3c (diff)
downloadcamu-197d41a3e23cab35848f623c6133baccc62aacbe.tar.gz
camu-197d41a3e23cab35848f623c6133baccc62aacbe.tar.bz2
camu-197d41a3e23cab35848f623c6133baccc62aacbe.zip
OSD stuff and Android fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/fruits')
-rw-r--r--src/fruits/cmv/cmv.c38
-rw-r--r--src/fruits/cmv/meson.build13
-rw-r--r--src/fruits/ctv/ctv.c74
-rw-r--r--src/fruits/ctv/meson.build4
-rw-r--r--src/fruits/droid/ctv/app/src/main/AndroidManifest.xml28
5 files changed, 65 insertions, 92 deletions
diff --git a/src/fruits/cmv/cmv.c b/src/fruits/cmv/cmv.c
index 58c8e32..74e3555 100644
--- a/src/fruits/cmv/cmv.c
+++ b/src/fruits/cmv/cmv.c
@@ -53,6 +53,10 @@ static nn_thread_result NNWT_THREADCALL event_loop_thread(void *userdata)
static bool decode_addr(str *addr, str *enc)
{
+ if (al_str_find(enc, '.') != AL_STR_NO_POS) {
+ al_str_clone(addr, enc);
+ return true;
+ }
char value[4]; // max = 255.
for (u32 i = 0; i < 8; i += 2) {
str sub = al_str_substr(enc, i, i + 2);
@@ -75,40 +79,39 @@ static bool parse_exe_name(str *exe_name, str *addr)
u32 index = al_str_rfind(exe_name, '/');
if (index == AL_STR_NO_POS) {
if ((index = al_str_rfind(exe_name, '\\')) == AL_STR_NO_POS) {
- goto def;
+ return false;
}
}
str sub = al_str_substr(exe_name, index + 1, exe_name->length);
if (al_str_cmp(&sub, &al_str_c("sink-"), 0, 5) != 0) {
- goto def;
+ return false;
}
sub = al_str_substr(&sub, 5, sub.length);
// Skip version.
if ((index = al_str_find(&sub, '-')) == AL_STR_NO_POS) {
- goto def;
+ return false;
}
sub = al_str_substr(&sub, index + 1, sub.length);
if ((index = al_str_find(&sub, '.')) != AL_STR_NO_POS) {
sub = al_str_substr(&sub, 0, index);
}
- al_str_from(addr, "");
decode_addr(addr, &sub);
log_debug("Parsed address %.*s from exe filename.", al_str_x(addr));
return true;
-def:
- return false;
}
static struct cmv c = { 0 };
+#ifdef STELA_USE_PLATFORM_MAIN
+s32 stl_platform_main(u32 argc, str *argv, void *extra)
+#else
s32 window_system_main(u32 argc, str *argv, void *extra)
+#endif
{
- (void)extra;
-
bool local;
#ifdef CAMU_SINK_ONLY
local = argc > 1;
@@ -134,9 +137,9 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
nn_event_loop_init(&c.loop);
u8 type;
- str addr = al_str_null();
+ str addr = AL_STR_EMPTY;
if (local) {
-#ifdef NAUNET_ON_WINDOWS
+#if defined NAUNET_ON_WINDOWS || defined NAUNET_ON_ANDROID
type = NNWT_SOCKET_TCP;
al_str_clone(&addr, &al_str_c("127.0.0.1"));
#else
@@ -151,8 +154,8 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
} else {
type = NNWT_SOCKET_TCP;
char *SINK_IP = getenv("SINK_IP");
- al_str_from(&addr, "");
if (!SINK_IP || !decode_addr(&addr, &al_str_cr(SINK_IP))) {
+ local = true; // If no IP, default back to local.
al_str_cat(&addr, &al_str_c("127.0.0.1"));
}
}
@@ -228,11 +231,22 @@ s32 window_system_main(u32 argc, str *argv, void *extra)
#endif
nn_packet_free(packet);
}
+ if (extra) {
+ u32 start_index = *(u32 *)extra;
+ if (start_index != 0) {
+ camu_server_local_set_index(&c.server, start_index);
+ }
+ }
}
struct nn_thread thread;
nn_thread_create(&thread, event_loop_thread, &c);
+#ifdef STELA_USE_PLATFORM_MAIN
+ al_str_free(&addr);
+ return 0;
+#endif
+
while (camu_desktop_tick(&c.desktop)) {}
camu_desktop_stop(&c.desktop);
@@ -251,6 +265,7 @@ out:
return ret;
}
+#ifndef STELA_USE_PLATFORM_MAIN
static bool sigint_force = false;
static void sigint_handler(s32 signum)
{
@@ -314,3 +329,4 @@ s32 main(s32 argc, char *argv[])
return ret;
}
+#endif
diff --git a/src/fruits/cmv/meson.build b/src/fruits/cmv/meson.build
index ec27c81..301fa58 100644
--- a/src/fruits/cmv/meson.build
+++ b/src/fruits/cmv/meson.build
@@ -14,7 +14,10 @@ if use_tui
endif
cmv_link_args = []
-if is_windows
+if is_android
+ # https://github.com/google/ExoPlayer/issues/9933#issuecomment-1029775358
+ cmv_link_args += ['-Wl,-Bsymbolic', '-static-libstdc++']
+elif is_windows
windows = import('windows')
cmv_src += [windows.compile_resources('icon.rc')]
if not is_msvc
@@ -22,4 +25,10 @@ if is_windows
endif
endif
-executable('cmv', cmv_src, dependencies: cmv_deps, c_args: cmv_args, link_args: cmv_link_args, install: true)
+if is_android
+ cmv_args += ['-DAPPLICATION_NAME="CTV"']
+ shared_library('ctv', cmv_src, dependencies: cmv_deps, c_args: cmv_args, link_args: cmv_link_args)
+else
+ cmv_args += ['-DAPPLICATION_NAME="CMV"']
+ executable('cmv', cmv_src, dependencies: cmv_deps, c_args: cmv_args, link_args: cmv_link_args, install: true)
+endif
diff --git a/src/fruits/ctv/ctv.c b/src/fruits/ctv/ctv.c
deleted file mode 100644
index 2878600..0000000
--- a/src/fruits/ctv/ctv.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <al/log.h>
-#include <android/log.h>
-
-#include "../../libsink/sink.h"
-#include "../../libsink/desktop.h"
-#ifdef CAMU_HAVE_FFMPEG
-#include "../../codec/ffmpeg/common.h"
-#endif
-
-#include "../common.h"
-
-struct ctv {
- struct nn_event_loop loop;
- struct camu_desktop desktop;
- struct nn_thread thread;
-};
-
-static nn_thread_result NNWT_THREADCALL event_loop_thread(void *userdata)
-{
- struct ctv *c = (struct ctv *)userdata;
- nn_thread_set_name("event_loop");
-
- nn_event_loop_init(&c->loop);
-
- struct camu_sink *sink = &c->desktop.sink;
- sink->local = true;
-
- struct lia_prefs *prefs = &sink->prefs;
-#ifdef CAMU_HAVE_SUBTITLES
- prefs->enabled = (1 << CAMU_STREAM_AUDIO) | (1 << CAMU_STREAM_VIDEO) | (1 << CAMU_STREAM_SUBTITLE);
-#else
- prefs->enabled = (1 << CAMU_STREAM_AUDIO) | (1 << CAMU_STREAM_VIDEO);
-#endif
- prefs->language.audio = CAMU_LANG_JAPANESE;
- prefs->language.subtitles = CAMU_LANG_ENGLISH;
-
- if (!camu_desktop_connect(&c->desktop, &al_str_c("ctv"), &c->loop, NNWT_SOCKET_TCP, &al_str_c(""), CAMU_PORT)) {
- return 0;
- }
-
- nn_event_loop_run(&c->loop);
-
- return 0;
-}
-
-static s32 log_callback(void *userdata, u8 level, char *message)
-{
- (void)userdata;
- (void)level;
- __android_log_print(ANDROID_LOG_DEBUG, "CTV", "%*.*s", 0, AL_LOG_MESSAGE_SIZE, message);
- return al_strnlen(message, AL_LOG_MESSAGE_SIZE);
-}
-
-static struct ctv c = { 0 };
-
-s32 stl_platform_main(u32 argc, str *argv)
-{
- (void)argc;
- (void)argv;
-
- al_set_print(log_callback, NULL);
-
-#ifdef CAMU_HAVE_FFMPEG
- camu_ff_common_init();
-#endif
-
- if (!camu_desktop_open(&c.desktop, "ctv")) {
- return 0;
- }
-
- nn_thread_create(&c.thread, event_loop_thread, &c);
-
- return EXIT_SUCCESS;
-}
diff --git a/src/fruits/ctv/meson.build b/src/fruits/ctv/meson.build
deleted file mode 100644
index bf6f9e5..0000000
--- a/src/fruits/ctv/meson.build
+++ /dev/null
@@ -1,4 +0,0 @@
-ctv_src = ['ctv.c']
-ctv_deps = [common_deps, desktop]
-# https://github.com/google/ExoPlayer/issues/9933#issuecomment-1029775358
-shared_library('ctv', ctv_src, dependencies: ctv_deps, link_args: ['-Wl,-Bsymbolic', '-static-libstdc++'])
diff --git a/src/fruits/droid/ctv/app/src/main/AndroidManifest.xml b/src/fruits/droid/ctv/app/src/main/AndroidManifest.xml
index e957943..30a4d35 100644
--- a/src/fruits/droid/ctv/app/src/main/AndroidManifest.xml
+++ b/src/fruits/droid/ctv/app/src/main/AndroidManifest.xml
@@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
+ <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
+ <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-feature android:name="android.software.leanback"
android:required="false" />
<uses-feature android:name="android.hardware.touchscreen"
@@ -27,6 +31,28 @@
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
- </application>
+ <activity-alias
+ android:name=".api.file.OpenWithActivity"
+ android:exported="true"
+ android:targetActivity="android.app.NativeActivity">
+ <meta-data
+ android:name="android.app.lib_name"
+ android:value="ctv" />
+
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:scheme="content" />
+ <data android:scheme="file" />
+ <data android:scheme="http" />
+ <data android:mimeType="application/*" />
+ <data android:mimeType="audio/*" />
+ <data android:mimeType="image/*" />
+ <data android:mimeType="text/*" />
+ <data android:mimeType="video/*" />
+ </intent-filter>
+ </activity-alias>
+ </application>
</manifest>