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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.FecOutputSettings
import Amazonka.MediaLive.Types.OutputLocationRef
import Amazonka.MediaLive.Types.UdpContainerSettings
import qualified Amazonka.Prelude as Prelude

-- | Udp Output Settings
--
-- /See:/ 'newUdpOutputSettings' smart constructor.
data UdpOutputSettings = UdpOutputSettings'
  { -- | Settings for enabling and adjusting Forward Error Correction on UDP
    -- outputs.
    UdpOutputSettings -> Maybe FecOutputSettings
fecOutputSettings :: Prelude.Maybe FecOutputSettings,
    -- | UDP output buffering in milliseconds. Larger values increase latency
    -- through the transcoder but simultaneously assist the transcoder in
    -- maintaining a constant, low-jitter UDP\/RTP output while accommodating
    -- clock recovery, input switching, input disruptions, picture reordering,
    -- etc.
    UdpOutputSettings -> Maybe Natural
bufferMsec :: Prelude.Maybe Prelude.Natural,
    -- | Destination address and port number for RTP or UDP packets. Can be
    -- unicast or multicast RTP or UDP (eg. rtp:\/\/239.10.10.10:5001 or
    -- udp:\/\/10.100.100.100:5002).
    UdpOutputSettings -> OutputLocationRef
destination :: OutputLocationRef,
    UdpOutputSettings -> UdpContainerSettings
containerSettings :: UdpContainerSettings
  }
  deriving (UdpOutputSettings -> UdpOutputSettings -> Bool
(UdpOutputSettings -> UdpOutputSettings -> Bool)
-> (UdpOutputSettings -> UdpOutputSettings -> Bool)
-> Eq UdpOutputSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UdpOutputSettings -> UdpOutputSettings -> Bool
$c/= :: UdpOutputSettings -> UdpOutputSettings -> Bool
== :: UdpOutputSettings -> UdpOutputSettings -> Bool
$c== :: UdpOutputSettings -> UdpOutputSettings -> Bool
Prelude.Eq, ReadPrec [UdpOutputSettings]
ReadPrec UdpOutputSettings
Int -> ReadS UdpOutputSettings
ReadS [UdpOutputSettings]
(Int -> ReadS UdpOutputSettings)
-> ReadS [UdpOutputSettings]
-> ReadPrec UdpOutputSettings
-> ReadPrec [UdpOutputSettings]
-> Read UdpOutputSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UdpOutputSettings]
$creadListPrec :: ReadPrec [UdpOutputSettings]
readPrec :: ReadPrec UdpOutputSettings
$creadPrec :: ReadPrec UdpOutputSettings
readList :: ReadS [UdpOutputSettings]
$creadList :: ReadS [UdpOutputSettings]
readsPrec :: Int -> ReadS UdpOutputSettings
$creadsPrec :: Int -> ReadS UdpOutputSettings
Prelude.Read, Int -> UdpOutputSettings -> ShowS
[UdpOutputSettings] -> ShowS
UdpOutputSettings -> String
(Int -> UdpOutputSettings -> ShowS)
-> (UdpOutputSettings -> String)
-> ([UdpOutputSettings] -> ShowS)
-> Show UdpOutputSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UdpOutputSettings] -> ShowS
$cshowList :: [UdpOutputSettings] -> ShowS
show :: UdpOutputSettings -> String
$cshow :: UdpOutputSettings -> String
showsPrec :: Int -> UdpOutputSettings -> ShowS
$cshowsPrec :: Int -> UdpOutputSettings -> ShowS
Prelude.Show, (forall x. UdpOutputSettings -> Rep UdpOutputSettings x)
-> (forall x. Rep UdpOutputSettings x -> UdpOutputSettings)
-> Generic UdpOutputSettings
forall x. Rep UdpOutputSettings x -> UdpOutputSettings
forall x. UdpOutputSettings -> Rep UdpOutputSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UdpOutputSettings x -> UdpOutputSettings
$cfrom :: forall x. UdpOutputSettings -> Rep UdpOutputSettings x
Prelude.Generic)

-- |
-- Create a value of 'UdpOutputSettings' 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:
--
-- 'fecOutputSettings', 'udpOutputSettings_fecOutputSettings' - Settings for enabling and adjusting Forward Error Correction on UDP
-- outputs.
--
-- 'bufferMsec', 'udpOutputSettings_bufferMsec' - UDP output buffering in milliseconds. Larger values increase latency
-- through the transcoder but simultaneously assist the transcoder in
-- maintaining a constant, low-jitter UDP\/RTP output while accommodating
-- clock recovery, input switching, input disruptions, picture reordering,
-- etc.
--
-- 'destination', 'udpOutputSettings_destination' - Destination address and port number for RTP or UDP packets. Can be
-- unicast or multicast RTP or UDP (eg. rtp:\/\/239.10.10.10:5001 or
-- udp:\/\/10.100.100.100:5002).
--
-- 'containerSettings', 'udpOutputSettings_containerSettings' - Undocumented member.
newUdpOutputSettings ::
  -- | 'destination'
  OutputLocationRef ->
  -- | 'containerSettings'
  UdpContainerSettings ->
  UdpOutputSettings
newUdpOutputSettings :: OutputLocationRef -> UdpContainerSettings -> UdpOutputSettings
newUdpOutputSettings
  OutputLocationRef
pDestination_
  UdpContainerSettings
pContainerSettings_ =
    UdpOutputSettings' :: Maybe FecOutputSettings
-> Maybe Natural
-> OutputLocationRef
-> UdpContainerSettings
-> UdpOutputSettings
UdpOutputSettings'
      { $sel:fecOutputSettings:UdpOutputSettings' :: Maybe FecOutputSettings
fecOutputSettings =
          Maybe FecOutputSettings
forall a. Maybe a
Prelude.Nothing,
        $sel:bufferMsec:UdpOutputSettings' :: Maybe Natural
bufferMsec = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:destination:UdpOutputSettings' :: OutputLocationRef
destination = OutputLocationRef
pDestination_,
        $sel:containerSettings:UdpOutputSettings' :: UdpContainerSettings
containerSettings = UdpContainerSettings
pContainerSettings_
      }

-- | Settings for enabling and adjusting Forward Error Correction on UDP
-- outputs.
udpOutputSettings_fecOutputSettings :: Lens.Lens' UdpOutputSettings (Prelude.Maybe FecOutputSettings)
udpOutputSettings_fecOutputSettings :: (Maybe FecOutputSettings -> f (Maybe FecOutputSettings))
-> UdpOutputSettings -> f UdpOutputSettings
udpOutputSettings_fecOutputSettings = (UdpOutputSettings -> Maybe FecOutputSettings)
-> (UdpOutputSettings
    -> Maybe FecOutputSettings -> UdpOutputSettings)
-> Lens
     UdpOutputSettings
     UdpOutputSettings
     (Maybe FecOutputSettings)
     (Maybe FecOutputSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UdpOutputSettings' {Maybe FecOutputSettings
fecOutputSettings :: Maybe FecOutputSettings
$sel:fecOutputSettings:UdpOutputSettings' :: UdpOutputSettings -> Maybe FecOutputSettings
fecOutputSettings} -> Maybe FecOutputSettings
fecOutputSettings) (\s :: UdpOutputSettings
s@UdpOutputSettings' {} Maybe FecOutputSettings
a -> UdpOutputSettings
s {$sel:fecOutputSettings:UdpOutputSettings' :: Maybe FecOutputSettings
fecOutputSettings = Maybe FecOutputSettings
a} :: UdpOutputSettings)

-- | UDP output buffering in milliseconds. Larger values increase latency
-- through the transcoder but simultaneously assist the transcoder in
-- maintaining a constant, low-jitter UDP\/RTP output while accommodating
-- clock recovery, input switching, input disruptions, picture reordering,
-- etc.
udpOutputSettings_bufferMsec :: Lens.Lens' UdpOutputSettings (Prelude.Maybe Prelude.Natural)
udpOutputSettings_bufferMsec :: (Maybe Natural -> f (Maybe Natural))
-> UdpOutputSettings -> f UdpOutputSettings
udpOutputSettings_bufferMsec = (UdpOutputSettings -> Maybe Natural)
-> (UdpOutputSettings -> Maybe Natural -> UdpOutputSettings)
-> Lens
     UdpOutputSettings UdpOutputSettings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UdpOutputSettings' {Maybe Natural
bufferMsec :: Maybe Natural
$sel:bufferMsec:UdpOutputSettings' :: UdpOutputSettings -> Maybe Natural
bufferMsec} -> Maybe Natural
bufferMsec) (\s :: UdpOutputSettings
s@UdpOutputSettings' {} Maybe Natural
a -> UdpOutputSettings
s {$sel:bufferMsec:UdpOutputSettings' :: Maybe Natural
bufferMsec = Maybe Natural
a} :: UdpOutputSettings)

-- | Destination address and port number for RTP or UDP packets. Can be
-- unicast or multicast RTP or UDP (eg. rtp:\/\/239.10.10.10:5001 or
-- udp:\/\/10.100.100.100:5002).
udpOutputSettings_destination :: Lens.Lens' UdpOutputSettings OutputLocationRef
udpOutputSettings_destination :: (OutputLocationRef -> f OutputLocationRef)
-> UdpOutputSettings -> f UdpOutputSettings
udpOutputSettings_destination = (UdpOutputSettings -> OutputLocationRef)
-> (UdpOutputSettings -> OutputLocationRef -> UdpOutputSettings)
-> Lens
     UdpOutputSettings
     UdpOutputSettings
     OutputLocationRef
     OutputLocationRef
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UdpOutputSettings' {OutputLocationRef
destination :: OutputLocationRef
$sel:destination:UdpOutputSettings' :: UdpOutputSettings -> OutputLocationRef
destination} -> OutputLocationRef
destination) (\s :: UdpOutputSettings
s@UdpOutputSettings' {} OutputLocationRef
a -> UdpOutputSettings
s {$sel:destination:UdpOutputSettings' :: OutputLocationRef
destination = OutputLocationRef
a} :: UdpOutputSettings)

-- | Undocumented member.
udpOutputSettings_containerSettings :: Lens.Lens' UdpOutputSettings UdpContainerSettings
udpOutputSettings_containerSettings :: (UdpContainerSettings -> f UdpContainerSettings)
-> UdpOutputSettings -> f UdpOutputSettings
udpOutputSettings_containerSettings = (UdpOutputSettings -> UdpContainerSettings)
-> (UdpOutputSettings -> UdpContainerSettings -> UdpOutputSettings)
-> Lens
     UdpOutputSettings
     UdpOutputSettings
     UdpContainerSettings
     UdpContainerSettings
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UdpOutputSettings' {UdpContainerSettings
containerSettings :: UdpContainerSettings
$sel:containerSettings:UdpOutputSettings' :: UdpOutputSettings -> UdpContainerSettings
containerSettings} -> UdpContainerSettings
containerSettings) (\s :: UdpOutputSettings
s@UdpOutputSettings' {} UdpContainerSettings
a -> UdpOutputSettings
s {$sel:containerSettings:UdpOutputSettings' :: UdpContainerSettings
containerSettings = UdpContainerSettings
a} :: UdpOutputSettings)

instance Core.FromJSON UdpOutputSettings where
  parseJSON :: Value -> Parser UdpOutputSettings
parseJSON =
    String
-> (Object -> Parser UdpOutputSettings)
-> Value
-> Parser UdpOutputSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UdpOutputSettings"
      ( \Object
x ->
          Maybe FecOutputSettings
-> Maybe Natural
-> OutputLocationRef
-> UdpContainerSettings
-> UdpOutputSettings
UdpOutputSettings'
            (Maybe FecOutputSettings
 -> Maybe Natural
 -> OutputLocationRef
 -> UdpContainerSettings
 -> UdpOutputSettings)
-> Parser (Maybe FecOutputSettings)
-> Parser
     (Maybe Natural
      -> OutputLocationRef -> UdpContainerSettings -> UdpOutputSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FecOutputSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"fecOutputSettings")
            Parser
  (Maybe Natural
   -> OutputLocationRef -> UdpContainerSettings -> UdpOutputSettings)
-> Parser (Maybe Natural)
-> Parser
     (OutputLocationRef -> UdpContainerSettings -> UdpOutputSettings)
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
"bufferMsec")
            Parser
  (OutputLocationRef -> UdpContainerSettings -> UdpOutputSettings)
-> Parser OutputLocationRef
-> Parser (UdpContainerSettings -> UdpOutputSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser OutputLocationRef
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"destination")
            Parser (UdpContainerSettings -> UdpOutputSettings)
-> Parser UdpContainerSettings -> Parser UdpOutputSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser UdpContainerSettings
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"containerSettings")
      )

instance Prelude.Hashable UdpOutputSettings

instance Prelude.NFData UdpOutputSettings

instance Core.ToJSON UdpOutputSettings where
  toJSON :: UdpOutputSettings -> Value
toJSON UdpOutputSettings' {Maybe Natural
Maybe FecOutputSettings
OutputLocationRef
UdpContainerSettings
containerSettings :: UdpContainerSettings
destination :: OutputLocationRef
bufferMsec :: Maybe Natural
fecOutputSettings :: Maybe FecOutputSettings
$sel:containerSettings:UdpOutputSettings' :: UdpOutputSettings -> UdpContainerSettings
$sel:destination:UdpOutputSettings' :: UdpOutputSettings -> OutputLocationRef
$sel:bufferMsec:UdpOutputSettings' :: UdpOutputSettings -> Maybe Natural
$sel:fecOutputSettings:UdpOutputSettings' :: UdpOutputSettings -> Maybe FecOutputSettings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"fecOutputSettings" Text -> FecOutputSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FecOutputSettings -> Pair)
-> Maybe FecOutputSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FecOutputSettings
fecOutputSettings,
            (Text
"bufferMsec" 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
bufferMsec,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"destination" Text -> OutputLocationRef -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OutputLocationRef
destination),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"containerSettings" Text -> UdpContainerSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UdpContainerSettings
containerSettings)
          ]
      )