Hi, i am working with a TV tuner that have 3 inputs: S-Video, Composite and Tuner, the problem that i have is that the default input is S-Video, so if i change it to composite (input needed) each time i reboot the computer and the start the application again this settings come again to the default value (svideo).
I want to store in a config file the input needed (Svideo, Composite, Tuner) and every time the app starts set the correct video input. Another way i think was change the default input in windows registry, but i didn't find any key for that.
My question is How to achive this (Set input from code or change default input in windows registry).
Thank's in advance
Andres
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
for (int i = 0; i < iOutputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(false, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_VideoDecoder) iPinIndexOutput = iPinIndexRelated;
}
for (int i = 0; i < iInputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(true, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_Composite) iPinIndexInput = iPinIndexRelated;
}
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
}
Sets the input Pin for Composite to 4 and the output pin for Video Decoder to 1
But the correct values are 1 and 0 (I saw these values in the crossbar window of Amcap),
so this code works fine:
iPinIndexInput=1;
iPinIndexOutput=0;
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would suggere you using the crossbar filter, which permit to configure which input to use...
To get the crossbar
IAMCrossbar iCrossbar = null;
m_fGB2.FindInterface( null, null, m_fSource, typeof(IAMCrossbar).GUID, out o );
iCrossbar = o as IAMCrossbar; o = null;
to seek for the composite entry for example :
if (iCrossbar != null)
{
int iOutputPinCount = 0, iInputPinCount = 0, iPinIndexRelated = 0, iPinIndexOutput = 0, iPinIndexInput = 0;
PhysicalConnectorType cPhysicalConnectorType;
iCrossbar.get_PinCounts(out iOutputPinCount, out iInputPinCount);
for (int i = 0; i < iOutputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(false, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_VideoDecoder) iPinIndexOutput = iPinIndexRelated;
}
for (int i = 0; i < iInputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(true, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_Composite) iPinIndexInput = iPinIndexRelated;
}
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
}
hope that help !
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would suggere you using the crossbar filter, which permit to configure which input to use...
To get the crossbar
IAMCrossbar iCrossbar = null;
m_fGB2.FindInterface( null, null, m_fSource, typeof(IAMCrossbar).GUID, out o );
iCrossbar = o as IAMCrossbar; o = null;
to seek for the composite entry for example :
if (iCrossbar != null)
{
int iOutputPinCount = 0, iInputPinCount = 0, iPinIndexRelated = 0, iPinIndexOutput = 0, iPinIndexInput = 0;
PhysicalConnectorType cPhysicalConnectorType;
iCrossbar.get_PinCounts(out iOutputPinCount, out iInputPinCount);
for (int i = 0; i < iOutputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(false, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_VideoDecoder) iPinIndexOutput = iPinIndexRelated;
}
for (int i = 0; i < iInputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(true, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_Composite) iPinIndexInput = iPinIndexRelated;
}
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
}
hope that help !
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank's for your reply, i put your code in the device initialization method, but seems i made something wrong because the device keep working with SVideo, here is my code:
private void SetupGraph(DsDevice dev, int iFrameRate, int iWidth, int iHeight, string FileName, Control hControl)
{
int hr;
ISampleGrabber sampGrabber = null;
IBaseFilter baseGrabFlt = null;
IBaseFilter capFilter = null;
IBaseFilter muxFilter = null;
IFileSinkFilter fileWriterFilter = null;
ICaptureGraphBuilder2 capGraph = null;
// Get the graphbuilder object
m_FilterGraph = new FilterGraph() as IFilterGraph2;
m_mediaCtrl = m_FilterGraph as IMediaControl;
if DEBUG
m_rot = new DsROTEntry(m_FilterGraph);
endif
try{// Get the ICaptureGraphBuilder2capGraph=(ICaptureGraphBuilder2)newCaptureGraphBuilder2();// Get the SampleGrabber interfacesampGrabber=(ISampleGrabber)newSampleGrabber();// Start building the graphhr=capGraph.SetFiltergraph(m_FilterGraph);DsError.ThrowExceptionForHR(hr);// Add the video devicehr=m_FilterGraph.AddSourceFilterForMoniker(dev.Mon,null,dev.Name,outcapFilter);DsError.ThrowExceptionForHR(hr);baseGrabFlt=(IBaseFilter)sampGrabber;ConfigureSampleGrabber(sampGrabber);// Add the frame grabber to the graphhr=m_FilterGraph.AddFilter(baseGrabFlt,"Ds.NETGrabber");DsError.ThrowExceptionForHR(hr);// If any of the default config items are setif(iFrameRate+iHeight+iWidth>0){SetConfigParms(capGraph,capFilter,iFrameRate,iWidth,iHeight);}// To get the crossbar IAMCrossbariCrossbar=null;objecto;capGraph.FindInterface(null,null,capFilter,typeof(IAMCrossbar).GUID,outo);iCrossbar=oasIAMCrossbar;o=null;//to seek for the composite entry for example : if(iCrossbar!=null){intiOutputPinCount=0,iInputPinCount=0,iPinIndexRelated=0,iPinIndexOutput=0,iPinIndexInput=0;PhysicalConnectorTypecPhysicalConnectorType;iCrossbar.get_PinCounts(outiOutputPinCount,outiInputPinCount);for(inti=0;i<iOutputPinCount;i++){iCrossbar.get_CrossbarPinInfo(false,i,outiPinIndexRelated,outcPhysicalConnectorType);if(cPhysicalConnectorType==PhysicalConnectorType.Video_VideoDecoder)iPinIndexOutput=iPinIndexRelated;}for(inti=0;i<iInputPinCount;i++){iCrossbar.get_CrossbarPinInfo(true,i,outiPinIndexRelated,outcPhysicalConnectorType);if(cPhysicalConnectorType==PhysicalConnectorType.Video_Composite)iPinIndexInput=iPinIndexRelated;}// connexion du crossbar iCrossbar.Route(iPinIndexOutput,iPinIndexInput);}boolacceptPreview=false;if(this.InitMode==CaptureMode.SnapAndRec){// Create a filter for the output avi filehr=capGraph.SetOutputFileName(MediaSubType.Avi,FileName,outmuxFilter,outfileWriterFilter);DsError.ThrowExceptionForHR(hr);hr=capGraph.RenderStream(PinCategory.Capture,MediaType.Video,capFilter,baseGrabFlt,muxFilter);DsError.ThrowExceptionForHR(hr);try{//Render any preview pin of the devicehr=capGraph.RenderStream(PinCategory.Preview,MediaType.Video,capFilter,null,null);DsError.ThrowExceptionForHR(hr);acceptPreview=true;}catch(Exceptionex){Debug.WriteLine(ex.Message);}//// Now that sizes are fixed, store the sizesSaveSizeInfo(sampGrabber);if(acceptPreview){ConfigVideoWindow(hControl);}}elseif(this.initMode==CaptureMode.OnlySnap){hr=capGraph.RenderStream(PinCategory.Capture,MediaType.Video,capFilter,baseGrabFlt,muxFilter);DsError.ThrowExceptionForHR(hr);SaveSizeInfo(sampGrabber);ConfigVideoWindow(hControl);}this.state=CaptureState.Ready;}finally{if(fileWriterFilter!=null){Marshal.ReleaseComObject(fileWriterFilter);fileWriterFilter=null;}if(muxFilter!=null){Marshal.ReleaseComObject(muxFilter);muxFilter=null;}if(capFilter!=null){Marshal.ReleaseComObject(capFilter);capFilter=null;}if(sampGrabber!=null){Marshal.ReleaseComObject(sampGrabber);sampGrabber=null;}}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Thanks for the help in C#.. However
the iPinIndexOutput, iPinIndexInput should be the value of "i" in
the FOR loops
Vb.net working code.
Dim o As Object = Nothing
Dim iCrossbar As IAMCrossbar = Nothing
Dim iOutputPinCount As Integer = 0, iInputPinCount As Integer = 0,
iPinIndexRelated As Integer = 0, iPinIndexOutput As Integer = 0,
iPinIndexInput As Integer = 0
Hi, i am working with a TV tuner that have 3 inputs: S-Video, Composite and Tuner, the problem that i have is that the default input is S-Video, so if i change it to composite (input needed) each time i reboot the computer and the start the application again this settings come again to the default value (svideo).
I want to store in a config file the input needed (Svideo, Composite, Tuner) and every time the app starts set the correct video input. Another way i think was change the default input in windows registry, but i didn't find any key for that.
My question is How to achive this (Set input from code or change default input in windows registry).
Thank's in advance
Andres
I found the problem, this code:
for (int i = 0; i < iOutputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(false, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_VideoDecoder) iPinIndexOutput = iPinIndexRelated;
}
for (int i = 0; i < iInputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(true, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_Composite) iPinIndexInput = iPinIndexRelated;
}
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
}
Sets the input Pin for Composite to 4 and the output pin for Video Decoder to 1
But the correct values are 1 and 0 (I saw these values in the crossbar window of Amcap),
so this code works fine:
iPinIndexInput=1;
iPinIndexOutput=0;
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
I would suggere you using the crossbar filter, which permit to configure which input to use...
To get the crossbar
IAMCrossbar iCrossbar = null;
m_fGB2.FindInterface( null, null, m_fSource, typeof(IAMCrossbar).GUID, out o );
iCrossbar = o as IAMCrossbar; o = null;
to seek for the composite entry for example :
if (iCrossbar != null)
{
int iOutputPinCount = 0, iInputPinCount = 0, iPinIndexRelated = 0, iPinIndexOutput = 0, iPinIndexInput = 0;
PhysicalConnectorType cPhysicalConnectorType;
iCrossbar.get_PinCounts(out iOutputPinCount, out iInputPinCount);
for (int i = 0; i < iOutputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(false, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_VideoDecoder) iPinIndexOutput = iPinIndexRelated;
}
for (int i = 0; i < iInputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(true, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_Composite) iPinIndexInput = iPinIndexRelated;
}
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
}
hope that help !
I would suggere you using the crossbar filter, which permit to configure which input to use...
To get the crossbar
IAMCrossbar iCrossbar = null;
m_fGB2.FindInterface( null, null, m_fSource, typeof(IAMCrossbar).GUID, out o );
iCrossbar = o as IAMCrossbar; o = null;
to seek for the composite entry for example :
if (iCrossbar != null)
{
int iOutputPinCount = 0, iInputPinCount = 0, iPinIndexRelated = 0, iPinIndexOutput = 0, iPinIndexInput = 0;
PhysicalConnectorType cPhysicalConnectorType;
iCrossbar.get_PinCounts(out iOutputPinCount, out iInputPinCount);
for (int i = 0; i < iOutputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(false, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_VideoDecoder) iPinIndexOutput = iPinIndexRelated;
}
for (int i = 0; i < iInputPinCount; i++)
{
iCrossbar.get_CrossbarPinInfo(true, i, out iPinIndexRelated, out cPhysicalConnectorType);
if (cPhysicalConnectorType == PhysicalConnectorType.Video_Composite) iPinIndexInput = iPinIndexRelated;
}
// connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput);
}
hope that help !
Thank's for your reply, i put your code in the device initialization method, but seems i made something wrong because the device keep working with SVideo, here is my code:
private void SetupGraph(DsDevice dev, int iFrameRate, int iWidth, int iHeight, string FileName, Control hControl)
{
int hr;
if DEBUG
endif
Have you try debugging to verify that input and output pin of the crossbar are well finded ?
Hi Thanks for the help in C#.. However
the iPinIndexOutput, iPinIndexInput should be the value of "i" in
the FOR loops
Vb.net working code.
Dim o As Object = Nothing
Dim iCrossbar As IAMCrossbar = Nothing
Dim iOutputPinCount As Integer = 0, iInputPinCount As Integer = 0,
iPinIndexRelated As Integer = 0, iPinIndexOutput As Integer = 0,
iPinIndexInput As Integer = 0
CaptureGraphBuilder.FindInterface(PinCategory.Capture, Nothing, sourceFilter,
GetType(IAMCrossbar).GUID, o)
iCrossbar = TryCast(o, IAMCrossbar)
o = Nothing
'to seek for the composite entry for example :
If iCrossbar IsNot Nothing Then
Dim cPhysicalConnectorType As PhysicalConnectorType
iCrossbar.get_PinCounts(iOutputPinCount, iInputPinCount)
' we want the INDEX to the connectortype NOT the related index.
'
For i As Integer = 0 To iOutputPinCount - 1
iCrossbar.get_CrossbarPinInfo(False, i, iPinIndexRelated,
cPhysicalConnectorType)
If cPhysicalConnectorType = PhysicalConnectorType.Video_VideoDecoder Then
iPinIndexOutput = i
Exit For
End If
Next
For i As Integer = 0 To iInputPinCount - 1
iCrossbar.get_CrossbarPinInfo(True, i, iPinIndexRelated,
cPhysicalConnectorType)
' Debug.WriteLine("Inp Cphysconnectortype " *
iPinIndexRelated.ToString & " = " &
cPhysicalConnectorType.ToString)
If cPhysicalConnectorType = PhysicalConnectorType.Video_Composite Then
iPinIndexInput = i
Exit For
End If
Next
' connexion du crossbar
iCrossbar.Route(iPinIndexOutput, iPinIndexInput)
End If
Hope this helps