{-# 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-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.UdpOutputSettings 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.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'
  { -- | 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,
    -- | Settings for enabling and adjusting Forward Error Correction on UDP
    -- outputs.
    UdpOutputSettings -> Maybe FecOutputSettings
fecOutputSettings :: Prelude.Maybe FecOutputSettings,
    -- | 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
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]
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
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. 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:
--
-- '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.
--
-- 'fecOutputSettings', 'udpOutputSettings_fecOutputSettings' - Settings for enabling and adjusting Forward Error Correction on UDP
-- outputs.
--
-- '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'
      { $sel:bufferMsec:UdpOutputSettings' :: Maybe Natural
bufferMsec = forall a. Maybe a
Prelude.Nothing,
        $sel:fecOutputSettings:UdpOutputSettings' :: Maybe FecOutputSettings
fecOutputSettings = forall a. Maybe a
Prelude.Nothing,
        $sel:destination:UdpOutputSettings' :: OutputLocationRef
destination = OutputLocationRef
pDestination_,
        $sel:containerSettings:UdpOutputSettings' :: UdpContainerSettings
containerSettings = UdpContainerSettings
pContainerSettings_
      }

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

-- | Settings for enabling and adjusting Forward Error Correction on UDP
-- outputs.
udpOutputSettings_fecOutputSettings :: Lens.Lens' UdpOutputSettings (Prelude.Maybe FecOutputSettings)
udpOutputSettings_fecOutputSettings :: Lens' UdpOutputSettings (Maybe FecOutputSettings)
udpOutputSettings_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)

-- | 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 :: Lens' UdpOutputSettings OutputLocationRef
udpOutputSettings_destination = 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 :: Lens' UdpOutputSettings UdpContainerSettings
udpOutputSettings_containerSettings = 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 Data.FromJSON UdpOutputSettings where
  parseJSON :: Value -> Parser UdpOutputSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UdpOutputSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe FecOutputSettings
-> OutputLocationRef
-> UdpContainerSettings
-> UdpOutputSettings
UdpOutputSettings'
            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
"bufferMsec")
            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
"fecOutputSettings")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"destination")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"containerSettings")
      )

instance Prelude.Hashable UdpOutputSettings where
  hashWithSalt :: Int -> UdpOutputSettings -> Int
hashWithSalt Int
_salt UdpOutputSettings' {Maybe Natural
Maybe FecOutputSettings
OutputLocationRef
UdpContainerSettings
containerSettings :: UdpContainerSettings
destination :: OutputLocationRef
fecOutputSettings :: Maybe FecOutputSettings
bufferMsec :: Maybe Natural
$sel:containerSettings:UdpOutputSettings' :: UdpOutputSettings -> UdpContainerSettings
$sel:destination:UdpOutputSettings' :: UdpOutputSettings -> OutputLocationRef
$sel:fecOutputSettings:UdpOutputSettings' :: UdpOutputSettings -> Maybe FecOutputSettings
$sel:bufferMsec:UdpOutputSettings' :: UdpOutputSettings -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
bufferMsec
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FecOutputSettings
fecOutputSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OutputLocationRef
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UdpContainerSettings
containerSettings

instance Prelude.NFData UdpOutputSettings where
  rnf :: UdpOutputSettings -> ()
rnf UdpOutputSettings' {Maybe Natural
Maybe FecOutputSettings
OutputLocationRef
UdpContainerSettings
containerSettings :: UdpContainerSettings
destination :: OutputLocationRef
fecOutputSettings :: Maybe FecOutputSettings
bufferMsec :: Maybe Natural
$sel:containerSettings:UdpOutputSettings' :: UdpOutputSettings -> UdpContainerSettings
$sel:destination:UdpOutputSettings' :: UdpOutputSettings -> OutputLocationRef
$sel:fecOutputSettings:UdpOutputSettings' :: UdpOutputSettings -> Maybe FecOutputSettings
$sel:bufferMsec:UdpOutputSettings' :: UdpOutputSettings -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
bufferMsec
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FecOutputSettings
fecOutputSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf OutputLocationRef
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UdpContainerSettings
containerSettings

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