1 /* 2 * Copyright (c) 2024-2024 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 HISTREAMER_NETWORK_CLIENT_H 17 #define HISTREAMER_NETWORK_CLIENT_H 18 19 #include <string> 20 #include <map> 21 #include "network/network_typs.h" 22 #include "plugin/plugin_event.h" 23 #include "meta/media_types.h" 24 #include "common/status.h" 25 26 namespace OHOS { 27 namespace Media { 28 namespace Plugins { 29 namespace HttpPlugin { 30 class NetworkClient { 31 public: 32 virtual ~NetworkClient() = default; 33 virtual Status Init() = 0; 34 virtual Status Open(const std::string& url, const std::map<std::string, std::string>& httpHeader, 35 int32_t timeoutMs) = 0; 36 virtual Status RequestData(long startPos, int len, const RequestInfo& sourceInfo, 37 HandleResponseCbFunc completedCb) = 0; 38 virtual Status Close(bool isAsync) = 0; 39 virtual Status Deinit() = 0; 40 static std::shared_ptr<NetworkClient> GetInstance(RxHeader headCallback, RxBody bodyCallback, void *userParam); 41 virtual Status GetIp(std::string &ip); 42 virtual void SetAppUid(int32_t appUid); 43 }; 44 } // namespace HttpPlugin 45 } // namespace Plugins 46 } // namespace Media 47 } // namespace OHOS 48 #endif // HISTREAMER_NETWORK_CLIENT_H 49