|
|
Hi all,
I have created a simple application to write video image samples according to the Windows Media Format 11 documentation ( http://msdn.microsoft.com/en-us/library/aa392242 (VS.85).aspx ). But when adding a stream to the profile object ( ppProfile->AddStream( pIStreamConfig ) ) the return value of HRESULT is -1072889796. And also when setting the profile to the writer object ( pWriter->SetProfile(ppProfile) ), the return value of HRESULT is -1072886842. The source code of the program is attached with this.(I have indicated the error values as comments on the source code). Can any one help me to identify the problem here?
Thanks & Regards,
Kelum
///////////////////////////////////////////////////////////////// // source code ////////////////////////////////////////////////////////////////
#include "stdafx.h" #include <wmsdk.h>
int _tmain(int argc, _TCHAR* argv[]) {
HRESULT hr = S_OK; IWMProfile * ppProfile; IWMProfileManager * pProfileMgr; IWMCodecInfo3 * pCodecInfo; IWMStreamConfig * pIStreamConfig; IWMStreamConfig * pIWMStreamConfig2 = NULL; IWMMediaProps * pImediaprops; IWMMediaProps * pIWMMediaProps2 = NULL; WM_MEDIA_TYPE * pMediaType; IWMWriter *pWriter = NULL; DWORD pcbType; DWORD cCodecs = 0; DWORD cFormats; DWORD cStreams = 0; DWORD cInputs = 0; WCHAR* pwszCodecName = NULL; DWORD cchCodecName = 0; DWORD dwCodecIndex; WORD wStreamNum = 0; DWORD dwBitrate = 1024;
hr = CoInitialize( NULL );
hr = WMCreateProfileManager(&pProfileMgr); // Create the empty profile. hr = pProfileMgr->CreateEmptyProfile(WMT_VER_9_0, &ppProfile);
hr = pProfileMgr->QueryInterface( IID_IWMCodecInfo3, ( void ** ) &pCodecInfo );
hr = pCodecInfo->GetCodecInfoCount(WMMEDIATYPE_Video, &cCodecs);
// Loop through the video codecs. for(dwCodecIndex = 0; dwCodecIndex < cCodecs; dwCodecIndex++) { hr = pCodecInfo->GetCodecFormatCount ( WMMEDIATYPE_Video, dwCodecIndex, &cFormats );
pCodecInfo->GetCodecFormat (WMMEDIATYPE_Video,dwCodecIndex,0, &pIStreamConfig); hr = pIStreamConfig->QueryInterface(IID_IWMMediaProps, (void **) &pImediaprops ); hr = pImediaprops->GetMediaType(0x00, &pcbType); pMediaType = (WM_MEDIA_TYPE*) new BYTE[pcbType]; hr = pImediaprops->GetMediaType(pMediaType, &pcbType);
if(pMediaType->subtype == WMMEDIASUBTYPE_WMVP) { hr = ppProfile->CreateNewStream( pMediaType-
[Quoted Text] >subtype,
&pIWMStreamConfig2 ); hr = pIWMStreamConfig2->GetStreamNumber ( &wStreamNum ); hr = pIStreamConfig->SetStreamNumber ( wStreamNum ); hr = pIStreamConfig->SetStreamName( L"Video Stream" ); hr = pIStreamConfig->SetConnectionName ( L"Video" ); hr = pIStreamConfig->SetBitrate( dwBitrate ); hr = pIStreamConfig->QueryInterface ( IID_IWMMediaProps, (void **) &pIWMMediaProps2 ); hr = pIWMMediaProps2->SetMediaType (pMediaType );
hr = ppProfile->AddStream ( pIStreamConfig ); // hr = -1072889796
hr = WMCreateWriter(NULL, &pWriter);
hr = pWriter->SetProfile(ppProfile); // hr = -1072886842
hr = pWriter->GetInputCount( &cInputs );
// rest of the programm // //
} delete[] pMediaType;
}
CoUninitialize(); return 0; }
|
|
From: "Kelum"
[Quoted Text] > object ( ppProfile->AddStream( pIStreamConfig ) ) the > return value of HRESULT is -1072889796. And also when > setting the profile to the writer object ( > pWriter->SetProfile(ppProfile) ), the return value of > HRESULT is -1072886842.
You should print out HRESULTs in hex, which makes them far more readable, and you should look them up in nserror.h, since I don't think anybody has them memorized.
You errors are:
-1072889796 0xc00d003c NS_E_INVALID_STREAM -1072886842 0xc00d0bc6 NS_E_INVALIDPROFILE
The following articles give you possible reasons why you get those errors:
http://msdn.microsoft.com/en-us/library/aa388792(VS.85).aspx http://msdn.microsoft.com/en-us/library/aa390152(VS.85).aspx
> The source code of the program is attached with this.(I > have indicated the > error values as comments on the source code). Can any one > help me to identify the problem here?
Your code doesn't make sense:
1. you get an IStreamConfig (A) from a codec object
2. you create a new IStreamConfig (B)
3. copy the stream number from B to A (???)
4. set some properties on A
5. copy the media type from A to B (???)
6. add A to the profile
You should simply
1. create the IStreamConfig from the codec object,
2. get, complete and set its media type (http://msdn.microsoft.com/en-us/library/aa384772(VS.85).aspx),
3. set the other stream properties (http://msdn.microsoft.com/en-us/library/aa384565(VS.85).aspx),
4. then add this stream to the profile.
Maybe you should take a look at GenProfile sample.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
|