wpf - Enumerating Available Camera Resolutions via DirectShow -


i trying enumerate usb camera’s video resolutions using directshow accessed wpf through com. have following test code.

var videooutpin = this.basefilterobject.getpin(pindirection.output, 0);  var streamconfig = (iamstreamconfig)videooutpin;  var picount = 0; var pisize = 0;  if (streamconfig.getnumberofcapabilities(ref picount, ref pisize) != 0) {     return; }  this.mediatypes = new collection<ammediatype>();  var resolutions = new collection<string>();  var ptr = marshal.alloccotaskmem(pisize);  (var = 0; < picount; i++) {     var mediatype = new ammediatype();     if (streamconfig.getstreamcaps(i, ref mediatype, ptr) != 0)     {         continue;     }      var header = (videoinfoheader)marshal.ptrtostructure(mediatype.formatptr, typeof(videoinfoheader));      var resolution = header.bmiheader.bitcount + " bits : " + header.bmiheader.width + " * " + header.bmiheader.height;      this.mediatypes.add(mediatype);     resolutions.add(resolution); } 

however, believe mediatype picking audio capabilities video. e.g. every other iteration gives me header.bmiheader.width of 0 , header.bmiheader.bitcount of 0.

firstly, right in thinking resulting casting audio capabilities using videoinfoheader.

how enumerate video capabilities , eliminate audio?

==============================

edit

i used directshow capture capabilities tool , got following suspect capability:

capability: 1
  • am_media_type:
    • data: 76 69 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 59 55 59 32 00 00 10 00 80 00 00 aa 00 38 9b 71 01 00 00 00 00 00 00 00 00 60 09 00 a0 76 2a f7 0a eb d0 11 ac e4 00 00 c0 cc 16 ba 00 00 00 00 70 00 00 00 40 07 b3 03
    • format data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ca 08 00 00 00 00 15 16 05 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 03 00 00 00 81 26 8d 00 00 00 00 00 28 00 00 00 80 02 00 00 e0 01 00 00 01 00 10 00 59 55 59 32 00 60 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    • .subtype: fourcc yuy2
    • .bfixedsizesamples: 1
    • .btemporalcompression: 0
    • .lsamplesize: 614,400
    • .cbformat: 112
    • videoinfoheader2:
  • unknown capabilities:
    • type: {f72a76a0-eb0a-11d0-ace4-0000c0cc16ba}
    • data: a0 76 2a f7 0a eb d0 11 ac e4 00 00 c0 cc 16 ba 00 00 00 00 80 02 00 00 e0 01 00 00 80 02 00 00 e0 01 00 00 80 02 00 00 e0 01 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 80 02 00 00 e0 01 00 00 80 02 00 00 e0 01 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 16 05 00 00 00 00 00 15 16 05 00 00 00 00 00 00 00 ca 08 00 00 ca 08

does make sense???

==============================

edit #2

following roman r.'s advice (if understand correctly).

i declare:-

private static readonly guid videoinfo =         new guid(0x05589f80, 0xc356, 0x11ce, 0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a); 

then modify code follows:

 (var = 0; < picount; i++)         {             var mediatype = new ammediatype();             if (streamconfig.getstreamcaps(i, ref mediatype, ptr) != 0)             {                 continue;             }             if (mediatype.formattype != videoinfo)             {                 continue;             }              marshal.ptrtostructure(mediatype.formatptr, typeof(videoinfoheader));              var header = (videoinfoheader)marshal.ptrtostructure(mediatype.formatptr, typeof(videoinfoheader));              var resolution = header.bmiheader.bitcount + " bits : " + header.bmiheader.width + " * "                              + header.bmiheader.height;              this.mediatypes.add(mediatype);             resolutions.add(resolution);         } 

the above change seems work e.g. working on test camera. correct. there else should worried code???

i believe mediatype picking audio capabilities video. [...]

how enumerate video capabilities , eliminate audio?

even though possible, highly unlikely video , audio capabilities , media types mixed on specific pin. is, enumerate right , video ones, or audio ones depending on pin.

you can compare enumeration media types shown graphedit, graphstudionext or directshowcapturecapabilities.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -