www.pudn.com > BlueSoleil_SDK1.0.0.zip > av_tst.c
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Copyright (c) 1999-2005 IVT Corporation
*
* All rights reserved.
*
---------------------------------------------------------------------------*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Module Name:
av_tst.c
Abstract:
Revision History:
2007-3-20 Huyi Created
---------------------------------------------------------------------------*/
#include "sdk_tst.h"
#include "profiles_tst.h"
/* current remote audio device handle */
static BTDEVHDL s_currAudioRmtDevHdl = BTSDK_INVALID_HANDLE;
/* current remote audio device AV service handle */
static BTSHCHDL s_currAudioSvcHdl = BTSDK_INVALID_HANDLE;
/* current remote audio device connection handle */
static BTCONNHDL s_currAudioConnHdl = BTSDK_INVALID_HANDLE;
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
This function is to select expected remote device.
Arguments:
Return:
void
---------------------------------------------------------------------------*/
void TestSelectRmtAudioDev()
{
//s_currAudioRmtDevHdl = SelectRemoteDevice(BTSDK_DEVCLS_MASK(BTSDK_AV_HEADSET));
s_currAudioRmtDevHdl = SelectRemoteDevice(0);
if (BTSDK_INVALID_HANDLE == s_currAudioRmtDevHdl)
{
printf("Please make sure that the expected device is in discoverable state and search again.\n");
}
else
{
printf("Select remote audio device successfully.\n");
}
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
This function is to get service handle according to given device handle.
Arguments:
Return:
void
---------------------------------------------------------------------------*/
void TestSelectAudioSvc()
{
s_currAudioSvcHdl = SelectRemoteService(s_currAudioRmtDevHdl);
if (BTSDK_INVALID_HANDLE == s_currAudioSvcHdl)
{
printf("Can't get expected service handle.\n");
}
else
{
printf("Select remote audio device's service successfully.\n");
}
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
This function is to connect specified device's service with it's service handle.
Arguments:
Return:
void
---------------------------------------------------------------------------*/
void TestConnectAudioSvc()
{
BTINT32 ulRet = BTSDK_FALSE;
ulRet = Btsdk_Connect(s_currAudioSvcHdl, 0, &s_currAudioConnHdl);
if (BTSDK_OK != ulRet)
{
printf("Please make sure that the expected device is powered on and connectable.\n");
return;
}
if (BTSDK_INVALID_HANDLE != s_currAudioConnHdl)
{
GetConnectionInfo(s_currAudioRmtDevHdl);
}
return;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
This function is a callback function for AVRCP events
Arguments:
event: [in] AVRCP event
param: [in] profile specified parameter
Return:
void
---------------------------------------------------------------------------*/
void AVRCP_Event_CbkFunc(BTUINT16 event, BTUINT8 *param)
{
/* param is always a NULL pointer, reserved for later use. */
switch (event)
{
case BTSDK_APP_EV_AVRCP_IND_CONN:
printf("AVRCP connect successful.\n");
break;
case BTSDK_APP_EV_AVRCP_IND_DISCONN:
printf("AVRCP disconnected.\n");
break;
default:
break;
}
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
This function is to deal with the event generated by a user's operation.
Arguments:
op_id: [in] operation code ID
state_flag: [in] states flag
Return:
void
---------------------------------------------------------------------------*/
void AVRCP_PassThr_Cmd_CbkFunc(BTUINT8 op_id, BTUINT8 state_flag)
{
/* state_flag indicates the button status (up or down). */
if (BTSDK_AVRCP_BUTTON_STATE_PRESSED != state_flag)
{
return;
}
/* op_id could be one of the following status. please add code for each case. */
switch (op_id)
{
case BTSDK_AVRCP_OPID_AVC_PANEL_PLAY:
printf("The user has pressed down 'Play' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_STOP:
printf("The user has pressed down 'Stop' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_PAUSE:
printf("The user has pressed down 'Pause' button on the AV device's panel.\n ");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_FAST_FORWARD:
printf("The user has pressed down 'Fast forward' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_FORWARD:
printf("The user has pressed down 'Forward' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_BACKWARD:
printf("The user has pressed down 'Backward' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_VOLUME_UP:
printf("The user has pressed down 'Volume up' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_VOLUME_DOWN:
printf("The user has pressed down 'Volume down' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_RECORD:
printf("The user has pressed down 'Record' button on the AV device's panel.\n");
break;
case BTSDK_AVRCP_OPID_AVC_PANEL_POWER:
case BTSDK_AVRCP_OPID_AVC_PANEL_MUTE:
case BTSDK_AVRCP_OPID_AVC_PANEL_REWIND:
case BTSDK_AVRCP_OPID_AVC_PANEL_EJECT:
default:
break;
}
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
This function is to show user interface of AV test.
Arguments:
void
Return:
void
---------------------------------------------------------------------------*/
void TestAVShowMenu(void)
{
printf("*****************************************\n");
printf("* Please select the choice you want: *\n");
printf("* <1> Select A Remote Audio Device *\n");
printf("* <2> Select Service's Handle *\n");
printf("* <3> Connect Remote Audio Service *\n");
printf("* <4> Disconnect *\n");
printf("* Return to the upper menu *\n");
printf("*****************************************\n");
printf(">>");
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
This function is the entry function for AV APIs test.
Arguments:
void
Return:
void
---------------------------------------------------------------------------*/
void TestAVFunc(void)
{
BTUINT8 ch = 0;
s_currAudioRmtDevHdl = BTSDK_INVALID_HANDLE;
s_currAudioSvcHdl = BTSDK_INVALID_HANDLE;
Btsdk_AVRCP_RegPassThrCmdCbk4ThirdParty(AVRCP_PassThr_Cmd_CbkFunc);
Btsdk_AVRCP_RegIndCbk4ThirdParty(AVRCP_Event_CbkFunc);
TestAVShowMenu();
while (ch != 'r')
{
scanf(" %c", &ch);
getchar();
if (ch == '\n')
{
printf(">>");
}
else
{
switch (ch)
{
case '1':
TestSelectRmtAudioDev();
break;
case '2':
TestSelectAudioSvc();
break;
case '3':
TestConnectAudioSvc();
break;
case '4':
if (BTSDK_INVALID_HANDLE != s_currAudioConnHdl)
{
Btsdk_Disconnect(s_currAudioConnHdl);
}
break;
case 'r':
break;
default:
printf("Invalid command.\n");
break;
}
printf("\n");
TestAVShowMenu();
}
}
Btsdk_AVRCP_RegPassThrCmdCbk4ThirdParty(NULL);
Btsdk_AVRCP_RegIndCbk4ThirdParty(NULL);
}