Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request offline viewing license for local asset #2646

Closed
yanivlankry opened this issue Apr 4, 2017 · 3 comments
Closed

request offline viewing license for local asset #2646

yanivlankry opened this issue Apr 4, 2017 · 3 comments
Assignees
Labels

Comments

@yanivlankry
Copy link

yanivlankry commented Apr 4, 2017

Issue description

Fail to process local storage MPD file - DashUtil.loadManifest is not suitable to process local storage file.
DashUtil.loadManifest is handling only input streaming - used for network , while local files should use FileInputStream

Reproduction steps

Download Asset to my local storage.
Request offline viewing license.
See app crash report blow.

Link to test content

local content - simple DASH

Version of ExoPlayer being used

Specify the absolute version number. Avoid using terms such as "latest".

Device(s) and version(s) of Android being used

Using LG G3 android M.

A full bug report captured from the device

04-04 18:55:19.792 10209-10209/com.cisco.mdrm.demo W/ResourceType: For resource 0x01030481, entry index(1153) is beyond type entryCount(1)
04-04 18:55:19.793 10209-10209/com.cisco.mdrm.demo W/ResourceType: For resource 0x01030481, entry index(1153) is beyond type entryCount(1)
04-04 18:55:19.795 10209-10209/com.cisco.mdrm.demo W/ResourceType: For resource 0x01030481, entry index(1153) is beyond type entryCount(1)
04-04 18:55:19.795 10209-10209/com.cisco.mdrm.demo W/ResourceType: For resource 0x01030481, entry index(1153) is beyond type entryCount(1)
04-04 18:55:21.304 10209-10209/com.cisco.mdrm.demo I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
04-04 18:55:21.381 10209-10209/com.cisco.mdrm.demo I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
04-04 18:55:21.457 10209-10209/com.cisco.mdrm.demo W/ResourceType: For resource 0x01030046, entry index(70) is beyond type entryCount(1)
04-04 18:55:21.460 10209-10209/com.cisco.mdrm.demo W/ResourceType: For resource 0x01030046, entry index(70) is beyond type entryCount(1)
04-04 18:55:21.561 10209-11755/com.cisco.mdrm.demo D/MDrmOfflineViewingLicenseHandler: GetOfflineKeyFromServer offlineLicenseKeySetId: localURI:file:/mnt/sdcard/assets/Brave-PRWV/Brave-PRWV.mpd
04-04 18:55:21.591 10209-11755/com.cisco.mdrm.demo E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: com.cisco.mdrm.demo, PID: 10209
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassCastException: libcore.net.url.FileURLConnection cannot be cast to java.net.HttpURLConnection
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:393)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:350)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:192)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:101)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:64)
at com.google.android.exoplayer2.source.dash.DashUtil.loadManifest(DashUtil.java:57)
at com.google.android.exoplayer2.drm.OfflineLicenseHelper.download(OfflineLicenseHelper.java:144)
at com.cisco.mdrm.impl.MDrmOfflineViewingLicenseHandler$GetOfflineKeyFromServer.doInBackground(MDrmOfflineViewingLicenseHandler.java:103)
at com.cisco.mdrm.impl.MDrmOfflineViewingLicenseHandler$GetOfflineKeyFromServer.doInBackground(MDrmOfflineViewingLicenseHandler.java:77)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
04-04 18:55:21.616 10209-10209/com.cisco.mdrm.demo V/ViewRootImpl: Contents drawing finished : Toast
04-04 18:55:21.924 10209-10252/com.cisco.mdrm.demo E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa5c9a250
04-04 18:55:21.933 10209-10252/com.cisco.mdrm.demo D/OpenGLRenderer: endAllActiveAnimators on 0xb3a6d400 (

My Solution:

  public static DashManifest downloadManifest(HttpDataSource dataSource, String manifestUriString)
      throws IOException
  {
    String local_file_sufix = "file:";
    if (manifestUriString.startsWith(local_file_sufix) )
    {
      String file_to_Open  = manifestUriString.toString().replace(local_file_sufix,"");
      Uri uri = Uri.parse(file_to_Open);
      File file = new File(file_to_Open);
      FileInputStream fileInputStream = new FileInputStream(file);

      DashManifestParser parser = new DashManifestParser();
      return parser.parse(uri, fileInputStream);
    }
    else
    {

      DataSourceInputStream inputStream = new DataSourceInputStream(
              dataSource, new DataSpec(Uri.parse(manifestUriString)));
      try
      {
        inputStream.open();
        DashManifestParser parser = new DashManifestParser();
        return parser.parse(dataSource.getUri(), inputStream);
      }
      finally
      {
        inputStream.close();
      }
    }
  }
@erdemguven
Copy link
Contributor

@yanivlankry this should be fixed when the latest changes published to GitHub.
If you wish, until then you can load local and online manifests with:

defaultDataSource = new DefaultDataSource(<parameters>);
DashUtil.loadManifest(defaultDataSource, manifestUri)

@yanivlankry
Copy link
Author

thank you , i'll try

@ojw28 ojw28 added the bug label Apr 6, 2017
@ojw28 ojw28 closed this as completed Apr 6, 2017
@ojw28
Copy link
Contributor

ojw28 commented Apr 6, 2017

This is fixed already in dev-v2. OfflineLicenseHelper no longer has a dependency on DashUtil.

@google google locked and limited conversation to collaborators Aug 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants