Sorry for repeat this quetion again, my project needs this solution
urgently, and standstill! We think we almostly succeed, but only less
the key point...So anyone kindly help? thanks!
Below is my code:
///////////////////////////////////////Build SBE
file///////////////////////////////////////////////////
HRESULT hr = S_OK;
IStreamBufferConfigure3* pStreamBufferConfigure = NULL;
IStreamBufferInitialize* pStreamBufferInitialize = NULL;
IStreamBufferSink* pStreamBufferSink = NULL;
CFilterProxy* StreamAnalyzer = NULL;
CFilterProxy* SBSink = NULL;
hr = DVBT.m_gbMain->AddFilter("{6CFAD761-735D-4AA5-8AFC-
AF91A7D61EBA}","MPEG-2 Video Stream Analyzer",&StreamAnalyzer);
hr = DVBT.m_gbMain->AddFilter("{2DB47AE5-CF39-43C2-
B4D6-0CD8D90946F4}","StreamBufferSink",&SBSink);
hr = DVBT.m_gbMain->CONNECTOK(DVBT.videoPin ,StreamAnalyzer-
>FirstDisconnectedPin(TRUE));
hr = DVBT.m_gbMain->CONNECTOK(StreamAnalyzer-
>FirstDisconnectedPin(FALSE) ,SBSink->Pin("DVR In - 1"));
memset(szTempSBE, 0, 260);
win.GetMyTempPath(szTempSBE);
SHGetSpecialFolderPath(NULL,tmp_szTempSBE, CSIDL_TEMPLATES, true);
DeleteDirectory(szTempSBE); // clear TempSBE folder
_strset(szSpecialFolderPath,'\0');
MultiByteToWideChar(
CP_ACP, // code page
MB_PRECOMPOSED, // character-type options
szSpecialFolderPath, // string to map
MAX_PATH, // number of bytes in string
lpszTemplateDir, // wide-character buffer
MAX_PATH // size of buffer
);
strncpy(szSpecialFolderPath+strcspn(szSpecialFolderPath,"\0"),"\
\stubfile.sbe",14);
DeleteFile(szSpecialFolderPath);
MultiByteToWideChar(
CP_ACP, // code page
MB_PRECOMPOSED, // character-type options
szSpecialFolderPath, // string to map
MAX_PATH, // number of bytes in string
lpszStubFile, // wide-character buffer
MAX_PATH // size of buffer
);
hr =
CoCreateInstance(CLSID_StreamBufferConfig,NULL,CLSCTX_INPROC_SERVER,
IID_IStreamBufferConfigure,reinterpret_cast<void**>
(&pStreamBufferConfigure));
hr = pStreamBufferConfigure-
>QueryInterface(__uuidof(IStreamBufferInitialize),
(void**)&pStreamBufferInitialize);
hr = RegCreateKey(HKEY_LOCAL_MACHINE,TEXT("SOFTWARE\
\MyStreamBufferKey"), &hkey);
hr = pStreamBufferInitialize->SetHKEY(hkey); // Set the registry key
if(xSbeMinutes==0)
xSbeMinutes=30;
hr = pStreamBufferConfigure->SetBackingFileCount(15,17);
hr = pStreamBufferConfigure->SetBackingFileDuration(xSbeMinutes*4);
hr = pStreamBufferConfigure->SetDirectory(lpszTemplateDir); // Set
the backing file directory
hr = pStreamBufferConfigure->SetNamespace(NULL); //S_OK
RELEASE(pStreamBufferConfigure);
RELEASE(pStreamBufferInitialize);
hr = SBSink->QueryInterface(__uuidof(IStreamBufferSink),(void
**)&pStreamBufferSink);
if( hr == S_OK )
{
hr = SBSink->QueryInterface(__uuidof(IStreamBufferInitialize),
(void**)&pStreamBufferInitialize);
hr = pStreamBufferInitialize->SetHKEY(hkey); // Set the registry key
RELEASE(pStreamBufferInitialize);
//AfxMessageBox("LockProfile!");
hr = pStreamBufferSink->LockProfile(lpszStubFile); // don't know why
sometimes failed
//AfxMessageBox("After LockProfile!");
RELEASE(pStreamBufferSink);
if(hr != S_OK) //lockProfile failed...
{
//do something here to leave SBE...
//AfxMessageBox("Please run TVGo using Run as administrator!");
return 0;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
All hr of above are S_OK, and succefully there are some SBE files made
in C:\Users\vannes\AppData\Roaming\Microsoft\Windows\Templates\; but
then I try load it fail:
/////////////////////////////////////////////////////Play SBE
file/////////////////////////////////////////////////////////////
HRESULT hr = S_OK;
HRESULT hrBuild = S_OK;
DVBT.m_gbSBE = new CGraphBuilder; //give timeshift graph a physical
address
if(!DVBT.m_bSBE)
return 999;
ADDFILTER("{C9F5FE02-F851-4EB5-99EE-
AD602AF1E619}","StreamBufferSource",SBSource);
hr = SBSource->QueryInterface(__uuidof(IFileSourceFilter),(void
**)&pFileSourceFilter);
if(hr==S_OK)
{
hr = pFileSourceFilter->Load(lpszStubFile,0); //This line will fail
if(hr!=S_OK)
{
DESTROY(DVBT.m_gbSBE);
DVBT.VMRenderer2 = NULL;
return E_FAIL;
}
RELEASE(pFileSourceFilter);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The command "Load" seems fail and the compiler's message is
0x80070020, and I tried so many methods still fail.
Is anyone know how to solve it? thx a lot.
By the way, my project is build by VC2003, use windows SDK for vista.
> The command "Load" seems fail and the compiler's message is
> 0x80070020, and I tried so many methods still fail.
I don't think that this is the compiler's message ;) FWIW, this HRESULT is:
HRESULT: 0x80070020 (2147942432)
Name: ERROR_SHARING_VIOLATION
Description: n/a
Severity code: Failed
Facility Code: FACILITY_WIN32 (7)
Error Code: 0x0020 (32)
I don't know why the OP didn't bother to include the details.
--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution