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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.FecOutputIncludeFec
import qualified Amazonka.Prelude as Prelude

-- | Fec Output Settings
--
-- /See:/ 'newFecOutputSettings' smart constructor.
data FecOutputSettings = FecOutputSettings'
  { -- | Parameter L from SMPTE 2022-1. The width of the FEC protection matrix.
    -- Must be between 1 and 20, inclusive. If only Column FEC is used, then
    -- larger values increase robustness. If Row FEC is used, then this is the
    -- number of transport stream packets per row error correction packet, and
    -- the value must be between 4 and 20, inclusive, if includeFec is
    -- columnAndRow. If includeFec is column, this value must be 1 to 20,
    -- inclusive.
    FecOutputSettings -> Maybe Natural
rowLength :: Prelude.Maybe Prelude.Natural,
    -- | Enables column only or column and row based FEC
    FecOutputSettings -> Maybe FecOutputIncludeFec
includeFec :: Prelude.Maybe FecOutputIncludeFec,
    -- | Parameter D from SMPTE 2022-1. The height of the FEC protection matrix.
    -- The number of transport stream packets per column error correction
    -- packet. Must be between 4 and 20, inclusive.
    FecOutputSettings -> Maybe Natural
columnDepth :: Prelude.Maybe Prelude.Natural
  }
  deriving (FecOutputSettings -> FecOutputSettings -> Bool
(FecOutputSettings -> FecOutputSettings -> Bool)
-> (FecOutputSettings -> FecOutputSettings -> Bool)
-> Eq FecOutputSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FecOutputSettings -> FecOutputSettings -> Bool
$c/= :: FecOutputSettings -> FecOutputSettings -> Bool
== :: FecOutputSettings -> FecOutputSettings -> Bool
$c== :: FecOutputSettings -> FecOutputSettings -> Bool
Prelude.Eq, ReadPrec [FecOutputSettings]
ReadPrec FecOutputSettings
Int -> ReadS FecOutputSettings
ReadS [FecOutputSettings]
(Int -> ReadS FecOutputSettings)
-> ReadS [FecOutputSettings]
-> ReadPrec FecOutputSettings
-> ReadPrec [FecOutputSettings]
-> Read FecOutputSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FecOutputSettings]
$creadListPrec :: ReadPrec [FecOutputSettings]
readPrec :: ReadPrec FecOutputSettings
$creadPrec :: ReadPrec FecOutputSettings
readList :: ReadS [FecOutputSettings]
$creadList :: ReadS [FecOutputSettings]
readsPrec :: Int -> ReadS FecOutputSettings
$creadsPrec :: Int -> ReadS FecOutputSettings
Prelude.Read, Int -> FecOutputSettings -> ShowS
[FecOutputSettings] -> ShowS
FecOutputSettings -> String
(Int -> FecOutputSettings -> ShowS)
-> (FecOutputSettings -> String)
-> ([FecOutputSettings] -> ShowS)
-> Show FecOutputSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FecOutputSettings] -> ShowS
$cshowList :: [FecOutputSettings] -> ShowS
show :: FecOutputSettings -> String
$cshow :: FecOutputSettings -> String
showsPrec :: Int -> FecOutputSettings -> ShowS
$cshowsPrec :: Int -> FecOutputSettings -> ShowS
Prelude.Show, (forall x. FecOutputSettings -> Rep FecOutputSettings x)
-> (forall x. Rep FecOutputSettings x -> FecOutputSettings)
-> Generic FecOutputSettings
forall x. Rep FecOutputSettings x -> FecOutputSettings
forall x. FecOutputSettings -> Rep FecOutputSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FecOutputSettings x -> FecOutputSettings
$cfrom :: forall x. FecOutputSettings -> Rep FecOutputSettings x
Prelude.Generic)

-- |
-- Create a value of 'FecOutputSettings' 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:
--
-- 'rowLength', 'fecOutputSettings_rowLength' - Parameter L from SMPTE 2022-1. The width of the FEC protection matrix.
-- Must be between 1 and 20, inclusive. If only Column FEC is used, then
-- larger values increase robustness. If Row FEC is used, then this is the
-- number of transport stream packets per row error correction packet, and
-- the value must be between 4 and 20, inclusive, if includeFec is
-- columnAndRow. If includeFec is column, this value must be 1 to 20,
-- inclusive.
--
-- 'includeFec', 'fecOutputSettings_includeFec' - Enables column only or column and row based FEC
--
-- 'columnDepth', 'fecOutputSettings_columnDepth' - Parameter D from SMPTE 2022-1. The height of the FEC protection matrix.
-- The number of transport stream packets per column error correction
-- packet. Must be between 4 and 20, inclusive.
newFecOutputSettings ::
  FecOutputSettings
newFecOutputSettings :: FecOutputSettings
newFecOutputSettings =
  FecOutputSettings' :: Maybe Natural
-> Maybe FecOutputIncludeFec -> Maybe Natural -> FecOutputSettings
FecOutputSettings'
    { $sel:rowLength:FecOutputSettings' :: Maybe Natural
rowLength = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:includeFec:FecOutputSettings' :: Maybe FecOutputIncludeFec
includeFec = Maybe FecOutputIncludeFec
forall a. Maybe a
Prelude.Nothing,
      $sel:columnDepth:FecOutputSettings' :: Maybe Natural
columnDepth = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Parameter L from SMPTE 2022-1. The width of the FEC protection matrix.
-- Must be between 1 and 20, inclusive. If only Column FEC is used, then
-- larger values increase robustness. If Row FEC is used, then this is the
-- number of transport stream packets per row error correction packet, and
-- the value must be between 4 and 20, inclusive, if includeFec is
-- columnAndRow. If includeFec is column, this value must be 1 to 20,
-- inclusive.
fecOutputSettings_rowLength :: Lens.Lens' FecOutputSettings (Prelude.Maybe Prelude.Natural)
fecOutputSettings_rowLength :: (Maybe Natural -> f (Maybe Natural))
-> FecOutputSettings -> f FecOutputSettings
fecOutputSettings_rowLength = (FecOutputSettings -> Maybe Natural)
-> (FecOutputSettings -> Maybe Natural -> FecOutputSettings)
-> Lens
     FecOutputSettings FecOutputSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FecOutputSettings' {Maybe Natural
rowLength :: Maybe Natural
$sel:rowLength:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
rowLength} -> Maybe Natural
rowLength) (\s :: FecOutputSettings
s@FecOutputSettings' {} Maybe Natural
a -> FecOutputSettings
s {$sel:rowLength:FecOutputSettings' :: Maybe Natural
rowLength = Maybe Natural
a} :: FecOutputSettings)

-- | Enables column only or column and row based FEC
fecOutputSettings_includeFec :: Lens.Lens' FecOutputSettings (Prelude.Maybe FecOutputIncludeFec)
fecOutputSettings_includeFec :: (Maybe FecOutputIncludeFec -> f (Maybe FecOutputIncludeFec))
-> FecOutputSettings -> f FecOutputSettings
fecOutputSettings_includeFec = (FecOutputSettings -> Maybe FecOutputIncludeFec)
-> (FecOutputSettings
    -> Maybe FecOutputIncludeFec -> FecOutputSettings)
-> Lens
     FecOutputSettings
     FecOutputSettings
     (Maybe FecOutputIncludeFec)
     (Maybe FecOutputIncludeFec)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FecOutputSettings' {Maybe FecOutputIncludeFec
includeFec :: Maybe FecOutputIncludeFec
$sel:includeFec:FecOutputSettings' :: FecOutputSettings -> Maybe FecOutputIncludeFec
includeFec} -> Maybe FecOutputIncludeFec
includeFec) (\s :: FecOutputSettings
s@FecOutputSettings' {} Maybe FecOutputIncludeFec
a -> FecOutputSettings
s {$sel:includeFec:FecOutputSettings' :: Maybe FecOutputIncludeFec
includeFec = Maybe FecOutputIncludeFec
a} :: FecOutputSettings)

-- | Parameter D from SMPTE 2022-1. The height of the FEC protection matrix.
-- The number of transport stream packets per column error correction
-- packet. Must be between 4 and 20, inclusive.
fecOutputSettings_columnDepth :: Lens.Lens' FecOutputSettings (Prelude.Maybe Prelude.Natural)
fecOutputSettings_columnDepth :: (Maybe Natural -> f (Maybe Natural))
-> FecOutputSettings -> f FecOutputSettings
fecOutputSettings_columnDepth = (FecOutputSettings -> Maybe Natural)
-> (FecOutputSettings -> Maybe Natural -> FecOutputSettings)
-> Lens
     FecOutputSettings FecOutputSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FecOutputSettings' {Maybe Natural
columnDepth :: Maybe Natural
$sel:columnDepth:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
columnDepth} -> Maybe Natural
columnDepth) (\s :: FecOutputSettings
s@FecOutputSettings' {} Maybe Natural
a -> FecOutputSettings
s {$sel:columnDepth:FecOutputSettings' :: Maybe Natural
columnDepth = Maybe Natural
a} :: FecOutputSettings)

instance Core.FromJSON FecOutputSettings where
  parseJSON :: Value -> Parser FecOutputSettings
parseJSON =
    String
-> (Object -> Parser FecOutputSettings)
-> Value
-> Parser FecOutputSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FecOutputSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe FecOutputIncludeFec -> Maybe Natural -> FecOutputSettings
FecOutputSettings'
            (Maybe Natural
 -> Maybe FecOutputIncludeFec -> Maybe Natural -> FecOutputSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe FecOutputIncludeFec -> Maybe Natural -> FecOutputSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"rowLength")
            Parser
  (Maybe FecOutputIncludeFec -> Maybe Natural -> FecOutputSettings)
-> Parser (Maybe FecOutputIncludeFec)
-> Parser (Maybe Natural -> FecOutputSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FecOutputIncludeFec)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"includeFec")
            Parser (Maybe Natural -> FecOutputSettings)
-> Parser (Maybe Natural) -> Parser FecOutputSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"columnDepth")
      )

instance Prelude.Hashable FecOutputSettings

instance Prelude.NFData FecOutputSettings

instance Core.ToJSON FecOutputSettings where
  toJSON :: FecOutputSettings -> Value
toJSON FecOutputSettings' {Maybe Natural
Maybe FecOutputIncludeFec
columnDepth :: Maybe Natural
includeFec :: Maybe FecOutputIncludeFec
rowLength :: Maybe Natural
$sel:columnDepth:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
$sel:includeFec:FecOutputSettings' :: FecOutputSettings -> Maybe FecOutputIncludeFec
$sel:rowLength:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"rowLength" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
rowLength,
            (Text
"includeFec" Text -> FecOutputIncludeFec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FecOutputIncludeFec -> Pair)
-> Maybe FecOutputIncludeFec -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FecOutputIncludeFec
includeFec,
            (Text
"columnDepth" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
columnDepth
          ]
      )