2012-06-12 6 views
5

Ho un'applicazione WPF per trasmettere video utilizzando Microsoft.expression.encoder e framework 4.0, ma ho ottenuto un ritardo di 15 secondi durante la trasmissione. C'è qualche suggerimento per ridurre il ritardo durante la trasmissione .wpf applicazione per la trasmissione di video con 15 secondi di ritardo

sotto è il codice

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()); 
    } 

} 

Sto usando MediaElement per mostrare la webcam sia sui miei sistemi server e client.

sul lato client

try 
      { 

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

mai trovato la soluzione a questo? –

+0

KevinCloet: No, non ancora .. –

risposta

0

è possibile eliminare un certo ritardo nel client utilizzando un PreviewWindow invece di un MediaElement, bypassando la necessità di codificare il flusso prima di visualizzarla nel client. PreviewWindow è un controllo WinForms, quindi funzionerà solo in WPF.

In XAML:

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

codice dietro:

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