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.



//              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

        hr = data->noise->QueryInterface(IID_IWMReaderCallback, (void **)
        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:

            /* [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 =

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

            /* [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;


  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.


Reply via email to