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

-- | Fec Output Settings
--
-- /See:/ 'newFecOutputSettings' smart constructor.
data FecOutputSettings = 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 -> Maybe Natural
columnDepth :: Prelude.Maybe Prelude.Natural,
    -- | Enables column only or column and row based FEC
    FecOutputSettings -> Maybe FecOutputIncludeFec
includeFec :: Prelude.Maybe FecOutputIncludeFec,
    -- | 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
  }
  deriving (FecOutputSettings -> FecOutputSettings -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'includeFec', 'fecOutputSettings_includeFec' - Enables column only or column and row based FEC
--
-- '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.
newFecOutputSettings ::
  FecOutputSettings
newFecOutputSettings :: FecOutputSettings
newFecOutputSettings =
  FecOutputSettings'
    { $sel:columnDepth:FecOutputSettings' :: Maybe Natural
columnDepth = forall a. Maybe a
Prelude.Nothing,
      $sel:includeFec:FecOutputSettings' :: Maybe FecOutputIncludeFec
includeFec = forall a. Maybe a
Prelude.Nothing,
      $sel:rowLength:FecOutputSettings' :: Maybe Natural
rowLength = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' FecOutputSettings (Maybe Natural)
fecOutputSettings_columnDepth = 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)

-- | Enables column only or column and row based FEC
fecOutputSettings_includeFec :: Lens.Lens' FecOutputSettings (Prelude.Maybe FecOutputIncludeFec)
fecOutputSettings_includeFec :: Lens' FecOutputSettings (Maybe FecOutputIncludeFec)
fecOutputSettings_includeFec = 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 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 :: Lens' FecOutputSettings (Maybe Natural)
fecOutputSettings_rowLength = 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)

instance Data.FromJSON FecOutputSettings where
  parseJSON :: Value -> Parser FecOutputSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FecOutputSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe FecOutputIncludeFec -> Maybe Natural -> FecOutputSettings
FecOutputSettings'
            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
"columnDepth")
            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
"includeFec")
            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
"rowLength")
      )

instance Prelude.Hashable FecOutputSettings where
  hashWithSalt :: Int -> FecOutputSettings -> Int
hashWithSalt Int
_salt FecOutputSettings' {Maybe Natural
Maybe FecOutputIncludeFec
rowLength :: Maybe Natural
includeFec :: Maybe FecOutputIncludeFec
columnDepth :: Maybe Natural
$sel:rowLength:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
$sel:includeFec:FecOutputSettings' :: FecOutputSettings -> Maybe FecOutputIncludeFec
$sel:columnDepth:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
columnDepth
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FecOutputIncludeFec
includeFec
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
rowLength

instance Prelude.NFData FecOutputSettings where
  rnf :: FecOutputSettings -> ()
rnf FecOutputSettings' {Maybe Natural
Maybe FecOutputIncludeFec
rowLength :: Maybe Natural
includeFec :: Maybe FecOutputIncludeFec
columnDepth :: Maybe Natural
$sel:rowLength:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
$sel:includeFec:FecOutputSettings' :: FecOutputSettings -> Maybe FecOutputIncludeFec
$sel:columnDepth:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
columnDepth
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FecOutputIncludeFec
includeFec
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
rowLength

instance Data.ToJSON FecOutputSettings where
  toJSON :: FecOutputSettings -> Value
toJSON FecOutputSettings' {Maybe Natural
Maybe FecOutputIncludeFec
rowLength :: Maybe Natural
includeFec :: Maybe FecOutputIncludeFec
columnDepth :: Maybe Natural
$sel:rowLength:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
$sel:includeFec:FecOutputSettings' :: FecOutputSettings -> Maybe FecOutputIncludeFec
$sel:columnDepth:FecOutputSettings' :: FecOutputSettings -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"columnDepth" 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 Natural
columnDepth,
            (Key
"includeFec" 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 FecOutputIncludeFec
includeFec,
            (Key
"rowLength" 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 Natural
rowLength
          ]
      )