Skip to content

Commit

Permalink
Increase version, do not use super frame size for OPUS
Browse files Browse the repository at this point in the history
  • Loading branch information
sh123 committed Dec 25, 2023
1 parent b19dcb8 commit dda3677
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions codec2talkie/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.radio.codec2talkie"
minSdkVersion 23
targetSdkVersion 30
versionCode 168
versionName "1.68"
versionCode 169
versionName "1.69"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;

import androidx.preference.PreferenceManager;

import com.radio.codec2talkie.protocol.message.TextMessage;
import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.tools.DebugTools;
import com.radio.codec2talkie.transport.Transport;
import com.radio.opus.Opus;

Expand Down Expand Up @@ -48,18 +46,17 @@ public void initialize(Transport transport, Context context, ProtocolCallback pr
int complexity = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.OPUS_COMPLEXITY, "5"));
float pcmFrameDuration = Float.parseFloat(sharedPreferences.getString(PreferenceKeys.OPUS_FRAME_SIZE, "40"));

int superFrameSize = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.CODEC2_TX_FRAME_MAX_SIZE, "48"));
_pcmFrameSize = (int)(SAMPLE_RATE / 1000 * pcmFrameDuration);
_audioBufferSize = 10*_pcmFrameSize;

_playbackAudioBuffer = new short[_audioBufferSize];
_recordAudioEncodedBuffer = new byte[superFrameSize];
_recordAudioEncodedBuffer = new byte[_audioBufferSize];

_opusCon = Opus.create(SAMPLE_RATE, 1, Opus.OPUS_APPLICATION_VOIP, bitRate, complexity);
if (_opusCon == 0) {
Log.e(TAG, "Failed to create opus");
}
Log.i(TAG, "Opus is initialized, pcm frame size: " + _pcmFrameSize + ", super frame size: " + superFrameSize);
Log.i(TAG, "Opus is initialized, pcm frame size: " + _pcmFrameSize + ", buffer size: " + _audioBufferSize);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion codec2talkie/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<string name="kiss_toast_modem_reboot">Modem reboot requested</string>

<string name="codec2_tx_frame_max_size_title">Maximum super frame size (bytes)</string>
<string name="codec2_tx_frame_max_size_summary">Multiple audio codec encoded samples are aggregated into super frame not larger than this value</string>
<string name="codec2_tx_frame_max_size_summary">Multiple Codec2 encoded samples are aggregated into super frame not larger than this value</string>

<string name="usb_settings_title">USB settings</string>
<string name="usb_data_bits_title">Serial data bits</string>
Expand Down
9 changes: 1 addition & 8 deletions codec2talkie/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,7 @@
app:summary="@string/codec_type_settings_summary"
app:fragment="com.radio.codec2talkie.settings.SettingsActivity$SettingsCodecFragment">
</Preference>

<EditTextPreference
app:key="codec2_tx_frame_max_size"
app:title="@string/codec2_tx_frame_max_size_title"
app:summary="@string/codec2_tx_frame_max_size_summary"
app:defaultValue="48">
</EditTextPreference>


<SwitchPreference
app:key="codec2_recording_enabled"
app:title="@string/codec2_recorder_title"
Expand Down
7 changes: 7 additions & 0 deletions codec2talkie/src/main/res/xml/preferences_codec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
app:summary="%s">
</ListPreference>

<EditTextPreference
app:key="codec2_tx_frame_max_size"
app:title="@string/codec2_tx_frame_max_size_title"
app:summary="@string/codec2_tx_frame_max_size_summary"
app:defaultValue="48">
</EditTextPreference>

</PreferenceCategory>

<PreferenceCategory
Expand Down

0 comments on commit dda3677

Please sign in to comment.