Porównaj commity

...

13 Commity
1.67 ... master

Autor SHA1 Wiadomość Data
sh123 1b15e9a029 Update version 2024-02-22 19:59:48 +02:00
sh123 f6bfff12a2 Add raspberry pi pico device filter 2024-02-20 20:45:03 +02:00
sh123 cdb787d922 Update version and some strings 2024-02-20 18:05:35 +02:00
sh123 8edf786869 Added custom prefix as protocol 2024-02-19 22:28:53 +02:00
sh123 579c27f931 Cleanup 2024-02-19 21:52:57 +02:00
sh123 fb809eb47f Remove previous feature, needs another approach 2024-02-19 21:45:20 +02:00
sh123 ad6e79044b Add option to prefix USB packet with transmission target 2024-02-19 19:04:24 +02:00
sh123 83cffeaeea Fix issue with exact super frame size giving smaller packet 2024-02-18 22:30:57 +02:00
sh123 532686c3cf Fix NDK working version 2024-02-18 22:16:23 +02:00
sh123 dda3677b00 Increase version, do not use super frame size for OPUS 2023-12-25 12:51:56 +02:00
sh123 b19dcb8ca3 Change from /usr/bin/cmake to cmake 2023-12-11 17:39:14 +02:00
sh123 aa1087cd9e Increase version 2023-12-10 18:43:59 +02:00
sh123 4d0eb259b3 Added .gitignore 2023-12-10 08:38:07 +02:00
20 zmienionych plików z 273 dodań i 25 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ plugins {
}
android {
android.ndkVersion "21.4.7075529"
compileSdkVersion 30
buildToolsVersion "30.0.2"
@ -10,8 +11,8 @@ android {
applicationId "com.radio.codec2talkie"
minSdkVersion 23
targetSdkVersion 30
versionCode 167
versionName "1.67"
versionCode 172
versionName "1.72"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Wyświetl plik

@ -113,6 +113,14 @@ public class UsbConnectActivity extends AppCompatActivity {
customTable.addProduct(0x0403, 0x6011, FtdiSerialDriver.class);
customTable.addProduct(0x0403, 0x6014, FtdiSerialDriver.class);
customTable.addProduct(0x0403, 0x6015, FtdiSerialDriver.class);
// Raspberry PI Pico
customTable.addProduct(0x2e8a, 0x0004, CdcAcmSerialDriver.class);
customTable.addProduct(0x2e8a, 0x0005, CdcAcmSerialDriver.class);
customTable.addProduct(0x2e8a, 0x000a, CdcAcmSerialDriver.class);
customTable.addProduct(0x2e8a, 0x000b, CdcAcmSerialDriver.class);
customTable.addProduct(0x2e8a, 0x000c, CdcAcmSerialDriver.class);
customTable.addProduct(0x2e8a, 0x000d, CdcAcmSerialDriver.class);
customTable.addProduct(0x2e8a, 0x000e, CdcAcmSerialDriver.class);
return new UsbSerialProber(customTable);
}

Wyświetl plik

@ -68,7 +68,7 @@ public class AudioCodec2FrameAggregator implements Protocol {
@Override
public void sendCompressedAudio(String src, String dst, byte[] frame) throws IOException {
if ( _outputBufferPos + frame.length >= _outputBufferSize) {
if ( _outputBufferPos + frame.length > _outputBufferSize) {
_childProtocol.sendCompressedAudio(src, dst, Arrays.copyOf(_outputBuffer, _outputBufferPos));
_outputBufferPos = 0;
}

Wyświetl plik

@ -2,7 +2,6 @@ package com.radio.codec2talkie.protocol;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import androidx.preference.PreferenceManager;
@ -10,7 +9,6 @@ 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;
@ -48,18 +46,17 @@ public class AudioOpus implements Protocol {
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

Wyświetl plik

@ -0,0 +1,167 @@
package com.radio.codec2talkie.protocol;
import android.content.Context;
import android.content.SharedPreferences;
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.TextTools;
import com.radio.codec2talkie.transport.Transport;
import java.io.IOException;
import java.nio.ByteBuffer;
public class CustomDataPrefix implements Protocol {
private final Protocol _childProtocol;
private ProtocolCallback _parentProtocolCallback;
private final byte[] _bytePrefix;
public CustomDataPrefix(Protocol childProtocol, SharedPreferences sharedPreferences) {
_childProtocol = childProtocol;
String prefix = sharedPreferences.getString(PreferenceKeys.CUSTOM_PREFIX, "");
_bytePrefix = TextTools.hexStringToByteArray(prefix);
}
@Override
public void initialize(Transport transport, Context context, ProtocolCallback protocolCallback) throws IOException {
_parentProtocolCallback = protocolCallback;
_childProtocol.initialize(transport, context, _protocolCallback);
}
@Override
public int getPcmAudioRecordBufferSize() {
return -1;
}
@Override
public void sendCompressedAudio(String src, String dst, byte[] frame) throws IOException {
byte[] prefixedData = ByteBuffer.allocate(_bytePrefix.length + frame.length)
.put(_bytePrefix)
.put(frame)
.array();
_childProtocol.sendCompressedAudio(src, dst, prefixedData);
}
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
_childProtocol.sendTextMessage(textMessage);
}
@Override
public void sendPcmAudio(String src, String dst, short[] pcmFrame) throws IOException {
_childProtocol.sendPcmAudio(src, dst, pcmFrame);
}
@Override
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
byte[] prefixedData = ByteBuffer.allocate(_bytePrefix.length + dataPacket.length)
.put(_bytePrefix)
.put(dataPacket)
.array();
_childProtocol.sendData(src, dst, path, prefixedData);
}
@Override
public boolean receive() throws IOException {
return _childProtocol.receive();
}
@Override
public void sendPosition(Position position) throws IOException {
_childProtocol.sendPosition(position);
}
@Override
public void flush() throws IOException {
_childProtocol.flush();
}
@Override
public void close() {
_childProtocol.close();
}
ProtocolCallback _protocolCallback = new ProtocolCallback() {
@Override
protected void onReceivePosition(Position position) {
_parentProtocolCallback.onReceivePosition(position);
}
@Override
protected void onReceivePcmAudio(String src, String dst, short[] pcmFrame) {
_parentProtocolCallback.onReceivePcmAudio(src, dst, pcmFrame);
}
@Override
protected void onReceiveCompressedAudio(String src, String dst, byte[] audioFrame) {
_parentProtocolCallback.onReceiveCompressedAudio(src, dst, audioFrame);
}
@Override
protected void onReceiveTextMessage(TextMessage textMessage) {
_parentProtocolCallback.onReceiveTextMessage(textMessage);
}
@Override
protected void onReceiveData(String src, String dst, String path, byte[] data) {
_parentProtocolCallback.onReceiveData(src, dst, path, data);
}
@Override
protected void onReceiveSignalLevel(short rssi, short snr) {
_parentProtocolCallback.onReceiveSignalLevel(rssi, snr);
}
@Override
protected void onReceiveTelemetry(int batVoltage) {
_parentProtocolCallback.onReceiveTelemetry(batVoltage);
}
@Override
protected void onReceiveLog(String logData) {
_parentProtocolCallback.onReceiveLog(logData);
}
@Override
protected void onTransmitPcmAudio(String src, String dst, short[] frame) {
_parentProtocolCallback.onTransmitPcmAudio(src, dst, frame);
}
@Override
protected void onTransmitCompressedAudio(String src, String dst, byte[] frame) {
_parentProtocolCallback.onTransmitCompressedAudio(src, dst, frame);
}
@Override
protected void onTransmitTextMessage(TextMessage textMessage) {
_parentProtocolCallback.onTransmitTextMessage(textMessage);
}
@Override
protected void onTransmitPosition(Position position) {
_parentProtocolCallback.onTransmitPosition(position);
}
@Override
protected void onTransmitData(String src, String dst, String path, byte[] data) {
_parentProtocolCallback.onTransmitData(src, dst, path, data);
}
@Override
protected void onTransmitLog(String logData) {
_parentProtocolCallback.onTransmitLog(logData);
}
@Override
protected void onProtocolRxError() {
_parentProtocolCallback.onProtocolRxError();
}
@Override
protected void onProtocolTxError() {
_parentProtocolCallback.onProtocolTxError();
}
};
}

Wyświetl plik

@ -72,6 +72,7 @@ public class ProtocolFactory {
boolean aprsIsEnabled = SettingsWrapper.isAprsIsEnabled(sharedPreferences);
boolean freedvEnabled = SettingsWrapper.isFreeDvSoundModemModulation(sharedPreferences);
boolean codec2Enabled = SettingsWrapper.isCodec2Enabled(sharedPreferences);
boolean isCustomPrefixEnabled = SettingsWrapper.isCustomPrefixEnabled(sharedPreferences);
// "root" protocol
Protocol proto;
@ -97,6 +98,9 @@ public class ProtocolFactory {
break;
}
if (isCustomPrefixEnabled) {
proto = new CustomDataPrefix(proto, sharedPreferences);
}
if (scramblingEnabled) {
proto = new Scrambler(proto, scramblingKey);
}
@ -108,7 +112,6 @@ public class ProtocolFactory {
if (recordingEnabled) {
proto = new Recorder(proto, sharedPreferences);
}
proto = new AudioCodec2FrameAggregator(proto, sharedPreferences);
proto = new AudioCodec2(proto, sharedPreferences);
} else {

Wyświetl plik

@ -9,7 +9,6 @@ public final class PreferenceKeys {
public static String PORTS_USB_PARITY = "ports_usb_parity";
public static String PORTS_USB_DTR = "ports_usb_dtr";
public static String PORTS_USB_RTS = "ports_usb_rts";
public static String PORTS_BT_CLIENT_NAME = "ports_bt_client_name";
public static String PORTS_TCP_IP_ADDRESS = "ports_tcp_ip_address";
@ -30,6 +29,9 @@ public final class PreferenceKeys {
public static String PORTS_SOUND_MODEM_FREEDV_SQUELCH_SNR="ports_sound_modem_freedv_squelch_snr";
public static String PORTS_SOUND_MODEM_FREEDV_DATA_MODE="ports_sound_modem_freedv_data_mode";
public static String CUSTOM_PREFIX_ENABLED = "custom_prefix_enabled";
public static String CUSTOM_PREFIX = "custom_prefix";
public static String CODEC_TYPE = "codec_type";
public static String CODEC2_RECORDING_ENABLED = "codec2_recording_enabled";

Wyświetl plik

@ -117,6 +117,15 @@ public class SettingsActivity extends AppCompatActivity
}
}
public static class SettingsTncExtendedFragment extends PreferenceFragmentCompat
{
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences_tnc_extended, null);
setNumberInputType(getPreferenceManager());
}
}
public static class SettingsTcpIpFragment extends PreferenceFragmentCompat
{
@Override

Wyświetl plik

@ -44,6 +44,10 @@ public class SettingsWrapper {
return sharedPreferences.getString(PreferenceKeys.CODEC_TYPE, "Codec2").equals("Codec2");
}
public static boolean isCustomPrefixEnabled(SharedPreferences sharedPreferences) {
return sharedPreferences.getBoolean(PreferenceKeys.CUSTOM_PREFIX_ENABLED, false);
}
public static int getFreeDvSoundModemModulation(SharedPreferences sharedPreferences) {
String modemType = sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_TYPE, "1200");
if (modemType.startsWith("F")) {

Wyświetl plik

@ -53,4 +53,14 @@ public class TextTools {
}
return result.toString();
}
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
}

Wyświetl plik

@ -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>
@ -193,6 +193,15 @@
<string name="usb_serial_title">USB serial settings</string>
<string name="usb_serial_summary">Set USB serial settings, such as speed, bits, parity, etc.</string>
<string name="tnc_extended_title">Extended TNC settings</string>
<string name="tnc_extended_summary">Additional TNC specific settings</string>
<string name="tnc_extended_uart_title">UART modem prefix</string>
<string name="custom_prefix_enabled_title">Enable UART modem TX prefix</string>
<string name="custom_prefix_enabled_summary">Prefix data with the HEX string, used in fixed transmission mode by some UART modems to specify transmission target</string>
<string name="custom_prefix_title">Packet prefix value as a HEX string</string>
<string name="custom_prefix_summary">Prefix content as a HEX string, e.g. C0FFEE</string>
<string name="app_audio_output_speaker_title">Play audio through the speaker</string>
<string name="app_audio_output_speaker_summary">Output incoming audio through the speaker</string>
<string name="app_audio_input_voice_communication_title">Microphone enhancements</string>

Wyświetl plik

@ -35,4 +35,6 @@
<usb-device vendor-id="1155" product-id="22322" /> <!-- 0x0483 / 0x5732: STM, MCHF -->
<usb-device vendor-id="4292" product-id="60000" /> <!-- 0x10c4 / 0xea60: CP2102/2109, iCom -->
<!-- Raspberry PI -->
<usb-device vendor-id="11914" /> <!-- 0x2E8A / ......: Raspberry -->
</resources>

Wyświetl plik

@ -112,6 +112,12 @@
app:fragment="com.radio.codec2talkie.settings.SettingsActivity$SettingsSoundModemFragment">
</Preference>
<Preference
app:key="ports_tnc_extended"
app:title="@string/tnc_extended_title"
app:summary="@string/tnc_extended_summary"
app:fragment="com.radio.codec2talkie.settings.SettingsActivity$SettingsTncExtendedFragment">
</Preference>
</PreferenceCategory>
<PreferenceCategory
@ -133,14 +139,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"

Wyświetl plik

@ -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

Wyświetl plik

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:key="tnc_extended_uart"
app:title="@string/tnc_extended_uart_title">
<CheckBoxPreference
app:key="custom_prefix_enabled"
app:title="@string/custom_prefix_enabled_title"
app:summary="@string/custom_prefix_enabled_summary"
app:defaultValue="false">
</CheckBoxPreference>
<EditTextPreference
app:key="custom_prefix"
app:title="@string/custom_prefix_title"
app:summary = "@string/custom_prefix_summary"
app:dependency="custom_prefix_enabled"
app:defaultValue="C0FFEE">
</EditTextPreference>
</PreferenceCategory>
</PreferenceScreen>

Wyświetl plik

@ -54,5 +54,6 @@
app:summary="@string/usb_rts_summary"
app:defaultValue="false">
</CheckBoxPreference>
</PreferenceCategory>
</PreferenceScreen>

Wyświetl plik

@ -74,12 +74,12 @@ task compileCodec2 {
doLast {
exec {
workingDir "$projectDir/build/codec2_build_linux"
commandLine "/usr/bin/cmake", "$projectDir/src/codec2"
commandLine "cmake", "$projectDir/src/codec2"
}
exec {
workingDir "$projectDir/build/codec2_build_linux"
commandLine "/usr/bin/make"
commandLine "make"
}
for(String abi : rootProject.ext.ABI_FILTERS.split(";")) {
@ -96,7 +96,7 @@ task compileCodec2 {
exec {
workingDir "$projectDir/build/codec2_build_android_" + abi
commandLine "/usr/bin/cmake", "--build", "."
commandLine "cmake", "--build", "."
}
copy {

3
libopus-android/.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1,3 @@
/build
**/.cxx

Wyświetl plik

@ -74,12 +74,12 @@ task compileOpus {
doLast {
exec {
workingDir "$projectDir/build/opus_build_linux"
commandLine "/usr/bin/cmake", "$projectDir/src/opus"
commandLine "cmake", "$projectDir/src/opus"
}
exec {
workingDir "$projectDir/build/opus_build_linux"
commandLine "/usr/bin/make"
commandLine "make"
}
for(String abi : rootProject.ext.ABI_FILTERS.split(";")) {
@ -95,7 +95,7 @@ task compileOpus {
exec {
workingDir "$projectDir/build/opus_build_android_" + abi
commandLine "/usr/bin/cmake", "--build", "."
commandLine "cmake", "--build", "."
}
copy {

Wyświetl plik

@ -27,6 +27,7 @@ namespace Java_com_radio_opus_Opus {
opus_encoder_ctl(encoder, OPUS_SET_BITRATE(bitrate));
opus_encoder_ctl(encoder, OPUS_SET_COMPLEXITY(complexity));
opus_encoder_ctl(encoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
}
int decoderError;