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

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

-- | Placeholder documentation for VideoBlackFailoverSettings
--
-- /See:/ 'newVideoBlackFailoverSettings' smart constructor.
data VideoBlackFailoverSettings = VideoBlackFailoverSettings'
  { -- | 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,
    -- | 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
  }
  deriving (VideoBlackFailoverSettings -> VideoBlackFailoverSettings -> Bool
(VideoBlackFailoverSettings -> VideoBlackFailoverSettings -> Bool)
-> (VideoBlackFailoverSettings
    -> VideoBlackFailoverSettings -> Bool)
-> Eq VideoBlackFailoverSettings
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]
(Int -> ReadS VideoBlackFailoverSettings)
-> ReadS [VideoBlackFailoverSettings]
-> ReadPrec VideoBlackFailoverSettings
-> ReadPrec [VideoBlackFailoverSettings]
-> Read 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
(Int -> VideoBlackFailoverSettings -> ShowS)
-> (VideoBlackFailoverSettings -> String)
-> ([VideoBlackFailoverSettings] -> ShowS)
-> Show VideoBlackFailoverSettings
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.
 VideoBlackFailoverSettings -> Rep VideoBlackFailoverSettings x)
-> (forall x.
    Rep VideoBlackFailoverSettings x -> VideoBlackFailoverSettings)
-> Generic VideoBlackFailoverSettings
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:
--
-- 'videoBlackThresholdMsec', 'videoBlackFailoverSettings_videoBlackThresholdMsec' - The amount of time (in milliseconds) that the active input must be black
-- before automatic input failover occurs.
--
-- '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.
newVideoBlackFailoverSettings ::
  VideoBlackFailoverSettings
newVideoBlackFailoverSettings :: VideoBlackFailoverSettings
newVideoBlackFailoverSettings =
  VideoBlackFailoverSettings' :: Maybe Natural -> Maybe Double -> VideoBlackFailoverSettings
VideoBlackFailoverSettings'
    { $sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: Maybe Natural
videoBlackThresholdMsec =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:blackDetectThreshold:VideoBlackFailoverSettings' :: Maybe Double
blackDetectThreshold = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> VideoBlackFailoverSettings -> f VideoBlackFailoverSettings
videoBlackFailoverSettings_videoBlackThresholdMsec = (VideoBlackFailoverSettings -> Maybe Natural)
-> (VideoBlackFailoverSettings
    -> Maybe Natural -> VideoBlackFailoverSettings)
-> Lens
     VideoBlackFailoverSettings
     VideoBlackFailoverSettings
     (Maybe Natural)
     (Maybe Natural)
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)

-- | 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 :: (Maybe Double -> f (Maybe Double))
-> VideoBlackFailoverSettings -> f VideoBlackFailoverSettings
videoBlackFailoverSettings_blackDetectThreshold = (VideoBlackFailoverSettings -> Maybe Double)
-> (VideoBlackFailoverSettings
    -> Maybe Double -> VideoBlackFailoverSettings)
-> Lens
     VideoBlackFailoverSettings
     VideoBlackFailoverSettings
     (Maybe Double)
     (Maybe Double)
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)

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

instance Prelude.Hashable VideoBlackFailoverSettings

instance Prelude.NFData VideoBlackFailoverSettings

instance Core.ToJSON VideoBlackFailoverSettings where
  toJSON :: VideoBlackFailoverSettings -> Value
toJSON VideoBlackFailoverSettings' {Maybe Double
Maybe Natural
blackDetectThreshold :: Maybe Double
videoBlackThresholdMsec :: Maybe Natural
$sel:blackDetectThreshold:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Double
$sel:videoBlackThresholdMsec:VideoBlackFailoverSettings' :: VideoBlackFailoverSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"videoBlackThresholdMsec" 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
videoBlackThresholdMsec,
            (Text
"blackDetectThreshold" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
blackDetectThreshold
          ]
      )