Skip to content

Exoplayer does not play MPEG-DASH + PlayReady contents. #2386

@from-unknown

Description

@from-unknown

Description

I tried to play MPEG-DASH + PlayReady (actually it was a common encryption media - playready and widevine modular) contents and found that exoplayer could not play it.

Reproduce link

Not available now - I will try to create one if needed.
Manifest file is nearly like this.
Big Buck Bunny

Device

Nexus player (6.1)
Android TV - Sony Bravia (5.1.1)

Possible solution

While debugging this problem, I found that exoplayer did not parse mspr:pro tag in manifest file.
Looking at smooth streaming code, I added code below and then contents played fine.

code (exoplayer 2.X):
DashManifestParser.java

protected SchemeData parseContentProtection(XmlPullParser xpp) throws XmlPullParserException,
      IOException {
    String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri"); // Added
    byte[] data = null;
    UUID uuid = null;
    boolean seenPsshElement = false;
    boolean requiresSecureDecoder = false;
    do {
      xpp.next();
      // The cenc:pssh element is defined in 23001-7:2015.
      if (XmlPullParserUtil.isStartTag(xpp, "cenc:pssh") && xpp.next() == XmlPullParser.TEXT) {
        seenPsshElement = true;
        data = Base64.decode(xpp.getText(), Base64.DEFAULT);
        uuid = PsshAtomUtil.parseUuid(data);
      } else if (XmlPullParserUtil.isStartTag(xpp, "widevine:license")) {
        String robustnessLevel = xpp.getAttributeValue(null, "robustness_level");
        requiresSecureDecoder = robustnessLevel != null && robustnessLevel.startsWith("HW");
      // ----- Add start -----
      } else if (ParserUtil.isStartTag(xpp, "mspr:pro") && xpp.next() == XmlPullParser.TEXT) {
        seenPsshElement = true;
        uuid = UUID.fromString(schemeIdUri.split(":")[2]);
        data = new SchemeInitData(MimeTypes.VIDEO_MP4,
                PsshAtomUtil.buildPsshAtom(uuid,Base64.decode(xpp.getText(), Base64.DEFAULT)));
      }
      // ----- Add end ----- 
    } while (!XmlPullParserUtil.isEndTag(xpp, "ContentProtection"));
    if (!seenPsshElement) {
      return null;
    } else if (uuid != null) {
      return new SchemeData(uuid, MimeTypes.VIDEO_MP4, data, requiresSecureDecoder);
    } else {
      Log.w(TAG, "Skipped unsupported ContentProtection element");
      return null;
    }
}

code (exoplayer 1.X):
MediaPresentationDescriptionParser.java

  protected ContentProtection parseContentProtection(XmlPullParser xpp)
      throws XmlPullParserException, IOException {
    String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
    UUID uuid = null;
    SchemeInitData data = null;
    boolean seenPsshElement = false;
    do {
      xpp.next();
      // The cenc:pssh element is defined in 23001-7:2015.
      if (ParserUtil.isStartTag(xpp, "cenc:pssh") && xpp.next() == XmlPullParser.TEXT) {
        seenPsshElement = true;
        data = new SchemeInitData(MimeTypes.VIDEO_MP4,
            Base64.decode(xpp.getText(), Base64.DEFAULT));
        uuid = PsshAtomUtil.parseUuid(data.data);
      }
      // ----- Add start -----
      if (ParserUtil.isStartTag(xpp, "mspr:pro") && xpp.next() == XmlPullParser.TEXT) {
        seenPsshElement = true;
        uuid = UUID.fromString(schemeIdUri.split(":")[2]);
        data = new SchemeInitData(MimeTypes.VIDEO_MP4,
                PsshAtomUtil.buildPsshAtom(uuid,Base64.decode(xpp.getText(), Base64.DEFAULT)));
      }
      // ----- Add end ----- 
    } while (!ParserUtil.isEndTag(xpp, "ContentProtection"));
    if (seenPsshElement && uuid == null) {
      Log.w(TAG, "Skipped unsupported ContentProtection element");
      return null;
    }
    return buildContentProtection(schemeIdUri, uuid, data);
  }

I am not sure that this code is good enough, but at least works at my envelopment.
I hope this code helps solve this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions