1 /* 2 * Copyright (C) 2021 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 AVCONTAINER_TYPES_H 17 #define AVCONTAINER_TYPES_H 18 19 #include "nocopyable.h" 20 #include "av_common.h" 21 #include "avcodec_common.h" 22 23 namespace OHOS { 24 namespace Media { 25 /** 26 * @brief Enumerates the container format types. 27 */ 28 class ContainerFormatType { 29 public: 30 static constexpr std::string_view CFT_MPEG_4A = "m4a"; 31 static constexpr std::string_view CFT_MPEG_4 = "mp4"; 32 static constexpr std::string_view CFT_MPEG_TS = "mpeg-ts"; 33 static constexpr std::string_view CFT_MKV = "mkv"; 34 static constexpr std::string_view CFT_WEBM = "webm"; 35 static constexpr std::string_view CFT_OGG = "ogg"; 36 static constexpr std::string_view CFT_WAV = "wav"; 37 static constexpr std::string_view CFT_AAC = "aac"; 38 static constexpr std::string_view CFT_FLAC = "flac"; 39 }; 40 41 /** 42 * @brief Description information of a sample associated a media track. 43 */ 44 struct TrackSampleInfo { 45 /** 46 * @brief the id of track that this sample belongs to. 47 */ 48 uint32_t trackIdx; 49 /** 50 * @brief the presentation timestamp in microseconds. 51 */ 52 int64_t timeUs; 53 /** 54 * @brief the size in bytes. 55 */ 56 uint32_t size; 57 /** 58 * @brief the flags associated with the sample, this 59 * maybe be a combination of multiple {@link AVCodecBufferFlag}. 60 */ 61 AVCodecBufferFlag flags; 62 }; 63 64 class AVContainerMemory : public NoCopyable { 65 public: AVContainerMemory(uint8_t * base,size_t capacity)66 AVContainerMemory(uint8_t *base, size_t capacity) : base_(base), capacity_(capacity) {}; 67 68 ~AVContainerMemory() = default; 69 Base()70 uint8_t *Base() const 71 { 72 return base_; 73 } 74 Data()75 uint8_t *Data() const 76 { 77 return base_ + offset_; 78 } 79 Capacity()80 size_t Capacity() const 81 { 82 return capacity_; 83 } 84 Size()85 size_t Size() const 86 { 87 return size_; 88 } 89 Offset()90 size_t Offset() const 91 { 92 return offset_; 93 } 94 SetRange(size_t offset,size_t size)95 void SetRange(size_t offset, size_t size) 96 { 97 offset_ = offset; 98 size_ = size; 99 } 100 101 private: 102 uint8_t *base_ = nullptr; 103 size_t offset_ = 0; 104 size_t size_ = 0; 105 size_t capacity_ = 0; 106 }; 107 } // namespace Media 108 } // namespace OHOS 109 #endif // AVCONTAINER_TYPES_H 110