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 "ipc_skeleton.h" 21 #include "nocopyable.h" 22 #include "i_mediakeysystemfactory_service.h" 23 #include "drm_death_recipient.h" 24 #include "drm_log.h" 25 #include "hitrace/tracechain.h" 26 27 namespace OHOS { 28 namespace DrmStandard { 29 class MediaKeySystemFactoryImpl : public RefBase { 30 public: 31 MediaKeySystemFactoryImpl(); 32 ~MediaKeySystemFactoryImpl(); 33 void Init(); 34 static sptr<MediaKeySystemFactoryImpl> &GetInstance(); 35 bool IsMediaKeySystemSupported(std::string &name); 36 bool IsMediaKeySystemSupported(std::string &name, std::string &mimeType); 37 bool IsMediaKeySystemSupported(std::string &name, std::string &mimeType, 38 IMediaKeySessionService::ContentProtectionLevel securityLevel); 39 int32_t GetMediaKeySystems(std::map<std::string, std::string> &keySystemNames); 40 int32_t GetMediaKeySystemUuid(std::string &name, std::string &uuid); 41 int32_t CreateMediaKeySystem(std::string &name, sptr<MediaKeySystemImpl> *mediaKeySystemImpl); 42 43 private: 44 void MediaKeySystemFactoryServerDied(pid_t pid); 45 const sptr<IMediaKeySystemFactoryService> GetServiceProxy(); 46 std::mutex serviceProxyMutex_; 47 sptr<OHOS::DrmStandard::IMediaKeySystemFactoryService> privateServiceProxy_; 48 std::mutex mutex_; 49 static sptr<MediaKeySystemFactoryImpl> mediaKeySystemFactoryImpl_; 50 sptr<DrmDeathRecipient> deathRecipient_ = nullptr; 51 sptr<DrmListenerStub> listenerStub_ = nullptr; 52 HiviewDFX::HiTraceId traceId_; 53 }; 54 } // DrmStandard 55 } // OHOS 56 #endif // OHOS_DRM_MEDIA_KEY_SYSTEMP_FACTORY_IMPL_H