Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:12:48+00:00 2026-06-15T05:12:48+00:00

Currently I’m working on a DirectShow based application for configuring TV capture cards. It’s

  • 0

Currently I’m working on a DirectShow based application for configuring TV capture cards. It’s supposed to work with most of the capture cards out there, so it has to be as generic as possible.

Since most capture card manufacturers seem to come up with different ways of configuration, my application will try to analyse the related filters and their pins. One common is checking if a certain pin can be connected to a renderer directly, or it needs an encoder/mux first.

Note: I am using the DirectShow .NET library with VB.NET, but you can answer in C# or C++ if you like.

I tried checking if the output pin accepts a certain AMMediaType with the following function:

Private Function Check1(filter As IBaseFilter, type As AMMediaType) As Boolean
  Dim enumPins As IEnumPins = Nothing
  If filter.EnumPins(enumPins) = 0 Then
    Dim pin(0) As IPin
    While (enumPins.Next(1, pin, Nothing) = 0)

      Dim accepted As Boolean = (pin(0).QueryAccept(type) = 0)
      Marshal.ReleaseComObject(pin(0))
      If accepted Then Return True

    End While
  End If
  Return False
End Function

This function always returns False. After some debugging I found out that QueryAccept always returns -2147467259. The documentation does not mention such return value. After some more investigation, I found out QueryAccept is used for proposing a new MediaType, so I assume QueryAccept only works when the calling pin is already connected. Read more here.

I can check if a certain AMMediaType is preferred by the output pin using the function below:

Private Function Check2(filter As IBaseFilter, type As AMMediaType) As Boolean
  Dim enumPins As IEnumPins = Nothing
  If filter.EnumPins(enumPins) = 0 Then
    Dim pin(0) As IPin
    While (enumPins.Next(1, pin, Nothing) = 0)

      Dim enumMediaTypes As IEnumMediaTypes = Nothing
      If pin(0).EnumMediaTypes(enumMediaTypes) = 0 Then
        Dim mediaType(0) As AMMediaType
        While (enumMediaTypes.Next(1, mediaType, Nothing) = 0)

          Dim equals As Boolean = (type Is Nothing OrElse
            (type.majorType = Nothing OrElse mediaType(0).majorType = type.majorType) AndAlso
            (type.subType = Nothing OrElse mediaType(0).subType = type.subType) AndAlso
            (type.formatType = Nothing OrElse mediaType(0).formatType = type.formatType))
          DsUtils.FreeAMMediaType(mediaType(0))
          If equals Then
            Return True
          End If

        End While
      End If
    End While
  End If
  Return False
End Function

By enumerating EnumMediaTypes, I can determine if a certain AMMediaType is listed as preferred. This, however, does not assure me that a connection is possible. Often there are types that are not contained by this enumeration, but can still be used to connect. Sometimes this enumeration is empty.

What I’m searching for is a way to determine if a filter can be connected to another filter directly, or it should connect to an encoder/mux first. Does someone know how I can achieve this?

Note: Simply connecting the filters and using the return value to determine if it was succesful, is not an option. In my experience, ICaptureGraphBuilder::RenderStream often returns S_OK while no connection was made. For example, try using MediaType.AnalogVideo while there is no analog video pin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:12:49+00:00Added an answer on June 15, 2026 at 5:12 am

    Instead of ICaptureGraphBuilder::RenderStream, I ended up using IGraphBuilder::Connect, but only for checking if a connection is possible. After connecting the filters, the following function immediately disconnects the filters, and uses the HRESULT to determine if the connection was succesful:

    Private Function Check3(graph As IGraphBuilder, filterOut As IBaseFilter, filterIn As IBaseFilter, type As AMMediaType) As Boolean
      Dim result As Boolean
    
      ' Enumerate output pins
      Dim enumPinsOut As IEnumPins = Nothing
      If filterOut.EnumPins(enumPinsOut) = 0 Then
        Dim pinOut(0) As IPin
        While enumPinsOut.Next(1, pinOut, Nothing) = 0
    
          ' Enumerate output media types
          Dim enumMediaTypes As IEnumMediaTypes = Nothing
          If pinOut(0).EnumMediaTypes(enumMediaTypes) = 0 Then
            Dim mediaType(0) As AMMediaType
            While enumMediaTypes.Next(1, mediaType, Nothing) = 0
    
              ' Compare media types
              If type Is Nothing OrElse
                (type.majorType = Nothing OrElse type.majorType = mediaType(0).majorType) AndAlso
                (type.subType = Nothing OrElse type.subType = mediaType(0).subType) AndAlso
                (type.formatType = Nothing OrElse type.formatType = mediaType(0).formatType) Then
    
                ' Enumerate input pins
                Dim enumPinsIn As IEnumPins = Nothing
                If filterIn.EnumPins(enumPinsIn) = 0 Then
                  Dim pinIn(0) As IPin
                  While enumPinsIn.Next(1, pinIn, Nothing) = 0
    
                    ' Evaluate connection return value
                    Dim hr As Integer = graph.Connect(pinOut(0), pinIn(0))
                    graph.Disconnect(pinOut(0))
                    result = (hr = 0)
                    If result = False Then Console.WriteLine(DsError.GetErrorText(hr))
    
                    Marshal.ReleaseComObject(pinIn(0))
                    If result = True Then Exit While
                  End While
                End If
              End If
    
              DsUtils.FreeAMMediaType(mediaType(0))
              If result = True Then Exit While
            End While
          End If
    
          Marshal.ReleaseComObject(pinOut(0))
          If result = True Then Exit While
        End While
      End If
    
      Return result
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I have a GWT based application /app.htm It displays an openId login button
currently I am working on a Qt application running on an Embedded platform (i.MX53).
Currently, I am writing a MiddleWare application that synchronizes information between and accounting application
currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently, I'm working on a project where I have a server - client relationship
Currently working with converting SQLException error messages into messages that are more useful for
Currently i have a node.js and socket.io application in development on my local machine
Currently, my MVC 3 app has a dependency on a static class that is
Currently, I am writing up a bit of a product-based CMS as my first
Currently writing a C# application it should do backups using GIT in the background.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.