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

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

-- | The video configuration for each program in a multiplex.
--
-- /See:/ 'newMultiplexVideoSettings' smart constructor.
data MultiplexVideoSettings = MultiplexVideoSettings'
  { -- | Statmux rate control settings. When this field is defined,
    -- ConstantBitrate must be undefined.
    MultiplexVideoSettings -> Maybe MultiplexStatmuxVideoSettings
statmuxSettings :: Prelude.Maybe MultiplexStatmuxVideoSettings,
    -- | The constant bitrate configuration for the video encode. When this field
    -- is defined, StatmuxSettings must be undefined.
    MultiplexVideoSettings -> Maybe Natural
constantBitrate :: Prelude.Maybe Prelude.Natural
  }
  deriving (MultiplexVideoSettings -> MultiplexVideoSettings -> Bool
(MultiplexVideoSettings -> MultiplexVideoSettings -> Bool)
-> (MultiplexVideoSettings -> MultiplexVideoSettings -> Bool)
-> Eq MultiplexVideoSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MultiplexVideoSettings -> MultiplexVideoSettings -> Bool
$c/= :: MultiplexVideoSettings -> MultiplexVideoSettings -> Bool
== :: MultiplexVideoSettings -> MultiplexVideoSettings -> Bool
$c== :: MultiplexVideoSettings -> MultiplexVideoSettings -> Bool
Prelude.Eq, ReadPrec [MultiplexVideoSettings]
ReadPrec MultiplexVideoSettings
Int -> ReadS MultiplexVideoSettings
ReadS [MultiplexVideoSettings]
(Int -> ReadS MultiplexVideoSettings)
-> ReadS [MultiplexVideoSettings]
-> ReadPrec MultiplexVideoSettings
-> ReadPrec [MultiplexVideoSettings]
-> Read MultiplexVideoSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MultiplexVideoSettings]
$creadListPrec :: ReadPrec [MultiplexVideoSettings]
readPrec :: ReadPrec MultiplexVideoSettings
$creadPrec :: ReadPrec MultiplexVideoSettings
readList :: ReadS [MultiplexVideoSettings]
$creadList :: ReadS [MultiplexVideoSettings]
readsPrec :: Int -> ReadS MultiplexVideoSettings
$creadsPrec :: Int -> ReadS MultiplexVideoSettings
Prelude.Read, Int -> MultiplexVideoSettings -> ShowS
[MultiplexVideoSettings] -> ShowS
MultiplexVideoSettings -> String
(Int -> MultiplexVideoSettings -> ShowS)
-> (MultiplexVideoSettings -> String)
-> ([MultiplexVideoSettings] -> ShowS)
-> Show MultiplexVideoSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MultiplexVideoSettings] -> ShowS
$cshowList :: [MultiplexVideoSettings] -> ShowS
show :: MultiplexVideoSettings -> String
$cshow :: MultiplexVideoSettings -> String
showsPrec :: Int -> MultiplexVideoSettings -> ShowS
$cshowsPrec :: Int -> MultiplexVideoSettings -> ShowS
Prelude.Show, (forall x. MultiplexVideoSettings -> Rep MultiplexVideoSettings x)
-> (forall x.
    Rep MultiplexVideoSettings x -> MultiplexVideoSettings)
-> Generic MultiplexVideoSettings
forall x. Rep MultiplexVideoSettings x -> MultiplexVideoSettings
forall x. MultiplexVideoSettings -> Rep MultiplexVideoSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MultiplexVideoSettings x -> MultiplexVideoSettings
$cfrom :: forall x. MultiplexVideoSettings -> Rep MultiplexVideoSettings x
Prelude.Generic)

-- |
-- Create a value of 'MultiplexVideoSettings' 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:
--
-- 'statmuxSettings', 'multiplexVideoSettings_statmuxSettings' - Statmux rate control settings. When this field is defined,
-- ConstantBitrate must be undefined.
--
-- 'constantBitrate', 'multiplexVideoSettings_constantBitrate' - The constant bitrate configuration for the video encode. When this field
-- is defined, StatmuxSettings must be undefined.
newMultiplexVideoSettings ::
  MultiplexVideoSettings
newMultiplexVideoSettings :: MultiplexVideoSettings
newMultiplexVideoSettings =
  MultiplexVideoSettings' :: Maybe MultiplexStatmuxVideoSettings
-> Maybe Natural -> MultiplexVideoSettings
MultiplexVideoSettings'
    { $sel:statmuxSettings:MultiplexVideoSettings' :: Maybe MultiplexStatmuxVideoSettings
statmuxSettings =
        Maybe MultiplexStatmuxVideoSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:constantBitrate:MultiplexVideoSettings' :: Maybe Natural
constantBitrate = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Statmux rate control settings. When this field is defined,
-- ConstantBitrate must be undefined.
multiplexVideoSettings_statmuxSettings :: Lens.Lens' MultiplexVideoSettings (Prelude.Maybe MultiplexStatmuxVideoSettings)
multiplexVideoSettings_statmuxSettings :: (Maybe MultiplexStatmuxVideoSettings
 -> f (Maybe MultiplexStatmuxVideoSettings))
-> MultiplexVideoSettings -> f MultiplexVideoSettings
multiplexVideoSettings_statmuxSettings = (MultiplexVideoSettings -> Maybe MultiplexStatmuxVideoSettings)
-> (MultiplexVideoSettings
    -> Maybe MultiplexStatmuxVideoSettings -> MultiplexVideoSettings)
-> Lens
     MultiplexVideoSettings
     MultiplexVideoSettings
     (Maybe MultiplexStatmuxVideoSettings)
     (Maybe MultiplexStatmuxVideoSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultiplexVideoSettings' {Maybe MultiplexStatmuxVideoSettings
statmuxSettings :: Maybe MultiplexStatmuxVideoSettings
$sel:statmuxSettings:MultiplexVideoSettings' :: MultiplexVideoSettings -> Maybe MultiplexStatmuxVideoSettings
statmuxSettings} -> Maybe MultiplexStatmuxVideoSettings
statmuxSettings) (\s :: MultiplexVideoSettings
s@MultiplexVideoSettings' {} Maybe MultiplexStatmuxVideoSettings
a -> MultiplexVideoSettings
s {$sel:statmuxSettings:MultiplexVideoSettings' :: Maybe MultiplexStatmuxVideoSettings
statmuxSettings = Maybe MultiplexStatmuxVideoSettings
a} :: MultiplexVideoSettings)

-- | The constant bitrate configuration for the video encode. When this field
-- is defined, StatmuxSettings must be undefined.
multiplexVideoSettings_constantBitrate :: Lens.Lens' MultiplexVideoSettings (Prelude.Maybe Prelude.Natural)
multiplexVideoSettings_constantBitrate :: (Maybe Natural -> f (Maybe Natural))
-> MultiplexVideoSettings -> f MultiplexVideoSettings
multiplexVideoSettings_constantBitrate = (MultiplexVideoSettings -> Maybe Natural)
-> (MultiplexVideoSettings
    -> Maybe Natural -> MultiplexVideoSettings)
-> Lens
     MultiplexVideoSettings
     MultiplexVideoSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultiplexVideoSettings' {Maybe Natural
constantBitrate :: Maybe Natural
$sel:constantBitrate:MultiplexVideoSettings' :: MultiplexVideoSettings -> Maybe Natural
constantBitrate} -> Maybe Natural
constantBitrate) (\s :: MultiplexVideoSettings
s@MultiplexVideoSettings' {} Maybe Natural
a -> MultiplexVideoSettings
s {$sel:constantBitrate:MultiplexVideoSettings' :: Maybe Natural
constantBitrate = Maybe Natural
a} :: MultiplexVideoSettings)

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

instance Prelude.Hashable MultiplexVideoSettings

instance Prelude.NFData MultiplexVideoSettings

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