Live Smooth Streaming: How-to: Retrieve the configuration settings programmatically

In my previous post, I explained how the Microsoft.Web.Administration API of IIS7 helped us to manage the Live Smooth Streaming Publishing Points programmatically. In this post I’m going to show you how, using the same API, you can retrieve the Live Smooth Streaming configuration settings.

First, let’s take a look at the Live Smooth Streaming configuration settings window

image

The main idea here is to read the Live Streaming configuration section and get the attributes values from there. The piece of code looks like:

const string LiveStreamingSectionPath = “system.webServer/media/liveStreaming”;

ServerManager serverManager = new ServerManager();

Configuration configuration = serverManager.GetApplicationHostConfiguration();
ConfigurationSection section = configuration.GetSection(LiveStreamingSectionPath);

if (section != null)
{
    foreach (ConfigurationAttribute attribute in section.Attributes)
    {
        Console.WriteLine(“{0}: {1}”, attribute.Name, attribute.Value);
    }

    Console.ReadLine();
}

Running the preceding code will output the following:

image

As you see, reading the configuration settings is easy and can enable you different scenarios, for example, deleting the archived streams of a publishing point.
If you want to take a look at the Live Smooth Streaming schema, go to %windir%\System32\inetsrv\config\schema and open the IISMedia_LiveStreaming_schema.xml file.

Happy streaming!

Live Smooth Streaming: How-to: Start, Stop & Shutdown a Publishing Point Programmatically

During the last months I have been working in a project highly related to multimedia and iis-smoothclient development technologies such as Silverlight. And in the last few weeks, I started to look to some of the new IIS Media services such as Smooth Streaming and Live Smooth Streaming in order to gather as much knowledge about them to perform some spikes for the project.

One of the things that came up while spiking was finding a way to start, stop & shutdown a publishing point via code.

Microsoft.Web.Administration to the Rescue

ServerManagerWith IIS7 a new API to administer IIS from managed code was introduced. This API is really simple to use and with a few lines of code you can manipulate the server configuration as any other information available in IIS7. (if you want to taste the power of this API, I recommend you to read this post from Carlos Aguilar Mares).

So, I used the Microsoft.Web.Administration.dll assembly, that can be found at IIS Directory (%windir%\System32\inetSrv), to perform the operations over the publishing point. But it was not so easy to do it, as there is no information available yet about what RSCA function has to be called  and which parameters need to be used in order get the desired results.

Then, I started to look at the different IIS configuration files (%windir%\System32\inetsrv\config) searching for clues and I came up with the Microsoft.Web.Management.Media.LiveStreaming.dll assembly (this assembly can be found in the GAC after installing the Live Smooth Streaming bits).

In that moment I summoned my best friend Reflector and together went to the depths of this assembly until we found some code that might be useful for our objective.

After doing some tests, I ended up with the following method:

private static void ExecuteRscaFunction(ConfigurationElement workerProcess,
                                        string siteName, string applicationPath,
                                        string fileName, string functionName)
{
    ConfigurationMethod configurationMethod = workerProcess.Methods["GetCustomData"];

    ConfigurationMethodInstance instance = configurationMethod.CreateInstance();
    instance.Input["guidIdOfFunctionCall"] = “Media_LiveStreaming_Control”;

    string currentLogicalPath = applicationPath;

    if (!currentLogicalPath.EndsWith(“/”, StringComparison.OrdinalIgnoreCase))
    {
        currentLogicalPath = currentLogicalPath + “/”;
    }

    string fullPath = string.Concat(currentLogicalPath, fileName);
    string parameters = string.Format(CultureInfo.InvariantCulture, “{0};{1};{2}”,
                                      functionName, siteName, fullPath);
    instance.Input["parametersOfFunctionCall"] = parameters;
    instance.Execute();
}

The most important thing of the method above is the functionName parameter. This parameter can be one the following values depending on what you want to accomplish:

  • StartPublishingPoint. This is used to start a publishing point.
  • StopPublishingPoint. This is used to stop the live source of the publishing point.
  • ShutdownPublishingPoint. This is used to shutdown a publishing point.

To understand where the others parameters should come from, let’s take a look at the following example: image So, if we want to the start the LiveSmoothStream publishing point associated to the SmoothStreaming application from the Default Web Site, we should call the ExecuteRscaFunction method in this way:

ExecuteRscaFunction(workerProcess,
                    “Default Web Site”, “/SmoothStreaming”,
                    “LiveSmoothStream.isml”, “StartPublishingPoint”);

The remaining parameter (workerProcess) must be retrieved from the application pool associated to the application.

Note: You can use the Microsoft.Web.Administration API to get all the values previously mentioned.

To see if the function is working you can add the following lines of code at the end of the method to parse the output and print it on the console.

string rawOutput = instance.Output["data"] as string;

byte[] bytes = Convert.FromBase64String(rawOutput);
ASCIIEncoding encoding = new ASCIIEncoding();

Console.WriteLine(encoding.GetString(bytes));

The output after executing the Stop, Shutdown and Start functions:

image

Hope this helps!. If you want to learn more about Smooth Streaming you might find useful the following links:

Happy streaming!.

kick it on DotNetKicks.com

Prism v2: Migrating from Drop 9 to Drop 10

As you may know, last Friday a new drop of the Composite Application Guidance for WPF & Silverlight was released.

As Erwin said in this post, one of the breaking changes of this new drop is that they removed the .Silverlight and .Desktop extensions from the Assembly names. If you are like me and have more than one solution using Prism v2 with a bunch of projects, you will probably find really annoying going over each project to update the references and the xaml files.

So, in order to accomplish this, I created a Powershell script that will look for all the .csproj and .xaml that contain references to the old prism assemblies and will update it to the new version of them.

Note: If you have your code in TFS, make sure to go offline before running the script, so when you go back online it will detect the changes.

Disclaimer

This code is provided “AS IS” with no warranties, and confers no rights.

Download

You can find the script here.

 

Hope you find it useful.

PDC 2008 Time: Meet Me In Los Angeles

meetme During the latest months at Southworks, we have been working on several demos and materials for the Microsoft’s Professional Developer Conference 2008.

And in the last two weeks, with Matias and Edgardo, we were in Redmond (Microsoft Corp Main Campus) working hard with the Microsoft Developer & Platform Evangelism (DPE) Team on many different projects, all them related to PDC 2008.

Now is time to fly to LA. Matias, Edgardo, Tim, Alex, Johnny, Fede, and myself will be attending one of the biggest events designed for leading-edge developers and software architects.

There are a lot of sessions about many different topics, but the star will be the cloud. Microsoft will be announcing new technologies around the development platform, including the Windows Live Services Platform.

 

So if you are attending, let’s meet there. For sure that you will find me in the Cloud and Identity sessions.

CompositeWPF (Prism) Contrib Latest Additions (2008-10-26)

These are the latest extensions added to the CompositeWPF Contrib community project:

Download

You can get these extensions, among others, by downloading latest change set of the CompositeWPF Contrib source control.

Where I can find the documentation of the extensions added to the project?

To check the documentation of the extensions added so far, please visit the Documentation page in the community site.

 

Enjoy!

New Samples in CompositeWPF (Prism) Contrib (2008-09-13)

Four new samples has been added to the CompositeWPF Contrib community project:

Download

You can get these samples, among others extensions, by downloading latest change set of the CompositeWPF Contrib source control.

Coming soon

Some people has been asking for an OutlookBar sample. The good news is that Damian Schenkelman and me are working on it, so stay tuned, we will publish it soon.

Interested in migrating from Composite Application Block (CAB) to CompositeWPF (Prism)? Check our new guidance

As Diego Poza announced in his post, we have just published a new guidance to help CAB developers familiarize themselves with the Composite Application Guidance by comparing the main components of both libraries.

Let’s take a look at the guidance content index:

image

Because the Composite UI Application Block and the Composite Application Guidance are targeted to build composite applications, they have similar core concepts. These core concepts have different implementations. The following figure compares the implementation of the core concepts.
 image

Want more?

Download the Composite Application Guidance for Composite UI Application Block Developers from Codeplex.

Feedback

We really want your feedback on this guidance, so feel free to give us your feedback on the discussion board.

Enjoy!

Silverlight & Composite Application Guidance (Prism): Spike published

Weeks ago we shipped the Composite Application Guidance for WPF and with the Prism team we started to spike around the migration of the Composite Application Library to Silverlight 2 Beta 2. The good news is that yesterday we published that spike. (A ’spike’ is a small and quickly developed sample application in order to mitigate some risks).

After downloading and decompressing the latest change set of the source control, you will find a new folder named spikes that contains the Composite Application Library migrated to Silverlight. As you may imagine, there were many challenges that we had to address in order to make it “work”  (Rob Eisenberg wrote two articles describing differences between WPF and Silverlight that you might want to check: There’s some darkness in your silver light and Silverlight Problems That Affect Me).

Note: The migration is not complete, we used the spike to have a perspective of the challenges.

 

Modularity

Module loading in Silverlight is very different from WPF, so this was a challenge. We continued spiking on different approaches, but those spikes are not uploaded to Codeplex yet.

Regarding the module enumerators, System.Configuration is not supported by Silverlight current version, so we are using a new XML file module enumerator (not published either).

Regions

In WPF, the RegionManager attached property value gets inherited by the elements in the visual tree. This cannot be done in Silverlight due to the lack of the FrameworkPropertyMetadataOptions.Inherits option. However, we have found a workaround for this issue.

If you want to declare regions in XAML, you have to create an application resource to store the RegionManager instance, so it can be used by the views. This can be done in the Bootstrapper, as shown in the code below:

protected override void ConfigureContainer()
{
   base.ConfigureContainer(); IRegionManager regionManager = Container.Resolve<IRegionManager>();
   Application.Current.Resources.Add(“RegionManager”, regionManager);
}

And the view has to explicitly set the RegionManager attached property to the resource created previously.

<ItemsControl x:Name=”MainRegionControl” cal:RegionManager.RegionName=”MainRegion” cal:RegionManager.RegionManager=”{StaticResource RegionManager}” />

Events

Events has been migrated successfully, however, the unit tests are still a challenge because of the differences in threading between Silverlight and WPF. One difference we found, is that if you are subscribing to an event using weak references, for this reason you can only use public methods as delegates (lambdas, anonymous delegates or private methods won’t work) because of security restrictions enforced by Silverlight.

Commands

As you might know, the support for commands is missing in Silverlight. This is really bad news, considering that big part of our guidance talk about using Commands for communication between the modules and from the view.

I’m not going into deep details on this because Julian Dominguez published a great post explaining how to use commands in Silverlight.

Download

You can get the spike by downloading the latest change set of the CompositeWPF source control.

Notes

  • We didn’t ship the Unity Application Block, so I recommend you to see Michael Sync’s post in order to have Unity working on Silverlight.
  • In order to run the Unit tests, check Jeff Wilcox’post.

Feedback  / Contributions

Feel free to give us your feedback on the discussion board. If you want to contribute with the CompositeWPF project, check the CompositeWPF contrib. community site.

Enjoy!

CompositeWPF (Prism) Contrib Latest Additions (2008-07-26)

These are the latest extensions added to the CompositeWPF Contrib community project:

  • Extended Module Loader Service (contributed by Willem Meints). The extended module loader service can be used to load modules on demand. When the module loader service loads a module it will check if the module being loaded is actually installed and install it from the original installation source.
  • Module Status Service (contributed by Willem Meints). The module status service can be used to retrieve a list of modules and their status (loaded or unloaded). This is particular useful when you want to show the user of your CompositeWPF application what modules are available to the application and which modules are actually active at this moment. image
    For more information about this service, see Module status service for CompositeWPF.
  • OutlookBar control and region adapter.
     
    For more information about this control, see Use the OutlookBar in your CompositeWPF (Prism) Applications.
Where I can find the documentation of the extensions added to the project?

To check the documentation of the extensions added so far, please visit the Documentation page in the community site.

To learn more about other additions to the project, see this post.

Enjoy!

Use the OutlookBar in your CompositeWPF (Prism) Applications

Two years ago, together with Matias Woloski we wrote the Outlook Bar for the Composite Application Block (CAB). I can say that it was a popular workspace, with more than 19,000 downloads!. Now that we shipped CompositeWPF (Prism), some people at the CompositeWPF community started asking for the OutlookBar for CompositeWPF, so Julian Dominguez, Matias Woloski and me decided to spend some time and create the Composite WPF version.

clip_image001

 

Usage

First of all, you have to register the region adapter mapping in the Bootstrapper as shown in the code below:

protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
    IEventAggregator eventAggregator = Container.Resolve<IEventAggregator>();

    RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();

    mappings.RegisterMapping(typeof(OutlookBarControl), new OutlookBarControlRegionAdapter(eventAggregator));

    return mappings;
}

Now you can add the OutlookBarControl to your Shell/View XAML (you have to declare the namespace on the top of the file):

<Controls:OutlookBarControl 
       cal:RegionManager.RegionName="{x:Static infrastructure:RegionNames.OutlookBarRegion}"/>
                
To add views, just obtain the region and call the Add method as you do with other regions: 

IRegionManager regionManager = Container.Resolve<IRegionManager>();
MyView view = new MyView();
OutlookBarControl.SetOutlookBarMetadata(view, new OutlookBarMetadata
    {
        Title = "Mail",
        Payload = "MyPayload"
    });

regionManager.Regions[RegionNames.OutlookBarRegion].Add(view);
regionManager.Regions[RegionNames.OutlookBarRegion].Activate(view);

As you may noticed, in the preceding code we are also setting the OutlookBarMetadata attached property to the view. This attached property is used by the control template and by the OutlookBarControlRegionAdapter.

  • In the control template we are using the Title property in the OutlookBarControl header and in the buttons.
  • In the region adapter we are using the payload to publish the OutlookBarEvent. This event is published every time you select a view.

The OutlookBarMetadata serves a similar purpose the OutlookBarSmartPartInfo served in the CAB version.

Disclaimer

This code is provided "AS IS" with no warranties, and confers no rights.

Acknowledgments

The control template is based on this article on CodeProject.

Download

You can get the OutlookBar by downloading the latest change set of the CompositeWPF Contrib source control.

 

Stay tuned, we are working on v1.1 of the OutlookBar.

Next Page »