RDK-V AvSync HAL 1.0.0
 
Loading...
Searching...
No Matches
avsync-soc.h
Go to the documentation of this file.
1/*
2 * If not stated otherwise in this file or this component's LICENSE file
3 * the following copyright and licenses apply:
4 *
5 * Copyright 2016 RDK Management
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20/**
21 * @addtogroup HPK Hardware Porting Kit
22 * @{
23 * @par The Hardware Porting Kit
24 * HPK is the next evolution of the well-defined Hardware Abstraction Layer
25 * (HAL), but augmented with more comprehensive documentation and test suites
26 * that OEM or SOC vendors can use to self-certify their ports before taking
27 * them to RDKM for validation or to an operator for final integration and
28 * deployment. The Hardware Porting Kit effectively enables an OEM and/or SOC
29 * vendor to self-certify their own Video Accelerator devices, with minimal RDKM
30 * assistance.
31 *
32 */
33
34/**
35 * @defgroup RDK_AVSYNC RDK AVSync Module
36 * @{
37 * @par Application API Specification
38 * AVSync module provides functionalities for audio/video synchronization
39 * during playback, ensuring proper alignment and timing between the streams.
40 * Provides API defines the structures and functions for the RDK HAL AVSync.
41 *
42 */
43
44/**
45 * @defgroup RDK_AVSYNC_HAL RDK AVSync HAL
46 * @{
47 */
48
49/**
50 * @defgroup AVSYNC_SOC_H AvSync SOC Header
51 * @{
52 *
53 * @par Application API Specification
54 * AVSync module provides functionalities for audio/video synchronization
55 * during playback, ensuring proper alignment and timing between the streams.
56 * Provides API defines the structures and functions for the RDK HAL AVSync.
57 *
58 */
59
60/**
61 * @file avsync-soc.h
62 *
63 * @brief RDK HAL AVSync Public API
64 *
65 * This file defines the structures and functions for the RDK HAL AVSync
66 *
67 * @par Abbreviations
68 * - HAL: Hardware Abstraction Layer
69 * - AV Sync: Audio Video Synchronization
70 * - API: Application Programming Interface
71 * - SoC: System on Chip
72 * - pts: Presentation timestamp
73 *
74 */
75
76#ifndef __AVSYNC_H__
77#define __AVSYNC_H__
78
79#include <stdint.h>
80#include <stdbool.h>
81
82/**
83 * @struct AVSyncVideoFrame_
84 *
85 * @brief This structure is to encapsulate information related to a video
86 * frame's metadata.
87 */
88typedef struct AVSyncVideoFrame_
89{
90 void* context; /**< Pointer to additional context data associated
91 with the video frame's metadata */
92 void* sync; /**< Pointer to synchronization data or object
93 associated with the video frame's metadata */
94 void* videoFrame; /**< Pointer to the video frame's metadata */
95 void* syncFrame; /**< Pointer to synchronization frame */
96 uint32_t pts; /**< Presentation timestamp of the video frame */
97 uint32_t duration; /**< Duration of the video frame */
98
100
101
102/**
103 * @brief Frame delete callback prototype
104 */
105typedef void (*AVSyncFrameFree)(AVSyncVideoFrame * frame);
106
107
108/**
109 * @brief Initializes AV Sync session
110 *
111 * This function initializes AV Sync session and returns a pointer to an AVSync
112 * object used for audio-video synchronization.
113 *
114 * @param [in] refreshRate - The display refresh rate in hertz
115 * Valid range: 1Hz to 1000Hz
116 * @param [in] syncType - The type of syncronization to use
117 * Valid range: 0 to maximum number of syncType
118 * @param [out] sessionId - A pointer to an integer that will be set to the ID
119 * of the avsync session.
120 * @param [out] session - A pointer to an integer that will be set to the
121 * file descriptor of the avsync session
122 *
123 * @return void*
124 * @retval handle for avsync module or null for failure
125 *
126 */
127void* avsync_soc_init( int refreshRate, int syncType, int *sessionId, int* session );
128
129
130/**
131 * @brief Terminates AV Sync session
132 *
133 * This function is used to terminate and clean up resources associated with an
134 * AVSync object.
135 *
136 * @param [in] sync - A pointer to the AVSync structure that was created by
137 * the avsync_soc_init() function
138 * @param [in] session - The file descriptor of the avsync session
139 *
140 * @return void
141 *
142 * @pre avsync_soc_init() must be called before calling this API
143 *
144 */
145void avsync_soc_term( void* sync, int session );
146
147
148/**
149 * @brief Sets Mode for AV Sync session
150 *
151 * This function is used to set the synchronization mode for an AVSync object.
152 * Possible modes are Video Master, Audio Master and Program Clock Reference
153 * Master.
154 *
155 * @param [in] sync - A pointer to the AVSync structure that was created by the
156 * avsync_soc_init() function
157 * @param [in] type - The new mode to set. Possible values are: 0, 1, 2
158 *
159 * @return int - The status of the operation
160 * @retval 0 if successful, -1 otherwise
161 *
162 * @pre avsync_soc_init() must be called before calling this API
163 *
164 */
165int avsync_soc_set_mode( void* sync, int type );
166
167
168/**
169 * @brief Registers the callback to free the allocated video frames and
170 * metadata.
171 *
172 * This function is used to set the frame free callback function for an AVSync
173 * object.
174 *
175 * @param [in] sync - A pointer to the AVSync structure that was created by
176 * the avsync_soc_init() function
177 * @param [in] freeCB - A pointer to the AVSyncFrameFree structure
178 *
179 * @return void
180 *
181 * @pre avsync_soc_init() must be called before calling this API
182 *
183 * @see avsync_soc_init()
184 *
185 */
187
188
189/**
190 * @brief Push a video frame to the AVSync module.
191 *
192 * This function is used to push a video frame to the AVSync module for
193 * synchronization.
194 *
195 * @param [in] sync - A pointer to the AVSync structure that was created by the
196 * avsync_soc_init() function
197 * @param [in] f - A pointer to the AVSyncVideoFrame structure that contains
198 * the frame metadata. Valid value: any non-zero value
199 *
200 * @return bool - The status of the operation
201 * @retval true if successful, false otherwise
202 *
203 * @see AVSyncVideoFrame_
204 *
205 * @pre avsync_soc_init() must be called before calling this API
206 *
207 */
209
210
211/**
212 * @brief Pop a video frame from the AVSync module.
213 *
214 * This function is used to pop/retrieve a video frame from the AVSync module's
215 * frame queue.
216 *
217 * @param [in] sync - A pointer to the AVSync structure that was created by the
218 * avsync_soc_init() function
219 *
220 * @return - AVSyncVideoFrame*
221 * @retval A pointer to the AVSyncVideoFrame structure that contains
222 * the frame metadata. Valid value: any non-zero value
223 *
224 * @see AVSyncVideoFrame_, avsync_soc_set_interval(), avsync_soc_push_frame()
225 *
226 * @pre avsync_soc_init() must be called before calling this API
227 * @pre avsync_soc_push_frame() must be called before calling this API
228 *
229 */
231
232
233/**
234 * @brief Sets playback rate for AV Sync session
235 *
236 * This function is used to set the playback rate/speed of an AVSync object
237 *
238 * @param [in] sync - A pointer to the AVSync structure that was created by the
239 * avsync_soc_init() function
240 * @param [in] rate - is the playback rate. Valid range: 0.0 to 256.0
241 *
242 * @return void
243 *
244 * @pre avsync_soc_init() must be called before calling this API
245 *
246 */
247void avsync_soc_set_rate( void* sync, float rate );
248
249
250/**
251 * @brief Pauses or resume AV Sync session
252 *
253 * This function is used to pause or resume playback of an AVSync object.
254 *
255 * @param [in] sync - A pointer to the AVSync structure that was created by
256 * the avsync_soc_init() function
257 * @param [in] pause - a boolean value that indicates whether to pause (true)
258 * or resume (false) playback
259 *
260 * @return void
261 *
262 * @pre avsync_soc_init() must be called before calling this API
263 * @pre avsync_soc_set_rate() must be called before calling this API
264 *
265 * @see avsync_soc_set_rate()
266 *
267 */
268void avsync_soc_pause( void* sync, bool pause );
269
270
271/**
272 * @brief Sets vsync interval for AV Sync session
273 *
274 * This function is used to set the interval between vertical synchronization
275 * (vsync interval) events for the AVSync module.
276 *
277 * @param [in] sync - A pointer to the AVSync structure that was created by
278 * the avsync_soc_init() function
279 * @param [in] interval - the desired interval between vsync events. Valid range: 1-1000 milliseconds
280 *
281 * @return void
282 *
283 * @pre avsync_soc_init() must be called before calling this API
284 *
285 */
286void avsync_soc_set_interval( void* sync, uint32_t interval );
287
288
289/**
290 * @brief Signals EOS for AV Sync session
291 *
292 * This function is used to signal the end of stream(EOS) to the AVSync module.
293 *
294 * @param [in] sync - A pointer to the AVSync structure that was created by the
295 * avsync_soc_init() function
296 *
297 * @return void
298 *
299 * @pre avsync_soc_init() must be called before calling this API
300 *
301 */
302void avsync_soc_eos( void* sync );
303
304
305#endif // End of __AVSYNC_H__
306
307/** @} */ // End of AVSYNC_SOC_H
308/** @} */ // End of RDK_AVSYNC_HAL
309/** @} */ // End of RDK_AVSYNC
310/** @} */ // End of HPK
void(* AVSyncFrameFree)(AVSyncVideoFrame *frame)
Frame delete callback prototype.
Definition avsync-soc.h:105
int avsync_soc_set_mode(void *sync, int type)
Sets Mode for AV Sync session.
AVSyncVideoFrame * avsync_soc_pop_frame(void *sync)
Pop a video frame from the AVSync module.
void avsync_soc_free_frame_callback(void *sync, AVSyncFrameFree *freeCB)
Registers the callback to free the allocated video frames and metadata.
bool avsync_soc_push_frame(void *sync, AVSyncVideoFrame *f)
Push a video frame to the AVSync module.
void avsync_soc_eos(void *sync)
Signals EOS for AV Sync session.
void avsync_soc_pause(void *sync, bool pause)
Pauses or resume AV Sync session.
void * avsync_soc_init(int refreshRate, int syncType, int *sessionId, int *session)
Initializes AV Sync session.
void avsync_soc_set_interval(void *sync, uint32_t interval)
Sets vsync interval for AV Sync session.
struct AVSyncVideoFrame_ AVSyncVideoFrame
void avsync_soc_set_rate(void *sync, float rate)
Sets playback rate for AV Sync session.
void avsync_soc_term(void *sync, int session)
Terminates AV Sync session.
This structure is to encapsulate information related to a video frame's metadata.
Definition avsync-soc.h:89
uint32_t pts
Definition avsync-soc.h:96
uint32_t duration
Definition avsync-soc.h:97
void * sync
Definition avsync-soc.h:92
void * syncFrame
Definition avsync-soc.h:95
void * videoFrame
Definition avsync-soc.h:94
void * context
Definition avsync-soc.h:90