--- a/AndroidManifest.xml Sun Jan 24 00:42:29 2010 +0100
+++ b/AndroidManifest.xml Sun Jan 24 04:52:19 2010 +0100
@@ -97,6 +97,8 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
+ <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
+
<uses-sdk android:minSdkVersion="3" />
</manifest>
Binary file assets/alerting has changed
--- a/res/menu/call.xml Sun Jan 24 00:42:29 2010 +0100
+++ b/res/menu/call.xml Sun Jan 24 04:52:19 2010 +0100
@@ -5,6 +5,6 @@
android:title="~ speaker off ~" android:icon="@android:drawable/ic_lock_silent_mode" />
<item android:id="@+id/call_hold_on" android:visible="true"
android:title="~ hold on ~ " android:icon="@android:drawable/ic_lock_lock" />
- <item android:id="@+id/call_hold_on" android:visible="true"
- android:title="~ hold on ~ " android:icon="@android:drawable/ic_menu_call" />
+ <item android:id="@+id/call_hold_off" android:visible="true"
+ android:title="~ hold off ~ " android:icon="@android:drawable/ic_menu_call" />
</menu>
Binary file res/raw/ringback.ogg has changed
--- a/src/com/beem/project/beem/jingle/JingleService.java Sun Jan 24 00:42:29 2010 +0100
+++ b/src/com/beem/project/beem/jingle/JingleService.java Sun Jan 24 04:52:19 2010 +0100
@@ -66,6 +66,7 @@
import android.content.Intent;
import com.beem.project.beem.ui.Call;
+import com.beem.project.beem.jingle.RTPAudioSession;
import com.beem.project.beem.service.aidl.IBeemJingleListener;
import com.beem.project.beem.service.aidl.IJingle;
@@ -84,6 +85,7 @@
private JingleSessionRequest mRequest;
private Context mContext;
private boolean isCaller;
+ private RTPAudioSession mAudioSession;
/**
* JingleService constructor.
@@ -150,12 +152,18 @@
}
isCaller = false;
}
+
+ @Override
+ public void setSpeakerMode(int mode) throws RemoteException {
+ mAudioSession.setSpeakerMode(mode);
+ }
/**
* close a jingle call.
*/
@Override
public void closeCall() throws RemoteException {
+ mAudioSession = null;
if (isCaller) {
try {
mOut.terminate("Cancelled");
@@ -242,10 +250,8 @@
public void sessionEstablished(PayloadType pt, TransportCandidate remoteCandidate,
TransportCandidate localCandidate, JingleSession jingleSession) {
Log.d(TAG, "Session " + jingleSession.getResponder() + "established");
-
- jingleSession.getSession().getMediaSession(pt.getName());
+ mAudioSession = (RTPAudioSession) jingleSession.getSession().getMediaSession(MicrophoneRTPManager.MEDIA_NAME);
final int n = mRemoteJingleListeners.beginBroadcast();
-
for (int i = 0; i < n; i++) {
IBeemJingleListener listener = mRemoteJingleListeners.getBroadcastItem(i);
try {
--- a/src/com/beem/project/beem/jingle/RTPAudioSession.java Sun Jan 24 00:42:29 2010 +0100
+++ b/src/com/beem/project/beem/jingle/RTPAudioSession.java Sun Jan 24 04:52:19 2010 +0100
@@ -32,19 +32,24 @@
public RTPAudioSession(final PayloadType pt, final TransportCandidate remote,
final TransportCandidate local, final String mediaLocator, final JingleSession jingleSession, Context ctx) {
super(pt, remote, local, mediaLocator, jingleSession);
-
- prepareRtpSession(local.getPort(), remote.getIp(), remote.getPort());
Log.d("AUDIO", String.format("payload type : %s ipdest %s port dest %d port src %d",pt.getName(), remote.getIp(), remote.getPort(), local.getPort()));
- //mSender = new RtpStreamSender(CodecManager.getCodecByRtpName(pt.getName()), rtpSession);
-
- //mReceiver = new RtpStreamReceiver(CodecManager.getCodecByRtpName(pt.getName()), rtpSession, ctx);
+ SipdroidSocket rtpSocket = null;
+ try {
+ rtpSocket = new SipdroidSocket(local.getPort());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ mSender = new RtpStreamSender(true, 8, 8000, 160, rtpSocket, remote.getIp(), remote.getPort());
+ mReceiver = new RtpStreamReceiver(rtpSocket, 8);
}
@Override
public void initialize() {
- // TODO Auto-generated method stub
-
+ }
+
+ public void setSpeakerMode(final int mode) {
+ mReceiver.speaker(mode);
}
@Override
@@ -81,16 +86,4 @@
mSender = null;
}
}
-
- private void prepareRtpSession(int src_port, String dest_addr, int dest_port) {
- SipdroidSocket rtpSocket = null;
- SipdroidSocket rtcpSocket = null;
-
- try {
- rtpSocket = new SipdroidSocket(src_port);
- rtcpSocket = new SipdroidSocket(src_port + 1);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
}
--- a/src/com/beem/project/beem/service/aidl/IJingle.aidl Sun Jan 24 00:42:29 2010 +0100
+++ b/src/com/beem/project/beem/service/aidl/IJingle.aidl Sun Jan 24 04:52:19 2010 +0100
@@ -66,5 +66,10 @@
* close a jingle audio call
*/
void closeCall();
+
+ /**
+ * Set speaker mode
+ */
+ void setSpeakerMode(in int mode);
}
--- a/src/com/beem/project/beem/ui/Call.java Sun Jan 24 00:42:29 2010 +0100
+++ b/src/com/beem/project/beem/ui/Call.java Sun Jan 24 04:52:19 2010 +0100
@@ -48,6 +48,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.media.AudioManager;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
@@ -57,6 +58,7 @@
import android.os.Vibrator;
import android.view.Menu;
import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
@@ -93,6 +95,8 @@
private Button mAcceptCall;
private IJingle mJingle;
+ final static long[] vibratePattern = {0,1000,1000};
+
public static final int UA_STATE_IDLE = 0;
public static final int UA_STATE_INCOMING_CALL = 1;
public static final int UA_STATE_OUTGOING_CALL = 2;
@@ -115,6 +119,8 @@
}
public static void startRingtone() {
+ android.os.Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+ v.vibrate(vibratePattern,1);
oRingtone = RingtoneManager.getRingtone(mContext, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
oRingtone.play();
}
@@ -139,9 +145,12 @@
if (callingIntent.getBooleanExtra("isCaller", false)) {
mAcceptCall = (Button) findViewById(R.id.call_accept_button);
mAcceptCall.setVisibility(View.GONE);
+ call_state = UA_STATE_OUTGOING_CALL;
} else {
mAcceptCall = (Button) findViewById(R.id.call_accept_button);
mAcceptCall.setOnClickListener(new ClickListener());
+ call_state = UA_STATE_INCOMING_CALL;
+ Call.startRingtone();
}
mCallInfo = (TextView) findViewById(R.id.call_info);
}
@@ -182,6 +191,39 @@
}
/**
+ * Callback for menu item selected.
+ * @param item the item selected
+ * @return true on success, false otherwise
+ */
+ @Override
+ public final boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.call_speaker_on:
+ try {
+ mJingle.setSpeakerMode(AudioManager.MODE_NORMAL);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return true;
+ case R.id.call_speaker_off:
+ try {
+ mJingle.setSpeakerMode(AudioManager.MODE_IN_CALL);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return true;
+ case R.id.call_hold_on:
+ Call.call_state = UA_STATE_HOLD;
+ return true;
+ case R.id.call_hold_off:
+ Call.call_state = UA_STATE_INCALL;
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
* Click event listener on cancel button.
*/
private class ClickListener implements OnClickListener {
@@ -195,10 +237,15 @@
@Override
public void onClick(View v) {
try {
- if (v == mCloseCall)
+ if (v == mCloseCall) {
mJingle.closeCall();
- else if (v == mAcceptCall)
+ stopRingtone();
+ Call.call_state = UA_STATE_IDLE;
+ } else if (v == mAcceptCall) {
mJingle.acceptCall();
+ stopRingtone();
+ Call.call_state = UA_STATE_INCALL;
+ }
} catch (RemoteException e) {
e.printStackTrace();
}
@@ -227,7 +274,6 @@
@Override
public void run() {
mCallInfo.setText(mStr);
-
}
}
@@ -237,26 +283,33 @@
@Override
public void sessionClosed(final String reason) {
android.util.Log.d("TEST", "TEST " + reason);
+ Call.stopRingtone();
+ call_state = UA_STATE_IDLE;
mHandler.post(new RunnableChange(reason));
}
@Override
public void sessionDeclined(final String reason) {
android.util.Log.d("TEST", "TEST4 " + reason);
+ Call.stopRingtone();
+ call_state = UA_STATE_IDLE;
mHandler.post(new RunnableChange(reason));
}
@Override
public void sessionClosedOnError(final String error) {
android.util.Log.d("TEST", "TEST5 " + error);
+ Call.stopRingtone();
+ call_state = UA_STATE_IDLE;
mHandler.post(new RunnableChange(error));
}
@Override
public void sessionEstablished() {
android.util.Log.d("TEST", "TEST2 ");
- //mCallInfo.setText("established");
- mHandler.post(new RunnableChange("ok"));
+ call_state = UA_STATE_INCALL;
+ Call.stopRingtone();
+ mHandler.post(new RunnableChange("established"));
}
@Override
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/utils/Random.java Sun Jan 24 04:52:19 2010 +0100
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2005 Luca Veltri - University of Parma - Italy
+ *
+ * This file is part of MjSip (http://www.mjsip.org)
+ *
+ * MjSip is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MjSip is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MjSip; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author(s):
+ * Luca Veltri (luca.veltri@unipr.it)
+ */
+
+package com.beem.project.beem.utils;
+
+/**
+ * Class Random collects some static methods for generating random numbers and
+ * other stuff.
+ */
+public class Random {
+ /** The random seed */
+ static final long seed = System.currentTimeMillis();
+ // static final long seed=0;
+
+ static java.util.Random rand = new java.util.Random(seed);
+
+ // static java.util.Random rand=new java.util.Random();
+
+ /** Returns a random integer between 0 and n-1 */
+ /*
+ * static public int nextInt(int n) { seed=(seed*37)%987654321; return
+ * (int)(seed%n); }
+ */
+
+ /** Returns true or false respectively with probability p/100 and (1-p/100) */
+ /*
+ * static boolean percent(int p) { return integer(100)<p; }
+ */
+
+ /** Sets the seed of this random number generator using a single long seed */
+ public static void setSeed(long seed) {
+ rand.setSeed(seed);
+ }
+
+ /** Returns a random integer */
+ public static int nextInt() {
+ return rand.nextInt();
+ }
+
+ /** Returns a random integer between 0 and n-1 */
+ public static int nextInt(int n) {
+ return Math.abs(rand.nextInt()) % n;
+ }
+
+ /** Returns a random long */
+ public static long nextLong() {
+ return rand.nextLong();
+ }
+
+ /** Returns a random boolean */
+ public static boolean nextBoolean() {
+ return rand.nextInt(2) == 1;
+ }
+
+ /** Returns a random array of bytes */
+ public static byte[] nextBytes(int len) {
+ byte[] buff = new byte[len];
+ for (int i = 0; i < len; i++)
+ buff[i] = (byte) nextInt(256);
+ return buff;
+ }
+
+ /** Returns a random String */
+ public static String nextString(int len) {
+ byte[] buff = new byte[len];
+ for (int i = 0; i < len; i++) {
+ int n = nextInt(62);
+ buff[i] = (byte) ((n < 10) ? 48 + n : ((n < 36) ? 55 + n : 61 + n));
+ }
+ return new String(buff);
+ }
+
+ /** Returns a random numeric String */
+ public static String nextNumString(int len) {
+ byte[] buff = new byte[len];
+ for (int i = 0; i < len; i++)
+ buff[i] = (byte) (48 + nextInt(10));
+ return new String(buff);
+ }
+
+ /** Returns a random hexadecimal String */
+ public static String nextHexString(int len) {
+ byte[] buff = new byte[len];
+ for (int i = 0; i < len; i++) {
+ int n = nextInt(16);
+ buff[i] = (byte) ((n < 10) ? 48 + n : 87 + n);
+ }
+ return new String(buff);
+ }
+}
--- a/src/org/sipdroid/media/RtpStreamSender.java Sun Jan 24 00:42:29 2010 +0100
+++ b/src/org/sipdroid/media/RtpStreamSender.java Sun Jan 24 04:52:19 2010 +0100
@@ -351,13 +351,13 @@
e.printStackTrace();
}
time += frame_size;
- if (useGSM && p_type == 8 && !BeemConnectivity.isWifi(Call.mContext) && tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE) {
+ /*if (useGSM && p_type == 8 && !BeemConnectivity.isWifi(Call.mContext) && tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE) {
rtp_packet.setPayloadType(p_type = 3);
if (frame_size == 1024) {
frame_size = 960;
ring = 0;
}
- }
+ }*/
}
record.stop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/sipdroid/pjlib/Codec.java Sun Jan 24 04:52:19 2010 +0100
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2009 The Sipdroid Open Source Project
+ *
+ * This file is part of Sipdroid (http://www.sipdroid.org)
+ *
+ * Sipdroid is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this source code; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package org.sipdroid.pjlib;
+
+import java.lang.String;
+
+public class Codec {
+ public static native int open(String codec_id);
+ public static native int decode(byte alaw[], short lin[], int frames);
+ public static native int encode(short lin[], int offset, byte alaw[], int frames);
+ public static native int close();
+
+ public static void init() {
+ }
+
+ public static boolean loaded;
+
+ static {
+ try {
+ System.loadLibrary("pjlib_linker_jni");
+ open("gsm");
+ loaded = true;
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}