{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.HlsInputSettings where

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

-- | Hls Input Settings
--
-- /See:/ 'newHlsInputSettings' smart constructor.
data HlsInputSettings = 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 -> Maybe Natural
bandwidth :: Prelude.Maybe Prelude.Natural,
    -- | 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,
    -- | 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
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]
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
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. 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:
--
-- '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.
--
-- '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.
--
-- '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'
    { $sel:bandwidth:HlsInputSettings' :: Maybe Natural
bandwidth = forall a. Maybe a
Prelude.Nothing,
      $sel:bufferSegments:HlsInputSettings' :: Maybe Natural
bufferSegments = forall a. Maybe a
Prelude.Nothing,
      $sel:retries:HlsInputSettings' :: Maybe Natural
retries = forall a. Maybe a
Prelude.Nothing,
      $sel:retryInterval:HlsInputSettings' :: Maybe Natural
retryInterval = forall a. Maybe a
Prelude.Nothing,
      $sel:scte35Source:HlsInputSettings' :: Maybe HlsScte35SourceType
scte35Source = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' HlsInputSettings (Maybe Natural)
hlsInputSettings_bandwidth = 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)

-- | 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 :: Lens' HlsInputSettings (Maybe Natural)
hlsInputSettings_bufferSegments = 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 :: Lens' HlsInputSettings (Maybe Natural)
hlsInputSettings_retries = 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 :: Lens' HlsInputSettings (Maybe Natural)
hlsInputSettings_retryInterval = 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)

-- | 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 :: Lens' HlsInputSettings (Maybe HlsScte35SourceType)
hlsInputSettings_scte35Source = 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 Data.FromJSON HlsInputSettings where
  parseJSON :: Value -> Parser HlsInputSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HlsInputSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe HlsScte35SourceType
-> HlsInputSettings
HlsInputSettings'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"bandwidth")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"bufferSegments")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"retries")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"retryInterval")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"scte35Source")
      )

instance Prelude.Hashable HlsInputSettings where
  hashWithSalt :: Int -> HlsInputSettings -> Int
hashWithSalt Int
_salt HlsInputSettings' {Maybe Natural
Maybe HlsScte35SourceType
scte35Source :: Maybe HlsScte35SourceType
retryInterval :: Maybe Natural
retries :: Maybe Natural
bufferSegments :: Maybe Natural
bandwidth :: Maybe Natural
$sel:scte35Source:HlsInputSettings' :: HlsInputSettings -> Maybe HlsScte35SourceType
$sel:retryInterval:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:retries:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:bufferSegments:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:bandwidth:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
bandwidth
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
bufferSegments
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
retries
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
retryInterval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HlsScte35SourceType
scte35Source

instance Prelude.NFData HlsInputSettings where
  rnf :: HlsInputSettings -> ()
rnf HlsInputSettings' {Maybe Natural
Maybe HlsScte35SourceType
scte35Source :: Maybe HlsScte35SourceType
retryInterval :: Maybe Natural
retries :: Maybe Natural
bufferSegments :: Maybe Natural
bandwidth :: Maybe Natural
$sel:scte35Source:HlsInputSettings' :: HlsInputSettings -> Maybe HlsScte35SourceType
$sel:retryInterval:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:retries:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:bufferSegments:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
$sel:bandwidth:HlsInputSettings' :: HlsInputSettings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
bandwidth
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
bufferSegments
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
retries
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
retryInterval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HlsScte35SourceType
scte35Source

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