Skip to content

Commit

Permalink
add audio filter values files with path
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Nov 6, 2023
1 parent ca13286 commit e75f42b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 63 deletions.
22 changes: 0 additions & 22 deletions mp.rnnn

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
public class AVActivity {

private static final String TAG = "ffmpegav.AVActivity";
static final String Version = "0.99.3";
static final String Version = "0.99.4";

public static native String ffmpegav_version();
public static native String ffmpegav_libavutil_version();
public static native int ffmpegav_init();
public static native int ffmpegav_init(String resources_dir);
public static native void ffmpegav_apply_audio_filter(int apply_filter);
public static native String[] ffmpegav_get_video_in_devices();
public static native String[] ffmpegav_get_audio_in_devices();
Expand Down Expand Up @@ -195,7 +195,8 @@ public static void main(String[] args) {
}
Log.i(TAG, "libavutil version: " + ffmpegav_libavutil_version());
Log.i(TAG, "ffmpegav version: " + ffmpegav_version());
final int res = ffmpegav_init();
// final int res = ffmpegav_init("./"); // exmaple with path must include the seperator at the end!
final int res = ffmpegav_init(null); // exmaple with "null" -> filter data will be loaded from current directory
Log.i(TAG, "ffmpeg init: " + res);

final String[] video_in_devices = ffmpegav_get_video_in_devices();
Expand Down
92 changes: 56 additions & 36 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Audiotrack
import androidx.compose.material.icons.filled.Filter
import androidx.compose.material.icons.filled.FormatSize
import androidx.compose.material.icons.filled.Fullscreen
import androidx.compose.material.icons.filled.Refresh
Expand Down Expand Up @@ -69,6 +68,7 @@ import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import ca.gosyer.appdirs.AppDirs
import com.zoffcc.applications.ffmpegav.AVActivity
import com.zoffcc.applications.trifa.AudioBar
import com.zoffcc.applications.trifa.AudioBar.audio_in_bar
Expand Down Expand Up @@ -116,12 +116,12 @@ import org.briarproject.briar.desktop.ui.VerticalDivider
import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n
import java.awt.Component
import java.awt.Toolkit
import java.io.File
import java.util.*
import java.util.concurrent.Executors
import java.util.prefs.Preferences
import javax.swing.JButton
import javax.swing.JPanel
import kotlin.collections.ArrayList

private const val TAG = "trifa.Main.kt"
var tox_running_state_wrapper = "start"
Expand Down Expand Up @@ -168,6 +168,8 @@ var global_semaphore_grouppeerlist_ui = CustomSemaphore(1)
var global_semaphore_grouplist_ui = CustomSemaphore(1)
var global_semaphore_messagelist_ui = CustomSemaphore(1)
var global_semaphore_groupmessagelist_ui = CustomSemaphore(1)
val APPDIRS = AppDirs("trifa_material", "zoxcore")
val RESOURCESDIR = File(System.getProperty("compose.application.resources.dir"))

@OptIn(DelicateCoroutinesApi::class, ExperimentalFoundationApi::class)
@Composable
Expand All @@ -178,6 +180,21 @@ fun App()
var tox_running_state: String by remember { mutableStateOf("stopped") }
var ui_scale by remember { mutableStateOf(1.0f) }

println("User data dir: " + APPDIRS.getUserDataDir())
println("User data dir (roaming): " + APPDIRS.getUserDataDir(roaming = true))
println("User config dir: " + APPDIRS.getUserConfigDir())
println("User config dir (roaming): " + APPDIRS.getUserConfigDir(roaming = true))
println("User cache dir: " + APPDIRS.getUserCacheDir())
println("User log dir: " + APPDIRS.getUserLogDir())
println("Site data dir: " + APPDIRS.getSiteDataDir())
println("Site data dir (multi path): " + APPDIRS.getSiteDataDir(multiPath = true))
println("Site config dir: " + APPDIRS.getSiteConfigDir())
println("Site config dir (multi path): " + APPDIRS.getSiteConfigDir(multiPath = true))
println("Shared dir: " + APPDIRS.getSharedDir())

Log.i(TAG, "resources dir: " + RESOURCESDIR)
Log.i(TAG, "resources dir canonical: " + RESOURCESDIR.canonicalPath + File.separator)

Log.i(TAG, "CCCC:" + PrefsSettings::class.java)
ui_scale = 1.0f

Expand Down Expand Up @@ -303,38 +320,41 @@ fun App()
}
}
)
var audio_filter_current_value by remember { mutableStateOf(PREF__audio_input_filter)}
Icon(modifier = Modifier.padding(5.dp).combinedClickable(
onClick = {
if (PREF__audio_input_filter == 0){
PREF__audio_input_filter = 1
} else {
PREF__audio_input_filter = 0
}
audio_filter_current_value = PREF__audio_input_filter
AVActivity.ffmpegav_apply_audio_filter(PREF__audio_input_filter)
}),
imageVector = Icons.Default.Audiotrack, contentDescription = "",
tint = if (audio_filter_current_value == 1) Color.Red else Color.DarkGray)
Icon(modifier = Modifier.padding(5.dp)
.combinedClickable(onClick = {
if (video_in_box_small)
{
video_in_box_width = VIDEO_IN_BOX_WIDTH_BIG
video_in_box_height = VIDEO_IN_BOX_HEIGHT_BIG
main_top_tab_height = VIDEO_IN_BOX_HEIGHT_BIG
video_in_box_width_fraction = VIDEO_IN_BOX_WIDTH_FRACTION_BIG
}
else
{
video_in_box_width = VIDEO_IN_BOX_WIDTH_SMALL
video_in_box_height = VIDEO_IN_BOX_HEIGHT_SMALL
main_top_tab_height = MAIN_TOP_TAB_HEIGHT
video_in_box_width_fraction = VIDEO_IN_BOX_WIDTH_FRACTION_SMALL
}
video_in_box_small = video_in_box_small.not()
Log.i(TAG, "update3: " + video_in_box_small)
}), imageVector = Icons.Default.Fullscreen, contentDescription = "")
Column {
Icon(modifier = Modifier.padding(5.dp)
.combinedClickable(onClick = {
if (video_in_box_small)
{
video_in_box_width = VIDEO_IN_BOX_WIDTH_BIG
video_in_box_height = VIDEO_IN_BOX_HEIGHT_BIG
main_top_tab_height = VIDEO_IN_BOX_HEIGHT_BIG
video_in_box_width_fraction = VIDEO_IN_BOX_WIDTH_FRACTION_BIG
} else
{
video_in_box_width = VIDEO_IN_BOX_WIDTH_SMALL
video_in_box_height = VIDEO_IN_BOX_HEIGHT_SMALL
main_top_tab_height = MAIN_TOP_TAB_HEIGHT
video_in_box_width_fraction = VIDEO_IN_BOX_WIDTH_FRACTION_SMALL
}
video_in_box_small = video_in_box_small.not()
Log.i(TAG, "update3: " + video_in_box_small)
}), imageVector = Icons.Default.Fullscreen, contentDescription = "")
var audio_filter_current_value by remember { mutableStateOf(PREF__audio_input_filter) }
Icon(modifier = Modifier.padding(5.dp).combinedClickable(
onClick = {
if (PREF__audio_input_filter == 0)
{
PREF__audio_input_filter = 1
} else
{
PREF__audio_input_filter = 0
}
audio_filter_current_value = PREF__audio_input_filter
AVActivity.ffmpegav_apply_audio_filter(PREF__audio_input_filter)
}),
imageVector = Icons.Default.Audiotrack, contentDescription = "",
tint = if (audio_filter_current_value == 1) Color.Red else Color.DarkGray)
}
var video_out_box_width by remember { mutableStateOf(VIDEO_OUT_BOX_WIDTH_SMALL) }
var video_out_box_height by remember { mutableStateOf(VIDEO_OUT_BOX_HEIGHT_SMALL) }
var video_out_box_small by remember { mutableStateOf(true)}
Expand Down Expand Up @@ -638,7 +658,7 @@ fun App()
} else
{
messagestore.send(MessageAction.Clear(0))
//GlobalScope.launch {
// GlobalScope.launch {
load_messages_for_friend(contacts.selectedContactPubkey)
//}
ChatAppWithScaffold(focusRequester = focusRequester, contactList = contacts, ui_scale = ui_scale)
Expand Down Expand Up @@ -669,7 +689,7 @@ fun App()
} else
{
groupmessagestore.send(GroupMessageAction.ClearGroup(0))
//GlobalScope.launch {
// GlobalScope.launch {
load_groupmessages_for_friend(groups.selectedGroupId)
//}
GroupAppWithScaffold(focusRequester = groupfocusRequester, groupList = groups, ui_scale = ui_scale)
Expand Down
15 changes: 13 additions & 2 deletions src/main/kotlin/com/zoffcc/applications/trifa/AVState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.zoffcc.applications.trifa
import CAPTURE_VIDEO_FPS
import CAPTURE_VIDEO_HEIGHT
import CAPTURE_VIDEO_WIDTH
import RESOURCESDIR
import avstatestorecallstate
import com.zoffcc.applications.ffmpegav.AVActivity
import com.zoffcc.applications.ffmpegav.AVActivity.ffmpegav_apply_audio_filter
Expand All @@ -15,6 +16,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import java.io.File
import java.nio.ByteBuffer
import java.util.concurrent.Semaphore

Expand Down Expand Up @@ -124,8 +126,17 @@ data class AVState(val a: Int)
{
if (!ffmpeg_init_done_get())
{
val res = ffmpegav_init()
println("==================ffmpeg init: $res")
try
{
val res = ffmpegav_init(RESOURCESDIR.canonicalPath + File.separator)
println("==================ffmpeg init:1: $res")
}
catch(e: Exception)
{
Log.i(TAG, "ERROR: something happend while trying to get RESOURCESDIR.canonicalPath")
val res = ffmpegav_init(null)
println("==================ffmpeg init:2: $res")
}
ffmpeg_init_done_set(true)
}
}
Expand Down

0 comments on commit e75f42b

Please sign in to comment.