Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
I am working on a project where i need to broadcast Live videos using win Media Encoder 9,Win Media Services,Win server 2003,Asp.net 3.5/4.0,C#.
i am facing much problems using win media Encoder sdk codes into my web application like Credentails issue,Unable to acquire network and much more.
Even when i launch win media encoder wizard it throws me username and pwd invalid.Can anyone help me out.
C#
public static void Main()
   {
     try
     {
       // Create WMEncoderApp and WMEncoder objects.
       WMEncoderApp EncoderApp = new WMEncoderApp();
       WMEncoder wmEncoder = new WMEncoder();
       IWMEncoder Encoder = EncoderApp.Encoder;
       wmEncoder.OnAcquireCredentials += new _IWMEncoderEvents_OnAcquireCredentialsEventHandler(wmEncoder_OnAcquireCredentials);
       // Display the predefined Encoder UI.
       EncoderApp.Visible = true;

       // Specify the source for the input stream.
       IWMEncSourceGroupCollection SrcGrpColl = wmEncoder.SourceGroupCollection;
       IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("Test");
       IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
       IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
       SrcAud.SetInput("Default_Audio_Device", "Device", "");
       SrcVid.SetInput("Default_Video_Device", "Device", "");
       // Specify a profile.
       IWMEncProfile Pro;
       IWMEncProfileCollection ProColl = wmEncoder.ProfileCollection;
       for (int i = 0; i < ProColl.Count; i++)
       {
         Pro = ProColl.Item(i);
         if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)")
         {
           SrcGrp.set_Profile(Pro);
           break;
         }
       }
       string strServerName = "ServerName:PortNumber";
       string strPubPoint = "23";
       string strPubTemplate = "Live";
       //Broadcast a Live Event
       IWMEncPushDistribution PushDist = (IWMEncPushDistribution)wmEncoder.Broadcast;
       IWMEncBroadcast BrdCst = wmEncoder.Broadcast;
       BrdCst.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, 82);
       //BrdCst.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_PUSH_DISTRIBUTION, 82);
       // Set the push distribution variables.

       //string MyNSCFile = "\\SNGS-DEMO\\Test\\MyPubPoint.nsc";
       //string MyNSCURL = "\\SNGS-DEMO\\Test\\MyPubPoint.nsc";
       // string MyASXFile = "\\SNGS-DEMO\\Test\\MyPubPoint.asx";
       PushDist.AutoRemovePublishingPoint = true;
       // Generate the announcement file.
       PushDist.ServerName = strServerName;
       PushDist.PublishingPoint = strPubPoint;
       PushDist.Template = strPubTemplate;

       // PushDist.GenerateMulticastInfoFile(MyNSCFile);
      // PushDist.GenerateAnnouncementFile(MyNSCURL, MyASXFile);

       // Retrieve the IWMSPublishingPoints object.
       //PubPoints = winMServer.PublishingPoints;
       // Create a new WMSServer object.
       winMServer = new WMSServer();
       winMServer.AllowClientsToConnect = true;

       // Retrieve the IWMSPlugin object for the
       // WMS Publishing Points ACL Authorization plug-in.
       //Plugin = winMServer.EventHandlers["WMS Publishing Points ACL Authorization"];
       // Retrieve the administrative interface for the
       // WMS Publishing Points ACL Authorization plug-in.
       //IWMSACLCheckAdmin ACLCheckAdmin = (IWMSACLCheckAdmin)Plugin.CustomInterface;
       // Retrieve the list of access control entries.
       //IWMSAccessControlList AccessCtrlList = ACLCheckAdmin.AccessControlList;

        //// Specify the push distribution variables, including the Windows Media
       //// server name, publishing point, and announcement files.

       wmEncoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler(wmEncoder_OnStateChange);
       wmEncoder.OnSourceStateChange += new _IWMEncoderEvents_OnSourceStateChangeEventHandler(wmEncoder_OnSourceStateChange);
       //Server Credentials
       wmEncoder.PrepareToEncode(true);
       wmEncoder.Start();
     }
     catch (Exception e)
     {
       // TODO: Handle exceptions.
     }
   }
Posted
Updated 20-Mar-11 21:07pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900