RDK Documentation (Open Sourced RDK Components)
btrMgr_streamInGst.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_streamInGst.h
21  *
22  * @description This file defines bluetooth manager's data streaming interfaces using GStreamer to external BT devices
23  *
24  */
25 #ifndef __BTR_MGR_STREAMIN_GST_H__
26 #define __BTR_MGR_STREAMIN_GST_H__
27 
28 typedef void* tBTRMgrSiGstHdl;
29 
30 
31 #define BTRMGR_AUDIO_INPUT_TYPE_SBC "SBC"
32 #define BTRMGR_AUDIO_INPUT_TYPE_AAC "MP4A-LATM"
33 #define BTRMGR_AUDIO_INPUT_TYPE_PCM "PCM"
34 // Add additional support Audio input types
35 
36 #define BTRMGR_AUDIO_SFMT_SIGNED_8BIT "S8"
37 #define BTRMGR_AUDIO_SFMT_SIGNED_LE_16BIT "S16LE"
38 #define BTRMGR_AUDIO_SFMT_SIGNED_LE_24BIT "S24LE"
39 #define BTRMGR_AUDIO_SFMT_SIGNED_LE_32BIT "S32LE"
40 // Add additional sampling formats as supported by Gst SI layer
41 
42 #define BTRMGR_AUDIO_CHANNELMODE_MONO "mono"
43 #define BTRMGR_AUDIO_CHANNELMODE_DUAL "dual"
44 #define BTRMGR_AUDIO_CHANNELMODE_STEREO "stereo"
45 #define BTRMGR_AUDIO_CHANNELMODE_JSTEREO "joint"
46 // Add additional chennel modes as supported by Gst SI layer
47 
48 
49 /**
50  * @addtogroup Stream_In
51  * @{
52  *
53  */
54 
55 typedef enum _eBTRMgrSIGstRet {
56  eBTRMgrSIGstFailure,
57  eBTRMgrSIGstFailInArg,
58  eBTRMgrSIGstSuccess
59 } eBTRMgrSIGstRet;
60 
61 typedef enum _eBTRMgrSIGstStatus {
62  eBTRMgrSIGstStInitialized,
63  eBTRMgrSIGstStDeInitialized,
64  eBTRMgrSIGstStPaused,
65  eBTRMgrSIGstStPlaying,
66  eBTRMgrSIGstStUnderflow,
67  eBTRMgrSIGstStOverflow,
68  eBTRMgrSIGstStCompleted,
69  eBTRMgrSIGstStStopped,
70  eBTRMgrSIGstStWarning,
71  eBTRMgrSIGstStError,
72  eBTRMgrSIGstStUnknown
73 } eBTRMgrSIGstStatus;
74 
75 
76 /* Fptr Callbacks types */
77 typedef eBTRMgrSIGstRet (*fPtr_BTRMgr_SI_GstStatusCb) (eBTRMgrSIGstStatus aeBtrMgrSiGstStatus, void *apvUserData);
78 
79 
80 /* Interfaces */
81 /**
82  * @brief This API initializes the streaming interface.
83  *
84  * Uses gstreamer element "fdsrc" for initialization.
85  *
86  * @param[in] phBTRMgrSiGstHdl Handle to the stream in interface.
87  * @param[in] afpcBSiGstStatus Stream In callback function.
88  * @param[in] apvUserData Data for the callback function.
89  *
90  * @return Returns the status of the operation.
91  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
92  */
93 eBTRMgrSIGstRet BTRMgr_SI_GstInit (tBTRMgrSiGstHdl* phBTRMgrSiGstHdl, fPtr_BTRMgr_SI_GstStatusCb afpcBSiGstStatus, void* apvUserData);
94 
95 /**
96  * @brief This API performs the cleanup operations.
97  *
98  * Cancels the threads that are running within and frees all associated memory.
99  *
100  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
101  *
102  * @return Returns the status of the operation.
103  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
104  */
105 eBTRMgrSIGstRet BTRMgr_SI_GstDeInit (tBTRMgrSiGstHdl hBTRMgrSiGstHdl);
106 
107 /**
108  * @brief This API starts the playback and listens to the events associated with it.
109  *
110  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
111  * @param[in] aiInBufMaxSize Maximum buffer size.
112  * @param[in] aiBTDevFd Input file descriptor.
113  * @param[in] aiBTDevMTU Block size to read.
114  * @param[in] aiBTDevSFreq The Clock rate.
115  *
116  * @return Returns the status of the operation.
117  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
118  */
119 eBTRMgrSIGstRet BTRMgr_SI_GstStart (tBTRMgrSiGstHdl hBTRMgrSiGstHdl, int aiInBufMaxSize, int aiBTDevFd, int aiBTDevMTU, unsigned int aiBTDevSFreq, const char* apcAudioInType);
120 
121 /**
122  * @brief This API stops the current playback and sets the state as NULL.
123  *
124  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
125  *
126  * @return Returns the status of the operation.
127  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
128  */
129 eBTRMgrSIGstRet BTRMgr_SI_GstStop (tBTRMgrSiGstHdl hBTRMgrSiGstHdl);
130 
131 /**
132  * @brief This API pauses the current playback and listens to the events.
133  *
134  * Checks for the current state, if it is in playing state pause state is set.
135  *
136  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
137  *
138  * @return Returns the status of the operation.
139  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
140  */
141 eBTRMgrSIGstRet BTRMgr_SI_GstPause (tBTRMgrSiGstHdl hBTRMgrSiGstHdl);
142 
143 /**
144  * @brief This API resumes the current operation and listens to the events.
145  *
146  * Checks for the current state, if it is in paused state, playing state is set.
147  *
148  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
149  *
150  * @return Returns the status of the operation.
151  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
152  */
153 eBTRMgrSIGstRet BTRMgr_SI_GstResume (tBTRMgrSiGstHdl hBTRMgrSiGstHdl);
154 
155 /**
156  * @brief This API resumes the current operation and listens to the events.
157  *
158  * Checks for the current state, if it is in paused state, playing state is set.
159  *
160  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
161  *
162  * @return Returns the status of the operation.
163  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
164  */
165 eBTRMgrSIGstRet BTRMgr_SI_GstSetVolume (tBTRMgrSiGstHdl hBTRMgrSiGstHdl, unsigned char ui8Volume);
166 
167 /**
168  * @brief This API pushes the buffer to the queue.
169  *
170  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
171  * @param[in] pcInBuf The buffer to be added to the queue.
172  * @param[in] aiInBufSize Buffer size.
173  *
174  * @return Returns the status of the operation.
175  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
176  */
177 eBTRMgrSIGstRet BTRMgr_SI_GstSendBuffer (tBTRMgrSiGstHdl hBTRMgrSiGstHdl, char* pcInBuf, int aiInBufSize);
178 
179 /**
180  * @brief This API is used to push EOS(End of Stream) to the queue.
181  *
182  * @param[in] hBTRMgrSiGstHdl Handle to the stream in interface.
183  *
184  * @return Returns the status of the operation.
185  * @retval eBTRMgrSIGstSuccess on success, appropriate error code otherwise.
186  */
187 eBTRMgrSIGstRet BTRMgr_SI_GstSendEOS (tBTRMgrSiGstHdl hBTRMgrSiGstHdl);
188 /** @} */
189 
190 #endif /* __BTR_MGR_STREAMIN_GST_H__ */
191 
BTRMgr_SI_GstInit
eBTRMgrSIGstRet BTRMgr_SI_GstInit(tBTRMgrSiGstHdl *phBTRMgrSiGstHdl, fPtr_BTRMgr_SI_GstStatusCb afpcBSiGstStatus, void *apvUserData)
This API initializes the streaming interface.
Definition: btrMgr_streamInGst.c:257
BTRMgr_SI_GstStart
eBTRMgrSIGstRet BTRMgr_SI_GstStart(tBTRMgrSiGstHdl hBTRMgrSiGstHdl, int aiInBufMaxSize, int aiBTDevFd, int aiBTDevMTU, unsigned int aiBTDevSFreq, const char *apcAudioInType)
This API starts the playback and listens to the events associated with it.
Definition: btrMgr_streamInGst.c:485
BTRMgr_SI_GstSetVolume
eBTRMgrSIGstRet BTRMgr_SI_GstSetVolume(tBTRMgrSiGstHdl hBTRMgrSiGstHdl, unsigned char ui8Volume)
This API resumes the current operation and listens to the events.
Definition: btrMgr_streamInGst.c:673
BTRMgr_SI_GstSendBuffer
eBTRMgrSIGstRet BTRMgr_SI_GstSendBuffer(tBTRMgrSiGstHdl hBTRMgrSiGstHdl, char *pcInBuf, int aiInBufSize)
This API pushes the buffer to the queue.
Definition: btrMgr_streamInGst.c:698
BTRMgr_SI_GstDeInit
eBTRMgrSIGstRet BTRMgr_SI_GstDeInit(tBTRMgrSiGstHdl hBTRMgrSiGstHdl)
This API performs the cleanup operations.
Definition: btrMgr_streamInGst.c:410
BTRMgr_SI_GstSendEOS
eBTRMgrSIGstRet BTRMgr_SI_GstSendEOS(tBTRMgrSiGstHdl hBTRMgrSiGstHdl)
This API is used to push EOS(End of Stream) to the queue.
Definition: btrMgr_streamInGst.c:751
BTRMgr_SI_GstStop
eBTRMgrSIGstRet BTRMgr_SI_GstStop(tBTRMgrSiGstHdl hBTRMgrSiGstHdl)
This API stops the current playback and sets the state as NULL.
Definition: btrMgr_streamInGst.c:562
BTRMgr_SI_GstResume
eBTRMgrSIGstRet BTRMgr_SI_GstResume(tBTRMgrSiGstHdl hBTRMgrSiGstHdl)
This API resumes the current operation and listens to the events.
Definition: btrMgr_streamInGst.c:635
BTRMgr_SI_GstPause
eBTRMgrSIGstRet BTRMgr_SI_GstPause(tBTRMgrSiGstHdl hBTRMgrSiGstHdl)
This API pauses the current playback and listens to the events.
Definition: btrMgr_streamInGst.c:597