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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticTranscoder.Types.CaptionFormat
import Amazonka.ElasticTranscoder.Types.CaptionSource
import qualified Amazonka.Prelude as Prelude

-- | The captions to be created, if any.
--
-- /See:/ 'newCaptions' smart constructor.
data Captions = Captions'
  { -- | The array of file formats for the output captions. If you leave this
    -- value blank, Elastic Transcoder returns an error.
    Captions -> Maybe [CaptionFormat]
captionFormats :: Prelude.Maybe [CaptionFormat],
    -- | Source files for the input sidecar captions used during the transcoding
    -- process. To omit all sidecar captions, leave @CaptionSources@ blank.
    Captions -> Maybe [CaptionSource]
captionSources :: Prelude.Maybe [CaptionSource],
    -- | A policy that determines how Elastic Transcoder handles the existence of
    -- multiple captions.
    --
    -- -   __MergeOverride:__ Elastic Transcoder transcodes both embedded and
    --     sidecar captions into outputs. If captions for a language are
    --     embedded in the input file and also appear in a sidecar file,
    --     Elastic Transcoder uses the sidecar captions and ignores the
    --     embedded captions for that language.
    --
    -- -   __MergeRetain:__ Elastic Transcoder transcodes both embedded and
    --     sidecar captions into outputs. If captions for a language are
    --     embedded in the input file and also appear in a sidecar file,
    --     Elastic Transcoder uses the embedded captions and ignores the
    --     sidecar captions for that language. If @CaptionSources@ is empty,
    --     Elastic Transcoder omits all sidecar captions from the output files.
    --
    -- -   __Override:__ Elastic Transcoder transcodes only the sidecar
    --     captions that you specify in @CaptionSources@.
    --
    -- @MergePolicy@ cannot be null.
    Captions -> Maybe Text
mergePolicy :: Prelude.Maybe Prelude.Text
  }
  deriving (Captions -> Captions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Captions -> Captions -> Bool
$c/= :: Captions -> Captions -> Bool
== :: Captions -> Captions -> Bool
$c== :: Captions -> Captions -> Bool
Prelude.Eq, ReadPrec [Captions]
ReadPrec Captions
Int -> ReadS Captions
ReadS [Captions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Captions]
$creadListPrec :: ReadPrec [Captions]
readPrec :: ReadPrec Captions
$creadPrec :: ReadPrec Captions
readList :: ReadS [Captions]
$creadList :: ReadS [Captions]
readsPrec :: Int -> ReadS Captions
$creadsPrec :: Int -> ReadS Captions
Prelude.Read, Int -> Captions -> ShowS
[Captions] -> ShowS
Captions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Captions] -> ShowS
$cshowList :: [Captions] -> ShowS
show :: Captions -> String
$cshow :: Captions -> String
showsPrec :: Int -> Captions -> ShowS
$cshowsPrec :: Int -> Captions -> ShowS
Prelude.Show, forall x. Rep Captions x -> Captions
forall x. Captions -> Rep Captions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Captions x -> Captions
$cfrom :: forall x. Captions -> Rep Captions x
Prelude.Generic)

-- |
-- Create a value of 'Captions' 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:
--
-- 'captionFormats', 'captions_captionFormats' - The array of file formats for the output captions. If you leave this
-- value blank, Elastic Transcoder returns an error.
--
-- 'captionSources', 'captions_captionSources' - Source files for the input sidecar captions used during the transcoding
-- process. To omit all sidecar captions, leave @CaptionSources@ blank.
--
-- 'mergePolicy', 'captions_mergePolicy' - A policy that determines how Elastic Transcoder handles the existence of
-- multiple captions.
--
-- -   __MergeOverride:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the sidecar captions and ignores the
--     embedded captions for that language.
--
-- -   __MergeRetain:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the embedded captions and ignores the
--     sidecar captions for that language. If @CaptionSources@ is empty,
--     Elastic Transcoder omits all sidecar captions from the output files.
--
-- -   __Override:__ Elastic Transcoder transcodes only the sidecar
--     captions that you specify in @CaptionSources@.
--
-- @MergePolicy@ cannot be null.
newCaptions ::
  Captions
newCaptions :: Captions
newCaptions =
  Captions'
    { $sel:captionFormats:Captions' :: Maybe [CaptionFormat]
captionFormats = forall a. Maybe a
Prelude.Nothing,
      $sel:captionSources:Captions' :: Maybe [CaptionSource]
captionSources = forall a. Maybe a
Prelude.Nothing,
      $sel:mergePolicy:Captions' :: Maybe Text
mergePolicy = forall a. Maybe a
Prelude.Nothing
    }

-- | The array of file formats for the output captions. If you leave this
-- value blank, Elastic Transcoder returns an error.
captions_captionFormats :: Lens.Lens' Captions (Prelude.Maybe [CaptionFormat])
captions_captionFormats :: Lens' Captions (Maybe [CaptionFormat])
captions_captionFormats = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Captions' {Maybe [CaptionFormat]
captionFormats :: Maybe [CaptionFormat]
$sel:captionFormats:Captions' :: Captions -> Maybe [CaptionFormat]
captionFormats} -> Maybe [CaptionFormat]
captionFormats) (\s :: Captions
s@Captions' {} Maybe [CaptionFormat]
a -> Captions
s {$sel:captionFormats:Captions' :: Maybe [CaptionFormat]
captionFormats = Maybe [CaptionFormat]
a} :: Captions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Source files for the input sidecar captions used during the transcoding
-- process. To omit all sidecar captions, leave @CaptionSources@ blank.
captions_captionSources :: Lens.Lens' Captions (Prelude.Maybe [CaptionSource])
captions_captionSources :: Lens' Captions (Maybe [CaptionSource])
captions_captionSources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Captions' {Maybe [CaptionSource]
captionSources :: Maybe [CaptionSource]
$sel:captionSources:Captions' :: Captions -> Maybe [CaptionSource]
captionSources} -> Maybe [CaptionSource]
captionSources) (\s :: Captions
s@Captions' {} Maybe [CaptionSource]
a -> Captions
s {$sel:captionSources:Captions' :: Maybe [CaptionSource]
captionSources = Maybe [CaptionSource]
a} :: Captions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A policy that determines how Elastic Transcoder handles the existence of
-- multiple captions.
--
-- -   __MergeOverride:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the sidecar captions and ignores the
--     embedded captions for that language.
--
-- -   __MergeRetain:__ Elastic Transcoder transcodes both embedded and
--     sidecar captions into outputs. If captions for a language are
--     embedded in the input file and also appear in a sidecar file,
--     Elastic Transcoder uses the embedded captions and ignores the
--     sidecar captions for that language. If @CaptionSources@ is empty,
--     Elastic Transcoder omits all sidecar captions from the output files.
--
-- -   __Override:__ Elastic Transcoder transcodes only the sidecar
--     captions that you specify in @CaptionSources@.
--
-- @MergePolicy@ cannot be null.
captions_mergePolicy :: Lens.Lens' Captions (Prelude.Maybe Prelude.Text)
captions_mergePolicy :: Lens' Captions (Maybe Text)
captions_mergePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Captions' {Maybe Text
mergePolicy :: Maybe Text
$sel:mergePolicy:Captions' :: Captions -> Maybe Text
mergePolicy} -> Maybe Text
mergePolicy) (\s :: Captions
s@Captions' {} Maybe Text
a -> Captions
s {$sel:mergePolicy:Captions' :: Maybe Text
mergePolicy = Maybe Text
a} :: Captions)

instance Data.FromJSON Captions where
  parseJSON :: Value -> Parser Captions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Captions"
      ( \Object
x ->
          Maybe [CaptionFormat]
-> Maybe [CaptionSource] -> Maybe Text -> Captions
Captions'
            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
"CaptionFormats" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"CaptionSources" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"MergePolicy")
      )

instance Prelude.Hashable Captions where
  hashWithSalt :: Int -> Captions -> Int
hashWithSalt Int
_salt Captions' {Maybe [CaptionSource]
Maybe [CaptionFormat]
Maybe Text
mergePolicy :: Maybe Text
captionSources :: Maybe [CaptionSource]
captionFormats :: Maybe [CaptionFormat]
$sel:mergePolicy:Captions' :: Captions -> Maybe Text
$sel:captionSources:Captions' :: Captions -> Maybe [CaptionSource]
$sel:captionFormats:Captions' :: Captions -> Maybe [CaptionFormat]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CaptionFormat]
captionFormats
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CaptionSource]
captionSources
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mergePolicy

instance Prelude.NFData Captions where
  rnf :: Captions -> ()
rnf Captions' {Maybe [CaptionSource]
Maybe [CaptionFormat]
Maybe Text
mergePolicy :: Maybe Text
captionSources :: Maybe [CaptionSource]
captionFormats :: Maybe [CaptionFormat]
$sel:mergePolicy:Captions' :: Captions -> Maybe Text
$sel:captionSources:Captions' :: Captions -> Maybe [CaptionSource]
$sel:captionFormats:Captions' :: Captions -> Maybe [CaptionFormat]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CaptionFormat]
captionFormats
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [CaptionSource]
captionSources
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mergePolicy

instance Data.ToJSON Captions where
  toJSON :: Captions -> Value
toJSON Captions' {Maybe [CaptionSource]
Maybe [CaptionFormat]
Maybe Text
mergePolicy :: Maybe Text
captionSources :: Maybe [CaptionSource]
captionFormats :: Maybe [CaptionFormat]
$sel:mergePolicy:Captions' :: Captions -> Maybe Text
$sel:captionSources:Captions' :: Captions -> Maybe [CaptionSource]
$sel:captionFormats:Captions' :: Captions -> Maybe [CaptionFormat]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CaptionFormats" 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 [CaptionFormat]
captionFormats,
            (Key
"CaptionSources" 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 [CaptionSource]
captionSources,
            (Key
"MergePolicy" 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
mergePolicy
          ]
      )