{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MediaConvert.Types.DashIsoEncryptionSettings
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaConvert.Types.DashIsoEncryptionSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaConvert.Types.DashIsoPlaybackDeviceCompatibility
import Amazonka.MediaConvert.Types.SpekeKeyProvider
import qualified Amazonka.Prelude as Prelude

-- | Specifies DRM settings for DASH outputs.
--
-- /See:/ 'newDashIsoEncryptionSettings' smart constructor.
data DashIsoEncryptionSettings = DashIsoEncryptionSettings'
  { -- | This setting can improve the compatibility of your output with video
    -- players on obsolete devices. It applies only to DASH H.264 outputs with
    -- DRM encryption. Choose Unencrypted SEI (UNENCRYPTED_SEI) only to correct
    -- problems with playback on older devices. Otherwise, keep the default
    -- setting CENC v1 (CENC_V1). If you choose Unencrypted SEI, for that
    -- output, the service will exclude the access unit delimiter and will
    -- leave the SEI NAL units unencrypted.
    DashIsoEncryptionSettings
-> Maybe DashIsoPlaybackDeviceCompatibility
playbackDeviceCompatibility :: Prelude.Maybe DashIsoPlaybackDeviceCompatibility,
    -- | If your output group type is HLS, DASH, or Microsoft Smooth, use these
    -- settings when doing DRM encryption with a SPEKE-compliant key provider.
    -- If your output group type is CMAF, use the SpekeKeyProviderCmaf settings
    -- instead.
    DashIsoEncryptionSettings -> Maybe SpekeKeyProvider
spekeKeyProvider :: Prelude.Maybe SpekeKeyProvider
  }
  deriving (DashIsoEncryptionSettings -> DashIsoEncryptionSettings -> Bool
(DashIsoEncryptionSettings -> DashIsoEncryptionSettings -> Bool)
-> (DashIsoEncryptionSettings -> DashIsoEncryptionSettings -> Bool)
-> Eq DashIsoEncryptionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DashIsoEncryptionSettings -> DashIsoEncryptionSettings -> Bool
$c/= :: DashIsoEncryptionSettings -> DashIsoEncryptionSettings -> Bool
== :: DashIsoEncryptionSettings -> DashIsoEncryptionSettings -> Bool
$c== :: DashIsoEncryptionSettings -> DashIsoEncryptionSettings -> Bool
Prelude.Eq, ReadPrec [DashIsoEncryptionSettings]
ReadPrec DashIsoEncryptionSettings
Int -> ReadS DashIsoEncryptionSettings
ReadS [DashIsoEncryptionSettings]
(Int -> ReadS DashIsoEncryptionSettings)
-> ReadS [DashIsoEncryptionSettings]
-> ReadPrec DashIsoEncryptionSettings
-> ReadPrec [DashIsoEncryptionSettings]
-> Read DashIsoEncryptionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DashIsoEncryptionSettings]
$creadListPrec :: ReadPrec [DashIsoEncryptionSettings]
readPrec :: ReadPrec DashIsoEncryptionSettings
$creadPrec :: ReadPrec DashIsoEncryptionSettings
readList :: ReadS [DashIsoEncryptionSettings]
$creadList :: ReadS [DashIsoEncryptionSettings]
readsPrec :: Int -> ReadS DashIsoEncryptionSettings
$creadsPrec :: Int -> ReadS DashIsoEncryptionSettings
Prelude.Read, Int -> DashIsoEncryptionSettings -> ShowS
[DashIsoEncryptionSettings] -> ShowS
DashIsoEncryptionSettings -> String
(Int -> DashIsoEncryptionSettings -> ShowS)
-> (DashIsoEncryptionSettings -> String)
-> ([DashIsoEncryptionSettings] -> ShowS)
-> Show DashIsoEncryptionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DashIsoEncryptionSettings] -> ShowS
$cshowList :: [DashIsoEncryptionSettings] -> ShowS
show :: DashIsoEncryptionSettings -> String
$cshow :: DashIsoEncryptionSettings -> String
showsPrec :: Int -> DashIsoEncryptionSettings -> ShowS
$cshowsPrec :: Int -> DashIsoEncryptionSettings -> ShowS
Prelude.Show, (forall x.
 DashIsoEncryptionSettings -> Rep DashIsoEncryptionSettings x)
-> (forall x.
    Rep DashIsoEncryptionSettings x -> DashIsoEncryptionSettings)
-> Generic DashIsoEncryptionSettings
forall x.
Rep DashIsoEncryptionSettings x -> DashIsoEncryptionSettings
forall x.
DashIsoEncryptionSettings -> Rep DashIsoEncryptionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DashIsoEncryptionSettings x -> DashIsoEncryptionSettings
$cfrom :: forall x.
DashIsoEncryptionSettings -> Rep DashIsoEncryptionSettings x
Prelude.Generic)

-- |
-- Create a value of 'DashIsoEncryptionSettings' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'playbackDeviceCompatibility', 'dashIsoEncryptionSettings_playbackDeviceCompatibility' - This setting can improve the compatibility of your output with video
-- players on obsolete devices. It applies only to DASH H.264 outputs with
-- DRM encryption. Choose Unencrypted SEI (UNENCRYPTED_SEI) only to correct
-- problems with playback on older devices. Otherwise, keep the default
-- setting CENC v1 (CENC_V1). If you choose Unencrypted SEI, for that
-- output, the service will exclude the access unit delimiter and will
-- leave the SEI NAL units unencrypted.
--
-- 'spekeKeyProvider', 'dashIsoEncryptionSettings_spekeKeyProvider' - If your output group type is HLS, DASH, or Microsoft Smooth, use these
-- settings when doing DRM encryption with a SPEKE-compliant key provider.
-- If your output group type is CMAF, use the SpekeKeyProviderCmaf settings
-- instead.
newDashIsoEncryptionSettings ::
  DashIsoEncryptionSettings
newDashIsoEncryptionSettings :: DashIsoEncryptionSettings
newDashIsoEncryptionSettings =
  DashIsoEncryptionSettings' :: Maybe DashIsoPlaybackDeviceCompatibility
-> Maybe SpekeKeyProvider -> DashIsoEncryptionSettings
DashIsoEncryptionSettings'
    { $sel:playbackDeviceCompatibility:DashIsoEncryptionSettings' :: Maybe DashIsoPlaybackDeviceCompatibility
playbackDeviceCompatibility =
        Maybe DashIsoPlaybackDeviceCompatibility
forall a. Maybe a
Prelude.Nothing,
      $sel:spekeKeyProvider:DashIsoEncryptionSettings' :: Maybe SpekeKeyProvider
spekeKeyProvider = Maybe SpekeKeyProvider
forall a. Maybe a
Prelude.Nothing
    }

-- | This setting can improve the compatibility of your output with video
-- players on obsolete devices. It applies only to DASH H.264 outputs with
-- DRM encryption. Choose Unencrypted SEI (UNENCRYPTED_SEI) only to correct
-- problems with playback on older devices. Otherwise, keep the default
-- setting CENC v1 (CENC_V1). If you choose Unencrypted SEI, for that
-- output, the service will exclude the access unit delimiter and will
-- leave the SEI NAL units unencrypted.
dashIsoEncryptionSettings_playbackDeviceCompatibility :: Lens.Lens' DashIsoEncryptionSettings (Prelude.Maybe DashIsoPlaybackDeviceCompatibility)
dashIsoEncryptionSettings_playbackDeviceCompatibility :: (Maybe DashIsoPlaybackDeviceCompatibility
 -> f (Maybe DashIsoPlaybackDeviceCompatibility))
-> DashIsoEncryptionSettings -> f DashIsoEncryptionSettings
dashIsoEncryptionSettings_playbackDeviceCompatibility = (DashIsoEncryptionSettings
 -> Maybe DashIsoPlaybackDeviceCompatibility)
-> (DashIsoEncryptionSettings
    -> Maybe DashIsoPlaybackDeviceCompatibility
    -> DashIsoEncryptionSettings)
-> Lens
     DashIsoEncryptionSettings
     DashIsoEncryptionSettings
     (Maybe DashIsoPlaybackDeviceCompatibility)
     (Maybe DashIsoPlaybackDeviceCompatibility)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DashIsoEncryptionSettings' {Maybe DashIsoPlaybackDeviceCompatibility
playbackDeviceCompatibility :: Maybe DashIsoPlaybackDeviceCompatibility
$sel:playbackDeviceCompatibility:DashIsoEncryptionSettings' :: DashIsoEncryptionSettings
-> Maybe DashIsoPlaybackDeviceCompatibility
playbackDeviceCompatibility} -> Maybe DashIsoPlaybackDeviceCompatibility
playbackDeviceCompatibility) (\s :: DashIsoEncryptionSettings
s@DashIsoEncryptionSettings' {} Maybe DashIsoPlaybackDeviceCompatibility
a -> DashIsoEncryptionSettings
s {$sel:playbackDeviceCompatibility:DashIsoEncryptionSettings' :: Maybe DashIsoPlaybackDeviceCompatibility
playbackDeviceCompatibility = Maybe DashIsoPlaybackDeviceCompatibility
a} :: DashIsoEncryptionSettings)

-- | If your output group type is HLS, DASH, or Microsoft Smooth, use these
-- settings when doing DRM encryption with a SPEKE-compliant key provider.
-- If your output group type is CMAF, use the SpekeKeyProviderCmaf settings
-- instead.
dashIsoEncryptionSettings_spekeKeyProvider :: Lens.Lens' DashIsoEncryptionSettings (Prelude.Maybe SpekeKeyProvider)
dashIsoEncryptionSettings_spekeKeyProvider :: (Maybe SpekeKeyProvider -> f (Maybe SpekeKeyProvider))
-> DashIsoEncryptionSettings -> f DashIsoEncryptionSettings
dashIsoEncryptionSettings_spekeKeyProvider = (DashIsoEncryptionSettings -> Maybe SpekeKeyProvider)
-> (DashIsoEncryptionSettings
    -> Maybe SpekeKeyProvider -> DashIsoEncryptionSettings)
-> Lens
     DashIsoEncryptionSettings
     DashIsoEncryptionSettings
     (Maybe SpekeKeyProvider)
     (Maybe SpekeKeyProvider)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DashIsoEncryptionSettings' {Maybe SpekeKeyProvider
spekeKeyProvider :: Maybe SpekeKeyProvider
$sel:spekeKeyProvider:DashIsoEncryptionSettings' :: DashIsoEncryptionSettings -> Maybe SpekeKeyProvider
spekeKeyProvider} -> Maybe SpekeKeyProvider
spekeKeyProvider) (\s :: DashIsoEncryptionSettings
s@DashIsoEncryptionSettings' {} Maybe SpekeKeyProvider
a -> DashIsoEncryptionSettings
s {$sel:spekeKeyProvider:DashIsoEncryptionSettings' :: Maybe SpekeKeyProvider
spekeKeyProvider = Maybe SpekeKeyProvider
a} :: DashIsoEncryptionSettings)

instance Core.FromJSON DashIsoEncryptionSettings where
  parseJSON :: Value -> Parser DashIsoEncryptionSettings
parseJSON =
    String
-> (Object -> Parser DashIsoEncryptionSettings)
-> Value
-> Parser DashIsoEncryptionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DashIsoEncryptionSettings"
      ( \Object
x ->
          Maybe DashIsoPlaybackDeviceCompatibility
-> Maybe SpekeKeyProvider -> DashIsoEncryptionSettings
DashIsoEncryptionSettings'
            (Maybe DashIsoPlaybackDeviceCompatibility
 -> Maybe SpekeKeyProvider -> DashIsoEncryptionSettings)
-> Parser (Maybe DashIsoPlaybackDeviceCompatibility)
-> Parser (Maybe SpekeKeyProvider -> DashIsoEncryptionSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DashIsoPlaybackDeviceCompatibility)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"playbackDeviceCompatibility")
            Parser (Maybe SpekeKeyProvider -> DashIsoEncryptionSettings)
-> Parser (Maybe SpekeKeyProvider)
-> Parser DashIsoEncryptionSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SpekeKeyProvider)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"spekeKeyProvider")
      )

instance Prelude.Hashable DashIsoEncryptionSettings

instance Prelude.NFData DashIsoEncryptionSettings

instance Core.ToJSON DashIsoEncryptionSettings where
  toJSON :: DashIsoEncryptionSettings -> Value
toJSON DashIsoEncryptionSettings' {Maybe DashIsoPlaybackDeviceCompatibility
Maybe SpekeKeyProvider
spekeKeyProvider :: Maybe SpekeKeyProvider
playbackDeviceCompatibility :: Maybe DashIsoPlaybackDeviceCompatibility
$sel:spekeKeyProvider:DashIsoEncryptionSettings' :: DashIsoEncryptionSettings -> Maybe SpekeKeyProvider
$sel:playbackDeviceCompatibility:DashIsoEncryptionSettings' :: DashIsoEncryptionSettings
-> Maybe DashIsoPlaybackDeviceCompatibility
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"playbackDeviceCompatibility" Text -> DashIsoPlaybackDeviceCompatibility -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DashIsoPlaybackDeviceCompatibility -> Pair)
-> Maybe DashIsoPlaybackDeviceCompatibility -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DashIsoPlaybackDeviceCompatibility
playbackDeviceCompatibility,
            (Text
"spekeKeyProvider" Text -> SpekeKeyProvider -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SpekeKeyProvider -> Pair) -> Maybe SpekeKeyProvider -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SpekeKeyProvider
spekeKeyProvider
          ]
      )