Ejemplo n.º 1
0
void ExecTest(AudioPlayerPtr player, AudioStream sound)
{
	printf("ExecTest channels = %ld \n", GetChannelsSound(sound));
    int res = LoadChannel(player, sound, 1, 1.0f, 1.0f, 0.0f);
	SetStopCallbackChannel(player, 1, TestCallback, NULL);
    if (res == NO_ERR) {
        TestPlay(player);
    } else {
        printf("LoadChannel error %d \n", res);
    }
    StopChannel(player, 1);
}
Ejemplo n.º 2
0
void TestPlay(AudioPlayerPtr player)
{
    float vol = 1.0f;
    float panLeft = 1.0f;
	float panRight = 1.0f;
    char c;
    
    AudioRendererPtr renderer = GetAudioPlayerRenderer(player);
	
    while ((c = getchar()) && (c != 'n')) {

        switch (c) {

            case 'b':
                StartChannel(player, 1);
				break;

            case 'p':
                ContChannel(player, 1);
                break;

            case 's':
                StopChannel(player, 1);
                break;

            case '+':
                vol += 0.05f;
                //SetVolAudioPlayer(player, vol);
				time_strech += 0.1;
				printf("time_strech %f\n", time_strech);
                break;

            case '-':
                vol -= 0.05f;
                //SetVolAudioPlayer(player, vol);
				time_strech -= 0.1;
				printf("time_strech %f\n", time_strech);
                break;
				
			case '1':
                vol += 0.05f;
                //SetVolAudioPlayer(player, vol);
				pitch_shift += 0.1;
				printf("pitch_shift %f\n", pitch_shift);
                break;

            case '2':
                vol -= 0.05f;
                //SetVolAudioPlayer(player, vol);
				pitch_shift -= 0.1;
				printf("pitch_shift %f\n", pitch_shift);
                break;
                
            case 'w':
                RendererInfo info;
                GetAudioRendererInfo(renderer, &info);
                printf("info.fCurFrame %lld\n", info.fCurFrame);
                printf("info.fCurUsec %lld\n", info.fCurUsec);
				break;

            /*
            case '1':
                panLeft += 0.05f;
				panRight -= 0.05f;
                SetPanAudioPlayer(player, panLeft, panRight);
                break;

            case '2':
				panLeft += 0.05f;
				panRight -= 0.05f;
                SetPanAudioPlayer(player, panLeft, panRight);
                break;
            */
			 case 'c': // To be used only when faust effects are running....
				SetControlValueEffect(faust_effect, 1, 0.95f);
				SetControlValueEffect(faust_effect, 2, 0.9f);
	            break;
        }
    }
}
IVS_INT32 CRDAChannel::InitChannel(IVS_UINT32 uiProtocolType, MEDIA_ADDR& stDecoderAddr)
{
	// 初始化解码器通道
	IPI_INIT_BUSINESS_REQ pParaInfo = {0};
	pParaInfo.ulAsyncSeq = m_ulAsyncSeq;
	pParaInfo.usChannelNo = static_cast<unsigned short>(m_uiChannel);
	bool bSucc = CToolsHelp::Strncpy(pParaInfo.szDecoderID, sizeof(pParaInfo.szDecoderID), m_strDecoderID.c_str(), m_strDecoderID.length());
	CHECK_SUCCESS_RET(bSucc, IVS_ALLOC_MEMORY_ERROR);
	pParaInfo.ucTransportProtocol = (1==uiProtocolType) ? RDA_PROTOCOL_RTP_OVER_UDP:RDA_PROTOCOL_RTP_OVER_TCP;
	m_ucTransportProtocol = pParaInfo.ucTransportProtocol;
	IVS_INT32 iRet = IVS_TVWall_InitBusiness(&pParaInfo);
	if(IVS_SUCCEED!=iRet)
	{
		BP_RUN_LOG_ERR(iRet, "Init Channel", "Init Business failed!");
		return iRet;
	}

    BP_DBG_LOG("CRDAChannel::InitChannel: Send Init Channel Info Suc. usChannelNo = %d.", pParaInfo.usChannelNo);

	//获取解码器初始化信息,要从中取出媒体IP等信息
	CUMW_NOTIFY_INIT_DECODER_INFO decoderInitInfo = {0};
	for(int i=0;i<90;i++)
	{
        //检查是否有停止请求
        CHECK_STOP_FLAG_FOR_START();

		iRet = m_pTVWallMgr->GetDecoderInitInfo(m_ulAsyncSeq, &decoderInitInfo);
		if(IVS_SUCCEED==iRet)
		{
			m_ulBusinessID = decoderInitInfo.ulBusinessID;
			break;
		}
		VOS_Sleep(70);
	}
	if(IVS_SUCCEED!=iRet)
	{
		BP_RUN_LOG_ERR(iRet, "Init Channel", "Get Decoder Init Info Failed!");
		HandlePlayException();
		return iRet;
	}

    //检查解码器返回的数据是否为成功
    if (IVS_SUCCEED != decoderInitInfo.stErrorCode.ulErrorCode)
    {
        BP_RUN_LOG_ERR(IVS_TVWALL_DECODER_INIT_CHANNEL_FAIL, "Init Channel", "Init Business failed!");
		(void)StopChannel();
		HandlePlayException();
        return IVS_TVWALL_DECODER_INIT_CHANNEL_FAIL;
    }

	stDecoderAddr.unMediaIp = htonl((unsigned int)inet_addr(decoderInitInfo.stMediaNetInfo.szMediaIP));
	if(decoderInitInfo.stMediaNetInfo.ucTransportProtocol==RDA_PROTOCOL_RTP_OVER_TCP)
	{
		stDecoderAddr.unMediaVideoPort = decoderInitInfo.stMediaNetInfo.usTcpInterleavedPort;
		stDecoderAddr.unMediaAudioPort = decoderInitInfo.stMediaNetInfo.usTcpInterleavedPort;
	}
	else
	{
		stDecoderAddr.unMediaVideoPort = decoderInitInfo.stMediaNetInfo.usUdpVideoRtpPort;
		stDecoderAddr.unMediaAudioPort = decoderInitInfo.stMediaNetInfo.usUdpAudioRtpPort;
	}
	BP_DBG_LOG("CRDAChannel::InitChannel, get DecoderInitInfo success: \
			   DecoderID=%s,TCPPort=%d,UDPVideoPort=%d,UDPAudioPort=%d", 
			   decoderInitInfo.szDecoderID,
			   decoderInitInfo.stMediaNetInfo.usTcpInterleavedPort, 
			   decoderInitInfo.stMediaNetInfo.usUdpVideoRtpPort,
			   decoderInitInfo.stMediaNetInfo.usUdpAudioRtpPort);
	return IVS_SUCCEED;
}