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

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

-- | Ignore this setting unless your input captions format is SCC. To have
-- the service compensate for differing frame rates between your input
-- captions and input video, specify the frame rate of the captions file.
-- Specify this value as a fraction. When you work directly in your JSON
-- job specification, use the settings framerateNumerator and
-- framerateDenominator. For example, you might specify 24 \/ 1 for 24 fps,
-- 25 \/ 1 for 25 fps, 24000 \/ 1001 for 23.976 fps, or 30000 \/ 1001 for
-- 29.97 fps.
--
-- /See:/ 'newCaptionSourceFramerate' smart constructor.
data CaptionSourceFramerate = CaptionSourceFramerate'
  { -- | Specify the denominator of the fraction that represents the frame rate
    -- for the setting Caption source frame rate (CaptionSourceFramerate). Use
    -- this setting along with the setting Framerate numerator
    -- (framerateNumerator).
    CaptionSourceFramerate -> Maybe Natural
framerateDenominator :: Prelude.Maybe Prelude.Natural,
    -- | Specify the numerator of the fraction that represents the frame rate for
    -- the setting Caption source frame rate (CaptionSourceFramerate). Use this
    -- setting along with the setting Framerate denominator
    -- (framerateDenominator).
    CaptionSourceFramerate -> Maybe Natural
framerateNumerator :: Prelude.Maybe Prelude.Natural
  }
  deriving (CaptionSourceFramerate -> CaptionSourceFramerate -> Bool
(CaptionSourceFramerate -> CaptionSourceFramerate -> Bool)
-> (CaptionSourceFramerate -> CaptionSourceFramerate -> Bool)
-> Eq CaptionSourceFramerate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptionSourceFramerate -> CaptionSourceFramerate -> Bool
$c/= :: CaptionSourceFramerate -> CaptionSourceFramerate -> Bool
== :: CaptionSourceFramerate -> CaptionSourceFramerate -> Bool
$c== :: CaptionSourceFramerate -> CaptionSourceFramerate -> Bool
Prelude.Eq, ReadPrec [CaptionSourceFramerate]
ReadPrec CaptionSourceFramerate
Int -> ReadS CaptionSourceFramerate
ReadS [CaptionSourceFramerate]
(Int -> ReadS CaptionSourceFramerate)
-> ReadS [CaptionSourceFramerate]
-> ReadPrec CaptionSourceFramerate
-> ReadPrec [CaptionSourceFramerate]
-> Read CaptionSourceFramerate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptionSourceFramerate]
$creadListPrec :: ReadPrec [CaptionSourceFramerate]
readPrec :: ReadPrec CaptionSourceFramerate
$creadPrec :: ReadPrec CaptionSourceFramerate
readList :: ReadS [CaptionSourceFramerate]
$creadList :: ReadS [CaptionSourceFramerate]
readsPrec :: Int -> ReadS CaptionSourceFramerate
$creadsPrec :: Int -> ReadS CaptionSourceFramerate
Prelude.Read, Int -> CaptionSourceFramerate -> ShowS
[CaptionSourceFramerate] -> ShowS
CaptionSourceFramerate -> String
(Int -> CaptionSourceFramerate -> ShowS)
-> (CaptionSourceFramerate -> String)
-> ([CaptionSourceFramerate] -> ShowS)
-> Show CaptionSourceFramerate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptionSourceFramerate] -> ShowS
$cshowList :: [CaptionSourceFramerate] -> ShowS
show :: CaptionSourceFramerate -> String
$cshow :: CaptionSourceFramerate -> String
showsPrec :: Int -> CaptionSourceFramerate -> ShowS
$cshowsPrec :: Int -> CaptionSourceFramerate -> ShowS
Prelude.Show, (forall x. CaptionSourceFramerate -> Rep CaptionSourceFramerate x)
-> (forall x.
    Rep CaptionSourceFramerate x -> CaptionSourceFramerate)
-> Generic CaptionSourceFramerate
forall x. Rep CaptionSourceFramerate x -> CaptionSourceFramerate
forall x. CaptionSourceFramerate -> Rep CaptionSourceFramerate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptionSourceFramerate x -> CaptionSourceFramerate
$cfrom :: forall x. CaptionSourceFramerate -> Rep CaptionSourceFramerate x
Prelude.Generic)

-- |
-- Create a value of 'CaptionSourceFramerate' 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:
--
-- 'framerateDenominator', 'captionSourceFramerate_framerateDenominator' - Specify the denominator of the fraction that represents the frame rate
-- for the setting Caption source frame rate (CaptionSourceFramerate). Use
-- this setting along with the setting Framerate numerator
-- (framerateNumerator).
--
-- 'framerateNumerator', 'captionSourceFramerate_framerateNumerator' - Specify the numerator of the fraction that represents the frame rate for
-- the setting Caption source frame rate (CaptionSourceFramerate). Use this
-- setting along with the setting Framerate denominator
-- (framerateDenominator).
newCaptionSourceFramerate ::
  CaptionSourceFramerate
newCaptionSourceFramerate :: CaptionSourceFramerate
newCaptionSourceFramerate =
  CaptionSourceFramerate' :: Maybe Natural -> Maybe Natural -> CaptionSourceFramerate
CaptionSourceFramerate'
    { $sel:framerateDenominator:CaptionSourceFramerate' :: Maybe Natural
framerateDenominator =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:framerateNumerator:CaptionSourceFramerate' :: Maybe Natural
framerateNumerator = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the denominator of the fraction that represents the frame rate
-- for the setting Caption source frame rate (CaptionSourceFramerate). Use
-- this setting along with the setting Framerate numerator
-- (framerateNumerator).
captionSourceFramerate_framerateDenominator :: Lens.Lens' CaptionSourceFramerate (Prelude.Maybe Prelude.Natural)
captionSourceFramerate_framerateDenominator :: (Maybe Natural -> f (Maybe Natural))
-> CaptionSourceFramerate -> f CaptionSourceFramerate
captionSourceFramerate_framerateDenominator = (CaptionSourceFramerate -> Maybe Natural)
-> (CaptionSourceFramerate
    -> Maybe Natural -> CaptionSourceFramerate)
-> Lens
     CaptionSourceFramerate
     CaptionSourceFramerate
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSourceFramerate' {Maybe Natural
framerateDenominator :: Maybe Natural
$sel:framerateDenominator:CaptionSourceFramerate' :: CaptionSourceFramerate -> Maybe Natural
framerateDenominator} -> Maybe Natural
framerateDenominator) (\s :: CaptionSourceFramerate
s@CaptionSourceFramerate' {} Maybe Natural
a -> CaptionSourceFramerate
s {$sel:framerateDenominator:CaptionSourceFramerate' :: Maybe Natural
framerateDenominator = Maybe Natural
a} :: CaptionSourceFramerate)

-- | Specify the numerator of the fraction that represents the frame rate for
-- the setting Caption source frame rate (CaptionSourceFramerate). Use this
-- setting along with the setting Framerate denominator
-- (framerateDenominator).
captionSourceFramerate_framerateNumerator :: Lens.Lens' CaptionSourceFramerate (Prelude.Maybe Prelude.Natural)
captionSourceFramerate_framerateNumerator :: (Maybe Natural -> f (Maybe Natural))
-> CaptionSourceFramerate -> f CaptionSourceFramerate
captionSourceFramerate_framerateNumerator = (CaptionSourceFramerate -> Maybe Natural)
-> (CaptionSourceFramerate
    -> Maybe Natural -> CaptionSourceFramerate)
-> Lens
     CaptionSourceFramerate
     CaptionSourceFramerate
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSourceFramerate' {Maybe Natural
framerateNumerator :: Maybe Natural
$sel:framerateNumerator:CaptionSourceFramerate' :: CaptionSourceFramerate -> Maybe Natural
framerateNumerator} -> Maybe Natural
framerateNumerator) (\s :: CaptionSourceFramerate
s@CaptionSourceFramerate' {} Maybe Natural
a -> CaptionSourceFramerate
s {$sel:framerateNumerator:CaptionSourceFramerate' :: Maybe Natural
framerateNumerator = Maybe Natural
a} :: CaptionSourceFramerate)

instance Core.FromJSON CaptionSourceFramerate where
  parseJSON :: Value -> Parser CaptionSourceFramerate
parseJSON =
    String
-> (Object -> Parser CaptionSourceFramerate)
-> Value
-> Parser CaptionSourceFramerate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CaptionSourceFramerate"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> CaptionSourceFramerate
CaptionSourceFramerate'
            (Maybe Natural -> Maybe Natural -> CaptionSourceFramerate)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> CaptionSourceFramerate)
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
"framerateDenominator")
            Parser (Maybe Natural -> CaptionSourceFramerate)
-> Parser (Maybe Natural) -> Parser CaptionSourceFramerate
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 CaptionSourceFramerate

instance Prelude.NFData CaptionSourceFramerate

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