{-# 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-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.MediaLive.Types.AudioLanguageSelection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AudioLanguageSelection -> AudioLanguageSelection -> Bool)
-> (AudioLanguageSelection -> AudioLanguageSelection -> Bool)
-> Eq AudioLanguageSelection
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]
(Int -> ReadS AudioLanguageSelection)
-> ReadS [AudioLanguageSelection]
-> ReadPrec AudioLanguageSelection
-> ReadPrec [AudioLanguageSelection]
-> Read 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
(Int -> AudioLanguageSelection -> ShowS)
-> (AudioLanguageSelection -> String)
-> ([AudioLanguageSelection] -> ShowS)
-> Show AudioLanguageSelection
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. AudioLanguageSelection -> Rep AudioLanguageSelection x)
-> (forall x.
    Rep AudioLanguageSelection x -> AudioLanguageSelection)
-> Generic AudioLanguageSelection
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' :: Maybe AudioLanguageSelectionPolicy
-> Text -> AudioLanguageSelection
AudioLanguageSelection'
    { $sel:languageSelectionPolicy:AudioLanguageSelection' :: Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy =
        Maybe AudioLanguageSelectionPolicy
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 :: (Maybe AudioLanguageSelectionPolicy
 -> f (Maybe AudioLanguageSelectionPolicy))
-> AudioLanguageSelection -> f AudioLanguageSelection
audioLanguageSelection_languageSelectionPolicy = (AudioLanguageSelection -> Maybe AudioLanguageSelectionPolicy)
-> (AudioLanguageSelection
    -> Maybe AudioLanguageSelectionPolicy -> AudioLanguageSelection)
-> Lens
     AudioLanguageSelection
     AudioLanguageSelection
     (Maybe AudioLanguageSelectionPolicy)
     (Maybe AudioLanguageSelectionPolicy)
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 :: (Text -> f Text)
-> AudioLanguageSelection -> f AudioLanguageSelection
audioLanguageSelection_languageCode = (AudioLanguageSelection -> Text)
-> (AudioLanguageSelection -> Text -> AudioLanguageSelection)
-> Lens AudioLanguageSelection AudioLanguageSelection Text Text
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 Core.FromJSON AudioLanguageSelection where
  parseJSON :: Value -> Parser AudioLanguageSelection
parseJSON =
    String
-> (Object -> Parser AudioLanguageSelection)
-> Value
-> Parser AudioLanguageSelection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AudioLanguageSelection"
      ( \Object
x ->
          Maybe AudioLanguageSelectionPolicy
-> Text -> AudioLanguageSelection
AudioLanguageSelection'
            (Maybe AudioLanguageSelectionPolicy
 -> Text -> AudioLanguageSelection)
-> Parser (Maybe AudioLanguageSelectionPolicy)
-> Parser (Text -> AudioLanguageSelection)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AudioLanguageSelectionPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"languageSelectionPolicy")
            Parser (Text -> AudioLanguageSelection)
-> Parser Text -> Parser AudioLanguageSelection
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"languageCode")
      )

instance Prelude.Hashable AudioLanguageSelection

instance Prelude.NFData AudioLanguageSelection

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"languageSelectionPolicy" Text -> AudioLanguageSelectionPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AudioLanguageSelectionPolicy -> Pair)
-> Maybe AudioLanguageSelectionPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AudioLanguageSelectionPolicy
languageSelectionPolicy,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"languageCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
languageCode)
          ]
      )