Browse Source

Use only shared source events in Android streaming UI and tests

master
evgeny 7 days ago
parent
commit
cacd377d55
  1. 4
      tests/test_android_stream.c
  2. 2
      tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt
  3. 5
      tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/StreamScreen.kt

4
tests/test_android_stream.c

@ -69,8 +69,8 @@ int main(void) {
CHECK(!stream_service_needs_activity(inst)); CHECK(!stream_service_needs_activity(inst));
CHECK(android_stream_open(1, group, 0, 1280, 720, 90, 1, 0) == 0); CHECK(android_stream_open(1, group, 0, 1280, 720, 90, 1, 0) == 0);
size_t size = 0; u_free(wait_event(1, 4, &size)); size_t size = 0; u_free(wait_event(1, 4, &size));
char *sources = android_stream_sources(group); u_free(sources); test_clock_poll(ua, 100); char *sources = NULL; CHECK(stream_sources_json(inst, group, &sources) == STREAM_OK);
sources = android_stream_sources(group); CHECK(strstr(sources, "epoch") && strstr(sources, "name")); u_free(sources); CHECK(strstr(sources, "epoch") && strstr(sources, "name")); u_free(sources); test_clock_poll(ua, 100);
CHECK(source_events == 2 && strstr(source_snapshot, "epoch")); CHECK(source_events == 2 && strstr(source_snapshot, "epoch"));
struct stream_member_state member; struct stream_member_state member;
CHECK(stream_member_load(inst, group, inst->node_id, &member, NULL) == STREAM_OK && member.published); CHECK(stream_member_load(inst, group, inst->node_id, &member, NULL) == STREAM_OK && member.published);

2
tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt

@ -205,7 +205,6 @@ object NativeLib {
fun streamFeed(id: Long, video: Boolean, pts: Long, key: Boolean, data: ByteArray): Int = nativeStreamFeed(id, video, pts, key, data) fun streamFeed(id: Long, video: Boolean, pts: Long, key: Boolean, data: ByteArray): Int = nativeStreamFeed(id, video, pts, key, data)
fun streamStop(id: Long) { nativeStreamStop(id) } fun streamStop(id: Long) { nativeStreamStop(id) }
fun streamPull(id: Long): ByteArray? = nativeStreamPull(id) fun streamPull(id: Long): ByteArray? = nativeStreamPull(id)
fun streamSources(group: Long): String = nativeStreamSources(group) ?: "[]"
fun streamOpusCreate(encode: Boolean): Long = nativeStreamOpusCreate(encode) fun streamOpusCreate(encode: Boolean): Long = nativeStreamOpusCreate(encode)
fun streamOpusEncode(handle: Long, pcm: ShortArray): ByteArray? = nativeStreamOpusEncode(handle, pcm) fun streamOpusEncode(handle: Long, pcm: ShortArray): ByteArray? = nativeStreamOpusEncode(handle, pcm)
fun streamOpusDecode(handle: Long, packet: ByteArray): ShortArray? = nativeStreamOpusDecode(handle, packet) fun streamOpusDecode(handle: Long, packet: ByteArray): ShortArray? = nativeStreamOpusDecode(handle, packet)
@ -216,7 +215,6 @@ object NativeLib {
private external fun nativeStreamFeed(id: Long, video: Boolean, pts: Long, key: Boolean, data: ByteArray): Int private external fun nativeStreamFeed(id: Long, video: Boolean, pts: Long, key: Boolean, data: ByteArray): Int
private external fun nativeStreamStop(id: Long) private external fun nativeStreamStop(id: Long)
private external fun nativeStreamPull(id: Long): ByteArray? private external fun nativeStreamPull(id: Long): ByteArray?
private external fun nativeStreamSources(group: Long): String?
private external fun nativeStreamOpusCreate(encode: Boolean): Long private external fun nativeStreamOpusCreate(encode: Boolean): Long
private external fun nativeStreamOpusEncode(handle: Long, pcm: ShortArray): ByteArray? private external fun nativeStreamOpusEncode(handle: Long, pcm: ShortArray): ByteArray?
private external fun nativeStreamOpusDecode(handle: Long, packet: ByteArray): ShortArray? private external fun nativeStreamOpusDecode(handle: Long, packet: ByteArray): ShortArray?

5
tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/StreamScreen.kt

@ -28,15 +28,10 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleEventObserver
import com.utun.chat.R import com.utun.chat.R
import com.utun.chat.data.LogManager import com.utun.chat.data.LogManager
import com.utun.chat.data.NativeLib
import com.utun.chat.data.StreamController import com.utun.chat.data.StreamController
import com.utun.chat.data.StreamPhase import com.utun.chat.data.StreamPhase
import com.utun.chat.data.StreamPlayerEngine import com.utun.chat.data.StreamPlayerEngine
import com.utun.chat.data.StreamSource import com.utun.chat.data.StreamSource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import org.json.JSONArray
/** Выход с экрана закрывает только reader; foreground publisher останавливает явная кнопка/notification. */ /** Выход с экрана закрывает только reader; foreground publisher останавливает явная кнопка/notification. */
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)

Loading…
Cancel
Save