HdcpSession HdcpSession HdcpSession HdcpSession Class

Definition

Allows apps to set and query the current state of High-bandwidth Digital Content Protection (HDCP) between the graphics hardware and the display.

public : sealed class HdcpSession : IClosable, IHdcpSessionpublic sealed class HdcpSession : IDisposable, IHdcpSessionPublic NotInheritable Class HdcpSession Implements IDisposable, IHdcpSession// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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() HdcpSession() HdcpSession() HdcpSession()

Initializes a new instance of the HdcpSession class.

public : HdcpSession()public HdcpSession()Public Sub New()// You can use this method in JavaScript.

Methods

Close() Close() Close() Close()

Closes the HdcpSession instance.

public : void Close()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.

Dispose() Dispose() Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

This member is not implemented in C++void Dispose()Sub Disposevoid Dispose()

GetEffectiveProtection() GetEffectiveProtection() GetEffectiveProtection() GetEffectiveProtection()

Returns the effective protection of the HdcpSession instance.

public : IReference<HdcpProtection> GetEffectiveProtection()public Nullable<HdcpProtection> GetEffectiveProtection()Public Function GetEffectiveProtection() As Nullable( Of HdcpProtection )// You can use this method in JavaScript.
Returns
IReference<HdcpProtection> Nullable<HdcpProtection> Nullable<HdcpProtection> Nullable<HdcpProtection>

The level of protection that the HdcpSession instance currently has.

Remarks

To get the output of this method, assign it to a variable of type HdcpProtection?:

HdcpProtection? protection = hdcpSession.GetEffectiveProtection();

Then, to get the actual value of the enumeration, use protection.Value.

IsEffectiveProtectionAtLeast(HdcpProtection) IsEffectiveProtectionAtLeast(HdcpProtection) IsEffectiveProtectionAtLeast(HdcpProtection) IsEffectiveProtectionAtLeast(HdcpProtection)

Checks whether the effective protection of the HdcpSession instance is at least equal to the given HdcpProtection value.

public : PlatForm::Boolean IsEffectiveProtectionAtLeast(HdcpProtection protection)public bool IsEffectiveProtectionAtLeast(HdcpProtection protection)Public Function IsEffectiveProtectionAtLeast(protection As HdcpProtection) As bool// You can use this method in JavaScript.
Parameters
protection
HdcpProtection HdcpProtection HdcpProtection HdcpProtection

The level of protection to check against the HdcpSession instance's protection level.

Returns
PlatForm::Boolean bool bool bool

True if the protection level of the HdcpSession is at least equal to the value of protection.

SetDesiredMinProtectionAsync(HdcpProtection) SetDesiredMinProtectionAsync(HdcpProtection) SetDesiredMinProtectionAsync(HdcpProtection) SetDesiredMinProtectionAsync(HdcpProtection)

Asynchronously attempts to set the protection of the HdcpSession instance with the given protection level.

public : IAsyncOperation<HdcpSetProtectionResult> SetDesiredMinProtectionAsync(HdcpProtection protection)public IAsyncOperation<HdcpSetProtectionResult> SetDesiredMinProtectionAsync(HdcpProtection protection)Public Function SetDesiredMinProtectionAsync(protection As HdcpProtection) As IAsyncOperation( Of HdcpSetProtectionResult )// You can use this method in JavaScript.
Parameters
protection
HdcpProtection HdcpProtection HdcpProtection HdcpProtection

The level of protection at which to set the HdcpSession instance.

Returns

Remarks

It is a good idea to listen for the Completed event on this function, and then to check the results by calling GetResults on the operation and compare it to the values of the HdcpSetProtectionResult enumeration. This way, you can implement your own logic depending on the result of trying to set HDCP. For a usage example, see HdcpSession.

Events

ProtectionChanged ProtectionChanged ProtectionChanged ProtectionChanged

Fires when the protection level of the HdcpSession instance changes.

public : event TypedEventHandler ProtectionChanged<HdcpSession,  object>public event TypedEventHandler ProtectionChanged<HdcpSession,  object>Public Event ProtectionChanged<HdcpSession,  object>// You can use this event in JavaScript.

Remarks

For a usage example of this event, see HdcpSession.