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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:syncThreshold:TimecodeConfig' :: Maybe Natural
syncThreshold = 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 :: Lens' TimecodeConfig (Maybe Natural)
timecodeConfig_syncThreshold = 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 :: Lens' TimecodeConfig TimecodeConfigSource
timecodeConfig_source = 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 Data.FromJSON TimecodeConfig where
  parseJSON :: Value -> Parser TimecodeConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimecodeConfig"
      ( \Object
x ->
          Maybe Natural -> TimecodeConfigSource -> TimecodeConfig
TimecodeConfig'
            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
"syncThreshold")
            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
"source")
      )

instance Prelude.Hashable TimecodeConfig where
  hashWithSalt :: Int -> TimecodeConfig -> Int
hashWithSalt Int
_salt TimecodeConfig' {Maybe Natural
TimecodeConfigSource
source :: TimecodeConfigSource
syncThreshold :: Maybe Natural
$sel:source:TimecodeConfig' :: TimecodeConfig -> TimecodeConfigSource
$sel:syncThreshold:TimecodeConfig' :: TimecodeConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
syncThreshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TimecodeConfigSource
source

instance Prelude.NFData TimecodeConfig where
  rnf :: TimecodeConfig -> ()
rnf TimecodeConfig' {Maybe Natural
TimecodeConfigSource
source :: TimecodeConfigSource
syncThreshold :: Maybe Natural
$sel:source:TimecodeConfig' :: TimecodeConfig -> TimecodeConfigSource
$sel:syncThreshold:TimecodeConfig' :: TimecodeConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
syncThreshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TimecodeConfigSource
source

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