Live Smooth Streaming: Managing Publishing Points Programmatically on IIS Media Services 3.0
Many people have been asking me how to manage publishing point programmatically on IIS Media Services 3.0 (instead of the 2.0 bits, as I explained in this post)
So, I started to dig and I came up with the following code:
// Live Streaming Section Pathconst string LiveStreamingSectionPath = “system.webServer/media/liveStreaming“;// Change this settings with your values// Site namestring siteName = “Default Web Site“;// Application namestring applicationName = “/SmoothStreaming“;// Publishing point filenamestring fileName = “LiveSmooth.isml“;ServerManager serverManager = new ServerManager();// Gets the site from IISSite site = serverManager.Sites[siteName];// Gets the application from IISApplication application = site.Applications[applicationName];// Gets the LiveStreamingSection from the site configurationConfigurationSection section = site.GetWebConfiguration().GetSection(LiveStreamingSectionPath);// Gets the ConfigurationMethodInstance to get the available publishing pointsConfigurationMethodInstance instance = section.Methods["GetPublishingPoints"].CreateInstance();// Sets the input parameters of the GetPublishingPoints methodinstance.Input["siteName"] = site.Name;instance.Input["virtualPath"] = applicationName;// Executes the methodinstance.Execute();// Gets the PublishingPointCollection type.Type type = Type.GetType("Microsoft.Web.Management.Media.LiveStreaming.PublishingPointCollection, Microsoft.Web.Management.Media.LiveStreaming“);// Gets the PublishingPointCollection associated with the method outputConfigurationElement collection = instance.Output.GetCollection(type);// Gets an item from the collection using the Publishing Point fileName as parameter.// The item is of type PublishingPoint.object pubPoint = collection.GetType().InvokeMember("Item“,BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance,null, collection, new object[] { fileName }, null);// Invokes the desired method of the Publishing Point.// In this case we are calling the Start method (others supported functions are “Shutdown” and “Stop”)pubPoint.GetType().InvokeMember("Start“,BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod,null, pubPoint, null);
Remember that in order to use the previous code, you must have references to the following assemblies:
- Microsoft.Web.Administration.dll (can be found at IIS Directory %windir%\System32\inetSrv)
- Microsoft.Web.Management.Media.LiveStreaming.dll (can be found in the GAC after installing the Live Smooth Streaming bits)
Hope this helps.
Happy streaming!
Live Smooth Streaming: Managing Publishing Points Programmatically on …
You’ve been kicked (a good thing) - Trackback from DotNetKicks.com…
Ezequiel Jadib’s Blog » Live Smooth Streaming: Managing Publishing Points Programmatically on IIS Media Services 3.0…
Thank you for submitting this cool story - Trackback from DotNetShoutout…
[...] Ezequiel Jadib’s Blog » Live Smooth Streaming: Managing Publishing Points Programmatically on IIS… blogs.southworks.net/ejadib/2010/01/18/live-smooth-streaming-managing-publishing-points-programmatically-on-iis-media-services-30 – view page – cached Live Smooth Streaming: Managing Publishing Points Programmatically on IIS Media Services 3.0 [...]
Great post Ezequiel. Now a question from some encoder manufacturing friends… can you do this in C ?
Ezequiel Jadib’s Blog » Live Smooth Streaming: Managing Publishing Points Programmatically on IIS Media Services 3.0…
Thank you for submitting this cool story - Trackback from progg.ru…
Ezequiel,
Have you been successful in using this code remotely with the ServerManager.OpenRemote(this.ServerName) method?
Is there some specific configuration that needs to happen first on the box to enable the remote management?
Programmatically Accessing the Live Smooth Streaming API…
Live Smooth Streaming is a Microsoft technology that allows you to take a live, encoded, incoming video…
Ezequiel Jadib’s Blog » Live Smooth Streaming: Managing Publishing Points Programmatically on IIS Media Services 3.0…
Thank you for submitting this cool story - Trackback from Servefault.com…