public void MeteringReportProactively() { TestLogger.LogMessage("Enter Metering.MeteringReportProactively()"); try { TestLogger.LogMessage("Creating metering report service request..."); PlayReadyMeteringReportServiceRequest meteringRequest = new PlayReadyMeteringReportServiceRequest(); MeteringReportReactively(meteringRequest); } catch (Exception ex) { if (ex.HResult == ServiceRequest.MSPR_E_NEEDS_INDIVIDUALIZATION) { PlayReadyIndividualizationServiceRequest indivServiceRequest = new PlayReadyIndividualizationServiceRequest(); RequestChain requestChain = new RequestChain(indivServiceRequest); requestChain.FinishAndReportResult(new ReportResultDelegate(HandleIndivServiceRequest_Finished)); } else { TestLogger.LogImportantMessage("MeteringReportProactively failed:" + ex.HResult); } } TestLogger.LogMessage("Leave Metering.MeteringReportProactively()"); }
public void DomainLeaveProactively() { TestLogger.LogMessage("Enter DomainLeave.DomainLeaveProactively()"); try { PlayReadyDomainLeaveServiceRequest domainLeaveRequest = new PlayReadyDomainLeaveServiceRequest(); DomainLeaveReactively(domainLeaveRequest); } catch (Exception ex) { if (ex.HResult == ServiceRequest.MSPR_E_NEEDS_INDIVIDUALIZATION) { PlayReadyIndividualizationServiceRequest indivServiceRequest = new PlayReadyIndividualizationServiceRequest(); RequestChain requestChain = new RequestChain(indivServiceRequest); requestChain.FinishAndReportResult(new ReportResultDelegate(HandleIndivServiceRequest_Finished)); } else { TestLogger.LogMessage("DomainLeaveProactively failed:" + ex.HResult); } } TestLogger.LogMessage("Leave DomainLeave.DomainLeaveProactively()"); }
public async void IndivReactively(PlayReadyIndividualizationServiceRequest indivRequest) { TestLogger.LogMessage("Enter Indiv.IndivReactively()"); Exception exception = null; try { _serviceRequest = indivRequest; SerivceRequestStatistics.IncIndivCount(); TestLogger.LogMessage("Begin indiv service request..."); await indivRequest.BeginServiceRequest(); } catch (Exception ex) { TestLogger.LogMessage("Saving exception.."); exception = ex; } finally { IndivServiceRequestCompleted(indivRequest, exception); } TestLogger.LogMessage("Leave Indiv.IndivReactively()"); }
/// <summary> /// Invoked to send the Individualization Request /// </summary> async Task <bool> ReactiveIndividualizationRequestAsync(PlayReadyIndividualizationServiceRequest individualizationRequest, MediaProtectionServiceCompletion completionNotifier) { bool bResult = false; Log("ProtectionManager PlayReady Individualization Service Request in progress..."); try { await individualizationRequest.BeginServiceRequest(); bResult = true; } catch (COMException comException) when(comException.HResult == MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED) { individualizationRequest.NextServiceRequest(); } catch (Exception) { } if (bResult == true) { Log("ProtectionManager PlayReady Individualization Service Request successful"); } else { Log("ProtectionManager PlayReady Individualization Service Request failed"); } if (completionNotifier != null) { completionNotifier.Complete(bResult); } return(bResult); }
/// <summary> /// The individual process can kick off proactively and not need to wait for a reactionary service /// request from PlayReady. This enables the app to manage when activation occures. /// </summary> static public void ProactiveIndividualization(Action callback) { //Creating a new Indiv request and using the previous reactive method to complete the request var indivRequest = new PlayReadyIndividualizationServiceRequest(); ReactiveIndividualization(indivRequest, null, callback); }
private async void ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs e) { Log("ProtectionManager_ServiceRequested"); if (e.Request is PlayReadyIndividualizationServiceRequest) { Log("ProtectionManager_ServiceRequested: PlayReadyIndividualizationServiceRequest"); PlayReadyIndividualizationServiceRequest individualizationServiceRequest = (PlayReadyIndividualizationServiceRequest)e.Request; await individualizationServiceRequest.BeginServiceRequest(); Log("ProtectionManager_ServiceRequested: PlayReadyIndividualizationServiceRequest complete"); e.Completion.Complete(true); } else if (e.Request is PlayReadyLicenseAcquisitionServiceRequest) { Log("ProtectionManager_ServiceRequested: PlayReadyLicenseAcquisitionServiceRequest"); PlayReadyLicenseAcquisitionServiceRequest licenseAcquisitionRequest = (PlayReadyLicenseAcquisitionServiceRequest)e.Request; await licenseAcquisitionRequest.BeginServiceRequest(); Log("ProtectionManager_ServiceRequested: PlayReadyLicenseAcquisitionServiceRequest complete"); e.Completion.Complete(true); } }
public void SecureStopProactively() { Debug.WriteLine("Enter SecureStop.SecureStopReportProactively()"); try { Debug.WriteLine("Creating SecureStop report service request..."); PlayReadySecureStopIterable secureStopIterable = new PlayReadySecureStopIterable(_SecureStopCert); PlayReadySecureStopServiceRequest SecureStopRequest = secureStopIterable.First() as PlayReadySecureStopServiceRequest; //PlayReadySecureStopServiceRequest SecureStopRequest = new PlayReadySecureStopServiceRequest(_SecureStopCert); SecureStopReactively(SecureStopRequest); } catch (Exception ex) { if (ex.HResult == ServiceRequest.MSPR_E_NEEDS_INDIVIDUALIZATION) { PlayReadyIndividualizationServiceRequest indivServiceRequest = new PlayReadyIndividualizationServiceRequest(); RequestChain requestChain = new RequestChain(indivServiceRequest); requestChain.FinishAndReportResult(new ReportResultDelegate(HandleIndivServiceRequest_Finished)); } else { Debug.WriteLine("SecureStopProactively failed:" + ex.HResult); } } Debug.WriteLine("Leave SecureStop.SecureStopReportProactively()"); }
public void AcquireLicenseProactively() { IPlayReadyLicenseAcquisitionServiceRequest licenseRequest; try { PlayReadyContentHeader contentHeader = new PlayReadyContentHeader(0, RequestConfigData.KeyIds, null, RequestConfigData.EncryptionAlgorithm, null, null, String.Empty, RequestConfigData.DomainServiceId); Debug.WriteLine("Creating license acquisition service request..."); if (bPersistent) { // persistent license licenseRequest = (IPlayReadyLicenseAcquisitionServiceRequest) new PlayReadyLicenseAcquisitionServiceRequest(); } else { if (this.licenseSession == null) { throw new ArgumentNullException("licenseSession can not be null"); } //in-memory license, use license session to create a license service request //this way, the acquired license will be tied to the media session associated with the license session licenseRequest = this.licenseSession.CreateLAServiceRequest(); } licenseRequest.ContentHeader = contentHeader; licenseRequest.Uri = RequestConfigData.Uri; AcquireLicenseReactively(licenseRequest); } catch (Exception ex) { if (ex.HResult == ServiceRequest.MSPR_E_NEEDS_INDIVIDUALIZATION) { PlayReadyIndividualizationServiceRequest indivServiceRequest = new PlayReadyIndividualizationServiceRequest(); RequestChain requestChain = new RequestChain(indivServiceRequest); requestChain.FinishAndReportResult(new ReportResultDelegate(HandleIndivServiceRequest_Finished)); } else { //Debug.WriteLine("AcquireLicenseProactively failed:" + ex.HResult); Debug.WriteLine("AcquireLicenseProactively failed:" + ex.HResult); licenseRequest = (IPlayReadyLicenseAcquisitionServiceRequest) new PlayReadyLicenseAcquisitionServiceRequest(); LAServiceRequestCompleted(licenseRequest, ex); } } }
void HandleIndivServiceRequest(PlayReadyIndividualizationServiceRequest serviceRequest) { Debug.WriteLine(" "); Debug.WriteLine("Enter RequestChain.HandleIndivServiceRequest()"); _indivAndReportResult = new IndivAndReportResult(new ReportResultDelegate(HandleServiceRequest_Finished)); _indivAndReportResult.RequestConfigData = _requestConfigData; _indivAndReportResult.IndivReactively(serviceRequest); Debug.WriteLine("Leave RequestChain.HandleIndivServiceRequest()"); }
protected override void IndivServiceRequestCompleted(PlayReadyIndividualizationServiceRequest sender, Exception hrCompletionStatus) { if (hrCompletionStatus == null) { _reportResult(true); } else { //needed for LA revoke->Re-Indiv->LA sequence if (!PerformEnablingActionIfRequested(hrCompletionStatus)) { _reportResult(false); } } }
protected override void IndivServiceRequestCompleted( PlayReadyIndividualizationServiceRequest sender, Exception hrCompletionStatus ) { if( hrCompletionStatus == null ) { _reportResult( true ); } else { //needed for LA revoke->Re-Indiv->LA sequence if( !PerformEnablingActionIfRequested(hrCompletionStatus) ) { _reportResult( false ); } } }
/// <summary> /// Proactive Individualization Request /// </summary> async void ProactiveIndividualizationRequest() { var individualizationRequest = new PlayReadyIndividualizationServiceRequest(); Log("ProtectionManager PlayReady ProActive Individualization Service Request in progress..."); bool bResultIndiv = await ReactiveIndividualizationRequestAsync(individualizationRequest, null); if (bResultIndiv == true) { Log("ProtectionManager PlayReady ProActive Individualization Service Request successful"); } else { Log("ProtectionManager PlayReady ProActive Individualization Service Request failed"); } }
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"); }
/// <summary> /// Invoked to send the Individualization Request /// </summary> async Task <bool> ReactiveIndivRequest(PlayReadyIndividualizationServiceRequest IndivRequest, MediaProtectionServiceCompletion CompletionNotifier) { bool bResult = false; Exception exception = null; log("ProtectionManager PlayReady Individualization Service Request in progress..."); try { await IndivRequest.BeginServiceRequest(); } catch (Exception ex) { exception = ex; } finally { if (exception == null) { bResult = true; } else { COMException comException = exception as COMException; if (comException != null && comException.HResult == MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED) { IndivRequest.NextServiceRequest(); } } } if (bResult == true) { log("ProtectionManager PlayReady Individualization Service Request successful"); } else { log("ProtectionManager PlayReady Individualization Service Request failed"); } if (CompletionNotifier != null) { CompletionNotifier.Complete(bResult); } return(bResult); }
async public void IndivReactively(PlayReadyIndividualizationServiceRequest indivRequest) { Exception exception = null; try { _serviceRequest = indivRequest; await indivRequest.BeginServiceRequest(); } catch ( Exception ex ) { exception = ex; } finally { IndivServiceRequestCompleted( indivRequest, exception ); } }
async public void IndivReactively(PlayReadyIndividualizationServiceRequest indivRequest) { Exception exception = null; try { _serviceRequest = indivRequest; await indivRequest.BeginServiceRequest(); } catch (Exception ex) { exception = ex; } finally { IndivServiceRequestCompleted(indivRequest, exception); } }
/// <summary>Request a token that identifies the player session.</summary> /// <param name="request">The request.</param> /// <returns><c>True</c> if successfull, <c>false</c> otherwise.</returns> public static async Task <bool> RequestIndividualizationToken(PlayReadyIndividualizationServiceRequest request) { Debug.WriteLine("ProtectionManager PlayReady Individualization Service Request in progress"); try { Debug.WriteLine("Requesting individualization token from {0}", request.Uri); await request.BeginServiceRequest(); } catch (Exception ex) { Debug.WriteLine("ProtectionManager PlayReady Individualization Service Request failed: " + ex.Message); return(false); } Debug.WriteLine("ProtectionManager PlayReady Individualization Service Request successfull"); return(true); }
/// <summary>Request a token that identifies the player session.</summary> /// <param name="request">The request.</param> /// <returns><c>True</c> if successfull, <c>false</c> otherwise.</returns> public static async Task<bool> RequestIndividualizationToken(PlayReadyIndividualizationServiceRequest request) { Debug.WriteLine("ProtectionManager PlayReady Individualization Service Request in progress"); try { Debug.WriteLine("Requesting individualization token from {0}", request.Uri); await request.BeginServiceRequest(); } catch (Exception ex) { Debug.WriteLine("ProtectionManager PlayReady Individualization Service Request failed: " + ex.Message); return false; } Debug.WriteLine("ProtectionManager PlayReady Individualization Service Request successfull"); return true; }
protected override void IndivServiceRequestCompleted(PlayReadyIndividualizationServiceRequest sender, Exception hrCompletionStatus) { TestLogger.LogMessage("Enter IndivAndReportResult.IndivServiceRequestCompleted()"); if (hrCompletionStatus == null) { TestLogger.LogImportantMessage("***Indiv succeeded***"); TestLogger.LogImportantMessage("PlayReady security version " + Windows.Media.Protection.PlayReady.PlayReadyStatics.PlayReadySecurityVersion); _reportResult(true, null); } else { //needed for LA revoke->Re-Indiv->LA sequence if (!PerformEnablingActionIfRequested(hrCompletionStatus)) { TestLogger.LogError("IndivServiceRequestCompleted ERROR: " + hrCompletionStatus.ToString()); _reportResult(false, null); } } TestLogger.LogMessage("Leave IndivAndReportResult.IndivServiceRequestCompleted()"); }
public void HandleRevocationProactively() { try { PlayReadyRevocationServiceRequest request = new PlayReadyRevocationServiceRequest(); HandleRevocationReactively(request); } catch (Exception ex) { if (ex.HResult == ServiceRequest.MSPR_E_NEEDS_INDIVIDUALIZATION) { PlayReadyIndividualizationServiceRequest indivServiceRequest = new PlayReadyIndividualizationServiceRequest(); RequestChain requestChain = new RequestChain(indivServiceRequest); requestChain.FinishAndReportResult(new ReportResultDelegate(HandleIndivServiceRequest_Finished)); } else { TestLogger.LogImportantMessage("HandleRevocationProactively failed:" + ex.HResult); } } }
/// <summary> /// Reactive individualization is triggered by PlayReady when the DRM is first utilized in a new app. /// If individualization was triggered as part a license request then that request will be queued until /// the indiv process completes. The serviceCompletionNotifier is utilized to notify the ProtectionManager /// that the next service request can begin. /// </summary> static public async void ReactiveIndividualization(PlayReadyIndividualizationServiceRequest indivRequest, MediaProtectionServiceCompletion serviceCompletionNotifier, Action callback = null) { Exception exception = null; try { // The actual service call. // The Indiv ServiceRequest call cannot be customized like most other ServiceRequests. await indivRequest.BeginServiceRequest(); } catch (Exception ex) { exception = ex; } finally { if (serviceCompletionNotifier != null) { // The Complete call will notify listeners that the service call is complete // and queued service requests can begin. serviceCompletionNotifier.Complete(exception == null); } ViewModelBase.Log("ReactiveIndividualization::Complete"); } // The callback is only used in the sample to show PlayReadyStatics within the UI on the // completion of the ServiceRequest. if (callback != null) { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { callback.Invoke(); }); } }
public void IndivProactively() { PlayReadyIndividualizationServiceRequest indivRequest = new PlayReadyIndividualizationServiceRequest(); IndivReactively(indivRequest); }
protected virtual void IndivServiceRequestCompleted(PlayReadyIndividualizationServiceRequest sender, Exception hrCompletionStatus) { }
void HandleIndivServiceRequest(PlayReadyIndividualizationServiceRequest serviceRequest) { _indivAndReportResult = new IndivAndReportResult(new ReportResultDelegate(HandleServiceRequest_Finished)); _indivAndReportResult.RequestConfigData = RequestConfigData; _indivAndReportResult.IndivReactively(serviceRequest); }
/// <summary> /// Invoked to send the Individualization Request /// </summary> async Task<bool> ReactiveIndividualizationRequestAsync(PlayReadyIndividualizationServiceRequest individualizationRequest, MediaProtectionServiceCompletion completionNotifier) { bool bResult = false; Log("ProtectionManager PlayReady Individualization Service Request in progress..."); try { await individualizationRequest.BeginServiceRequest(); bResult = true; } catch (COMException comException) when (comException.HResult == MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED) { individualizationRequest.NextServiceRequest(); } catch (Exception) { } if (bResult == true) Log("ProtectionManager PlayReady Individualization Service Request successful"); else Log("ProtectionManager PlayReady Individualization Service Request failed"); if (completionNotifier != null) completionNotifier.Complete(bResult); return bResult; }
/// <summary> /// Reactive individualization is triggered by PlayReady when the DRM is first utilized in a new app. /// If individualization was triggered as part a license request then that request will be queued until /// the indiv process completes. The serviceCompletionNotifier is utilized to notify the ProtectionManager /// that the next service request can begin. /// </summary> static public async void ReactiveIndividualization(PlayReadyIndividualizationServiceRequest indivRequest, MediaProtectionServiceCompletion serviceCompletionNotifier, Action callback = null) { Exception exception = null; try { // The actual service call. // The Indiv ServiceRequest call cannot be customized like most other ServiceRequests. await indivRequest.BeginServiceRequest(); } catch (Exception ex) { exception = ex; } finally { if (serviceCompletionNotifier != null) { // The Complete call will notify listeners that the service call is complete // and queued service requests can begin. serviceCompletionNotifier.Complete(exception == null); } ViewModelBase.Log("ReactiveIndividualization::Complete"); } // The callback is only used in the sample to show PlayReadyStatics within the UI on the // completion of the ServiceRequest. if (callback != null) { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { callback.Invoke(); }); } }
/// <summary> /// The individual process can kick off proactively and not need to wait for a reactionary service /// request from PlayReady. This enables the app to manage when activation occures. /// </summary> static public void ProactiveIndividualization(Action callback) { //Creating a new Indiv request and using the previous reactive method to complete the request var indivRequest = new PlayReadyIndividualizationServiceRequest(); ReactiveIndividualization(indivRequest, null, callback); }
public void IndivProactively() { PlayReadyIndividualizationServiceRequest indivRequest = new PlayReadyIndividualizationServiceRequest(); IndivReactively(indivRequest); }
protected virtual void IndivServiceRequestCompleted( PlayReadyIndividualizationServiceRequest sender, Exception hrCompletionStatus ) { }
/// <summary> /// Proactive Individualization Request /// </summary> async void ProActiveIndivRequest() { PlayReadyIndividualizationServiceRequest indivRequest = new PlayReadyIndividualizationServiceRequest(); log("ProtectionManager PlayReady ProActive Individualization Service Request in progress..."); bool bResultIndiv = await ReactiveIndivRequest(indivRequest, null); if (bResultIndiv == true) log("ProtectionManager PlayReady ProActive Individualization Service Request successful"); else log("ProtectionManager PlayReady ProActive Individualization Service Request failed"); }
/// <summary> /// Invoked to send the Individualization Request /// </summary> async Task<bool> ReactiveIndivRequest(PlayReadyIndividualizationServiceRequest IndivRequest, MediaProtectionServiceCompletion CompletionNotifier) { bool bResult = false; Exception exception = null; log("ProtectionManager PlayReady Individualization Service Request in progress..."); try { await IndivRequest.BeginServiceRequest(); } catch (Exception ex) { exception = ex; } finally { if (exception == null) { bResult = true; } else { COMException comException = exception as COMException; if (comException != null && comException.HResult == MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED) { IndivRequest.NextServiceRequest(); } } } if (bResult == true) log("ProtectionManager PlayReady Individualization Service Request successful"); else log("ProtectionManager PlayReady Individualization Service Request failed"); if (CompletionNotifier != null) CompletionNotifier.Complete(bResult); return bResult; }
void HandleIndivServiceRequest(PlayReadyIndividualizationServiceRequest serviceRequest) { _indivAndReportResult = new IndivAndReportResult(new ReportResultDelegate(HandleServiceRequest_Finished)); _indivAndReportResult.RequestConfigData = RequestConfigData; _indivAndReportResult.IndivReactively(serviceRequest); }