readium / SDKLauncher-Android

Launcher app for Readium SDK on Android
BSD 3-Clause "New" or "Revised" License
77 stars 65 forks source link

readDataFull returns max 10MB of data #150

Open ronghester opened 5 years ago

ronghester commented 5 years ago

This issue is a Bug|Question

Package: org.readium.sdk.android Class: PackageResource Method: readDataFull() Issue: When dealing with resource more than 17MB of size then readDataFull() method is returning maximum 10mb of data. What should be changed in order to get all the data from resource?

If getInputStream(true) method is used then the full track data is returned. However this requires to get the input stream and then change it to bytes[] this process takes time and impacting the performance of the player.

Is there any work around so that readDataFull() return full data.

Thanks

danielweck commented 5 years ago

My comments extracted from the parallel Slack discussion:

You should absolutely avoid loading large audio/video buffers in memory. Instead, stream chunks of data via the HTTP transport layer (HTTP 1.1 partial requests / byte ranges is fine for that). That's how the ReadiumSDK is designed, and it even works with encrypted resources.

Typically, in SDKLauncher apps EPUB resources are served over HTTP, so an audio asset from a (zipped) publication would typically be accessible through a URL like http://120.0.0.1:9090/pub/ID/path/to/audio.mp3 => the HTTP server is 1.1 compliant so it will respond correctly to partial byte range request, i.e. it will emit buffer chunks on demand (and the ReadiumSDK resource stream architecture takes care of fetching small amounts of data from the zipped publication)