private IWMWriterAdvanced GetWriterAdvanced(IBaseFilter asfWriter) { int hr; IWMWriterAdvanced pWriterAdvanced = null; // I don't understand why we can't just QueryInterface for a IWMWriterAdvanced, but // we just can't. So, we use an IServiceProvider DirectShowLib.IServiceProvider pProvider = asfWriter as DirectShowLib.IServiceProvider; if (pProvider != null) { object opro; hr = pProvider.QueryService(typeof(IWMWriterAdvanced2).GUID, typeof(IWMWriterAdvanced2).GUID, out opro); WMError.ThrowExceptionForHR(hr); pWriterAdvanced = opro as IWMWriterAdvanced; if (pWriterAdvanced == null) { throw new Exception("Can't get IWMWriterAdvanced"); } } return(pWriterAdvanced); }
private void TestProxy() { string s; bool b; int i; int c = 0; int hr = m_ian.FindProxyForURL("http", "limegreensocks.com", out b, out s, out i, ref c); WMError.ThrowExceptionForHR(hr); Debug.Assert(b == false); m_ian.RegisterProxyFailure(-1, c); m_ian.ShutdownProxyContext(c); }
/// <summary> /// Retrieve the url that should be connected to from media player. From withing /// media player user File/Open URL and entry the string returned from this function. /// </summary> /// <returns></returns> public string GetURL() { int hr; int iSize = 0; // Call the function once to get the size hr = m_pNetSink.GetHostURL(null, ref iSize); WMError.ThrowExceptionForHR(hr); StringBuilder sRet = new StringBuilder(iSize, iSize); hr = m_pNetSink.GetHostURL(sRet, ref iSize); WMError.ThrowExceptionForHR(hr); // Trim off the trailing null return(sRet.ToString().Substring(0, iSize - 1)); }
/// <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; } } }
private void RemoveAllSinks(IWMWriterAdvanced pWriterAdvanced) { IWMWriterSink ppSink; int iSinkCount; int hr = pWriterAdvanced.GetSinkCount(out iSinkCount); WMError.ThrowExceptionForHR(hr); for (int x = iSinkCount - 1; x >= 0; x--) { hr = pWriterAdvanced.GetSink(x, out ppSink); WMError.ThrowExceptionForHR(hr); hr = pWriterAdvanced.RemoveSink(ppSink); WMError.ThrowExceptionForHR(hr); } }
private void Test() { string pName, pw; bool b; NetSourceURLCredPolicySettings ps; m_ian.SetCredentialsEx2("foo", "bar", false, "david", "moo", true, false, true); m_ian.GetCredentialsEx2("foo", "bar", false, true, out ps, out pName, out pw, out b); Debug.Assert(pName == "david" && pw == "moo" && b == false); string s; long context = 0; int p; int hr = m_ian.FindProxyForURLEx2("http", "www.limegreensocks.com", "http://www.limegreensocks.com/DShow", out b, out s, out p, ref context); WMError.ThrowExceptionForHR(hr); m_ian.ShutdownProxyContext2(context); }
/// <summary> /// Queries the WM ASF Writer filter for the IWMWriterAdvanced interface. /// </summary> /// <returns>the IWMWriterAdvanced interface from the ASF Writer filter</returns> protected IWMWriterAdvanced GetWriterAdvanced() { int hr; IWMWriterAdvanced pWriterAdvanced = null; DirectShowLib.IServiceProvider pProvider = _asfFilter as DirectShowLib.IServiceProvider; if (pProvider != null) { object opro; hr = pProvider.QueryService(typeof(IWMWriterAdvanced2).GUID, typeof(IWMWriterAdvanced2).GUID, out opro); WMError.ThrowExceptionForHR(hr); pWriterAdvanced = opro as IWMWriterAdvanced; if (pWriterAdvanced == null) { throw new Exception("Can't get IWMWriterAdvanced"); } } return(pWriterAdvanced); }