{"id":1699,"date":"2016-08-24T23:39:24","date_gmt":"2016-08-24T21:39:24","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=1699"},"modified":"2016-08-24T23:39:24","modified_gmt":"2016-08-24T21:39:24","slug":"number-of-streams-served-by-imfsourcereader-interface","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/1699","title":{"rendered":"Number of streams served by IMFSourceReader interface"},"content":{"rendered":"<p>It looks confusing that <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd374655\"><code>IMFSourceReader<\/code><\/a> interface does not offer a dedicated method to find out the number of streams behind it. There is a <code>IMFMediaSource<\/code> instance behind the reader, and its streams are available through <code>IMFMediaSource::CreatePresentationDescriptor<\/code> method and <code>IMFPresentationDescriptor::GetStreamDescriptorCount<\/code> method call.<\/p>\n<p>I am under impression that source reader&#8217;s method just has to be there even though I am not seeing it looking at the list of methods. Okay, there are other methods, namely <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd374664\"><code>IMFSourceReader::GetStreamSelection<\/code><\/a> method, which takes either ordinal stream index or an alias as the first argument, then returns <code>MF_E_INVALIDSTREAMNUMBER<\/code> if you run out of streams. However the problem is that this is associated with an internal exception, and I consider exceptions as exceptional conditions the code should not normally hit. I would expect to have a legal exception-free way to find out the number of streams. I am using debugger that breaks on exception or at least pollutes output log for no reason, I use other tools that intercept and log exceptions as something that needs attention &#8211; getting number of streams is nowhere near there.<\/p>\n<p><a href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2016\/08\/Clipbrd4-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1700 size-full\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2016\/08\/Clipbrd4-2.png\" alt=\"Internal MF_E_INVALIDSTREAMNUMBER Exception\" width=\"545\" height=\"311\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2016\/08\/Clipbrd4-2.png 545w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2016\/08\/Clipbrd4-2-320x183.png 320w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/a><\/p>\n<p>Even though it is not a real drawback of the API since it is still possible to get the data and the API acts as documented, I still think someone overlooked this and API like this should have have a normal method or argument to request number of streams explicitly. Or I am just not seeing it even though I am trying thoroughly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It looks confusing that IMFSourceReader interface does not offer a dedicated method to find out the number of streams behind it. There is a IMFMediaSource instance behind the reader, and its streams are available through IMFMediaSource::CreatePresentationDescriptor method and IMFPresentationDescriptor::GetStreamDescriptorCount method call. I am under impression that source reader&#8217;s method just has to be there even&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/1699\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[424,70],"class_list":["post-1699","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-media-foundation","tag-winapi"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=1699"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/1699\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=1699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=1699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=1699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}