private PanasonicCameraFocusControl focusControl = null;
private PanasonicCameraCaptureControl captureControl = null;
private PanasonicCameraZoomLensControl zoomControl = null;
+ private PanasonicCameraConnection cameraConnection = null;
public PanasonicCameraWrapper(final Activity context, final ICameraStatusReceiver statusReceiver , final @NonNull ICameraChangeListener listener)
{
try
{
//this.panasonicCameraApi = PanasonicCameraApi.newInstance(panasonicCamera);
- eventObserver = CameraEventObserver.newInstance(context, panasonicCamera);
- liveViewControl = new PanasonicLiveViewControl(panasonicCamera);
-
+ if (eventObserver == null)
+ {
+ eventObserver = CameraEventObserver.newInstance(context, panasonicCamera);
+ }
+ if (liveViewControl == null)
+ {
+ liveViewControl = new PanasonicLiveViewControl(panasonicCamera);
+ }
focusControl.setCamera(panasonicCamera);
captureControl.setCamera(panasonicCamera);
zoomControl.setCamera(panasonicCamera);
eventObserver.activate();
eventObserver.start();
ICameraStatusHolder holder = eventObserver.getCameraStatusHolder();
- holder.getLiveviewStatus();
+ if (holder != null)
+ {
+ holder.getLiveviewStatus();
+ }
}
}
- catch (Exception e) {
+ catch (Exception e)
+ {
e.printStackTrace();
}
}
@Override
public ICameraConnection getPanasonicCameraConnection()
{
- return (new PanasonicCameraConnection(context, provider, this, listener));
+ // PanasonicCameraConnectionは複数生成しない。
+ if (cameraConnection == null)
+ {
+ cameraConnection = new PanasonicCameraConnection(context, provider, this, listener);
+ }
+ return (cameraConnection);
}
@Override
String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + LIVEVIEW_STOP_REQUEST, TIMEOUT_MS);
if (!reply.contains("<result>ok</result>"))
{
- Log.v(TAG, "stopLiveview() reply is fail... ");
+ Log.v(TAG, "stopLiveview() reply is fail... " + reply);
}
else
{
- // ライブビューウォッチャーを止める
- whileStreamReceive = false;
Log.v(TAG, "stopLiveview() is issued.");
}
+ // ライブビューウォッチャーを止める
+ whileStreamReceive = false;
+ closeReceiveSocket();
}
catch (Exception e)
{
}
}
}
+ closeReceiveSocket();
+ Log.v(TAG, " ----- startReceiveStream() : Finished.");
+ System.gc();
+ }
+
+ public ILiveViewListener getLiveViewListener()
+ {
+ return (liveViewListener);
+ }
+
+ private void closeReceiveSocket()
+ {
+ Log.v(TAG, "closeReceiveSocket()");
try
{
if (receiveSocket != null)
{
+ Log.v(TAG, " ----- SOCKET CLOSE ----- ");
receiveSocket.close();
receiveSocket = null;
}
{
e.printStackTrace();
}
- Log.v(TAG, " ----- startReceiveStream() : Finished.");
- System.gc();
- }
-
- public ILiveViewListener getLiveViewListener()
- {
- return (liveViewListener);
}
}