{-# 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.CaptionDescription
-- 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.CaptionDescription 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.AccessibilityType
import Amazonka.MediaLive.Types.CaptionDestinationSettings
import qualified Amazonka.Prelude as Prelude

-- | Caption Description
--
-- /See:/ 'newCaptionDescription' smart constructor.
data CaptionDescription = CaptionDescription'
  { -- | Indicates whether the caption track implements accessibility features
    -- such as written descriptions of spoken dialog, music, and sounds.
    CaptionDescription -> Maybe AccessibilityType
accessibility :: Prelude.Maybe AccessibilityType,
    -- | Additional settings for captions destination that depend on the
    -- destination type.
    CaptionDescription -> Maybe CaptionDestinationSettings
destinationSettings :: Prelude.Maybe CaptionDestinationSettings,
    -- | ISO 639-2 three-digit code: http:\/\/www.loc.gov\/standards\/iso639-2\/
    CaptionDescription -> Maybe Text
languageCode :: Prelude.Maybe Prelude.Text,
    -- | Human readable information to indicate captions available for players
    -- (eg. English, or Spanish).
    CaptionDescription -> Maybe Text
languageDescription :: Prelude.Maybe Prelude.Text,
    -- | Specifies which input caption selector to use as a caption source when
    -- generating output captions. This field should match a captionSelector
    -- name.
    CaptionDescription -> Text
captionSelectorName :: Prelude.Text,
    -- | Name of the caption description. Used to associate a caption description
    -- with an output. Names must be unique within an event.
    CaptionDescription -> Text
name :: Prelude.Text
  }
  deriving (CaptionDescription -> CaptionDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptionDescription -> CaptionDescription -> Bool
$c/= :: CaptionDescription -> CaptionDescription -> Bool
== :: CaptionDescription -> CaptionDescription -> Bool
$c== :: CaptionDescription -> CaptionDescription -> Bool
Prelude.Eq, ReadPrec [CaptionDescription]
ReadPrec CaptionDescription
Int -> ReadS CaptionDescription
ReadS [CaptionDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptionDescription]
$creadListPrec :: ReadPrec [CaptionDescription]
readPrec :: ReadPrec CaptionDescription
$creadPrec :: ReadPrec CaptionDescription
readList :: ReadS [CaptionDescription]
$creadList :: ReadS [CaptionDescription]
readsPrec :: Int -> ReadS CaptionDescription
$creadsPrec :: Int -> ReadS CaptionDescription
Prelude.Read, Int -> CaptionDescription -> ShowS
[CaptionDescription] -> ShowS
CaptionDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptionDescription] -> ShowS
$cshowList :: [CaptionDescription] -> ShowS
show :: CaptionDescription -> String
$cshow :: CaptionDescription -> String
showsPrec :: Int -> CaptionDescription -> ShowS
$cshowsPrec :: Int -> CaptionDescription -> ShowS
Prelude.Show, forall x. Rep CaptionDescription x -> CaptionDescription
forall x. CaptionDescription -> Rep CaptionDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptionDescription x -> CaptionDescription
$cfrom :: forall x. CaptionDescription -> Rep CaptionDescription x
Prelude.Generic)

-- |
-- Create a value of 'CaptionDescription' 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:
--
-- 'accessibility', 'captionDescription_accessibility' - Indicates whether the caption track implements accessibility features
-- such as written descriptions of spoken dialog, music, and sounds.
--
-- 'destinationSettings', 'captionDescription_destinationSettings' - Additional settings for captions destination that depend on the
-- destination type.
--
-- 'languageCode', 'captionDescription_languageCode' - ISO 639-2 three-digit code: http:\/\/www.loc.gov\/standards\/iso639-2\/
--
-- 'languageDescription', 'captionDescription_languageDescription' - Human readable information to indicate captions available for players
-- (eg. English, or Spanish).
--
-- 'captionSelectorName', 'captionDescription_captionSelectorName' - Specifies which input caption selector to use as a caption source when
-- generating output captions. This field should match a captionSelector
-- name.
--
-- 'name', 'captionDescription_name' - Name of the caption description. Used to associate a caption description
-- with an output. Names must be unique within an event.
newCaptionDescription ::
  -- | 'captionSelectorName'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  CaptionDescription
newCaptionDescription :: Text -> Text -> CaptionDescription
newCaptionDescription Text
pCaptionSelectorName_ Text
pName_ =
  CaptionDescription'
    { $sel:accessibility:CaptionDescription' :: Maybe AccessibilityType
accessibility =
        forall a. Maybe a
Prelude.Nothing,
      $sel:destinationSettings:CaptionDescription' :: Maybe CaptionDestinationSettings
destinationSettings = forall a. Maybe a
Prelude.Nothing,
      $sel:languageCode:CaptionDescription' :: Maybe Text
languageCode = forall a. Maybe a
Prelude.Nothing,
      $sel:languageDescription:CaptionDescription' :: Maybe Text
languageDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:captionSelectorName:CaptionDescription' :: Text
captionSelectorName = Text
pCaptionSelectorName_,
      $sel:name:CaptionDescription' :: Text
name = Text
pName_
    }

-- | Indicates whether the caption track implements accessibility features
-- such as written descriptions of spoken dialog, music, and sounds.
captionDescription_accessibility :: Lens.Lens' CaptionDescription (Prelude.Maybe AccessibilityType)
captionDescription_accessibility :: Lens' CaptionDescription (Maybe AccessibilityType)
captionDescription_accessibility = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionDescription' {Maybe AccessibilityType
accessibility :: Maybe AccessibilityType
$sel:accessibility:CaptionDescription' :: CaptionDescription -> Maybe AccessibilityType
accessibility} -> Maybe AccessibilityType
accessibility) (\s :: CaptionDescription
s@CaptionDescription' {} Maybe AccessibilityType
a -> CaptionDescription
s {$sel:accessibility:CaptionDescription' :: Maybe AccessibilityType
accessibility = Maybe AccessibilityType
a} :: CaptionDescription)

-- | Additional settings for captions destination that depend on the
-- destination type.
captionDescription_destinationSettings :: Lens.Lens' CaptionDescription (Prelude.Maybe CaptionDestinationSettings)
captionDescription_destinationSettings :: Lens' CaptionDescription (Maybe CaptionDestinationSettings)
captionDescription_destinationSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionDescription' {Maybe CaptionDestinationSettings
destinationSettings :: Maybe CaptionDestinationSettings
$sel:destinationSettings:CaptionDescription' :: CaptionDescription -> Maybe CaptionDestinationSettings
destinationSettings} -> Maybe CaptionDestinationSettings
destinationSettings) (\s :: CaptionDescription
s@CaptionDescription' {} Maybe CaptionDestinationSettings
a -> CaptionDescription
s {$sel:destinationSettings:CaptionDescription' :: Maybe CaptionDestinationSettings
destinationSettings = Maybe CaptionDestinationSettings
a} :: CaptionDescription)

-- | ISO 639-2 three-digit code: http:\/\/www.loc.gov\/standards\/iso639-2\/
captionDescription_languageCode :: Lens.Lens' CaptionDescription (Prelude.Maybe Prelude.Text)
captionDescription_languageCode :: Lens' CaptionDescription (Maybe Text)
captionDescription_languageCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionDescription' {Maybe Text
languageCode :: Maybe Text
$sel:languageCode:CaptionDescription' :: CaptionDescription -> Maybe Text
languageCode} -> Maybe Text
languageCode) (\s :: CaptionDescription
s@CaptionDescription' {} Maybe Text
a -> CaptionDescription
s {$sel:languageCode:CaptionDescription' :: Maybe Text
languageCode = Maybe Text
a} :: CaptionDescription)

-- | Human readable information to indicate captions available for players
-- (eg. English, or Spanish).
captionDescription_languageDescription :: Lens.Lens' CaptionDescription (Prelude.Maybe Prelude.Text)
captionDescription_languageDescription :: Lens' CaptionDescription (Maybe Text)
captionDescription_languageDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionDescription' {Maybe Text
languageDescription :: Maybe Text
$sel:languageDescription:CaptionDescription' :: CaptionDescription -> Maybe Text
languageDescription} -> Maybe Text
languageDescription) (\s :: CaptionDescription
s@CaptionDescription' {} Maybe Text
a -> CaptionDescription
s {$sel:languageDescription:CaptionDescription' :: Maybe Text
languageDescription = Maybe Text
a} :: CaptionDescription)

-- | Specifies which input caption selector to use as a caption source when
-- generating output captions. This field should match a captionSelector
-- name.
captionDescription_captionSelectorName :: Lens.Lens' CaptionDescription Prelude.Text
captionDescription_captionSelectorName :: Lens' CaptionDescription Text
captionDescription_captionSelectorName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionDescription' {Text
captionSelectorName :: Text
$sel:captionSelectorName:CaptionDescription' :: CaptionDescription -> Text
captionSelectorName} -> Text
captionSelectorName) (\s :: CaptionDescription
s@CaptionDescription' {} Text
a -> CaptionDescription
s {$sel:captionSelectorName:CaptionDescription' :: Text
captionSelectorName = Text
a} :: CaptionDescription)

-- | Name of the caption description. Used to associate a caption description
-- with an output. Names must be unique within an event.
captionDescription_name :: Lens.Lens' CaptionDescription Prelude.Text
captionDescription_name :: Lens' CaptionDescription Text
captionDescription_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionDescription' {Text
name :: Text
$sel:name:CaptionDescription' :: CaptionDescription -> Text
name} -> Text
name) (\s :: CaptionDescription
s@CaptionDescription' {} Text
a -> CaptionDescription
s {$sel:name:CaptionDescription' :: Text
name = Text
a} :: CaptionDescription)

instance Data.FromJSON CaptionDescription where
  parseJSON :: Value -> Parser CaptionDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CaptionDescription"
      ( \Object
x ->
          Maybe AccessibilityType
-> Maybe CaptionDestinationSettings
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> CaptionDescription
CaptionDescription'
            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
"accessibility")
            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
"destinationSettings")
            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
"languageCode")
            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
"languageDescription")
            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
"captionSelectorName")
            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
"name")
      )

instance Prelude.Hashable CaptionDescription where
  hashWithSalt :: Int -> CaptionDescription -> Int
hashWithSalt Int
_salt CaptionDescription' {Maybe Text
Maybe AccessibilityType
Maybe CaptionDestinationSettings
Text
name :: Text
captionSelectorName :: Text
languageDescription :: Maybe Text
languageCode :: Maybe Text
destinationSettings :: Maybe CaptionDestinationSettings
accessibility :: Maybe AccessibilityType
$sel:name:CaptionDescription' :: CaptionDescription -> Text
$sel:captionSelectorName:CaptionDescription' :: CaptionDescription -> Text
$sel:languageDescription:CaptionDescription' :: CaptionDescription -> Maybe Text
$sel:languageCode:CaptionDescription' :: CaptionDescription -> Maybe Text
$sel:destinationSettings:CaptionDescription' :: CaptionDescription -> Maybe CaptionDestinationSettings
$sel:accessibility:CaptionDescription' :: CaptionDescription -> Maybe AccessibilityType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccessibilityType
accessibility
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CaptionDestinationSettings
destinationSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
languageCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
languageDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
captionSelectorName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData CaptionDescription where
  rnf :: CaptionDescription -> ()
rnf CaptionDescription' {Maybe Text
Maybe AccessibilityType
Maybe CaptionDestinationSettings
Text
name :: Text
captionSelectorName :: Text
languageDescription :: Maybe Text
languageCode :: Maybe Text
destinationSettings :: Maybe CaptionDestinationSettings
accessibility :: Maybe AccessibilityType
$sel:name:CaptionDescription' :: CaptionDescription -> Text
$sel:captionSelectorName:CaptionDescription' :: CaptionDescription -> Text
$sel:languageDescription:CaptionDescription' :: CaptionDescription -> Maybe Text
$sel:languageCode:CaptionDescription' :: CaptionDescription -> Maybe Text
$sel:destinationSettings:CaptionDescription' :: CaptionDescription -> Maybe CaptionDestinationSettings
$sel:accessibility:CaptionDescription' :: CaptionDescription -> Maybe AccessibilityType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AccessibilityType
accessibility
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CaptionDestinationSettings
destinationSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
languageCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
languageDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
captionSelectorName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON CaptionDescription where
  toJSON :: CaptionDescription -> Value
toJSON CaptionDescription' {Maybe Text
Maybe AccessibilityType
Maybe CaptionDestinationSettings
Text
name :: Text
captionSelectorName :: Text
languageDescription :: Maybe Text
languageCode :: Maybe Text
destinationSettings :: Maybe CaptionDestinationSettings
accessibility :: Maybe AccessibilityType
$sel:name:CaptionDescription' :: CaptionDescription -> Text
$sel:captionSelectorName:CaptionDescription' :: CaptionDescription -> Text
$sel:languageDescription:CaptionDescription' :: CaptionDescription -> Maybe Text
$sel:languageCode:CaptionDescription' :: CaptionDescription -> Maybe Text
$sel:destinationSettings:CaptionDescription' :: CaptionDescription -> Maybe CaptionDestinationSettings
$sel:accessibility:CaptionDescription' :: CaptionDescription -> Maybe AccessibilityType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"accessibility" 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 AccessibilityType
accessibility,
            (Key
"destinationSettings" 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 CaptionDestinationSettings
destinationSettings,
            (Key
"languageCode" 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 Text
languageCode,
            (Key
"languageDescription" 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 Text
languageDescription,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"captionSelectorName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
captionSelectorName),
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )