Esempio n. 1
0
/*
 * Class:     sage_DShowCaptureDevice
 * Method:    tuneToChannel0
 * Signature: (JLjava/lang/String;I)V
 */
JNIEXPORT void JNICALL Java_sage_DShowCaptureDevice_tuneToChannel0
  (JNIEnv *env, jobject jo, jlong capInfo, jstring jnum, jint streamType)
{
	if (!capInfo) return;
	DShowCaptureInfo* pCapInfo = (DShowCaptureInfo*) capInfo;
	//ZQ
	if (capMask(pCapInfo->captureConfig, sage_DShowCaptureDevice_BDA_VIDEO_CAPTURE_MASK ))
	{
		const char* cnum = env->GetStringUTFChars(jnum, NULL);
		slog((env, "tuneToChannel0 digital tuner '%s-%d' num=%s (ver 3.1)\r\n", pCapInfo->videoCaptureFilterName, 
			        pCapInfo->videoCaptureFilterNum, cnum ));

		
		SetupBDAStreamOutFormat( env, pCapInfo, streamType );
		HRESULT hr = TurnBDAChannel( env, pCapInfo, cnum  );
		env->ReleaseStringUTFChars(jnum, cnum);

	}else //ZQ
	{
		if (!pCapInfo->pTVTuner) return;
		const char* cnum = env->GetStringUTFChars(jnum, NULL);
		int numericChannel = atoi(cnum);
		long lFreq = 0, lTVFormat;
		env->ReleaseStringUTFChars(jnum, cnum);
		if ( numericChannel == 0 || numericChannel < 0 )
			return ;

		IAMTVTuner* pTunerProps = NULL;
		HRESULT hr = pCapInfo->pTVTuner->QueryInterface(IID_IAMTVTuner, (void**)&pTunerProps);
		slog((env, "tuneToChannel0 %d hr=0x%x num=%d\r\n", (int) capInfo, hr, numericChannel));
		if (SUCCEEDED(hr))
		{
			
			pTunerProps->put_Channel(numericChannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
			HRESULT hr2 = pTunerProps->get_VideoFrequency( &lFreq );
			        hr2 = pTunerProps->get_TVFormat( &lTVFormat );
			SAFE_RELEASE(pTunerProps);
			pCapInfo->dwTuneState = 0x01;
		}
		slog((env, "DONE: tuneToChannel0 %d hr=0x%x freq:%d TVFormat:%d\r\n", 
			                                 (int)capInfo, hr, lFreq, lTVFormat  ));
	}
}
Esempio n. 2
0
/*
 * Class:     sage_DShowCaptureDevice
 * Method:    autoTuneChannel0
 * Signature: (JLjava/lang/String;I)Z
 */
JNIEXPORT jboolean JNICALL Java_sage_DShowCaptureDevice_autoTuneChannel0
  (JNIEnv *env, jobject jo, jlong capInfo, jstring jnum, jint streamType )
{
	if (!capInfo) return JNI_FALSE;
	DShowCaptureInfo* pCapInfo = (DShowCaptureInfo*)capInfo;

	////ZQ audio leaking
	//pCapInfo->pMC->Run();
	//slog((env, ">>>>  Start (capture:%s) \r\n"));


	//ZQ
	if (capMask(pCapInfo->captureConfig, sage_DShowCaptureDevice_BDA_VIDEO_CAPTURE_MASK ))
	{
		HRESULT hr;
		const char* cnum = env->GetStringUTFChars(jnum, NULL);
		if ( cnum == NULL || *cnum == 0x0 ) cnum = "0";
		slog((env, "autotune0 digital tuner '%s-%d' num=%s (ver 3.1)\r\n", pCapInfo->videoCaptureFilterName, 
			        pCapInfo->videoCaptureFilterNum, cnum ));

		//setup output format
		hr = SetupBDAStreamOutFormat( env, pCapInfo, streamType );

		hr = TurnBDAChannel( env, pCapInfo, cnum );
		env->ReleaseStringUTFChars(jnum, cnum);


		int locked = SageCheckLocked( pCapInfo );
		slog((env, "DONE: autotune0 hr=0x%x locked:%d\r\n", hr, locked ));

		return hr == S_OK ? JNI_TRUE : JNI_FALSE;
        
	}else //ZQ
	{
		if (!pCapInfo->pTVTuner) return JNI_FALSE;
		const char* cnum = env->GetStringUTFChars(jnum, NULL);
		int numericChannel = atoi(cnum);
		env->ReleaseStringUTFChars(jnum, cnum);
		IAMTVTuner* pTunerProps = NULL;
		long tuneResult = 0;
		if ( numericChannel == 0 || numericChannel < 0 )
			return JNI_FALSE;

		long lFreq = 0;
		HRESULT hr = pCapInfo->pTVTuner->QueryInterface(IID_IAMTVTuner, (void**)&pTunerProps);
		slog((env, "autotune0 analog tuner '%s-%d' hr=0x%x num=%d\r\n", pCapInfo->videoCaptureFilterName, 
					pCapInfo->videoCaptureFilterNum,	hr, numericChannel));
		if (SUCCEEDED(hr))
		{
			hr = pTunerProps->AutoTune(numericChannel, &tuneResult);

			HRESULT hr2 = pTunerProps->get_VideoFrequency( &lFreq );
			//if ( tuneResult )
			//	pTunerProps->StoreAutoTune();
			pCapInfo->dwTuneState = 0x01;
			//Fusion Card, FIX: after ATSC tune, fail to tune TV 
			if ( strstr( pCapInfo->videoCaptureFilterName, "Fusion" ) )
				pTunerProps->put_Mode( AMTUNER_MODE_FM_RADIO );  
			pTunerProps->put_Mode( AMTUNER_MODE_TV );  //ZQ. 
			SAFE_RELEASE(pTunerProps);
		}
		slog((env, "DONE: autotune0 %d hr=0x%x result=%d  freq:%d.\r\n", 
			(int)capInfo, hr, tuneResult, lFreq ));
		return (SUCCEEDED(hr) && (tuneResult != 0));
	}
	return JNI_FALSE;
}