tdmb_rf.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:17k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * tdmb_rf.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * TDMB RF source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _TDMB_RF_H_
- #include "tdmb_rf.h"
- #endif
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _MAN_FDM_H_
- #include "man_fdm.h"
- #endif
- #ifndef _MAN_HANDLE_H_
- #include "man_handle.h"
- #endif
- //===========================================================================
- static CTDMBRF* g_tdmb_rf_ptr;
- static bool g_bIsRunning = false;
- //===========================================================================
- static void REQ_Power_On(void)
- {
- g_tdmb_rf_ptr->REQ_Power_On();
- }
- //---------------------------------------------------------------------------
- static void REQ_Set_Freq(void)
- {
- g_tdmb_rf_ptr->REQ_Set_Freq();
- }
- //---------------------------------------------------------------------------
- static void REQ_Get_Signal(void)
- {
- g_tdmb_rf_ptr->REQ_Get_Signal();
- }
- //---------------------------------------------------------------------------
- static void REQ_AutoScan(void)
- {
- g_tdmb_rf_ptr->REQ_AutoScan();
- }
- //---------------------------------------------------------------------------
- static void REQ_Select_Service_Only(void)
- {
- g_tdmb_rf_ptr->REQ_Select_Service_Only();
- }
- //---------------------------------------------------------------------------
- static void REQ_RecordStream(void)
- {
- g_tdmb_rf_ptr->REQ_RecordStream();
- }
- //---------------------------------------------------------------------------
- static void __stdcall CNF_RecordStream(const TDMB_SEL_SERV_ERROR_RESULT status)
- {
- g_tdmb_rf_ptr->CNF_RecordStream(status);
- }
- //---------------------------------------------------------------------------
- static void REQ_Stop_Service(void)
- {
- g_tdmb_rf_ptr->REQ_Stop_Service();
- }
- //---------------------------------------------------------------------------
- static int __stdcall CNF_Stop_Service(unsigned char percent, int sent_bytes, int total_bytes, const short token, void *usr_arg)
- {
- g_tdmb_rf_ptr->CNF_Stop_Service(percent, sent_bytes, total_bytes, token, usr_arg);
- return 0;
- }
- //===========================================================================
- CTDMBRF::CTDMBRF(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- }
- //---------------------------------------------------------------------------
- CTDMBRF::~CTDMBRF()
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (confirm_state != METAAPP_SECTION_OK)
- {
- g_bIsRunning = false;
- }
- if (confirm_state != METAAPP_SUCCESS)
- {
- META_CancelAllBlockingCall_r(m_META_HANDLE_Obj.Get_MainHandle());
- }
- if (NULL == ConfirmCallback)
- {
- return;
- }
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction(ConfirmCallback);
- }
- //===========================================================================
- void CTDMBRF::REQ_Power_On_Start(void)
- {
- g_tdmb_rf_ptr = this;
- g_bIsRunning = true;
- ActiveMan->SetActiveFunction(::REQ_Power_On);
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::REQ_Power_On(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult = META_TDMB_TurnOn_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- void CTDMBRF::REQ_Set_Freq_Start(E_TDMB_BAND_T band, unsigned int freq_kHz)
- {
- g_tdmb_rf_ptr = this;
- g_bIsRunning = true;
- m_eBand = band;
- m_uiFreqKHz = freq_kHz;
- ActiveMan->SetActiveFunction(::REQ_Set_Freq);
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::REQ_Set_Freq(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- // set band
- TDMB_SET_BAND_REQ_T band_req;
- switch (m_eBand)
- {
- case TDMB_KOREA_BAND_IDX:
- {
- band_req.m_rBand = META_TDMB_KOREA_BAND;
- }
- break;
- case TDMB_VHF_BAND3_IDX:
- {
- band_req.m_rBand = META_TDMB_BAND_III;
- }
- break;
- case TDMB_LBAND_IDX:
- {
- band_req.m_rBand = META_TDMB_L_BAND;
- }
- break;
- case TDMB_CHINA_BAND_IDX:
- {
- band_req.m_rBand = META_TDMB_CHINESE_BAND;
- }
- break;
- }
-
- META_RESULT MetaResult = META_TDMB_SetBand_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &band_req);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- // set frequency
- TDMB_SET_FREQ_REQ_T freq_req;
- freq_req.m_u4Freq = m_uiFreqKHz;
- MetaResult = META_TDMB_SetFreq_r(m_META_HANDLE_Obj.Get_MainHandle(),15000, &freq_req, &m_sFreqEnsemble);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- if (m_sFreqEnsemble.m_cResult)
- {
- Confirm(METAAPP_FAIL);
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- void CTDMBRF::REQ_AutoScan_Start(E_TDMB_BAND_T band)
- {
- g_tdmb_rf_ptr = this;
- g_bIsRunning = true;
- m_eBand = band;
- ActiveMan->SetActiveFunction(::REQ_AutoScan);
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::REQ_AutoScan(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- // set band
- TDMB_SET_BAND_REQ_T band_req;
- switch (m_eBand)
- {
- case TDMB_KOREA_BAND_IDX:
- {
- band_req.m_rBand = META_TDMB_KOREA_BAND;
- }
- break;
- case TDMB_VHF_BAND3_IDX:
- {
- band_req.m_rBand = META_TDMB_BAND_III;
- }
- break;
- case TDMB_LBAND_IDX:
- {
- band_req.m_rBand = META_TDMB_L_BAND;
- }
- break;
- case TDMB_CHINA_BAND_IDX:
- {
- band_req.m_rBand = META_TDMB_CHINESE_BAND;
- }
- break;
- }
- MetaResult = META_TDMB_SetBand_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &band_req);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
-
- MetaResult = META_TDMB_AutoScan_GetEnsemble_r(m_META_HANDLE_Obj.Get_MainHandle(), 60000, &m_sScanEnsemble);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- bool CTDMBRF::REQ_Get_Signal_Start(void)
- {
- g_tdmb_rf_ptr = this;
- g_bIsRunning = true;
- //ActiveMan->SetActiveFunction(::REQ_Get_Signal);
- META_RESULT MetaResult = META_TDMB_GetSignal_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &m_sSignal);
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::REQ_Get_Signal(void)
- {
- #if 0
- if (!g_bIsRunning)
- {
- return;
- }
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- Confirm(METAAPP_SUCCESS);
- #endif
- }
- //===========================================================================
- void CTDMBRF::REQ_Select_Service_Only_Start(S_TDMB_SEL_SERV_ONLY_T req)
- {
- g_tdmb_rf_ptr = this;
- g_bIsRunning = true;
- m_sServiceOnly = req;
- ActiveMan->SetActiveFunction(::REQ_Select_Service_Only);
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::REQ_Select_Service_Only(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- TDMB_SET_FREQ_REQ_T freq_req;
- freq_req.m_u4Freq = m_sServiceOnly.ui_freq_khz;
- META_RESULT MetaResult = META_TDMB_SetFreq_r(m_META_HANDLE_Obj.Get_MainHandle(), 15000, &freq_req, &m_sFreqEnsemble);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- MetaResult = META_TDMB_SelServiceOnly_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &m_sServiceOnly.req);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- void CTDMBRF::REQ_RecordStream_Start(S_TDMB_SEL_SERV_T req)
- {
- g_tdmb_rf_ptr = this;
- g_bIsRunning = true;
- m_sService = req;
- m_sSelServiceResult.b_valid = false;
- ActiveMan->SetActiveFunction(::REQ_RecordStream);
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::REQ_RecordStream(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- TDMB_SET_FREQ_REQ_T freq_req;
- freq_req.m_u4Freq = m_sService.ui_freq_khz;
- META_RESULT MetaResult = META_TDMB_SetFreq_r(m_META_HANDLE_Obj.Get_MainHandle(), 15000, &freq_req, &m_sFreqEnsemble);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- MetaResult = META_TDMB_SelService_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &m_sService.req, ::CNF_RecordStream);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //---------------------------------------------------------------------------
- void __stdcall CTDMBRF::CNF_RecordStream(const TDMB_SEL_SERV_ERROR_RESULT status)
- {
- m_sSelServiceResult.b_valid = true;
- m_sSelServiceResult.e_result = status;
- }
- //===========================================================================
- void CTDMBRF::REQ_Stop_Service_Start(void)
- {
- g_tdmb_rf_ptr = this;
- g_bIsRunning = true;
- ActiveMan->SetActiveFunction(::REQ_Stop_Service);
- }
- //---------------------------------------------------------------------------
- void CTDMBRF::REQ_Stop_Service(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult = META_TDMB_SetIdle_r(m_META_HANDLE_Obj.Get_MainHandle(), 10000, ::CNF_Stop_Service, NULL);
- if (MetaResult != META_SUCCESS)
- {
- if (META_TIMEOUT == MetaResult)
- {
- Confirm(METAAPP_TIMEOUT);
- }
- else
- {
- Confirm(METAAPP_FAIL);
- }
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //---------------------------------------------------------------------------
- int __stdcall CTDMBRF::CNF_Stop_Service(unsigned char percent, int sent_bytes, int total_bytes, const short token, void *usr_arg)
- {
- m_sFatProgress.percent = percent;
- m_sFatProgress.sent_bytes = sent_bytes;
- m_sFatProgress. total_bytes = total_bytes;
- return 0;
- }
- //===========================================================================
- ///////////////////////////// Query /////////////////////////
- //===========================================================================
- bool CTDMBRF::Query_TDMBSupport_Start(void)
- {
- META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, "META_TDMB_TurnOn_r");
- if (MetaResult != META_SUCCESS)
- {
- m_bTDMBSupport = false;
- }
- else
- {
- m_bTDMBSupport = true;
- }
- return m_bTDMBSupport;
- }
- //===========================================================================
- ///////////////////////////// Global information /////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CTDMBRF::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //---------------------------------------------------------------------------
- bool CTDMBRF::Get_TDMBSupport(void)
- {
- return m_bTDMBSupport;
- }
- //---------------------------------------------------------------------------
- TDMB_SET_FREQ_CNF_T* CTDMBRF::Get_FreqEnsembleResult(void)
- {
- return &m_sFreqEnsemble;
- }
- //---------------------------------------------------------------------------
- TDMB_GET_ENSM_INFO_BY_AUTO_SCAN_CNF_T* CTDMBRF::Get_ScanEnsembleResult(void)
- {
- return &m_sScanEnsemble;
- }
- //---------------------------------------------------------------------------
- TDMB_GET_SIGNAL_CNF_T* CTDMBRF::Get_Signal(void)
- {
- return &m_sSignal;
- }
- //---------------------------------------------------------------------------
- S_TDMB_SEL_SERV_ERROR_RESULT* CTDMBRF::Get_SelServiceResult(void)
- {
- return &m_sSelServiceResult;
- }
- //---------------------------------------------------------------------------
- S_FAT_PROGRESS* CTDMBRF::Get_FatProgress(void)
- {
- return &m_sFatProgress;
- }