1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DRM_MEDIA_KEY_SYSTEMP_FACTORY_IMPL_H 17 #define OHOS_DRM_MEDIA_KEY_SYSTEMP_FACTORY_IMPL_H 18 19 #include "media_key_system_impl.h" 20 #include "system_ability_definition.h" 21 #include "ipc_skeleton.h" 22 #include "iservice_registry.h" 23 #include "nocopyable.h" 24 #include "i_mediakeysystemfactory_service.h" 25 #include "drm_death_recipient.h" 26 #include "drm_log.h" 27 #include "hitrace/tracechain.h" 28 29 namespace OHOS { 30 namespace DrmStandard { 31 class MediaKeySystemFactoryImpl : public RefBase { 32 public: 33 MediaKeySystemFactoryImpl(); 34 ~MediaKeySystemFactoryImpl(); 35 void Init(); 36 static sptr<MediaKeySystemFactoryImpl> &GetInstance(); 37 bool IsMediaKeySystemSupported(std::string &name); 38 bool IsMediaKeySystemSupported(std::string &name, std::string &mimeType); 39 bool IsMediaKeySystemSupported(std::string &name, std::string &mimeType, 40 IMediaKeySessionService::ContentProtectionLevel securityLevel); 41 int32_t GetMediaKeySystems(std::map<std::string, std::string> &keySystemNames); 42 int32_t GetMediaKeySystemUuid(std::string &name, std::string &uuid); 43 int32_t CreateMediaKeySystem(std::string &name, sptr<MediaKeySystemImpl> *mediaKeySystemImpl); 44 45 private: 46 void MediaKeySystemFactoryServerDied(pid_t pid); 47 const sptr<IMediaKeySystemFactoryService> GetServiceProxy(); 48 std::mutex serviceProxyMutex_; 49 sptr<OHOS::DrmStandard::IMediaKeySystemFactoryService> privateServiceProxy_; 50 std::mutex mutex_; 51 static sptr<MediaKeySystemFactoryImpl> mediaKeySystemFactoryImpl_; 52 sptr<DrmDeathRecipient> deathRecipient_ = nullptr; 53 sptr<DrmListenerStub> listenerStub_ = nullptr; 54 HiviewDFX::HiTraceId traceId_; 55 }; 56 } // DrmStandard 57 } // OHOS 58 #endif // OHOS_DRM_MEDIA_KEY_SYSTEMP_FACTORY_IMPL_H