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

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

-- | Frame Capture Settings
--
-- /See:/ 'newFrameCaptureSettings' smart constructor.
data FrameCaptureSettings = FrameCaptureSettings'
  { -- | Unit for the frame capture interval.
    FrameCaptureSettings -> Maybe FrameCaptureIntervalUnit
captureIntervalUnits :: Prelude.Maybe FrameCaptureIntervalUnit,
    -- | The frequency at which to capture frames for inclusion in the output.
    -- May be specified in either seconds or milliseconds, as specified by
    -- captureIntervalUnits.
    FrameCaptureSettings -> Maybe Natural
captureInterval :: Prelude.Maybe Prelude.Natural
  }
  deriving (FrameCaptureSettings -> FrameCaptureSettings -> Bool
(FrameCaptureSettings -> FrameCaptureSettings -> Bool)
-> (FrameCaptureSettings -> FrameCaptureSettings -> Bool)
-> Eq FrameCaptureSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FrameCaptureSettings -> FrameCaptureSettings -> Bool
$c/= :: FrameCaptureSettings -> FrameCaptureSettings -> Bool
== :: FrameCaptureSettings -> FrameCaptureSettings -> Bool
$c== :: FrameCaptureSettings -> FrameCaptureSettings -> Bool
Prelude.Eq, ReadPrec [FrameCaptureSettings]
ReadPrec FrameCaptureSettings
Int -> ReadS FrameCaptureSettings
ReadS [FrameCaptureSettings]
(Int -> ReadS FrameCaptureSettings)
-> ReadS [FrameCaptureSettings]
-> ReadPrec FrameCaptureSettings
-> ReadPrec [FrameCaptureSettings]
-> Read FrameCaptureSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FrameCaptureSettings]
$creadListPrec :: ReadPrec [FrameCaptureSettings]
readPrec :: ReadPrec FrameCaptureSettings
$creadPrec :: ReadPrec FrameCaptureSettings
readList :: ReadS [FrameCaptureSettings]
$creadList :: ReadS [FrameCaptureSettings]
readsPrec :: Int -> ReadS FrameCaptureSettings
$creadsPrec :: Int -> ReadS FrameCaptureSettings
Prelude.Read, Int -> FrameCaptureSettings -> ShowS
[FrameCaptureSettings] -> ShowS
FrameCaptureSettings -> String
(Int -> FrameCaptureSettings -> ShowS)
-> (FrameCaptureSettings -> String)
-> ([FrameCaptureSettings] -> ShowS)
-> Show FrameCaptureSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FrameCaptureSettings] -> ShowS
$cshowList :: [FrameCaptureSettings] -> ShowS
show :: FrameCaptureSettings -> String
$cshow :: FrameCaptureSettings -> String
showsPrec :: Int -> FrameCaptureSettings -> ShowS
$cshowsPrec :: Int -> FrameCaptureSettings -> ShowS
Prelude.Show, (forall x. FrameCaptureSettings -> Rep FrameCaptureSettings x)
-> (forall x. Rep FrameCaptureSettings x -> FrameCaptureSettings)
-> Generic FrameCaptureSettings
forall x. Rep FrameCaptureSettings x -> FrameCaptureSettings
forall x. FrameCaptureSettings -> Rep FrameCaptureSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FrameCaptureSettings x -> FrameCaptureSettings
$cfrom :: forall x. FrameCaptureSettings -> Rep FrameCaptureSettings x
Prelude.Generic)

-- |
-- Create a value of 'FrameCaptureSettings' 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:
--
-- 'captureIntervalUnits', 'frameCaptureSettings_captureIntervalUnits' - Unit for the frame capture interval.
--
-- 'captureInterval', 'frameCaptureSettings_captureInterval' - The frequency at which to capture frames for inclusion in the output.
-- May be specified in either seconds or milliseconds, as specified by
-- captureIntervalUnits.
newFrameCaptureSettings ::
  FrameCaptureSettings
newFrameCaptureSettings :: FrameCaptureSettings
newFrameCaptureSettings =
  FrameCaptureSettings' :: Maybe FrameCaptureIntervalUnit
-> Maybe Natural -> FrameCaptureSettings
FrameCaptureSettings'
    { $sel:captureIntervalUnits:FrameCaptureSettings' :: Maybe FrameCaptureIntervalUnit
captureIntervalUnits =
        Maybe FrameCaptureIntervalUnit
forall a. Maybe a
Prelude.Nothing,
      $sel:captureInterval:FrameCaptureSettings' :: Maybe Natural
captureInterval = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Unit for the frame capture interval.
frameCaptureSettings_captureIntervalUnits :: Lens.Lens' FrameCaptureSettings (Prelude.Maybe FrameCaptureIntervalUnit)
frameCaptureSettings_captureIntervalUnits :: (Maybe FrameCaptureIntervalUnit
 -> f (Maybe FrameCaptureIntervalUnit))
-> FrameCaptureSettings -> f FrameCaptureSettings
frameCaptureSettings_captureIntervalUnits = (FrameCaptureSettings -> Maybe FrameCaptureIntervalUnit)
-> (FrameCaptureSettings
    -> Maybe FrameCaptureIntervalUnit -> FrameCaptureSettings)
-> Lens
     FrameCaptureSettings
     FrameCaptureSettings
     (Maybe FrameCaptureIntervalUnit)
     (Maybe FrameCaptureIntervalUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameCaptureSettings' {Maybe FrameCaptureIntervalUnit
captureIntervalUnits :: Maybe FrameCaptureIntervalUnit
$sel:captureIntervalUnits:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe FrameCaptureIntervalUnit
captureIntervalUnits} -> Maybe FrameCaptureIntervalUnit
captureIntervalUnits) (\s :: FrameCaptureSettings
s@FrameCaptureSettings' {} Maybe FrameCaptureIntervalUnit
a -> FrameCaptureSettings
s {$sel:captureIntervalUnits:FrameCaptureSettings' :: Maybe FrameCaptureIntervalUnit
captureIntervalUnits = Maybe FrameCaptureIntervalUnit
a} :: FrameCaptureSettings)

-- | The frequency at which to capture frames for inclusion in the output.
-- May be specified in either seconds or milliseconds, as specified by
-- captureIntervalUnits.
frameCaptureSettings_captureInterval :: Lens.Lens' FrameCaptureSettings (Prelude.Maybe Prelude.Natural)
frameCaptureSettings_captureInterval :: (Maybe Natural -> f (Maybe Natural))
-> FrameCaptureSettings -> f FrameCaptureSettings
frameCaptureSettings_captureInterval = (FrameCaptureSettings -> Maybe Natural)
-> (FrameCaptureSettings -> Maybe Natural -> FrameCaptureSettings)
-> Lens
     FrameCaptureSettings
     FrameCaptureSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrameCaptureSettings' {Maybe Natural
captureInterval :: Maybe Natural
$sel:captureInterval:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
captureInterval} -> Maybe Natural
captureInterval) (\s :: FrameCaptureSettings
s@FrameCaptureSettings' {} Maybe Natural
a -> FrameCaptureSettings
s {$sel:captureInterval:FrameCaptureSettings' :: Maybe Natural
captureInterval = Maybe Natural
a} :: FrameCaptureSettings)

instance Core.FromJSON FrameCaptureSettings where
  parseJSON :: Value -> Parser FrameCaptureSettings
parseJSON =
    String
-> (Object -> Parser FrameCaptureSettings)
-> Value
-> Parser FrameCaptureSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FrameCaptureSettings"
      ( \Object
x ->
          Maybe FrameCaptureIntervalUnit
-> Maybe Natural -> FrameCaptureSettings
FrameCaptureSettings'
            (Maybe FrameCaptureIntervalUnit
 -> Maybe Natural -> FrameCaptureSettings)
-> Parser (Maybe FrameCaptureIntervalUnit)
-> Parser (Maybe Natural -> FrameCaptureSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FrameCaptureIntervalUnit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"captureIntervalUnits")
            Parser (Maybe Natural -> FrameCaptureSettings)
-> Parser (Maybe Natural) -> Parser FrameCaptureSettings
forall (f :: * -> *) a b. Applicative f => 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
"captureInterval")
      )

instance Prelude.Hashable FrameCaptureSettings

instance Prelude.NFData FrameCaptureSettings

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