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

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

-- | Required when you set (Codec) under (AudioDescriptions)>(CodecSettings)
-- to the value MP2.
--
-- /See:/ 'newMp2Settings' smart constructor.
data Mp2Settings = Mp2Settings'
  { -- | Specify the average bitrate in bits per second.
    Mp2Settings -> Maybe Natural
bitrate :: Prelude.Maybe Prelude.Natural,
    -- | Set Channels to specify the number of channels in this output audio
    -- track. Choosing Mono in the console will give you 1 output channel;
    -- choosing Stereo will give you 2. In the API, valid values are 1 and 2.
    Mp2Settings -> Maybe Natural
channels :: Prelude.Maybe Prelude.Natural,
    -- | Sample rate in hz.
    Mp2Settings -> Maybe Natural
sampleRate :: Prelude.Maybe Prelude.Natural
  }
  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' - Specify the average bitrate in bits per second.
--
-- 'channels', 'mp2Settings_channels' - Set Channels to specify the number of channels in this output audio
-- track. Choosing Mono in the console will give you 1 output channel;
-- choosing Stereo will give you 2. In the API, valid values are 1 and 2.
--
-- 'sampleRate', 'mp2Settings_sampleRate' - Sample rate in hz.
newMp2Settings ::
  Mp2Settings
newMp2Settings :: Mp2Settings
newMp2Settings =
  Mp2Settings'
    { $sel:bitrate:Mp2Settings' :: Maybe Natural
bitrate = forall a. Maybe a
Prelude.Nothing,
      $sel:channels:Mp2Settings' :: Maybe Natural
channels = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:Mp2Settings' :: Maybe Natural
sampleRate = forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the average bitrate in bits per second.
mp2Settings_bitrate :: Lens.Lens' Mp2Settings (Prelude.Maybe Prelude.Natural)
mp2Settings_bitrate :: Lens' Mp2Settings (Maybe Natural)
mp2Settings_bitrate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp2Settings' {Maybe Natural
bitrate :: Maybe Natural
$sel:bitrate:Mp2Settings' :: Mp2Settings -> Maybe Natural
bitrate} -> Maybe Natural
bitrate) (\s :: Mp2Settings
s@Mp2Settings' {} Maybe Natural
a -> Mp2Settings
s {$sel:bitrate:Mp2Settings' :: Maybe Natural
bitrate = Maybe Natural
a} :: Mp2Settings)

-- | Set Channels to specify the number of channels in this output audio
-- track. Choosing Mono in the console will give you 1 output channel;
-- choosing Stereo will give you 2. In the API, valid values are 1 and 2.
mp2Settings_channels :: Lens.Lens' Mp2Settings (Prelude.Maybe Prelude.Natural)
mp2Settings_channels :: Lens' Mp2Settings (Maybe Natural)
mp2Settings_channels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp2Settings' {Maybe Natural
channels :: Maybe Natural
$sel:channels:Mp2Settings' :: Mp2Settings -> Maybe Natural
channels} -> Maybe Natural
channels) (\s :: Mp2Settings
s@Mp2Settings' {} Maybe Natural
a -> Mp2Settings
s {$sel:channels:Mp2Settings' :: Maybe Natural
channels = Maybe Natural
a} :: Mp2Settings)

-- | Sample rate in hz.
mp2Settings_sampleRate :: Lens.Lens' Mp2Settings (Prelude.Maybe Prelude.Natural)
mp2Settings_sampleRate :: Lens' Mp2Settings (Maybe Natural)
mp2Settings_sampleRate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mp2Settings' {Maybe Natural
sampleRate :: Maybe Natural
$sel:sampleRate:Mp2Settings' :: Mp2Settings -> Maybe Natural
sampleRate} -> Maybe Natural
sampleRate) (\s :: Mp2Settings
s@Mp2Settings' {} Maybe Natural
a -> Mp2Settings
s {$sel:sampleRate:Mp2Settings' :: Maybe Natural
sampleRate = Maybe Natural
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 Natural -> Maybe Natural -> Maybe Natural -> 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
"channels")
            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 Natural
sampleRate :: Maybe Natural
channels :: Maybe Natural
bitrate :: Maybe Natural
$sel:sampleRate:Mp2Settings' :: Mp2Settings -> Maybe Natural
$sel:channels:Mp2Settings' :: Mp2Settings -> Maybe Natural
$sel:bitrate:Mp2Settings' :: Mp2Settings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
bitrate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
channels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
sampleRate

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

instance Data.ToJSON Mp2Settings where
  toJSON :: Mp2Settings -> Value
toJSON Mp2Settings' {Maybe Natural
sampleRate :: Maybe Natural
channels :: Maybe Natural
bitrate :: Maybe Natural
$sel:sampleRate:Mp2Settings' :: Mp2Settings -> Maybe Natural
$sel:channels:Mp2Settings' :: Mp2Settings -> Maybe Natural
$sel:bitrate:Mp2Settings' :: Mp2Settings -> Maybe Natural
..} =
    [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 Natural
bitrate,
            (Key
"channels" 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 Natural
channels,
            (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 Natural
sampleRate
          ]
      )