1791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang/* 2791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * Copyright (C) 2017 The Android Open Source Project 3791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * 4791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * Licensed under the Apache License, Version 2.0 (the "License"); 5791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * you may not use this file except in compliance with the License. 6791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * You may obtain a copy of the License at 7791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * 8791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * http://www.apache.org/licenses/LICENSE-2.0 9791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * 10791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * Unless required by applicable law or agreed to in writing, software 11791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * distributed under the License is distributed on an "AS IS" BASIS, 12791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * See the License for the specific language governing permissions and 14791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * limitations under the License. 15791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang */ 16791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 17791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#ifndef CLEAR_KEY_FETCHER_H_ 18791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#define CLEAR_KEY_FETCHER_H_ 19791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 20791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include <vector> 21791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 22791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include "protos/license_protos.pb.h" 23791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 24791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include <media/stagefright/foundation/ABase.h> 25791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include "KeyFetcher.h" 26791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 27791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangnamespace android { 28791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangnamespace clearkeycas { 29791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 30791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangclass LicenseFetcher; 31791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 32791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangclass ClearKeyFetcher : public KeyFetcher { 33791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangpublic: 34791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // ClearKeyFetcher takes ownership of |license_fetcher|. 35791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang explicit ClearKeyFetcher( 36791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang std::unique_ptr<LicenseFetcher> license_fetcher); 37791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 38791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang virtual ~ClearKeyFetcher(); 39791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 40791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // Initializes the fetcher. Must be called before ObtainKey. 41791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang status_t Init() override; 42791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 43791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // Obtains the |asset_id| and |keys| from the Ecm contained in |ecm|. 44791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // Returns 45791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // - errors returned by EcmContainer::Parse. 46791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // - errors returned by ClassicLicenseFetcher::FetchLicense. 47791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // - errors returned by Ecm::Decrypt. 48791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // |asset_id| and |keys| are owned by the caller and cannot be null. 49791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang // Init() must have been called. 50791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang status_t ObtainKey(const sp<ABuffer>& ecm, uint64_t* asset_id, 51791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang std::vector<KeyInfo>* keys) override; 52791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 53791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangprivate: 54791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang clearkeycas::Asset asset_; 55791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang bool initialized_; 56791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang std::unique_ptr<LicenseFetcher> license_fetcher_; 57791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 58791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang DISALLOW_EVIL_CONSTRUCTORS(ClearKeyFetcher); 59791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}; 60791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 61791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang} // namespace clearkeycas 62791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang} // namespace android 63791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang 64791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#endif // CLEAR_KEY_FETCHER_H_ 65