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

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

-- | Required when you set (Codec) under (VideoDescription)>(CodecSettings)
-- to the value FRAME_CAPTURE.
--
-- /See:/ 'newFrameCaptureSettings' smart constructor.
data FrameCaptureSettings = FrameCaptureSettings'
  { -- | JPEG Quality - a higher value equals higher quality.
    FrameCaptureSettings -> Maybe Natural
quality :: Prelude.Maybe Prelude.Natural,
    -- | Frame capture will encode the first frame of the output stream, then one
    -- frame every framerateDenominator\/framerateNumerator seconds. For
    -- example, settings of framerateNumerator = 1 and framerateDenominator = 3
    -- (a rate of 1\/3 frame per second) will capture the first frame, then 1
    -- frame every 3s. Files will be named as filename.n.jpg where n is the
    -- 0-based sequence number of each Capture.
    FrameCaptureSettings -> Maybe Natural
framerateDenominator :: Prelude.Maybe Prelude.Natural,
    -- | Maximum number of captures (encoded jpg output files).
    FrameCaptureSettings -> Maybe Natural
maxCaptures :: Prelude.Maybe Prelude.Natural,
    -- | Frame capture will encode the first frame of the output stream, then one
    -- frame every framerateDenominator\/framerateNumerator seconds. For
    -- example, settings of framerateNumerator = 1 and framerateDenominator = 3
    -- (a rate of 1\/3 frame per second) will capture the first frame, then 1
    -- frame every 3s. Files will be named as filename.NNNNNNN.jpg where N is
    -- the 0-based frame sequence number zero padded to 7 decimal places.
    FrameCaptureSettings -> Maybe Natural
framerateNumerator :: 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:
--
-- 'quality', 'frameCaptureSettings_quality' - JPEG Quality - a higher value equals higher quality.
--
-- 'framerateDenominator', 'frameCaptureSettings_framerateDenominator' - Frame capture will encode the first frame of the output stream, then one
-- frame every framerateDenominator\/framerateNumerator seconds. For
-- example, settings of framerateNumerator = 1 and framerateDenominator = 3
-- (a rate of 1\/3 frame per second) will capture the first frame, then 1
-- frame every 3s. Files will be named as filename.n.jpg where n is the
-- 0-based sequence number of each Capture.
--
-- 'maxCaptures', 'frameCaptureSettings_maxCaptures' - Maximum number of captures (encoded jpg output files).
--
-- 'framerateNumerator', 'frameCaptureSettings_framerateNumerator' - Frame capture will encode the first frame of the output stream, then one
-- frame every framerateDenominator\/framerateNumerator seconds. For
-- example, settings of framerateNumerator = 1 and framerateDenominator = 3
-- (a rate of 1\/3 frame per second) will capture the first frame, then 1
-- frame every 3s. Files will be named as filename.NNNNNNN.jpg where N is
-- the 0-based frame sequence number zero padded to 7 decimal places.
newFrameCaptureSettings ::
  FrameCaptureSettings
newFrameCaptureSettings :: FrameCaptureSettings
newFrameCaptureSettings =
  FrameCaptureSettings' :: Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> FrameCaptureSettings
FrameCaptureSettings'
    { $sel:quality:FrameCaptureSettings' :: Maybe Natural
quality = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:framerateDenominator:FrameCaptureSettings' :: Maybe Natural
framerateDenominator = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxCaptures:FrameCaptureSettings' :: Maybe Natural
maxCaptures = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:framerateNumerator:FrameCaptureSettings' :: Maybe Natural
framerateNumerator = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | JPEG Quality - a higher value equals higher quality.
frameCaptureSettings_quality :: Lens.Lens' FrameCaptureSettings (Prelude.Maybe Prelude.Natural)
frameCaptureSettings_quality :: (Maybe Natural -> f (Maybe Natural))
-> FrameCaptureSettings -> f FrameCaptureSettings
frameCaptureSettings_quality = (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
quality :: Maybe Natural
$sel:quality:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
quality} -> Maybe Natural
quality) (\s :: FrameCaptureSettings
s@FrameCaptureSettings' {} Maybe Natural
a -> FrameCaptureSettings
s {$sel:quality:FrameCaptureSettings' :: Maybe Natural
quality = Maybe Natural
a} :: FrameCaptureSettings)

-- | Frame capture will encode the first frame of the output stream, then one
-- frame every framerateDenominator\/framerateNumerator seconds. For
-- example, settings of framerateNumerator = 1 and framerateDenominator = 3
-- (a rate of 1\/3 frame per second) will capture the first frame, then 1
-- frame every 3s. Files will be named as filename.n.jpg where n is the
-- 0-based sequence number of each Capture.
frameCaptureSettings_framerateDenominator :: Lens.Lens' FrameCaptureSettings (Prelude.Maybe Prelude.Natural)
frameCaptureSettings_framerateDenominator :: (Maybe Natural -> f (Maybe Natural))
-> FrameCaptureSettings -> f FrameCaptureSettings
frameCaptureSettings_framerateDenominator = (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
framerateDenominator :: Maybe Natural
$sel:framerateDenominator:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
framerateDenominator} -> Maybe Natural
framerateDenominator) (\s :: FrameCaptureSettings
s@FrameCaptureSettings' {} Maybe Natural
a -> FrameCaptureSettings
s {$sel:framerateDenominator:FrameCaptureSettings' :: Maybe Natural
framerateDenominator = Maybe Natural
a} :: FrameCaptureSettings)

-- | Maximum number of captures (encoded jpg output files).
frameCaptureSettings_maxCaptures :: Lens.Lens' FrameCaptureSettings (Prelude.Maybe Prelude.Natural)
frameCaptureSettings_maxCaptures :: (Maybe Natural -> f (Maybe Natural))
-> FrameCaptureSettings -> f FrameCaptureSettings
frameCaptureSettings_maxCaptures = (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
maxCaptures :: Maybe Natural
$sel:maxCaptures:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
maxCaptures} -> Maybe Natural
maxCaptures) (\s :: FrameCaptureSettings
s@FrameCaptureSettings' {} Maybe Natural
a -> FrameCaptureSettings
s {$sel:maxCaptures:FrameCaptureSettings' :: Maybe Natural
maxCaptures = Maybe Natural
a} :: FrameCaptureSettings)

-- | Frame capture will encode the first frame of the output stream, then one
-- frame every framerateDenominator\/framerateNumerator seconds. For
-- example, settings of framerateNumerator = 1 and framerateDenominator = 3
-- (a rate of 1\/3 frame per second) will capture the first frame, then 1
-- frame every 3s. Files will be named as filename.NNNNNNN.jpg where N is
-- the 0-based frame sequence number zero padded to 7 decimal places.
frameCaptureSettings_framerateNumerator :: Lens.Lens' FrameCaptureSettings (Prelude.Maybe Prelude.Natural)
frameCaptureSettings_framerateNumerator :: (Maybe Natural -> f (Maybe Natural))
-> FrameCaptureSettings -> f FrameCaptureSettings
frameCaptureSettings_framerateNumerator = (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
framerateNumerator :: Maybe Natural
$sel:framerateNumerator:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
framerateNumerator} -> Maybe Natural
framerateNumerator) (\s :: FrameCaptureSettings
s@FrameCaptureSettings' {} Maybe Natural
a -> FrameCaptureSettings
s {$sel:framerateNumerator:FrameCaptureSettings' :: Maybe Natural
framerateNumerator = 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 Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> FrameCaptureSettings
FrameCaptureSettings'
            (Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> FrameCaptureSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural -> Maybe Natural -> FrameCaptureSettings)
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
"quality")
            Parser
  (Maybe Natural
   -> Maybe Natural -> Maybe Natural -> FrameCaptureSettings)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> 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
"framerateDenominator")
            Parser (Maybe Natural -> Maybe Natural -> FrameCaptureSettings)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> 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
"maxCaptures")
            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
"framerateNumerator")
      )

instance Prelude.Hashable FrameCaptureSettings

instance Prelude.NFData FrameCaptureSettings

instance Core.ToJSON FrameCaptureSettings where
  toJSON :: FrameCaptureSettings -> Value
toJSON FrameCaptureSettings' {Maybe Natural
framerateNumerator :: Maybe Natural
maxCaptures :: Maybe Natural
framerateDenominator :: Maybe Natural
quality :: Maybe Natural
$sel:framerateNumerator:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
$sel:maxCaptures:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
$sel:framerateDenominator:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
$sel:quality:FrameCaptureSettings' :: FrameCaptureSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"quality" 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
quality,
            (Text
"framerateDenominator" 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
framerateDenominator,
            (Text
"maxCaptures" 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
maxCaptures,
            (Text
"framerateNumerator" 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
framerateNumerator
          ]
      )