/** 从记录仪上获取突发视频的数据 */ private void getEventDataFromCamera() { Logger.i(TAG, "getEventDataFromCamera()"); CameraMessage getLSMessage = new CameraMessage( CommandID.AMBA_LS_NEW, new CameraMessageCallback() { @Override public void onReceiveErrorMessage( CameraMessage cameraMessage, JSONObject jsonObject) { Logger.e(TAG, "onReceiveErrorMessage" + jsonObject.toString()); } @Override public void onReceiveMessage(CameraMessage cameraMessage, JSONObject jsonObject) { Logger.e(TAG, "onReceiveMessage:" + jsonObject.toString()); // mEventListingInfo = GsonUtils.fromJson(jsonObject.toString(), // ListingInfo.class); // Logger.i(TAG, "EventListingInfo:" + mEventListingInfo.toString()); // 只初始化Event页的数据 } @Override public void onReceiveNotification(JSONObject jsonObject) {} }); getLSMessage.put("type", "event"); remoteCamHelper.sendCommand(getLSMessage); }
/** 发命令让记录仪切换为sta状态 */ private void apStatrt() { final String password = "******"; CameraMessage cameraMessage = new CameraMessage( 1543, new CameraMessageCallback() { @Override public void onReceiveErrorMessage( CameraMessage cameraMessage, JSONObject jsonObject) {} @Override public void onReceiveMessage(CameraMessage cameraMessage, JSONObject jsonObject) { // wifiAp.startWifiAp(ssid, password); Constant.token = 0; RemoteCamHelper.getRemoteCam().closeChannel(); } @Override public void onReceiveNotification(JSONObject jsonObject) {} }); cameraMessage.put("type", "sta"); cameraMessage.put("ssid", ssid); cameraMessage.put("password", password); cameraMessage.put("times", 30); remoteCamHelper.sendCommand(cameraMessage); Logger.e("Send 'sta' command to recorder!"); // CheckUDPService.chekUdpTimeOut(); }
@AfterViews void init() { mPlayer = MedIaPlayerManager.createPlayer(); admin = new WifiAdminV2(mActivity.getApplicationContext()); com.leautolink.leautocamera.config.Constant.isLive = true; mPlayer.initPlayer(mActivity, video_layout, MedIaPlayerManager.PLAY_TYPE_LIVE); remoteCamHelper = RemoteCamHelper.getRemoteCam(); mPlayer.setPlayerListener(this); ll_connect_to_camera.setVisibility(View.GONE); if (RemoteCamHelper.isStartSessionSuccess) { DeviceInfo.getInstance() .setContext(new WeakReference<Context>(CameraFragment.this.getActivity())); DeviceInfo.getInstance().getDeviceInfo(); } }
/** 从记录仪上获取手动记录的数据 */ private void getPhotoDataFromCamera() { Logger.i(TAG, "getPhotoDataFromCamera()"); CameraMessage getLSMessage = new CameraMessage( CommandID.AMBA_LS_NEW, new CameraMessageCallback() { @Override public void onReceiveErrorMessage( CameraMessage cameraMessage, JSONObject jsonObject) { Logger.e(TAG, "onReceiveErrorMessage" + jsonObject.toString()); } @Override public void onReceiveMessage(CameraMessage cameraMessage, JSONObject jsonObject) { Logger.e(TAG, "onReceiveMessage:" + jsonObject.toString()); mPhotoListingInfo = GsonUtils.fromJson(jsonObject.toString(), ListingInfo.class); // shimeng add for protect null point,20160416,begin if (null != mPhotoListingInfo) { List<ListingInfo.FileInfo> fileInfos = mPhotoListingInfo.getListing(); int count = Math.min(3, fileInfos.size()); homePhotoInfos.clear(); for (int i = fileInfos.size(); i > fileInfos.size() - 3 && i > 0; i--) { String thumbName = fileInfos.get(i - 1).getFilename().replace("A", "T"); HomePhotoInfo homePI = new HomePhotoInfo(thumbName, HomePhotoInfo.NORMAL_PIC); homePhotoInfos.add(homePI); } showPhoto(); Logger.i(TAG, "PhotoListingInfo:" + mPhotoListingInfo.toString()); } // shimeng add for protect null point,20160416,end } @Override public void onReceiveNotification(JSONObject jsonObject) {} }); getLSMessage.put("type", "photo"); RemoteCamHelper.getRemoteCam().sendCommand(getLSMessage); }
private void timeOutCancel(String filePath) { remoteCamHelper.cancelGetFile( filePath, new CameraMessageCallback() { @Override public void onReceiveErrorMessage(CameraMessage cameraMessage, JSONObject jsonObject) { if (jsonObject.optString("rval").equals("-13")) { hideLoading(); canTakePhotoIconInMainThread(); } } @Override public void onReceiveMessage(CameraMessage cameraMessage, JSONObject jsonObject) { hideLoading(); canTakePhotoIconInMainThread(); } @Override public void onReceiveNotification(JSONObject jsonObject) {} }); }
/** 获取到当前的状态 */ private void getCameraStatus() { CameraMessage getCameraStatus = new CameraMessage( CommandID.AMBA_GET_SETTING, new CameraMessageCallback() { @Override public void onReceiveErrorMessage( CameraMessage cameraMessage, JSONObject jsonObject) {} @Override public void onReceiveMessage(CameraMessage cameraMessage, JSONObject jsonObject) { cameraStatus = jsonObject.optString("param"); if (mPlayer.isPlaying()) { initRecordedIcon(); } } @Override public void onReceiveNotification(JSONObject jsonObject) {} }); getCameraStatus.put("type", "app_status"); remoteCamHelper.sendCommand(getCameraStatus); }
@Click(R.id.bt_take_photo) void takePhoto() { if (LeautoCameraAppLication.isApConnectCamera) { if (Constant.isSDCardPresent) { bt_take_photo.setEnabled(false); showLoadingIgnoreKeyBack(getResources().getString(R.string.passing)); handler_.postDelayed(runnable, 30000); CameraMessage takePhoto = new CameraMessage( CommandID.AMBA_TAKE_PHOTO, new CameraMessageCallback() { @Override public void onReceiveErrorMessage( CameraMessage cameraMessage, JSONObject jsonObject) { hideLoading(); canTakePhotoIconInMainThread(); showToastSafe(getResources().getString(R.string.take_photo_error)); } @Override public void onReceiveMessage(CameraMessage cameraMessage, JSONObject jsonObject) { String path = jsonObject.optString("param"); filePath = "/tmp/SD0" + path.split(":")[1].replace("\\", "/"); int index = filePath.lastIndexOf("/"); photoName = filePath.substring(index); String thumbPhoto = photoName.replace("A", "T").substring(1); HomePhotoInfo homePhotoInfo = new HomePhotoInfo(thumbPhoto, HomePhotoInfo.NORMAL_PIC); homePhotoInfos.add(0, homePhotoInfo); canTakePhotoIconInMainThread(); hideLoading(); showPhoto(); handler_.removeCallbacks(runnable); // CameraMessage setInfo = new // CameraMessage(CommandID.AMBA_SET_CLINT_INFO, new CameraMessageCallback() { // @Override // public void onReceiveErrorMessage(CameraMessage // cameraMessage, JSONObject jsonObject) { // hideLoading(); // canTakePhotoIconInMainThread(); // showToastSafe("拍照失败"); // } // // @Override // public void onReceiveMessage(CameraMessage // cameraMessage, JSONObject jsonObject) { // remoteCamHelper.getFile(filePath, new // SendCommandCallback() { // @Override // public void onFail(CameraMessage // cameraMessage, JSONObject jsonObject) { // canTakePhotoIconInMainThread(); // } // // @Override // public void onSuccess(CameraMessage // cameraMessage, JSONObject jsonObject) { // canTakePhotoIconInMainThread(); // hideLoading(); // showPhoto(); // handler_.removeCallbacks(runnable); //// if (!photoIsShow) { //// } // } // }); // } // // @Override // public void onReceiveNotification(JSONObject // jsonObject) { // } //// }); // setInfo.put("type", "TCP"); // setInfo.put("param", Constant.phoneIP); // remoteCamHelper.sendCommand(setInfo); } @Override public void onReceiveNotification(JSONObject jsonObject) {} }); remoteCamHelper.sendCommand(takePhoto); } else { showToastSafe(getResources().getString(R.string.idcard_loss)); } } else { bt_take_photo.setEnabled(false); showToastSafe(mActivity.getString(R.string.phone_and_camera_not_connect)); } }