2012-06-12 5 views
5

私はMicrosoft.expression.encoderとframework 4.0を使ってビデオをブロードキャストするWPFアプリケーションを持っていますが、ブロードキャスト中に15秒の遅延があります。ブロードキャスト中に遅延を減らすための提案はありますか。wpf 15秒の遅延でビデオをブロードキャストするアプリケーション

は、以下の私は、サーバーとクライアントシステム上の両方のウェブカメラを表示するのMediaElementを使用していますコード

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

} 

です。

クライアント側で

try 
      { 

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

はこれまで、この解決策を見つけましたか? –

+0

KevinCloet:いいえ、まだ.. –

答えて

0

あなたは、クライアントにそれを表示する前に、ストリームをエンコードする必要性をバイパスし、代わりにMediaElementPreviewWindowを使用して、クライアントで多少の遅延を解消することができます。 PreviewWindowはWinFormsコントロールなので、WPFでのみ動作します。 XAMLで

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

コードの背後にある:

var previewWindow = new PreviewWindow(new HandleRef(this.PreviewPanel, this.PreviewPanel.Handle)); 
_deviceSource.PreviewWindow = previewWindow; 
// .. 
_job.ActivateSource(_deviceSource); 
関連する問題