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

-- | The file format of the output captions. If you leave this value blank,
-- Elastic Transcoder returns an error.
--
-- /See:/ 'newCaptionFormat' smart constructor.
data CaptionFormat = CaptionFormat'
  { -- | The encryption settings, if any, that you want Elastic Transcoder to
    -- apply to your caption formats.
    CaptionFormat -> Maybe Encryption
encryption :: Prelude.Maybe Encryption,
    -- | The format you specify determines whether Elastic Transcoder generates
    -- an embedded or sidecar caption for this output.
    --
    -- -   __Valid Embedded Caption Formats:__
    --
    --     -   __for FLAC__: None
    --
    --     -   __For MP3__: None
    --
    --     -   __For MP4__: mov-text
    --
    --     -   __For MPEG-TS__: None
    --
    --     -   __For ogg__: None
    --
    --     -   __For webm__: None
    --
    -- -   __Valid Sidecar Caption Formats:__ Elastic Transcoder supports dfxp
    --     (first div element only), scc, srt, and webvtt. If you want ttml or
    --     smpte-tt compatible captions, specify dfxp as your output format.
    --
    --     -   __For FMP4__: dfxp
    --
    --     -   __Non-FMP4 outputs__: All sidecar types
    --
    --     @fmp4@ captions have an extension of @.ismt@
    CaptionFormat -> Maybe Text
format :: Prelude.Maybe Prelude.Text,
    -- | The prefix for caption filenames, in the form
    -- /description/-@{language}@, where:
    --
    -- -   /description/ is a description of the video.
    --
    -- -   @{language}@ is a literal value that Elastic Transcoder replaces
    --     with the two- or three-letter code for the language of the caption
    --     in the output file names.
    --
    -- If you don\'t include @{language}@ in the file name pattern, Elastic
    -- Transcoder automatically appends \"@{language}@\" to the value that you
    -- specify for the description. In addition, Elastic Transcoder
    -- automatically appends the count to the end of the segment files.
    --
    -- For example, suppose you\'re transcoding into srt format. When you enter
    -- \"Sydney-{language}-sunrise\", and the language of the captions is
    -- English (en), the name of the first caption file is be
    -- Sydney-en-sunrise00000.srt.
    CaptionFormat -> Maybe Text
pattern' :: Prelude.Maybe Prelude.Text
  }
  deriving (CaptionFormat -> CaptionFormat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptionFormat -> CaptionFormat -> Bool
$c/= :: CaptionFormat -> CaptionFormat -> Bool
== :: CaptionFormat -> CaptionFormat -> Bool
$c== :: CaptionFormat -> CaptionFormat -> Bool
Prelude.Eq, ReadPrec [CaptionFormat]
ReadPrec CaptionFormat
Int -> ReadS CaptionFormat
ReadS [CaptionFormat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptionFormat]
$creadListPrec :: ReadPrec [CaptionFormat]
readPrec :: ReadPrec CaptionFormat
$creadPrec :: ReadPrec CaptionFormat
readList :: ReadS [CaptionFormat]
$creadList :: ReadS [CaptionFormat]
readsPrec :: Int -> ReadS CaptionFormat
$creadsPrec :: Int -> ReadS CaptionFormat
Prelude.Read, Int -> CaptionFormat -> ShowS
[CaptionFormat] -> ShowS
CaptionFormat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptionFormat] -> ShowS
$cshowList :: [CaptionFormat] -> ShowS
show :: CaptionFormat -> String
$cshow :: CaptionFormat -> String
showsPrec :: Int -> CaptionFormat -> ShowS
$cshowsPrec :: Int -> CaptionFormat -> ShowS
Prelude.Show, forall x. Rep CaptionFormat x -> CaptionFormat
forall x. CaptionFormat -> Rep CaptionFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptionFormat x -> CaptionFormat
$cfrom :: forall x. CaptionFormat -> Rep CaptionFormat x
Prelude.Generic)

-- |
-- Create a value of 'CaptionFormat' 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:
--
-- 'encryption', 'captionFormat_encryption' - The encryption settings, if any, that you want Elastic Transcoder to
-- apply to your caption formats.
--
-- 'format', 'captionFormat_format' - The format you specify determines whether Elastic Transcoder generates
-- an embedded or sidecar caption for this output.
--
-- -   __Valid Embedded Caption Formats:__
--
--     -   __for FLAC__: None
--
--     -   __For MP3__: None
--
--     -   __For MP4__: mov-text
--
--     -   __For MPEG-TS__: None
--
--     -   __For ogg__: None
--
--     -   __For webm__: None
--
-- -   __Valid Sidecar Caption Formats:__ Elastic Transcoder supports dfxp
--     (first div element only), scc, srt, and webvtt. If you want ttml or
--     smpte-tt compatible captions, specify dfxp as your output format.
--
--     -   __For FMP4__: dfxp
--
--     -   __Non-FMP4 outputs__: All sidecar types
--
--     @fmp4@ captions have an extension of @.ismt@
--
-- 'pattern'', 'captionFormat_pattern' - The prefix for caption filenames, in the form
-- /description/-@{language}@, where:
--
-- -   /description/ is a description of the video.
--
-- -   @{language}@ is a literal value that Elastic Transcoder replaces
--     with the two- or three-letter code for the language of the caption
--     in the output file names.
--
-- If you don\'t include @{language}@ in the file name pattern, Elastic
-- Transcoder automatically appends \"@{language}@\" to the value that you
-- specify for the description. In addition, Elastic Transcoder
-- automatically appends the count to the end of the segment files.
--
-- For example, suppose you\'re transcoding into srt format. When you enter
-- \"Sydney-{language}-sunrise\", and the language of the captions is
-- English (en), the name of the first caption file is be
-- Sydney-en-sunrise00000.srt.
newCaptionFormat ::
  CaptionFormat
newCaptionFormat :: CaptionFormat
newCaptionFormat =
  CaptionFormat'
    { $sel:encryption:CaptionFormat' :: Maybe Encryption
encryption = forall a. Maybe a
Prelude.Nothing,
      $sel:format:CaptionFormat' :: Maybe Text
format = forall a. Maybe a
Prelude.Nothing,
      $sel:pattern':CaptionFormat' :: Maybe Text
pattern' = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The format you specify determines whether Elastic Transcoder generates
-- an embedded or sidecar caption for this output.
--
-- -   __Valid Embedded Caption Formats:__
--
--     -   __for FLAC__: None
--
--     -   __For MP3__: None
--
--     -   __For MP4__: mov-text
--
--     -   __For MPEG-TS__: None
--
--     -   __For ogg__: None
--
--     -   __For webm__: None
--
-- -   __Valid Sidecar Caption Formats:__ Elastic Transcoder supports dfxp
--     (first div element only), scc, srt, and webvtt. If you want ttml or
--     smpte-tt compatible captions, specify dfxp as your output format.
--
--     -   __For FMP4__: dfxp
--
--     -   __Non-FMP4 outputs__: All sidecar types
--
--     @fmp4@ captions have an extension of @.ismt@
captionFormat_format :: Lens.Lens' CaptionFormat (Prelude.Maybe Prelude.Text)
captionFormat_format :: Lens' CaptionFormat (Maybe Text)
captionFormat_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionFormat' {Maybe Text
format :: Maybe Text
$sel:format:CaptionFormat' :: CaptionFormat -> Maybe Text
format} -> Maybe Text
format) (\s :: CaptionFormat
s@CaptionFormat' {} Maybe Text
a -> CaptionFormat
s {$sel:format:CaptionFormat' :: Maybe Text
format = Maybe Text
a} :: CaptionFormat)

-- | The prefix for caption filenames, in the form
-- /description/-@{language}@, where:
--
-- -   /description/ is a description of the video.
--
-- -   @{language}@ is a literal value that Elastic Transcoder replaces
--     with the two- or three-letter code for the language of the caption
--     in the output file names.
--
-- If you don\'t include @{language}@ in the file name pattern, Elastic
-- Transcoder automatically appends \"@{language}@\" to the value that you
-- specify for the description. In addition, Elastic Transcoder
-- automatically appends the count to the end of the segment files.
--
-- For example, suppose you\'re transcoding into srt format. When you enter
-- \"Sydney-{language}-sunrise\", and the language of the captions is
-- English (en), the name of the first caption file is be
-- Sydney-en-sunrise00000.srt.
captionFormat_pattern :: Lens.Lens' CaptionFormat (Prelude.Maybe Prelude.Text)
captionFormat_pattern :: Lens' CaptionFormat (Maybe Text)
captionFormat_pattern = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionFormat' {Maybe Text
pattern' :: Maybe Text
$sel:pattern':CaptionFormat' :: CaptionFormat -> Maybe Text
pattern'} -> Maybe Text
pattern') (\s :: CaptionFormat
s@CaptionFormat' {} Maybe Text
a -> CaptionFormat
s {$sel:pattern':CaptionFormat' :: Maybe Text
pattern' = Maybe Text
a} :: CaptionFormat)

instance Data.FromJSON CaptionFormat where
  parseJSON :: Value -> Parser CaptionFormat
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CaptionFormat"
      ( \Object
x ->
          Maybe Encryption -> Maybe Text -> Maybe Text -> CaptionFormat
CaptionFormat'
            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
"Encryption")
            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
"Format")
            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
"Pattern")
      )

instance Prelude.Hashable CaptionFormat where
  hashWithSalt :: Int -> CaptionFormat -> Int
hashWithSalt Int
_salt CaptionFormat' {Maybe Text
Maybe Encryption
pattern' :: Maybe Text
format :: Maybe Text
encryption :: Maybe Encryption
$sel:pattern':CaptionFormat' :: CaptionFormat -> Maybe Text
$sel:format:CaptionFormat' :: CaptionFormat -> Maybe Text
$sel:encryption:CaptionFormat' :: CaptionFormat -> Maybe Encryption
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Encryption
encryption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
format
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pattern'

instance Prelude.NFData CaptionFormat where
  rnf :: CaptionFormat -> ()
rnf CaptionFormat' {Maybe Text
Maybe Encryption
pattern' :: Maybe Text
format :: Maybe Text
encryption :: Maybe Encryption
$sel:pattern':CaptionFormat' :: CaptionFormat -> Maybe Text
$sel:format:CaptionFormat' :: CaptionFormat -> Maybe Text
$sel:encryption:CaptionFormat' :: CaptionFormat -> Maybe Encryption
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Encryption
encryption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
format
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pattern'

instance Data.ToJSON CaptionFormat where
  toJSON :: CaptionFormat -> Value
toJSON CaptionFormat' {Maybe Text
Maybe Encryption
pattern' :: Maybe Text
format :: Maybe Text
encryption :: Maybe Encryption
$sel:pattern':CaptionFormat' :: CaptionFormat -> Maybe Text
$sel:format:CaptionFormat' :: CaptionFormat -> Maybe Text
$sel:encryption:CaptionFormat' :: CaptionFormat -> Maybe Encryption
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Encryption" 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 Encryption
encryption,
            (Key
"Format" 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
format,
            (Key
"Pattern" 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
pattern'
          ]
      )