2012-06-12 3 views
5

Ich habe eine WPF-Anwendung für die Ausstrahlung von Video mit Microsoft.expression.encoder und Framework 4.0, aber ich habe eine Verzögerung von 15 Sekunden während des Broadcasting.Ist es einen Vorschlag zur Verringerung der Verzögerung beim Senden .WPF-Anwendung für die Übertragung von Video mit 15s Verzögerung

unten ist der Code

using Microsoft.Expression.Encoder.Live; 
using Microsoft.Expression.Encoder; 

private void button1_Click(object sender, RoutedEventArgs e) 
{ 
    try 
    { 
     EncoderDevice video = null; 
     EncoderDevice audio = null; 
     GetSelectedVideoAndAudioDevices(out video, out audio); 
     StopJob(); 

     if (video == null) 
     { 
      return; 
     } 

     StopJob(); 
     _job = new LiveJob(); 

     if (video != null && audio != null) 
     { 
      //StopJob(); 
      _deviceSource = null; 
      _deviceSource = _job.AddDeviceSource(video, audio); 
      _job.ActivateSource(_deviceSource); 

      // Finds and applys a smooth streaming preset   
      //_job.ApplyPreset(LivePresets.VC1HighSpeedBroadband4x3); 

      // Creates the publishing format for the job 
      PullBroadcastPublishFormat format = new PullBroadcastPublishFormat(); 
      format.BroadcastPort = 9090; 
      format.MaximumNumberOfConnections = 50; 

      // Adds the publishing format to the job 
      _job.PublishFormats.Add(format); 

      // Starts encoding 
      _job.StartEncoding(); 
     } 
     //webCamCtrl.StartCapture(); 
    } 
    catch (Exception ex) 
    { 
     WriteLogFile(this.GetType().Name, "button1_Click", ex.Message.ToString()); 
    } 

} 

I Media bin mit der Webcam zu zeigen, sowohl auf meinem Server und Client-Systemen.

auf Client-Seite

try 
      { 

       theMainWindow.getServerIPAddress(); 
       IP = theMainWindow.machineIP; 
       MediaElement1.Source = new Uri("http://" + IP + ":9090/"); 
      } 
      catch (Exception ex) 
      { 
      } 
+0

gefunden überhaupt die Lösung dieses Problems? –

+0

KevinCloet: Nein, noch nicht .. –

Antwort

0

Sie können eine gewisse Verzögerung in dem Client beseitigen, indem ein PreviewWindow anstelle ein MediaElement verwenden, wodurch die Notwendigkeit umgangen wird, den Strom zu kodieren, bevor es in dem Client angezeigt werden. PreviewWindow ist ein WinForms-Steuerelement, das funktioniert nur in WPF.

In XAML:

<WindowsFormsHost> 
    <wf:Panel x:Name="PreviewPanel" /> 
</WindowsFormsHost> 

-Code hinter:

var previewWindow = new PreviewWindow(new HandleRef(this.PreviewPanel, this.PreviewPanel.Handle)); 
_deviceSource.PreviewWindow = previewWindow; 
// .. 
_job.ActivateSource(_deviceSource); 
Verwandte Themen