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 LOADING_REQUEST_H 17 #define LOADING_REQUEST_H 18 #include <map> 19 #include "buffer/avsharedmemorybase.h" 20 21 namespace OHOS { 22 namespace Media { 23 class LoadingRequest { 24 public: 25 virtual ~LoadingRequest() = default; 26 27 virtual int32_t RespondData(int64_t uuid, int64_t offset, const std::shared_ptr<AVSharedMemory> &mem) = 0; 28 virtual int32_t RespondHeader(int64_t uuid, std::map<std::string, std::string> header, std::string redirectUrl) = 0; 29 virtual int32_t FinishLoading(int64_t uuid, int32_t requestedError) = 0; 30 virtual uint64_t GetUniqueId() = 0; 31 virtual std::string GetUrl() = 0; 32 virtual std::map<std::string, std::string> GetHeader() = 0; 33 }; 34 35 class LoaderCallback { 36 public: 37 virtual ~LoaderCallback() = default; 38 virtual int64_t Open(std::shared_ptr<LoadingRequest> &request) = 0; 39 virtual void Read(int64_t uuid, int64_t requestedOffset, int64_t requestedLength) = 0; 40 virtual void Close(int64_t uuid) = 0; 41 }; 42 } // namespace Media 43 } // namespace OHOS 44 #endif // LOADING_REQUEST_H 45