示例#1
0
  /**
   * Creates a Subtitle with the given parameters.
   *
   * @param index Subtitle index
   * @param streamId Stream ID of this subtitle
   * @param vts Stream VTS
   * @param ds {@link DvdSubtitle} with further data
   * @param format {@link SubtitleFormat} of this subtitle
   * @return Created {@link Subtitle}
   */
  private Subtitle createSubtitle(
      int index, int streamId, int vts, DvdSubtitle ds, SubtitleFormat format) {
    Subtitle sub = new Subtitle();
    sub.setIndex(index);
    sub.setStreamId(String.format("0x%02X", streamId));
    sub.setFormat(format);
    sub.setVts(vts);

    Language language = LanguageUtils.findLanguage(ds.getLanguage());
    if (language != null) {
      sub.setLanguage(language);
      sub.setEnabled(format == SubtitleFormat.STANDARD || format == SubtitleFormat.WIDE);
    } else {
      sub.setLanguage(LanguageUtils.getMissing());
      sub.setEnabled(false);
    }

    sub.setType(SubtitleType.NOT_SPECIFIED);
    if (ds.getType() != null) {
      try {
        sub.setType(SubtitleType.valueOf(ds.getType().name()));
      } catch (IllegalArgumentException ex) {
        // ignore
      }
    }

    return sub;
  }
示例#2
0
  /**
   * Gets all {@link Audio} streams of a track.
   *
   * @param trackNr Track number, starting from 1
   * @return List of {@link Audio} streams found
   */
  public List<Audio> getAudios(int trackNr) {
    if (trackNr <= 0) {
      return Collections.emptyList();
    }

    DvdTitle title = info.getTitle(trackNr - 1);
    DvdTitleSet vts = title.getTitleSet();

    List<Audio> result = new ArrayList<>();

    for (int ix = 0; ix < vts.getAudios().size(); ix++) {
      DvdAudio da = vts.getAudios().get(ix);
      if (da.getStreamId() == null) {
        continue;
      }

      Audio audio = new Audio();
      audio.setIx(ix + 1);
      audio.setFormat(da.getMode().toString().toLowerCase());
      audio.setChannels(da.getChannels());
      audio.setStreamId(da.getStreamId());
      audio.setType(AudioType.NOT_SPECIFIED);

      if (da.getType() != null) {
        try {
          audio.setType(AudioType.valueOf(da.getType().name()));
        } catch (IllegalArgumentException ex) {
          // ignore
        }
      }

      Language language = LanguageUtils.findLanguage(da.getLang());
      if (language != null) {
        audio.setLanguage(language);
        audio.setEnabled(true);
      } else {
        audio.setLanguage(LanguageUtils.getMissing());
        audio.setEnabled(false);
      }

      result.add(audio);
    }

    return result;
  }