{-# 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.MediaLive.Types.HlsInputSettings
-- 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.MediaLive.Types.HlsInputSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.HlsScte35SourceType
import qualified Amazonka.Prelude as Prelude

-- | Hls Input Settings
--
-- /See:/ 'newHlsInputSettings' smart constructor.
data HlsInputSettings = HlsInputSettings'
  { -- | When specified, reading of the HLS input will begin this many buffer
    -- segments from the end (most recently written segment). When not
    -- specified, the HLS input will begin with the first segment specified in
    -- the m3u8.
    HlsInputSettings -> Maybe Natural
bufferSegments :: Prelude.Maybe Prelude.Natural,
    -- | The number of consecutive times that attempts to read a manifest or
    -- segment must fail before the input is considered unavailable.
    HlsInputSettings -> Maybe Natural
retries :: Prelude.Maybe Prelude.Natural,
    -- | The number of seconds between retries when an attempt to read a manifest
    -- or segment fails.
    HlsInputSettings -> Maybe Natural
retryInterval :: Prelude.Maybe Prelude.Natural,
    -- | When specified the HLS stream with the m3u8 BANDWIDTH that most closely
    -- matches this value will be chosen, otherwise the highest bandwidth
    -- stream in the m3u8 will be chosen. The bitrate is specified in bits per
    -- second, as in an HLS manifest.
    HlsInputSettings -> Maybe Natural
bandwidth :: Prelude.Maybe Prelude.Natural,
    -- | Identifies the source for the SCTE-35 messages that MediaLive will
    -- ingest. Messages can be ingested from the content segments (in the
    -- stream) or from tags in the playlist (the HLS manifest). MediaLive
    -- ignores SCTE-35 information in the source that is not selected.
    HlsInputSettings -> Maybe HlsScte35SourceType
scte35Source :: Prelude.Maybe HlsScte35SourceType
  }
  deriving (HlsInputSettings -> HlsInputSettings -> Bool
(HlsInputSettings -> HlsInputSettings -> Bool)
-> (HlsInputSettings -> HlsInputSettings -> Bool)
-> Eq HlsInputSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HlsInputSettings -> HlsInputSettings -> Bool
$c/= :: HlsInputSettings -> HlsInputSettings -> Bool
== :: HlsInputSettings -> HlsInputSettings -> Bool
$c== :: HlsInputSettings -> HlsInputSettings -> Bool
Prelude.Eq, ReadPrec [HlsInputSettings]
ReadPrec HlsInputSettings
Int -> ReadS HlsInputSettings
ReadS [HlsInputSettings]
(Int -> ReadS HlsInputSettings)
-> ReadS [HlsInputSettings]
-> ReadPrec HlsInputSettings
-> ReadPrec [HlsInputSettings]
-> Read HlsInputSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HlsInputSettings]
$creadListPrec :: ReadPrec [HlsInputSettings]
readPrec :: ReadPrec HlsInputSettings
$creadPrec :: ReadPrec HlsInputSettings
readList :: ReadS [HlsInputSettings]
$creadList :: ReadS [HlsInputSettings]
readsPrec :: Int -> ReadS HlsInputSettings
$creadsPrec :: Int -> ReadS HlsInputSettings
Prelude.Read, Int -> HlsInputSettings -> ShowS
[HlsInputSettings] -> ShowS
HlsInputSettings -> String
(Int -> HlsInputSettings -> ShowS)
-> (HlsInputSettings -> String)
-> ([HlsInputSettings] -> ShowS)
-> Show HlsInputSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HlsInputSettings] -> ShowS
$cshowList :: [HlsInputSettings] -> ShowS
show :: HlsInputSettings -> String
$cshow :: HlsInputSettings -> String
showsPrec :: Int -> HlsInputSettings -> ShowS
$cshowsPrec :: Int -> HlsInputSettings -> ShowS
Prelude.Show, (forall x. HlsInputSettings -> Rep HlsInputSettings x)
-> (forall x. Rep HlsInputSettings x -> HlsInputSettings)
-> Generic HlsInputSettings
forall x. Rep HlsInputSettings x -> HlsInputSettings
forall x. HlsInputSettings -> Rep HlsInputSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HlsInputSettings x -> HlsInputSettings
$cfrom :: forall x. HlsInputSettings -> Rep HlsInputSettings x
Prelude.Generic)

-- |
-- Create a value of 'HlsInputSettings' 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:
--
-- 'bufferSegments', 'hlsInputSettings_bufferSegments' - When specified, reading of the HLS input will begin this many buffer
-- segments from the end (most recently written segment). When not
-- specified, the HLS input will begin with the first segment specified in
-- the m3u8.
--
-- 'retries', 'hlsInputSettings_retries' - The number of consecutive times that attempts to read a manifest or
-- segment must fail before the input is considered unavailable.
--
-- 'retryInterval', 'hlsInputSettings_retryInterval' - The number of seconds between retries when an attempt to read a manifest
-- or segment fails.
--
-- 'bandwidth', 'hlsInputSettings_bandwidth' - When specified the HLS stream with the m3u8 BANDWIDTH that most closely
-- matches this value will be chosen, otherwise the highest bandwidth
-- stream in the m3u8 will be chosen. The bitrate is specified in bits per
-- second, as in an HLS manifest.
--
-- 'scte35Source', 'hlsInputSettings_scte35Source' - Identifies the source for the SCTE-35 messages that MediaLive will
-- ingest. Messages can be ingested from the content segments (in the
-- stream) or from tags in the playlist (the HLS manifest). MediaLive
-- ignores SCTE-35 information in the source that is not selected.
newHlsInputSettings ::
  HlsInputSettings
newHlsInputSettings :: HlsInputSettings
newHlsInputSettings =
  HlsInputSettings' :: Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe HlsScte35SourceType
-> HlsInputSettings
HlsInputSettings'
    { $sel:bufferSegments:HlsInputSettings' :: Maybe Natural
bufferSegments = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:retries:HlsInputSettings' :: Maybe Natural
retries = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:retryInterval:HlsInputSettings' :: Maybe Natural
retryInterval = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:bandwidth:HlsInputSettings' :: Maybe Natural
bandwidth = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:scte35Source:HlsInputSettings' :: Maybe HlsScte35SourceType
scte35Source = Maybe HlsScte35SourceType
forall a. Maybe a
Prelude.Nothing
    }

-- | When specified, reading of the HLS input will begin this many buffer
-- segments from the end (most recently written segment). When not
-- specified, the HLS input will begin with the first segment specified in
-- the m3u8.
hlsInputSettings_bufferSegments :: Lens.Lens' HlsInputSettings (Prelude.Maybe Prelude.Natural)
hlsInputSettings_bufferSegments :: (Maybe Natural -> f (Maybe Natural))
-> HlsInputSettings -> f HlsInputSettings
hlsInputSettings_bufferSegments = (HlsInputSettings -> Maybe Natural)
-> (HlsInputSettings -> Maybe Natural -> HlsInputSettings)
-> Lens
     HlsInputSettings HlsInputSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsInputSettings' {Maybe Natural
bufferSegments :: Maybe Natural
$sel:bufferSegments:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
bufferSegments} -> Maybe Natural
bufferSegments) (\s :: HlsInputSettings
s@HlsInputSettings' {} Maybe Natural
a -> HlsInputSettings
s {$sel:bufferSegments:HlsInputSettings' :: Maybe Natural
bufferSegments = Maybe Natural
a} :: HlsInputSettings)

-- | The number of consecutive times that attempts to read a manifest or
-- segment must fail before the input is considered unavailable.
hlsInputSettings_retries :: Lens.Lens' HlsInputSettings (Prelude.Maybe Prelude.Natural)
hlsInputSettings_retries :: (Maybe Natural -> f (Maybe Natural))
-> HlsInputSettings -> f HlsInputSettings
hlsInputSettings_retries = (HlsInputSettings -> Maybe Natural)
-> (HlsInputSettings -> Maybe Natural -> HlsInputSettings)
-> Lens
     HlsInputSettings HlsInputSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsInputSettings' {Maybe Natural
retries :: Maybe Natural
$sel:retries:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
retries} -> Maybe Natural
retries) (\s :: HlsInputSettings
s@HlsInputSettings' {} Maybe Natural
a -> HlsInputSettings
s {$sel:retries:HlsInputSettings' :: Maybe Natural
retries = Maybe Natural
a} :: HlsInputSettings)

-- | The number of seconds between retries when an attempt to read a manifest
-- or segment fails.
hlsInputSettings_retryInterval :: Lens.Lens' HlsInputSettings (Prelude.Maybe Prelude.Natural)
hlsInputSettings_retryInterval :: (Maybe Natural -> f (Maybe Natural))
-> HlsInputSettings -> f HlsInputSettings
hlsInputSettings_retryInterval = (HlsInputSettings -> Maybe Natural)
-> (HlsInputSettings -> Maybe Natural -> HlsInputSettings)
-> Lens
     HlsInputSettings HlsInputSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsInputSettings' {Maybe Natural
retryInterval :: Maybe Natural
$sel:retryInterval:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
retryInterval} -> Maybe Natural
retryInterval) (\s :: HlsInputSettings
s@HlsInputSettings' {} Maybe Natural
a -> HlsInputSettings
s {$sel:retryInterval:HlsInputSettings' :: Maybe Natural
retryInterval = Maybe Natural
a} :: HlsInputSettings)

-- | When specified the HLS stream with the m3u8 BANDWIDTH that most closely
-- matches this value will be chosen, otherwise the highest bandwidth
-- stream in the m3u8 will be chosen. The bitrate is specified in bits per
-- second, as in an HLS manifest.
hlsInputSettings_bandwidth :: Lens.Lens' HlsInputSettings (Prelude.Maybe Prelude.Natural)
hlsInputSettings_bandwidth :: (Maybe Natural -> f (Maybe Natural))
-> HlsInputSettings -> f HlsInputSettings
hlsInputSettings_bandwidth = (HlsInputSettings -> Maybe Natural)
-> (HlsInputSettings -> Maybe Natural -> HlsInputSettings)
-> Lens
     HlsInputSettings HlsInputSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsInputSettings' {Maybe Natural
bandwidth :: Maybe Natural
$sel:bandwidth:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
bandwidth} -> Maybe Natural
bandwidth) (\s :: HlsInputSettings
s@HlsInputSettings' {} Maybe Natural
a -> HlsInputSettings
s {$sel:bandwidth:HlsInputSettings' :: Maybe Natural
bandwidth = Maybe Natural
a} :: HlsInputSettings)

-- | Identifies the source for the SCTE-35 messages that MediaLive will
-- ingest. Messages can be ingested from the content segments (in the
-- stream) or from tags in the playlist (the HLS manifest). MediaLive
-- ignores SCTE-35 information in the source that is not selected.
hlsInputSettings_scte35Source :: Lens.Lens' HlsInputSettings (Prelude.Maybe HlsScte35SourceType)
hlsInputSettings_scte35Source :: (Maybe HlsScte35SourceType -> f (Maybe HlsScte35SourceType))
-> HlsInputSettings -> f HlsInputSettings
hlsInputSettings_scte35Source = (HlsInputSettings -> Maybe HlsScte35SourceType)
-> (HlsInputSettings
    -> Maybe HlsScte35SourceType -> HlsInputSettings)
-> Lens
     HlsInputSettings
     HlsInputSettings
     (Maybe HlsScte35SourceType)
     (Maybe HlsScte35SourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsInputSettings' {Maybe HlsScte35SourceType
scte35Source :: Maybe HlsScte35SourceType
$sel:scte35Source:HlsInputSettings' :: HlsInputSettings -> Maybe HlsScte35SourceType
scte35Source} -> Maybe HlsScte35SourceType
scte35Source) (\s :: HlsInputSettings
s@HlsInputSettings' {} Maybe HlsScte35SourceType
a -> HlsInputSettings
s {$sel:scte35Source:HlsInputSettings' :: Maybe HlsScte35SourceType
scte35Source = Maybe HlsScte35SourceType
a} :: HlsInputSettings)

instance Core.FromJSON HlsInputSettings where
  parseJSON :: Value -> Parser HlsInputSettings
parseJSON =
    String
-> (Object -> Parser HlsInputSettings)
-> Value
-> Parser HlsInputSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HlsInputSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe HlsScte35SourceType
-> HlsInputSettings
HlsInputSettings'
            (Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe HlsScte35SourceType
 -> HlsInputSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe HlsScte35SourceType
      -> HlsInputSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bufferSegments")
            Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe HlsScte35SourceType
   -> HlsInputSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural -> Maybe HlsScte35SourceType -> HlsInputSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"retries")
            Parser
  (Maybe Natural
   -> Maybe Natural -> Maybe HlsScte35SourceType -> HlsInputSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural -> Maybe HlsScte35SourceType -> HlsInputSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"retryInterval")
            Parser
  (Maybe Natural -> Maybe HlsScte35SourceType -> HlsInputSettings)
-> Parser (Maybe Natural)
-> Parser (Maybe HlsScte35SourceType -> HlsInputSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bandwidth")
            Parser (Maybe HlsScte35SourceType -> HlsInputSettings)
-> Parser (Maybe HlsScte35SourceType) -> Parser HlsInputSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HlsScte35SourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"scte35Source")
      )

instance Prelude.Hashable HlsInputSettings

instance Prelude.NFData HlsInputSettings

instance Core.ToJSON HlsInputSettings where
  toJSON :: HlsInputSettings -> Value
toJSON HlsInputSettings' {Maybe Natural
Maybe HlsScte35SourceType
scte35Source :: Maybe HlsScte35SourceType
bandwidth :: Maybe Natural
retryInterval :: Maybe Natural
retries :: Maybe Natural
bufferSegments :: Maybe Natural
$sel:scte35Source:HlsInputSettings' :: HlsInputSettings -> Maybe HlsScte35SourceType
$sel:bandwidth:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:retryInterval:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:retries:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:bufferSegments:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"bufferSegments" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
bufferSegments,
            (Text
"retries" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
retries,
            (Text
"retryInterval" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
retryInterval,
            (Text
"bandwidth" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
bandwidth,
            (Text
"scte35Source" Text -> HlsScte35SourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HlsScte35SourceType -> Pair)
-> Maybe HlsScte35SourceType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HlsScte35SourceType
scte35Source
          ]
      )