예제 #1
0
  /** 从记录仪上获取突发视频的数据 */
  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);
  }
예제 #2
0
  /** 发命令让记录仪切换为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();
  }
예제 #3
0
  /** 获取到当前的状态 */
  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);
  }
예제 #4
0
  @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));
    }
  }