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_REPRESENTATION_MANAGER_H
17 #define DASH_REPRESENTATION_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 DashRepresentationManager {
27 public:
28     explicit DashRepresentationManager(DashRepresentationInfo *representation);
29     DashRepresentationManager() = default;
30     ~DashRepresentationManager();
31 
32     void Reset();
33     void SetRepresentationInfo(DashRepresentationInfo *representation);
34     DashUrlType *GetInitSegment(int32_t &segTmpltFlag);
35     DashRepresentationInfo *GetRepresentationInfo();
36     DashRepresentationInfo *GetPreviousRepresentationInfo();
37 
38 private:
39     void Init();
40     void Clear();
41     void ParseInitSegment();
42     void ParseInitSegmentBySegTmplt();
43 
44     DashRepresentationManager(const DashRepresentationManager &representationManager);
45     DashRepresentationManager &operator=(const DashRepresentationManager &representationManager);
46 
47     DashUrlType *initSegment_{nullptr};
48     DashRepresentationInfo *representationInfo_{nullptr};
49     DashRepresentationInfo *previousRepresentationInfo_{nullptr};
50     int32_t segTmpltFlag_{0}; // indicate the initialization segment is get from SegmentTemplate@Initialization
51 };
52 } // namespace HttpPluginLite
53 } // namespace Plugin
54 } // namespace Media
55 } // namespace OHOS
56 #endif // DASH_REPRESENTATION_MANAGER_H