ron94
ron94

Reputation: 51

Azure media service custom Streaming Policy

I'm trying to build a custom streaming policy based on https://learn.microsoft.com/en-us/azure/media-services/latest/drm-offline-fairplay-for-ios-concept#enable-offline-mode

private static async Task<StreamingLocator> CreateStreamingLocatorAsync(
        IAzureMediaServicesClient client,
        string resourceGroup,
        string accountName,
        string assetName,
        string locatorName,
        string contentPolicyName)
    {
        CommonEncryptionCbcs objStreamingPolicyInput = new CommonEncryptionCbcs()
        {
            Drm = new CbcsDrmConfiguration()
            {
                FairPlay = new StreamingPolicyFairPlayConfiguration()
                {
                    AllowPersistentLicense = true // This enables offline mode
                }
            },
            EnabledProtocols = new EnabledProtocols()
            {
                Hls = true,
                Dash = true // Even though DASH under CBCS is not supported for either CSF or CMAF, HLS-CMAF-CBCS uses DASH-CBCS fragments in its HLS playlist
            },

            ContentKeys = new StreamingPolicyContentKeys()
            {
                // Default key must be specified if keyToTrackMappings is present
                DefaultKey = new DefaultKey()
                {
                    Label = "CBCS_DefaultKeyLabel"
                }
            }
        };

        // If you also added FairPlay, use "Predefined_MultiDrmStreaming
        StreamingLocator locator = await client.StreamingLocators.CreateAsync(
            resourceGroup,
            accountName,
            locatorName,
            new StreamingLocator
            {
                AssetName = assetName,
                // "Predefined_MultiDrmCencStreaming" policy supports envelope and cenc encryption
                // And sets two content keys on the StreamingLocator
                StreamingPolicyName = nameof(objStreamingPolicyInput),
                DefaultContentKeyPolicyName = contentPolicyName
            });

        return locator;
    }

Based on my understanding I should create the "objStreamingPolicyInput" then replace the "StreamingPolicyName" when creating the streaming locator, but then seems like not working. Anyhelp please?

Error:

Operation returned an invalid status code 'BadRequest'
ERROR: API call failed with error code 'BadRequest' and message 'Streaming Policy is not found: objStreamingPolicyInput'

Upvotes: 0

Views: 117

Answers (0)

Related Questions