المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : c# DirectShow udp



C# Programming
07-19-2009, 12:50 AM
Hello,
I'm using the DirectShow.Net library to create a media player in my software.
using the followong code I'm able to play files in the local pc or the network (unc path)


private const int WMGraphNotify = 0x0400 + 13;
private const int VolumeFull = 0;
private const int VolumeSilence = -10000;

private IGraphBuilder graphBuilder = null;
private IMediaControl mediaControl = null;
private IMediaEventEx mediaEventEx = null;
private IVideoWindow videoWindow = null;
private IBasicAudio basicAudio = null;
private IBasicVideo basicVideo = null;
private IMediaSeeking mediaSeeking = null;
private IMediaPosition mediaPosition = null;
private IVideoFrameStep frameStep = null;
private string filename = string.Empty;
private bool isAudioOnly = false;
private bool isFullScreen = false;
private int currentVolume = VolumeFull;
private PlayState currentState = PlayState.Stopped;
private double currentPlaybackRate = 1.0;
private bool m_bTracking;
private IntPtr hDrain = IntPtr.Zero;
private AMSeekingSeekingCapabilities seek;
private double tDuration;

public void OpenPlayFile(string filename)
{
StopClip();
CloseInterfaces();

int hr = 0;

if (filename == string.Empty)
return;

this.graphBuilder = (IGraphBuilder)new FilterGraph();

// Have the graph builder construct its the appropriate graph automatically
hr = this.graphBuilder.RenderFile(filename, null);
DsError.ThrowExceptionForHR(hr);

// QueryInterface for DirectShow interfaces
this.mediaControl = (IMediaControl)this.graphBuilder;
this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
this.mediaPosition = (IMediaPosition)this.graphBuilder;

// Query for video interfaces, which may not be relevant for audio files
this.videoWindow = this.graphBuilder as IVideoWindow;
this.basicVideo = this.graphBuilder as IBasicVideo;

// Query for audio interfaces, which may not be relevant for video-only files
this.basicAudio = this.graphBuilder as IBasicAudio;

// Is this an audio-only file (no video component)?
CheckVisibility();

// Have the graph signal event via window callbacks for performance
hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);

if (!this.isAudioOnly)
{
// Setup the video window
hr = this.video********put_Owner(this.Handle);
DsError.ThrowExceptionForHR(hr);

hr = this.video********put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
DsError.ThrowExceptionForHR(hr);

hr = InitVideoWindow(1, 1);
DsError.ThrowExceptionForHR(hr);

GetFrameStepInterface();
}
else
{
// Initialize the default player size and enable playback menu items
hr = InitPlayerWindow();
DsError.ThrowExceptionForHR(hr);
}

// Complete window initialization
this.isFullScreen = false;
this.currentPlaybackRate = 1.0;

this.Focus();

// Run the graph to play the media file
hr = this.mediaControl.Run();
DsError.ThrowExceptionForHR(hr);

this.currentState = PlayState.Running;

hr = this.mediaSeeking.GetCapabilities(out seek);
DsError.ThrowExceptionForHR(hr);

if (seek != AMSeekingSeekingCapabilities.None)
{
hr = mediaPosition.get_Duration(out tDuration);
DsError.ThrowExceptionForHR(hr);

tbSeekBar.Enabled = true;
btnRewind.Enabled = true;
btnForward.Enabled = true;
timer.Enabled = true;
}
else
{
tbSeekBar.Enabled = false;
btnRewind.Enabled = false;
btnForward.Enabled = false;
timer.Enabled = false;
}
}


I need to be able to play multicast streams that are sent form other computers and cameres in the Lan in udp, in the vlc player I would use the following address to play it udp://@225.19.19.83:1234 I can'r use this address in my function because it failes on
hr = this.graphBuilder.RenderFile(filename, null);
DsError.ThrowExceptionForHR(hr);

System.IO.FileNotFoundException was unhandled
Message="Exception from HRESULT: 0x800C000D"

It's logical because my code can't connect to the source
can someone help me to be able to conncet to a udp multicast sream?