Ejemplo n.º 1
0
HRESULT CConvert::AddVideoSourceFiles()
{
	HRESULT hr = S_OK;

	CComPtr<IAMTimelineObj> pSourceVideoObj;	
	hr = m_pTimeline->CreateEmptyNode(&pSourceVideoObj, TIMELINE_MAJOR_TYPE_SOURCE );
	if(FAILED( hr )) 
		return hr;
	
	double dStop = m_pSettings->dEndTime;
	if (m_pSettings->dEndTime == 0.0f)
		dStop = m_dSourceLength;

	hr = S_OK;
	hr |= pSourceVideoObj->SetStartStop2(0, dStop);
	HR_ASSERT(hr);

	CComQIPtr<IAMTimelineSrc, &IID_IAMTimelineSrc> pSourceVideoSrc(pSourceVideoObj);
	hr |= pSourceVideoSrc->SetMediaTimes2(0, dStop);
	HR_ASSERT(hr);

	hr |= pSourceVideoSrc->SetMediaName(m_pSettings->strInputFile);
	HR_ASSERT(hr);

	hr |= pSourceVideoSrc->SetStretchMode(RESIZEF_STRETCH);
	HR_ASSERT(hr);

	if (FAILED( hr )) 
		return hr;
			
	// Get the video root composition
	CComQIPtr<IAMTimelineComp, &IID_IAMTimelineComp> pRootComp(m_pVideoGroupObj);
	
	CComPtr<IAMTimelineObj> pVideoTrackObj;
	pRootComp->GetVTrack(&pVideoTrackObj, 0);

	CComQIPtr<IAMTimelineTrack, &IID_IAMTimelineTrack> pTrackVideo(pVideoTrackObj);
	hr = pTrackVideo->SrcAdd(pSourceVideoObj);
	if (FAILED( hr )) 
		return hr;

	return hr;
}
Ejemplo n.º 2
0
HRESULT CPipeServer::start(int channelCount /*= 1*/)
{
	HR_ASSERT(0 < channelCount, E_INVALIDARG);

	HR_ASSERT_OK(CPipe::setup(channelCount));

	for (channels_t::iterator ch = m_channels.begin(); ch != m_channels.end(); ch++) {
		Channel* channel = ch->get();

		// Create server pipe instance
		DWORD dwOpenMode = PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED;
		DWORD dwPipeMode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE;
		DWORD nMaxInstanes = m_channels.size();
		DWORD nOutBufferSize = 128;
		DWORD nInBufferSize = 128;
		DWORD nDefaultTimOout = 1000;
		channel->hPipe.reset(::CreateNamedPipe(m_pipeName, dwOpenMode, dwPipeMode, nMaxInstanes, nOutBufferSize, nInBufferSize, nDefaultTimOout, NULL));
		WIN32_ASSERT(channel->hPipe.isValid());

		// Wait for client to connect
		HR_ASSERT(!ConnectNamedPipe(channel->hPipe, &channel->connectIO), E_ABORT);	// ConnetNamedPipe() should return FALSE.
		DWORD error = GetLastError();
		switch (error) {
		case ERROR_IO_PENDING:
			break;
		case ERROR_PIPE_CONNECTED:
			WIN32_ASSERT(SetEvent(channel->connectIO));
			break;
		default:
			WIN32_FAIL(ConnectNamedPipe(), error);
		}
	};

	// Server is waiting for client to connect.
	return CPipe::start();
}
Ejemplo n.º 3
0
HRESULT CPipeServer::disconnect(int ch)
{
	Channel* channel;
	HR_ASSERT_OK(getChannel(ch, &channel));

	HR_ASSERT(channel->isConnected(), E_ILLEGAL_METHOD_CALL);

	channel->invalidate();
	WIN32_ASSERT(DisconnectNamedPipe(channel->hPipe));

	HRESULT hr = S_OK;
	if (channel->onDisconnected) {
		hr = HR_EXPECT_OK(channel->onDisconnected());
	}
	if ((hr == S_OK) && onDisconnected) {
		hr = HR_EXPECT_OK(onDisconnected(ch));
	}

	return hr;
}