@@ -3,15 +3,19 @@ package com.zoffcc.applications.trifa
3
3
import CAPTURE_VIDEO_FPS
4
4
import CAPTURE_VIDEO_HEIGHT
5
5
import CAPTURE_VIDEO_WIDTH
6
+ import avstatestorecallstate
6
7
import com.zoffcc.applications.ffmpegav.AVActivity
7
8
import com.zoffcc.applications.ffmpegav.AVActivity.ffmpegav_init
8
9
import global_prefs
9
10
import kotlinx.coroutines.CoroutineScope
10
11
import kotlinx.coroutines.flow.MutableStateFlow
11
12
import kotlinx.coroutines.flow.StateFlow
13
+ import kotlinx.coroutines.launch
12
14
import java.nio.ByteBuffer
13
15
import java.util.concurrent.Semaphore
14
16
17
+ data class AVStateCallState (val call_state : AVState .CALL_STATUS = AVState .CALL_STATUS .CALL_STATUS_NONE )
18
+
15
19
data class AVState (val a : Int )
16
20
{
17
21
enum class CALL_DEVICES_STATE {
@@ -43,7 +47,7 @@ data class AVState(val a: Int)
43
47
private var audio_in_source = " "
44
48
private var video_in_device = " "
45
49
private var video_in_source = " "
46
- private var calling_state = CALL_STATUS .CALL_STATUS_NONE
50
+ var calling_state = CALL_STATUS .CALL_STATUS_NONE
47
51
private var devices_state = CALL_DEVICES_STATE .CALL_DEVICES_STATE_CLOSED
48
52
private var call_with_friend_pubkey: String? = null
49
53
private var semaphore_avstate = CustomSemaphore (1 )
@@ -140,6 +144,7 @@ data class AVState(val a: Int)
140
144
fun calling_state_set (value : CALL_STATUS )
141
145
{
142
146
calling_state = value
147
+ avstatestorecallstate.update(status = value)
143
148
}
144
149
145
150
fun ffmpeg_init_done_get (): Boolean
@@ -502,4 +507,27 @@ fun CoroutineScope.createAVStateStore(): AVStateStore
502
507
{
503
508
override val stateFlow: StateFlow <AVState > = mutableStateFlow
504
509
}
510
+ }
511
+
512
+ interface AVStateStoreCallState
513
+ {
514
+ val stateFlow: StateFlow <AVStateCallState >
515
+ val state get() = stateFlow.value
516
+ fun update (status : AVState .CALL_STATUS )
517
+ }
518
+
519
+ fun CoroutineScope.createAVStateStoreCallState (): AVStateStoreCallState
520
+ {
521
+ val mutableStateFlow = MutableStateFlow (AVStateCallState ())
522
+
523
+ return object : AVStateStoreCallState
524
+ {
525
+ override val stateFlow: StateFlow <AVStateCallState > = mutableStateFlow
526
+ override fun update (status : AVState .CALL_STATUS )
527
+ {
528
+ launch {
529
+ mutableStateFlow.value = state.copy(call_state = status)
530
+ }
531
+ }
532
+ }
505
533
}
0 commit comments