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

-- | Teletext Source Settings
--
-- /See:/ 'newTeletextSourceSettings' smart constructor.
data TeletextSourceSettings = TeletextSourceSettings'
  { -- | Optionally defines a region where TTML style captions will be displayed
    TeletextSourceSettings -> Maybe CaptionRectangle
outputRectangle :: Prelude.Maybe CaptionRectangle,
    -- | Specifies the teletext page number within the data stream from which to
    -- extract captions. Range of 0x100 (256) to 0x8FF (2303). Unused for
    -- passthrough. Should be specified as a hexadecimal string with no \"0x\"
    -- prefix.
    TeletextSourceSettings -> Maybe Text
pageNumber :: Prelude.Maybe Prelude.Text
  }
  deriving (TeletextSourceSettings -> TeletextSourceSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TeletextSourceSettings -> TeletextSourceSettings -> Bool
$c/= :: TeletextSourceSettings -> TeletextSourceSettings -> Bool
== :: TeletextSourceSettings -> TeletextSourceSettings -> Bool
$c== :: TeletextSourceSettings -> TeletextSourceSettings -> Bool
Prelude.Eq, ReadPrec [TeletextSourceSettings]
ReadPrec TeletextSourceSettings
Int -> ReadS TeletextSourceSettings
ReadS [TeletextSourceSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TeletextSourceSettings]
$creadListPrec :: ReadPrec [TeletextSourceSettings]
readPrec :: ReadPrec TeletextSourceSettings
$creadPrec :: ReadPrec TeletextSourceSettings
readList :: ReadS [TeletextSourceSettings]
$creadList :: ReadS [TeletextSourceSettings]
readsPrec :: Int -> ReadS TeletextSourceSettings
$creadsPrec :: Int -> ReadS TeletextSourceSettings
Prelude.Read, Int -> TeletextSourceSettings -> ShowS
[TeletextSourceSettings] -> ShowS
TeletextSourceSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TeletextSourceSettings] -> ShowS
$cshowList :: [TeletextSourceSettings] -> ShowS
show :: TeletextSourceSettings -> String
$cshow :: TeletextSourceSettings -> String
showsPrec :: Int -> TeletextSourceSettings -> ShowS
$cshowsPrec :: Int -> TeletextSourceSettings -> ShowS
Prelude.Show, forall x. Rep TeletextSourceSettings x -> TeletextSourceSettings
forall x. TeletextSourceSettings -> Rep TeletextSourceSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TeletextSourceSettings x -> TeletextSourceSettings
$cfrom :: forall x. TeletextSourceSettings -> Rep TeletextSourceSettings x
Prelude.Generic)

-- |
-- Create a value of 'TeletextSourceSettings' 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:
--
-- 'outputRectangle', 'teletextSourceSettings_outputRectangle' - Optionally defines a region where TTML style captions will be displayed
--
-- 'pageNumber', 'teletextSourceSettings_pageNumber' - Specifies the teletext page number within the data stream from which to
-- extract captions. Range of 0x100 (256) to 0x8FF (2303). Unused for
-- passthrough. Should be specified as a hexadecimal string with no \"0x\"
-- prefix.
newTeletextSourceSettings ::
  TeletextSourceSettings
newTeletextSourceSettings :: TeletextSourceSettings
newTeletextSourceSettings =
  TeletextSourceSettings'
    { $sel:outputRectangle:TeletextSourceSettings' :: Maybe CaptionRectangle
outputRectangle =
        forall a. Maybe a
Prelude.Nothing,
      $sel:pageNumber:TeletextSourceSettings' :: Maybe Text
pageNumber = forall a. Maybe a
Prelude.Nothing
    }

-- | Optionally defines a region where TTML style captions will be displayed
teletextSourceSettings_outputRectangle :: Lens.Lens' TeletextSourceSettings (Prelude.Maybe CaptionRectangle)
teletextSourceSettings_outputRectangle :: Lens' TeletextSourceSettings (Maybe CaptionRectangle)
teletextSourceSettings_outputRectangle = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TeletextSourceSettings' {Maybe CaptionRectangle
outputRectangle :: Maybe CaptionRectangle
$sel:outputRectangle:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe CaptionRectangle
outputRectangle} -> Maybe CaptionRectangle
outputRectangle) (\s :: TeletextSourceSettings
s@TeletextSourceSettings' {} Maybe CaptionRectangle
a -> TeletextSourceSettings
s {$sel:outputRectangle:TeletextSourceSettings' :: Maybe CaptionRectangle
outputRectangle = Maybe CaptionRectangle
a} :: TeletextSourceSettings)

-- | Specifies the teletext page number within the data stream from which to
-- extract captions. Range of 0x100 (256) to 0x8FF (2303). Unused for
-- passthrough. Should be specified as a hexadecimal string with no \"0x\"
-- prefix.
teletextSourceSettings_pageNumber :: Lens.Lens' TeletextSourceSettings (Prelude.Maybe Prelude.Text)
teletextSourceSettings_pageNumber :: Lens' TeletextSourceSettings (Maybe Text)
teletextSourceSettings_pageNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TeletextSourceSettings' {Maybe Text
pageNumber :: Maybe Text
$sel:pageNumber:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe Text
pageNumber} -> Maybe Text
pageNumber) (\s :: TeletextSourceSettings
s@TeletextSourceSettings' {} Maybe Text
a -> TeletextSourceSettings
s {$sel:pageNumber:TeletextSourceSettings' :: Maybe Text
pageNumber = Maybe Text
a} :: TeletextSourceSettings)

instance Data.FromJSON TeletextSourceSettings where
  parseJSON :: Value -> Parser TeletextSourceSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TeletextSourceSettings"
      ( \Object
x ->
          Maybe CaptionRectangle -> Maybe Text -> TeletextSourceSettings
TeletextSourceSettings'
            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
"outputRectangle")
            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
"pageNumber")
      )

instance Prelude.Hashable TeletextSourceSettings where
  hashWithSalt :: Int -> TeletextSourceSettings -> Int
hashWithSalt Int
_salt TeletextSourceSettings' {Maybe Text
Maybe CaptionRectangle
pageNumber :: Maybe Text
outputRectangle :: Maybe CaptionRectangle
$sel:pageNumber:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe Text
$sel:outputRectangle:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe CaptionRectangle
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CaptionRectangle
outputRectangle
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pageNumber

instance Prelude.NFData TeletextSourceSettings where
  rnf :: TeletextSourceSettings -> ()
rnf TeletextSourceSettings' {Maybe Text
Maybe CaptionRectangle
pageNumber :: Maybe Text
outputRectangle :: Maybe CaptionRectangle
$sel:pageNumber:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe Text
$sel:outputRectangle:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe CaptionRectangle
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CaptionRectangle
outputRectangle
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pageNumber

instance Data.ToJSON TeletextSourceSettings where
  toJSON :: TeletextSourceSettings -> Value
toJSON TeletextSourceSettings' {Maybe Text
Maybe CaptionRectangle
pageNumber :: Maybe Text
outputRectangle :: Maybe CaptionRectangle
$sel:pageNumber:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe Text
$sel:outputRectangle:TeletextSourceSettings' :: TeletextSourceSettings -> Maybe CaptionRectangle
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"outputRectangle" 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 CaptionRectangle
outputRectangle,
            (Key
"pageNumber" 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
pageNumber
          ]
      )