{-# 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.ElasticTranscoder.Types.CaptionSource
-- 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.ElasticTranscoder.Types.CaptionSource where

import qualified Amazonka.Core as Core
import Amazonka.ElasticTranscoder.Types.Encryption
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A source file for the input sidecar captions used during the transcoding
-- process.
--
-- /See:/ 'newCaptionSource' smart constructor.
data CaptionSource = CaptionSource'
  { -- | For clip generation or captions that do not start at the same time as
    -- the associated video file, the @TimeOffset@ tells Elastic Transcoder how
    -- much of the video to encode before including captions.
    --
    -- Specify the TimeOffset in the form [+-]SS.sss or [+-]HH:mm:SS.ss.
    CaptionSource -> Maybe Text
timeOffset :: Prelude.Maybe Prelude.Text,
    -- | The encryption settings, if any, that Elastic Transcoder needs to
    -- decyrpt your caption sources, or that you want Elastic Transcoder to
    -- apply to your caption sources.
    CaptionSource -> Maybe Encryption
encryption :: Prelude.Maybe Encryption,
    -- | The name of the sidecar caption file that you want Elastic Transcoder to
    -- include in the output file.
    CaptionSource -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | A string that specifies the language of the caption. If you specified
    -- multiple inputs with captions, the caption language must match in order
    -- to be included in the output. Specify this as one of:
    --
    -- -   2-character ISO 639-1 code
    --
    -- -   3-character ISO 639-2 code
    --
    -- For more information on ISO language codes and language names, see the
    -- List of ISO 639-1 codes.
    CaptionSource -> Maybe Text
language :: Prelude.Maybe Prelude.Text,
    -- | The label of the caption shown in the player when choosing a language.
    -- We recommend that you put the caption language name here, in the
    -- language of the captions.
    CaptionSource -> Maybe Text
label :: Prelude.Maybe Prelude.Text
  }
  deriving (CaptionSource -> CaptionSource -> Bool
(CaptionSource -> CaptionSource -> Bool)
-> (CaptionSource -> CaptionSource -> Bool) -> Eq CaptionSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptionSource -> CaptionSource -> Bool
$c/= :: CaptionSource -> CaptionSource -> Bool
== :: CaptionSource -> CaptionSource -> Bool
$c== :: CaptionSource -> CaptionSource -> Bool
Prelude.Eq, ReadPrec [CaptionSource]
ReadPrec CaptionSource
Int -> ReadS CaptionSource
ReadS [CaptionSource]
(Int -> ReadS CaptionSource)
-> ReadS [CaptionSource]
-> ReadPrec CaptionSource
-> ReadPrec [CaptionSource]
-> Read CaptionSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptionSource]
$creadListPrec :: ReadPrec [CaptionSource]
readPrec :: ReadPrec CaptionSource
$creadPrec :: ReadPrec CaptionSource
readList :: ReadS [CaptionSource]
$creadList :: ReadS [CaptionSource]
readsPrec :: Int -> ReadS CaptionSource
$creadsPrec :: Int -> ReadS CaptionSource
Prelude.Read, Int -> CaptionSource -> ShowS
[CaptionSource] -> ShowS
CaptionSource -> String
(Int -> CaptionSource -> ShowS)
-> (CaptionSource -> String)
-> ([CaptionSource] -> ShowS)
-> Show CaptionSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptionSource] -> ShowS
$cshowList :: [CaptionSource] -> ShowS
show :: CaptionSource -> String
$cshow :: CaptionSource -> String
showsPrec :: Int -> CaptionSource -> ShowS
$cshowsPrec :: Int -> CaptionSource -> ShowS
Prelude.Show, (forall x. CaptionSource -> Rep CaptionSource x)
-> (forall x. Rep CaptionSource x -> CaptionSource)
-> Generic CaptionSource
forall x. Rep CaptionSource x -> CaptionSource
forall x. CaptionSource -> Rep CaptionSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptionSource x -> CaptionSource
$cfrom :: forall x. CaptionSource -> Rep CaptionSource x
Prelude.Generic)

-- |
-- Create a value of 'CaptionSource' 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:
--
-- 'timeOffset', 'captionSource_timeOffset' - For clip generation or captions that do not start at the same time as
-- the associated video file, the @TimeOffset@ tells Elastic Transcoder how
-- much of the video to encode before including captions.
--
-- Specify the TimeOffset in the form [+-]SS.sss or [+-]HH:mm:SS.ss.
--
-- 'encryption', 'captionSource_encryption' - The encryption settings, if any, that Elastic Transcoder needs to
-- decyrpt your caption sources, or that you want Elastic Transcoder to
-- apply to your caption sources.
--
-- 'key', 'captionSource_key' - The name of the sidecar caption file that you want Elastic Transcoder to
-- include in the output file.
--
-- 'language', 'captionSource_language' - A string that specifies the language of the caption. If you specified
-- multiple inputs with captions, the caption language must match in order
-- to be included in the output. Specify this as one of:
--
-- -   2-character ISO 639-1 code
--
-- -   3-character ISO 639-2 code
--
-- For more information on ISO language codes and language names, see the
-- List of ISO 639-1 codes.
--
-- 'label', 'captionSource_label' - The label of the caption shown in the player when choosing a language.
-- We recommend that you put the caption language name here, in the
-- language of the captions.
newCaptionSource ::
  CaptionSource
newCaptionSource :: CaptionSource
newCaptionSource =
  CaptionSource' :: Maybe Text
-> Maybe Encryption
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CaptionSource
CaptionSource'
    { $sel:timeOffset:CaptionSource' :: Maybe Text
timeOffset = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:CaptionSource' :: Maybe Encryption
encryption = Maybe Encryption
forall a. Maybe a
Prelude.Nothing,
      $sel:key:CaptionSource' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:language:CaptionSource' :: Maybe Text
language = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:label:CaptionSource' :: Maybe Text
label = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | For clip generation or captions that do not start at the same time as
-- the associated video file, the @TimeOffset@ tells Elastic Transcoder how
-- much of the video to encode before including captions.
--
-- Specify the TimeOffset in the form [+-]SS.sss or [+-]HH:mm:SS.ss.
captionSource_timeOffset :: Lens.Lens' CaptionSource (Prelude.Maybe Prelude.Text)
captionSource_timeOffset :: (Maybe Text -> f (Maybe Text)) -> CaptionSource -> f CaptionSource
captionSource_timeOffset = (CaptionSource -> Maybe Text)
-> (CaptionSource -> Maybe Text -> CaptionSource)
-> Lens CaptionSource CaptionSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSource' {Maybe Text
timeOffset :: Maybe Text
$sel:timeOffset:CaptionSource' :: CaptionSource -> Maybe Text
timeOffset} -> Maybe Text
timeOffset) (\s :: CaptionSource
s@CaptionSource' {} Maybe Text
a -> CaptionSource
s {$sel:timeOffset:CaptionSource' :: Maybe Text
timeOffset = Maybe Text
a} :: CaptionSource)

-- | The encryption settings, if any, that Elastic Transcoder needs to
-- decyrpt your caption sources, or that you want Elastic Transcoder to
-- apply to your caption sources.
captionSource_encryption :: Lens.Lens' CaptionSource (Prelude.Maybe Encryption)
captionSource_encryption :: (Maybe Encryption -> f (Maybe Encryption))
-> CaptionSource -> f CaptionSource
captionSource_encryption = (CaptionSource -> Maybe Encryption)
-> (CaptionSource -> Maybe Encryption -> CaptionSource)
-> Lens
     CaptionSource CaptionSource (Maybe Encryption) (Maybe Encryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSource' {Maybe Encryption
encryption :: Maybe Encryption
$sel:encryption:CaptionSource' :: CaptionSource -> Maybe Encryption
encryption} -> Maybe Encryption
encryption) (\s :: CaptionSource
s@CaptionSource' {} Maybe Encryption
a -> CaptionSource
s {$sel:encryption:CaptionSource' :: Maybe Encryption
encryption = Maybe Encryption
a} :: CaptionSource)

-- | The name of the sidecar caption file that you want Elastic Transcoder to
-- include in the output file.
captionSource_key :: Lens.Lens' CaptionSource (Prelude.Maybe Prelude.Text)
captionSource_key :: (Maybe Text -> f (Maybe Text)) -> CaptionSource -> f CaptionSource
captionSource_key = (CaptionSource -> Maybe Text)
-> (CaptionSource -> Maybe Text -> CaptionSource)
-> Lens CaptionSource CaptionSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSource' {Maybe Text
key :: Maybe Text
$sel:key:CaptionSource' :: CaptionSource -> Maybe Text
key} -> Maybe Text
key) (\s :: CaptionSource
s@CaptionSource' {} Maybe Text
a -> CaptionSource
s {$sel:key:CaptionSource' :: Maybe Text
key = Maybe Text
a} :: CaptionSource)

-- | A string that specifies the language of the caption. If you specified
-- multiple inputs with captions, the caption language must match in order
-- to be included in the output. Specify this as one of:
--
-- -   2-character ISO 639-1 code
--
-- -   3-character ISO 639-2 code
--
-- For more information on ISO language codes and language names, see the
-- List of ISO 639-1 codes.
captionSource_language :: Lens.Lens' CaptionSource (Prelude.Maybe Prelude.Text)
captionSource_language :: (Maybe Text -> f (Maybe Text)) -> CaptionSource -> f CaptionSource
captionSource_language = (CaptionSource -> Maybe Text)
-> (CaptionSource -> Maybe Text -> CaptionSource)
-> Lens CaptionSource CaptionSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSource' {Maybe Text
language :: Maybe Text
$sel:language:CaptionSource' :: CaptionSource -> Maybe Text
language} -> Maybe Text
language) (\s :: CaptionSource
s@CaptionSource' {} Maybe Text
a -> CaptionSource
s {$sel:language:CaptionSource' :: Maybe Text
language = Maybe Text
a} :: CaptionSource)

-- | The label of the caption shown in the player when choosing a language.
-- We recommend that you put the caption language name here, in the
-- language of the captions.
captionSource_label :: Lens.Lens' CaptionSource (Prelude.Maybe Prelude.Text)
captionSource_label :: (Maybe Text -> f (Maybe Text)) -> CaptionSource -> f CaptionSource
captionSource_label = (CaptionSource -> Maybe Text)
-> (CaptionSource -> Maybe Text -> CaptionSource)
-> Lens CaptionSource CaptionSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionSource' {Maybe Text
label :: Maybe Text
$sel:label:CaptionSource' :: CaptionSource -> Maybe Text
label} -> Maybe Text
label) (\s :: CaptionSource
s@CaptionSource' {} Maybe Text
a -> CaptionSource
s {$sel:label:CaptionSource' :: Maybe Text
label = Maybe Text
a} :: CaptionSource)

instance Core.FromJSON CaptionSource where
  parseJSON :: Value -> Parser CaptionSource
parseJSON =
    String
-> (Object -> Parser CaptionSource)
-> Value
-> Parser CaptionSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CaptionSource"
      ( \Object
x ->
          Maybe Text
-> Maybe Encryption
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CaptionSource
CaptionSource'
            (Maybe Text
 -> Maybe Encryption
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> CaptionSource)
-> Parser (Maybe Text)
-> Parser
     (Maybe Encryption
      -> Maybe Text -> Maybe Text -> Maybe Text -> CaptionSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TimeOffset")
            Parser
  (Maybe Encryption
   -> Maybe Text -> Maybe Text -> Maybe Text -> CaptionSource)
-> Parser (Maybe Encryption)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> CaptionSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Encryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Encryption")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> CaptionSource)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> CaptionSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Key")
            Parser (Maybe Text -> Maybe Text -> CaptionSource)
-> Parser (Maybe Text) -> Parser (Maybe Text -> CaptionSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Language")
            Parser (Maybe Text -> CaptionSource)
-> Parser (Maybe Text) -> Parser CaptionSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Label")
      )

instance Prelude.Hashable CaptionSource

instance Prelude.NFData CaptionSource

instance Core.ToJSON CaptionSource where
  toJSON :: CaptionSource -> Value
toJSON CaptionSource' {Maybe Text
Maybe Encryption
label :: Maybe Text
language :: Maybe Text
key :: Maybe Text
encryption :: Maybe Encryption
timeOffset :: Maybe Text
$sel:label:CaptionSource' :: CaptionSource -> Maybe Text
$sel:language:CaptionSource' :: CaptionSource -> Maybe Text
$sel:key:CaptionSource' :: CaptionSource -> Maybe Text
$sel:encryption:CaptionSource' :: CaptionSource -> Maybe Encryption
$sel:timeOffset:CaptionSource' :: CaptionSource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TimeOffset" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
timeOffset,
            (Text
"Encryption" Text -> Encryption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Encryption -> Pair) -> Maybe Encryption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Encryption
encryption,
            (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key,
            (Text
"Language" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
language,
            (Text
"Label" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
label
          ]
      )