function TVideo.InitTuner: Boolean;
var
pEnum: IEnumMoniker;
pmoniker: IMoniker;
pDevEnum: ICreateDevEnum;
pProcAmp: IAMVideoProcAmp;
Flags: TVideoProcAmpFlags;
begin
Result:= false;
// Create the Filter Graph Manager.
if Succeeded(CoCreateInstance(CLSID_FilterGraph,
nil, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, GraphB))
then
// Create the Capture Graph Builder.
if Succeeded(CoCreateInstance(CLSID_CaptureGraphBuilder2,
nil,
CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, CaptureGraph))
then
begin
CaptureGraph.SetFiltergraph(GraphB);
end;
// get the SourceFilter
if Succeeded(CoCreateInstance(CLSID_SystemDeviceEnum,
nil, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, pDevEnum))
then
if Succeeded(pDevEnum.CreateClassEnumerator(CLSID_VideoInputDeviceCategory, pEnum, 0))
then
if Succeeded(pEnum.Next(1, pmoniker,
nil))
then
if Succeeded(pmoniker.BindToObject(
nil,
nil, IID_IBaseFilter, sourceFilter))
then
if Succeeded(Graphb.AddFilter(SourceFilter, '
Capture Filter'))
then
// Get Tuner Interface
if Failed(CaptureGraph.FindInterface(@LOOK_UPSTREAM_ONLY,
nil, SourceFilter, IID_IAMTVTuner, FTVTuner))
then
begin
Showmessage('
No TV card in system!');
end else
if Succeeded(FTVTuner.put_InputType(0, TunerInputCable))
then
if Succeeded(FTVTuner.put_Mode(AMTUNER_MODE_TV))
then
// Render CaptureStream
if Succeeded(CaptureGraph.RenderStream(@PIN_CATEGORY_PREVIEW, @MEDIATYPE_Video, SourceFilter,
nil,
nil))
then
// Update ProcAmp um Farben anzupassen. Siht wenigstens etwas besser aus.
// Query the capture filter for the IAMVideoProcAmp interface.
if Succeeded(SourceFilter.QueryInterface(IID_IAMVideoProcAmp, pProcAmp))
then
if Succeeded(pProcAmp.Set_(VideoProcAmp_Brightness, 7500, VideoProcAmp_Flags_Manual))
then
if Succeeded(pProcAmp.Set_(VideoProcAmp_Hue, 2500, VideoProcAmp_Flags_Manual))
then
if Succeeded(pProcAmp.Set_(VideoProcAmp_Saturation, 10000, VideoProcAmp_Flags_Manual))
then
Result:= true;
ShowGraph(Result);
Mode:= vmCapture;
{ ... }
end;