1 /* 2 * Copyright (c) 2025 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 CJ_AVPLAYER_UTILS_H 17 #define CJ_AVPLAYER_UTILS_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <refbase.h> 22 #include <string> 23 #include "cj_common_ffi.h" 24 #include "player.h" 25 26 #define INVALID_ID (-1) 27 #define MAX_SIZE_OF_MEDIADESCRIPTIONKEY (14) 28 29 namespace OHOS { 30 namespace Media { 31 struct CSubtitleInfo { 32 char *text; 33 int32_t startTime; 34 int32_t duration; 35 }; 36 37 struct CValueType { 38 int32_t number; 39 double dou; 40 char *str; 41 }; 42 43 struct CMediaDescription { 44 char **key; 45 CValueType *value; 46 int64_t size; 47 }; 48 49 struct CArrCMediaDescription { 50 CMediaDescription *head; 51 int64_t size; 52 }; 53 54 struct CArrFloat { 55 float *head; 56 int64_t size; 57 }; 58 59 struct CMediaKeySystemInfo { 60 char *uuid; 61 CArrUI8 pssh; 62 }; 63 64 struct CArrCMediaKeySystemInfo { 65 CMediaKeySystemInfo *head; 66 int64_t size; 67 }; 68 69 struct CAVFileDescriptor { 70 int32_t fd; 71 int64_t offset; 72 int64_t length; 73 }; 74 75 struct CAVDataSrcDescriptor { 76 int64_t fileSize; 77 int64_t callback; 78 }; 79 80 struct CPlaybackInfo { 81 int32_t key; 82 void *value; 83 }; 84 85 struct CArrCPlaybackInfo { 86 CPlaybackInfo *infos; 87 int64_t size; 88 }; 89 90 struct CPlayStrategy { 91 uint32_t preferredWidth; 92 uint32_t preferredHeight; 93 uint32_t preferredBufferDuration; 94 bool preferredHdr; 95 int32_t mutedMediaType; 96 char *preferredAudioLanguage; 97 char *preferredSubtitleLanguage; 98 }; 99 100 bool __attribute__((visibility("default"))) StrToULL(const std::string &str, uint64_t &value); 101 char *MallocCString(const std::string &origin); 102 CArrI32 Convert2CArrI32(const std::vector<int32_t> &arr); 103 CArrFloat Convert2CArrFloat(const std::vector<float> &arr); 104 CSubtitleInfo Convert2CSubtitleInfo(std::string text, int32_t pts, int32_t duration); 105 CMediaDescription Convert2CMediaDescription(const Format trackInfo); 106 CArrCMediaDescription Convert2CArrCMediaDescription(const std::vector<Format> trackInfo); 107 } // namespace Media 108 } // namespace OHOS 109 110 #endif