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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.InputLossActionForUdpOut
import Amazonka.MediaLive.Types.UdpTimedMetadataId3Frame
import qualified Amazonka.Prelude as Prelude

-- | Udp Group Settings
--
-- /See:/ 'newUdpGroupSettings' smart constructor.
data UdpGroupSettings = UdpGroupSettings'
  { -- | Timed Metadata interval in seconds.
    UdpGroupSettings -> Maybe Natural
timedMetadataId3Period :: Prelude.Maybe Prelude.Natural,
    -- | Specifies behavior of last resort when input video is lost, and no more
    -- backup inputs are available. When dropTs is selected the entire
    -- transport stream will stop being emitted. When dropProgram is selected
    -- the program can be dropped from the transport stream (and replaced with
    -- null packets to meet the TS bitrate requirement). Or, when emitProgram
    -- is chosen the transport stream will continue to be produced normally
    -- with repeat frames, black frames, or slate frames substituted for the
    -- absent input video.
    UdpGroupSettings -> Maybe InputLossActionForUdpOut
inputLossAction :: Prelude.Maybe InputLossActionForUdpOut,
    -- | Indicates ID3 frame that has the timecode.
    UdpGroupSettings -> Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame :: Prelude.Maybe UdpTimedMetadataId3Frame
  }
  deriving (UdpGroupSettings -> UdpGroupSettings -> Bool
(UdpGroupSettings -> UdpGroupSettings -> Bool)
-> (UdpGroupSettings -> UdpGroupSettings -> Bool)
-> Eq UdpGroupSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UdpGroupSettings -> UdpGroupSettings -> Bool
$c/= :: UdpGroupSettings -> UdpGroupSettings -> Bool
== :: UdpGroupSettings -> UdpGroupSettings -> Bool
$c== :: UdpGroupSettings -> UdpGroupSettings -> Bool
Prelude.Eq, ReadPrec [UdpGroupSettings]
ReadPrec UdpGroupSettings
Int -> ReadS UdpGroupSettings
ReadS [UdpGroupSettings]
(Int -> ReadS UdpGroupSettings)
-> ReadS [UdpGroupSettings]
-> ReadPrec UdpGroupSettings
-> ReadPrec [UdpGroupSettings]
-> Read UdpGroupSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UdpGroupSettings]
$creadListPrec :: ReadPrec [UdpGroupSettings]
readPrec :: ReadPrec UdpGroupSettings
$creadPrec :: ReadPrec UdpGroupSettings
readList :: ReadS [UdpGroupSettings]
$creadList :: ReadS [UdpGroupSettings]
readsPrec :: Int -> ReadS UdpGroupSettings
$creadsPrec :: Int -> ReadS UdpGroupSettings
Prelude.Read, Int -> UdpGroupSettings -> ShowS
[UdpGroupSettings] -> ShowS
UdpGroupSettings -> String
(Int -> UdpGroupSettings -> ShowS)
-> (UdpGroupSettings -> String)
-> ([UdpGroupSettings] -> ShowS)
-> Show UdpGroupSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UdpGroupSettings] -> ShowS
$cshowList :: [UdpGroupSettings] -> ShowS
show :: UdpGroupSettings -> String
$cshow :: UdpGroupSettings -> String
showsPrec :: Int -> UdpGroupSettings -> ShowS
$cshowsPrec :: Int -> UdpGroupSettings -> ShowS
Prelude.Show, (forall x. UdpGroupSettings -> Rep UdpGroupSettings x)
-> (forall x. Rep UdpGroupSettings x -> UdpGroupSettings)
-> Generic UdpGroupSettings
forall x. Rep UdpGroupSettings x -> UdpGroupSettings
forall x. UdpGroupSettings -> Rep UdpGroupSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UdpGroupSettings x -> UdpGroupSettings
$cfrom :: forall x. UdpGroupSettings -> Rep UdpGroupSettings x
Prelude.Generic)

-- |
-- Create a value of 'UdpGroupSettings' 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:
--
-- 'timedMetadataId3Period', 'udpGroupSettings_timedMetadataId3Period' - Timed Metadata interval in seconds.
--
-- 'inputLossAction', 'udpGroupSettings_inputLossAction' - Specifies behavior of last resort when input video is lost, and no more
-- backup inputs are available. When dropTs is selected the entire
-- transport stream will stop being emitted. When dropProgram is selected
-- the program can be dropped from the transport stream (and replaced with
-- null packets to meet the TS bitrate requirement). Or, when emitProgram
-- is chosen the transport stream will continue to be produced normally
-- with repeat frames, black frames, or slate frames substituted for the
-- absent input video.
--
-- 'timedMetadataId3Frame', 'udpGroupSettings_timedMetadataId3Frame' - Indicates ID3 frame that has the timecode.
newUdpGroupSettings ::
  UdpGroupSettings
newUdpGroupSettings :: UdpGroupSettings
newUdpGroupSettings =
  UdpGroupSettings' :: Maybe Natural
-> Maybe InputLossActionForUdpOut
-> Maybe UdpTimedMetadataId3Frame
-> UdpGroupSettings
UdpGroupSettings'
    { $sel:timedMetadataId3Period:UdpGroupSettings' :: Maybe Natural
timedMetadataId3Period =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:inputLossAction:UdpGroupSettings' :: Maybe InputLossActionForUdpOut
inputLossAction = Maybe InputLossActionForUdpOut
forall a. Maybe a
Prelude.Nothing,
      $sel:timedMetadataId3Frame:UdpGroupSettings' :: Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame = Maybe UdpTimedMetadataId3Frame
forall a. Maybe a
Prelude.Nothing
    }

-- | Timed Metadata interval in seconds.
udpGroupSettings_timedMetadataId3Period :: Lens.Lens' UdpGroupSettings (Prelude.Maybe Prelude.Natural)
udpGroupSettings_timedMetadataId3Period :: (Maybe Natural -> f (Maybe Natural))
-> UdpGroupSettings -> f UdpGroupSettings
udpGroupSettings_timedMetadataId3Period = (UdpGroupSettings -> Maybe Natural)
-> (UdpGroupSettings -> Maybe Natural -> UdpGroupSettings)
-> Lens
     UdpGroupSettings UdpGroupSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UdpGroupSettings' {Maybe Natural
timedMetadataId3Period :: Maybe Natural
$sel:timedMetadataId3Period:UdpGroupSettings' :: UdpGroupSettings -> Maybe Natural
timedMetadataId3Period} -> Maybe Natural
timedMetadataId3Period) (\s :: UdpGroupSettings
s@UdpGroupSettings' {} Maybe Natural
a -> UdpGroupSettings
s {$sel:timedMetadataId3Period:UdpGroupSettings' :: Maybe Natural
timedMetadataId3Period = Maybe Natural
a} :: UdpGroupSettings)

-- | Specifies behavior of last resort when input video is lost, and no more
-- backup inputs are available. When dropTs is selected the entire
-- transport stream will stop being emitted. When dropProgram is selected
-- the program can be dropped from the transport stream (and replaced with
-- null packets to meet the TS bitrate requirement). Or, when emitProgram
-- is chosen the transport stream will continue to be produced normally
-- with repeat frames, black frames, or slate frames substituted for the
-- absent input video.
udpGroupSettings_inputLossAction :: Lens.Lens' UdpGroupSettings (Prelude.Maybe InputLossActionForUdpOut)
udpGroupSettings_inputLossAction :: (Maybe InputLossActionForUdpOut
 -> f (Maybe InputLossActionForUdpOut))
-> UdpGroupSettings -> f UdpGroupSettings
udpGroupSettings_inputLossAction = (UdpGroupSettings -> Maybe InputLossActionForUdpOut)
-> (UdpGroupSettings
    -> Maybe InputLossActionForUdpOut -> UdpGroupSettings)
-> Lens
     UdpGroupSettings
     UdpGroupSettings
     (Maybe InputLossActionForUdpOut)
     (Maybe InputLossActionForUdpOut)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UdpGroupSettings' {Maybe InputLossActionForUdpOut
inputLossAction :: Maybe InputLossActionForUdpOut
$sel:inputLossAction:UdpGroupSettings' :: UdpGroupSettings -> Maybe InputLossActionForUdpOut
inputLossAction} -> Maybe InputLossActionForUdpOut
inputLossAction) (\s :: UdpGroupSettings
s@UdpGroupSettings' {} Maybe InputLossActionForUdpOut
a -> UdpGroupSettings
s {$sel:inputLossAction:UdpGroupSettings' :: Maybe InputLossActionForUdpOut
inputLossAction = Maybe InputLossActionForUdpOut
a} :: UdpGroupSettings)

-- | Indicates ID3 frame that has the timecode.
udpGroupSettings_timedMetadataId3Frame :: Lens.Lens' UdpGroupSettings (Prelude.Maybe UdpTimedMetadataId3Frame)
udpGroupSettings_timedMetadataId3Frame :: (Maybe UdpTimedMetadataId3Frame
 -> f (Maybe UdpTimedMetadataId3Frame))
-> UdpGroupSettings -> f UdpGroupSettings
udpGroupSettings_timedMetadataId3Frame = (UdpGroupSettings -> Maybe UdpTimedMetadataId3Frame)
-> (UdpGroupSettings
    -> Maybe UdpTimedMetadataId3Frame -> UdpGroupSettings)
-> Lens
     UdpGroupSettings
     UdpGroupSettings
     (Maybe UdpTimedMetadataId3Frame)
     (Maybe UdpTimedMetadataId3Frame)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UdpGroupSettings' {Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame :: Maybe UdpTimedMetadataId3Frame
$sel:timedMetadataId3Frame:UdpGroupSettings' :: UdpGroupSettings -> Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame} -> Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame) (\s :: UdpGroupSettings
s@UdpGroupSettings' {} Maybe UdpTimedMetadataId3Frame
a -> UdpGroupSettings
s {$sel:timedMetadataId3Frame:UdpGroupSettings' :: Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame = Maybe UdpTimedMetadataId3Frame
a} :: UdpGroupSettings)

instance Core.FromJSON UdpGroupSettings where
  parseJSON :: Value -> Parser UdpGroupSettings
parseJSON =
    String
-> (Object -> Parser UdpGroupSettings)
-> Value
-> Parser UdpGroupSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UdpGroupSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe InputLossActionForUdpOut
-> Maybe UdpTimedMetadataId3Frame
-> UdpGroupSettings
UdpGroupSettings'
            (Maybe Natural
 -> Maybe InputLossActionForUdpOut
 -> Maybe UdpTimedMetadataId3Frame
 -> UdpGroupSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe InputLossActionForUdpOut
      -> Maybe UdpTimedMetadataId3Frame -> UdpGroupSettings)
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
"timedMetadataId3Period")
            Parser
  (Maybe InputLossActionForUdpOut
   -> Maybe UdpTimedMetadataId3Frame -> UdpGroupSettings)
-> Parser (Maybe InputLossActionForUdpOut)
-> Parser (Maybe UdpTimedMetadataId3Frame -> UdpGroupSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputLossActionForUdpOut)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputLossAction")
            Parser (Maybe UdpTimedMetadataId3Frame -> UdpGroupSettings)
-> Parser (Maybe UdpTimedMetadataId3Frame)
-> Parser UdpGroupSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UdpTimedMetadataId3Frame)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timedMetadataId3Frame")
      )

instance Prelude.Hashable UdpGroupSettings

instance Prelude.NFData UdpGroupSettings

instance Core.ToJSON UdpGroupSettings where
  toJSON :: UdpGroupSettings -> Value
toJSON UdpGroupSettings' {Maybe Natural
Maybe InputLossActionForUdpOut
Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame :: Maybe UdpTimedMetadataId3Frame
inputLossAction :: Maybe InputLossActionForUdpOut
timedMetadataId3Period :: Maybe Natural
$sel:timedMetadataId3Frame:UdpGroupSettings' :: UdpGroupSettings -> Maybe UdpTimedMetadataId3Frame
$sel:inputLossAction:UdpGroupSettings' :: UdpGroupSettings -> Maybe InputLossActionForUdpOut
$sel:timedMetadataId3Period:UdpGroupSettings' :: UdpGroupSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"timedMetadataId3Period" 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
timedMetadataId3Period,
            (Text
"inputLossAction" Text -> InputLossActionForUdpOut -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InputLossActionForUdpOut -> Pair)
-> Maybe InputLossActionForUdpOut -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputLossActionForUdpOut
inputLossAction,
            (Text
"timedMetadataId3Frame" Text -> UdpTimedMetadataId3Frame -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UdpTimedMetadataId3Frame -> Pair)
-> Maybe UdpTimedMetadataId3Frame -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UdpTimedMetadataId3Frame
timedMetadataId3Frame
          ]
      )