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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
    { $sel:audioSilenceThresholdMsec:AudioSilenceFailoverSettings' :: Maybe Natural
audioSilenceThresholdMsec =
        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 :: Lens' AudioSilenceFailoverSettings (Maybe Natural)
audioSilenceFailoverSettings_audioSilenceThresholdMsec = 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 :: Lens' AudioSilenceFailoverSettings Text
audioSilenceFailoverSettings_audioSelectorName = 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 Data.FromJSON AudioSilenceFailoverSettings where
  parseJSON :: Value -> Parser AudioSilenceFailoverSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AudioSilenceFailoverSettings"
      ( \Object
x ->
          Maybe Natural -> Text -> AudioSilenceFailoverSettings
AudioSilenceFailoverSettings'
            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
"audioSilenceThresholdMsec")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"audioSelectorName")
      )

instance
  Prelude.Hashable
    AudioSilenceFailoverSettings
  where
  hashWithSalt :: Int -> AudioSilenceFailoverSettings -> Int
hashWithSalt Int
_salt AudioSilenceFailoverSettings' {Maybe Natural
Text
audioSelectorName :: Text
audioSilenceThresholdMsec :: Maybe Natural
$sel:audioSelectorName:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Text
$sel:audioSilenceThresholdMsec:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
audioSilenceThresholdMsec
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
audioSelectorName

instance Prelude.NFData AudioSilenceFailoverSettings where
  rnf :: AudioSilenceFailoverSettings -> ()
rnf AudioSilenceFailoverSettings' {Maybe Natural
Text
audioSelectorName :: Text
audioSilenceThresholdMsec :: Maybe Natural
$sel:audioSelectorName:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Text
$sel:audioSilenceThresholdMsec:AudioSilenceFailoverSettings' :: AudioSilenceFailoverSettings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
audioSilenceThresholdMsec
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
audioSelectorName

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"audioSilenceThresholdMsec" 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
audioSilenceThresholdMsec,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"audioSelectorName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
audioSelectorName)
          ]
      )