Ejemplo n.º 1
0
  public static RecordingInfo getRecordingInfo(int number) throws IOException {
    Response response = VDRConnection.send(new LSTR(number));
    if (response != null && response.getCode() == 215) {
      try {
        org.hampelratte.svdrp.responses.highlevel.Recording rec = new Recording();
        new RecordingParser().parseRecording(rec, response.getMessage());

        RecordingInfo recordingInfo = new RecordingInfo();
        recordingInfo.id = MD5.calculate(response.getMessage());

        recordingInfo.channelName = rec.getChannelName();
        recordingInfo.date = rec.getStartTime().getTimeInMillis() / 1000;
        recordingInfo.description = rec.getDescription();
        long end = rec.getEndTime().getTimeInMillis() / 1000;
        recordingInfo.duration = end - recordingInfo.date;
        recordingInfo.title = rec.getDisplayTitle();
        recordingInfo.priority = rec.getPriority();
        recordingInfo.lifetime = rec.getLifetime();

        for (Stream stream : rec.getStreams()) {
          StreamInfo si = new StreamInfo();
          // stream type
          si.type = Integer.toString(stream.getType(), 16);

          // stream language
          si.language = stream.getLanguage();

          // stream description
          si.description = stream.getDescription();

          // stream kind
          switch (stream.getContent()) {
            case MP2V:
            case H264:
              si.kind = 1;
              recordingInfo.setVideoStream(si);
              break;
            case MP2A:
            case AC3:
            case HEAAC:
              si.kind = 2;
              recordingInfo.addAudioStream(si);
              break;
          }
        }
        return recordingInfo;
      } catch (ParseException e) {
        logger.error("Couldn't get recording info", e);
        throw new IOException(e.getMessage());
      } catch (Exception e) {
        // --- Parser could throw NPE ---
        logger.error("Couldn't get recording info", e);
        throw new IOException("Invalid recording info");
      }
    } else {
      throw new IOException(
          response.getCode() + " - " + response.getMessage().replaceAll("\n$", ""));
    }
  }