@@ -55,6 +55,41 @@ data class AVState(val a: Int)
55
55
ffmpeg_init_done_set(false )
56
56
}
57
57
58
+ fun ffmpeg_devices_start ()
59
+ {
60
+ val devices_state_copy: CALL_DEVICES_STATE
61
+ semaphore_avstate.acquire((Throwable ().stackTrace[0 ].fileName + " :" + Throwable ().stackTrace[0 ].lineNumber))
62
+ devices_state_copy = devices_state
63
+ semaphore_avstate.release()
64
+ if (devices_state_copy == CALL_DEVICES_STATE .CALL_DEVICES_STATE_CLOSED )
65
+ {
66
+ if ((video_in_device != null ) && (video_in_device != " " ))
67
+ {
68
+ if ((video_in_source != null ) && (video_in_source != " " ))
69
+ {
70
+ println (" ffmpeg video in device: " + video_in_device + " " + video_in_source)
71
+ val res_vd = AVActivity .ffmpegav_open_video_in_device(video_in_device, video_in_source,
72
+ CAPTURE_VIDEO_WIDTH , CAPTURE_VIDEO_HEIGHT , CAPTURE_VIDEO_FPS )
73
+ println (" ffmpeg open video capture device: $res_vd " )
74
+ }
75
+ }
76
+ if ((audio_in_device != null ) && (audio_in_device != " " ))
77
+ {
78
+ if ((audio_in_source != null ) && (audio_in_source != " " ))
79
+ {
80
+ println (" ffmpeg audio in device: " + audio_in_device + " " + audio_in_source)
81
+ val res_ad = AVActivity .ffmpegav_open_audio_in_device(audio_in_device, audio_in_source)
82
+ println (" ffmpeg open audio capture device: $res_ad " )
83
+ }
84
+ }
85
+ AVActivity .ffmpegav_start_video_in_capture()
86
+ AVActivity .ffmpegav_start_audio_in_capture()
87
+ }
88
+ semaphore_avstate.acquire((Throwable ().stackTrace[0 ].fileName + " :" + Throwable ().stackTrace[0 ].lineNumber))
89
+ devices_state = CALL_DEVICES_STATE .CALL_DEVICES_STATE_ACTIVE
90
+ semaphore_avstate.release()
91
+ }
92
+
58
93
fun ffmpeg_devices_stop ()
59
94
{
60
95
val devices_state_copy: CALL_DEVICES_STATE
@@ -67,6 +102,10 @@ data class AVState(val a: Int)
67
102
AVActivity .ffmpegav_close_audio_in_device()
68
103
AVActivity .ffmpegav_stop_video_in_capture()
69
104
AVActivity .ffmpegav_close_video_in_device()
105
+ AudioBar .set_cur_value(0 , AudioBar .audio_in_bar)
106
+ AudioBar .set_cur_value(0 , AudioBar .audio_out_bar)
107
+ VideoOutFrame .clear_video_out_frame()
108
+ VideoInFrame .clear_video_in_frame()
70
109
}
71
110
semaphore_avstate.acquire((Throwable ().stackTrace[0 ].fileName + " :" + Throwable ().stackTrace[0 ].lineNumber))
72
111
devices_state = CALL_DEVICES_STATE .CALL_DEVICES_STATE_CLOSED
@@ -133,6 +172,19 @@ data class AVState(val a: Int)
133
172
return if (video_in_source == null ) " " else video_in_source
134
173
}
135
174
175
+ fun restart_devices ()
176
+ {
177
+ val devices_state_copy: CALL_DEVICES_STATE
178
+ semaphore_avstate.acquire((Throwable ().stackTrace[0 ].fileName + " :" + Throwable ().stackTrace[0 ].lineNumber))
179
+ devices_state_copy = devices_state
180
+ semaphore_avstate.release()
181
+ if (devices_state_copy == CALL_DEVICES_STATE .CALL_DEVICES_STATE_ACTIVE )
182
+ {
183
+ ffmpeg_devices_stop()
184
+ ffmpeg_devices_start()
185
+ }
186
+ }
187
+
136
188
fun audio_in_device_set (value : String? )
137
189
{
138
190
if (value == null )
@@ -144,6 +196,7 @@ data class AVState(val a: Int)
144
196
audio_in_device = value
145
197
}
146
198
save_device_information()
199
+ restart_devices()
147
200
}
148
201
149
202
fun audio_in_source_set (value : String? )
@@ -157,6 +210,7 @@ data class AVState(val a: Int)
157
210
audio_in_source = value
158
211
}
159
212
save_device_information()
213
+ restart_devices()
160
214
}
161
215
162
216
fun video_in_device_set (value : String? )
@@ -170,6 +224,7 @@ data class AVState(val a: Int)
170
224
video_in_device = value
171
225
}
172
226
save_device_information()
227
+ restart_devices()
173
228
}
174
229
175
230
fun video_in_source_set (value : String? )
@@ -183,6 +238,7 @@ data class AVState(val a: Int)
183
238
video_in_source = value
184
239
}
185
240
save_device_information()
241
+ restart_devices()
186
242
}
187
243
188
244
fun load_device_information ()
0 commit comments