private void Config() { IWMWriterNetworkSink pWMWriterNetworkSink = null; WMUtils.WMCreateWriterNetworkSink(out pWMWriterNetworkSink); m_pAddressAccess = (IWMAddressAccess2)pWMWriterNetworkSink; }
/// <summary> /// Get and configure the IWMWriterAdvanced /// </summary> /// <param name="asfWriter">IBaseFilter from which to get the IWMWriterAdvanced</param> void DoAnet(IBaseFilter asfWriter) { int hr; int dwPortNum = PortNum; // Get the IWMWriterAdvanced IWMWriterAdvanced pWriterAdvanced = GetWriterAdvanced(asfWriter); try { // Remove all the sinks from the writer RemoveAllSinks(pWriterAdvanced); // Say we are using live data hr = pWriterAdvanced.SetLiveSource(true); WMError.ThrowExceptionForHR(hr); // Create a network sink hr = WMUtils.WMCreateWriterNetworkSink(out m_pNetSink); WMError.ThrowExceptionForHR(hr); // Configure the network sink hr = m_pNetSink.SetNetworkProtocol(NetProtocol.HTTP); WMError.ThrowExceptionForHR(hr); // Configure the network sink hr = m_pNetSink.SetMaximumClients(MaxClients); WMError.ThrowExceptionForHR(hr); // Done configuring the network sink, open it hr = m_pNetSink.Open(ref dwPortNum); WMError.ThrowExceptionForHR(hr); // Add the network sink to the IWMWriterAdvanced hr = pWriterAdvanced.AddSink(m_pNetSink as IWMWriterSink); WMError.ThrowExceptionForHR(hr); } finally { if (pWriterAdvanced != null) { Marshal.ReleaseComObject(pWriterAdvanced); pWriterAdvanced = null; } } }
/// <summary> /// Adds a IWMWriterNetworkSink to the current AsfWriter output filter /// </summary> /// <param name="streamPort">The port out of which to stream the transcoded file</param> private void AddStreamSinkToCurrentOutputFilter(int streamPort) { int hr; DirectShowLib.IServiceProvider pServiceProvider; // http://msdn.microsoft.com/en-us/library/dd390985%28VS.85%29.aspx WMAsfWriter asfwriter = (WMAsfWriter)currentOutputFilter; pServiceProvider = (DirectShowLib.IServiceProvider)asfwriter; // Get access to WMwriterAdvanced2 object using pServiceProvider (poss not futureproof) (see http://groups.google.com/group/microsoft.public.win32.programmer.directx.video/browse_thread/thread/36b154d41cb76ffd/c571d6ef56de11af?#c571d6ef56de11af ) DsGuid dsgWMwriterAdvanced2 = DsGuid.FromGuid(new Guid(GUIDs.IWMWriterAdvanced2)); IWMWriterAdvanced2 WMWriterAdvanced2 = null; object o = null; hr = pServiceProvider.QueryService(dsgWMwriterAdvanced2, dsgWMwriterAdvanced2, out o); // FAILS IN A STA THREAD DsError.ThrowExceptionForHR(hr); WMWriterAdvanced2 = (IWMWriterAdvanced2)o; IWMWriterNetworkSink nsink; WMUtils.WMCreateWriterNetworkSink(out nsink); NetworkSink = nsink; dc.Add(nsink); nsink.SetMaximumClients(1); nsink.SetNetworkProtocol(NetProtocol.HTTP); NetworkSink.Open(ref streamPort); // Will throw exception if port is in use int nSinks; WMWriterAdvanced2.GetSinkCount(out nSinks); if (nSinks > 0) { IWMWriterSink pSink = null; WMWriterAdvanced2.GetSink(0, out pSink); if (pSink != null) { WMWriterAdvanced2.RemoveSink(pSink); } Marshal.ReleaseComObject(pSink); pSink = null; } WMWriterAdvanced2.AddSink(NetworkSink); }
/// <summary> /// Creates the Network Writer Sink (populates member variable) /// </summary> private void CreateNetworkWriterSink() { //Create Network Sink WMUtils.WMCreateWriterNetworkSink(out _netSink); // Configure the network sink //register to receive callbacks from the Network Sink IWMRegisterCallback iCallback = (IWMRegisterCallback)_netSink; iCallback.Advise(this, IntPtr.Zero); _netSink.SetNetworkProtocol(NetProtocol.HTTP); if ((SourceConfig.MaxClients < 0) || (SourceConfig.MaxClients > 50)) { throw new SourceConfigException("MaxClients must be 0-50 for ASFNetSink!"); } _netSink.SetMaximumClients(SourceConfig.MaxClients); }
private void Config() { WMUtils.WMCreateWriter(IntPtr.Zero, out writer); writer.SetProfileByID(g); WMUtils.WMCreateWriterNetworkSink(out sink); m_clientConns = (IWMClientConnections)sink; IWMWriterAdvanced advWriter = (IWMWriterAdvanced)writer; advWriter.AddSink(sink); sink.Open(ref port); int urlLen = 0; sink.GetHostURL(null, ref urlLen); sbUrl = new StringBuilder(urlLen); sink.GetHostURL(sbUrl, ref urlLen); writer.BeginWriting(); WMUtils.WMCreateReader(IntPtr.Zero, Rights.Playback, out reader); reader.Open(sbUrl.ToString(), this, new IntPtr(123)); lock (m_openLock) { Monitor.Wait(m_openLock); } reader.Start(0, 0, 1.0f, new IntPtr(321)); lock (m_openLock) { Monitor.Wait(m_openLock); } }
private void Config() { WMUtils.WMCreateWriterNetworkSink(out m_pSink); }