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_PERIOD_MANAGER_H 17 #define DASH_PERIOD_MANAGER_H 18 19 #include <cstdint> 20 #include "dash_mpd_def.h" 21 #include "av_common.h" 22 23 namespace OHOS { 24 namespace Media { 25 namespace Plugins { 26 namespace HttpPlugin { 27 class DashPeriodManager { 28 public: 29 DashPeriodManager() = default; 30 explicit DashPeriodManager(DashPeriodInfo *period); 31 ~DashPeriodManager(); 32 33 bool Empty() const; 34 void Reset(); 35 void SetPeriodInfo(DashPeriodInfo *period); 36 void GetBaseUrlList(std::list<std::string> &baseUrlList); 37 void GetAdptSetsByStreamType(DashVector<DashAdptSetInfo *> &adptSetInfo, MediaAVCodec::MediaType streamType); 38 DashUrlType *GetInitSegment(int32_t &flag); 39 DashPeriodInfo *GetPeriod(); 40 DashPeriodInfo *GetPreviousPeriod(); 41 42 private: 43 void Init(); 44 void Clear(); 45 void ParseAdptSetList(DashList<DashAdptSetInfo *> adptSetList); 46 void ParseAdptSetTypeByMime(std::string mimeType, DashAdptSetInfo *adptSetInfo); 47 void ParseAdptSetTypeByComp(DashList<DashContentCompInfo *> contentCompList, DashAdptSetInfo *adptSetInfo); 48 void ParseInitSegment(); 49 void ParseInitSegmentBySegTmplt(); 50 DashPeriodManager(const DashPeriodManager &period); 51 DashPeriodManager &operator=(const DashPeriodManager &period); 52 53 private: 54 static constexpr const char *const SUBTITLE_MIME_APPLICATION = "application"; 55 static constexpr const char *const SUBTITLE_MIME_TEXT = "text"; 56 static constexpr const char *const AUDIO_MIME_TYPE = "audio"; 57 static constexpr const char *const VIDEO_MIME_TYPE = "video"; 58 59 DashPeriodInfo *periodInfo_{nullptr}; 60 DashPeriodInfo *previousPeriodInfo_{nullptr}; 61 DashUrlType *initSegment_{nullptr}; 62 int32_t segTmpltFlag_{0}; // indicate the initialization segment is get from SegmentTemplate@Initialization 63 std::string subtitleMimeType_; // mimeType of subtitle such as application/mp4 text/vtt 64 DashVector<DashAdptSetInfo *> videoAdptSetsVector_; 65 DashVector<DashAdptSetInfo *> audioAdptSetsVector_; 66 DashVector<DashAdptSetInfo *> subtitleAdptSetsVector_; 67 }; 68 } // namespace HttpPluginLite 69 } // namespace Plugin 70 } // namespace Media 71 } // namespace OHOS 72 #endif // DASH_PERIOD_MANAGER_H