-
Notifications
You must be signed in to change notification settings - Fork 163
ContentFilterEncryptedMedia
For a quick turnaround when experimenting with encrypted media resources, you may use the existing ContentFilter called "PassThroughFilter" (which by default simply passes the raw data extracted from the zip archive, no byte transformation involved).
1) First, register the filter in the PopulateFilterManager() initialisation function, so that the filter can be included in the processing chain:
https://github.com/readium/readium-sdk/blob/develop/ePub3/ePub/initialization.cpp#L40
PassThroughFilter::Register();
2) Secondly, make sure that the SniffPassThroughContent method correctly tests your resource. For example, your content filter may need to decode only certain types of audio and video files:
// "item" is a ManifestItem pointer
auto mediaType = item->MediaType();
return (mediaType == "audio/mp4" || mediaType == "audio/mpeg" || mediaType == "video/mp4" || mediaType == "video/mpeg");
3) Thirdly, you now need to implement the FilterData() decryption routine, which should consume raw bytes (provided by the PassThroughContext instance) and transform them into their decoded form:
Note that by default, the PassThroughFilter returns "OperatingMode::SupportsByteRanges" in the GetOperatingMode() method, which means that your implementation must support arbitrary HTTP byte range requests (i.e. query of bytes within the stream, from a given offset, for a given length).
Should your de-encryption algorithm not support byte ranges, you may need to disable support for "OperatingMode::SupportsByteRanges", and instead use the "OperatingMode::RequiresCompleteData" variant (which implies that your encrypted media resources will be entirely loaded in memory).
3) Fourthly,