public void Test_LicenseAcquisition(Guid [] GuidKids, string strEncryptionAlgorithm, string strLAURL, string strServiceID, string strCustomData, string useManualEnabling, string errorExpected) { TestLogger.LogMessage("Enter Test_LicenseAcquisition()"); ServiceRequestConfigData requestConfigData = new ServiceRequestConfigData(); requestConfigData.KeyIds = GuidKids; requestConfigData.EncryptionAlgorithm = ActionParamConvertToPlayReadyEncryptionAlgorithm(strEncryptionAlgorithm); requestConfigData.Uri = ActionParamConvertToUri(strLAURL); requestConfigData.DomainServiceId = ActionParamConvertToGuid(strServiceID); requestConfigData.ChallengeCustomData = ActionParamConvertToString(strCustomData); if (useManualEnabling.ToLower() == "true") { requestConfigData.ManualEnabling = true; } _licenseAcquisition = new LAAndReportResult(new ReportResultDelegate(TestActionFinished)); _licenseAcquisition.RequestConfigData = requestConfigData; _licenseAcquisition.ExpectedError = ActionParamConvertToString(errorExpected); _licenseAcquisition.AcquireLicenseProactively(); TestLogger.LogMessage("Leave Test_LicenseAcquisition()"); }
void HandleLicenseAcquisitionServiceRequest(PlayReadyLicenseAcquisitionServiceRequest serviceRequest) { TestLogger.LogMessage(" "); TestLogger.LogMessage("Enter RequestChain.HandleLicenseAcquisitionServiceRequest()"); _licenseAcquisition = new LAAndReportResult(new ReportResultDelegate(HandleServiceRequest_Finished)); _licenseAcquisition.RequestConfigData = _requestConfigData; _licenseAcquisition.AcquireLicenseReactively(serviceRequest); TestLogger.LogMessage("Leave RequestChain.HandleLicenseAcquisitionServiceRequest()"); }
public void Test_CocktailContentResolver(string strContentHeader, string strLAURL, string strExpectServiceRequest) { TestLogger.LogMessage("Enter Test_CocktailContentResolver()"); bool bExpectServiceRequest = ActionParamConvertToBool(strExpectServiceRequest); Uri uri = ActionParamConvertToUri(strLAURL); TestLogger.LogMessage(strContentHeader); PlayReadyContentHeader contentHeader = new PlayReadyContentHeader( new System.Text.UnicodeEncoding().GetBytes(strContentHeader), uri, uri, String.Empty, Guid.Empty ); LicenseAcquisition.DumpContentHeaderValues(contentHeader); TestLogger.LogMessage("Using PlayReadyContentResolver..."); IPlayReadyServiceRequest serviceRequest = PlayReadyContentResolver.ServiceRequest(contentHeader); if (serviceRequest == null && !bExpectServiceRequest) { TestLogger.LogMessage("ServiceRequest not needed!!!"); TestActionFinished(true, null); } else { TestLogger.LogMessage("Servicing request..."); PlayReadyLicenseAcquisitionServiceRequest licenseServiceRequest = serviceRequest as PlayReadyLicenseAcquisitionServiceRequest; LAAndReportResult licenseAcquisition = new LAAndReportResult(new ReportResultDelegate(TestActionFinished), null); licenseAcquisition.AcquireLicenseReactively(serviceRequest as PlayReadyLicenseAcquisitionServiceRequest); } TestLogger.LogMessage("Leave Test_CocktailContentResolver()"); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { itemIds = (String[])e.NavigationParameter; MediaCount = (uint)itemIds.Length; playbackContents = new Playback[MediaCount]; playbackContents[0] = new Playback(myME); if (MediaCount > 1) { playbackContents[1] = new Playback(myME2); if (MediaCount > 2) { playbackContents[2] = new Playback(myME3); } } for (uint playerIndex = 0; playerIndex < itemIds.Length; playerIndex++) { PRUtilities prUtilities = new PRUtilities(); SampleDataItem item = await SampleDataSource.GetItemAsync(itemIds[playerIndex]); this.DefaultViewModel["Item" + (playerIndex + 1).ToString()] = item; item.PlayerIndex = playerIndex; item.IsLDL = false; this.localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; if (item.Laurl.Contains("http://playready.directtaps.net")) { if (this.localSettings.Values.ContainsKey("CustomRightsURL")) { item.LaurlWithRights = item.Laurl + this.localSettings.Values["CustomRightsURL"]; } else { item.LaurlWithRights = item.Laurl + "&UseSimpleNonPersistentLicense=1"; } } else { item.LaurlWithRights = item.Laurl; } ConfigLayout((int)playerIndex, item); if (!(item.Kid.ToString().Equals("null"))) { //proactive LA LAAndReportResult licenseAcquisition = new LAAndReportResult(new ReportResultDelegate(ProvactiveActionFinished), item); bool isFirstPlayExpirationUsed = false; item.IsRootLicense = false; if (item.UplinkKey != "null") { LogMessage("pre-acquire a non-expired root license"); item.IsRootLicense = true; ProactiveLA(licenseAcquisition, item, playbackContents[playerIndex], item.LaurlWithRights, isFirstPlayExpirationUsed, item.IsRootLicense); } item.IsRootLicense = false; if (item.FirstPlayExpiration != "null") { LogMessage("pre-acquire a SDL(short duration license) first"); isFirstPlayExpirationUsed = true; } else { LogMessage("pre-acquire a non-expiration license"); } ProactiveLA(licenseAcquisition, item, playbackContents[playerIndex], item.LaurlWithRights, isFirstPlayExpirationUsed, item.IsRootLicense); if (isFirstPlayExpirationUsed && item.FirstPlayExpiration != "null") { isFirstPlayExpirationUsed = false; uint?uintSec = prUtilities.ActionParamConvertToUint(item.FirstPlayExpiration); if (uintSec != null) { uint waitDuration = (uint)uintSec * 1000 - timeBuffer; if (waitDuration < 0) { waitDuration = 0; } LogMessage("wait for " + waitDuration + " ms"); await Task.Delay((int)waitDuration); } else { LogError("invalid FirstPlayExpiration value"); break; } LogMessage("acquire a LDL(long duration license) before SDL expired"); item.IsLDL = true; ProactiveLA(licenseAcquisition, item, playbackContents[playerIndex], item.LaurlWithRights, isFirstPlayExpirationUsed, item.IsRootLicense); } } else { //reactive LA ServiceRequestConfigData requestConfigData = new ServiceRequestConfigData(); if (item.Laurl != "null") { requestConfigData.Uri = new Uri(item.LaurlWithRights); } if (item.DomainUrl != "null") { requestConfigData.DomainUri = new Uri(item.DomainUrl); } if (item.CustomData != "null") { requestConfigData.ChallengeCustomData = item.CustomData; } playbackContents[playerIndex].RequestConfigData = requestConfigData; playbackContents[playerIndex].Play(item.Content); } } }
private void ProactiveLA(LAAndReportResult f_licenseAcquisition, SampleDataItem f_item, Playback f_playMedia, String f_Laurl, bool f_useFirstPlayExpiration, bool f_rootLicense) { PRUtilities prUtilities = new PRUtilities(); String laurl = f_Laurl; ServiceRequestConfigData LArequestConfigData = new ServiceRequestConfigData(); if (f_rootLicense && f_item.UplinkKey != "null") //pre-acquire a root license { Guid[] GuidRootKids = new Guid[1]; GuidRootKids[0] = prUtilities.ActionParamConvertToGuid(f_item.UplinkKey); LArequestConfigData.KeyIds = GuidRootKids; //chained Root License laurl = laurl + "&UseRootLicense=1"; } else if (!(f_item.Kid.ToString().Equals("null"))) //if kids is not null, proactively acquire simple or leaf license { if (f_item.UplinkKey != "null") { //chained Leaf License Guid uplinkKeyGUID = prUtilities.ActionParamConvertToGuid(f_item.UplinkKey); LogMessage("uplinkKeyGUID=" + uplinkKeyGUID); string base64UplinkKid = prUtilities.GuidToBase64(uplinkKeyGUID); LogMessage("base64UplinkKid=" + base64UplinkKid); { laurl = laurl + "&UseChainLicense=1" + "&UplinkKey=" + base64UplinkKid; } } int count = 100; int i = 0; Guid[] guidKids; string[] keyIds = f_item.Kid.Split(','); int len = keyIds.Length; if (f_useFirstPlayExpiration && f_item.FirstPlayExpiration != "null") //realtime expiration { laurl = laurl + "&RealTimeExpiration=1" + "&FirstPlayExpiration=" + f_item.FirstPlayExpiration; guidKids = new Guid[count]; for (; i < count / 2; i++) { guidKids[i] = Guid.NewGuid(); } for (int j = 0; j < len; j++) { guidKids[i++] = prUtilities.ActionParamConvertToGuid(keyIds[j]); } for (; i < count; i++) { guidKids[i] = Guid.NewGuid(); } } else { guidKids = new Guid[len]; for (int j = 0; j < len; j++) { guidKids[j] = prUtilities.ActionParamConvertToGuid(keyIds[j]); } } LArequestConfigData.KeyIds = guidKids; } LArequestConfigData.EncryptionAlgorithm = prUtilities.ActionParamConvertToPlayReadyEncryptionAlgorithm(f_item.EncryptionAlgorithm); LArequestConfigData.Uri = prUtilities.ActionParamConvertToUri(laurl); LArequestConfigData.DomainServiceId = prUtilities.ActionParamConvertToGuid(f_item.DomainId); LArequestConfigData.ChallengeCustomData = prUtilities.ActionParamConvertToString(f_item.CustomData); f_licenseAcquisition.RequestConfigData = LArequestConfigData; if (f_Laurl.Contains("UseSimpleNonPersistentLicense=1")) { //To acquire in memory license proactively that will later be used for playback, we need to create the media session before hand. //Afterward, we need to tie the license session to the playback session. See configMediaProtectionManager for more detail. f_licenseAcquisition.Persistent = false; f_licenseAcquisition.configMediaProtectionManager(f_playMedia.mediaProtectionManager); } else { f_licenseAcquisition.Persistent = true; } f_licenseAcquisition.AcquireLicenseProactively(); }