Ejemplo n.º 1
0
        //<SnippetHdcpSessionMethod>
        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);
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the radio button selections from the UI and imposes that minimum desired protection
        /// </summary>
        private async void HdcpDesiredMinimumProtection_Click(object sender, RoutedEventArgs e)
        {
            HdcpProtection desiredMinimumProtection = HdcpProtection.Off;
            string         selected = (sender as RadioButton).Tag.ToString();

            if (Enum.TryParse(selected, out desiredMinimumProtection))
            {
                var result = await hdcpSession.SetDesiredMinProtectionAsync(desiredMinimumProtection);

                HdcpProtection?actualProtection = hdcpSession.GetEffectiveProtection();
                if (result != HdcpSetProtectionResult.Success)
                {
                    Log($"ERROR: Unable to set HdcpProtection.{desiredMinimumProtection}, Error: {result}, Actual HDCP: {actualProtection}");
                }
                else
                {
                    Log($"HDCP Requested Minimum: {desiredMinimumProtection}, Actual: {actualProtection}");
                }
            }
        }
        /// <summary>
        /// Enforces a fictitious content publisher's rules for bandwidth maximums based on HDCP protection levels.
        /// </summary>
        /// <param name="protection">Protection level to use when imposing bandwidth restriction.</param>
        /// <param name="ams">AdaptiveMediaSource on which to impose restrictions</param>
        private void SetMaxBitrateForProtectionLevel(HdcpProtection? protection, AdaptiveMediaSource ams)
        {
            EffectiveHdcpProtectionText.Text = protection.ToString();

            if (ams != null && ams.AvailableBitrates.Count > 1)
            {
                // Get a sorted list of available bitrates.
                var bitrates = new List<uint>(ams.AvailableBitrates);
                bitrates.Sort();

                // Apply maximum bitrate policy based on a fictitious content publisher's rules.
                switch (protection)
                {
                    case HdcpProtection.OnWithTypeEnforcement:
                        // Allow full bitrate.
                        ams.DesiredMaxBitrate = bitrates[bitrates.Count - 1];
                        DesiredMaxBitrateText.Text = "full bitrate allowed";
                        break;
                    case HdcpProtection.On:
                        // When there is no HDCP Type 1, make the highest bitrate unavailable.
                        ams.DesiredMaxBitrate = bitrates[bitrates.Count - 2];
                        DesiredMaxBitrateText.Text = "highest bitrate is unavailable";
                        break;
                    case HdcpProtection.Off:
                    case null:
                    default:
                        // When there is no HDCP at all (Off), or the system is still trying to determine what
                        // HDCP protection level to apply (null), then make only the lowest bitrate available.
                        ams.DesiredMaxBitrate = bitrates[0];
                        DesiredMaxBitrateText.Text = "lowest bitrate only";
                        break;
                }
                Log($"Imposed DesiredMaxBitrate={ams.DesiredMaxBitrate} for HdcpProtection.{protection}");
            }
        }