Welcome to MSDN Blogs Sign in | Join | Help
Diagnosing and Tuning Expression Encoder 3 SmoothStreaming Performance using SmoothStreamingConfig.xml

The Expression Encoder 3 Smooth Streaming Media Stream Source allows configuration via a file “SmoothStreamingConfig.XML” when it is placed in the same folder on the webserver as the copy of ”SmoothStreaming.XAP”.    An archetypical copy of “SmoothStreamingConfig.XML” is attached to this post that documents the “Factory Default”  configuration.  By placing a copy of the file and adjusting the values within it is possible to obtain additional diagnostic information and to also tune the bitrate switching behavior of Smooth Streaming heuristics.

Contained within the  archetypical copy of “SmoothStreamingConfig.XML” are XML comments that provide some explanation of the purpose and meaning of each setting.    The “factory default” settings are intended to work in a wide variety of cases – if you decide to override the default settings it is wise to test the playback performance on a range of client machines – slow machines, fast machines, broadband connections, DSL connects – choose a range of machines that closely matches that of your target audience.

 

Also attached to this post is a special "ReleaseTrace" build of “SmoothStreaming.XAP” – this build has additional diagnostic tracing code compiled into it.  The copy supplied with Expression Encoder 3 omits the additional tracing code in the interest of having as compact a .XAP as possible.  To see the trace data -- you'll need to attach a debugger to the browser process that is running the player as described in a prior post:  http://blogs.msdn.com/randyoakley/archive/2009/10/07/how-to-debug-expression-encoder-3-templates-with-smoothstreaming-content.aspx

 

 

 

How to debug Expression Encoder 3 templates with SmoothStreaming content

It’s trickier than you thought, but it isn’t that bad

 

When you edit  a copy of an Expression Encoder 3 template in Visual Studio 2008 SP1 – sometimes after you make changes they don’t always work as you expected the first time.  So you have to debug.   However debugging an EE3 Media Player template isn’t as easy as pressing “F5” is Visual Studio – at least when you are trying to use SmoothStreaming content.

 

With smooth streaming it is more complex.  The main reason for this is that the Smooth Streaming content is downloaded from the web server to the client using the HTTP: protocol.  However when you launch the template from within Visual Studio 2008 – the website is launched using the FILE: protocol and as a result the HTTP: protocol isn’t available to deliver packets to the client.

 

There are several ways to solve this problem and debug effectively.   In this post I will outline one approach that has worked for me.

 

1)       Setup a test web server.  Install Windows Server 2008 and enable IIS7 and install the latest release of the IIS Media PlugIn.   I recycled a several year old development machine for this – it doesn’t need much capacity – since the number of users will be small.  To facilitate dropping new content and new builds of the .XAPs onto the server I usually enable file sharing and share out the WWWROOT of the website.

2)      Use Expression Encoder 3 to encode some Smooth Streaming test content – be sure to select a template – hopefully the one you want to debug.  Once the encoding process is complete copy the entire contents of the output to a new folder under the WWWROOT.   I recommend that  you uncheck the “Load Content Automatically” and “Play content automatically” checkboxes in Expression Encoder – this will make debugging easier. (more on this later)

3)      Start Visual Studio 2008 and load the Template.SLN file for the template you are trying to debug.

4)      Launch Internet Explorer and type in the URL for the webpage just created.

5)      In VS2008 use the Debug->Attach To Process command – 1st change the “Attach To” setting to “Silverlight” or “Silverlight Code”.  2nd find the right process to connect to – this is a bit tricky since IE8 creates two processes – one for IE and one for the webpage.  The one you want will have a blank title and say “Silverlight, x86” under the Type column.

6)      Once you attached – set a breakpoint near the suspected bit of code.

7)      If the code you are trying to debug is related to initialization – “unchecking” the “autoplay” check boxes about will help – refreshing the page in IE8 will restart the player – but leave the debug session intact.

8)      If you are one of the few that need to debugging the code in SmoothStreaming.XAP – the break points will not be active until SmoothStreaming.XAP has be downloaded and merged into the process.

9)      Once you identify a problem you’ll need to disconnect the debug session, exit IE and then fix the code and rebuilt the affected .XAP .  I usually just drag the new .XAP to the webpage folder using Explorer (keeping two explorer windows open)  If I’ve got a lot of  work – sometimes I will add post-build step to copy the new XAP(s) to the test server share.

TTFN

Powepoint Slide Deck for Silverlight Summit presentation
I've attached the PPTX from my presentation at  the Silverlight Summit
Source code for VS2008 extended Expression Encoder Player
ZIP file attached to post contains the complete source code for the extended player I'm demonstrating at the Silverlight Summit
Using Javascript to control Expression Encoder SP1 Silverlight 2 templates.

The Silverlight 2 player templates included  with Expression Encoder SP1 were released without enabling scripting from JavaScript.  

 

Here is how to customize the Silverlight 2 templates to allow scripting.

 

1)      In Expression Encoder SP1 select the template you would like to script (e.g. “Silverlight 2 Default”) and invoke the “Edit Copy in Visual Studio” command.

2)      In VS find the “ExpressionPlayer” class and add the  [ScriptableType] attribute  to the class.

3)      For each of the public methods that you need to invoke from script add the [ScriptableMember] attribute.  Note: some of the methods you may want are defined in the “MediaPlayer” class that “ExpressionPlayer” is derived from.  e.g.  the “Stop” method is defined in “MediaPlayer”

4)      In the constructor for the “ExpressionPlayer” class add:

HtmlPage.RegisterScriptableObject("playerObject", this);

5)      In default.html name the Silverlight object   e.g.   <object id=”PLAYER”  … >

6)      In your JS you can then write script like:

var player = document.all(“PLAYER”);
player.Content.playerObject.Stop();

Page view tracker