Azure / Azure-Media-Services-Explorer

Azure Media Services Explorer Tool
Other
210 stars 86 forks source link

Fix WidevineTemplate value to serialize with snake case. #143

Closed m-otoguro closed 3 years ago

m-otoguro commented 3 years ago

See more info here: https://docs.microsoft.com/en-us/azure/media-services/latest/drm-widevine-license-template-concept

Purpose

This change concerns: (mark with an x)

- [ ] AMSE v4.x (for AMS v2) in 'AMSv2' branch
- [x ] AMSE v5.x (for AMS v3) in 'main' branch
- [ ] Other

Does this introduce a breaking change?

[ ] Yes
[x ] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ x] Bugfix
[ ] Feature
[ ] User Interface
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  1. Go to the page "DRM_WidevineLicence.cs" by publishing locator with Widevine.
  2. Select "Advanced license"
  3. You can see JSON with snake case instead of pascal case.
{
  "allowed_track_types": "SD_HD",
  "content_key_specs": [
    {
      "track_type": "SD",
      "security_level": 1,
      "required_output_protection": {
        "hdcp": "HDCP_NONE"
      }
    }
  ],
  "policy_overrides": {
    "can_play": true,
    "can_persist": true,
    "can_renew": false,
    "rental_duration_seconds": 2592000,
    "playback_duration_seconds": 10800,
    "license_duration_seconds": 604800
  }
}

If you want to check more, use Desktop Browser with Non-HDCP display like VGA. With the configuration No.1, HDCP_V1 restriction is not effective and you can play video with VGA connection in spite of HDCP_V1 restriction. However, If you set the configuration No.2, playback with VGA will be blocked. It means that the value of WidevineTemplate should be JSON string with snake case.

No. 1: Pascal Case

{
  "AllowedTrackTypes": "SD_HD",
  "ContentKeySpecs": [
    {
      "TrackType": "SD",
      "SecurityLevel": 1,
      "RequiredOutputProtection": {
        "HDCP": "HDCP_V1"
      }
    }
  ],
  "PolicyOverrides": {
    "CanPlay": true,
    "CanPersist": true,
    "CanRenew": false,
    "RentalDurationSeconds": 2592000,
    "PlaybackDurationSeconds": 10800,
    "LicenseDurationSeconds": 604800
  }
}

No. 2: Snake Case

{
  "allowed_track_types": "SD_HD",
  "content_key_specs": [
    {
      "track_type": "SD",
      "security_level": 1,
      "required_output_protection": {
        "hdcp": "HDCP_V1"
      }
    }
  ],
  "policy_overrides": {
    "can_play": true,
    "can_persist": true,
    "can_renew": false,
    "rental_duration_seconds": 2592000,
    "playback_duration_seconds": 10800,
    "license_duration_seconds": 604800
  }
}

What to Check

Verify that the following are valid

Other Information

xpouyat commented 3 years ago

Thanks for your contribution. Yuu are right, we need to use snake case (I discovered the same on another project). I will probably integrate your PR in the new .Net 5 code. Thanks !