Ejemplo n.º 1
0
  /**
   * 返回当前录像的会话ID.
   *
   * @param client
   * @param alarm
   * @return
   */
  public String startAlarmRecord(MonitorClient client, AlarmRecord alarm) {
    Date startTime = new Date();
    String path =
        getSavePath(startTime, client.info.uuid, alarm.user, alarm.alarmCode, alarm.channelId);
    alarm.videoPath = path;
    alarm.generatePK();

    int ch = 0;
    try {
      ch = Integer.parseInt(alarm.channelId);
    } catch (Exception e) {
    }

    alarm.recorder = new FileVideoRecorder(new File(rootPath, path), MonitorChannel.MAIN_VIDEO, ch);

    log.info(String.format("Start record, sid:%s, path:%s", alarm.uuid, alarm.videoPath));
    client.route.addDestination(alarm.recorder);
    client.realPlay(ch, MonitorChannel.MAIN_VIDEO);
    storage.save(alarm);

    runningRecorder.put(alarm.uuid, alarm);

    return alarm.uuid;

    // return alarm.uuid;
  }
Ejemplo n.º 2
0
  public void stoptRecord(String sid) {
    AlarmRecord alarm = runningRecorder.get(sid);
    if (alarm != null) {
      alarm.recorder.close();
      alarm.endTime = new Date();
      storage.save(alarm);

      runningRecorder.remove(sid);
      log.info(String.format("Closed record, sid:%s", alarm.uuid));
    } else {
      log.warn("Try to stop record, but Not found session by id " + sid);
    }
  }