{-# 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.Mp2Settings
-- 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.Mp2Settings 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.Mp2CodingMode
import qualified Amazonka.Prelude as Prelude

-- | Mp2 Settings
--
-- /See:/ 'newMp2Settings' smart constructor.
data Mp2Settings = Mp2Settings'
  { -- | Average bitrate in bits\/second.
    Mp2Settings -> Maybe Double
bitrate :: Prelude.Maybe Prelude.Double,
    -- | The MPEG2 Audio coding mode. Valid values are codingMode10 (for mono) or
    -- codingMode20 (for stereo).
    Mp2Settings -> Maybe Mp2CodingMode
codingMode :: Prelude.Maybe Mp2CodingMode,
    -- | Sample rate in Hz.
    Mp2Settings -> Maybe Double
sampleRate :: Prelude.Maybe Prelude.Double
  }
  deriving (Mp2Settings -> Mp2Settings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Mp2Settings -> Mp2Settings -> Bool
$c/= :: Mp2Settings -> Mp2Settings -> Bool
== :: Mp2Settings -> Mp2Settings -> Bool
$c== :: Mp2Settings -> Mp2Settings -> Bool
Prelude.Eq, ReadPrec [Mp2Settings]
ReadPrec Mp2Settings
Int -> ReadS Mp2Settings
ReadS [Mp2Settings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Mp2Settings]
$creadListPrec :: ReadPrec [Mp2Settings]
readPrec :: ReadPrec Mp2Settings
$creadPrec :: ReadPrec Mp2Settings
readList :: ReadS [Mp2Settings]
$creadList :: ReadS [Mp2Settings]
readsPrec :: Int -> ReadS Mp2Settings
$creadsPrec :: Int -> ReadS Mp2Settings
Prelude.Read, Int -> Mp2Settings -> ShowS
[Mp2Settings] -> ShowS
Mp2Settings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Mp2Settings] -> ShowS
$cshowList :: [Mp2Settings] -> ShowS
show :: Mp2Settings -> String
$cshow :: Mp2Settings -> String
showsPrec :: Int -> Mp2Settings -> ShowS
$cshowsPrec :: Int -> Mp2Settings -> ShowS
Prelude.Show, forall x. Rep Mp2Settings x -> Mp2Settings
forall x. Mp2Settings -> Rep Mp2Settings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Mp2Settings x -> Mp2Settings
$cfrom :: forall x. Mp2Settings -> Rep Mp2Settings x
Prelude.Generic)

-- |
-- Create a value of 'Mp2Settings' 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:
--
-- 'bitrate', 'mp2Settings_bitrate' - Average bitrate in bits\/second.
--
-- 'codingMode', 'mp2Settings_codingMode' - The MPEG2 Audio coding mode. Valid values are codingMode10 (for mono) or
-- codingMode20 (for stereo).
--
-- 'sampleRate', 'mp2Settings_sampleRate' - Sample rate in Hz.
newMp2Settings ::
  Mp2Settings
newMp2Settings :: Mp2Settings
newMp2Settings =
  Mp2Settings'
    { $sel:bitrate:Mp2Settings' :: Maybe Double
bitrate = forall a. Maybe a
Prelude.Nothing,
      $sel:codingMode:Mp2Settings' :: Maybe Mp2CodingMode
codingMode = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:Mp2Settings' :: Maybe Double
sampleRate = forall a. Maybe a
Prelude.Nothing
    }

-- | Average bitrate in bits\/second.
mp2Settings_bitrate :: Lens.Lens' Mp2Settings (Prelude.Maybe Prelude.Double)
mp2Settings_bitrate :: Lens' Mp2Settings (Maybe Double)
mp2Settings_bitrate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp2Settings' {Maybe Double
bitrate :: Maybe Double
$sel:bitrate:Mp2Settings' :: Mp2Settings -> Maybe Double
bitrate} -> Maybe Double
bitrate) (\s :: Mp2Settings
s@Mp2Settings' {} Maybe Double
a -> Mp2Settings
s {$sel:bitrate:Mp2Settings' :: Maybe Double
bitrate = Maybe Double
a} :: Mp2Settings)

-- | The MPEG2 Audio coding mode. Valid values are codingMode10 (for mono) or
-- codingMode20 (for stereo).
mp2Settings_codingMode :: Lens.Lens' Mp2Settings (Prelude.Maybe Mp2CodingMode)
mp2Settings_codingMode :: Lens' Mp2Settings (Maybe Mp2CodingMode)
mp2Settings_codingMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp2Settings' {Maybe Mp2CodingMode
codingMode :: Maybe Mp2CodingMode
$sel:codingMode:Mp2Settings' :: Mp2Settings -> Maybe Mp2CodingMode
codingMode} -> Maybe Mp2CodingMode
codingMode) (\s :: Mp2Settings
s@Mp2Settings' {} Maybe Mp2CodingMode
a -> Mp2Settings
s {$sel:codingMode:Mp2Settings' :: Maybe Mp2CodingMode
codingMode = Maybe Mp2CodingMode
a} :: Mp2Settings)

-- | Sample rate in Hz.
mp2Settings_sampleRate :: Lens.Lens' Mp2Settings (Prelude.Maybe Prelude.Double)
mp2Settings_sampleRate :: Lens' Mp2Settings (Maybe Double)
mp2Settings_sampleRate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp2Settings' {Maybe Double
sampleRate :: Maybe Double
$sel:sampleRate:Mp2Settings' :: Mp2Settings -> Maybe Double
sampleRate} -> Maybe Double
sampleRate) (\s :: Mp2Settings
s@Mp2Settings' {} Maybe Double
a -> Mp2Settings
s {$sel:sampleRate:Mp2Settings' :: Maybe Double
sampleRate = Maybe Double
a} :: Mp2Settings)

instance Data.FromJSON Mp2Settings where
  parseJSON :: Value -> Parser Mp2Settings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Mp2Settings"
      ( \Object
x ->
          Maybe Double -> Maybe Mp2CodingMode -> Maybe Double -> Mp2Settings
Mp2Settings'
            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
"bitrate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"codingMode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sampleRate")
      )

instance Prelude.Hashable Mp2Settings where
  hashWithSalt :: Int -> Mp2Settings -> Int
hashWithSalt Int
_salt Mp2Settings' {Maybe Double
Maybe Mp2CodingMode
sampleRate :: Maybe Double
codingMode :: Maybe Mp2CodingMode
bitrate :: Maybe Double
$sel:sampleRate:Mp2Settings' :: Mp2Settings -> Maybe Double
$sel:codingMode:Mp2Settings' :: Mp2Settings -> Maybe Mp2CodingMode
$sel:bitrate:Mp2Settings' :: Mp2Settings -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
bitrate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Mp2CodingMode
codingMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
sampleRate

instance Prelude.NFData Mp2Settings where
  rnf :: Mp2Settings -> ()
rnf Mp2Settings' {Maybe Double
Maybe Mp2CodingMode
sampleRate :: Maybe Double
codingMode :: Maybe Mp2CodingMode
bitrate :: Maybe Double
$sel:sampleRate:Mp2Settings' :: Mp2Settings -> Maybe Double
$sel:codingMode:Mp2Settings' :: Mp2Settings -> Maybe Mp2CodingMode
$sel:bitrate:Mp2Settings' :: Mp2Settings -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
bitrate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Mp2CodingMode
codingMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
sampleRate

instance Data.ToJSON Mp2Settings where
  toJSON :: Mp2Settings -> Value
toJSON Mp2Settings' {Maybe Double
Maybe Mp2CodingMode
sampleRate :: Maybe Double
codingMode :: Maybe Mp2CodingMode
bitrate :: Maybe Double
$sel:sampleRate:Mp2Settings' :: Mp2Settings -> Maybe Double
$sel:codingMode:Mp2Settings' :: Mp2Settings -> Maybe Mp2CodingMode
$sel:bitrate:Mp2Settings' :: Mp2Settings -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"bitrate" 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 Double
bitrate,
            (Key
"codingMode" 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 Mp2CodingMode
codingMode,
            (Key
"sampleRate" 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 Double
sampleRate
          ]
      )