internal void SetMediaElement (MediaElement mediaElement)
{
IntPtr demuxer = IntPtr.Zero;
if (this.demuxer != IntPtr.Zero)
throw new InvalidOperationException ("MediaStreamSource: this source has already been initialized.");
if (handle.IsAllocated)
throw new InvalidOperationException ("MediaStreamSource: this source has already been initialized.");
media_element = mediaElement;
handle = GCHandle.Alloc (this);
demuxer = NativeMethods.media_element_set_demuxer_source (media_element.native, GCHandle.ToIntPtr (handle), closeMediaCallback, getDiagnosticAsyncCallback, getSampleAsyncCallback, openMediaAsyncCallback, seekAsyncCallback, switchMediaStreamAsyncCallback);
if (demuxer == IntPtr.Zero)
throw new InvalidOperationException ("MediaStreamSource: Could not create native demuxer.");
if (this.media == IntPtr.Zero)
this.media = NativeMethods.imedia_object_get_media_reffed (demuxer);
this.demuxer = demuxer;
}