public void SetUpProtectionManager(MediaPlayer mediaPlayer) { Log("Enter SetUpProtectionManager"); if(mediaPlayer == null) throw new ArgumentException("SetUpProtectionManager was passed a null MediaPlayer"); Log("Creating protection system mappings..."); var protectionManager = new MediaProtectionManager(); protectionManager.ComponentLoadFailed += new ComponentLoadFailedEventHandler(ProtectionManager_ComponentLoadFailed); protectionManager.ServiceRequested += new ServiceRequestedEventHandler(ProtectionManager_ServiceRequested); // The code here is mandatory and should be just copied directly over to the app // Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376846%28v=vs.85%29.aspx // Setup PlayReady as the ProtectionSystem to use by mediaFoundation: var contentProtectionSystems = new PropertySet(); contentProtectionSystems.Add(PlayReadyWinRTTrustedInput); protectionManager.Properties.Add(MediaProtectionSystemIdMapping, contentProtectionSystems); protectionManager.Properties.Add(MediaProtectionSystemId); protectionManager.Properties.Add(MediaProtectionContainerGuid); mediaPlayer.ProtectionManager = protectionManager; Log("Leave SetUpProtectionManager"); }
/// <summary>Initializes the PlayReady protection manager.</summary> private void InitializeMediaProtectionManager() { var mediaProtectionManager = new MediaProtectionManager(); mediaProtectionManager.ComponentLoadFailed += OnMediaProtectionManagerComponentLoadFailed; mediaProtectionManager.ServiceRequested += OnMediaProtectionManagerServiceRequested; // Set up the container GUID for the CFF format (used with DASH streams), see http://uvdemystified.com/uvfaq.html#3.2 // The GUID represents MPEG DASH Content Protection using Microsoft PlayReady, see http://dashif.org/identifiers/protection/ mediaProtectionManager.Properties["Windows.Media.Protection.MediaProtectionContainerGuid"] = "{9A04F079-9840-4286-AB92-E65BE0885F95}"; // Set up the drm layer to use. Hardware DRM is the default, but not all older hardware supports this var supportsHardwareDrm = PlayReadyStatics.CheckSupportedHardware(PlayReadyHardwareDRMFeatures.HardwareDRM); if (!supportsHardwareDrm) { mediaProtectionManager.Properties["Windows.Media.Protection.UseSoftwareProtectionLayer"] = true; } // Set up the content protection manager so it uses the PlayReady Input Trust Authority (ITA) for the relevant media sources // The MediaProtectionSystemId GUID is format and case sensitive, see https://msdn.microsoft.com/en-us/library/windows.media.protection.mediaprotectionmanager.properties.aspx var cpsystems = new PropertySet(); cpsystems[PlayReadyStatics.MediaProtectionSystemId.ToString("B").ToUpper()] = "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput"; mediaProtectionManager.Properties["Windows.Media.Protection.MediaProtectionSystemIdMapping"] = cpsystems; mediaProtectionManager.Properties["Windows.Media.Protection.MediaProtectionSystemId"] = PlayReadyStatics.MediaProtectionSystemId.ToString("B").ToUpper(); Player.ProtectionManager = mediaProtectionManager; }
public PlayReadyPage() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); this.navigationHelper.LoadState += this.NavigationHelper_LoadState; this.navigationHelper.SaveState += this.NavigationHelper_SaveState; var protectionManager = new MediaProtectionManager(); protectionManager.ComponentLoadFailed += ProtectionManager_ComponentLoadFailed; protectionManager.ServiceRequested += ProtectionManager_ServiceRequested; Windows.Foundation.Collections.PropertySet cpSystems = new Windows.Foundation.Collections.PropertySet(); cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput"); //Playready protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems); protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"); player.ProtectionManager = protectionManager; var extensions = player.MediaExtensionManager; extensions.RegisterByteStreamHandler("Microsoft.Media.PlayReadyClient.PlayReadyByteStreamHandler", ".pyv", "PRvideo"); extensions.RegisterByteStreamHandler("Microsoft.Media.PlayReadyClient.PlayReadyByteStreamHandler", ".pya", "PRaudio"); extensions.RegisterByteStreamHandler("Microsoft.Media.PlayReadyClient.PlayReadyByteStreamHandler", ".wma", "PRaudio"); extensions.RegisterByteStreamHandler("Microsoft.Media.PlayReadyClient.PlayReadyByteStreamHandler", ".wmv", "PRvideo"); }
void ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs srEvent) { serviceCompletionNotifier = srEvent.Completion; IPlayReadyServiceRequest serviceRequest = (IPlayReadyServiceRequest)srEvent.Request; ViewModelBase.Log(serviceRequest.GetType().Name); ProcessServiceRequest(serviceRequest); }
void ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs srEvent) { _serviceCompletionNotifier = srEvent.Completion; IPlayReadyServiceRequest serviceRequest = (IPlayReadyServiceRequest)srEvent.Request; _requestChain = new RequestChain(serviceRequest); _requestChain.LicenseRequestUri = new Uri(LAURL); _requestChain.RequestConfigData = this.RequestConfigData; _requestChain.FinishAndReportResult(new ReportResultDelegate(HandleServiceRequest_Finished)); }
/// <summary> /// A ComponentLoadFailed event will occur when binary data fails to load. /// This an infrequent event that may be triggered by a pending OS update in which DRM compoments /// are being renewed and may require a restart. /// </summary> static void ComponentLoadFailed(MediaProtectionManager sender, ComponentLoadFailedEventArgs e) { for (int i = 0; i < e.Information.Items.Count; i++) { ViewModelBase.Log(e.Information.Items[i].Name + "\nReasons=0x" + e.Information.Items[i].Reasons + "\n" + "Renewal Id=" + e.Information.Items[i].RenewalId); } e.Completion.Complete(false); }
void InitPlayReady() { var protectionManager = new MediaProtectionManager(); protectionManager.ComponentLoadFailed += ProtectionManager_ComponentLoadFailed; protectionManager.ServiceRequested += ProtectionManager_ServiceRequested; Windows.Foundation.Collections.PropertySet cpSystems = new Windows.Foundation.Collections.PropertySet(); cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput"); //Playready protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems); protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"); player.ProtectionManager = protectionManager; }
static public MediaProtectionManager InitializeProtectionManager(ServiceRequestedEventHandler serviceRequestHandler) { var protectionManager = new MediaProtectionManager(); //A setting to tell MF that we are using PlayReady. var props = new Windows.Foundation.Collections.PropertySet(); props.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput"); protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", props); protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"); //Maps the conatiner guid from the manifest or media segment protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionContainerGuid", "{9A04F079-9840-4286-AB92-E65BE0885F95}"); protectionManager.ServiceRequested += new ServiceRequestedEventHandler(serviceRequestHandler); protectionManager.ComponentLoadFailed += new ComponentLoadFailedEventHandler(ComponentLoadFailed); // Windows 10 provides built in support for Dash and does not require additional configuration. // This would be be good place to configure a MediaExtensionManager to support another stream source // such as the Smooth Streaming SDK return protectionManager; }
private async void OnMediaProtectionManagerServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs e) { Debug.WriteLine("ProtectionManager ServiceRequested"); var completionNotifier = e.Completion; var request = (IPlayReadyServiceRequest)e.Request; var result = false; if (request.Type == PlayReadyStatics.IndividualizationServiceRequestType) { result = await PlayReadyLicenseHandler.RequestIndividualizationToken(request as PlayReadyIndividualizationServiceRequest); } else if (request.Type == PlayReadyStatics.LicenseAcquirerServiceRequestType) { // NOTE: You might need to set the request.ChallengeCustomData, depending on your Rights Manager. if (!string.IsNullOrEmpty(arguments.RightsManagerUrl)) { request.Uri = new Uri(arguments.RightsManagerUrl); } result = await PlayReadyLicenseHandler.RequestLicense(request as PlayReadyLicenseAcquisitionServiceRequest); } completionNotifier.Complete(result); }
private void OnMediaProtectionManagerComponentLoadFailed(MediaProtectionManager sender, ComponentLoadFailedEventArgs e) { Debug.WriteLine("ProtectionManager ComponentLoadFailed"); e.Completion.Complete(false); }
void ProtectionManager_ComponentLoadFailed(MediaProtectionManager sender, ComponentLoadFailedEventArgs e) { e.Completion.Complete(false); }
private void SetUpProtectionManager(ref MediaElement m) { log("Enter SetUpProtectionManager"); log("Creating protection system mappings..."); protectionManager = new MediaProtectionManager(); protectionManager.ComponentLoadFailed += new ComponentLoadFailedEventHandler(ProtectionManager_ComponentLoadFailed); protectionManager.ServiceRequested += new ServiceRequestedEventHandler(ProtectionManager_ServiceRequested); //Setup PlayReady as the ProtectionSystem to use by MF. //The code here is mandatory and should be just copied directly over to the app Windows.Foundation.Collections.PropertySet cpSystems = new Windows.Foundation.Collections.PropertySet(); cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput"); protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems); //Use by the media stream source about how to create ITA InitData. //See here for more detai: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376846%28v=vs.85%29.aspx protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"); // Setup the container GUID that's in the PPSH box protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionContainerGuid", "{9A04F079-9840-4286-AB92-E65BE0885F95}"); m.ProtectionManager = protectionManager; log("Leave SetUpProtectionManager"); }
private async void ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs e) { log("Enter ProtectionManager_ServiceRequested"); if (e.Request is PlayReadyIndividualizationServiceRequest) { PlayReadyIndividualizationServiceRequest IndivRequest = e.Request as PlayReadyIndividualizationServiceRequest; bool bResultIndiv = await ReactiveIndivRequest(IndivRequest, e.Completion); } else if (e.Request is PlayReadyLicenseAcquisitionServiceRequest) { PlayReadyLicenseAcquisitionServiceRequest licenseRequest = e.Request as PlayReadyLicenseAcquisitionServiceRequest; LicenseAcquisitionRequest(licenseRequest, e.Completion, playReadyLicenseUrl, playReadyChallengeCustomData); } log("Leave ProtectionManager_ServiceRequested"); }
private void ProtectionManager_ComponentLoadFailed(MediaProtectionManager sender, ComponentLoadFailedEventArgs e) { Log("Enter ProtectionManager_ComponentLoadFailed"); Log(e.Information.ToString()); // List the failing components - RevocationAndRenewalInformation foreach (var item in e.Information.Items) { Log(item.Name + "\nReasons=0x" + item.Reasons + "\nRenewal Id=" + item.RenewalId); } e.Completion.Complete(false); Log("Leave ProtectionManager_ComponentLoadFailed"); }
// Method not used in this sample. // This shows the minimal configuration for basic reactive playback. public void MinConfig(MediaElement mediaElement) { var manager = new MediaProtectionManager(); var props = new Windows.Foundation.Collections.PropertySet(); props.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput"); manager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", props); manager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"); manager.Properties.Add("Windows.Media.Protection.MediaProtectionContainerGuid", "{9A04F079-9840-4286-AB92-E65BE0885F95}"); MediaProtectionServiceCompletion completionNotifer = null; manager.ServiceRequested += async (sender, srEvent) => { completionNotifer = srEvent.Completion; var serviceRequest = (IPlayReadyServiceRequest)srEvent.Request; ProcessServiceRequest(serviceRequest); if (serviceRequest is PlayReadyIndividualizationServiceRequest) { var indivRequest = serviceRequest as PlayReadyIndividualizationServiceRequest; await indivRequest.BeginServiceRequest(); serviceCompletionNotifier.Complete(true); } else if (serviceRequest is PlayReadyLicenseAcquisitionServiceRequest) { var licenseRequest = serviceRequest as PlayReadyLicenseAcquisitionServiceRequest; //licenseRequest. await licenseRequest.BeginServiceRequest(); serviceCompletionNotifier.Complete(true); serviceCompletionNotifier = null; } }; mediaElement.ProtectionManager = manager; }
private void ProtectionManager_ComponentLoadFailed(MediaProtectionManager sender, ComponentLoadFailedEventArgs e) { log("Enter ProtectionManager_ComponentLoadFailed"); log(e.Information.ToString()); // List the failing components - RevocationAndRenewalInformation for (int i = 0; i < e.Information.Items.Count; i++) { log(e.Information.Items[i].Name + "\nReasons=0x" + e.Information.Items[i].Reasons + "\n" + "Renewal Id=" + e.Information.Items[i].RenewalId); } e.Completion.Complete(false); log("Leave ProtectionManager_ComponentLoadFailed"); }
public MediaProtectionManagerEvents(MediaProtectionManager This) { this.This = This; }