DtvKit_ATSC3.0
Loading...
Searching...
No Matches
atsc_plf_frontend_hwcontrol.h
Go to the documentation of this file.
1#ifndef ATSC_PLF_FRONTEND_HWCONTROL_H_
2#define ATSC_PLF_FRONTEND_HWCONTROL_H_
3
4#include <stdbool.h>
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8#include <pthread.h>
9#include <unistd.h>
10#include <termios.h>
11#include <fcntl.h>
12#include <thread>
13#include <poll.h>
14
15#include "atsc_basetype.h"
16
24#define FRONTEND_MODE_ATSC_10 0
25
29#define FRONTEND_MODE_ATSC_30 1
30
34#define FRONTEND_MAX_DEVICES 2
35
39typedef void(*DataCallback)(void *pParentInst,int32_t iPacketType,
40 int32_t iPlpID,uint8_t *pData,
41 int32_t iLen, uint32_t iHdrLen);
42
43
49{
50public:
57 CFeHwCtrl(int iDevId);
58
66
73 int32_t StopInput(void);
74
81 int32_t StartInput(void);
82
89 int32_t SetCallback(void *pParent,DataCallback dataCB);
90
97 int32_t GetStatus(int32_t *pSnr,int32_t *pRssi, int32_t *pEas,int32_t *pLock);
98
105 int32_t SetProperties(int32_t iMode,uint32_t iFreq,int32_t iBandwidth, int32_t iPlp);
106
113 int32_t GetProperty(int32_t *pMode,uint32_t *pFreq,int *pBandwidth, int32_t *pPlp);
114
115protected:
116
120#define FRONTEND_TRANS_SIZE (65536)
121
125#define FRONTEND_ARRAY_SIZE 128
126
130#define FRONTEND_MAX_ALP_DATA_SIZE 2048
131
135#define FRONTEND_DATA_BUFFER_SIZE (188*170)
136
137pthread_t mCaptureThread;
138pthread_mutex_t mCaptureMutex;
144typedef struct
145{
146 bool bLock;
147 int32_t iSnr;
148 int32_t iRssi;
149 int32_t iEas;
151
155typedef struct
156{
157 int32_t iFd;
158 int32_t iFreq;
159 int32_t iPlpid;
160 int32_t iDevId;
161 int32_t iSystem;
162 int32_t iDemuxFd;
163 int32_t iIsLocked;
164 int32_t iIsOpened;
165 int32_t iBandwidth;
166 int32_t iIsRunning;
168 pollfd stPfd;
169} sFeHw_t;
170
172void* mpParent;
174DataCallback pCallbackHandler;
176int32_t m_Mode;
177int32_t m_State;
178int32_t m_CurPlp;
179int32_t m_BitCount;
180int32_t m_CurIndex;
181int32_t m_TSRemain;
182int32_t m_RecvState;
183int32_t m_SyncPoint;
184int32_t m_AlpRemain;
186uint8_t * m_pData;
187uint8_t * m_pAlpData;
188uint8_t * m_pResData;
189uint8_t * m_pInputBuf;
190uint8_t * m_pRemainData;
192int32_t mBitrate;
193int32_t mAvgBitrate;
201static void * DataReadInput(void* a_pParam);
202
209void DataDeInit( void );
210
217void SetByteAlign( void );
218
225uint32_t GetBitCount(void );
226
233void SkipData(int iBitCount);
234
241int32_t SendData(sFeHw_t * pHan);
242
249int32_t StopDemux (sFeHw_t * pHan);
250
257int32_t StartDemux (sFeHw_t * pHan);
258
266
273uint32_t GetData(int32_t iBitSize);
274
281int32_t InitFrontend (sFeHw_t * pHan);
282
289int32_t CloseFrontend (sFeHw_t * pHan);
290
297void DataInit(unsigned char *pData);
298
306
314
321void ThreadCleanUp(void * pCleanHandle);
322
330int32_t ProcessInput(unsigned char *pTsData);
331
338void ProcessALP(unsigned char *pDataBuf,int32_t iLen);
339
347int32_t ProcessTS(unsigned char * pDataBuf, int32_t iLen);
348
355int32_t ProcessAlpData(unsigned char * pDataBuf ,int32_t iLen);
356
363int32_t CheckFrontend (sFeHw_t * pHan,sFeHwStatus_t *pTunerProp);
364};
365
366#endif /* ATSC_PLF_FRONTEND_HWCONTROL_H_ */
Definition atsc_plf_frontend_hwcontrol.h:49
pthread_mutex_t mCaptureMutex
Definition atsc_plf_frontend_hwcontrol.h:138
int32_t m_CurPlp
Definition atsc_plf_frontend_hwcontrol.h:178
uint8_t * m_pAlpData
Definition atsc_plf_frontend_hwcontrol.h:187
static void * DataReadInput(void *a_pParam)
To get the data from driver frontend via CaptureThreadHandler().
int32_t m_BitCount
Definition atsc_plf_frontend_hwcontrol.h:179
int32_t StopInput(void)
To Stop the demux.
int32_t SendData(sFeHw_t *pHan)
Read the data from driver frontend and provide the data for formation of TS,ALP.
int32_t mAvgBitrate
Definition atsc_plf_frontend_hwcontrol.h:193
int32_t ProcessInput(unsigned char *pTsData)
Process the received input data of TS and provide the data for ALP via ProcessALP() by calculating th...
int32_t m_RecvState
Definition atsc_plf_frontend_hwcontrol.h:182
~CFeHwCtrl()
Stop the demux and close frontend. And free the allocated memory for ALP,Frontend.
int32_t m_Mode
Definition atsc_plf_frontend_hwcontrol.h:176
void SetByteAlign(void)
To adjust the m_BitCount member to ensure it is aligned to the nearest byte boundary.
int32_t SetFrontendParams(sFeHw_t *pHan)
To set the properties for frontend to driver.
uint8_t * m_pRemainData
Definition atsc_plf_frontend_hwcontrol.h:190
int32_t StopDemux(sFeHw_t *pHan)
To stop the PES filter demux.
int32_t mBitrate
Definition atsc_plf_frontend_hwcontrol.h:192
int32_t m_SyncPoint
Definition atsc_plf_frontend_hwcontrol.h:183
int32_t CloseFrontend(sFeHw_t *pHan)
To close the frontend and demux handle.
sFeHw_t hDevice
Definition atsc_plf_frontend_hwcontrol.h:171
void DataInit(unsigned char *pData)
Assign the INIT ALP data to the param m_pData.
void ThreadCleanUp(void *pCleanHandle)
To close the Frontend.
uint8_t * m_pInputBuf
Definition atsc_plf_frontend_hwcontrol.h:189
int32_t ProcessTS(unsigned char *pDataBuf, int32_t iLen)
Process the sync byte of TS data and passed the data as remaining data for ALP formation via ProcessI...
uint32_t GetData(int32_t iBitSize)
Calculated and return the data length represented in bit calc.
void * CaptureThreadHandler(void)
To get the data from driver frontend via SendData().
DataCallback pCallbackHandler
Definition atsc_plf_frontend_hwcontrol.h:174
uint8_t * m_pResData
Definition atsc_plf_frontend_hwcontrol.h:188
void SkipData(int iBitCount)
Skip the data based on m_BitCount which is used in GetData().
int32_t m_TSRemain
Definition atsc_plf_frontend_hwcontrol.h:181
pthread_t mCaptureThread
Definition atsc_plf_frontend_hwcontrol.h:137
void * mpParent
Definition atsc_plf_frontend_hwcontrol.h:172
int32_t StartInput(void)
To Start the demux for collecting the data.
int32_t m_State
Definition atsc_plf_frontend_hwcontrol.h:177
int32_t StartDemux(sFeHw_t *pHan)
To start the PES filter with immediate start to collect the data after tuner lock.
int32_t ProcessAlpData(unsigned char *pDataBuf, int32_t iLen)
Parsed the ALP data based on the header formation and passed the data via callback(pCallbackHandler).
void CancelReaderThread(sFeHw_t *pHan)
To close the Frontend.
int32_t InitFrontend(sFeHw_t *pHan)
To Open the driver API - Frontend.
int32_t m_CurIndex
Definition atsc_plf_frontend_hwcontrol.h:180
int32_t m_AlpRemain
Definition atsc_plf_frontend_hwcontrol.h:184
uint8_t * m_pData
Definition atsc_plf_frontend_hwcontrol.h:186
void DataDeInit(void)
Set the m_BitCount as 0.
uint32_t GetBitCount(void)
Get the m_BitCount value for process the get/skip data.
void ProcessALP(unsigned char *pDataBuf, int32_t iLen)
Passed the data for ALP via ProcessAlpData() for the received length.
int32_t CheckFrontend(sFeHw_t *pHan, sFeHwStatus_t *pTunerProp)
To check the frontend status such as Signal strength,Frequency, Lock status,SNR,Bitrate.
Definition atsc_plf_frontend_hwcontrol.h:145
int32_t iRssi
Definition atsc_plf_frontend_hwcontrol.h:148
bool bLock
Definition atsc_plf_frontend_hwcontrol.h:146
int32_t iSnr
Definition atsc_plf_frontend_hwcontrol.h:147
int32_t iEas
Definition atsc_plf_frontend_hwcontrol.h:149
Definition atsc_plf_frontend_hwcontrol.h:156
int32_t iIsInitialised
Definition atsc_plf_frontend_hwcontrol.h:167
int32_t iIsRunning
Definition atsc_plf_frontend_hwcontrol.h:166
pollfd stPfd
Definition atsc_plf_frontend_hwcontrol.h:168
int32_t iSystem
Definition atsc_plf_frontend_hwcontrol.h:161
int32_t iFreq
Definition atsc_plf_frontend_hwcontrol.h:158
int32_t iDemuxFd
Definition atsc_plf_frontend_hwcontrol.h:162
int32_t iIsLocked
Definition atsc_plf_frontend_hwcontrol.h:163
int32_t iDevId
Definition atsc_plf_frontend_hwcontrol.h:160
int32_t iPlpid
Definition atsc_plf_frontend_hwcontrol.h:159
int32_t iBandwidth
Definition atsc_plf_frontend_hwcontrol.h:165
int32_t iFd
Definition atsc_plf_frontend_hwcontrol.h:157
int32_t iIsOpened
Definition atsc_plf_frontend_hwcontrol.h:164