diff options
author | Andrew Comminos <andrewcomminos@gmail.com> | 2013-10-11 04:17:37 +0400 |
---|---|---|
committer | Andrew Comminos <andrewcomminos@gmail.com> | 2013-10-11 04:17:37 +0400 |
commit | e8d00f00917b7d7c4ea63f6b8dc4c3caa5c9dc76 (patch) | |
tree | ab4dde0bd9b21f936b983f1ee0fc98047a9b395b /src/main/java | |
parent | 076a7fefe5eed9f432292d4e3d0fdd29b95ed6ad (diff) |
Working Tor support with orbot, a bunch of audio fixes and various
protocol changes. Test suite temporarily broken.
Diffstat (limited to 'src/main/java')
43 files changed, 192 insertions, 89 deletions
diff --git a/src/main/java/com/morlunk/jumble/JumbleService.java b/src/main/java/com/morlunk/jumble/JumbleService.java index 24138ee..0526a84 100644 --- a/src/main/java/com/morlunk/jumble/JumbleService.java +++ b/src/main/java/com/morlunk/jumble/JumbleService.java @@ -117,13 +117,18 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon } @Override + public boolean isConnecting() throws RemoteException { + return mConnection != null && !mConnection.isConnected(); + } + + @Override public int getSession() throws RemoteException { return mConnection.getSession(); } @Override public User getSessionUser() throws RemoteException { - return mUserHandler.getUser(getSession()); + return mUserHandler != null ? mUserHandler.getUser(getSession()) : null; } @Override @@ -300,6 +305,14 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon } @Override + public void setPrioritySpeaker(int session, boolean priority) throws RemoteException { + Mumble.UserState.Builder usb = Mumble.UserState.newBuilder(); + usb.setSession(session); + usb.setPrioritySpeaker(priority); + mConnection.sendTCPMessage(usb.build(), JumbleTCPMessageType.UserState); + } + + @Override public void removeChannel(int channel) throws RemoteException { Mumble.ChannelRemove.Builder crb = Mumble.ChannelRemove.newBuilder(); crb.setChannelId(channel); @@ -422,7 +435,7 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon } public boolean isConnected() { - return mConnection.isConnected(); + return mConnection != null ? mConnection.isConnected() : false; } @Override diff --git a/src/main/java/com/morlunk/jumble/audio/AudioInput.java b/src/main/java/com/morlunk/jumble/audio/AudioInput.java index 9391c08..f43e621 100644 --- a/src/main/java/com/morlunk/jumble/audio/AudioInput.java +++ b/src/main/java/com/morlunk/jumble/audio/AudioInput.java @@ -16,38 +16,90 @@ package com.morlunk.jumble.audio; +import android.media.AudioFormat; +import android.media.AudioRecord; +import android.media.MediaRecorder; + +import com.morlunk.jumble.audio.celt11.CELT11; +import com.morlunk.jumble.audio.celt7.CELT7; +import com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTMode; +import com.morlunk.jumble.audio.opus.Opus; +import com.morlunk.jumble.audio.opus.OpusConstants; import com.morlunk.jumble.audio.opus.SWIGTYPE_p_OpusEncoder; import com.morlunk.jumble.net.JumbleUDPMessageType; /** * Created by andrew on 23/08/13. */ -public class AudioInput { +public class AudioInput implements Runnable { + private interface JumbleVoiceListener { + public void onFrameEncoded(byte[] data, int frameSize); + } + private SWIGTYPE_p_OpusEncoder mOpusEncoder; - private com.morlunk.jumble.audio.celt11.SWIGTYPE_p_CELTEncoder mCelt11Encoder; - private com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTEncoder mCelt7Encoder; + private com.morlunk.jumble.audio.celt11.SWIGTYPE_p_CELTEncoder mCELTBetaEncoder; + private com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTMode mCELTAlphaMode; + private com.morlunk.jumble.audio.celt7.SWIGTYPE_p_CELTEncoder mCELTAlphaEncoder; + + private JumbleVoiceListener mListener; + + private AudioRecord mAudioRecord; + private int mMinBufferSize; + private int mInputSampleRate = 44100; + private int mFrameSize = Audio.FRAME_SIZE; private JumbleUDPMessageType mCodec; - public AudioInput(JumbleUDPMessageType codec) { + public AudioInput(JumbleUDPMessageType codec, JumbleVoiceListener listener) { mCodec = codec; + mListener = listener; + int[] error = new int[1]; switch (codec) { case UDPVoiceOpus: + mOpusEncoder = Opus.opus_encoder_create(Audio.SAMPLE_RATE, 1, OpusConstants.OPUS_APPLICATION_VOIP, error); break; case UDPVoiceCELTBeta: + mCELTBetaEncoder = CELT11.celt_encoder_create(Audio.SAMPLE_RATE, 1, error); break; case UDPVoiceCELTAlpha: + mCELTAlphaMode = CELT7.celt_mode_create(Audio.SAMPLE_RATE, Audio.FRAME_SIZE, error); + mCELTAlphaEncoder = CELT7.celt_encoder_create(mCELTAlphaMode, 1, error); break; case UDPVoiceSpeex: + // TODO break; } + + mMinBufferSize = AudioRecord.getMinBufferSize(mInputSampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); + mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, mInputSampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, mMinBufferSize); } public void startRecording() { - + mAudioRecord.startRecording(); } public void stopRecording() { - + mAudioRecord.stop(); + } + + @Override + public void run() { + while(mAudioRecord.getState() == AudioRecord.RECORDSTATE_RECORDING) { + short[] audioData = new short[mFrameSize]; + byte[] encodedData = new byte[512]; + if(mAudioRecord.read(audioData, 0, mFrameSize) == AudioRecord.SUCCESS) { + switch (mCodec) { + case UDPVoiceOpus: + Opus.opus_encode(mOpusEncoder, audioData, mFrameSize, encodedData, 512); + break; + case UDPVoiceCELTBeta: + break; + case UDPVoiceCELTAlpha: + break; + case UDPVoiceSpeex: + break; + } + } + } } } diff --git a/src/main/java/com/morlunk/jumble/audio/celt11/CELT11.java b/src/main/java/com/morlunk/jumble/audio/celt11/CELT11.java index 5f57463..9a1bb6c 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt11/CELT11.java +++ b/src/main/java/com/morlunk/jumble/audio/celt11/CELT11.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt11/CELT11Constants.java b/src/main/java/com/morlunk/jumble/audio/celt11/CELT11Constants.java index 0d6d4c3..65a5964 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt11/CELT11Constants.java +++ b/src/main/java/com/morlunk/jumble/audio/celt11/CELT11Constants.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt11/CELT11JNI.java b/src/main/java/com/morlunk/jumble/audio/celt11/CELT11JNI.java index 025598d..27f89e7 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt11/CELT11JNI.java +++ b/src/main/java/com/morlunk/jumble/audio/celt11/CELT11JNI.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTDecoder.java b/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTDecoder.java index a9fd4da..713d400 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTDecoder.java +++ b/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTDecoder.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTEncoder.java b/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTEncoder.java index c85912c..5d2bc68 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTEncoder.java +++ b/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTEncoder.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTMode.java b/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTMode.java index 94f39a5..f720667 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTMode.java +++ b/src/main/java/com/morlunk/jumble/audio/celt11/SWIGTYPE_p_CELTMode.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt7/CELT7.java b/src/main/java/com/morlunk/jumble/audio/celt7/CELT7.java index fb5d8e4..59551d9 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt7/CELT7.java +++ b/src/main/java/com/morlunk/jumble/audio/celt7/CELT7.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt7/CELT7Constants.java b/src/main/java/com/morlunk/jumble/audio/celt7/CELT7Constants.java index bb854e5..62bd940 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt7/CELT7Constants.java +++ b/src/main/java/com/morlunk/jumble/audio/celt7/CELT7Constants.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt7/CELT7JNI.java b/src/main/java/com/morlunk/jumble/audio/celt7/CELT7JNI.java index 7b61ba4..349e109 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt7/CELT7JNI.java +++ b/src/main/java/com/morlunk/jumble/audio/celt7/CELT7JNI.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTDecoder.java b/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTDecoder.java index 03a80ee..dee7f32 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTDecoder.java +++ b/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTDecoder.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTEncoder.java b/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTEncoder.java index 3004d1e..7b012d1 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTEncoder.java +++ b/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTEncoder.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTMode.java b/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTMode.java index d9e39a5..fad5fc5 100644 --- a/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTMode.java +++ b/src/main/java/com/morlunk/jumble/audio/celt7/SWIGTYPE_p_CELTMode.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/Opus.java b/src/main/java/com/morlunk/jumble/audio/opus/Opus.java index 05f0274..d20b40d 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/Opus.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/Opus.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/OpusConstants.java b/src/main/java/com/morlunk/jumble/audio/opus/OpusConstants.java index 656fa44..f320dbf 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/OpusConstants.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/OpusConstants.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/OpusJNI.java b/src/main/java/com/morlunk/jumble/audio/opus/OpusJNI.java index 6fc01d2..0137325 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/OpusJNI.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/OpusJNI.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusDecoder.java b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusDecoder.java index 571c0c3..440c046 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusDecoder.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusDecoder.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusEncoder.java b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusEncoder.java index 12c5560..6f1370f 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusEncoder.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusEncoder.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusRepacketizer.java b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusRepacketizer.java index 335391b..d181ace 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusRepacketizer.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_OpusRepacketizer.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_p_unsigned_char.java b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_p_unsigned_char.java index ef18783..083a3ac 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_p_unsigned_char.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_p_unsigned_char.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_short.java b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_short.java index 6b6d2d7..edc683b 100644 --- a/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_short.java +++ b/src/main/java/com/morlunk/jumble/audio/opus/SWIGTYPE_p_short.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/JitterBufferPacket.java b/src/main/java/com/morlunk/jumble/audio/speex/JitterBufferPacket.java index 3c2e252..1555d8e 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/JitterBufferPacket.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/JitterBufferPacket.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_JitterBuffer_.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_JitterBuffer_.java index a83ab65..64461be 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_JitterBuffer_.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_JitterBuffer_.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexDecorrState_.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexDecorrState_.java index e45618d..c9a3bb8 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexDecorrState_.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexDecorrState_.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexEchoState_.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexEchoState_.java index 653c116..b1f1cdc 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexEchoState_.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexEchoState_.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexResamplerState_.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexResamplerState_.java index 8670a78..35633e8 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexResamplerState_.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_SpeexResamplerState_.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__struct_SpeexMode__p_void.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__struct_SpeexMode__p_void.java index 0eec2d2..fbb82c4 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__struct_SpeexMode__p_void.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__struct_SpeexMode__p_void.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__void_int_p_void__int.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__void_int_p_void__int.java index 72059be..81d4f65 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__void_int_p_void__int.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_q_const__void_int_p_void__int.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void__void.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void__void.java index 1d34000..19dd1bd 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void__void.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void__void.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_int_p_void__int.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_int_p_void__int.java index 939a8d6..6489d7f 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_int_p_void__int.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_int_p_void__int.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_struct_SpeexBits_p_void__int.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_struct_SpeexBits_p_void__int.java index 8814592..36c3294 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_struct_SpeexBits_p_void__int.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_struct_SpeexBits_p_void__int.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_void_p_struct_SpeexBits__int.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_void_p_struct_SpeexBits__int.java index a3df351..ca74682 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_void_p_struct_SpeexBits__int.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_f_p_void_p_void_p_struct_SpeexBits__int.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_p_SpeexMode.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_p_SpeexMode.java index ff017ee..df30f1e 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_p_SpeexMode.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_p_SpeexMode.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_void.java b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_void.java index 42dc7e2..eb8eebb 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_void.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SWIGTYPE_p_void.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/Speex.java b/src/main/java/com/morlunk/jumble/audio/speex/Speex.java index 618d6d4..a226288 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/Speex.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/Speex.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SpeexBits.java b/src/main/java/com/morlunk/jumble/audio/speex/SpeexBits.java index b6b6c0e..a15461f 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SpeexBits.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SpeexBits.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SpeexConstants.java b/src/main/java/com/morlunk/jumble/audio/speex/SpeexConstants.java index 58ce143..dab4a6d 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SpeexConstants.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SpeexConstants.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SpeexJNI.java b/src/main/java/com/morlunk/jumble/audio/speex/SpeexJNI.java index 3925a71..65efba3 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SpeexJNI.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SpeexJNI.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/audio/speex/SpeexMode.java b/src/main/java/com/morlunk/jumble/audio/speex/SpeexMode.java index 60d1afa..e15bf1b 100644 --- a/src/main/java/com/morlunk/jumble/audio/speex/SpeexMode.java +++ b/src/main/java/com/morlunk/jumble/audio/speex/SpeexMode.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.10 + * Version 2.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/src/main/java/com/morlunk/jumble/net/JumbleConnection.java b/src/main/java/com/morlunk/jumble/net/JumbleConnection.java index baf53a1..2bd7b6a 100644 --- a/src/main/java/com/morlunk/jumble/net/JumbleConnection.java +++ b/src/main/java/com/morlunk/jumble/net/JumbleConnection.java @@ -57,7 +57,8 @@ public class JumbleConnection { * For annoying types like UDPTunnel. */ public static final List<JumbleTCPMessageType> UNLOGGED_MESSAGES = Arrays.asList(new JumbleTCPMessageType[] { - JumbleTCPMessageType.UDPTunnel + JumbleTCPMessageType.UDPTunnel, + JumbleTCPMessageType.Ping }); // Tor connection details @@ -497,8 +498,7 @@ public class JumbleConnection { * @param data Raw protobuf TCP data. * @param messageType Type of the message. * @return The parsed protobuf message. - * @throws InvalidProtocolBufferException Called if the messageType doe - }s not match the data. + * @throws InvalidProtocolBufferException Called if the messageType does not match the data. */ public static final Message getProtobufMessage(byte[] data, JumbleTCPMessageType messageType) throws InvalidProtocolBufferException { switch (messageType) { @@ -782,7 +782,8 @@ public class JumbleConnection { * @throws IOException if we can't write the message to the server. */ public void sendMessage(Message message, JumbleTCPMessageType messageType) throws IOException { - Log.v(Constants.TAG, "OUT: "+messageType); + if(!UNLOGGED_MESSAGES.contains(messageType)) + Log.v(Constants.TAG, "OUT: "+messageType); mDataOutput.writeShort(messageType.ordinal()); mDataOutput.writeInt(message.getSerializedSize()); message.writeTo(mDataOutput); @@ -794,7 +795,8 @@ public class JumbleConnection { * @throws IOException if we can't write the message to the server. */ public void sendMessage(byte[] message, JumbleTCPMessageType messageType) throws IOException { - Log.v(Constants.TAG, "OUT: "+messageType); + if(!UNLOGGED_MESSAGES.contains(messageType)) + Log.v(Constants.TAG, "OUT: "+messageType); mDataOutput.writeShort(messageType.ordinal()); mDataOutput.writeInt(message.length); mDataOutput.write(message); @@ -856,7 +858,7 @@ public class JumbleConnection { if(!force && (mForceTCP || !mUsingUDP)) { ByteBuffer bb = ByteBuffer.allocate(length + 6); - bb.putShort((short) JumbleUDPMessageType.UDPPing.ordinal()); + bb.putShort((short) messageType.ordinal()); bb.putInt(length); bb.put(data); mTCP.sendData(bb.array()); diff --git a/src/main/java/com/morlunk/jumble/net/JumbleSSLSocketFactory.java b/src/main/java/com/morlunk/jumble/net/JumbleSSLSocketFactory.java index 28344de..82fbd05 100644 --- a/src/main/java/com/morlunk/jumble/net/JumbleSSLSocketFactory.java +++ b/src/main/java/com/morlunk/jumble/net/JumbleSSLSocketFactory.java @@ -18,6 +18,7 @@ package com.morlunk.jumble.net; import java.io.IOException; import java.net.InetSocketAddress; +import java.net.Proxy; import java.net.Socket; import java.security.KeyManagementException; import java.security.KeyStore; @@ -26,41 +27,62 @@ import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SecureRandom; import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; - -import ch.boye.httpclientandroidlib.conn.ssl.SSLSocketFactory; -import ch.boye.httpclientandroidlib.params.BasicHttpParams; -import ch.boye.httpclientandroidlib.params.HttpParams; -import socks.Socks5Proxy; -import socks.SocksSocket; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; public class JumbleSSLSocketFactory { - private SSLSocketFactory mSocketFactory; + private SSLContext mContext; public JumbleSSLSocketFactory(KeyStore keystore, String keystorePassword) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException, NoSuchProviderException { - mSocketFactory = new SSLSocketFactory(SSLSocketFactory.TLS, - keystore, - keystorePassword, - null, - new SecureRandom(), - SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); // No need for trust store at the moment. FIXME security + mContext = SSLContext.getInstance("TLS"); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509"); + kmf.init(keystore, keystorePassword != null ? keystorePassword.toCharArray() : new char[0]); + + mContext.init(kmf.getKeyManagers(), new TrustManager[] { new JumblePermissiveTrustManager() }, new SecureRandom()); } /** * Creates a new SSLSocket that runs through a SOCKS5 proxy to reach its destination. */ public SSLSocket createTorSocket(String host, int port, String proxyHost, int proxyPort) throws IOException { - Socks5Proxy proxy = new Socks5Proxy(proxyHost, proxyPort); - proxy.resolveAddrLocally(false); // Let SOCKS5 proxy resolve host. Useful for Tor. - SocksSocket socksSocket = new SocksSocket(proxy, host, port); - return (SSLSocket) mSocketFactory.createLayeredSocket(socksSocket, proxyHost, proxyPort, new BasicHttpParams()); + Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(proxyHost, proxyPort)); + Socket socket = new Socket(proxy); + socket.connect(new InetSocketAddress(host, port)); + return (SSLSocket) mContext.getSocketFactory().createSocket(socket, host, port, true); } public SSLSocket createSocket(String host, int port) throws IOException { - HttpParams params = new BasicHttpParams(); - Socket socket = mSocketFactory.createSocket(params); - return (SSLSocket) mSocketFactory.connectSocket(socket, new InetSocketAddress(host, port), null, params); + return (SSLSocket) mContext.getSocketFactory().createSocket(host, port); + } + + /** + * This is horrible practice- we should prompt the user when the server's certificate is not trusted. + * TODO FIX: SECURITY + */ + private static class JumblePermissiveTrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } } }
\ No newline at end of file diff --git a/src/main/java/com/morlunk/jumble/net/UserHandler.java b/src/main/java/com/morlunk/jumble/net/UserHandler.java index ee2e404..a33de1a 100644 --- a/src/main/java/com/morlunk/jumble/net/UserHandler.java +++ b/src/main/java/com/morlunk/jumble/net/UserHandler.java @@ -47,7 +47,7 @@ public class UserHandler extends JumbleMessageHandler.Stub { public int compare(Integer lhs, Integer rhs) { User ulhs = mUsers.get(lhs); User urhs = mUsers.get(rhs); - return ulhs.getName().compareTo(urhs.getName()); + return ulhs.getName().toLowerCase().compareTo(urhs.getName().toLowerCase()); } }; @@ -101,6 +101,10 @@ public class UserHandler extends JumbleMessageHandler.Stub { return; } + User actor = null; + if(msg.hasActor()) + actor = getUser(msg.getActor()); + final User finalUser = user; if(msg.hasUserId()) @@ -164,6 +168,15 @@ public class UserHandler extends JumbleMessageHandler.Stub { user.setDeafened(msg.getDeaf()); if(msg.hasPrioritySpeaker()) user.setPrioritySpeaker(msg.getPrioritySpeaker()); + +/* if(self != null && ((user.getChannelId() == self.getChannelId()) || (actor.getSession() == self.getSession()))) { + if(user.getSession() == self.getSession()) { + if(msg.hasMute() && msg.hasDeaf() && user.isMuted() && user.isDeafened()) { + mService.logInfo(); + } + } + }*/ + /* * TODO: logging * Base this off of Messages.cpp:353 @@ -230,25 +243,26 @@ public class UserHandler extends JumbleMessageHandler.Stub { @Override public void messageUserRemove(Mumble.UserRemove msg) { + final User user = getUser(msg.getSession()); + final User actor = getUser(msg.getActor()); final String reason = msg.getReason(); - /* - * TODO: logging - * Base this off of Messages.cpp:511 - */ + if(msg.getSession() == mService.getSession()) + mService.logWarning(mService.getString(msg.getBan() ? R.string.chat_notify_kick_ban_self : R.string.chat_notify_kick_self, MessageFormatter.highlightString(actor.getName()), reason)); + else if(actor != null) + mService.logInfo(mService.getString(msg.getBan() ? R.string.chat_notify_kick_ban : R.string.chat_notify_kick, MessageFormatter.highlightString(actor.getName()), reason, MessageFormatter.highlightString(user.getName()))); + else + mService.logInfo(mService.getString(R.string.chat_notify_disconnected, MessageFormatter.highlightString(user.getName()))); - if(msg.getSession() != mService.getSession()) { - final User user = mService.getUserHandler().getUser(msg.getSession()); - Channel channel = mService.getChannelHandler().getChannel(user.getChannelId()); - channel.removeUser(user.getSession()); + Channel channel = mService.getChannelHandler().getChannel(user.getChannelId()); + channel.removeUser(user.getSession()); - mService.getChannelHandler().changeSubchannelUsers(channel, -1); - mService.notifyObservers(new JumbleService.ObserverRunnable() { - @Override - public void run(IJumbleObserver observer) throws RemoteException { - observer.onUserRemoved(user, reason); - } - }); - } + mService.getChannelHandler().changeSubchannelUsers(channel, -1); + mService.notifyObservers(new JumbleService.ObserverRunnable() { + @Override + public void run(IJumbleObserver observer) throws RemoteException { + observer.onUserRemoved(user, reason); + } + }); } } |