RDK Documentation (Open Sourced RDK Components)
btrMgr_streamOutGst.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * 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  * @file btrMgr_streamOutGst.h
21  *
22  * @description This file defines bluetooth manager's data streaming interfaces using GStreamer to external BT devices
23  *
24  */
25 
26 /**
27  * @addtogroup Stream_Out
28  * @{
29  *
30  */
31 
32 #ifndef __BTR_MGR_STREAMOUT_GST_H__
33 #define __BTR_MGR_STREAMOUT_GST_H__
34 
35 typedef void* tBTRMgrSoGstHdl;
36 
37 #define BTRMGR_AUDIO_SFMT_SIGNED_8BIT "S8"
38 #define BTRMGR_AUDIO_SFMT_SIGNED_LE_16BIT "S16LE"
39 #define BTRMGR_AUDIO_SFMT_SIGNED_LE_24BIT "S24LE"
40 #define BTRMGR_AUDIO_SFMT_SIGNED_LE_32BIT "S32LE"
41 // Add additional sampling formats as supported by Gst SO layer
42 
43 #define BTRMGR_AUDIO_CHANNELMODE_MONO "mono"
44 #define BTRMGR_AUDIO_CHANNELMODE_DUAL "dual"
45 #define BTRMGR_AUDIO_CHANNELMODE_STEREO "stereo"
46 #define BTRMGR_AUDIO_CHANNELMODE_JSTEREO "joint"
47 // Add additional chennel modes as supported by Gst SO layer
48 
49 typedef enum _eBTRMgrSOGstRet {
50  eBTRMgrSOGstFailure,
51  eBTRMgrSOGstFailInArg,
52  eBTRMgrSOGstSuccess
53 } eBTRMgrSOGstRet;
54 
55 typedef enum _eBTRMgrSOGstStatus {
56  eBTRMgrSOGstStInitialized,
57  eBTRMgrSOGstStDeInitialized,
58  eBTRMgrSOGstStPaused,
59  eBTRMgrSOGstStPlaying,
60  eBTRMgrSOGstStUnderflow,
61  eBTRMgrSOGstStOverflow,
62  eBTRMgrSOGstStCompleted,
63  eBTRMgrSOGstStStopped,
64  eBTRMgrSOGstStWarning,
65  eBTRMgrSOGstStError,
66  eBTRMgrSOGstStUnknown
67 } eBTRMgrSOGstStatus;
68 
69 
70 /* Fptr Callbacks types */
71 typedef eBTRMgrSOGstRet (*fPtr_BTRMgr_SO_GstStatusCb) (eBTRMgrSOGstStatus aeBtrMgrSoGstStatus, void *apvUserData);
72 
73 
74 /* Interfaces */
75 
76 /**
77  * @brief This API initializes the streaming interface.
78  *
79  * Uses gstreamer element "appsrc" for initialization.
80  *
81  * @param[in] phBTRMgrSoGstHdl Handle to the stream out interface.
82  * @param[in] afpcBSoGstStatus Stream Out callback function.
83  * @param[in] apvUserData Data for the callback function.
84  *
85  * @return Returns the status of the operation.
86  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
87  */
88 eBTRMgrSOGstRet BTRMgr_SO_GstInit (tBTRMgrSoGstHdl* phBTRMgrSoGstHdl, fPtr_BTRMgr_SO_GstStatusCb afpcBSoGstStatus, void* apvUserData);
89 
90 /**
91  * @brief This API performs the cleanup operations.
92  *
93  * Cancels the threads that are running within and frees all associated memory.
94  *
95  * @param[in] hBTRMgrSoGstHdl Handle to the stream out interface.
96  *
97  * @return Returns the status of the operation.
98  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
99  */
100 eBTRMgrSOGstRet BTRMgr_SO_GstDeInit (tBTRMgrSoGstHdl hBTRMgrSoGstHdl);
101 
102 /**
103  * @brief This API starts the playback and listens to the events associated with it.
104  *
105  * @param[in] hBTRMgrSoGstHdl Handle to the stream out interface.
106  * @param[in] apcInFmt Supported formats.
107  * @param[in] ai32InRate Input rate.
108  * @param[in] ai32InChannels Input channels.
109  * @param[in] ai32OutRate Output rate.
110  * @param[in] ai32OutChannels Channels supported.
111  * @param[in] apcOutChannelMode Channel modes.
112  * @param[in] aui8SbcAllocMethod Allocation methods.
113  * @param[in] aui8SbcSubbands Sub bands.
114  * @param[in] aui8SbcBlockLength Blocks.
115  * @param[in] aui8SbcMinBitpool Min bit pool.
116  * @param[in] aui8SbcMaxBitpool Max bit pool.
117  * @param[in] ai32InBufMaxSize Maximum buffer size.
118  * @param[in] ai32BTDevFd Input file descriptor.
119  * @param[in] ai32BTDevMTU Block size to read.
120  *
121  * @return Returns the status of the operation.
122  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
123  */
124 eBTRMgrSOGstRet BTRMgr_SO_GstStart (tBTRMgrSoGstHdl hBTRMgrSoGstHdl,
125  int ai32InBufMaxSize,
126  const char* apcInFmt,
127  int ai32InRate,
128  int ai32InChannels,
129  int ai32OutRate,
130  int ai32OutChannels,
131  const char* apcOutChannelMode,
132  unsigned char aui8SbcAllocMethod,
133  unsigned char aui8SbcSubbands,
134  unsigned char aui8SbcBlockLength,
135  unsigned char aui8SbcMinBitpool,
136  unsigned char aui8SbcMaxBitpool,
137  int ai32BTDevFd,
138  int ai32BTDevMTU);
139 
140 /**
141  * @brief This API stops the current playback and sets the state as NULL.
142  *
143  * @param[in] hBTRMgrSoGstHdl Handle to the stream out interface.
144  *
145  * @return Returns the status of the operation.
146  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
147  */
148 eBTRMgrSOGstRet BTRMgr_SO_GstStop (tBTRMgrSoGstHdl hBTRMgrSoGstHdl);
149 
150 /**
151  * @brief This API pauses the current playback and listens to the events.
152  *
153  * Checks for the current state if it is playing sets the state to pause.
154  *
155  * @param[in] hBTRMgrSoGstHdl Handle to the stream out interface.
156  *
157  * @return Returns the status of the operation.
158  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
159  */
160 eBTRMgrSOGstRet BTRMgr_SO_GstPause (tBTRMgrSoGstHdl hBTRMgrSoGstHdl);
161 
162 /**
163  * @brief This API resumes the current operation and listens to the events.
164  *
165  * Checks for the current state if it is paused sets the state to playing.
166  *
167  * @param[in] hBTRMgrSoGstHdl Handle to the stream out interface.
168  *
169  * @return Returns the status of the operation.
170  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
171  */
172 eBTRMgrSOGstRet BTRMgr_SO_GstResume (tBTRMgrSoGstHdl hBTRMgrSoGstHdl);
173 
174 /**
175  * @brief This API Sets whether the input of current Buffers is Paused.
176  *
177  * Sets the current state, if it is in paused state, with respect to buffer input
178  *
179  * @param[in] hBTRMgrSoGstHdl Handle to the stream in interface.
180  * @param[in] ui8InputPaused Input Buffers Paused.
181  *
182  * @return Returns the status of the operation.
183  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
184  */
185 eBTRMgrSOGstRet BTRMgr_SO_GstSetInputPaused (tBTRMgrSoGstHdl hBTRMgrSoGstHdl, unsigned char ui8InputPaused);
186 
187 /**
188  * @brief This API Sets the volume of current operation and listens to the events.
189  *
190  * Checks for the current state, if it is in paused state, playing state is set.
191  *
192  * @param[in] hBTRMgrSoGstHdl Handle to the stream in interface.
193  * @param[in] ui8Volume Input Volume.
194  *
195  * @return Returns the status of the operation.
196  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
197  */
198 eBTRMgrSOGstRet BTRMgr_SO_GstSetVolume (tBTRMgrSoGstHdl hBTRMgrSoGstHdl, unsigned char ui8Volume);
199 /**
200  * @brief This API Gets the volume of current operation and listens to the events.
201  *
202  * @param[in] hBTRMgrSoGstHdl Handle to the stream in interface.
203  * @param[in] ui8Volume Output Volume.
204  *
205  * @return Returns the status of the operation.
206  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
207  */
208 eBTRMgrSOGstRet BTRMgr_SO_GstGetVolume (tBTRMgrSoGstHdl hBTRMgrSoGstHdl, unsigned char * ui8Volume);
209 /**
210  * @brief This API Sets the Mute of current operation and listens to the events.
211  *
212  * @param[in] hBTRMgrSoGstHdl Handle to the stream in interface.
213  * @param[in] mute Input mute.
214  *
215  * @return Returns the status of the operation.
216  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
217  */
218 eBTRMgrSOGstRet BTRMgr_SO_GstSetMute (tBTRMgrSoGstHdl hBTRMgrSoGstHdl, gboolean mute);
219 /**
220  * @brief This API Gets the Mute of current operation and listens to the events.
221  *
222  * @param[in] hBTRMgrSoGstHdl Handle to the stream in interface.
223  * @param[in] mute Output mute.
224  *
225  * @return Returns the status of the operation.
226  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
227  */
228 eBTRMgrSOGstRet BTRMgr_SO_GstGetMute (tBTRMgrSoGstHdl hBTRMgrSoGstHdl, gboolean *mute);
229 
230 /**
231  * @brief This API pushes the buffer to the queue.
232  *
233  * @param[in] hBTRMgrSoGstHdl Handle to the stream out interface.
234  * @param[in] pcInBuf The buffer to be added to the queue.
235  * @param[in] aiInBufSize Buffer size.
236  *
237  * @return Returns the status of the operation.
238  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
239  */
240 eBTRMgrSOGstRet BTRMgr_SO_GstSendBuffer (tBTRMgrSoGstHdl hBTRMgrSoGstHdl, char* pcInBuf, int aiInBufSize);
241 
242 /**
243  * @brief This API is used to push EOS(End of Stream) to the queue.
244  *
245  * @param[in] hBTRMgrSoGstHdl Handle to the stream out interface.
246  *
247  * @return Returns the status of the operation.
248  * @retval eBTRMgrSOGstSuccess on success, appropriate error code otherwise.
249  */
250 eBTRMgrSOGstRet BTRMgr_SO_GstSendEOS (tBTRMgrSoGstHdl hBTRMgrSoGstHdl);
251 /** @} */
252 
253 #endif /* __BTR_MGR_STREAMOUT_GST_H__ */
254 
BTRMgr_SO_GstDeInit
eBTRMgrSOGstRet BTRMgr_SO_GstDeInit(tBTRMgrSoGstHdl hBTRMgrSoGstHdl)
This API performs the cleanup operations.
Definition: btrMgr_streamOutGst.c:463
BTRMgr_SO_GstResume
eBTRMgrSOGstRet BTRMgr_SO_GstResume(tBTRMgrSoGstHdl hBTRMgrSoGstHdl)
This API resumes the current operation and listens to the events.
Definition: btrMgr_streamOutGst.c:796
BTRMgr_SO_GstSendEOS
eBTRMgrSOGstRet BTRMgr_SO_GstSendEOS(tBTRMgrSoGstHdl hBTRMgrSoGstHdl)
This API is used to push EOS(End of Stream) to the queue.
Definition: btrMgr_streamOutGst.c:1102
BTRMgr_SO_GstSetVolume
eBTRMgrSOGstRet BTRMgr_SO_GstSetVolume(tBTRMgrSoGstHdl hBTRMgrSoGstHdl, unsigned char ui8Volume)
This API Sets the volume of current operation and listens to the events.
Definition: btrMgr_streamOutGst.c:884
BTRMgr_SO_GstGetMute
eBTRMgrSOGstRet BTRMgr_SO_GstGetMute(tBTRMgrSoGstHdl hBTRMgrSoGstHdl, gboolean *mute)
This API Gets the Mute of current operation and listens to the events.
Definition: btrMgr_streamOutGst.c:951
BTRMgr_SO_GstSetInputPaused
eBTRMgrSOGstRet BTRMgr_SO_GstSetInputPaused(tBTRMgrSoGstHdl hBTRMgrSoGstHdl, unsigned char ui8InputPaused)
This API Sets whether the input of current Buffers is Paused.
Definition: btrMgr_streamOutGst.c:828
BTRMgr_SO_GstInit
eBTRMgrSOGstRet BTRMgr_SO_GstInit(tBTRMgrSoGstHdl *phBTRMgrSoGstHdl, fPtr_BTRMgr_SO_GstStatusCb afpcBSoGstStatus, void *apvUserData)
This API initializes the streaming interface.
Definition: btrMgr_streamOutGst.c:300
BTRMgr_SO_GstPause
eBTRMgrSOGstRet BTRMgr_SO_GstPause(tBTRMgrSoGstHdl hBTRMgrSoGstHdl)
This API pauses the current playback and listens to the events.
Definition: btrMgr_streamOutGst.c:764
BTRMgr_SO_GstGetVolume
eBTRMgrSOGstRet BTRMgr_SO_GstGetVolume(tBTRMgrSoGstHdl hBTRMgrSoGstHdl, unsigned char *ui8Volume)
This API Gets the volume of current operation and listens to the events.
Definition: btrMgr_streamOutGst.c:907
BTRMgr_SO_GstStart
eBTRMgrSOGstRet BTRMgr_SO_GstStart(tBTRMgrSoGstHdl hBTRMgrSoGstHdl, int ai32InBufMaxSize, const char *apcInFmt, int ai32InRate, int ai32InChannels, int ai32OutRate, int ai32OutChannels, const char *apcOutChannelMode, unsigned char aui8SbcAllocMethod, unsigned char aui8SbcSubbands, unsigned char aui8SbcBlockLength, unsigned char aui8SbcMinBitpool, unsigned char aui8SbcMaxBitpool, int ai32BTDevFd, int ai32BTDevMTU)
This API starts the playback and listens to the events associated with it.
Definition: btrMgr_streamOutGst.c:547
BTRMgr_SO_GstSetMute
eBTRMgrSOGstRet BTRMgr_SO_GstSetMute(tBTRMgrSoGstHdl hBTRMgrSoGstHdl, gboolean mute)
This API Sets the Mute of current operation and listens to the events.
Definition: btrMgr_streamOutGst.c:930
BTRMgr_SO_GstStop
eBTRMgrSOGstRet BTRMgr_SO_GstStop(tBTRMgrSoGstHdl hBTRMgrSoGstHdl)
This API stops the current playback and sets the state as NULL.
Definition: btrMgr_streamOutGst.c:721
BTRMgr_SO_GstSendBuffer
eBTRMgrSOGstRet BTRMgr_SO_GstSendBuffer(tBTRMgrSoGstHdl hBTRMgrSoGstHdl, char *pcInBuf, int aiInBufSize)
This API pushes the buffer to the queue.
Definition: btrMgr_streamOutGst.c:974