{-# 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.OpusSettings
-- 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.OpusSettings 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 OPUS.
--
-- /See:/ 'newOpusSettings' smart constructor.
data OpusSettings = OpusSettings'
  { -- | Specify the number of channels in this output audio track. Choosing Mono
    -- on the console gives you 1 output channel; choosing Stereo gives you 2.
    -- In the API, valid values are 1 and 2.
    OpusSettings -> Maybe Natural
channels :: Prelude.Maybe Prelude.Natural,
    -- | Optional. Sample rate in hz. Valid values are 16000, 24000, and 48000.
    -- The default value is 48000.
    OpusSettings -> Maybe Natural
sampleRate :: Prelude.Maybe Prelude.Natural,
    -- | Optional. Specify the average bitrate in bits per second. Valid values
    -- are multiples of 8000, from 32000 through 192000. The default value is
    -- 96000, which we recommend for quality and bandwidth.
    OpusSettings -> Maybe Natural
bitrate :: Prelude.Maybe Prelude.Natural
  }
  deriving (OpusSettings -> OpusSettings -> Bool
(OpusSettings -> OpusSettings -> Bool)
-> (OpusSettings -> OpusSettings -> Bool) -> Eq OpusSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpusSettings -> OpusSettings -> Bool
$c/= :: OpusSettings -> OpusSettings -> Bool
== :: OpusSettings -> OpusSettings -> Bool
$c== :: OpusSettings -> OpusSettings -> Bool
Prelude.Eq, ReadPrec [OpusSettings]
ReadPrec OpusSettings
Int -> ReadS OpusSettings
ReadS [OpusSettings]
(Int -> ReadS OpusSettings)
-> ReadS [OpusSettings]
-> ReadPrec OpusSettings
-> ReadPrec [OpusSettings]
-> Read OpusSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpusSettings]
$creadListPrec :: ReadPrec [OpusSettings]
readPrec :: ReadPrec OpusSettings
$creadPrec :: ReadPrec OpusSettings
readList :: ReadS [OpusSettings]
$creadList :: ReadS [OpusSettings]
readsPrec :: Int -> ReadS OpusSettings
$creadsPrec :: Int -> ReadS OpusSettings
Prelude.Read, Int -> OpusSettings -> ShowS
[OpusSettings] -> ShowS
OpusSettings -> String
(Int -> OpusSettings -> ShowS)
-> (OpusSettings -> String)
-> ([OpusSettings] -> ShowS)
-> Show OpusSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpusSettings] -> ShowS
$cshowList :: [OpusSettings] -> ShowS
show :: OpusSettings -> String
$cshow :: OpusSettings -> String
showsPrec :: Int -> OpusSettings -> ShowS
$cshowsPrec :: Int -> OpusSettings -> ShowS
Prelude.Show, (forall x. OpusSettings -> Rep OpusSettings x)
-> (forall x. Rep OpusSettings x -> OpusSettings)
-> Generic OpusSettings
forall x. Rep OpusSettings x -> OpusSettings
forall x. OpusSettings -> Rep OpusSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpusSettings x -> OpusSettings
$cfrom :: forall x. OpusSettings -> Rep OpusSettings x
Prelude.Generic)

-- |
-- Create a value of 'OpusSettings' 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', 'opusSettings_channels' - Specify the number of channels in this output audio track. Choosing Mono
-- on the console gives you 1 output channel; choosing Stereo gives you 2.
-- In the API, valid values are 1 and 2.
--
-- 'sampleRate', 'opusSettings_sampleRate' - Optional. Sample rate in hz. Valid values are 16000, 24000, and 48000.
-- The default value is 48000.
--
-- 'bitrate', 'opusSettings_bitrate' - Optional. Specify the average bitrate in bits per second. Valid values
-- are multiples of 8000, from 32000 through 192000. The default value is
-- 96000, which we recommend for quality and bandwidth.
newOpusSettings ::
  OpusSettings
newOpusSettings :: OpusSettings
newOpusSettings =
  OpusSettings' :: Maybe Natural -> Maybe Natural -> Maybe Natural -> OpusSettings
OpusSettings'
    { $sel:channels:OpusSettings' :: Maybe Natural
channels = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:OpusSettings' :: Maybe Natural
sampleRate = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:bitrate:OpusSettings' :: Maybe Natural
bitrate = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the number of channels in this output audio track. Choosing Mono
-- on the console gives you 1 output channel; choosing Stereo gives you 2.
-- In the API, valid values are 1 and 2.
opusSettings_channels :: Lens.Lens' OpusSettings (Prelude.Maybe Prelude.Natural)
opusSettings_channels :: (Maybe Natural -> f (Maybe Natural))
-> OpusSettings -> f OpusSettings
opusSettings_channels = (OpusSettings -> Maybe Natural)
-> (OpusSettings -> Maybe Natural -> OpusSettings)
-> Lens OpusSettings OpusSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpusSettings' {Maybe Natural
channels :: Maybe Natural
$sel:channels:OpusSettings' :: OpusSettings -> Maybe Natural
channels} -> Maybe Natural
channels) (\s :: OpusSettings
s@OpusSettings' {} Maybe Natural
a -> OpusSettings
s {$sel:channels:OpusSettings' :: Maybe Natural
channels = Maybe Natural
a} :: OpusSettings)

-- | Optional. Sample rate in hz. Valid values are 16000, 24000, and 48000.
-- The default value is 48000.
opusSettings_sampleRate :: Lens.Lens' OpusSettings (Prelude.Maybe Prelude.Natural)
opusSettings_sampleRate :: (Maybe Natural -> f (Maybe Natural))
-> OpusSettings -> f OpusSettings
opusSettings_sampleRate = (OpusSettings -> Maybe Natural)
-> (OpusSettings -> Maybe Natural -> OpusSettings)
-> Lens OpusSettings OpusSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpusSettings' {Maybe Natural
sampleRate :: Maybe Natural
$sel:sampleRate:OpusSettings' :: OpusSettings -> Maybe Natural
sampleRate} -> Maybe Natural
sampleRate) (\s :: OpusSettings
s@OpusSettings' {} Maybe Natural
a -> OpusSettings
s {$sel:sampleRate:OpusSettings' :: Maybe Natural
sampleRate = Maybe Natural
a} :: OpusSettings)

-- | Optional. Specify the average bitrate in bits per second. Valid values
-- are multiples of 8000, from 32000 through 192000. The default value is
-- 96000, which we recommend for quality and bandwidth.
opusSettings_bitrate :: Lens.Lens' OpusSettings (Prelude.Maybe Prelude.Natural)
opusSettings_bitrate :: (Maybe Natural -> f (Maybe Natural))
-> OpusSettings -> f OpusSettings
opusSettings_bitrate = (OpusSettings -> Maybe Natural)
-> (OpusSettings -> Maybe Natural -> OpusSettings)
-> Lens OpusSettings OpusSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpusSettings' {Maybe Natural
bitrate :: Maybe Natural
$sel:bitrate:OpusSettings' :: OpusSettings -> Maybe Natural
bitrate} -> Maybe Natural
bitrate) (\s :: OpusSettings
s@OpusSettings' {} Maybe Natural
a -> OpusSettings
s {$sel:bitrate:OpusSettings' :: Maybe Natural
bitrate = Maybe Natural
a} :: OpusSettings)

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

instance Prelude.NFData OpusSettings

instance Core.ToJSON OpusSettings where
  toJSON :: OpusSettings -> Value
toJSON OpusSettings' {Maybe Natural
bitrate :: Maybe Natural
sampleRate :: Maybe Natural
channels :: Maybe Natural
$sel:bitrate:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:sampleRate:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:channels:OpusSettings' :: OpusSettings -> 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
          ]
      )