Reputation:
I'm attempting to stream audio and video live from my PC to a publishingpoint on a hosted service. I've written all the code that I think it should have (At the moment it's just test code in a small Console app). The code itself does not throw an error, it runs just fine, video is pulled from my webcam, however when trying to send the stream to the publishingpoint I get a DCOM error in the System Event logs "DCOM was unable to communicate with the computer streamwebtown.com using any of the configured protocols." I tried to do the same thing using the actual Expression Encoder 4 client application that comes with the SDK and the video/audio feed works just fine to the same publishingpoint. I've searched the internet far and wide to see if someone else has run into this problem but have come up empty. Asking the community if they have any ideas?
Code from Application:
static void Main(string[] args)
{
EncoderDevice video = EncoderDevices.FindDevices(EncoderDeviceType.Video).Count > 0 ? EncoderDevices.FindDevices(EncoderDeviceType.Video)[0] : null;
EncoderDevice audio = EncoderDevices.FindDevices(EncoderDeviceType.Audio).Count > 0 ? EncoderDevices.FindDevices(EncoderDeviceType.Audio)[0] : null;
LiveJob job = new LiveJob();
if (video != null && audio != null)
{
LiveDeviceSource source = job.AddDeviceSource(video, audio);
job.ActivateSource(source);
PushBroadcastPublishFormat publishingPoint = new PushBroadcastPublishFormat();
publishingPoint.PublishingPoint = new Uri("http://streamwebtown.com/abc");
publishingPoint.UserName = "user";
publishingPoint.Password = PullPW("Stream");
job.ApplyPreset(LivePresets.VC1Broadband16x9);
job.PublishFormats.Add(publishingPoint);
job.StartEncoding();
Console.ReadKey();
job.StopEncoding();
}
}
private static SecureString PullPW(string pw)
{
SecureString s = new SecureString();
foreach (char c in pw) s.AppendChar(c);
return s;
}
Upvotes: 8
Views: 964
Reputation:
I have found the answer, it was not authenticating against the server at all. So changed my code to the following and it suddenly worked just fine.
static void Main(string[] args)
{
EncoderDevice video = EncoderDevices.FindDevices(EncoderDeviceType.Video).Count > 0 ? EncoderDevices.FindDevices(EncoderDeviceType.Video)[0] : null;
EncoderDevice audio = EncoderDevices.FindDevices(EncoderDeviceType.Audio).Count > 0 ? EncoderDevices.FindDevices(EncoderDeviceType.Audio)[0] : null;
LiveJob job = new LiveJob();
job.AcquireCredentials += new EventHandler(job_AcquireCredentials);
if (video != null && audio != null)
{
LiveDeviceSource source = job.AddDeviceSource(video, audio);
job.ActivateSource(source);
PushBroadcastPublishFormat publishingPoint = new PushBroadcastPublishFormat();
publishingPoint.PublishingPoint = new Uri("http://streamwebtown.com/abc");
WindowsMediaOutputFormat wmof = new WindowsMediaOutputFormat();
VideoProfile vProfile = new AdvancedVC1VideoProfile();
AudioProfile aProfile = new WmaAudioProfile();
wmof.VideoProfile = vProfile;
wmof.AudioProfile = aProfile;
job.ApplyPreset(LivePresets.VC1Broadband16x9);
job.PublishFormats.Add(publishingPoint);
job.OutputFormat = wmof;
job.PreConnectPublishingPoint();
job.StartEncoding();
//After finished encoding dispose of all objects.
Console.ReadKey();
job.StopEncoding();
job.Dispose();
video.Dispose();
audio.Dispose();
source.Dispose();
}
}
static void job_AcquireCredentials(object sender, AcquireCredentialsEventArgs e)
{
e.UserName = "user";
e.Password = PullPW("Stream");
e.Modes = AcquireCredentialModes.None;
}
private static SecureString PullPW(string pw)
{
SecureString s = new SecureString();
foreach (char c in pw) s.AppendChar(c);
return s;
}
Upvotes: 4