HdcpSession Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Allows apps to set and query the current state of High-bandwidth Digital Content Protection (HDCP) between the graphics hardware and the display.
public ref class HdcpSession sealed : IClosable
/// [Windows.Foundation.Metadata.Activatable(196608, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HdcpSession final : IClosable
[Windows.Foundation.Metadata.Activatable(196608, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HdcpSession : System.IDisposable
function HdcpSession()
Public NotInheritable Class HdcpSession
Implements IDisposable
- Inheritance
- Attributes
- Implements
Windows requirements
Device family |
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v3.0)
|
Examples
The following example sets HDCP and then reacts when it's completed.
First, we make some declarations:
private HdcpProtection desiredHdcpProtection = HdcpProtection.OnWithTypeEnforcement;
private HdcpProtection currentHdcpProtection = HdcpProtection.On;
private bool outputIsProtected = false;
private HdcpSession hdcpSession;
private void SetHdcpProtection()
{
hdcpSession = new HdcpSession();
// Register an event to get notified when HDCP changes
hdcpSession.ProtectionChanged += (HdcpSession sender, object eventArgs) =>
{
// In case we want to do something with the level
HdcpProtection? protection = sender.GetEffectiveProtection();
if (protection != null)
{
currentHdcpProtection = protection.Value;
}
else
{
// The current Hdcp protection level is pending... so treat it as though it's off altogether
currentHdcpProtection = HdcpProtection.Off;
}
// Check the protection
outputIsProtected = sender.IsEffectiveProtectionAtLeast(desiredHdcpProtection);
};
hdcpSession.SetDesiredMinProtectionAsync(desiredHdcpProtection).Completed = (asyncOperation, asyncStatus) =>
{
if (HdcpSetProtectionResult.Success != asyncOperation.GetResults())
{
// Handle the case where we failed to set the HDCP protection
DebugTextBlock.Text = "ERROR! Something went wrong";
}
outputIsProtected = hdcpSession.IsEffectiveProtectionAtLeast(desiredHdcpProtection);
};
}
Remarks
You may want to turn on HDCP for your app, even though you're using neither the low-level Media Core Media Pipeline APIs for OPM, nor PlayReady DRM.
Different ISVs (Independent Software Vendors) may need different levels of protection. An ISV with a legal requirement for "simple In-Transit protection" might use HTTPS with Auth for streaming and HDCP for display output protection. Other ISVs build sophisticated pipelines and require direct control of HDCP from within those pipelines. They may enforce the stricter HDCP2 for some content, but not require it for other content.
ISVs may want to set HDCP state and check that it has been established. If the system is unable to establish HDCP, they may opt to implement business logic which will constrain the bitrate or resolution, or not play at all. They build their business logic based on their legal obligations.
Once the app is done with playback that must be HDCP protected, they may opt to turn it back off (for trailers, for example, or as part of a clean exit).
The HdcpSession APIs accommodate all of the above scenarios, allowing you to tweak your app's HDCP settings to suit your particular needs.
Constructors
HdcpSession() |
Initializes a new instance of the HdcpSession class. |
Methods
Close() |
Closes the HdcpSession instance. |
Dispose() |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
GetEffectiveProtection() |
Returns the effective protection of the HdcpSession instance. |
IsEffectiveProtectionAtLeast(HdcpProtection) |
Checks whether the effective protection of the HdcpSession instance is at least equal to the given HdcpProtection value. |
SetDesiredMinProtectionAsync(HdcpProtection) |
Asynchronously attempts to set the protection of the HdcpSession instance with the given protection level. |
Events
ProtectionChanged |
Fires when the protection level of the HdcpSession instance changes. |