Added menu to videocall activity:

- high/low resolution
- enable/disable camera
- return to dialer
- terminate call
Added bandwidth manager to manage video profiles and update current and subsequent calls.
Added VideoSize semantics and jni wrappings on linphoneCore.
This commit is contained in:
Guillaume Beraudo 2010-11-26 15:04:38 +01:00
parent dc20fb7739
commit 3c26f241c1
4 changed files with 79 additions and 18 deletions

View file

@ -18,10 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
import java.util.ArrayList;
import java.util.List;
import android.hardware.Camera;
import android.hardware.Camera.ErrorCallback;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.os.Build;
import android.util.Log;
import android.view.SurfaceHolder;
@ -44,8 +48,9 @@ public abstract class AndroidCameraRecord {
private static boolean previewStarted;
private static boolean parametersSet;
protected static int orientationCode;
private static boolean mute;
private static boolean muted;
private static final String tag="Linphone";
private static List <Size> supportedVideoSizes;
public AndroidCameraRecord() {
// TODO check if another instance is loaded and kill it.
@ -66,7 +71,7 @@ public abstract class AndroidCameraRecord {
* It will start automatically
*/
private void startPreview() {
if (mute) {
if (muted) {
Log.d(tag, "Not starting preview as camera has been muted");
return;
}
@ -100,6 +105,9 @@ public abstract class AndroidCameraRecord {
Camera.Parameters parameters=camera.getParameters();
if (supportedVideoSizes == null) {
supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes();
}
parameters.setPreviewSize(width, height);
parameters.setPreviewFrameRate(fps);
@ -174,6 +182,13 @@ public abstract class AndroidCameraRecord {
}
private static void stopPreview() {
camera.setPreviewCallback(null); // TODO check if used whatever the SDK version
camera.stopPreview();
camera.release();
camera=null;
previewStarted = false;
}
public static final void setSurfaceView(final SurfaceView sv) {
SurfaceHolder holder = sv.getHolder();
@ -187,11 +202,7 @@ public abstract class AndroidCameraRecord {
Log.e(tag, "Video capture: illegal state: surface destroyed but camera is already null");
return;
}
camera.setPreviewCallback(null); // TODO check if used whatever the SDK version
camera.stopPreview();
camera.release();
camera=null;
previewStarted = false;
stopPreview();
Log.w(tag, "Video capture Surface destroyed");
}
@ -235,19 +246,45 @@ public abstract class AndroidCameraRecord {
}
public static void setMuteCamera(boolean m) {
if (m == mute) return;
if (m == muted) return;
mute = m;
if (mute && previewStarted) {
camera.stopPreview();
muted = m;
if (muted && previewStarted) {
stopPreview();
return;
}
if (!mute) {
if (!muted) {
instance.startPreview();
}
}
public static void toggleMute() {
setMuteCamera(!muted);
}
public static List<Size> supportedVideoSizes() {
if (supportedVideoSizes != null) {
return new ArrayList<Size>(supportedVideoSizes);
}
if (camera == null) {
camera = Camera.open();
supportedVideoSizes = camera.getParameters().getSupportedPreviewSizes();
camera.release();
return supportedVideoSizes;
}
throw new RuntimeException("Should not be there");
}
public static boolean getCameraMuted() {
return muted;
}
public static void invalidateParameters() {
parametersSet = false;
stopPreview();
}
}

View file

@ -66,6 +66,4 @@ class LinphoneCallImpl implements LinphoneCall {
public LinphoneCallParams getCurrentParamsReadWrite() {
return getCurrentParamsReadOnly().copy();
}
}

View file

@ -34,7 +34,7 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams {
return getVideoEnabled(nativePtr);
}
public void setVideoEnalbled(boolean b) {
public void setVideoEnabled(boolean b) {
enableVideo(nativePtr, b);
}

View file

@ -81,7 +81,10 @@ class LinphoneCoreImpl implements LinphoneCore {
private native String getStunServer(long nativePtr);
private native long createDefaultCallParams(long nativePtr);
private native int updateCall(long ptrLc, long ptrCall, long ptrParams);
private native void setUploadBandwidth(long nativePtr, int bw);
private native void setDownloadBandwidth(long nativePtr, int bw);
private native void setPreferredVideoSize(long nativePtr, int width, int heigth);
private native int[] getPreferredVideoSize(long nativePtr);
private static String TAG = "LinphoneCore";
@ -379,4 +382,27 @@ class LinphoneCoreImpl implements LinphoneCore {
return updateCall(nativePtr, ptrCall, ptrParams);
}
public void setUploadBandwidth(int bw) {
setUploadBandwidth(nativePtr, bw);
}
public void setDownloadBandwidth(int bw) {
setDownloadBandwidth(nativePtr, bw);
}
public void setPreferredVideoSize(VideoSize vSize) {
setPreferredVideoSize(nativePtr, vSize.getWidth(), vSize.getHeight());
}
public VideoSize getPreferredVideoSize() {
int[] nativeSize = getPreferredVideoSize(nativePtr);
VideoSize vSize = new VideoSize();
vSize.setWidth(nativeSize[0]);
vSize.setHeight(nativeSize[1]);
return vSize;
}
}