void SoundParameterGraph::Render( int realX, int realY, bool highlighted, bool clicked )
{
    InvertedBox::Render( realX, realY, false, false );

    glColor4f( 1.0, 1.0, 1.0, 1.0 );
    g_editorFont.DrawText2D( realX + m_w/2, realY + m_h - 10, 16, LANGUAGEPHRASE(m_parent->m_name) );
    
    if( m_parameter->m_type == SoundParameter::TypeLinked )
    {
        g_editorFont.DrawText2D( realX + 10, realY + 10, 16, m_parameter->GetLinkName( m_parameter->m_link ) );
    }

    RescaleAxis     ();
    RenderAxis      ( realX, realY );
    RenderValues    ( realX, realY );
    RenderOutput    ( realX, realY );
    
    HandleMouseEvents();
}
Пример #2
0
HRESULT CConvert::StartConversionDirect()
{
	StopConversion();
	printf("Initialising conversion...\n");
	m_tStartTime = timeGetTime();

	HRESULT hr = MakeNotificationWindow();
	if (FAILED(hr))
		return hr;

	hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, 
                          NULL, CLSCTX_INPROC_SERVER,
						  IID_ICaptureGraphBuilder2, 
						  (void **)&m_pBuilder);
	
	if (FAILED(hr))
	{
		StopConversion();
		ThrowError(hr, "GraphBuilder could not be created");
		return hr;
	}

	if (wcscmp(m_pSettings->strOutputFile, m_pSettings->strOutputFile) == 0)
	{
		StopConversion();
		ThrowError(E_FAIL, "The source and target files are the same.");
		return E_FAIL;
	}

    hr |= CreateFilterGraph(&m_pGraph);
    if(FAILED(hr))
    {
        StopConversion();
        ThrowError(hr, "Couldn't create filter graph! Please check that DirectX 8 (or higher) is installed");
        return hr;
    }
    
    hr = m_pBuilder->SetFiltergraph(m_pGraph);
	if(FAILED(hr))
    {
        StopConversion();
        ThrowError(hr, "Couldn't create filter graph! Please check that DirectX 8 (or higher) is installed");
        return hr;
    }    
    
	m_pCallback->ConversionConnecting();

    CComPtr<IBaseFilter> pSourceFilter = NULL;
    hr = m_pGraph->AddSourceFilter(m_pSettings->strInputFile, NULL, &pSourceFilter);  
    if (FAILED(hr))
    {
        StopConversion();
        ThrowError(hr, "Failed to render source UROL!");
        return hr;
    }

	if (m_pCallback)
		m_pCallback->ConversionStreaming();

	hr = RenderOutput(m_pBuilder, m_pGraph, NULL, NULL, NULL, NULL, pSourceFilter);


//	PromptForGraph(m_pGraph, "stream");

	if (m_pCallback)
		m_pCallback->ConversionAboutToRun();


	hr = Run();
	
	if(FAILED(hr))
	{
        StopConversion();
		ThrowError(hr, "Could not start streaming!");
		return hr;
	}


    return hr;
}
Пример #3
0
HRESULT CConvert::StartConversion()
{
	StopConversion();
	
	printf("Initialising conversion...\n");
	
	bool bIsURL = IsURL(m_pSettings->strInputFile);
	if (bIsURL)
		return StartConversionDirect();

	HRESULT hr = MakeNotificationWindow();
	if (FAILED(hr))
		return hr;

	m_pSettings->ApplySettingsToFilter(m_pMPEGWriter);

	m_nLastEncodedFrameCount = 0;

	hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, 
                          NULL, CLSCTX_INPROC_SERVER,
						  IID_ICaptureGraphBuilder2, 
						  (void **)&m_pBuilder);
	
	if (FAILED(hr))
	{
		StopConversion();
		ThrowError(hr, "GraphBuilder could not be created");
		return hr;
	}

	if (wcscmp(m_pSettings->strInputFile, m_pSettings->strOutputFile) == 0)
	{
		StopConversion();
		ThrowError(E_FAIL, "The source and target files are the same.");
		return E_FAIL;
	}

    // make the timeline
    hr = CoCreateInstance(CLSID_AMTimeline, 
                         NULL, 
                         CLSCTX_INPROC_SERVER, 
                         IID_IAMTimeline, 
                         (void**) &m_pTimeline);

    if(FAILED( hr ))
	{
		StopConversion();
		ThrowError(hr, "Timeline could not be created");
        return hr;
	}

	BOOL bOutputHasVideo = TRUE;
	/*
	switch (m_audioFormat)
	{
	case formatMP3:
	case formatWAV:
		bOutputHasVideo = FALSE; 
		break;
	}*/

	double dFramerate = 0;
	BOOL bVideo = FALSE;
	BOOL bAudio = FALSE;
	long nWidth = 0;
	long nHeight = 0;
	
	hr = GetFileInfo(m_pSettings->strInputFile, &dFramerate, &m_dSourceLength, &bVideo, &bAudio, &nWidth, &nHeight, 0, 0);

	if (!bIsURL && FAILED(hr))
	{
		StopConversion();
		ThrowError(E_FAIL, "The source file could not be read. The conversion cannot proceed");
		return E_FAIL;
	}

	/*
	if ((bAudio && !bVideo || !bOutputHasVideo) && m_bLimitAudio)
	{
		SetStopTime(30);
	}
	*/

	/*
	if (m_dSourceLength == 0 && nWidth && nHeight)
	{
		// picture. We will encode as mpeg still image
		m_dSourceLength = 0.429f;
	}
	else */if (m_dSourceLength == 0)
	{
		StopConversion();
		ThrowError(E_FAIL, "The source file had a duration of 0 seconds. The conversion cannot proceed");
		return E_FAIL;
	}

	if (bVideo && (nWidth == 0 || nHeight == 0))
	{
		StopConversion();
		ThrowError(E_FAIL, "The source video could not be read. The conversion cannot proceed");
		return E_FAIL;
	}


	if (bVideo && bOutputHasVideo)
	{
		hr = AddVideoGroup(dFramerate, nWidth, nHeight);
		if (FAILED(hr))
		{
			StopConversion();
			ThrowError(hr, "Video group could not be added to timeline");
			_ASSERT(FALSE);
			return hr;
		}
	}

	if (bAudio)
	{
		hr = AddAudioGroup();
		if (FAILED(hr))
		{
			_ASSERT(FALSE);
			StopConversion();
			ThrowError(hr, "Audio group could not be added to timeline");
			return hr;
		}
	}

	if (bVideo && bOutputHasVideo)
	{
		hr = AddVideoTracks();
		if (FAILED(hr))
		{
			_ASSERT(FALSE);
			StopConversion();
			ThrowError(hr, "Video track could not be added to timeline");
			return hr;
		}
	}

	if (bAudio)
	{
		hr = AddAudioTracks();
		if (FAILED(hr))
		{
			_ASSERT(FALSE);
			StopConversion();
			ThrowError(hr, "Audio track could not be added to timeline");
			return hr;
		}
	}

	if (bVideo && bOutputHasVideo)
	{
		hr = AddVideoSourceFiles();
		if (FAILED(hr))
		{
			_ASSERT(FALSE);
			StopConversion();
			ThrowError(hr, "Video source file could not be added to timeline");
			return hr;
		}
	}
	
	if (bAudio)
	{
		hr = AddAudioSourceFiles();
		if (FAILED(hr))
		{
			_ASSERT(FALSE);
			StopConversion();
			ThrowError(hr, "Audio source file could not be added to timeline");
			
			return hr;
		}
	}

    hr = m_pTimeline->ValidateSourceNames(SFN_VALIDATEF_CHECK|SFN_VALIDATEF_POPUP|SFN_VALIDATEF_REPLACE, NULL, 0);
    _ASSERT(!FAILED(hr));

    hr = CoCreateInstance(CLSID_RenderEngine, NULL, CLSCTX_INPROC_SERVER, IID_IRenderEngine, (void**) &m_pRenderEngine);
    if (FAILED(hr))
	{
		StopConversion();
		ThrowError(hr, "Render engine could not be created");
		return hr;
	}

    hr = m_pRenderEngine->SetTimelineObject( m_pTimeline );
    if (FAILED(hr))
	{
		StopConversion();
		ThrowError(hr, "Timeline object corrupt. Bad timeline!");		
		return hr;
	}

	if (m_pSettings->dStartTime || m_pSettings->dEndTime)
	{
		hr = m_pRenderEngine->SetRenderRange((__int64)(m_pSettings->dStartTime * UNITS), (__int64)(m_pSettings->dEndTime * UNITS));
		if (FAILED(hr))
		{
			_ASSERT(FALSE);
		}
	}

    hr = m_pRenderEngine->ConnectFrontEnd();
	if (FAILED(hr))
	{
		StopConversion();
		ThrowError(hr, "File could not be rendered");
		return hr;
	}

	hr = S_OK;
	hr = m_pRenderEngine->GetFilterGraph( &m_pGraph );
	hr |= m_pBuilder->SetFiltergraph(m_pGraph);
	if (FAILED(hr))
	{
		StopConversion();
		ThrowError(hr, "Filter graph could not be retrieved");
		return hr;
	}


	CComPtr<IPin> pVideoOutPin;
	CComPtr<IPin> pAudioOutPin;

	// if it has an audio stream, but no video stream, or does not need video out
	if (bAudio && (!bVideo || !bOutputHasVideo))
	{
		hr = m_pRenderEngine->GetGroupOutputPin(0, &pAudioOutPin);
	}
	else
	{
		hr = m_pRenderEngine->GetGroupOutputPin(0, &pVideoOutPin);
		hr = m_pRenderEngine->GetGroupOutputPin(1, &pAudioOutPin);
	}

	hr = RenderOutput(m_pBuilder, m_pGraph, m_pRenderEngine, NULL, pVideoOutPin, pAudioOutPin, NULL);
	if (FAILED(hr))
	{
		ThrowError(hr, "The output could not be rendered");
		_ASSERT(FALSE);
		StopConversion();
		return hr;
	}
	
	if (CheckVisibility() == S_OK)
	{
		m_pVideoWindow->put_Owner((OAHWND)m_hwndPreviewWnd);
		Resize(m_rcWin);
		m_pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
	}


	// PromptForGraph(m_pGraph, "edit");

	if (m_pCallback)
		m_pCallback->ConversionAboutToRun();


	hr = Run();
	_ASSERT(SUCCEEDED(hr));
	if (FAILED(hr))
	{
		StopConversion();
		ThrowError(hr, "Everything was initialized okay, but the actual conversion could not start. Please check that you can write to the output file.");
	}

	return hr;
}