[This is a merge of http://go/wvgerrit/16522 ] This commit adds support for CBC and Pattern Mode to the MediaCrypto implementation. These are the only changes needed to support HLS. (No change is needed for MediaDrm, as it already passes HLS initialization data along to the core without closely inspecting it, as it should.) Following this change, the glue layer also supports the CENC, CBC1, CENS, and CBCS modes from the forthcoming update to the ISO-CENC spec. Note that, in order to differentiate CBC1 and CBCS, we have to cue on the presence or absence of a pattern, which may not continue to be sufficient in the future if a third CBC mode using patterns is ever added. Note that the unit tests for this code remain disabled for now. New unit tests are forthcoming in a separate commit. Bug: 25666017 Change-Id: I5942a8b70393e63b4de9d7dab985c4c2a98a20b3
57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
//
|
|
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
//
|
|
|
|
#ifndef WV_CRYPTO_PLUGIN_H_
|
|
#define WV_CRYPTO_PLUGIN_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "utils/StrongPointer.h"
|
|
#include "utils/Vector.h"
|
|
|
|
#include "media/hardware/CryptoAPI.h"
|
|
#include "media/stagefright/foundation/ABase.h"
|
|
#include "media/stagefright/foundation/AString.h"
|
|
#include "wv_content_decryption_module.h"
|
|
|
|
namespace wvdrm {
|
|
|
|
class WVCryptoPlugin : public android::CryptoPlugin {
|
|
public:
|
|
WVCryptoPlugin(const void* data, size_t size,
|
|
const android::sp<wvcdm::WvContentDecryptionModule>& cdm);
|
|
virtual ~WVCryptoPlugin() {}
|
|
|
|
virtual bool requiresSecureDecoderComponent(const char* mime) const;
|
|
|
|
virtual void notifyResolution(uint32_t width, uint32_t height);
|
|
|
|
virtual android::status_t setMediaDrmSession(
|
|
const android::Vector<uint8_t>& sessionId);
|
|
|
|
virtual ssize_t decrypt(bool secure, const uint8_t key[16],
|
|
const uint8_t iv[16], Mode mode, const Pattern &pattern,
|
|
const void* srcPtr,
|
|
const SubSample* subSamples, size_t numSubSamples,
|
|
void* dstPtr, android::AString* errorDetailMsg);
|
|
|
|
private:
|
|
DISALLOW_EVIL_CONSTRUCTORS(WVCryptoPlugin);
|
|
|
|
android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
|
|
|
|
bool mTestMode;
|
|
wvcdm::CdmSessionId mSessionId;
|
|
|
|
wvcdm::CdmSessionId configureTestMode(const void* data, size_t size);
|
|
static wvcdm::CdmResponseType countEncryptedBlocksInPatternedRange(
|
|
size_t range, size_t startingOffset, const Pattern& pattern,
|
|
size_t startingPatternOffset, uint64_t* result);
|
|
static void incrementIV(uint64_t increaseBy, std::vector<uint8_t>* ivPtr);
|
|
};
|
|
|
|
} // namespace wvdrm
|
|
|
|
#endif // WV_CRYPTO_PLUGIN_H_
|