static inline bool ConnecEncodedtFilters(IGraphBuilder *graph,
		IBaseFilter *filter, IBaseFilter *crossbar,
		IBaseFilter *encoder, IBaseFilter *demuxer)
{
	if (!DirectConnectFilters(graph, crossbar, filter)) {
		Warning(L"Encoded Device: Failed to connect crossbar to "
		        L"device");
		return false;
	}

	if (!!encoder) {
		if (!DirectConnectFilters(graph, filter, encoder)) {
			Warning(L"Encoded Device: Failed to connect device to "
			        L"encoder");
			return false;
		}

		if (!DirectConnectFilters(graph, encoder, demuxer)) {
			Warning(L"Encoded Device: Failed to connect encoder to "
				L"demuxer");
			return false;
		}
	} else {
		if (!DirectConnectFilters(graph, filter, demuxer)) {
			Warning(L"Encoded Device: Failed to connect device to "
			        L"demuxer");
			return false;
		}
	}

	return true;
}
Exemplo n.º 2
0
bool HVideoEncoder::SetupCrossbar()
{
	ComPtr<IBaseFilter> crossbar;
	ComPtr<IPin> pin;
	REGPINMEDIUM medium;

	/* C353 has no crossbar */
	if (config.name.find(L"C353") != std::string::npos)
		return true;

	if (!GetPinByName(device, PINDIR_INPUT, L"Analog Video In", &pin)) {
		Warning(L"Failed to get Analog Video In pin");
		return false;
	}
	if (!GetPinMedium(pin, medium)) {
		Warning(L"Failed to get Analog Video In pin medium");
		return false;
	}
	if (!GetFilterByMedium(AM_KSCATEGORY_CROSSBAR, medium, &crossbar)) {
		Warning(L"Failed to get crossbar filter");
		return false;
	}

	graph->AddFilter(crossbar, L"Crossbar Filter");

	if (!DirectConnectFilters(graph, crossbar, device)) {
		Warning(L"Failed to connect crossbar to device");
		return false;
	}

	return true;
}
Exemplo n.º 3
0
bool HDevice::ConnectPins(const GUID &category, const GUID &type,
		IBaseFilter *filter, IBaseFilter *capture)
{
	HRESULT hr;
	ComPtr<IBaseFilter> crossbar;
	ComPtr<IPin> filterPin;
	ComPtr<IPin> capturePin;
	bool connectCrossbar = !encodedDevice && type == MEDIATYPE_Video;

	if (!EnsureInitialized(L"HDevice::ConnectPins") ||
	    !EnsureInactive(L"HDevice::ConnectPins"))
		return false;

	if (connectCrossbar && FindCrossbar(filter, &crossbar)) {
		if (!DirectConnectFilters(graph, crossbar, filter)) {
			Warning(L"HDevice::ConnectPins: Failed to connect "
			        L"crossbar");
			return false;
		}
	}

	if (!GetFilterPin(filter, type, category, PINDIR_OUTPUT, &filterPin)) {
		Error(L"HDevice::ConnectPins: Failed to find pin");
		return false;
	}

	if (!GetPinByName(capture, PINDIR_INPUT, nullptr, &capturePin)) {
		Error(L"HDevice::ConnectPins: Failed to find capture pin");
		return false;
	}

	hr = graph->ConnectDirect(filterPin, capturePin, nullptr);
	if (FAILED(hr)) {
		WarningHR(L"HDevice::ConnectPins: failed to connect pins",
				hr);
		return false;
	}

	return true;
}