• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 /**
18  * @addtogroup LowPowerVideoSink
19  * @{
20  *
21  * @brief The LowPowerVideoSink submodule provides variables, properties, and functions
22  * for lowpower video sink.
23  *
24  * @since 20
25  */
26 
27 /**
28  * @file lowpower_video_sink_base.h
29  *
30  * @brief Declare the Native API used for lowpower video sink.
31  *
32  * @library liblowpower_avsink.so
33  * @kit MediaKit
34  * @syscap SystemCapability.Multimedia.Media.LowPowerAVSink
35  * @since 20
36  */
37 
38 #ifndef NATIVE_LOWPOWER_VIDEOSINK_BASH_H
39 #define NATIVE_LOWPOWER_VIDEOSINK_BASH_H
40 
41 #include <stdint.h>
42 #include <stdbool.h>
43 #include "native_avformat.h"
44 #include "lowpower_avsink_base.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /**
51  * @brief Forward declaration of OH_LowPowerVideoSink.
52  *
53  * @since 20
54  */
55 typedef struct OH_LowPowerVideoSink OH_LowPowerVideoSink;
56 
57 /**
58  * @brief Forward declaration of OH_LowPowerVideoSinkCallback.
59  *
60  * @since 20
61  */
62 typedef struct OH_LowPowerVideoSinkCallback OH_LowPowerVideoSinkCallback;
63 
64 /**
65  * @brief When the OH_LowPowerVideoSink instance report to need data, the function pointer will be called
66  * to request data.
67  *
68  * @param {OH_LowPowerVideoSink*} sink OH_LowPowerVideoSink instance
69  * @param {OH_AVSamplesBuffer*} buffer OH_AVSamplesBuffer instance that will be written in
70  * @param {void*} userData User specific data
71  * @since 20
72  */
73 typedef void (*OH_LowPowerVideoSink_OnDataNeeded)(
74     OH_LowPowerVideoSink* sink,
75     OH_AVSamplesBuffer* buffer,
76     void *userData);
77 
78 /**
79  * @brief When an error occurs in the running of the OH_LowPowerVideoSink instance, the function pointer will be called
80  * to report specific error information.
81  *
82  * @param {OH_LowPowerVideoSink*} sink OH_LowPowerVideoSink instance
83  * @param {OH_AVErrCode} errorCode The error code returned when an error occurs during service operation.
84  * See the definition of {@OH_AVErrCode}
85  * @param {const char*} errorMsg string of Error description information returned when an error occurs
86  * during service operation
87  * @param {void*} userData User specific data
88  * @since 20
89  */
90 typedef void (*OH_LowPowerVideoSink_OnError)(
91     OH_LowPowerVideoSink* sink,
92     OH_AVErrCode errCode,
93     const char* errMsg,
94     void* userData);
95 
96 /**
97  * @brief When the OH_LowPowerVideoSink instance report target video frame arrived, the function pointer will be called.
98  *
99  * @param {OH_LowPowerVideoSink*} sink OH_LowPowerVideoSink instance
100  * @param {const int64_t} targetPts Target pts of renderred frame
101  * @param {const bool} isTimeout If wait target pts timeout, it is false
102  * @param {void*} userData User specific data
103  * @since 20
104  */
105 typedef void (*OH_LowPowerVideoSink_OnTargetArrived)(
106     OH_LowPowerVideoSink* sink,
107     const int64_t targetPts,
108     const bool isTimeout,
109     void* userData);
110 
111 /**
112  * @brief When the OH_LowPowerVideoSink instance report first frame renderred, the function pointer will be called.
113  *
114  * @param {OH_LowPowerVideoSink*} sink OH_LowPowerVideoSink instance
115  * @param {void*} userData User specific data
116  * @since 20
117  */
118 typedef void (*OH_LowPowerVideoSink_OnRenderStarted)(OH_LowPowerVideoSink* sink, void* userData);
119 
120 /**
121  * @brief When the OH_LowPowerVideoSink instance reports that the parameters of the video stream have changed,
122  * the application is notified through this function
123  *
124  * @param {OH_LowPowerVideoSink*} sink OH_LowPowerVideoSink instance
125  * @param {OH_AVFormat*} format Carrying changing parameters and corresponding values
126  * @param {void*} userData User specific data
127  * @since 20
128  */
129 typedef void (*OH_LowPowerVideoSink_OnStreamChanged)(OH_LowPowerVideoSink* sink, OH_AVFormat* format, void* userData);
130 
131 /**
132  * @brief When the first frame of the OH_LowPowerVideoSink instance is decoded successfully, this function pointer
133  * will be called.
134  *
135  * @param {OH_LowPowerVideoSink*} sink OH_LowPowerVideoSink instance
136  * @param {void*} userData User specific data
137  * @since 20
138  */
139 typedef void (*OH_LowPowerVideoSink_OnFirstFrameDecoded)(OH_LowPowerVideoSink* sink, void* userData);
140 
141 /**
142  * @brief When the OH_LowPowerVideoSinkinstance play to end of stream, the function pointer will be called
143  * to report play completed event.
144  *
145  * @param {OH_LowPowerVideoSink*} sink OH_LowPowerVideoSink instance
146  * @param {void*} userData User specific data
147  * @since 20
148  */
149 typedef void (*OH_LowPowerVideoSink_OnEos)(OH_LowPowerVideoSink* sink, void* userData);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 #endif // NATIVE_LOWPOWER_VIDEOSINK_BASH_H
155 
156 /** @} */