{-# 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-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.CaptionFormat where

import qualified Amazonka.Core as Core
import Amazonka.ElasticTranscoder.Types.Encryption
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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 encryption settings, if any, that you want Elastic Transcoder to
    -- apply to your caption formats.
    CaptionFormat -> Maybe Encryption
encryption :: Prelude.Maybe Encryption
  }
  deriving (CaptionFormat -> CaptionFormat -> Bool
(CaptionFormat -> CaptionFormat -> Bool)
-> (CaptionFormat -> CaptionFormat -> Bool) -> Eq CaptionFormat
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]
(Int -> ReadS CaptionFormat)
-> ReadS [CaptionFormat]
-> ReadPrec CaptionFormat
-> ReadPrec [CaptionFormat]
-> Read 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
(Int -> CaptionFormat -> ShowS)
-> (CaptionFormat -> String)
-> ([CaptionFormat] -> ShowS)
-> Show CaptionFormat
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. CaptionFormat -> Rep CaptionFormat x)
-> (forall x. Rep CaptionFormat x -> CaptionFormat)
-> Generic CaptionFormat
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:
--
-- '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.
--
-- '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@
--
-- 'encryption', 'captionFormat_encryption' - The encryption settings, if any, that you want Elastic Transcoder to
-- apply to your caption formats.
newCaptionFormat ::
  CaptionFormat
newCaptionFormat :: CaptionFormat
newCaptionFormat =
  CaptionFormat' :: Maybe Text -> Maybe Text -> Maybe Encryption -> CaptionFormat
CaptionFormat'
    { $sel:pattern':CaptionFormat' :: Maybe Text
pattern' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:format:CaptionFormat' :: Maybe Text
format = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:CaptionFormat' :: Maybe Encryption
encryption = Maybe Encryption
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> CaptionFormat -> f CaptionFormat
captionFormat_pattern = (CaptionFormat -> Maybe Text)
-> (CaptionFormat -> Maybe Text -> CaptionFormat)
-> Lens CaptionFormat CaptionFormat (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> CaptionFormat -> f CaptionFormat
captionFormat_format = (CaptionFormat -> Maybe Text)
-> (CaptionFormat -> Maybe Text -> CaptionFormat)
-> Lens CaptionFormat CaptionFormat (Maybe Text) (Maybe Text)
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 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 :: (Maybe Encryption -> f (Maybe Encryption))
-> CaptionFormat -> f CaptionFormat
captionFormat_encryption = (CaptionFormat -> Maybe Encryption)
-> (CaptionFormat -> Maybe Encryption -> CaptionFormat)
-> Lens
     CaptionFormat CaptionFormat (Maybe Encryption) (Maybe 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)

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

instance Prelude.Hashable CaptionFormat

instance Prelude.NFData CaptionFormat

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