/**
   * This populates the file-specific transcode folder with all combinations of players, audio
   * tracks and subtitles.
   */
  @Override
  protected void resolveOnce() {
    if (getChildren().size() == 1) { // OK
      DLNAResource child = getChildren().get(0);
      child.syncResolve();

      RendererConfiguration renderer = null;
      if (this.getParent() != null) {
        renderer = this.getParent().getDefaultRenderer();
      }

      // create copies of the audio/subtitle track lists as we're making (local)
      // modifications to them
      List<DLNAMediaAudio> audioTracks = new ArrayList<>(child.getMedia().getAudioTracksList());
      List<DLNAMediaSubtitle> subtitleTracks =
          new ArrayList<>(child.getMedia().getSubtitleTracksList());

      // assemble copies for each combination of audio, subtitle and player
      ArrayList<DLNAResource> entries = new ArrayList<>();

      // First, add the option to simply stream the resource.
      if (renderer != null) {
        LOGGER.trace(
            "Duplicating {} for direct streaming to renderer: {}",
            child.getName(),
            renderer.getRendererName());
      }

      DLNAResource noTranscode = createResourceWithAudioSubtitlePlayer(child, null, null, null);
      addChildInternal(noTranscode);
      addChapterFolder(noTranscode);

      // add options for renderer capable to handle streamed subtitles
      if (!configuration.isDisableSubtitles()
          && renderer != null
          && renderer.isSubtitlesStreamingSupported()) {
        for (DLNAMediaSubtitle subtitle : subtitleTracks) {
          // only add the option if the renderer supports the given format
          if (subtitle.isExternal()) { // do not check for embedded subs
            if (renderer.isExternalSubtitlesFormatSupported(subtitle, child.getMedia())) {
              DLNAResource copy =
                  createResourceWithAudioSubtitlePlayer(child, null, subtitle, null);
              copy.getMediaSubtitle().setSubsStreamable(true);
              entries.add(copy);
              LOGGER.trace(
                  "Duplicating {} for direct streaming subtitles {}",
                  child.getName(),
                  subtitle.toString());
            }
          }
        }
      }

      /*
      we add (or may add) a null entry to the audio list and/or subtitle list
      to ensure the inner loop is always entered:

      for audio in audioTracks:
      for subtitle in subtitleTracks:
      for player in players:
      newResource(audio, subtitle, player)

      there are 4 different scenarios:

      1) a file with audio tracks and no subtitles (subtitle == null): in that case we want
      to assign a player for each audio track

      2) a file with subtitles and no audio tracks (audio == null): in that case we want
      to assign a player for each subtitle track

      3) a file with no audio tracks (audio == null) and no subtitles (subtitle == null)
      e.g. an audio file, a video with no sound and no subtitles or a web audio/video file:
      in that case we still want to provide a selection of players e.g. FFmpeg Web Video
      and VLC Web Video for a web video or FFmpeg Audio and MPlayer Audio for an audio file

      4) one or more audio tracks AND one or more subtitle tracks: this is the case this code
      used to handle when it solely dealt with (local) video files: assign a player
      for each combination of audio track and subtitle track

      If a null audio or subtitle track is passed to createResourceWithAudioSubtitlePlayer,
      it sets the copy's corresponding mediaAudio (AKA params.aid) or mediaSubtitle
      (AKA params.sid) value to null.

      Note: this is the only place in the codebase where mediaAudio and mediaSubtitle
      are assigned (ignoring the trivial clone operation in ChapterFileTranscodeVirtualFolder),
      so setting one or both of them to null is a no-op as they're already null.
      */

      if (audioTracks.isEmpty()) {
        audioTracks.add(null);
      }

      if (subtitleTracks.isEmpty()) {
        subtitleTracks.add(null);
      } else {
        // if there are subtitles, make sure a no-subtitle option is added
        // for each player
        DLNAMediaSubtitle noSubtitle = new DLNAMediaSubtitle();
        noSubtitle.setId(-1);
        subtitleTracks.add(noSubtitle);
      }

      for (DLNAMediaAudio audio : audioTracks) {
        // Create combinations of all audio tracks, subtitles and players.
        for (DLNAMediaSubtitle subtitle : subtitleTracks) {
          // Create a temporary copy of the child with the audio and
          // subtitle modified in order to be able to match players to it.
          DLNAResource temp = createResourceWithAudioSubtitlePlayer(child, audio, subtitle, null);

          // Determine which players match this audio track and subtitle
          ArrayList<Player> players = PlayerFactory.getPlayers(temp);

          // create a copy for each compatible player
          for (Player player : players) {
            DLNAResource copy =
                createResourceWithAudioSubtitlePlayer(child, audio, subtitle, player);
            entries.add(copy);
          }
        }
      }

      // Sort the list of combinations
      Collections.sort(entries, new ResourceSort(PlayerFactory.getPlayers()));

      // Now add the sorted list of combinations to the folder
      for (DLNAResource dlna : entries) {
        LOGGER.trace(
            "Adding {}: audio: {}, subtitle: {}, player: {}",
            new Object[] {
              dlna.getName(),
              dlna.getMediaAudio(),
              dlna.getMediaSubtitle(),
              (dlna.getPlayer() != null ? dlna.getPlayer().name() : null),
            });

        addChildInternal(dlna);
        addChapterFolder(dlna);
      }
    }
  }