1 /* 2 * Copyright (C) 2021 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 AVMETADATAHELPER_SERVICE_STUB_H 17 #define AVMETADATAHELPER_SERVICE_STUB_H 18 19 #include <map> 20 #include "i_standard_avmetadatahelper_service.h" 21 #include "media_death_recipient.h" 22 #include "avmetadatahelper_server.h" 23 24 namespace OHOS { 25 namespace Media { 26 class AVMetadataHelperServiceStub : public IRemoteStub<IStandardAVMetadataHelperService>, public NoCopyable { 27 public: 28 static sptr<AVMetadataHelperServiceStub> Create(); 29 virtual ~AVMetadataHelperServiceStub(); 30 31 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 32 int32_t SetSource(const std::string &uri, int32_t usage) override; 33 int32_t SetSource(int32_t fd, int64_t offset, int64_t size, int32_t usage) override; 34 std::string ResolveMetadata(int32_t key) override; 35 std::unordered_map<int32_t, std::string> ResolveMetadataMap() override; 36 std::shared_ptr<AVSharedMemory> FetchArtPicture() override; 37 std::shared_ptr<AVSharedMemory> FetchFrameAtTime(int64_t timeUs, 38 int32_t option, const OutputConfiguration ¶m) override; 39 void Release() override; 40 int32_t DestroyStub() override; 41 42 private: 43 AVMetadataHelperServiceStub(); 44 int32_t Init(); 45 int32_t SetUriSource(MessageParcel &data, MessageParcel &reply); 46 int32_t SetFdSource(MessageParcel &data, MessageParcel &reply); 47 int32_t ResolveMetadata(MessageParcel &data, MessageParcel &reply); 48 int32_t ResolveMetadataMap(MessageParcel &data, MessageParcel &reply); 49 int32_t FetchArtPicture(MessageParcel &data, MessageParcel &reply); 50 int32_t FetchFrameAtTime(MessageParcel &data, MessageParcel &reply); 51 int32_t Release(MessageParcel &data, MessageParcel &reply); 52 int32_t DestroyStub(MessageParcel &data, MessageParcel &reply); 53 54 std::mutex mutex_; 55 std::shared_ptr<IAVMetadataHelperService> avMetadateHelperServer_ = nullptr; 56 using AVMetadataHelperStubFunc = int32_t(AVMetadataHelperServiceStub::*)(MessageParcel &data, MessageParcel &reply); 57 std::map<uint32_t, AVMetadataHelperStubFunc> avMetadataHelperFuncs_; 58 }; 59 } // namespace Media 60 } // namespace OHOS 61 #endif // AVMETADATAHELPER_SERVICE_STUB_H 62