Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates #85

Merged
merged 8 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ org.jetbrains.compose.experimental.uikit.enabled=true
android.defaults.buildfeatures.buildconfig=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
compose.version=1.6.0-dev1340
compose.version=1.6.0-dev1347
kotlin.version=1.9.21
multiplatform.version=1.9.21
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class AudioSelectOutBox

final static CustomSemaphore semaphore_audio_out_convert = new CustomSemaphore(1);
static int semaphore_audio_out_convert_active_threads = 0;
static int semaphore_audio_out_convert_max_active_threads = 2;
static int semaphore_audio_out_convert_max_active_threads = 1;
final static CustomSemaphore semaphore_audio_device_changes = new CustomSemaphore(1);

final static int SAMPLE_RATE_DEFAULT = 48000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public void acquire() throws InterruptedException {
acquire(null);
}

public void acquire_passthru() throws InterruptedException {
super.acquire();
}

public void acquire(String sourcefile_line_) throws InterruptedException {

String callerMethodName = "";
Expand Down Expand Up @@ -74,6 +78,11 @@ public void acquire(String sourcefile_line_) throws InterruptedException {
if (LOGGING) Log.i(TAG, ""+SEM_ID + " " + "acquire:finish" + callerMethodName);
}

public void release_passthru()
{
super.release();
}

@Override
public void release() {
if (LOGGING) Log.i(TAG, ""+SEM_ID + " " + "release:start");
Expand Down
117 changes: 117 additions & 0 deletions src/main/java/com/zoffcc/applications/trifa/HelperFriend.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,123 @@ static void send_friend_msg_receipt_v2_wrapper(final long friend_number, final i
}
}

static void update_friend_msgv3_capability(long friend_number, int new_value)
{
try
{
if ((new_value == 0) || (new_value == 1))
{
FriendList f = TrifaToxService.Companion.getOrma().selectFromFriendList().
tox_public_key_stringEq(tox_friend_get_public_key(friend_number)).
get(0);
if (f != null)
{
if (f.msgv3_capability != new_value)
{
Log.i(TAG,
"update_friend_msgv3_capability f=" +
get_friend_name_from_num(friend_number) + " new=" +
new_value + " old=" + f.msgv3_capability);
TrifaToxService.Companion.getOrma().updateFriendList().
tox_public_key_stringEq(tox_friend_get_public_key(friend_number)).
msgv3_capability(new_value).
execute();
}
}
}
}
catch (Exception e)
{
}
}

static String get_friend_name_from_num(long friendnum)
{
String result = "Unknown";

try
{
if (TrifaToxService.Companion.getOrma() != null)
{
try
{
String result_alias = TrifaToxService.Companion.getOrma().selectFromFriendList().
tox_public_key_stringEq(tox_friend_get_public_key(friendnum)).
toList().get(0).alias_name;

if (result_alias != null)
{
if (result_alias.length() > 0)
{
result = result_alias;
return result;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}

result = TrifaToxService.Companion.getOrma().selectFromFriendList().
tox_public_key_stringEq(tox_friend_get_public_key(friendnum)).
toList().get(0).name;
}
}
catch (Exception e)
{
result = "Unknown";
e.printStackTrace();
}

return result;
}

static String get_friend_name_from_pubkey(String friend_pubkey)
{
String ret = "Unknown";
String friend_alias_name = "";
String friend_name = "";

try
{
friend_alias_name = TrifaToxService.Companion.getOrma().selectFromFriendList().
tox_public_key_stringEq(friend_pubkey).
toList().get(0).alias_name;
}
catch (Exception e)
{
friend_alias_name = "";
e.printStackTrace();
}

if ((friend_alias_name == null) || (friend_alias_name.equals("")))
{
try
{
friend_name = TrifaToxService.Companion.getOrma().selectFromFriendList().
tox_public_key_stringEq(friend_pubkey).
toList().get(0).name;
}
catch (Exception e)
{
friend_name = "";
e.printStackTrace();
}

if ((friend_name != null) && (!friend_name.equals("")))
{
ret = friend_name;
}
}
else
{
ret = friend_alias_name;
}

return ret;
}

static FriendList main_get_friend(long friendnum) {
FriendList f = null;

Expand Down
58 changes: 58 additions & 0 deletions src/main/java/com/zoffcc/applications/trifa/HelperMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,64 @@ static void send_msgv3_high_level_ack(final long friend_number, String msgV3hash
}
}

static void process_msgv3_high_level_ack(final long friend_number, String msgV3hash_hex_string, long message_timestamp)
{
Message m = null;
try
{
m = TrifaToxService.Companion.getOrma().selectFromMessage().
msg_idv3_hashEq(msgV3hash_hex_string).
tox_friendpubkeyEq(tox_friend_get_public_key(friend_number)).
directionEq(1).
readEq(false).
orderByIdDesc().
toList().get(0);
}
catch (Exception e)
{
return;
}

if (m != null)
{
try
{
if (message_timestamp > 0)
{
m.rcvd_timestamp = message_timestamp * 1000;
}
else
{
m.rcvd_timestamp = System.currentTimeMillis();
}
m.read = true;
update_message_in_db_read_rcvd_timestamp_rawmsgbytes(m);
// TODO: update message in UI
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

static void update_message_in_db_read_rcvd_timestamp_rawmsgbytes(final Message m)
{
try
{
TrifaToxService.Companion.getOrma().updateMessage().
idEq(m.id).
read(m.read).
raw_msgv2_bytes(m.raw_msgv2_bytes).
rcvd_timestamp(m.rcvd_timestamp).
execute();
}
catch (Exception e)
{
e.printStackTrace();
}
}

public static long get_message_id_from_filetransfer_id_and_friendnum(long filetransfer_id, long friend_number)
{
try
Expand Down
19 changes: 18 additions & 1 deletion src/main/kotlin/com/zoffcc/applications/trifa/AVState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import avstatestorevcapfpsstate
import com.zoffcc.applications.ffmpegav.AVActivity
import com.zoffcc.applications.ffmpegav.AVActivity.ffmpegav_apply_audio_filter
import com.zoffcc.applications.ffmpegav.AVActivity.ffmpegav_init
import com.zoffcc.applications.trifa.MainActivity.Companion.AUDIO_PCM_DEBUG_FILES
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__audio_input_filter
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__audio_play_volume_percent
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__v4l2_capture_force_mjpeg
Expand Down Expand Up @@ -512,7 +513,8 @@ data class AVState(val a: Int)
{
audio_buffer_2 = ByteBuffer.allocateDirect(buffer_size_in_bytes2)
MainActivity.set_JNI_audio_buffer(audio_buffer_2)
}/* DEBUG ONLY ----------------------------
}
/* DEBUG ONLY ----------------------------
try
{
audio_buffer_1!!.rewind()
Expand All @@ -536,6 +538,21 @@ data class AVState(val a: Int)
{
Log.i(TAG, "toxav_audio_send_frame:result=" + toxav_audio_send_frame_res)
}
if (AUDIO_PCM_DEBUG_FILES)
{
val f = File("/tmp/toxaudio_send.txt")
try
{
audio_buffer_2!!.rewind()
val want_bytes = out_samples * 2
val audio_in_byte_buffer = ByteArray(want_bytes)
audio_buffer_2!![audio_in_byte_buffer, 0, want_bytes]
f.appendBytes(audio_in_byte_buffer)
} catch (e: Exception)
{
e.printStackTrace()
}
}
}
// HINT: fix me --------
val sample_count_: Int = out_samples
Expand Down
Loading
Loading