/////////////////////////////////////////////////////////////////////// // Name: DoEnable // Description: Does the enabler action. // // flags: If ForceNonSilent, then always use non-silent enable. // Otherwise, use silent enable if possible. //////////////////////////////////////////////////////////////////////// public void DoEnable(EnablerFlags flags) { Debug.WriteLine(string.Format("ContentProtectionManager::DoEnable (flags ={0})", flags.ToString())); HResult hr; bool bAutomatic = false; Guid guidEnableType; try { // Get the enable type. (Just for logging. We don't use it.) hr = m_pEnabler.GetEnableType(out guidEnableType); MFError.ThrowExceptionForHR(hr); LogEnableType(guidEnableType); // Query for the IMFMediaEventGenerator interface so that we can get the // enabler events. m_pMEG = (IMFMediaEventGenerator)m_pEnabler; // Ask for the first event. hr = m_pMEG.BeginGetEvent(this, null); MFError.ThrowExceptionForHR(hr); // Decide whether to use silent or non-silent enabling. If flags is ForceNonSilent, // then we use non-silent. Otherwise, we query whether the enabler object supports // silent enabling (also called "automatic" enabling). if (flags == EnablerFlags.ForceNonSilent) { Debug.WriteLine(("Forcing non-silent enable.")); bAutomatic = false; } else { hr = m_pEnabler.IsAutomaticSupported(out bAutomatic); MFError.ThrowExceptionForHR(hr); Debug.WriteLine(string.Format("IsAutomatic: auto = {0}", bAutomatic)); } // Start automatic or non-silent, depending. if (bAutomatic) { m_state = Enabler.SilentInProgress; Debug.WriteLine("Content enabler: Automatic is supported"); hr = m_pEnabler.AutomaticEnable(); MFError.ThrowExceptionForHR(hr); } else { m_state = Enabler.NonSilentInProgress; Debug.WriteLine("Content enabler: Using non-silent enabling"); DoNonSilentEnable(); } } catch (Exception e) { m_hrStatus = (HResult)Marshal.GetHRForException(e); throw; } }
/////////////////////////////////////////////////////////////////////// // Name: DoEnable // Description: Does the enabler action. // // flags: If ForceNonSilent, then always use non-silent enable. // Otherwise, use silent enable if possible. //////////////////////////////////////////////////////////////////////// public void DoEnable(EnablerFlags flags) { Debug.WriteLine(string.Format("ContentProtectionManager::DoEnable (flags ={0})", flags.ToString())); int hr; bool bAutomatic = false; Guid guidEnableType; try { // Get the enable type. (Just for logging. We don't use it.) hr = m_pEnabler.GetEnableType(out guidEnableType); MFError.ThrowExceptionForHR(hr); LogEnableType(guidEnableType); // Query for the IMFMediaEventGenerator interface so that we can get the // enabler events. m_pMEG = (IMFMediaEventGenerator)m_pEnabler; // Ask for the first event. hr = m_pMEG.BeginGetEvent(this, null); MFError.ThrowExceptionForHR(hr); // Decide whether to use silent or non-silent enabling. If flags is ForceNonSilent, // then we use non-silent. Otherwise, we query whether the enabler object supports // silent enabling (also called "automatic" enabling). if (flags == EnablerFlags.ForceNonSilent) { Debug.WriteLine(("Forcing non-silent enable.")); bAutomatic = false; } else { hr = m_pEnabler.IsAutomaticSupported(out bAutomatic); MFError.ThrowExceptionForHR(hr); Debug.WriteLine(string.Format("IsAutomatic: auto = {0}", bAutomatic)); } // Start automatic or non-silent, depending. if (bAutomatic) { m_state = Enabler.SilentInProgress; Debug.WriteLine("Content enabler: Automatic is supported"); hr = m_pEnabler.AutomaticEnable(); MFError.ThrowExceptionForHR(hr); } else { m_state = Enabler.NonSilentInProgress; Debug.WriteLine("Content enabler: Using non-silent enabling"); DoNonSilentEnable(); } } catch (Exception e) { m_hrStatus = Marshal.GetHRForException(e); throw; } }