Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

unresolved external symbol _MFEnumDeviceSources@12

$
0
0

Hi,

I'm new to windows MF / C++ programming and i have a basic code that lists capture devices. But the linker still can't resolve the only 2 Media Foundation functions called in the code. But, the headers of the MF functions are well included in the code and the libraries of the linker are well pointing on the lib files of the headers. So, what is wrong with the code or the configuration? Thanks.

// ListCaptureDevices.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <new>
#include <windowsx.h>
#include <d3d9.h>
/* include Media Foundation main library */
#include <mfidl.h>
#include <Mfapi.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <mfreadwrite.h>
#include <mferror.h>
#include <strsafe.h>



using namespace std ;


void WINAPI manage_hresult_s_ok(HRESULT, string) ;

void WINAPI manage_lresult_s_ok(LRESULT result, string) ;

// manage return values that should be S_OK
void WINAPI manage_hresult_s_ok(HRESULT result, string message){
   if (result != S_OK) {
     cerr << message << endl ;
   }    
}      
void WINAPI manage_lresult_s_ok(LRESULT result, string message){
   if (result != S_OK) {
     cerr << message << endl ;
   }    
}      



int _tmain(int argc, _TCHAR* argv[])
{
	 unsigned int nbListedMediaSources ;
     // the interface defining the criteria store
     IMFAttributes * mediaSourcesCriteriaAttributesInterface ;
     manage_hresult_s_ok(MFCreateAttributes(&mediaSourcesCriteriaAttributesInterface, 0), "error creating attributes")  ; // initial size at 0,
     // set the criteria as video capture device type
     mediaSourcesCriteriaAttributesInterface->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID) ;
     IMFActivate *** mediaSourcesActivationObjects = 0 ;
     // list all video capture devices avalaible
     HRESULT listing_result = MFEnumDeviceSources(mediaSourcesCriteriaAttributesInterface, mediaSourcesActivationObjects, &nbListedMediaSources) ;
     manage_hresult_s_ok(listing_result, "error while getting the capture devices list") ;
     cout << "found " << listing_result << " capture devices" ;
     /*
     !!! DONT FORGET
     should (once done with IMFActivate pointers from listed media sources) release the pointers
     and call CoTaskMemFree to free tha array memory which was automatically allocated
     */
	return 0;
}


Viewing all articles
Browse latest Browse all 1079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>