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

-- | Audio Language Selection
--
-- /See:/ 'newAudioLanguageSelection' smart constructor.
data AudioLanguageSelection = AudioLanguageSelection'
  { -- | When set to \"strict\", the transport stream demux strictly identifies
    -- audio streams by their language descriptor. If a PMT update occurs such
    -- that an audio stream matching the initially selected language is no
    -- longer present then mute will be encoded until the language returns. If
    -- \"loose\", then on a PMT update the demux will choose another audio
    -- stream in the program with the same stream type if it can\'t find one
    -- with the same language.
    AudioLanguageSelection -> Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy :: Prelude.Maybe AudioLanguageSelectionPolicy,
    -- | Selects a specific three-letter language code from within an audio
    -- source.
    AudioLanguageSelection -> Text
languageCode :: Prelude.Text
  }
  deriving (AudioLanguageSelection -> AudioLanguageSelection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioLanguageSelection -> AudioLanguageSelection -> Bool
$c/= :: AudioLanguageSelection -> AudioLanguageSelection -> Bool
== :: AudioLanguageSelection -> AudioLanguageSelection -> Bool
$c== :: AudioLanguageSelection -> AudioLanguageSelection -> Bool
Prelude.Eq, ReadPrec [AudioLanguageSelection]
ReadPrec AudioLanguageSelection
Int -> ReadS AudioLanguageSelection
ReadS [AudioLanguageSelection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioLanguageSelection]
$creadListPrec :: ReadPrec [AudioLanguageSelection]
readPrec :: ReadPrec AudioLanguageSelection
$creadPrec :: ReadPrec AudioLanguageSelection
readList :: ReadS [AudioLanguageSelection]
$creadList :: ReadS [AudioLanguageSelection]
readsPrec :: Int -> ReadS AudioLanguageSelection
$creadsPrec :: Int -> ReadS AudioLanguageSelection
Prelude.Read, Int -> AudioLanguageSelection -> ShowS
[AudioLanguageSelection] -> ShowS
AudioLanguageSelection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioLanguageSelection] -> ShowS
$cshowList :: [AudioLanguageSelection] -> ShowS
show :: AudioLanguageSelection -> String
$cshow :: AudioLanguageSelection -> String
showsPrec :: Int -> AudioLanguageSelection -> ShowS
$cshowsPrec :: Int -> AudioLanguageSelection -> ShowS
Prelude.Show, forall x. Rep AudioLanguageSelection x -> AudioLanguageSelection
forall x. AudioLanguageSelection -> Rep AudioLanguageSelection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AudioLanguageSelection x -> AudioLanguageSelection
$cfrom :: forall x. AudioLanguageSelection -> Rep AudioLanguageSelection x
Prelude.Generic)

-- |
-- Create a value of 'AudioLanguageSelection' 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:
--
-- 'languageSelectionPolicy', 'audioLanguageSelection_languageSelectionPolicy' - When set to \"strict\", the transport stream demux strictly identifies
-- audio streams by their language descriptor. If a PMT update occurs such
-- that an audio stream matching the initially selected language is no
-- longer present then mute will be encoded until the language returns. If
-- \"loose\", then on a PMT update the demux will choose another audio
-- stream in the program with the same stream type if it can\'t find one
-- with the same language.
--
-- 'languageCode', 'audioLanguageSelection_languageCode' - Selects a specific three-letter language code from within an audio
-- source.
newAudioLanguageSelection ::
  -- | 'languageCode'
  Prelude.Text ->
  AudioLanguageSelection
newAudioLanguageSelection :: Text -> AudioLanguageSelection
newAudioLanguageSelection Text
pLanguageCode_ =
  AudioLanguageSelection'
    { $sel:languageSelectionPolicy:AudioLanguageSelection' :: Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:languageCode:AudioLanguageSelection' :: Text
languageCode = Text
pLanguageCode_
    }

-- | When set to \"strict\", the transport stream demux strictly identifies
-- audio streams by their language descriptor. If a PMT update occurs such
-- that an audio stream matching the initially selected language is no
-- longer present then mute will be encoded until the language returns. If
-- \"loose\", then on a PMT update the demux will choose another audio
-- stream in the program with the same stream type if it can\'t find one
-- with the same language.
audioLanguageSelection_languageSelectionPolicy :: Lens.Lens' AudioLanguageSelection (Prelude.Maybe AudioLanguageSelectionPolicy)
audioLanguageSelection_languageSelectionPolicy :: Lens' AudioLanguageSelection (Maybe AudioLanguageSelectionPolicy)
audioLanguageSelection_languageSelectionPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioLanguageSelection' {Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy :: Maybe AudioLanguageSelectionPolicy
$sel:languageSelectionPolicy:AudioLanguageSelection' :: AudioLanguageSelection -> Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy} -> Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy) (\s :: AudioLanguageSelection
s@AudioLanguageSelection' {} Maybe AudioLanguageSelectionPolicy
a -> AudioLanguageSelection
s {$sel:languageSelectionPolicy:AudioLanguageSelection' :: Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy = Maybe AudioLanguageSelectionPolicy
a} :: AudioLanguageSelection)

-- | Selects a specific three-letter language code from within an audio
-- source.
audioLanguageSelection_languageCode :: Lens.Lens' AudioLanguageSelection Prelude.Text
audioLanguageSelection_languageCode :: Lens' AudioLanguageSelection Text
audioLanguageSelection_languageCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioLanguageSelection' {Text
languageCode :: Text
$sel:languageCode:AudioLanguageSelection' :: AudioLanguageSelection -> Text
languageCode} -> Text
languageCode) (\s :: AudioLanguageSelection
s@AudioLanguageSelection' {} Text
a -> AudioLanguageSelection
s {$sel:languageCode:AudioLanguageSelection' :: Text
languageCode = Text
a} :: AudioLanguageSelection)

instance Data.FromJSON AudioLanguageSelection where
  parseJSON :: Value -> Parser AudioLanguageSelection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AudioLanguageSelection"
      ( \Object
x ->
          Maybe AudioLanguageSelectionPolicy
-> Text -> AudioLanguageSelection
AudioLanguageSelection'
            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
"languageSelectionPolicy")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"languageCode")
      )

instance Prelude.Hashable AudioLanguageSelection where
  hashWithSalt :: Int -> AudioLanguageSelection -> Int
hashWithSalt Int
_salt AudioLanguageSelection' {Maybe AudioLanguageSelectionPolicy
Text
languageCode :: Text
languageSelectionPolicy :: Maybe AudioLanguageSelectionPolicy
$sel:languageCode:AudioLanguageSelection' :: AudioLanguageSelection -> Text
$sel:languageSelectionPolicy:AudioLanguageSelection' :: AudioLanguageSelection -> Maybe AudioLanguageSelectionPolicy
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
languageCode

instance Prelude.NFData AudioLanguageSelection where
  rnf :: AudioLanguageSelection -> ()
rnf AudioLanguageSelection' {Maybe AudioLanguageSelectionPolicy
Text
languageCode :: Text
languageSelectionPolicy :: Maybe AudioLanguageSelectionPolicy
$sel:languageCode:AudioLanguageSelection' :: AudioLanguageSelection -> Text
$sel:languageSelectionPolicy:AudioLanguageSelection' :: AudioLanguageSelection -> Maybe AudioLanguageSelectionPolicy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
languageCode

instance Data.ToJSON AudioLanguageSelection where
  toJSON :: AudioLanguageSelection -> Value
toJSON AudioLanguageSelection' {Maybe AudioLanguageSelectionPolicy
Text
languageCode :: Text
languageSelectionPolicy :: Maybe AudioLanguageSelectionPolicy
$sel:languageCode:AudioLanguageSelection' :: AudioLanguageSelection -> Text
$sel:languageSelectionPolicy:AudioLanguageSelection' :: AudioLanguageSelection -> Maybe AudioLanguageSelectionPolicy
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"languageSelectionPolicy" 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 AudioLanguageSelectionPolicy
languageSelectionPolicy,
            forall a. a -> Maybe a
Prelude.Just (Key
"languageCode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
languageCode)
          ]
      )