{-# 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-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.MediaLive.Types.TeletextSourceSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(TeletextSourceSettings -> TeletextSourceSettings -> Bool)
-> (TeletextSourceSettings -> TeletextSourceSettings -> Bool)
-> Eq TeletextSourceSettings
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]
(Int -> ReadS TeletextSourceSettings)
-> ReadS [TeletextSourceSettings]
-> ReadPrec TeletextSourceSettings
-> ReadPrec [TeletextSourceSettings]
-> Read 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
(Int -> TeletextSourceSettings -> ShowS)
-> (TeletextSourceSettings -> String)
-> ([TeletextSourceSettings] -> ShowS)
-> Show TeletextSourceSettings
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. TeletextSourceSettings -> Rep TeletextSourceSettings x)
-> (forall x.
    Rep TeletextSourceSettings x -> TeletextSourceSettings)
-> Generic TeletextSourceSettings
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' :: Maybe CaptionRectangle -> Maybe Text -> TeletextSourceSettings
TeletextSourceSettings'
    { $sel:outputRectangle:TeletextSourceSettings' :: Maybe CaptionRectangle
outputRectangle =
        Maybe CaptionRectangle
forall a. Maybe a
Prelude.Nothing,
      $sel:pageNumber:TeletextSourceSettings' :: Maybe Text
pageNumber = Maybe Text
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 :: (Maybe CaptionRectangle -> f (Maybe CaptionRectangle))
-> TeletextSourceSettings -> f TeletextSourceSettings
teletextSourceSettings_outputRectangle = (TeletextSourceSettings -> Maybe CaptionRectangle)
-> (TeletextSourceSettings
    -> Maybe CaptionRectangle -> TeletextSourceSettings)
-> Lens
     TeletextSourceSettings
     TeletextSourceSettings
     (Maybe CaptionRectangle)
     (Maybe CaptionRectangle)
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 :: (Maybe Text -> f (Maybe Text))
-> TeletextSourceSettings -> f TeletextSourceSettings
teletextSourceSettings_pageNumber = (TeletextSourceSettings -> Maybe Text)
-> (TeletextSourceSettings -> Maybe Text -> TeletextSourceSettings)
-> Lens
     TeletextSourceSettings
     TeletextSourceSettings
     (Maybe Text)
     (Maybe Text)
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 Core.FromJSON TeletextSourceSettings where
  parseJSON :: Value -> Parser TeletextSourceSettings
parseJSON =
    String
-> (Object -> Parser TeletextSourceSettings)
-> Value
-> Parser TeletextSourceSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TeletextSourceSettings"
      ( \Object
x ->
          Maybe CaptionRectangle -> Maybe Text -> TeletextSourceSettings
TeletextSourceSettings'
            (Maybe CaptionRectangle -> Maybe Text -> TeletextSourceSettings)
-> Parser (Maybe CaptionRectangle)
-> Parser (Maybe Text -> TeletextSourceSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CaptionRectangle)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"outputRectangle")
            Parser (Maybe Text -> TeletextSourceSettings)
-> Parser (Maybe Text) -> Parser TeletextSourceSettings
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
"pageNumber")
      )

instance Prelude.Hashable TeletextSourceSettings

instance Prelude.NFData TeletextSourceSettings

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"outputRectangle" Text -> CaptionRectangle -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CaptionRectangle -> Pair) -> Maybe CaptionRectangle -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CaptionRectangle
outputRectangle,
            (Text
"pageNumber" 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
pageNumber
          ]
      )