Esempio n. 1
0
        public void Test_PlayWithExpectedError(MediaElement mediaElement,
                                               string mediaName,
                                               string strLAURL,
                                               string strCustomData,
                                               string strServiceId,
                                               string strAccountId,
                                               string strExpectedError)
        {
            TestLogger.LogMessage("Enter Test_PlayWithExpectedError()");

            ServiceRequestConfigData requestConfigData = new ServiceRequestConfigData();

            requestConfigData.Uri = ActionParamConvertToUri(strLAURL);
            requestConfigData.ChallengeCustomData = ActionParamConvertToString(strCustomData);
            requestConfigData.DomainUri           = requestConfigData.Uri;
            requestConfigData.DomainServiceId     = ActionParamConvertToGuid(strServiceId);
            requestConfigData.DomainAccountId     = ActionParamConvertToGuid(strAccountId);

            _playbackAndReportResult = new PlaybackAndReportResult(
                mediaElement,
                new ReportResultDelegate(TestActionFinished),
                ActionParamConvertToString(strExpectedError)
                );
            _playbackAndReportResult.RequestConfigData = requestConfigData;
            _playbackAndReportResult.FullPlayback(mediaElement, mediaName);

            TestLogger.LogMessage("Leave Test_PlayWithExpectedError()");
        }
Esempio n. 2
0
        public void Test_PlayExpectLAFailure(MediaElement mediaElement,
                                             string mediaName,
                                             string strLAURL,
                                             string strCustomData,
                                             string strExpectedLAErrorCode,
                                             string strExpectedPlaybackErrorCode,
                                             string useManualEnabling
                                             )
        {
            TestLogger.LogMessage("Enter Test_PlayExpectLAFailure()");

            ServiceRequestConfigData requestConfigData = new ServiceRequestConfigData();

            requestConfigData.Uri = ActionParamConvertToUri(strLAURL);
            requestConfigData.ChallengeCustomData = ActionParamConvertToString(strCustomData);
            requestConfigData.ExpectedLAErrorCode = ActionParamConvertToString(strExpectedLAErrorCode);
            requestConfigData.ManualEnabling      = ActionParamConvertToBool(useManualEnabling);

            _playbackAndReportResult = new PlaybackAndReportResult(
                mediaElement,
                new ReportResultDelegate(TestActionFinished),
                ActionParamConvertToString(strExpectedPlaybackErrorCode)
                );
            _playbackAndReportResult.RequestConfigData = requestConfigData;
            _playbackAndReportResult.FullPlayback(mediaElement, mediaName);

            TestLogger.LogMessage("Leave Test_PlayExpectLAFailure()");
        }
Esempio n. 3
0
        public void Test_LoadMedia(MediaElement mediaElement,
                                   string mediaName,
                                   string strLAURL,
                                   string strCustomData,
                                   string strDJURL,
                                   string strServiceId,
                                   string strAccountId,
                                   string useManualEnabling)
        {
            TestLogger.LogMessage("Enter Test_LoadMedia()");

            ServiceRequestConfigData requestConfigData = new ServiceRequestConfigData();

            requestConfigData.Uri = ActionParamConvertToUri(strLAURL);
            requestConfigData.ChallengeCustomData = ActionParamConvertToString(strCustomData);
            requestConfigData.DomainUri           = ActionParamConvertToUri(strDJURL);
            requestConfigData.DomainServiceId     = ActionParamConvertToGuid(strServiceId);
            requestConfigData.DomainAccountId     = ActionParamConvertToGuid(strAccountId);
            requestConfigData.ManualEnabling      = ActionParamConvertToBool(useManualEnabling);

            _playbackAndReportResult = new PlaybackAndReportResult(mediaElement, new ReportResultDelegate(TestActionFinished));
            _playbackAndReportResult.RequestConfigData = requestConfigData;
            _playbackAndReportResult.LoadMedia(mediaElement, mediaName, false);

            TestLogger.LogMessage("Leave Test_LoadMedia()");
        }
Esempio n. 4
0
        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()");
        }
Esempio n. 5
0
        public async void Test_ReportMeteringData(string strCertName,
                                                  string strLAUrl,
                                                  string strCustomData,
                                                  string strManualEnabling,
                                                  string strExpectError,
                                                  string strPlayCount)
        {
            TestLogger.LogMessage("Enter Test_ReportMeteringData()");

            bool bExpectError = ActionParamConvertToBool(strExpectError);
            uint?playCount    = ActionParamConvertToUint(strPlayCount);

            TestLogger.LogMessage("Reading metering cert...");

            if (strCertName == null)
            {
                throw new ArgumentException("certName is null");
            }

            Uri uriCertFile = new Uri("ms-appx:///PRFiles/" + strCertName);

            StorageFile certfile = await StorageFile.GetFileFromApplicationUriAsync(uriCertFile);

            if (certfile == null)
            {
                throw new Exception("MeteringCertFile can't be found");
            }


            IBuffer buffer = await FileIO.ReadBufferAsync(certfile);

            byte[] meteringCertBytes = new byte[buffer.Length];

            // Use a dataReader object to read from the buffer
            using (DataReader dataReader = DataReader.FromBuffer(buffer))
            {
                dataReader.ReadBytes(meteringCertBytes);
                // Perform additional tasks
            }

            ServiceRequestConfigData requestConfigData = new ServiceRequestConfigData();

            requestConfigData.ManualEnabling = ActionParamConvertToBool(strManualEnabling);

            _meteringAndReportResult = new MeteringAndReportResult(
                new ReportResultDelegate(TestActionFinished),
                bExpectError,
                playCount == null ? 0 : playCount.Value
                );
            _meteringAndReportResult.RequestConfigData = requestConfigData;
            _meteringAndReportResult.SetMeteringCertificate(meteringCertBytes);
            _meteringAndReportResult.MeteringReportProactively();

            TestLogger.LogMessage("Leave Test_ReportMeteringData()");
        }
Esempio n. 6
0
        public void Test_DomainLeave(string strAccountId,
                                     string strServiceId,
                                     string dlURL,
                                     string useManualEnabling)
        {
            TestLogger.LogMessage("Enter Test_DomainLeave()");

            ServiceRequestConfigData requestConfigData = new ServiceRequestConfigData();

            requestConfigData.DomainUri       = ActionParamConvertToUri(dlURL);
            requestConfigData.DomainServiceId = ActionParamConvertToGuid(strServiceId);
            requestConfigData.DomainAccountId = ActionParamConvertToGuid(strAccountId);
            requestConfigData.ManualEnabling  = ActionParamConvertToBool(useManualEnabling);

            _domainLeaveAndReportResult = new DomainLeaveAndReportResult(new ReportResultDelegate(TestActionFinished));
            _domainLeaveAndReportResult.RequestConfigData = requestConfigData;
            _domainLeaveAndReportResult.DomainLeaveProactively();

            TestLogger.LogMessage("Leave Test_DomainLeave()");
        }
        /// <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();
        }