Package com.castlabs.android.downloader
Class ContainerUtils
- java.lang.Object
-
- com.castlabs.android.downloader.ContainerUtils
-
public class ContainerUtils extends Object
Helper class that provides utilities to handle zip containers that contain DASH content. The zip always needs to contain a file namedmeta.json
. That file is a json file that must at least have an entry"manifest"
that points to the Manifest of the content within the zip file
-
-
Constructor Summary
Constructors Constructor Description ContainerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Uri
getManifestUrl(File zipFile)
Reads the zip filesmeta.json
file and returns aUri
to that Manifest.static Uri
getManifestUrl(File zipFile, JSONObject metadata)
Takes the zip filesmeta.json
content and returns aUri
to that Manifest.static JSONObject
readMetaData(File zipSource)
Take a zip file and looks for a "meta.json" entry.static Pair<String,String>
splitEntryPath(Uri uri)
Takes a zip file URI of the formzip:/path/to/file.zip/entry/path.txt
and returns a pair where the first element is the path to the zip file and the second entry is the path to the entry.
-
-
-
Method Detail
-
readMetaData
@Nullable public static JSONObject readMetaData(@NonNull File zipSource) throws IOException, JSONException
Take a zip file and looks for a "meta.json" entry.- Parameters:
zipSource
- The- Returns:
- The parsed entry or null if no such entry exists
- Throws:
IOException
- In case an error occurs while reading the entryJSONException
- In case an error occurs while parsing the entry
-
getManifestUrl
public static Uri getManifestUrl(@NonNull File zipFile) throws IOException, JSONException
Reads the zip filesmeta.json
file and returns aUri
to that Manifest. The uri constructed here can be passed to thePlayerController
to open the content in the zip.- Parameters:
zipFile
- The zip file- Returns:
- The Uri to the Manifest in the ZIP
- Throws:
IOException
- In case an error occurred while reading data or no meta-data was found or the meta entries are not validJSONException
- In case an error occurred while parsing the meta-data
-
getManifestUrl
public static Uri getManifestUrl(@NonNull File zipFile, @NonNull JSONObject metadata) throws IOException, JSONException
Takes the zip filesmeta.json
content and returns aUri
to that Manifest. The uri constructed here can be passed to thePlayerController
to open the content in the zip.- Parameters:
zipFile
- The zip filemetadata
- The ZIP meta-data- Returns:
- The Uri to the Manifest in the ZIP
- Throws:
IOException
- In case an error occurred while reading data or no meta-data was found or the meta entries are not validJSONException
- In case an error occurred while parsing the meta-data
-
splitEntryPath
public static Pair<String,String> splitEntryPath(Uri uri)
Takes a zip file URI of the formzip:/path/to/file.zip/entry/path.txt
and returns a pair where the first element is the path to the zip file and the second entry is the path to the entry. In the example above, this method returns/path/to/file.zip, entry/path.txt
. The method returns null if no zip file could be found. The method checks for the existence of the zip file but not the existence of the entry within the zip.- Parameters:
uri
- The URI- Returns:
- Pair of zip and entry path or null
-
-