IIS Media Services 4.0: publishing point runtime status

In my previous post I introduced some new features added to IIS Media Services (IIS MS) 4.0 and in particular the new manifest compression used for Live Streaming. In this post I discuss about the new publishing point runtime status avaliable with IIS MS 4.0.

This new feature can permit to you during a Live Streaming to check the status of the publishing point using the new UI added to IIS manager and in alternative using the RSCA API. During a live streaming in the pubpoint UI you can see a recap  of the pubpoint  status in the "Publishingh Point Summary" that you can see in the figure below:

 

 

As you can see in the pubpoint summary you can see status of incoming streams in IIS and a recap of the option activated on the pubpoint. Using the new "details" menù on the Actions pubpoint , you can activate a detailed view on pubpoint status:

 The details view give to you a complete view of the status in the pub point. You have the "stream summary" and the "track view details" and connections details :

 

 

The "stream summary" section show the status of incoming streams and give to you the opportunity to see the stream in input in the pubpoint from encoder or others IIS MS source. 

In the "tracks details" you can see the status of every Track in input to the IIS MS pubpoint form an encoder or another server. 

In order to clarify the terms a "stream" for Live Smooth Streaming publishing points, is a group of “tracks”  that are combined in a single Fragmented MP4 formatted bit stream. It’s the same bit stream that is transmitted over a single TCP connection from encoder or from another server. The grouping of tracks into streams is determined by the encoder. For example, you can have some encoder that have in output one track per stream and in this case you have many streams as the number of tracks.  Others encoder can have in output all tracks in one stream, or  you can have any combinations of the previous approach.

 A "track"  is a collection of related samples. In the case of  media data, a track is a sequence of images or sampled audio. For example if the presentation has X video bitrates, each one of them is a separate video track. You have a track also for the audio part of the presentation or more of one if the streaming has a multiaudio and in this case we have one track for every audio supported. You can have not only media (audio\video) track, you can have data track like captioning or others type of data.

In the tracks details you can see also the status of the stream , the last timestamp receives, track name and other information.

Each stream can have two states: started or stopped. When the stream is in started state, it is receiving media data or ready to receive media data from new sources. It is important to understand that a “started” stream does NOT necessarily mean that it is currently receiving live stream. A stream can stay in started state even if all connections from encoders have dropped. A stream can only be stopped by either an End-Of-Stream (EOS) signal from the encoder (or upstream server), a manual publishing point stop/shutdown command, or some internal errors. Without having any one of those three conditions, the stream will stay in started state. If you are looking for more information about Live Streaming Architecture and Fault Tolerance I suggest to you to read my post on this topics.

 In the "connection details " you can see source and destination in the pubpoint . Source: “Source” is from the publishing point receive data. Each source can provides one or more streams to the publishing point. In genaral, every stream  has one source. But in some scenarios, like active-active failover, you could have multiple sources from different locations sending in the same stream (identified by the Stream Name) to the same publishing point. In this case, the publishing point will do the proper job to consolidate the identical streams into one logical stream. The types of sources that IIS Media Services 4.0 support are: HTTP Push and HTTP Pull.
Destination: “Destination” is where the media data goes to. The type of destination shows how the publishing point isuse the media data . The types of destinations in IIS Media Services 4.0 are: IIS Smooth Streaming, Apple HTTP Live Streaming, HTTP Push and HTTP Pull. The last two types of HTTP destinations are for server-to-server distribution.

 You can access to the pubpoint runtime status also using RSCA API.In order to use this API you can use Microsoft.Web.Administration.dll (can be found at IIS Directory %windir%\System32\inetSrv) or a JS script that leverage ActiveXObject("Microsoft.ApplicationHost.AdminManager").

In order to access to a Pubpoint from managed code you can reference Microsoft.Web.Administration.dll and write this code in order to start the pub point:

// Live Streaming Section Path
const string LiveStreamingSectionPath = "system.webServer/media/liveStreaming";

//Pubpoint informations data

// Site name
string siteName = "Default Web Site";
// Application name
string applicationName = "/SmoothStreaming";
// Publishing point filename
string fileName = "LiveSmooth.isml";

ServerManager serverManager = new ServerManager();

// Gets the site from IIS
Site site = serverManager.Sites[siteName];

// Gets the application from IIS
Application application = site.Applications[applicationName];

// Gets the LiveStreamingSection from the site configuration
ConfigurationSection section = site.GetWebConfiguration().GetSection(LiveStreamingSectionPath);

// Gets the ConfigurationMethodInstance to get the available publishing points
ConfigurationMethodInstance instance = section.Methods["GetPublishingPoints"].CreateInstance();

// Sets the input parameters of the GetPublishingPoints method
instance.Input["siteName"] = site.Name;
instance.Input["virtualPath"] = applicationName;

// Executes the method
instance.Execute();

// Gets the PublishingPointCollection associated with the method output
ConfigurationElement collection = instance.Output.GetCollection();

// Looks for the publishing point and Invokes the desired method of the Publishing Point.
// In this case we are calling the Start method (others supported functions are "Shutdown" and "Stop")
foreach (var item in collection.GetCollection())
{
if (item.Attributes["name"].Value.ToString().Equals(fileName))
{
    var method = item.Methods["Start"];
    var methodInstance = method.CreateInstance(); 
    methodInstance.Execute();
  break;
}
}

You can use the same API to read the runtime status information. Below a sample to read on a pubpoint active streams and tracks in input:

// Live Streaming Section Path
const string LiveStreamingSectionPath = "system.webServer/media/liveStreaming";

// Change this settings with your values

// Site name
string siteName = "Default Web Site";
// Application name
string applicationName = "/SmoothStreaming";
// Publishing point filename
string fileName = "LiveSmooth.isml";

ServerManager serverManager = new ServerManager();

// Gets the site from IIS
Site site = serverManager.Sites[siteName];

// Gets the application from IIS
Application application = site.Applications[applicationName];

// Gets the LiveStreamingSection from the site configuration
ConfigurationSection section = site.GetWebConfiguration().GetSection(LiveStreamingSectionPath);

// Gets the ConfigurationMethodInstance to get the available publishing points
ConfigurationMethodInstance instance = section.Methods["GetPublishingPoints"].CreateInstance();

// Sets the input parameters of the GetPublishingPoints method
instance.Input["siteName"] = site.Name;
instance.Input["virtualPath"] = applicationName;

// Executes the method
instance.Execute();

// Gets the PublishingPointCollection associated with the method output
ConfigurationElement collection = instance.Output.GetCollection();

ConfigurationElement collectionInputStreams=null;
           

//Get Input Stream on a selected pubpoint
foreach (var item in collection.GetCollection())
            {
                if (item.Attributes["name"].Value.ToString().Equals(fileName))
                {
                    var method = item.Methods["GetInputStreams"];
                    var methodInstance = method.CreateInstance();
                    methodInstance.Execute();
                   collectionInputStreams=methodInstance.Output.GetCollection(); 
                    break;
                }
            }

 

//Read Streams and for each stream read Tracks
foreach (var item in collectionInputStreams.GetCollection())
            {
                Console.WriteLine("Stream ID {0} State {1} archive file {2}", item.GetAttributeValue("id"), item.GetAttributeValue("state"), item.GetAttributeValue("archiveFileName"));

               var tracks = item.GetCollection("tracks");

               foreach (var track in tracks)
               {
                   Console.WriteLine("TrackId {0} Name  {1} encoded bitrate {2} ", track.GetAttributeValue("id"), track.GetAttributeValue("name"), track.GetAttributeValue("encodedBitrate")); 
              
               }
           
            }
     
   }

Below the results in the Console after the execution of the previous code on a pubpoint on my PC:

Stream ID 7936-stream4 State 1 archive file 7936-stream4.ismv
TrackId 2 Name  video encoded bitrate 350000
Stream ID 7936-stream1 State 1 archive file 7936-stream1.ismv
TrackId 2 Name  video encoded bitrate 1050000
Stream ID 7936-stream3 State 1 archive file 7936-stream3.ismv
TrackId 2 Name  video encoded bitrate 475000
Stream ID 7936-stream0 State 1 archive file 7936-stream0.ismv
TrackId 2 Name  video encoded bitrate 1450000
TrackId 1 Name  audio encoded bitrate 64000
Stream ID 7936-stream2 State 1 archive file 7936-stream2.ismv
TrackId 2 Name  video encoded bitrate 600000