1 /* 2 * Copyright (C) 2023 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 NATIVE_AVSOURCE_H 17 #define NATIVE_AVSOURCE_H 18 19 #include <stdint.h> 20 #include "native_avcodec_base.h" 21 #include "native_averrors.h" 22 #include "native_avformat.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef struct OH_AVSource OH_AVSource; 29 30 /** 31 * @brief Creates an OH_AVSource instance that models the media at the URI. 32 * @syscap SystemCapability.Multimedia.Media.Spliter 33 * @param uri An URI for a remote media resource. 34 * @return Returns AV_ERR_OK if the execution is successful, 35 * otherwise returns a specific error code, refer to {@link OH_AVErrCode} 36 * @since 10 37 */ 38 OH_AVSource *OH_AVSource_CreateWithURI(char *uri); 39 40 /** 41 * @brief Creates an OH_AVSource instance that models the media at the FileDescriptor. 42 * @syscap SystemCapability.Multimedia.Media.Spliter 43 * @param fd The fileDescriptor of data source. 44 * @param offset The offset into the file to start reading. 45 * @param size The file size in bytes. 46 * @return Returns AV_ERR_OK if the execution is successful, 47 * otherwise returns a specific error code, refer to {@link OH_AVErrCode} 48 * @since 10 49 */ 50 OH_AVSource *OH_AVSource_CreateWithFD(int32_t fd, int64_t offset, int64_t size); 51 52 /** 53 * @brief Destroy the OH_AVSource instance and free the internal resources. 54 * @syscap SystemCapability.Multimedia.Media.Spliter 55 * @param source Pointer to an OH_AVSource instance. 56 * @return Returns AV_ERR_OK if the execution is successful, 57 * otherwise returns a specific error code, refer to {@link OH_AVErrCode} 58 * @since 10 59 */ 60 OH_AVErrCode OH_AVSource_Destroy(OH_AVSource *source); 61 62 /** 63 * @brief Get the format info of source. 64 * @syscap SystemCapability.Multimedia.Media.Spliter 65 * @param source Pointer to an OH_AVSource instance. 66 * @return Returns the source's format info. 67 * @since 10 68 */ 69 OH_AVFormat *OH_AVSource_GetSourceFormat(OH_AVSource *source); 70 71 /** 72 * @brief Get the format info of track. 73 * @syscap SystemCapability.Multimedia.Media.Spliter 74 * @param source Pointer to an OH_AVSource instance. 75 * @param trackIndex The track index to get format. 76 * @return Returns the track's format info. 77 * @since 10 78 */ 79 OH_AVFormat *OH_AVSource_GetTrackFormat(OH_AVSource *source, uint32_t trackIndex); 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif // NATIVE_AVSOURCE_H