Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Entertainment » microsoft.public.windowsmedia.sdk
Thread: recordeing Encoder Stream to Disk

HTVi
TV Discussion Newsgroups

recordeing Encoder Stream to Disk
Max 12/19/2008 11:29:01 AM
Hello,
I’m writing an application that uses the Windows Media Format API to read a
stream, broadcast by Windows Media Encoder, and save it to disk.
I’ve written a quick test application in C++ to test that this can be done.
The app can open the stream but cannot save it, getting a FALSE output from
the call to IWMReaderAdvanced4->CanSaveFileAs().
Can anyone point me in the right direction here?
Can streams be saved to disk? The Windows Media Format API suggests this is
possible.

I’ve added some of my source and header code below.
The Init() function is called first and when an WMT_OPENED message is
received ReadStream() is called.
Please excuse the style.

Cheers,
Max.

bool WMStreamReader::Init
(
uint16 p_PortNum,
const char8* p_pIpAddress
)
{
CStringW OpenObjectName("OpenObject");
m_OpenObject = ::CreateEvent( NULL, FALSE, FALSE, OpenObjectName );

bool Success = false;
IUnknown* pUnknownReserved = NULL;
DWORD Rights = 0;

Success = WMCreateReader( pUnknownReserved,
Rights,
&m_pReaderInterface) == S_OK;

if (Success)
{
AddRef();
{
WM_READER_CLIENTINFO ClientInfo;
::memset(&ClientInfo, 0, sizeof(WM_READER_CLIENTINFO));
ClientInfo.cbSize = sizeof(WM_READER_CLIENTINFO);
char* pOrig("NSPlayer/10.0.0.3802");
size_t origsize = strlen(pOrig) + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
wchar_t wcstring[newsize];
convertedChars = mbstowcs(wcstring, pOrig, origsize);
ClientInfo.wszPlayerUserAgent = wcstring;
IWMReaderAdvanced* pIWMReaderAdvanced = NULL;
Success = m_pReaderInterface->QueryInterface( IID_IWMReaderAdvanced,
reinterpret_cast<void**>(&pIWMReaderAdvanced)) == S_OK;
if (pIWMReaderAdvanced != NULL)
{
Success = pIWMReaderAdvanced->SetClientInfo(&ClientInfo) == S_OK;
}
}

// set up fast caching
Success = m_pReaderInterface->QueryInterface( IID_IWMReaderNetworkConfig2,
reinterpret_cast<void**>(&m_pIWMReaderNetworkConfig2)) == S_OK;

if (Success)
{
BOOL EnableCaching = TRUE;
Success =
m_pIWMReaderNetworkConfig2->SetEnableContentCaching(EnableCaching) == S_OK;
}

if (Success)
{
BOOL EnableFastCaching = TRUE;
Success =
m_pIWMReaderNetworkConfig2->SetEnableFastCache(EnableFastCaching) == S_OK;
}
{
char* pOrig("http://192.168.0.3:2433?WMCache=1");
size_t origsize = strlen(pOrig) + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
wchar_t wcstring[newsize];
convertedChars = mbstowcs(wcstring, pOrig, origsize);

Success = m_pReaderInterface->Open( wcstring,
this,
NULL) == S_OK;
}
}

return Success;
}

bool WMStreamReader::ReadStream()
{
bool Success = false;

Success = m_pReaderInterface->QueryInterface( IID_IWMReaderAdvanced4,
reinterpret_cast<void**>(&m_pIWMReaderAdvanced4)) == S_OK;

if (Success)
{
WMT_PLAY_MODE Mode = WMT_PLAY_MODE_AUTOSELECT;
Success = m_pIWMReaderAdvanced4->GetPlayMode(&Mode) == S_OK;
Mode = Mode;
}

if (Success)
{
BOOL CanSave = TRUE;
// Success = m_pIWMReaderAdvanced4->CanSaveFileAs(&CanSave) == S_OK &&
CanSave != FALSE;
Success = m_pIWMReaderAdvanced4->CanSaveFileAs(&CanSave) == S_OK;
Success = Success && CanSave != FALSE;
CanSave = CanSave;
}

BOOL UsingFastCache = FALSE;
if (Success)
{
Success = m_pIWMReaderAdvanced4->IsUsingFastCache(&UsingFastCache) == S_OK;
}

if (Success)
{
CStringW FileName;
if (UsingFastCache == FALSE)
{
CStringW ASFFileName("Recorded.ASF");
FileName = ASFFileName;
}
else
{
CStringW ASXFileName("Recorded.ASX");
FileName = ASXFileName;
}

// Success = m_pIWMReaderAdvanced4->SaveFileAs(FileName) == S_OK;
HRESULT Result = m_pIWMReaderAdvanced4->SaveFileAs(FileName);
Success = Result == S_OK;
}

return Success;
}

Re: recordeing Encoder Stream to Disk
"Chris P." <msdn[ at ]chrisnet.net> 12/19/2008 5:13:57 PM
On Fri, 19 Dec 2008 03:29:01 -0800, Max wrote:

[Quoted Text]
> I¢m writing an application that uses the Windows Media Format API to read a
> stream, broadcast by Windows Media Encoder, and save it to disk.
> I¢ve written a quick test application in C++ to test that this can be done.
> The app can open the stream but cannot save it, getting a FALSE output from
> the call to IWMReaderAdvanced4->CanSaveFileAs().
> Can anyone point me in the right direction here?
> Can streams be saved to disk? The Windows Media Format API suggests this is
> possible.
>
> I¢ve added some of my source and header code below.
> The Init() function is called first and when an WMT_OPENED message is
> received ReadStream() is called.

What is the HRESULT return value? If you can read the stream you can save
it, however the built in SaveFileAs() may not work in all cases. AFAIK it
is designed to work the HTTP download, not HTTP streaming.

--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]
Re: recordeing Encoder Stream to Disk
Max 12/22/2008 8:12:00 AM
Hi Chris,
the HResult to the CanSaveFileAs(). call is S_OK, but the Bool that is
output is set to FALSE.
I'll push on and se what happens if I ignore the FALSE value.
Cheers,
Max.

"Chris P." wrote:

[Quoted Text]
> On Fri, 19 Dec 2008 03:29:01 -0800, Max wrote:
>
> > Iʼm writing an application that uses the Windows Media Format API to read a
> > stream, broadcast by Windows Media Encoder, and save it to disk.
> > Iʼve written a quick test application in C++ to test that this can be done.
> > The app can open the stream but cannot save it, getting a FALSE output from
> > the call to IWMReaderAdvanced4->CanSaveFileAs().
> > Can anyone point me in the right direction here?
> > Can streams be saved to disk? The Windows Media Format API suggests this is
> > possible.
> >
> > Iʼve added some of my source and header code below.
> > The Init() function is called first and when an WMT_OPENED message is
> > received ReadStream() is called.
>
> What is the HRESULT return value? If you can read the stream you can save
> it, however the built in SaveFileAs() may not work in all cases. AFAIK it
> is designed to work the HTTP download, not HTTP streaming.
>
> --
> http://www.chrisnet.net/code.htm
> [MS MVP for DirectShow / MediaFoundation]
>
Re: recordeing Encoder Stream to Disk
Max 12/22/2008 12:57:01 PM
I think what I'll do is write the read/write glue myself, opening the stream
with an asynchonous reader and writing the encoded samples into an asf file.
Cheers,
Max.

"Max" wrote:

[Quoted Text]
> Hi Chris,
> the HResult to the CanSaveFileAs(). call is S_OK, but the Bool that is
> output is set to FALSE.
> I'll push on and se what happens if I ignore the FALSE value.
> Cheers,
> Max.
>
> "Chris P." wrote:
>
> > On Fri, 19 Dec 2008 03:29:01 -0800, Max wrote:
> >
> > > Iʼm writing an application that uses the Windows Media Format API to read a
> > > stream, broadcast by Windows Media Encoder, and save it to disk.
> > > Iʼve written a quick test application in C++ to test that this can be done.
> > > The app can open the stream but cannot save it, getting a FALSE output from
> > > the call to IWMReaderAdvanced4->CanSaveFileAs().
> > > Can anyone point me in the right direction here?
> > > Can streams be saved to disk? The Windows Media Format API suggests this is
> > > possible.
> > >
> > > Iʼve added some of my source and header code below.
> > > The Init() function is called first and when an WMT_OPENED message is
> > > received ReadStream() is called.
> >
> > What is the HRESULT return value? If you can read the stream you can save
> > it, however the built in SaveFileAs() may not work in all cases. AFAIK it
> > is designed to work the HTTP download, not HTTP streaming.
> >
> > --
> > http://www.chrisnet.net/code.htm
> > [MS MVP for DirectShow / MediaFoundation]
> >

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen