Beispiel #1
0
        private void ParseYoutubeScheme(ContentProtection descriptor)
        {
            var doc = new XmlDocument();

            try
            {
                doc.LoadXml(descriptor.Data);
            }
            catch (Exception)
            {
                return;
            }

            if (doc.FirstChild?.ChildNodes == null)
            {
                return;
            }

            foreach (XmlNode node in doc.FirstChild?.ChildNodes)
            {
                var type = node.Attributes?.GetNamedItem("type")?.Value;
                if (!CencUtils.SupportsType(type))
                {
                    continue;
                }

                var drmDescriptor = new DRMDescription
                {
                    LicenceUrl = node.InnerText,
                    Scheme     = type
                };
                setDrmConfigurationSubject.OnNext(drmDescriptor);
            }
        }
Beispiel #2
0
        private void ParseCencScheme(ContentProtection descriptor, string schemeIdUri)
        {
            var doc = new XmlDocument();

            try
            {
                doc.LoadXml(descriptor.Data);
            }
            catch (Exception)
            {
                return;
            }

            // read first node inner text (should be psshbox or pro header)
            var initData = doc.FirstChild?.FirstChild?.InnerText;

            if (initData == null)
            {
                return;
            }

            var drmInitData = new DRMInitData
            {
                KeyIDs   = CencUtils.GetKeyIDs(descriptor.CencDefaultKID),
                DataType = CencUtils.GetInitDataType(doc.FirstChild?.FirstChild?.Name),
                InitData = Convert.FromBase64String(initData),
                SystemId = CencUtils.SchemeIdUriToSystemId(schemeIdUri),
                // Stream Type will be appended during OnDRMInitDataFound()
            };

            drmInitDataSubject.OnNext(drmInitData);
        }
Beispiel #3
0
 public JsonResult Create(string transformName, string jobName, string jobDescription, string jobPriority, string inputFileUrl,
                          string inputAssetName, StandardBlobTier inputAssetStorageTier, string streamingPolicyName, ContentProtection contentProtection)
 {
     try
     {
         Job    job       = null;
         string authToken = HomeController.GetAuthToken(Request, Response);
         using (MediaClient mediaClient = new MediaClient(authToken))
         {
             bool      videoAnalyzerPreset = false;
             bool      audioAnalyzerPreset = false;
             Transform transform           = mediaClient.GetEntity <Transform>(MediaEntity.Transform, transformName);
             foreach (TransformOutput transformOutput in transform.Outputs)
             {
                 if (transformOutput.Preset is VideoAnalyzerPreset)
                 {
                     videoAnalyzerPreset = true;
                 }
                 else if (transformOutput.Preset is AudioAnalyzerPreset)
                 {
                     audioAnalyzerPreset = true;
                 }
             }
             MediaJobOutputPublish outputAssetPublish = new MediaJobOutputPublish()
             {
                 InputAssetStorageTier = inputAssetStorageTier,
                 StreamingPolicyName   = streamingPolicyName,
                 ContentProtection     = contentProtection,
             };
             string insightId  = null;
             Asset  inputAsset = string.IsNullOrEmpty(inputAssetName) ? null : mediaClient.GetEntity <Asset>(MediaEntity.Asset, inputAssetName);
             if (mediaClient.IndexerEnabled() && (videoAnalyzerPreset || audioAnalyzerPreset))
             {
                 insightId = mediaClient.IndexerUploadVideo(inputFileUrl, inputAsset, jobPriority, videoAnalyzerPreset, audioAnalyzerPreset);
             }
             if (!string.IsNullOrEmpty(transformName))
             {
                 MediaJobOutputInsight outputInsight = new MediaJobOutputInsight()
                 {
                     Id           = insightId,
                     VideoIndexer = videoAnalyzerPreset,
                     AudioIndexer = audioAnalyzerPreset
                 };
                 job = mediaClient.CreateJob(transformName, jobName, jobDescription, jobPriority, inputFileUrl, inputAsset, null, outputAssetPublish, outputInsight, true);
             }
         }
         return(Json(job));
     }
     catch (ValidationException ex)
     {
         Error error = new Error()
         {
             Type    = HttpStatusCode.BadRequest,
             Message = ex.Message
         };
         return(new JsonResult(error)
         {
             StatusCode = (int)error.Type
         });
     }
     catch (ApiErrorException ex)
     {
         return(new JsonResult(ex.Response.Content)
         {
             StatusCode = (int)ex.Response.StatusCode
         });
     }
 }