{-# 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-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.OpusSettings 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 OPUS.
--
-- /See:/ 'newOpusSettings' smart constructor.
data OpusSettings = 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 -> Maybe Natural
bitrate :: Prelude.Maybe Prelude.Natural,
    -- | 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
  }
  deriving (OpusSettings -> OpusSettings -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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.
newOpusSettings ::
  OpusSettings
newOpusSettings :: OpusSettings
newOpusSettings =
  OpusSettings'
    { $sel:bitrate:OpusSettings' :: Maybe Natural
bitrate = forall a. Maybe a
Prelude.Nothing,
      $sel:channels:OpusSettings' :: Maybe Natural
channels = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleRate:OpusSettings' :: Maybe Natural
sampleRate = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' OpusSettings (Maybe Natural)
opusSettings_bitrate = 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)

-- | 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 :: Lens' OpusSettings (Maybe Natural)
opusSettings_channels = 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 :: Lens' OpusSettings (Maybe Natural)
opusSettings_sampleRate = 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)

instance Data.FromJSON OpusSettings where
  parseJSON :: Value -> Parser OpusSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OpusSettings"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> Maybe Natural -> OpusSettings
OpusSettings'
            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 OpusSettings where
  hashWithSalt :: Int -> OpusSettings -> Int
hashWithSalt Int
_salt OpusSettings' {Maybe Natural
sampleRate :: Maybe Natural
channels :: Maybe Natural
bitrate :: Maybe Natural
$sel:sampleRate:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:channels:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:bitrate:OpusSettings' :: OpusSettings -> 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 OpusSettings where
  rnf :: OpusSettings -> ()
rnf OpusSettings' {Maybe Natural
sampleRate :: Maybe Natural
channels :: Maybe Natural
bitrate :: Maybe Natural
$sel:sampleRate:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:channels:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:bitrate:OpusSettings' :: OpusSettings -> 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 OpusSettings where
  toJSON :: OpusSettings -> Value
toJSON OpusSettings' {Maybe Natural
sampleRate :: Maybe Natural
channels :: Maybe Natural
bitrate :: Maybe Natural
$sel:sampleRate:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:channels:OpusSettings' :: OpusSettings -> Maybe Natural
$sel:bitrate:OpusSettings' :: OpusSettings -> 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
          ]
      )