{-# 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.VideoBlackFailoverSettings
-- 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.VideoBlackFailoverSettings 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 VideoBlackFailoverSettings
--
-- /See:/ 'newVideoBlackFailoverSettings' smart constructor.
data VideoBlackFailoverSettings = VideoBlackFailoverSettings'
  { -- | A value used in calculating the threshold below which MediaLive
    -- considers a pixel to be \'black\'. For the input to be considered black,
    -- every pixel in a frame must be below this threshold. The threshold is
    -- calculated as a percentage (expressed as a decimal) of white. Therefore
    -- .1 means 10% white (or 90% black). Note how the formula works for any
    -- color depth. For example, if you set this field to 0.1 in 10-bit color
    -- depth: (1023*0.1=102.3), which means a pixel value of 102 or less is
    -- \'black\'. If you set this field to .1 in an 8-bit color depth:
    -- (255*0.1=25.5), which means a pixel value of 25 or less is \'black\'.
    -- The range is 0.0 to 1.0, with any number of decimal places.
    VideoBlackFailoverSettings -> Maybe Double
blackDetectThreshold :: Prelude.Maybe Prelude.Double,
    -- | The amount of time (in milliseconds) that the active input must be black
    -- before automatic input failover occurs.
    VideoBlackFailoverSettings -> Maybe Natural
videoBlackThresholdMsec :: Prelude.Maybe Prelude.Natural
  }
  deriving (VideoBlackFailoverSettings -> VideoBlackFailoverSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VideoBlackFailoverSettings -> VideoBlackFailoverSettings -> Bool
$c/= :: VideoBlackFailoverSettings -> VideoBlackFailoverSettings -> Bool
== :: VideoBlackFailoverSettings -> VideoBlackFailoverSettings -> Bool
$c== :: VideoBlackFailoverSettings -> VideoBlackFailoverSettings -> Bool
Prelude.Eq, ReadPrec [VideoBlackFailoverSettings]
ReadPrec VideoBlackFailoverSettings
Int -> ReadS VideoBlackFailoverSettings
ReadS [VideoBlackFailoverSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VideoBlackFailoverSettings]
$creadListPrec :: ReadPrec [VideoBlackFailoverSettings]
readPrec :: ReadPrec VideoBlackFailoverSettings
$creadPrec :: ReadPrec VideoBlackFailoverSettings
readList :: ReadS [VideoBlackFailoverSettings]
$creadList :: ReadS [VideoBlackFailoverSettings]
readsPrec :: Int -> ReadS VideoBlackFailoverSettings
$creadsPrec :: Int -> ReadS VideoBlackFailoverSettings
Prelude.Read, Int -> VideoBlackFailoverSettings -> ShowS
[VideoBlackFailoverSettings] -> ShowS
VideoBlackFailoverSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VideoBlackFailoverSettings] -> ShowS
$cshowList :: [VideoBlackFailoverSettings] -> ShowS
show :: VideoBlackFailoverSettings -> String
$cshow :: VideoBlackFailoverSettings -> String
showsPrec :: Int -> VideoBlackFailoverSettings -> ShowS
$cshowsPrec :: Int -> VideoBlackFailoverSettings -> ShowS
Prelude.Show, forall x.
Rep VideoBlackFailoverSettings x -> VideoBlackFailoverSettings
forall x.
VideoBlackFailoverSettings -> Rep VideoBlackFailoverSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VideoBlackFailoverSettings x -> VideoBlackFailoverSettings
$cfrom :: forall x.
VideoBlackFailoverSettings -> Rep VideoBlackFailoverSettings x
Prelude.Generic)

-- |
-- Create a value of 'VideoBlackFailoverSettings' 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:
--
-- 'blackDetectThreshold', 'videoBlackFailoverSettings_blackDetectThreshold' - A value used in calculating the threshold below which MediaLive
-- considers a pixel to be \'black\'. For the input to be considered black,
-- every pixel in a frame must be below this threshold. The threshold is
-- calculated as a percentage (expressed as a decimal) of white. Therefore
-- .1 means 10% white (or 90% black). Note how the formula works for any
-- color depth. For example, if you set this field to 0.1 in 10-bit color
-- depth: (1023*0.1=102.3), which means a pixel value of 102 or less is
-- \'black\'. If you set this field to .1 in an 8-bit color depth:
-- (255*0.1=25.5), which means a pixel value of 25 or less is \'black\'.
-- The range is 0.0 to 1.0, with any number of decimal places.
--
-- 'videoBlackThresholdMsec', 'videoBlackFailoverSettings_videoBlackThresholdMsec' - The amount of time (in milliseconds) that the active input must be black
-- before automatic input failover occurs.
newVideoBlackFailoverSettings ::
  VideoBlackFailoverSettings
newVideoBlackFailoverSettings :: VideoBlackFailoverSettings
newVideoBlackFailoverSettings =
  VideoBlackFailoverSettings'
    { $sel:blackDetectThreshold:VideoBlackFailoverSettings' :: Maybe Double
blackDetectThreshold =
        forall a. Maybe a
Prelude.Nothing,
      $sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: Maybe Natural
videoBlackThresholdMsec = forall a. Maybe a
Prelude.Nothing
    }

-- | A value used in calculating the threshold below which MediaLive
-- considers a pixel to be \'black\'. For the input to be considered black,
-- every pixel in a frame must be below this threshold. The threshold is
-- calculated as a percentage (expressed as a decimal) of white. Therefore
-- .1 means 10% white (or 90% black). Note how the formula works for any
-- color depth. For example, if you set this field to 0.1 in 10-bit color
-- depth: (1023*0.1=102.3), which means a pixel value of 102 or less is
-- \'black\'. If you set this field to .1 in an 8-bit color depth:
-- (255*0.1=25.5), which means a pixel value of 25 or less is \'black\'.
-- The range is 0.0 to 1.0, with any number of decimal places.
videoBlackFailoverSettings_blackDetectThreshold :: Lens.Lens' VideoBlackFailoverSettings (Prelude.Maybe Prelude.Double)
videoBlackFailoverSettings_blackDetectThreshold :: Lens' VideoBlackFailoverSettings (Maybe Double)
videoBlackFailoverSettings_blackDetectThreshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VideoBlackFailoverSettings' {Maybe Double
blackDetectThreshold :: Maybe Double
$sel:blackDetectThreshold:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Double
blackDetectThreshold} -> Maybe Double
blackDetectThreshold) (\s :: VideoBlackFailoverSettings
s@VideoBlackFailoverSettings' {} Maybe Double
a -> VideoBlackFailoverSettings
s {$sel:blackDetectThreshold:VideoBlackFailoverSettings' :: Maybe Double
blackDetectThreshold = Maybe Double
a} :: VideoBlackFailoverSettings)

-- | The amount of time (in milliseconds) that the active input must be black
-- before automatic input failover occurs.
videoBlackFailoverSettings_videoBlackThresholdMsec :: Lens.Lens' VideoBlackFailoverSettings (Prelude.Maybe Prelude.Natural)
videoBlackFailoverSettings_videoBlackThresholdMsec :: Lens' VideoBlackFailoverSettings (Maybe Natural)
videoBlackFailoverSettings_videoBlackThresholdMsec = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VideoBlackFailoverSettings' {Maybe Natural
videoBlackThresholdMsec :: Maybe Natural
$sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Natural
videoBlackThresholdMsec} -> Maybe Natural
videoBlackThresholdMsec) (\s :: VideoBlackFailoverSettings
s@VideoBlackFailoverSettings' {} Maybe Natural
a -> VideoBlackFailoverSettings
s {$sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: Maybe Natural
videoBlackThresholdMsec = Maybe Natural
a} :: VideoBlackFailoverSettings)

instance Data.FromJSON VideoBlackFailoverSettings where
  parseJSON :: Value -> Parser VideoBlackFailoverSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VideoBlackFailoverSettings"
      ( \Object
x ->
          Maybe Double -> Maybe Natural -> VideoBlackFailoverSettings
VideoBlackFailoverSettings'
            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
"blackDetectThreshold")
            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
"videoBlackThresholdMsec")
      )

instance Prelude.Hashable VideoBlackFailoverSettings where
  hashWithSalt :: Int -> VideoBlackFailoverSettings -> Int
hashWithSalt Int
_salt VideoBlackFailoverSettings' {Maybe Double
Maybe Natural
videoBlackThresholdMsec :: Maybe Natural
blackDetectThreshold :: Maybe Double
$sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Natural
$sel:blackDetectThreshold:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
blackDetectThreshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
videoBlackThresholdMsec

instance Prelude.NFData VideoBlackFailoverSettings where
  rnf :: VideoBlackFailoverSettings -> ()
rnf VideoBlackFailoverSettings' {Maybe Double
Maybe Natural
videoBlackThresholdMsec :: Maybe Natural
blackDetectThreshold :: Maybe Double
$sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Natural
$sel:blackDetectThreshold:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
blackDetectThreshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
videoBlackThresholdMsec

instance Data.ToJSON VideoBlackFailoverSettings where
  toJSON :: VideoBlackFailoverSettings -> Value
toJSON VideoBlackFailoverSettings' {Maybe Double
Maybe Natural
videoBlackThresholdMsec :: Maybe Natural
blackDetectThreshold :: Maybe Double
$sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Natural
$sel:blackDetectThreshold:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"blackDetectThreshold" 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 Double
blackDetectThreshold,
            (Key
"videoBlackThresholdMsec" 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
videoBlackThresholdMsec
          ]
      )