{-# 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-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.Mp2Settings 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 (AudioDescriptions)>(CodecSettings)
-- to the value MP2.
--
-- /See:/ 'newMp2Settings' smart constructor.
data Mp2Settings = 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 -> Maybe Natural
channels :: Prelude.Maybe Prelude.Natural,
    -- | Sample rate in hz.
    Mp2Settings -> Maybe Natural
sampleRate :: Prelude.Maybe Prelude.Natural,
    -- | Specify the average bitrate in bits per second.
    Mp2Settings -> Maybe Natural
bitrate :: Prelude.Maybe Prelude.Natural
  }
  deriving (Mp2Settings -> Mp2Settings -> Bool
(Mp2Settings -> Mp2Settings -> Bool)
-> (Mp2Settings -> Mp2Settings -> Bool) -> Eq Mp2Settings
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]
(Int -> ReadS Mp2Settings)
-> ReadS [Mp2Settings]
-> ReadPrec Mp2Settings
-> ReadPrec [Mp2Settings]
-> Read 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
(Int -> Mp2Settings -> ShowS)
-> (Mp2Settings -> String)
-> ([Mp2Settings] -> ShowS)
-> Show Mp2Settings
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. Mp2Settings -> Rep Mp2Settings x)
-> (forall x. Rep Mp2Settings x -> Mp2Settings)
-> Generic Mp2Settings
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:
--
-- '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.
--
-- 'bitrate', 'mp2Settings_bitrate' - Specify the average bitrate in bits per second.
newMp2Settings ::
  Mp2Settings
newMp2Settings :: Mp2Settings
newMp2Settings =
  Mp2Settings' :: Maybe Natural -> Maybe Natural -> Maybe Natural -> Mp2Settings
Mp2Settings'
    { $sel:channels:Mp2Settings' :: Maybe Natural
channels = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:Mp2Settings' :: Maybe Natural
sampleRate = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:bitrate:Mp2Settings' :: Maybe Natural
bitrate = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> Mp2Settings -> f Mp2Settings
mp2Settings_channels = (Mp2Settings -> Maybe Natural)
-> (Mp2Settings -> Maybe Natural -> Mp2Settings)
-> Lens Mp2Settings Mp2Settings (Maybe Natural) (Maybe Natural)
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 :: (Maybe Natural -> f (Maybe Natural))
-> Mp2Settings -> f Mp2Settings
mp2Settings_sampleRate = (Mp2Settings -> Maybe Natural)
-> (Mp2Settings -> Maybe Natural -> Mp2Settings)
-> Lens Mp2Settings Mp2Settings (Maybe Natural) (Maybe Natural)
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)

-- | Specify the average bitrate in bits per second.
mp2Settings_bitrate :: Lens.Lens' Mp2Settings (Prelude.Maybe Prelude.Natural)
mp2Settings_bitrate :: (Maybe Natural -> f (Maybe Natural))
-> Mp2Settings -> f Mp2Settings
mp2Settings_bitrate = (Mp2Settings -> Maybe Natural)
-> (Mp2Settings -> Maybe Natural -> Mp2Settings)
-> Lens Mp2Settings Mp2Settings (Maybe Natural) (Maybe Natural)
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)

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

instance Prelude.Hashable Mp2Settings

instance Prelude.NFData Mp2Settings

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