On Tue, 30 May 2000, Ed Patriquin wrote:

> 
> Let's sync up.
> 
> Goal: Provide an arbitrary byte stream to the IWMReader object in the
> Windows Media Format SDK.
> 
> Here is the psuedocode for what I am trying to do:
> 
> I never get the chance to serve up any data to anyone as the Accept in the
> server thread never returns in this scenario.  Does this make things a
> little clearer.

  A little...
  I can't look at it in depth tonight, but here's a snippet of code from
my stuff.  It's unlikely that this will solve your problem, but it's all I
have time to do *right now*.  I'll try to dive in later.  This is all from
the windows media side of things, not the socket side of things.

        ECS(data->port_cs);
        sprintf(szUrl,"http://127.0.0.1:%i/%i",*data->port,key);
        LCS(data->port_cs);

        MultiByteToWideChar(CP_ACP,0,szUrl,-1,wsUrl,256);

//              create the WMA reader
        hr = WMCreateReader(NULL, 0, &comReader);
        if (hr!=S_OK) {ODS("Could not get a reader\n");}

//      open the reader, with cNoise->OnSample as the callback
        ResetEvent(data->hWait);

        hr = data->noise->QueryInterface(IID_IWMReaderCallback, (void **)
&comCallback);
        if (hr!=S_OK) {ODS("cNoise couldn't be a callback\n");}
        
        if (hr == E_NOINTERFACE) 
          {ODS("No Interface?  (hmmm....)\n");}
        if (hr == REGDB_E_CLASSNOTREG)  
          {ODS("Class not registered.  (oh fuck)\n");}
        if (hr == CLASS_E_NOAGGREGATION) 
          {ODS("Class can not be aggregated.  (huh?)\n");}

        hr = comReader->Open(wsUrl, comCallback, 0);
        if (hr!=S_OK) {ODS("Could not open the reader\n");}

        WaitForSingleObject(data->hWait, INFINITE);

  data->hWait gets set by the object data->noise, which implements the
callback, which is called by the system during opening:

STDMETHODIMP CSound::OnStatus( 
            /* [in] */ WMT_STATUS Status,
            /* [in] */ HRESULT hr,
            /* [in] */ WMT_ATTR_DATATYPE dwType,
            /* [in] */ BYTE __RPC_FAR *pValue,
            /* [in] */ void __RPC_FAR *pvContext)
{
//      ODS("OnStatus\n");
switch (Status)  {
        case WMT_OPENED:  ODS("OnStatus(WMT_OPENED)\n");
                HANDLE hWait;
                hWait =
OpenEvent(EVENT_MODIFY_STATE,FALSE,"windowsmedia_open");
          SetEvent(hWait);
          break;

  there are a bunch of other cases that you should consider processing,
and a similar function:

STDMETHODIMP CSound::OnSample( 
            /* [in] */ DWORD dwOutputNum,
            /* [in] */ QWORD cnsSampleTime,
            /* [in] */ QWORD cnsSampleDuration,
            /* [in] */ DWORD dwFlags,
            /* [in] */ INSSBuffer __RPC_FAR *pSample,
            /* [in] */ void __RPC_FAR *pvContext)
{
//      ODS("OnSample\n");
//      ODS("on sample\n");
        struct sound *s;
        s = (struct sound *)CoTaskMemAlloc(sizeof(struct sound));
        unsigned char *in;

        pSample->GetBufferAndLength(&in,&(s->size));

  which is called for each sample.

  If this helps at all, tell me.  If it doesn't help at all, tell me that
too.  Oh, ODS is a macro for outputdebugstring, and ECS/LCS are enter
critical section and leave critical section.  Neither have any real effect
on the code, at least not the part you're trying to understand.

_______________________________________________
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev

Reply via email to