{-# 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.AudioSilenceFailoverSettings
-- 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.AudioSilenceFailoverSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Placeholder documentation for AudioSilenceFailoverSettings
--
-- /See:/ 'newAudioSilenceFailoverSettings' smart constructor.
data AudioSilenceFailoverSettings = AudioSilenceFailoverSettings'
  { -- | The amount of time (in milliseconds) that the active input must be
    -- silent before automatic input failover occurs. Silence is defined as
    -- audio loss or audio quieter than -50 dBFS.
    AudioSilenceFailoverSettings -> Maybe Natural
audioSilenceThresholdMsec :: Prelude.Maybe Prelude.Natural,
    -- | The name of the audio selector in the input that MediaLive should
    -- monitor to detect silence. Select your most important rendition. If you
    -- didn\'t create an audio selector in this input, leave blank.
    AudioSilenceFailoverSettings -> Text
audioSelectorName :: Prelude.Text
  }
  deriving (AudioSilenceFailoverSettings
-> AudioSilenceFailoverSettings -> Bool
(AudioSilenceFailoverSettings
 -> AudioSilenceFailoverSettings -> Bool)
-> (AudioSilenceFailoverSettings
    -> AudioSilenceFailoverSettings -> Bool)
-> Eq AudioSilenceFailoverSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioSilenceFailoverSettings
-> AudioSilenceFailoverSettings -> Bool
$c/= :: AudioSilenceFailoverSettings
-> AudioSilenceFailoverSettings -> Bool
== :: AudioSilenceFailoverSettings
-> AudioSilenceFailoverSettings -> Bool
$c== :: AudioSilenceFailoverSettings
-> AudioSilenceFailoverSettings -> Bool
Prelude.Eq, ReadPrec [AudioSilenceFailoverSettings]
ReadPrec AudioSilenceFailoverSettings
Int -> ReadS AudioSilenceFailoverSettings
ReadS [AudioSilenceFailoverSettings]
(Int -> ReadS AudioSilenceFailoverSettings)
-> ReadS [AudioSilenceFailoverSettings]
-> ReadPrec AudioSilenceFailoverSettings
-> ReadPrec [AudioSilenceFailoverSettings]
-> Read AudioSilenceFailoverSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioSilenceFailoverSettings]
$creadListPrec :: ReadPrec [AudioSilenceFailoverSettings]
readPrec :: ReadPrec AudioSilenceFailoverSettings
$creadPrec :: ReadPrec AudioSilenceFailoverSettings
readList :: ReadS [AudioSilenceFailoverSettings]
$creadList :: ReadS [AudioSilenceFailoverSettings]
readsPrec :: Int -> ReadS AudioSilenceFailoverSettings
$creadsPrec :: Int -> ReadS AudioSilenceFailoverSettings
Prelude.Read, Int -> AudioSilenceFailoverSettings -> ShowS
[AudioSilenceFailoverSettings] -> ShowS
AudioSilenceFailoverSettings -> String
(Int -> AudioSilenceFailoverSettings -> ShowS)
-> (AudioSilenceFailoverSettings -> String)
-> ([AudioSilenceFailoverSettings] -> ShowS)
-> Show AudioSilenceFailoverSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioSilenceFailoverSettings] -> ShowS
$cshowList :: [AudioSilenceFailoverSettings] -> ShowS
show :: AudioSilenceFailoverSettings -> String
$cshow :: AudioSilenceFailoverSettings -> String
showsPrec :: Int -> AudioSilenceFailoverSettings -> ShowS
$cshowsPrec :: Int -> AudioSilenceFailoverSettings -> ShowS
Prelude.Show, (forall x.
 AudioSilenceFailoverSettings -> Rep AudioSilenceFailoverSettings x)
-> (forall x.
    Rep AudioSilenceFailoverSettings x -> AudioSilenceFailoverSettings)
-> Generic AudioSilenceFailoverSettings
forall x.
Rep AudioSilenceFailoverSettings x -> AudioSilenceFailoverSettings
forall x.
AudioSilenceFailoverSettings -> Rep AudioSilenceFailoverSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AudioSilenceFailoverSettings x -> AudioSilenceFailoverSettings
$cfrom :: forall x.
AudioSilenceFailoverSettings -> Rep AudioSilenceFailoverSettings x
Prelude.Generic)

-- |
-- Create a value of 'AudioSilenceFailoverSettings' 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:
--
-- 'audioSilenceThresholdMsec', 'audioSilenceFailoverSettings_audioSilenceThresholdMsec' - The amount of time (in milliseconds) that the active input must be
-- silent before automatic input failover occurs. Silence is defined as
-- audio loss or audio quieter than -50 dBFS.
--
-- 'audioSelectorName', 'audioSilenceFailoverSettings_audioSelectorName' - The name of the audio selector in the input that MediaLive should
-- monitor to detect silence. Select your most important rendition. If you
-- didn\'t create an audio selector in this input, leave blank.
newAudioSilenceFailoverSettings ::
  -- | 'audioSelectorName'
  Prelude.Text ->
  AudioSilenceFailoverSettings
newAudioSilenceFailoverSettings :: Text -> AudioSilenceFailoverSettings
newAudioSilenceFailoverSettings Text
pAudioSelectorName_ =
  AudioSilenceFailoverSettings' :: Maybe Natural -> Text -> AudioSilenceFailoverSettings
AudioSilenceFailoverSettings'
    { $sel:audioSilenceThresholdMsec:AudioSilenceFailoverSettings' :: Maybe Natural
audioSilenceThresholdMsec =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:audioSelectorName:AudioSilenceFailoverSettings' :: Text
audioSelectorName = Text
pAudioSelectorName_
    }

-- | The amount of time (in milliseconds) that the active input must be
-- silent before automatic input failover occurs. Silence is defined as
-- audio loss or audio quieter than -50 dBFS.
audioSilenceFailoverSettings_audioSilenceThresholdMsec :: Lens.Lens' AudioSilenceFailoverSettings (Prelude.Maybe Prelude.Natural)
audioSilenceFailoverSettings_audioSilenceThresholdMsec :: (Maybe Natural -> f (Maybe Natural))
-> AudioSilenceFailoverSettings -> f AudioSilenceFailoverSettings
audioSilenceFailoverSettings_audioSilenceThresholdMsec = (AudioSilenceFailoverSettings -> Maybe Natural)
-> (AudioSilenceFailoverSettings
    -> Maybe Natural -> AudioSilenceFailoverSettings)
-> Lens
     AudioSilenceFailoverSettings
     AudioSilenceFailoverSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioSilenceFailoverSettings' {Maybe Natural
audioSilenceThresholdMsec :: Maybe Natural
$sel:audioSilenceThresholdMsec:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Maybe Natural
audioSilenceThresholdMsec} -> Maybe Natural
audioSilenceThresholdMsec) (\s :: AudioSilenceFailoverSettings
s@AudioSilenceFailoverSettings' {} Maybe Natural
a -> AudioSilenceFailoverSettings
s {$sel:audioSilenceThresholdMsec:AudioSilenceFailoverSettings' :: Maybe Natural
audioSilenceThresholdMsec = Maybe Natural
a} :: AudioSilenceFailoverSettings)

-- | The name of the audio selector in the input that MediaLive should
-- monitor to detect silence. Select your most important rendition. If you
-- didn\'t create an audio selector in this input, leave blank.
audioSilenceFailoverSettings_audioSelectorName :: Lens.Lens' AudioSilenceFailoverSettings Prelude.Text
audioSilenceFailoverSettings_audioSelectorName :: (Text -> f Text)
-> AudioSilenceFailoverSettings -> f AudioSilenceFailoverSettings
audioSilenceFailoverSettings_audioSelectorName = (AudioSilenceFailoverSettings -> Text)
-> (AudioSilenceFailoverSettings
    -> Text -> AudioSilenceFailoverSettings)
-> Lens
     AudioSilenceFailoverSettings AudioSilenceFailoverSettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioSilenceFailoverSettings' {Text
audioSelectorName :: Text
$sel:audioSelectorName:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Text
audioSelectorName} -> Text
audioSelectorName) (\s :: AudioSilenceFailoverSettings
s@AudioSilenceFailoverSettings' {} Text
a -> AudioSilenceFailoverSettings
s {$sel:audioSelectorName:AudioSilenceFailoverSettings' :: Text
audioSelectorName = Text
a} :: AudioSilenceFailoverSettings)

instance Core.FromJSON AudioSilenceFailoverSettings where
  parseJSON :: Value -> Parser AudioSilenceFailoverSettings
parseJSON =
    String
-> (Object -> Parser AudioSilenceFailoverSettings)
-> Value
-> Parser AudioSilenceFailoverSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AudioSilenceFailoverSettings"
      ( \Object
x ->
          Maybe Natural -> Text -> AudioSilenceFailoverSettings
AudioSilenceFailoverSettings'
            (Maybe Natural -> Text -> AudioSilenceFailoverSettings)
-> Parser (Maybe Natural)
-> Parser (Text -> AudioSilenceFailoverSettings)
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
"audioSilenceThresholdMsec")
            Parser (Text -> AudioSilenceFailoverSettings)
-> Parser Text -> Parser AudioSilenceFailoverSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"audioSelectorName")
      )

instance
  Prelude.Hashable
    AudioSilenceFailoverSettings

instance Prelude.NFData AudioSilenceFailoverSettings

instance Core.ToJSON AudioSilenceFailoverSettings where
  toJSON :: AudioSilenceFailoverSettings -> Value
toJSON AudioSilenceFailoverSettings' {Maybe Natural
Text
audioSelectorName :: Text
audioSilenceThresholdMsec :: Maybe Natural
$sel:audioSelectorName:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Text
$sel:audioSilenceThresholdMsec:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"audioSilenceThresholdMsec" 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
audioSilenceThresholdMsec,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"audioSelectorName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
audioSelectorName)
          ]
      )