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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.TimecodeConfigSource
import qualified Amazonka.Prelude as Prelude

-- | Timecode Config
--
-- /See:/ 'newTimecodeConfig' smart constructor.
data TimecodeConfig = TimecodeConfig'
  { -- | Threshold in frames beyond which output timecode is resynchronized to
    -- the input timecode. Discrepancies below this threshold are permitted to
    -- avoid unnecessary discontinuities in the output timecode. No timecode
    -- sync when this is not specified.
    TimecodeConfig -> Maybe Natural
syncThreshold :: Prelude.Maybe Prelude.Natural,
    -- | Identifies the source for the timecode that will be associated with the
    -- events outputs. -Embedded (embedded): Initialize the output timecode
    -- with timecode from the the source. If no embedded timecode is detected
    -- in the source, the system falls back to using \"Start at 0\"
    -- (zerobased). -System Clock (systemclock): Use the UTC time. -Start at 0
    -- (zerobased): The time of the first frame of the event will be
    -- 00:00:00:00.
    TimecodeConfig -> TimecodeConfigSource
source :: TimecodeConfigSource
  }
  deriving (TimecodeConfig -> TimecodeConfig -> Bool
(TimecodeConfig -> TimecodeConfig -> Bool)
-> (TimecodeConfig -> TimecodeConfig -> Bool) -> Eq TimecodeConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimecodeConfig -> TimecodeConfig -> Bool
$c/= :: TimecodeConfig -> TimecodeConfig -> Bool
== :: TimecodeConfig -> TimecodeConfig -> Bool
$c== :: TimecodeConfig -> TimecodeConfig -> Bool
Prelude.Eq, ReadPrec [TimecodeConfig]
ReadPrec TimecodeConfig
Int -> ReadS TimecodeConfig
ReadS [TimecodeConfig]
(Int -> ReadS TimecodeConfig)
-> ReadS [TimecodeConfig]
-> ReadPrec TimecodeConfig
-> ReadPrec [TimecodeConfig]
-> Read TimecodeConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimecodeConfig]
$creadListPrec :: ReadPrec [TimecodeConfig]
readPrec :: ReadPrec TimecodeConfig
$creadPrec :: ReadPrec TimecodeConfig
readList :: ReadS [TimecodeConfig]
$creadList :: ReadS [TimecodeConfig]
readsPrec :: Int -> ReadS TimecodeConfig
$creadsPrec :: Int -> ReadS TimecodeConfig
Prelude.Read, Int -> TimecodeConfig -> ShowS
[TimecodeConfig] -> ShowS
TimecodeConfig -> String
(Int -> TimecodeConfig -> ShowS)
-> (TimecodeConfig -> String)
-> ([TimecodeConfig] -> ShowS)
-> Show TimecodeConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimecodeConfig] -> ShowS
$cshowList :: [TimecodeConfig] -> ShowS
show :: TimecodeConfig -> String
$cshow :: TimecodeConfig -> String
showsPrec :: Int -> TimecodeConfig -> ShowS
$cshowsPrec :: Int -> TimecodeConfig -> ShowS
Prelude.Show, (forall x. TimecodeConfig -> Rep TimecodeConfig x)
-> (forall x. Rep TimecodeConfig x -> TimecodeConfig)
-> Generic TimecodeConfig
forall x. Rep TimecodeConfig x -> TimecodeConfig
forall x. TimecodeConfig -> Rep TimecodeConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimecodeConfig x -> TimecodeConfig
$cfrom :: forall x. TimecodeConfig -> Rep TimecodeConfig x
Prelude.Generic)

-- |
-- Create a value of 'TimecodeConfig' 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:
--
-- 'syncThreshold', 'timecodeConfig_syncThreshold' - Threshold in frames beyond which output timecode is resynchronized to
-- the input timecode. Discrepancies below this threshold are permitted to
-- avoid unnecessary discontinuities in the output timecode. No timecode
-- sync when this is not specified.
--
-- 'source', 'timecodeConfig_source' - Identifies the source for the timecode that will be associated with the
-- events outputs. -Embedded (embedded): Initialize the output timecode
-- with timecode from the the source. If no embedded timecode is detected
-- in the source, the system falls back to using \"Start at 0\"
-- (zerobased). -System Clock (systemclock): Use the UTC time. -Start at 0
-- (zerobased): The time of the first frame of the event will be
-- 00:00:00:00.
newTimecodeConfig ::
  -- | 'source'
  TimecodeConfigSource ->
  TimecodeConfig
newTimecodeConfig :: TimecodeConfigSource -> TimecodeConfig
newTimecodeConfig TimecodeConfigSource
pSource_ =
  TimecodeConfig' :: Maybe Natural -> TimecodeConfigSource -> TimecodeConfig
TimecodeConfig'
    { $sel:syncThreshold:TimecodeConfig' :: Maybe Natural
syncThreshold = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:source:TimecodeConfig' :: TimecodeConfigSource
source = TimecodeConfigSource
pSource_
    }

-- | Threshold in frames beyond which output timecode is resynchronized to
-- the input timecode. Discrepancies below this threshold are permitted to
-- avoid unnecessary discontinuities in the output timecode. No timecode
-- sync when this is not specified.
timecodeConfig_syncThreshold :: Lens.Lens' TimecodeConfig (Prelude.Maybe Prelude.Natural)
timecodeConfig_syncThreshold :: (Maybe Natural -> f (Maybe Natural))
-> TimecodeConfig -> f TimecodeConfig
timecodeConfig_syncThreshold = (TimecodeConfig -> Maybe Natural)
-> (TimecodeConfig -> Maybe Natural -> TimecodeConfig)
-> Lens
     TimecodeConfig TimecodeConfig (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimecodeConfig' {Maybe Natural
syncThreshold :: Maybe Natural
$sel:syncThreshold:TimecodeConfig' :: TimecodeConfig -> Maybe Natural
syncThreshold} -> Maybe Natural
syncThreshold) (\s :: TimecodeConfig
s@TimecodeConfig' {} Maybe Natural
a -> TimecodeConfig
s {$sel:syncThreshold:TimecodeConfig' :: Maybe Natural
syncThreshold = Maybe Natural
a} :: TimecodeConfig)

-- | Identifies the source for the timecode that will be associated with the
-- events outputs. -Embedded (embedded): Initialize the output timecode
-- with timecode from the the source. If no embedded timecode is detected
-- in the source, the system falls back to using \"Start at 0\"
-- (zerobased). -System Clock (systemclock): Use the UTC time. -Start at 0
-- (zerobased): The time of the first frame of the event will be
-- 00:00:00:00.
timecodeConfig_source :: Lens.Lens' TimecodeConfig TimecodeConfigSource
timecodeConfig_source :: (TimecodeConfigSource -> f TimecodeConfigSource)
-> TimecodeConfig -> f TimecodeConfig
timecodeConfig_source = (TimecodeConfig -> TimecodeConfigSource)
-> (TimecodeConfig -> TimecodeConfigSource -> TimecodeConfig)
-> Lens
     TimecodeConfig
     TimecodeConfig
     TimecodeConfigSource
     TimecodeConfigSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimecodeConfig' {TimecodeConfigSource
source :: TimecodeConfigSource
$sel:source:TimecodeConfig' :: TimecodeConfig -> TimecodeConfigSource
source} -> TimecodeConfigSource
source) (\s :: TimecodeConfig
s@TimecodeConfig' {} TimecodeConfigSource
a -> TimecodeConfig
s {$sel:source:TimecodeConfig' :: TimecodeConfigSource
source = TimecodeConfigSource
a} :: TimecodeConfig)

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

instance Prelude.Hashable TimecodeConfig

instance Prelude.NFData TimecodeConfig

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