/****************************************************************************** Copyright (C), 2001-2011, Hisilicon Tech. Co., Ltd. ****************************************************************************** File Name : dvbplay.c Version : Initial Draft Author : Hisilicon multimedia software group Created : 2010/01/26 Description : History : 1.Date : 2010/01/26 Author : sdk Modification: Created file ******************************************************************************/ #include #include #include #include #include #include "hi_unf_common.h" #include "hi_unf_avplay.h" #include "hi_unf_sound.h" #include "hi_unf_disp.h" #include "hi_unf_vo.h" #include "hi_unf_demux.h" #include "hi_unf_hdmi.h" #include "HA.AUDIO.MP3.decode.h" #include "HA.AUDIO.MP2.decode.h" #include "HA.AUDIO.AAC.decode.h" #include "HA.AUDIO.DRA.decode.h" #include "HA.AUDIO.PCM.decode.h" #include "HA.AUDIO.WMA9STD.decode.h" #include "HA.AUDIO.AMRNB.codec.h" #include "hi_adp.h" #include "hi_adp_hdmi.h" #include "hi_adp_boardcfg.h" #include "hi_adp_mpi.h" #include "hi_adp_tuner.h" #ifdef CONFIG_SUPPORT_CA_RELEASE #define sample_printf #else #define sample_printf printf #endif PMT_COMPACT_TBL *g_pProgTbl = HI_NULL; HI_S32 main(HI_S32 argc,HI_CHAR *argv[]) { HI_S32 Ret; HI_HANDLE hWin; HI_HANDLE hAvplay; HI_UNF_AVPLAY_ATTR_S AvplayAttr; HI_UNF_SYNC_ATTR_S SyncAttr; HI_UNF_AVPLAY_STOP_OPT_S Stop; HI_CHAR InputCmd[32]; HI_U32 ProgNum; HI_HANDLE hTrack; HI_UNF_AUDIOTRACK_ATTR_S TrackAttr; HI_U32 Tuner = 0; HI_U32 TunerFreq; HI_U32 TunerSrate; HI_U32 ThirdParam; HI_U32 u32Ber[3]; HI_UNF_ENC_FMT_E Format = HI_UNF_ENC_FMT_1080i_50; if (argc < 2) { printf("Usage: %s [freq] [srate] [qamtype or polarization] [vo_format] [tuner]\n" " qamtype or polarization: \n" " For cable, used as qamtype, value can be 16|32|[64]|128|256|512 defaut[64] \n" " For satellite, used as polarization, value can be [0] horizontal | 1 vertical defaut[0] \n" " vo_format:2160P_30|2160P_24|1080P_60|1080P_50|1080i_60|[1080i_50]|720P_60|720P_50 default HI_UNF_ENC_FMT_1080i_50\n" " Tuner: value can be 0, 1, 2, 3\n", argv[0]); printf("Example: %s 618 6875 64 1080i_50 0\n", argv[0]); return HI_FAILURE; } TunerFreq = strtol(argv[1], NULL, 0); TunerSrate = (TunerFreq > 1000) ? 27500 : 6875; ThirdParam = (TunerFreq > 1000) ? 0 : 64; if (argc >= 3) { TunerSrate = strtol(argv[2], NULL, 0); } if (argc >= 4) { ThirdParam = strtol(argv[3], NULL, 0); } if (argc >= 5) { Format = HIADP_Disp_StrToFmt(argv[4]); } if (argc >= 6) { Tuner = strtol(argv[5], NULL, 0); } HI_SYS_Init(); HIADP_MCE_Exit(); Ret = HIADP_Snd_Init(); if (HI_SUCCESS != Ret) { sample_printf("call HIADP_Snd_Init failed.\n"); goto SYS_DEINIT; } Ret = HIADP_Disp_Init(Format); if (HI_SUCCESS != Ret) { sample_printf("call HIADP_Disp_DeInit failed.\n"); goto SND_DEINIT; } Ret = HIADP_VO_Init(HI_UNF_VO_DEV_MODE_NORMAL); Ret |= HIADP_VO_CreatWin(HI_NULL,&hWin); if (HI_SUCCESS != Ret) { sample_printf("call HIADP_VO_Init failed.\n"); HIADP_VO_DeInit(); goto DISP_DEINIT; } Ret = HI_UNF_DMX_Init(); Ret |= HIADP_DMX_AttachTSPort(0, Tuner); if (Ret != HI_SUCCESS) { sample_printf("call HIADP_Demux_Init failed.\n"); goto VO_DEINIT; } Ret = HIADP_Tuner_Init(); if (HI_SUCCESS != Ret) { sample_printf("call HIADP_Demux_Init failed.\n"); goto DMX_DEINIT; } Ret = HIADP_Tuner_Connect(Tuner, TunerFreq, TunerSrate, ThirdParam); if (HI_SUCCESS != Ret) { sample_printf("call HIADP_Tuner_Connect failed.\n"); goto TUNER_DEINIT; } HIADP_Search_Init(); Ret = HIADP_Search_GetAllPmt(0,&g_pProgTbl); if (HI_SUCCESS != Ret) { sample_printf("call HIADP_Search_GetAllPmt failed\n"); goto PSISI_FREE; } Ret = HIADP_AVPlay_RegADecLib(); Ret |= HI_UNF_AVPLAY_Init(); if (Ret != HI_SUCCESS) { sample_printf("call HI_UNF_AVPLAY_Init failed.\n"); goto PSISI_FREE; } Ret = HI_UNF_AVPLAY_GetDefaultConfig(&AvplayAttr, HI_UNF_AVPLAY_STREAM_TYPE_TS); AvplayAttr.u32DemuxId = 0; Ret |= HI_UNF_AVPLAY_Create(&AvplayAttr, &hAvplay); if (Ret != HI_SUCCESS) { sample_printf("call HI_UNF_AVPLAY_Create failed.\n"); goto AVPLAY_DEINIT; } Ret = HI_UNF_AVPLAY_ChnOpen(hAvplay, HI_UNF_AVPLAY_MEDIA_CHAN_VID, HI_NULL); Ret |= HI_UNF_AVPLAY_ChnOpen(hAvplay, HI_UNF_AVPLAY_MEDIA_CHAN_AUD, HI_NULL); if (HI_SUCCESS != Ret) { sample_printf("call HI_UNF_AVPLAY_ChnOpen failed.\n"); goto CHN_CLOSE; } Ret = HI_UNF_VO_AttachWindow(hWin, hAvplay); if (HI_SUCCESS != Ret) { sample_printf("call HI_UNF_VO_AttachWindow failed.\n"); goto CHN_CLOSE; } Ret = HI_UNF_VO_SetWindowEnable(hWin, HI_TRUE); if (HI_SUCCESS != Ret) { sample_printf("call HI_UNF_VO_SetWindowEnable failed.\n"); goto WIN_DETACH; } Ret = HI_UNF_SND_GetDefaultTrackAttr(HI_UNF_SND_TRACK_TYPE_MASTER, &TrackAttr); if (Ret != HI_SUCCESS) { sample_printf("call HI_UNF_SND_GetDefaultTrackAttr failed.\n"); goto WIN_DETACH; } Ret = HI_UNF_SND_CreateTrack(HI_UNF_SND_0, &TrackAttr, &hTrack); if (Ret != HI_SUCCESS) { sample_printf("call HI_UNF_SND_CreateTrack failed.\n"); goto WIN_DETACH; } Ret = HI_UNF_SND_Attach(hTrack, hAvplay); if (Ret != HI_SUCCESS) { sample_printf("call HI_UNF_SND_Attach failed.\n"); goto TRACK_DESTROY; } Ret = HI_UNF_AVPLAY_GetAttr(hAvplay, HI_UNF_AVPLAY_ATTR_ID_SYNC, &SyncAttr); SyncAttr.enSyncRef = HI_UNF_SYNC_REF_AUDIO; SyncAttr.stSyncStartRegion.s32VidPlusTime = 60; SyncAttr.stSyncStartRegion.s32VidNegativeTime = -20; SyncAttr.bQuickOutput = HI_FALSE; Ret = HI_UNF_AVPLAY_SetAttr(hAvplay, HI_UNF_AVPLAY_ATTR_ID_SYNC, &SyncAttr); if (Ret != HI_SUCCESS) { sample_printf("call HI_UNF_AVPLAY_SetAttr failed.\n"); goto SND_DETACH; } ProgNum = 0; Ret = HIADP_AVPlay_PlayProg(hAvplay,g_pProgTbl,ProgNum,HI_TRUE); if (Ret != HI_SUCCESS) { sample_printf("call SwitchProg failed.\n"); goto AVPLAY_STOP; } while(1) { printf("please input the q to quit!\n"); SAMPLE_GET_INPUTCMD(InputCmd); if ('q' == InputCmd[0]) { printf("prepare to quit!\n"); break; } if ('s' == InputCmd[0]) { static int cnt = 0; HI_BOOL bSmartvol; if(cnt % 2 == 0) { bSmartvol = HI_FALSE; printf("prepare to set smart volume true!\n"); HI_UNF_SND_SetTrackSmartVolume(hTrack, HI_TRUE); HI_UNF_SND_GetTrackSmartVolume(hTrack, &bSmartvol); printf("GetSmartVolume: bSmartvol = %d\n", bSmartvol); } else { bSmartvol = HI_TRUE; printf("prepare to set smart volume false!\n"); HI_UNF_SND_SetTrackSmartVolume(hTrack, HI_FALSE); HI_UNF_SND_GetTrackSmartVolume(hTrack, &bSmartvol); printf("GetSmartVolume: bSmartvol = %d\n", bSmartvol); } cnt++; } if ('g' == InputCmd[0]) { HI_UNF_TUNER_GetBER(Tuner, &u32Ber[0]); printf("\n-->BER: %dE -%d\n",u32Ber[0],u32Ber[2]); HI_UNF_TUNER_GetSNR(Tuner, &ThirdParam); printf("-->SNR: %d \n",ThirdParam); HI_UNF_TUNER_GetSignalStrength(Tuner, &ThirdParam); printf("-->SSI: %d \n",ThirdParam); HI_UNF_TUNER_GetSignalQuality(Tuner, &ThirdParam); printf("-->SQI: %d \n\n",ThirdParam); continue; } ProgNum = atoi(InputCmd); if (ProgNum == 0) ProgNum = 1; Ret = HIADP_AVPlay_PlayProg(hAvplay,g_pProgTbl,ProgNum-1,HI_TRUE); if (Ret != HI_SUCCESS) { sample_printf("call SwitchProgfailed!\n"); break; } } AVPLAY_STOP: Stop.enMode = HI_UNF_AVPLAY_STOP_MODE_BLACK; Stop.u32TimeoutMs = 0; HI_UNF_AVPLAY_Stop(hAvplay, HI_UNF_AVPLAY_MEDIA_CHAN_VID | HI_UNF_AVPLAY_MEDIA_CHAN_AUD, &Stop); SND_DETACH: HI_UNF_SND_Detach(hTrack, hAvplay); TRACK_DESTROY: HI_UNF_SND_DestroyTrack(hTrack); WIN_DETACH: HI_UNF_VO_SetWindowEnable(hWin,HI_FALSE); HI_UNF_VO_DetachWindow(hWin, hAvplay); CHN_CLOSE: HI_UNF_AVPLAY_ChnClose(hAvplay, HI_UNF_AVPLAY_MEDIA_CHAN_VID | HI_UNF_AVPLAY_MEDIA_CHAN_AUD); HI_UNF_AVPLAY_Destroy(hAvplay); AVPLAY_DEINIT: HI_UNF_AVPLAY_DeInit(); PSISI_FREE: HIADP_Search_FreeAllPmt(g_pProgTbl); HIADP_Search_DeInit(); TUNER_DEINIT: HIADP_Tuner_DeInit(); DMX_DEINIT: HI_UNF_DMX_DetachTSPort(0); HI_UNF_DMX_DeInit(); VO_DEINIT: HI_UNF_VO_DestroyWindow(hWin); HIADP_VO_DeInit(); DISP_DEINIT: HIADP_Disp_DeInit(); SND_DEINIT: HIADP_Snd_DeInit(); SYS_DEINIT: HI_SYS_DeInit(); return Ret; }