Need help shutting down IWMEncBroadcast ...

Discussion in 'Professional Video Production' started by alvinkrebs, May 5, 2005.

  1. alvinkrebs

    alvinkrebs Guest

    Hello All,

    I'm writing a little application that uses the windows media encoder.
    I've managed to set up an IWMEncBroadcast instance which can be picked
    up by a client running windows media player.

    At the same time, I'm saving the resulting sink file in a transcode
    directory so the next time a client comes in and wants to see a video
    that's already been played, I can just stream it out using the WMFSDK.

    When I do use the WMFSDK there are a few steps that occur when the
    stream ends:
    1. writer->Flush()
    2. writer->EndWriting()
    3. writerAdv->RemoveSink()
    and
    4. netSink->Close()

    These guys do a nice job of closing down the connection, leaving the
    client in a nice state, ready for another request.

    Is there similar support using the Encoder? I can't find it. When the
    stream ends the player pops up a "Network error has occurred ..."
    message (error C00D11C0). This coincides with the encoder shutting down
    the broadcast instance using IWMBroadcast->Release().

    Any ideas??

    Best,

    AlvinK
     
    alvinkrebs, May 5, 2005
    #1
    1. Advertisements

  2. As I'm pretty simple guy, so I usually call these in order :

    WMEncoder.Stop();
    WMEncoder.Reset();

    These methods are documented in the encoder SDK here :
    http://msdn.microsoft.com/library/d...ry/en-us/wmencode/htm/iwmencoderinterface.asp

    This releases the broadcast port (if you stop but don't reset, the
    encoder holds open the broadcast port, which appears to be listening
    for connections but isn't).

    The best place to handle network errors is on the client, so add some
    code to watch the playState or readyState of the player, and trap for
    error values using the error object.

    HTH
    CHeers - Neil
     
    Neil Smith [MVP Digital Media], May 6, 2005
    #2
    1. Advertisements

  3. alvinkrebs

    alvinkrebs Guest

    Hello,

    Thank you for the reply. I've added this call to my code but I'm still
    getting the same symptom. Maybe I should explain what I'm trying to do.


    I have a directory that has mp3 files. I'd like to stream these files
    to either my office laptop, behind a corporate T3, or my cell phone,
    behind a wap gateway; probably capable of about 30kb/sec. (Edge is not
    here yet, and I can't afford an edge phone anyways).

    That's where the encoder comes in. I use the encoder to trim down the
    bitrate, saving the resulting file to another directory containing
    music files with similar bit rates, call them "small". Before I knew
    about broadcasting from the encoder, I'd let the encoder complete,
    then, using WMFSDK, stream the resulting file to whatever device
    requested the content. It wasn't too bad, especially audio only stuff;
    that would take maybe 10% of running time to encode a "large" bitrate,
    and about half that for a "small" bitrate.

    So, now that I know the encoder can broadcast, that's what I'd like to
    use in cases where the mp3 files have not been stripped down.

    And that's where I see the problem. My client is simply windows media
    player 10, and I guess some mini version of windows media player on my
    cell phone. So, it's difficult to debug cell phone clients without an
    emulator (I guess).

    And I'm no expert (probably not even a novice) when it comes to
    debugging windows media player, other than using ethereal and seeing
    what's coming in.

    What do you think?

    bobg
     
    alvinkrebs, May 10, 2005
    #3
  4. Does it work when you connect WMP10 to the encoder port, and with the
    player on the same machine as the encoder (thereby bypassing any
    firewalls or NAT devices) ?

    Also bear in mind the encoder seems to have a very long lag between
    completing an encode session and shutting down. Especially using http
    broadcast with a file archive - for no apparent reason. But my tests
    with the encoder suggest *at least* 5-10 seconds before you can use it
    again after finishing one encode and starting another.

    The encoder has an event for this, and you can query the runState too
    if you prefer :

    HRESULT get_RunState(
    WMENC_ENCODER_STATE* penumState
    );

    "penumState" is an enumeration with these possible values (WME SDK)

    WMENC_ENCODER_STARTING = 1,
    WMENC_ENCODER_RUNNING = 2,
    WMENC_ENCODER_PAUSED = 3,
    WMENC_ENCODER_STOPPING = 4
    WMENC_ENCODER_STOPPED = 5,
    WMENC_ENCODER_END_PREPROCESS = 6
    WMENC_ENCODER_END_PAUSING = 7

    When the encoder is running it's consistently in state 2, when it's
    stopping you should see state 4, and this can be held for several
    seconds. Only when it's runState is 5 can you restart the encoder by
    adding a new source group and calling prepareToEncode() again.
    I can't think of any apart from the windows mobile smartphones -
    everything else seems to run real player or a proprietary java player,
    so unless it has the windows logo on it, it won't be playing WMP
    files.
    Sound pretty advanced to me (it's what I use, though "Effetech HTTP
    Sniffer" is simpler in many cases, it's not free and Etherial is cross
    platform ;-)

    Cheers - Neil
     
    Neil Smith [MVP Digital Media], May 11, 2005
    #4
  5. alvinkrebs

    alvinkrebs Guest

    Hello There,

    Thanks again for your quick reply.

    The encoder is streaming content on its broadcast port. You can
    connect directly to it with http://localhost:8989; and just prior to
    playing, I send an ASX file with the streamer's public ip address, this
    also works fine.

    Each time the encoder finishes, or is interrupted, I wait for the
    transission to WMENC_ENCODER_STOPPED prior to any other communication
    with the client **that I control**. I'll have a look at the ethereal
    output to see if there is any special sauce being sent by IWMEncoder*.

    As far as the delay when the content has finished streaming, I make an
    attempt to adhere to an MS whitepaper that describes three points in a
    streaming session that incur delay, each stage I've assigned 5 seconds,
    making a sleep time of 15 seconds at the end of each session prior to
    disconnecting the client. This seems to work well when streaming to a
    cell phone, but not to a LAN connected device.

    .... yes, the cell phone I'm using is a Motorola, MPx220, with internet
    explorer and Windows Media 9 Series Player. I'm not sure what version
    of each as there's no About ... widget anywhere on either UI.

    bobg
     
    alvinkrebs, May 13, 2005
    #5
  6. alvinkrebs

    alvinkrebs Guest

    Hello There,

    I've posted some observations to microsoft.public.windowsmedia.encoder
    under the topic "Trouble shutting down broadcast from encoder". I
    thought you'd like to see them, kind of interesting ...

    bobg
     
    alvinkrebs, May 17, 2005
    #6
  7. I know, I hang out there too ;-) Usually Alessandro is the guy for the
    WM Format SDK stuff, he "really knows his shit" as ya say.

    Cheers - Neil
     
    Neil Smith [MVP Digital Media], May 18, 2005
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.