📄 main.cpp
字号:
if( NULL == fp )
{
return 1;
}
int nRet = 0;
char *pPos = szSDP;
while(1)
{
nRet = fread(pPos,1,1024,fp);
if(nRet<= 0)
{
break;
}
pPos += nRet;
}
fclose(fp);
retLen = pPos -szSDP;
return 0;
}
int main( int argc, char *argv[])
{
if(argc < 2)
{
printf("usage: player filename(*.msf|*.mfs) [SDP File].");
return 0;
}
int err = 0;
char commandid[16];
int DataLength;
DataLength = DABQUEUE_GetReadBlockSize();
pPacketData = (unsigned char *)malloc(DataLength);
memset(&CallBacks, 0, sizeof(PLAY_CALLBACK_ARRAY));
//CallBacks.GetStreamData = NULL;
//CallBacks.GetCMMBMuxFrame = NULL;
g_pControl = IControl::Create();
Assert(g_pControl);
g_pControl->RegisterCallback(&CallBacks);
int x,y;
x = 240;// get the width of current device
y = 320;// get the height of current device
TDisplayParam DisplayPara;
TRECT rc_Screen = {0, 0, x, y};
TRECT rc_Clip = {0, 40, x, x*3/4+40};
DisplayPara.rectScreen = rc_Screen;
DisplayPara.rectClip = rc_Clip;
g_pControl->SetConfig(CFG_DISPLAY_PARAM, &DisplayPara);
////////////////////////////DESCRAMBLER_TY
#ifdef DESCRAMBLER_TY
CallBacks.GetDescrambleMSF = GetDescrambleMSF;
//1或取CA操作函数指针
memset(&g_tCAModuleOperations, 0, sizeof(CA_MODULE_OPERATIONS));
ca_module(&g_tCAModuleOperations);
//2检查CA硬件是否存在
// if(NULL == g_tCAModuleOperations.ca_detect_module
// || CA_OK != g_tCAModuleOperations.ca_detect_module())
// {
// //CA硬件不存在处理
// ;
// }
//3CA初始化
memset(&g_tCAData, 0, sizeof(CA_DATA));
if(NULL == g_tCAModuleOperations.ca_init_module
|| CA_OK != g_tCAModuleOperations.ca_init_module(&g_tCAData, NULL))
{
//CA硬件初始化失败
;
}
//在初始化后,调用接口返回是CA_UNKNOWN_ERROR,需要关闭CA后重新初始化
//4设置EADT(加密授权描述表),如果更新就重新设置
// UInt8 *pEADT = NULL;
// UInt32 u32EADTLen = 0;
// if(NULL == g_tCAModuleOperations.ca_send_EADT
// || CA_OK != g_tCAModuleOperations.ca_send_EADT(&g_tCAData, pEADT, u32EADTLen))
// {
// //设置EADT失败
// ;
// }
//5设置EMM(授权管理信息),将完整的复用子帧作为参数
// UInt8 *pEMMSubFrame = NULL;
// UInt32 u32EMMSubFrameLen= 0;
// if(NULL == g_tCAModuleOperations.ca_send_EMM
// || CA_OK != g_tCAModuleOperations.ca_send_EMM(&g_tCAData, pEMMSubFrame, u32EMMSubFrameLen))
// {
// //设置EADT失败
// ;
// }
//6解扰复用子帧
// UInt8 *pInSubFrame = NULL; //输入加扰复用子帧数据
// UInt32 u32InSubFrameLen = 0; //输入加扰复用子帧长度
// UInt8 *pOutSubFrame = NULL; //输出解扰复用子帧Buffer
// UInt32 u32OutSubFrameLen= 0; //输出解扰复用子帧长度
// CONDITIONAL_ACCESS tConditionalAccess;
// tConditionalAccess.service_id = 0;//指定复用子帧指针业务标识
// if(NULL == g_tCAModuleOperations.ca_descramble
// || CA_OK != g_tCAModuleOperations.ca_descramble(&g_tCAData, &tConditionalAccess,
// pInSubFrame, u32InSubFrameLen,
// pOutSubFrame, &u32OutSubFrameLen))
// {
// //解扰失败
// ;
// }
#endif
////////////////////////////DESCRAMBLER_TY
while (1)
{
printf("**********ZTE MobileTV Player*********\n\n");
printf("Please input a number\n");
printf("0 open live stream,\n");
printf("a open msf file,\n");
printf("b set channel id,\n");
printf("d set freq no,\n");
printf("c open mfs file,\n");
printf("1 Play,\n");
printf("2 Stop,\n");
printf("3 Close,\n");
printf("4 open Debug log,\n");
printf("5 close Debug log,\n");
printf("6 set volume,\n");
printf("7 play Pause,\n");
printf("8 play Resume,\n");
printf("9 Full Screen-Normal Change,\n");
printf("q quit,\n");
scanf("%s",commandid);
switch(commandid[0])
{
case '0': // open live stream
{
g_bLivePlay = true;
CallBacks.GetStreamData = GetStreamData;
CallBacks.GetCMMBMuxFrame = NULL;
g_pControl->RegisterCallback(&CallBacks);
EmuOpen(NULL, g_bLivePlay); // live stream
printf("Receive command OPEN\n");
g_pControl->Open();
break;
}
case 'a': // open MSF file stream
{
g_bLivePlay = false;
CallBacks.GetStreamData = GetStreamData;
CallBacks.GetCMMBMuxFrame = NULL;
g_pControl->RegisterCallback(&CallBacks);
EmuOpen(argv[1], g_bLivePlay); // file stream
printf("Receive command MSF OPEN\n");
g_pControl->Open();
break;
}
case 'c': // open MFS file stream
{
g_bLivePlay = false;
CallBacks.GetStreamData = NULL;
CallBacks.GetCMMBMuxFrame = GetCMMBMuxFrame;
g_pControl->RegisterCallback(&CallBacks);
EmuOpen(argv[1], g_bLivePlay); // file stream
printf("Receive command MFS OPEN\n");
g_pControl->Open();
break;
}
case 'b':
{
printf("Receive command set channel id\n");
printf("Please input channel id: ");
scanf("%d",&channelid);
if (g_bstartplay)
{
g_bstartplay = false;
g_pControl->Stop();
EmuEnd();
g_bstartplay = true;
EmuBegin(channelid);
if(argc > 2)
{
char szSDP[4096];
int nSDPLen = 4096;
if(!GetSDP(argv[2],szSDP, nSDPLen))
{
TSDPParam oTSDPParam;
oTSDPParam.nSDPLen = nSDPLen;
oTSDPParam.pSDPData= szSDP;
g_pControl->SetConfig(CFG_SDP_PARAM, &oTSDPParam);
}
}
Bool8 b8AudOnly = false;
g_pControl->SetConfig(CFG_AUDIO_ONLY, &b8AudOnly);
g_pControl->Play();
}
break;
}
case 'd':
{
int nFreqNo = 0;
printf("Please input freq no: ");
scanf("%d",&nFreqNo);
usleep(500*1000);
SetTunnerFreq(nFreqNo);
//SetTunnerFreq(43);
//SetTunnerFreq(20);
break;
}
case '1': // play
{
g_bstartplay = true;
g_u32CurTick = 0;
g_u32StartTick = 0;
g_u32ReadCount = 0;
EmuBegin(channelid);
printf("Receive command PLAY\n");
if(argc > 2)
{
char szSDP[4096];
int nSDPLen = 4096;
if(!GetSDP(argv[2],szSDP, nSDPLen))
{
TSDPParam oTSDPParam;
oTSDPParam.nSDPLen = nSDPLen;
oTSDPParam.pSDPData= szSDP;
g_pControl->SetConfig(CFG_SDP_PARAM, &oTSDPParam);
}
}
Bool8 b8AudOnly = false;
g_pControl->SetConfig(CFG_AUDIO_ONLY, &b8AudOnly);
g_pControl->Play();
break;
}
case '2': // stop
{
g_bstartplay = false;
printf("Receive command STOP\n");
g_pControl->Stop();
EmuEnd();
break;
}
case '3': // Close
{
g_bstartplay = false;
printf("Receive command Close\n");
g_pControl->Close();
EmuClose();
break;
}
case '4':
{
printf("Receive command open Debug log\n");
int nLogLevel = 0;
g_pControl->SetConfig(CFG_SHOW_LOG_LEVEL, &nLogLevel);
break;
}
case '5':
{
printf("Receive command close Debug log\n");
int nLogLevel = 1;
g_pControl->SetConfig(CFG_SHOW_LOG_LEVEL, &nLogLevel);
break;
}
case '6':
{
printf("Receive command set volume\n");
printf("Please input volume: ");
scanf("%s",commandid);
TVolume oVolume;
oVolume.nLeftVol = oVolume.nRightVol = strtoul(commandid, NULL, 10);
g_pControl->SetConfig(CFG_SET_VOLUME, &oVolume);
break;
}
case '7': // play Pause
{
printf("Receive command: play Pause\n");
g_pControl->Pause();
break;
}
case '8': // play Resume
{
printf("Receive command: play Resume\n");
g_pControl->Resume();
break;
}
case '9': // Full Screen - Normal Change
{
printf("Receive command: Full Screen - Normal Change \n");
g_pControl->SetConfig(CFG_FULL_SCREEN, NULL);
break;
}
case 'q': // quit
{
g_bstartplay = false;
printf("Receive command quit\n");
IControl::Destroy();
EmuClose();
if (pPacketData)
{
free(pPacketData);
}
printf("return..........=\n");
#ifdef SUBFRAME_FILE
fclose(pFile);
#endif
return 0;
}
default:
break;
}
}
////////////////////////////DESCRAMBLER_TY
#ifdef DESCRAMBLER_TY
//关闭CA
if(NULL != g_tCAModuleOperations.ca_shutdown_module)
{
g_tCAModuleOperations.ca_shutdown_module(&g_tCAData);
}
#endif
////////////////////////////DESCRAMBLER_TY
return err;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -