Convert Logs to new system. No more "tags" remaining.

This commit is contained in:
Guillaume Beraudo 2011-06-20 14:44:50 +02:00
parent 64ae9ce334
commit f5b18a6909
13 changed files with 74 additions and 82 deletions

View file

@ -3,7 +3,6 @@ package org.linphone.core;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Bitmap.Config;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@ -15,7 +14,6 @@ public class AndroidVideoWindowImpl {
private SurfaceView mView;
private Surface mSurface;
private VideoWindowListener mListener;
static private String TAG = "Linphone";
public static interface VideoWindowListener{
void onSurfaceReady(AndroidVideoWindowImpl vw);
void onSurfaceDestroyed(AndroidVideoWindowImpl vw);
@ -28,17 +26,17 @@ public class AndroidVideoWindowImpl {
view.getHolder().addCallback(new Callback(){
public void surfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
Log.i(TAG,"Surface is being changed.");
Log.i("Surface is being changed.");
synchronized(AndroidVideoWindowImpl.this){
mBitmap=Bitmap.createBitmap(width,height,Config.RGB_565);
mSurface=holder.getSurface();
}
if (mListener!=null) mListener.onSurfaceReady(AndroidVideoWindowImpl.this);
Log.w(TAG, "Video display surface changed");
Log.w("Video display surface changed");
}
public void surfaceCreated(SurfaceHolder holder) {
Log.w(TAG, "Video display surface created");
Log.w("Video display surface created");
}
public void surfaceDestroyed(SurfaceHolder holder) {
@ -48,7 +46,7 @@ public class AndroidVideoWindowImpl {
}
if (mListener!=null)
mListener.onSurfaceDestroyed(AndroidVideoWindowImpl.this);
Log.d(TAG, "Video display surface destroyed");
Log.d("Video display surface destroyed");
}
});
}
@ -56,7 +54,7 @@ public class AndroidVideoWindowImpl {
static final int PORTRAIT=1;
public void requestOrientation(int orientation){
//Surface.setOrientation(0, orientation==LANDSCAPE ? 1 : 0);
//Log.d("Linphone", "Orientation changed.");
//Log.d("Orientation changed.");
}
public void setListener(VideoWindowListener l){
mListener=l;

View file

@ -21,7 +21,6 @@ package org.linphone.core;
import android.hardware.Camera;
import android.media.AudioManager;
import android.os.Build;
import android.util.Log;
public final class Hacks {
@ -65,7 +64,7 @@ public final class Hacks {
/* private static final boolean log(final String msg) {
Log.d("Linphone", msg);
Log.d(msg);
return true;
}*/
@ -104,7 +103,7 @@ public final class Hacks {
//sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n");
sb.append("SDK=").append(Build.VERSION.SDK);
Log.i(Version.TAG, sb.toString());
Log.i(sb.toString());
}
public static boolean needSoftvolume() {
@ -134,12 +133,12 @@ public final class Hacks {
try {
nb = (Integer) Camera.class.getMethod("getNumberOfCameras", (Class[])null).invoke(null);
} catch (Exception e) {
Log.e(Version.TAG, "Error getting number of cameras");
Log.e("Error getting number of cameras");
}
return nb > 0;
}
Log.i(Version.TAG, "Hack: considering there IS a camera.\n"
Log.i("Hack: considering there IS a camera.\n"
+ "If it is not the case, report DEVICE and MODEL to linphone-users@nongnu.org");
return true;
}

View file

@ -21,15 +21,13 @@ package org.linphone.core;
import java.io.File;
import java.io.IOException;
import android.util.Log;
public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
private static void loadOptionalLibrary(String s) {
try {
System.loadLibrary(s);
} catch (Throwable e) {
Log.w(Version.TAG, "Unable to load optional library lib" + s);
Log.w("Unable to load optional library lib", s);
}
}

View file

@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone.core;
/**
* Convenient wrapper for Android logs.
*

View file

@ -26,8 +26,6 @@ import android.os.Build;
*/
public class Version {
public static final String TAG="Linphone";
public static final int API03_CUPCAKE_15 = 3;
public static final int API04_DONUT_16 = 4;
public static final int API06_ECLAIR_20 = 6;

View file

@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core.tutorials;
import org.linphone.core.Log;
import org.linphone.core.video.AndroidCameraRecord;
import android.hardware.Camera;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.util.Log;
import android.widget.TextView;
/**
@ -59,8 +59,8 @@ class JavaCameraRecordImpl extends AndroidCameraRecord implements PreviewCallbac
Size s = camera.getParameters().getPreviewSize();
int expectedBuffLength = s.width * s.height * 3 /2;
if (expectedBuffLength != data.length) {
Log.e(tag, "onPreviewFrame called with bad buffer length " + data.length
+ " whereas expected is " + expectedBuffLength + " don't calling putImage");
Log.e("onPreviewFrame called with bad buffer length ", data.length,
" whereas expected is ", expectedBuffLength, " don't calling putImage");
return;
}

View file

@ -18,15 +18,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core.tutorials;
import static org.linphone.core.VideoSize.CIF;
import static org.linphone.core.VideoSize.HVGA;
import static org.linphone.core.VideoSize.QCIF;
import static org.linphone.core.VideoSize.QVGA;
import java.util.Stack;
import org.linphone.R;
import org.linphone.core.Log;
import org.linphone.core.VideoSize;
import org.linphone.core.video.AndroidCameraRecord;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
@ -35,7 +40,6 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.TextView;
import static org.linphone.core.VideoSize.*;
/**
* Activity for displaying and starting the HelloWorld example on Android phone.
@ -48,7 +52,6 @@ public class TestVideoActivity extends Activity implements Callback, OnClickList
private SurfaceView surfaceView;
private static final int rate = 7;
private JavaCameraRecordImpl recorder;
private static String tag = "Linphone";
private TextView debugView;
private Button nextSize;
private Button changeCamera;
@ -171,12 +174,12 @@ public class TestVideoActivity extends Activity implements Callback, OnClickList
public void surfaceDestroyed(SurfaceHolder holder) {
surfaceView = null;
Log.d(tag , "Video capture surface destroyed");
Log.d("Video capture surface destroyed");
if (recorder != null) recorder.stopPreview();
}
public void surfaceCreated(SurfaceHolder holder) {
Log.d(tag , "Video capture surface created");
Log.d("Video capture surface created");
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

View file

@ -19,42 +19,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone.core.video;
import org.linphone.core.Hacks;
import org.linphone.core.Log;
import android.util.Log;
class AndroidCameraConf5 implements AndroidCameraConf {
private static final String tag = "Linphone";
private AndroidCameras foundCameras;
public AndroidCameras getFoundCameras() {return foundCameras;}
public AndroidCameraConf5() {
Log.i(tag, "Detecting cameras");
Log.i("Detecting cameras");
// Defaults
foundCameras = new AndroidCameras();
if (Hacks.isGalaxySOrTab()) {
Log.d(tag, "Hack Galaxy S : has one or more cameras");
Log.d("Hack Galaxy S : has one or more cameras");
if (Hacks.isGalaxySOrTabWithFrontCamera()) {
Log.d(tag, "Hack Galaxy S : HAS a front camera with id=2");
Log.d("Hack Galaxy S : HAS a front camera with id=2");
foundCameras.front = 2;
} else {
Log.d(tag, "Hack Galaxy S : NO front camera");
Log.d("Hack Galaxy S : NO front camera");
}
Log.d(tag, "Hack Galaxy S : HAS a rear camera with id=1");
Log.d("Hack Galaxy S : HAS a rear camera with id=1");
foundCameras.rear = 1;
foundCameras.defaultC = foundCameras.rear;
} else if (Hacks.hasTwoCamerasRear0Front1()) {
Log.d(tag, "Hack SPHD700 has 2 cameras a rear with id=0 and a front with id=1");
Log.d("Hack SPHD700 has 2 cameras a rear with id=0 and a front with id=1");
foundCameras.front = 1;
}
}
public int getNumberOfCameras() {
Log.i(tag, "Detecting the number of cameras");
Log.i("Detecting the number of cameras");
if (Hacks.hasTwoCamerasRear0Front1() || Hacks.isGalaxySOrTabWithFrontCamera()) {
Log.d(tag, "Hack: we know this model has 2 cameras");
Log.d("Hack: we know this model has 2 cameras");
return 2;
} else
return 1;
@ -65,7 +64,7 @@ class AndroidCameraConf5 implements AndroidCameraConf {
public int getCameraOrientation(int cameraId) {
// Use hacks to guess orientation of the camera
if (Hacks.isGalaxySOrTab() && isFrontCamera(cameraId)) {
Log.d(tag, "Hack Galaxy S : front camera mounted landscape");
Log.d("Hack Galaxy S : front camera mounted landscape");
// mounted in landscape for a portrait phone orientation
// |^^^^^^^^|
// | ____ |
@ -84,10 +83,10 @@ class AndroidCameraConf5 implements AndroidCameraConf {
public boolean isFrontCamera(int cameraId) {
// Use hacks to guess facing of the camera
if (cameraId == 2 && Hacks.isGalaxySOrTab()) {
Log.d(tag, "Hack Galaxy S : front camera has id=2");
Log.d("Hack Galaxy S : front camera has id=2");
return true;
} else if (cameraId == 1 && Hacks.hasTwoCamerasRear0Front1()) {
Log.d(tag, "Hack SPHD700 : front camera has id=1");
Log.d("Hack SPHD700 : front camera has id=1");
return true;
}

View file

@ -18,10 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core.video;
import org.linphone.core.Version;
import org.linphone.core.Log;
import android.hardware.Camera;
import android.util.Log;
class AndroidCameraConf9 implements AndroidCameraConf {
private AndroidCameras foundCameras;
@ -49,9 +48,7 @@ class AndroidCameraConf9 implements AndroidCameraConf {
public int getCameraOrientation(int cameraId) {
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
Log.d(Version.TAG, String.format("Camera info for %d: orientation=%d",
cameraId,
info.orientation));
Log.d("Camera info for ",cameraId,": orientation=",info.orientation);
return info.orientation;
}

View file

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.linphone.core.Log;
import org.linphone.core.Version;
import android.hardware.Camera;
@ -30,7 +31,6 @@ import android.hardware.Camera.ErrorCallback;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
@ -44,7 +44,6 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback {
private PreviewCallback storedPreviewCallback;
private boolean previewStarted;
protected static final String tag="Linphone";
private List <Size> supportedVideoSizes;
private Size currentPreviewSize;
@ -58,27 +57,27 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback {
public synchronized void startPreview() { // FIXME throws exception?
if (previewStarted) {
Log.w(tag, "Already started");
Log.w("Already started");
throw new RuntimeException("Video recorder already started");
// return
}
if (params.surfaceView.getVisibility() != SurfaceView.VISIBLE) {
// Illegal state
Log.e(tag, "Illegal state: video capture surface view is not visible");
Log.e("Illegal state: video capture surface view is not visible");
return;
}
Log.d(tag, "Trying to open camera with id " + params.cameraId);
Log.d("Trying to open camera with id ", params.cameraId);
if (camera != null) {
Log.e(tag, "Camera is not null, ?already open? : aborting");
Log.e("Camera is not null, ?already open? : aborting");
return;
}
camera = openCamera(params.cameraId);
camera.setErrorCallback(new ErrorCallback() {
public void onError(int error, Camera camera) {
Log.e(tag, "Camera error : " + error);
Log.e("Camera error : ", error);
}
});
@ -113,14 +112,14 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback {
camera.setPreviewDisplay(holder);
}
catch (Throwable t) {
Log.e(tag, "Exception in Video capture setPreviewDisplay()", t);
Log.e(t,"Exception in Video capture setPreviewDisplay()");
}
try {
camera.startPreview();
} catch (Throwable e) {
Log.e(tag, "Error, can't start camera preview. Releasing camera!");
Log.e("Error, can't start camera preview. Releasing camera!");
camera.release();
camera = null;
return;
@ -132,7 +131,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback {
if (Camera.Parameters.FOCUS_MODE_AUTO.equals(parameters.getFocusMode())) {
OnClickListener svClickListener = new OnClickListener() {
public void onClick(View v) {
Log.i(tag, "Auto focus requested");
Log.i("Auto focus requested");
camera.autoFocus(AndroidCameraRecord.this);
}
};
@ -167,7 +166,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback {
public void storePreviewCallBack(PreviewCallback cb) {
this.storedPreviewCallback = cb;
if (camera == null) {
Log.w(tag, "Capture camera not ready, storing preview callback");
Log.w("Capture camera not ready, storing preview callback");
return;
}
@ -181,7 +180,7 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback {
camera.stopPreview();
camera.release();
camera=null;
Log.d(tag, "Camera released");
Log.d("Camera released");
currentPreviewSize = null;
previewStarted = false;
}
@ -236,8 +235,8 @@ public abstract class AndroidCameraRecord implements AutoFocusCallback {
}
public void onAutoFocus(boolean success, Camera camera) {
if (success) Log.i(tag, "Autofocus success");
else Log.i(tag, "Autofocus failure");
if (success) Log.i("Autofocus success");
else Log.i("Autofocus failure");
}
public int getStoredPhoneOrientation() {

View file

@ -21,13 +21,13 @@ package org.linphone.core.video;
import java.util.Arrays;
import java.util.List;
import org.linphone.core.Log;
import org.linphone.core.video.AndroidCameraRecord.RecorderParams.MirrorType;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.util.Log;
/**
* Record from Android camera.
@ -63,18 +63,18 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac
public void onPreviewFrame(byte[] data, Camera camera) {
if (data == null) {
Log.e(tag, "onPreviewFrame Called with null buffer");
Log.e("onPreviewFrame Called with null buffer");
return;
}
if (filterCtxPtr == 0l) {
Log.e(tag, "onPreviewFrame Called with no filterCtxPtr set");
Log.e("onPreviewFrame Called with no filterCtxPtr set");
return;
}
int expectedBuffLength = getExpectedBufferLength();
if (expectedBuffLength != data.length) {
Log.e(tag, "onPreviewFrame called with bad buffer length " + data.length
+ " whereas expected is " + expectedBuffLength + " don't calling putImage");
Log.e("onPreviewFrame called with bad buffer length ", data.length,
" whereas expected is ", expectedBuffLength, " don't calling putImage");
return;
}
@ -87,7 +87,7 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac
double currentTimeElapsed = 0.8 * (curTime - lastFrameTime) / 1000 + 0.2 * timeElapsedBetweenFrames;
if (currentTimeElapsed < expectedTimeBetweenFrames) {
// Log.d(tag, "Clipping frame " + Math.round(1 / currentTimeElapsed) + " > " + fps);
// Log.d("Clipping frame ", Math.round(1 / currentTimeElapsed), " > ", fps);
return;
}
lastFrameTime = curTime;
@ -118,10 +118,10 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac
List<String> supportedFocusModes = parameters.getSupportedFocusModes();
String focusMode = selectFocusMode(supportedFocusModes);
if (focusMode != null) {
Log.w(tag, "Selected focus mode: " + focusMode);
Log.w("Selected focus mode: ", focusMode);
parameters.setFocusMode(focusMode);
} else {
Log.i(tag, "No suitable focus mode found in : " + Arrays.toString(supportedFocusModes.toArray()));
Log.i("No suitable focus mode found in : ", Arrays.toString(supportedFocusModes.toArray()));
}
}

View file

@ -20,11 +20,12 @@ package org.linphone.core.video;
import java.util.List;
import org.linphone.core.Log;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.util.Log;
/**
*
@ -42,7 +43,7 @@ class AndroidCameraRecord8 extends AndroidCameraRecord5 {
@Override
protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) {
if (cb != null) {
Log.d(tag, "Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!");
Log.d("Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!");
}
camera.setPreviewCallbackWithBuffer(cb);
}

View file

@ -21,12 +21,12 @@ package org.linphone.core.video;
import java.util.List;
import org.linphone.LinphoneManager;
import org.linphone.core.Log;
import org.linphone.core.Version;
import org.linphone.core.video.AndroidCameraRecord.RecorderParams;
import android.content.Context;
import android.hardware.Camera.Size;
import android.util.Log;
import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@ -41,7 +41,6 @@ import android.view.SurfaceHolder.Callback;
*
*/
public class AndroidCameraRecordManager {
private static final String tag = "Linphone";
private static AndroidCameraRecordManager instance;
private OrientationEventListener orientationEventListener;
private OnCapturingStateChangedListener capturingStateChangedListener;
@ -70,7 +69,7 @@ public class AndroidCameraRecordManager {
// singleton
private AndroidCameraRecordManager() {
cc = Version.sdkAboveOrEqual(9) ? new AndroidCameraConf9() : new AndroidCameraConf5();
Log.i(tag, "=== Detected " + cc.getFoundCameras()+ " ===");
Log.i("=== Detected " + cc.getFoundCameras()+ " ===");
cameraId = cc.getFoundCameras().defaultC;
}
@ -87,7 +86,7 @@ public class AndroidCameraRecordManager {
public void setUseFrontCamera(boolean value) {
if (!hasFrontCamera()) {
Log.e(tag, "setUseFrontCamera(true) while no front camera detected on device: using rear");
Log.e("setUseFrontCamera(true) while no front camera detected on device: using rear");
value = false;
}
if (cc.isFrontCamera(cameraId) == value) return; // already OK
@ -116,7 +115,7 @@ public class AndroidCameraRecordManager {
public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) {
if (recorder != null) {
Log.w(tag, "Recorder should not be running");
Log.w("Recorder should not be running");
stopVideoRecording();
}
RecorderParams p = new RecorderParams(filterDataPtr);
@ -148,19 +147,19 @@ public class AndroidCameraRecordManager {
holder.addCallback(new Callback() {
public void surfaceDestroyed(SurfaceHolder holder) {
surfaceView = null;
Log.d(tag , "Video capture surface destroyed");
Log.d("Video capture surface destroyed");
stopVideoRecording();
}
public void surfaceCreated(SurfaceHolder holder) {
surfaceView = sv;
Log.d(tag , "Video capture surface created");
Log.d("Video capture surface created");
tryToStartVideoRecording();
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
Log.d(tag , "Video capture surface changed");
Log.d("Video capture surface changed");
}
});
}
@ -200,7 +199,7 @@ public class AndroidCameraRecordManager {
if (muted || surfaceView == null || parameters == null) return;
if (recorder != null) {
Log.e(tag, "Recorder already present");
Log.e("Recorder already present");
stopVideoRecording();
}
@ -271,7 +270,7 @@ public class AndroidCameraRecordManager {
final int rotation = bufferRotationToCompensateCameraAndPhoneOrientations();
final boolean isPortrait = (rotation % 180) == 90;
Log.d(tag, "Camera sensor in " + (isPortrait? "portrait":"landscape") + " orientation.");
Log.d("Camera sensor in ", isPortrait? "portrait":"landscape"," orientation.");
return isPortrait;
}
@ -296,10 +295,10 @@ public class AndroidCameraRecordManager {
final int phoneOrientation = mAlwaysChangingPhoneOrientation;
final int cameraOrientation = cc.getCameraOrientation(cameraId);
final int rotation = (cameraOrientation + phoneOrientation) % 360;
Log.d(tag, String.format(
"Capture video buffer of cameraId=%d will need a rotation of "
+ "%d degrees: camera_orientation=%d, phone_orientation=%d",
cameraId, rotation, cameraOrientation, phoneOrientation));
Log.d("Capture video buffer of cameraId=",cameraId,
" will need a rotation of ",rotation,
" degrees: camera_orientation=",cameraOrientation,
" phone_orientation=", phoneOrientation);
return rotation;
}
@ -329,7 +328,7 @@ public class AndroidCameraRecordManager {
if (mAlwaysChangingPhoneOrientation == degrees) return;
Log.i(tag, "Phone orientation changed to " + degrees);
Log.i("Phone orientation changed to ", degrees);
mAlwaysChangingPhoneOrientation = degrees;
}
}