Exemplo n.º 1
0
 public HdsManifest(final HttpDownloadClient client, final String manifestUrl) throws IOException {
   try {
     final XPath xpath = XPathFactory.newInstance().newXPath();
     final F4mManifest manifest = F4mManifest.fetch(client, manifestUrl, xpath);
     final List<HdsMedia> medias = new ArrayList<HdsMedia>();
     final MediaNode firstMediaNode = manifest.getFirstMediaNode();
     if (!firstMediaNode.getHref().isEmpty()) {
       for (final MediaNode media : manifest.getMediaNodes()) {
         final String href = getUrl(manifestUrl, manifest.getBaseUrl(), media.getHref());
         final F4mManifest childManifest = F4mManifest.fetch(client, href, xpath);
         final MediaNode childMedia = childManifest.getFirstMediaNode();
         final BootstrapInfo info =
             childManifest.getBootstrapInfo(childMedia.getBootstrapInfoId());
         final String url = getUrl(href, childManifest.getBaseUrl(), childMedia.getUrl());
         medias.add(
             new HdsMedia(
                 url, manifest.getUrlQuery(), media.getBitrate(), info.getFragmentCount()));
       }
     } else {
       for (final MediaNode media : manifest.getMediaNodes()) {
         final BootstrapInfo info = manifest.getBootstrapInfo(media.getBootstrapInfoId());
         final String url = getUrl(manifestUrl, manifest.getBaseUrl(), media.getUrl());
         medias.add(
             new HdsMedia(
                 url, manifest.getUrlQuery(), media.getBitrate(), info.getFragmentCount()));
       }
     }
     logger.info("Found medias: " + medias.toString());
     this.medias = Collections.unmodifiableList(medias);
   } catch (final Exception e) {
     throw new IOException("Failed to parse manifest", e);
   }
 }