Exemplo 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;
  }
Exemplo n.º 2
0
 /**
  * 根据录像ID查询文件路径,
  *
  * @param uuid
  * @return 录像文件路径,如果没有找到或文件不存在,返回null;
  */
 public File getAlarmRecordFile(String uuid) {
   AlarmRecord record = (AlarmRecord) storage.load(AlarmRecord.class, uuid);
   File path = null;
   if (record != null) {
     path = new File(this.rootPath, record.videoPath);
     if (!path.isFile()) {
       log.warn("Not found video file:" + path + ", by id:" + uuid);
     }
   } else {
     log.warn("Not found video record by id:" + uuid);
   }
   return path;
 }
Exemplo n.º 3
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);
    }
  }