{-# 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.MediaPackageVOD.Types.HlsPackage
-- 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.MediaPackageVOD.Types.HlsPackage where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaPackageVOD.Types.HlsEncryption
import Amazonka.MediaPackageVOD.Types.HlsManifest
import qualified Amazonka.Prelude as Prelude

-- | An HTTP Live Streaming (HLS) packaging configuration.
--
-- /See:/ 'newHlsPackage' smart constructor.
data HlsPackage = HlsPackage'
  { -- | When enabled, audio streams will be placed in rendition groups in the
    -- output.
    HlsPackage -> Maybe Bool
useAudioRenditionGroup :: Prelude.Maybe Prelude.Bool,
    -- | When enabled, MediaPackage passes through digital video broadcasting
    -- (DVB) subtitles into the output.
    HlsPackage -> Maybe Bool
includeDvbSubtitles :: Prelude.Maybe Prelude.Bool,
    -- | Duration (in seconds) of each fragment. Actual fragments will be rounded
    -- to the nearest multiple of the source fragment duration.
    HlsPackage -> Maybe Int
segmentDurationSeconds :: Prelude.Maybe Prelude.Int,
    HlsPackage -> Maybe HlsEncryption
encryption :: Prelude.Maybe HlsEncryption,
    -- | A list of HLS manifest configurations.
    HlsPackage -> [HlsManifest]
hlsManifests :: [HlsManifest]
  }
  deriving (HlsPackage -> HlsPackage -> Bool
(HlsPackage -> HlsPackage -> Bool)
-> (HlsPackage -> HlsPackage -> Bool) -> Eq HlsPackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HlsPackage -> HlsPackage -> Bool
$c/= :: HlsPackage -> HlsPackage -> Bool
== :: HlsPackage -> HlsPackage -> Bool
$c== :: HlsPackage -> HlsPackage -> Bool
Prelude.Eq, ReadPrec [HlsPackage]
ReadPrec HlsPackage
Int -> ReadS HlsPackage
ReadS [HlsPackage]
(Int -> ReadS HlsPackage)
-> ReadS [HlsPackage]
-> ReadPrec HlsPackage
-> ReadPrec [HlsPackage]
-> Read HlsPackage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HlsPackage]
$creadListPrec :: ReadPrec [HlsPackage]
readPrec :: ReadPrec HlsPackage
$creadPrec :: ReadPrec HlsPackage
readList :: ReadS [HlsPackage]
$creadList :: ReadS [HlsPackage]
readsPrec :: Int -> ReadS HlsPackage
$creadsPrec :: Int -> ReadS HlsPackage
Prelude.Read, Int -> HlsPackage -> ShowS
[HlsPackage] -> ShowS
HlsPackage -> String
(Int -> HlsPackage -> ShowS)
-> (HlsPackage -> String)
-> ([HlsPackage] -> ShowS)
-> Show HlsPackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HlsPackage] -> ShowS
$cshowList :: [HlsPackage] -> ShowS
show :: HlsPackage -> String
$cshow :: HlsPackage -> String
showsPrec :: Int -> HlsPackage -> ShowS
$cshowsPrec :: Int -> HlsPackage -> ShowS
Prelude.Show, (forall x. HlsPackage -> Rep HlsPackage x)
-> (forall x. Rep HlsPackage x -> HlsPackage) -> Generic HlsPackage
forall x. Rep HlsPackage x -> HlsPackage
forall x. HlsPackage -> Rep HlsPackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HlsPackage x -> HlsPackage
$cfrom :: forall x. HlsPackage -> Rep HlsPackage x
Prelude.Generic)

-- |
-- Create a value of 'HlsPackage' 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:
--
-- 'useAudioRenditionGroup', 'hlsPackage_useAudioRenditionGroup' - When enabled, audio streams will be placed in rendition groups in the
-- output.
--
-- 'includeDvbSubtitles', 'hlsPackage_includeDvbSubtitles' - When enabled, MediaPackage passes through digital video broadcasting
-- (DVB) subtitles into the output.
--
-- 'segmentDurationSeconds', 'hlsPackage_segmentDurationSeconds' - Duration (in seconds) of each fragment. Actual fragments will be rounded
-- to the nearest multiple of the source fragment duration.
--
-- 'encryption', 'hlsPackage_encryption' - Undocumented member.
--
-- 'hlsManifests', 'hlsPackage_hlsManifests' - A list of HLS manifest configurations.
newHlsPackage ::
  HlsPackage
newHlsPackage :: HlsPackage
newHlsPackage =
  HlsPackage' :: Maybe Bool
-> Maybe Bool
-> Maybe Int
-> Maybe HlsEncryption
-> [HlsManifest]
-> HlsPackage
HlsPackage'
    { $sel:useAudioRenditionGroup:HlsPackage' :: Maybe Bool
useAudioRenditionGroup =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:includeDvbSubtitles:HlsPackage' :: Maybe Bool
includeDvbSubtitles = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:segmentDurationSeconds:HlsPackage' :: Maybe Int
segmentDurationSeconds = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:HlsPackage' :: Maybe HlsEncryption
encryption = Maybe HlsEncryption
forall a. Maybe a
Prelude.Nothing,
      $sel:hlsManifests:HlsPackage' :: [HlsManifest]
hlsManifests = [HlsManifest]
forall a. Monoid a => a
Prelude.mempty
    }

-- | When enabled, audio streams will be placed in rendition groups in the
-- output.
hlsPackage_useAudioRenditionGroup :: Lens.Lens' HlsPackage (Prelude.Maybe Prelude.Bool)
hlsPackage_useAudioRenditionGroup :: (Maybe Bool -> f (Maybe Bool)) -> HlsPackage -> f HlsPackage
hlsPackage_useAudioRenditionGroup = (HlsPackage -> Maybe Bool)
-> (HlsPackage -> Maybe Bool -> HlsPackage)
-> Lens HlsPackage HlsPackage (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsPackage' {Maybe Bool
useAudioRenditionGroup :: Maybe Bool
$sel:useAudioRenditionGroup:HlsPackage' :: HlsPackage -> Maybe Bool
useAudioRenditionGroup} -> Maybe Bool
useAudioRenditionGroup) (\s :: HlsPackage
s@HlsPackage' {} Maybe Bool
a -> HlsPackage
s {$sel:useAudioRenditionGroup:HlsPackage' :: Maybe Bool
useAudioRenditionGroup = Maybe Bool
a} :: HlsPackage)

-- | When enabled, MediaPackage passes through digital video broadcasting
-- (DVB) subtitles into the output.
hlsPackage_includeDvbSubtitles :: Lens.Lens' HlsPackage (Prelude.Maybe Prelude.Bool)
hlsPackage_includeDvbSubtitles :: (Maybe Bool -> f (Maybe Bool)) -> HlsPackage -> f HlsPackage
hlsPackage_includeDvbSubtitles = (HlsPackage -> Maybe Bool)
-> (HlsPackage -> Maybe Bool -> HlsPackage)
-> Lens HlsPackage HlsPackage (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsPackage' {Maybe Bool
includeDvbSubtitles :: Maybe Bool
$sel:includeDvbSubtitles:HlsPackage' :: HlsPackage -> Maybe Bool
includeDvbSubtitles} -> Maybe Bool
includeDvbSubtitles) (\s :: HlsPackage
s@HlsPackage' {} Maybe Bool
a -> HlsPackage
s {$sel:includeDvbSubtitles:HlsPackage' :: Maybe Bool
includeDvbSubtitles = Maybe Bool
a} :: HlsPackage)

-- | Duration (in seconds) of each fragment. Actual fragments will be rounded
-- to the nearest multiple of the source fragment duration.
hlsPackage_segmentDurationSeconds :: Lens.Lens' HlsPackage (Prelude.Maybe Prelude.Int)
hlsPackage_segmentDurationSeconds :: (Maybe Int -> f (Maybe Int)) -> HlsPackage -> f HlsPackage
hlsPackage_segmentDurationSeconds = (HlsPackage -> Maybe Int)
-> (HlsPackage -> Maybe Int -> HlsPackage)
-> Lens HlsPackage HlsPackage (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsPackage' {Maybe Int
segmentDurationSeconds :: Maybe Int
$sel:segmentDurationSeconds:HlsPackage' :: HlsPackage -> Maybe Int
segmentDurationSeconds} -> Maybe Int
segmentDurationSeconds) (\s :: HlsPackage
s@HlsPackage' {} Maybe Int
a -> HlsPackage
s {$sel:segmentDurationSeconds:HlsPackage' :: Maybe Int
segmentDurationSeconds = Maybe Int
a} :: HlsPackage)

-- | Undocumented member.
hlsPackage_encryption :: Lens.Lens' HlsPackage (Prelude.Maybe HlsEncryption)
hlsPackage_encryption :: (Maybe HlsEncryption -> f (Maybe HlsEncryption))
-> HlsPackage -> f HlsPackage
hlsPackage_encryption = (HlsPackage -> Maybe HlsEncryption)
-> (HlsPackage -> Maybe HlsEncryption -> HlsPackage)
-> Lens
     HlsPackage HlsPackage (Maybe HlsEncryption) (Maybe HlsEncryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsPackage' {Maybe HlsEncryption
encryption :: Maybe HlsEncryption
$sel:encryption:HlsPackage' :: HlsPackage -> Maybe HlsEncryption
encryption} -> Maybe HlsEncryption
encryption) (\s :: HlsPackage
s@HlsPackage' {} Maybe HlsEncryption
a -> HlsPackage
s {$sel:encryption:HlsPackage' :: Maybe HlsEncryption
encryption = Maybe HlsEncryption
a} :: HlsPackage)

-- | A list of HLS manifest configurations.
hlsPackage_hlsManifests :: Lens.Lens' HlsPackage [HlsManifest]
hlsPackage_hlsManifests :: ([HlsManifest] -> f [HlsManifest]) -> HlsPackage -> f HlsPackage
hlsPackage_hlsManifests = (HlsPackage -> [HlsManifest])
-> (HlsPackage -> [HlsManifest] -> HlsPackage)
-> Lens HlsPackage HlsPackage [HlsManifest] [HlsManifest]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsPackage' {[HlsManifest]
hlsManifests :: [HlsManifest]
$sel:hlsManifests:HlsPackage' :: HlsPackage -> [HlsManifest]
hlsManifests} -> [HlsManifest]
hlsManifests) (\s :: HlsPackage
s@HlsPackage' {} [HlsManifest]
a -> HlsPackage
s {$sel:hlsManifests:HlsPackage' :: [HlsManifest]
hlsManifests = [HlsManifest]
a} :: HlsPackage) (([HlsManifest] -> f [HlsManifest]) -> HlsPackage -> f HlsPackage)
-> (([HlsManifest] -> f [HlsManifest])
    -> [HlsManifest] -> f [HlsManifest])
-> ([HlsManifest] -> f [HlsManifest])
-> HlsPackage
-> f HlsPackage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([HlsManifest] -> f [HlsManifest])
-> [HlsManifest] -> f [HlsManifest]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON HlsPackage where
  parseJSON :: Value -> Parser HlsPackage
parseJSON =
    String
-> (Object -> Parser HlsPackage) -> Value -> Parser HlsPackage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HlsPackage"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> Maybe Int
-> Maybe HlsEncryption
-> [HlsManifest]
-> HlsPackage
HlsPackage'
            (Maybe Bool
 -> Maybe Bool
 -> Maybe Int
 -> Maybe HlsEncryption
 -> [HlsManifest]
 -> HlsPackage)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Int -> Maybe HlsEncryption -> [HlsManifest] -> HlsPackage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"useAudioRenditionGroup")
            Parser
  (Maybe Bool
   -> Maybe Int -> Maybe HlsEncryption -> [HlsManifest] -> HlsPackage)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Int -> Maybe HlsEncryption -> [HlsManifest] -> HlsPackage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"includeDvbSubtitles")
            Parser
  (Maybe Int -> Maybe HlsEncryption -> [HlsManifest] -> HlsPackage)
-> Parser (Maybe Int)
-> Parser (Maybe HlsEncryption -> [HlsManifest] -> HlsPackage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"segmentDurationSeconds")
            Parser (Maybe HlsEncryption -> [HlsManifest] -> HlsPackage)
-> Parser (Maybe HlsEncryption)
-> Parser ([HlsManifest] -> HlsPackage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HlsEncryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryption")
            Parser ([HlsManifest] -> HlsPackage)
-> Parser [HlsManifest] -> Parser HlsPackage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [HlsManifest])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hlsManifests" Parser (Maybe [HlsManifest])
-> [HlsManifest] -> Parser [HlsManifest]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [HlsManifest]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable HlsPackage

instance Prelude.NFData HlsPackage

instance Core.ToJSON HlsPackage where
  toJSON :: HlsPackage -> Value
toJSON HlsPackage' {[HlsManifest]
Maybe Bool
Maybe Int
Maybe HlsEncryption
hlsManifests :: [HlsManifest]
encryption :: Maybe HlsEncryption
segmentDurationSeconds :: Maybe Int
includeDvbSubtitles :: Maybe Bool
useAudioRenditionGroup :: Maybe Bool
$sel:hlsManifests:HlsPackage' :: HlsPackage -> [HlsManifest]
$sel:encryption:HlsPackage' :: HlsPackage -> Maybe HlsEncryption
$sel:segmentDurationSeconds:HlsPackage' :: HlsPackage -> Maybe Int
$sel:includeDvbSubtitles:HlsPackage' :: HlsPackage -> Maybe Bool
$sel:useAudioRenditionGroup:HlsPackage' :: HlsPackage -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"useAudioRenditionGroup" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
useAudioRenditionGroup,
            (Text
"includeDvbSubtitles" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeDvbSubtitles,
            (Text
"segmentDurationSeconds" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
segmentDurationSeconds,
            (Text
"encryption" Text -> HlsEncryption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HlsEncryption -> Pair) -> Maybe HlsEncryption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HlsEncryption
encryption,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"hlsManifests" Text -> [HlsManifest] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [HlsManifest]
hlsManifests)
          ]
      )