• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_AVDEMUXER_H
17 #define NATIVE_AVDEMUXER_H
18 
19 #include <stdint.h>
20 #include "native_avcodec_base.h"
21 #include "native_averrors.h"
22 #include "native_avmemory.h"
23 #include "native_avsource.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 typedef struct OH_AVDemuxer OH_AVDemuxer;
30 
31 /**
32  * @brief Creates an OH_AVDemuxer instance for getting samples from source.
33  * Free the resources of the instance by calling OH_AVDemuxer_Destroy.
34  * @syscap SystemCapability.Multimedia.Media.Spliter
35  * @param source Pointer to an OH_AVSource instance.
36  * @return Returns a pointer to an OH_AVDemuxer instance
37  * @since 10
38 */
39 OH_AVDemuxer *OH_AVDemuxer_CreateWithSource(OH_AVSource *source);
40 
41 /**
42  * @brief Destroy the OH_AVDemuxer instance and free the internal resources.
43  * The same instance can only be destroyed once. The destroyed instance
44  * should not be used before it is created again. It is recommended setting
45  * the instance pointer to NULL right after the instance is destroyed successfully.
46  * @syscap SystemCapability.Multimedia.Media.Spliter
47  * @param demuxer Pointer to an OH_AVDemuxer instance.
48  * @return Returns AV_ERR_OK if the execution is successful,
49  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
50  * @since 10
51 */
52 OH_AVErrCode OH_AVDemuxer_Destroy(OH_AVDemuxer *demuxer);
53 
54 /**
55  * @brief The specified track is selected and the demuxer will read samples from
56  * this track. Multiple tracks are selected by calling this interface multiple times
57  * with different track indexes. Only the selected tracks are valid when calling
58  * OH_AVDemuxer_ReadSample to read samples. The interface returns AV_ERR_OK and the
59  * track is selected only once if the same track is selected multiple times.
60  * @syscap SystemCapability.Multimedia.Media.Spliter
61  * @param demuxer Pointer to an OH_AVDemuxer instance.
62  * @param trackIndex The index of the selected track.
63  * @return Returns AV_ERR_OK if the execution is successful,
64  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
65  * @since 10
66 */
67 OH_AVErrCode OH_AVDemuxer_SelectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex);
68 
69 /**
70  * @brief The specified selected track is unselected. The unselected track's sample
71  * can not be read from demuxer. Multiple selected tracks are unselected by calling
72  * this interface multiple times with different track indexes. The interface returns
73  * AV_ERR_OK and the track is unselected only once if the same track is unselected
74  * multiple times.
75  * @syscap SystemCapability.Multimedia.Media.Spliter
76  * @param demuxer Pointer to an OH_AVDemuxer instance.
77  * @param trackIndex The index of the unselected track.
78  * @return Returns AV_ERR_OK if the execution is successful,
79  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
80  * @since 10
81 */
82 OH_AVErrCode OH_AVDemuxer_UnselectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex);
83 
84 /**
85  * @brief Get the current encoded sample and sample-related information from the specified
86  * track. The track index must be selected before reading sample. The demuxer will advance
87  * automatically after calling this interface.
88  * @syscap SystemCapability.Multimedia.Media.Spliter
89  * @param demuxer Pointer to an OH_AVDemuxer instance.
90  * @param trackIndex The index of the track from which read an encoded sample.
91  * @param sample The OH_AVMemory handle pointer to the buffer storing the sample data.
92  * @param info The OH_AVCodecBufferAttr handle pointer to the buffer storing sample information.
93  * @return Returns AV_ERR_OK if the execution is successful,
94  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
95  * @since 10
96 */
97 OH_AVErrCode OH_AVDemuxer_ReadSample(OH_AVDemuxer *demuxer, uint32_t trackIndex,
98     OH_AVMemory *sample, OH_AVCodecBufferAttr *info);
99 
100 /**
101  * @brief All selected tracks seek near to the requested time according to the seek mode.
102  * @syscap SystemCapability.Multimedia.Media.Spliter
103  * @param demuxer Pointer to an OH_AVDemuxer instance.
104  * @param millisecond The millisecond for seeking, the timestamp is the position of
105  * the file relative to the start of the file.
106  * @param mode The mode for seeking. See {@link OH_AVSeekMode}.
107  * @return Returns AV_ERR_OK if the execution is successful,
108  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
109  * @since 10
110 */
111 OH_AVErrCode OH_AVDemuxer_SeekToTime(OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVSeekMode mode);
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif // NATIVE_AVDEMUXER_H
118