/**
 * @file hv_mw_SearchSource.h
 * @brief Header file of SearchSource module.
 * 
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+)  
 * 
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-10
 */
#ifndef __HV_MW_CHANNEL_SEARCH_SOURCE_H__
#define __HV_MW_CHANNEL_SEARCH_SOURCE_H__


#include "hv_comm_DataType.h"
#include "hv_comm_Define.h"
#include "hv_comm_Event.h"
#include "hv_mw_StateMachine.h"
#include "hv_mw_Channel_Manager.h"

#if ((HV_PROJECT_CONFIG_PERIOD_SEARCH_CHECK_SROUCE_TIMER < 20) || (HV_PROJECT_CONFIG_PERIOD_SEARCH_CHECK_SROUCE_TIMER > 1000))
   #error "PERIOD_SEARCH_CHECK_SROUCE_TIMER range is 1000 >= value >=20 "
#endif

/**
 * @brief 通道搜索表初始化函数.
 * @param[in] ChannelData：通道控制元数据
 * @param[out] NULL
 * @return NULL
 */
VOID Hw_Mw_SearchTable_Init(ChannelData* pstChannelData);
/**
 * @brief channel状态机处于搜索态时的通道搜索函数，搜索策略包括自动和固定两种.
 * @param[in] pstChannelData：通道控制元数据
 * @param[out] NULL
 * @return HV_SUCCESS:搜索成功；HV_CONTINUE:继续搜索；HV_FAIL:搜索失败
 */
Status Hw_Mw_Channel_SearchSuitableSource(ChannelData* pstChannelData);
/**
 * @brief channel状态机处于无信号态时的通道搜索函数，搜索策略包括自动和固定两种.
 * @param[in] pstChannelData：通道控制元数据
 * @param[out] NULL
 * @return HV_SUCCESS:搜索成功；HV_CONTINUE:继续搜索；HV_FAIL:搜索失败
 */
Status Hw_Mw_Channel_NoSignal_SearchPort(ChannelData* pstChannelData);
/**
 * @brief RX 索引转换函数，将中间件索引转换为OSD索引.
 * @param[in] enPortIndex：中间件索引号
 * @param[out] NULL
 * @return OSD索引号
 */
UCHAR8 Hv_Mw_Channel_ConvertMwToGuiPortIndex(LinkPortIndex enPortIndex);
/**
 * @brief RX 索引转换函数，将OSD索引转换为中间件索引.
 * @param[in] ucGuiPortIndex：OSD索引
 * @param[out] NULL
 * @return 中间件索引号
 */
LinkPortIndex Hv_Mw_Channel_ConvertGuiToMwPortIndex(UCHAR8 ucGuiPortIndex);

/**
 * @brief 声音通道切换及资源切换.
 * @param[in] enChannelType：通道类型；pstChannelData：通道控制元数据
 * @param[out] NULL
 * @return NULL
 */
VOID Hw_Mw_AudioPath_Mux(const ChannelData* pstChannelData,ChannelType enChannelType);
#endif
