Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to enumerates media types on a given pin

How to enumerates media types on a given pin

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zengkun100
    wrote on last edited by
    #1

    I want to enumerates ac3filter's preferred media types, I suppose this process should be very easy, but I can't get this work. PLZ help!

    int _tmain(int argc, _TCHAR* argv[])
    {
    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    CLSID clsid;
    //ac3filter's clsid
    ::CLSIDFromString(_T("{A753A1EC-973E-4718-AF8E-A3F554D45C44}"), &clsid);
    IBaseFilter* pFilter = NULL;
    HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(IBaseFilter), (void **)&pFilter);
    IEnumPins* pEnumPins = NULL;
    hr = pFilter->EnumPins(&pEnumPins);
    if (SUCCEEDED(hr))
    {
    IPin* pPin = NULL;
    while (pEnumPins->Next(1, &pPin, NULL) == S_OK)
    {
    PIN_DIRECTION pinDir;
    //the pin direction can be queried
    pPin->QueryDirection(&pinDir);
    IEnumMediaTypes* pEnumMediaTypes = NULL;
    HRESULT hr = pPin->EnumMediaTypes(&pEnumMediaTypes);
    if (SUCCEEDED(hr))
    {
    AM_MEDIA_TYPE* pMediaType = NULL;
    //hr always S_FALSE, so the media type can not acquired
    hr = pEnumMediaTypes->Next(1, &pMediaType, NULL);
    pEnumMediaTypes->Release();
    }
    pPin->Release();
    }
    pEnumPins->Release();
    }
    return 0;
    }

    A Chinese VC++ programmer

    I 1 Reply Last reply
    0
    • Z zengkun100

      I want to enumerates ac3filter's preferred media types, I suppose this process should be very easy, but I can't get this work. PLZ help!

      int _tmain(int argc, _TCHAR* argv[])
      {
      CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
      CLSID clsid;
      //ac3filter's clsid
      ::CLSIDFromString(_T("{A753A1EC-973E-4718-AF8E-A3F554D45C44}"), &clsid);
      IBaseFilter* pFilter = NULL;
      HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(IBaseFilter), (void **)&pFilter);
      IEnumPins* pEnumPins = NULL;
      hr = pFilter->EnumPins(&pEnumPins);
      if (SUCCEEDED(hr))
      {
      IPin* pPin = NULL;
      while (pEnumPins->Next(1, &pPin, NULL) == S_OK)
      {
      PIN_DIRECTION pinDir;
      //the pin direction can be queried
      pPin->QueryDirection(&pinDir);
      IEnumMediaTypes* pEnumMediaTypes = NULL;
      HRESULT hr = pPin->EnumMediaTypes(&pEnumMediaTypes);
      if (SUCCEEDED(hr))
      {
      AM_MEDIA_TYPE* pMediaType = NULL;
      //hr always S_FALSE, so the media type can not acquired
      hr = pEnumMediaTypes->Next(1, &pMediaType, NULL);
      pEnumMediaTypes->Release();
      }
      pPin->Release();
      }
      pEnumPins->Release();
      }
      return 0;
      }

      A Chinese VC++ programmer

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      I'm not an expert on Pins, but I'm sure you can give more information on your problem. *What* didn;t work? Does it not compile? Does CoCreateInstance even work? Does it give success code, but no Pins? Do you get enumerators, they just are empty? Etc. We're not going to visit you and sit at your computer and use the debugger. China is a long way from here! Iain.

      Z 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        I'm not an expert on Pins, but I'm sure you can give more information on your problem. *What* didn;t work? Does it not compile? Does CoCreateInstance even work? Does it give success code, but no Pins? Do you get enumerators, they just are empty? Etc. We're not going to visit you and sit at your computer and use the debugger. China is a long way from here! Iain.

        Z Offline
        Z Offline
        zengkun100
        wrote on last edited by
        #3

        Thank you Iain. ;) As I commentted in the code, everything looks finely.The filter can be created; the pins can be enumerated; and the direction of the pins can be queried too, but when it comes to the media types of a given pin, IEnumMediaTypes::Next always returns S_FALSE. So I can't numerates media types on a given pin.

        A Chinese VC++ programmer

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups