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_ADAPTATION_SET_MANAGER_H
17 #define DASH_ADAPTATION_SET_MANAGER_H
18 
19 #include "dash_mpd_def.h"
20 
21 namespace OHOS {
22 namespace Media {
23 namespace Plugins {
24 namespace HttpPlugin {
25 class DashAdptSetManager {
26 public:
27     DashAdptSetManager() = default;
28     explicit DashAdptSetManager(DashAdptSetInfo *adptSet);
29     ~DashAdptSetManager();
30 
31     void Reset();
32     void SetAdptSetInfo(DashAdptSetInfo *adptSet);
33     void GetBaseUrlList(std::list<std::string> &baseUrlList);
34     void GetBandwidths(DashVector<uint32_t> &bandwidths);
35     DashUrlType *GetInitSegment(int32_t &flag);
36     DashAdptSetInfo *GetAdptSetInfo();
37     DashAdptSetInfo *GetPreviousAdptSetInfo();
38     DashRepresentationInfo *GetRepresentationByBandwidth(uint32_t bandwidth);
39     DashRepresentationInfo *GetHighRepresentation();
40     DashRepresentationInfo *GetLowRepresentation();
41     std::string GetMime() const;
42     bool IsOnDemand();
43     bool IsHdr();
44 private:
45     void Init();
46     void Clear();
47     void ParseInitSegment();
48     void ParseInitSegmentBySegTmplt();
49     DashAdptSetManager(const DashAdptSetManager &adptSetManager);
50     DashAdptSetManager &operator=(const DashAdptSetManager &adptSetManager);
51 
52 private:
53     int32_t segTmpltFlag_{0}; // indicate the initialization segment is get from SegmentTemplate@Initialization
54     DashList<DashRepresentationInfo *> representationList_;
55     DashUrlType *initSegment_{nullptr};
56     DashAdptSetInfo *previousAdptSetInfo_{nullptr};
57     DashAdptSetInfo *adptSetInfo_{nullptr};
58 };
59 } // namespace HttpPluginLite
60 } // namespace Plugin
61 } // namespace Media
62 } // namespace OHOS
63 #endif // DASH_ADAPTATION_SET_MANAGER_H