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 DASH_MPD_MANAGER_H
17 #define DASH_MPD_MANAGER_H
18 
19 #include <cstdint>
20 #include "dash_mpd_def.h"
21 
22 namespace OHOS {
23 namespace Media {
24 namespace Plugins {
25 namespace HttpPlugin {
26 class DashMpdManager {
27 public:
28     DashMpdManager() = default;
29     DashMpdManager(DashMpdInfo *mpdInfo, const std::string &mpdUrl);
30     ~DashMpdManager() = default;
31 
32 public:
33     void Reset();
34     void SetMpdInfo(DashMpdInfo *mpdInfo, const std::string &mpdUrl);
35     DashMpdInfo *GetMpdInfo();
36     DashPeriodInfo *GetFirstPeriod();
37     DashPeriodInfo *GetNextPeriod(const DashPeriodInfo *periodInfo);
38     TimeBase &GetTimeBase();
39 
40     // update mpd
41     void Update(DashMpdInfo *mpdInfo);
42     void SetTimeBase(time_t server, time_t client);
43     void GetBaseUrlList(std::list<std::string> &baseUrlList);
44     std::string GetBaseUrl();
45     void GetDuration(uint32_t *duration);
46     const DashList<DashPeriodInfo *> &GetPeriods() const;
47     void MakeBaseUrl(std::string &mpdUrlBase, std::string &urlSchem);
48 
49 private:
50     DashMpdInfo *mpdInfo_{nullptr};
51     std::string mpdUrl_;
52 };
53 } // namespace HttpPluginLite
54 } // namespace Plugin
55 } // namespace Media
56 } // namespace OHOS
57 #endif // DASH_MPD_MANAGER_H