{-# 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.MediaConvert.Types.OutputChannelMapping
-- 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.MediaConvert.Types.OutputChannelMapping where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | OutputChannel mapping settings.
--
-- /See:/ 'newOutputChannelMapping' smart constructor.
data OutputChannelMapping = OutputChannelMapping'
  { -- | Use this setting to specify your remix values when they have a decimal
    -- component, such as -10.312, 0.08, or 4.9. MediaConvert rounds your
    -- remixing values to the nearest thousandth.
    OutputChannelMapping -> Maybe [Double]
inputChannelsFineTune :: Prelude.Maybe [Prelude.Double],
    -- | Use this setting to specify your remix values when they are integers,
    -- such as -10, 0, or 4.
    OutputChannelMapping -> Maybe [Int]
inputChannels :: Prelude.Maybe [Prelude.Int]
  }
  deriving (OutputChannelMapping -> OutputChannelMapping -> Bool
(OutputChannelMapping -> OutputChannelMapping -> Bool)
-> (OutputChannelMapping -> OutputChannelMapping -> Bool)
-> Eq OutputChannelMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputChannelMapping -> OutputChannelMapping -> Bool
$c/= :: OutputChannelMapping -> OutputChannelMapping -> Bool
== :: OutputChannelMapping -> OutputChannelMapping -> Bool
$c== :: OutputChannelMapping -> OutputChannelMapping -> Bool
Prelude.Eq, ReadPrec [OutputChannelMapping]
ReadPrec OutputChannelMapping
Int -> ReadS OutputChannelMapping
ReadS [OutputChannelMapping]
(Int -> ReadS OutputChannelMapping)
-> ReadS [OutputChannelMapping]
-> ReadPrec OutputChannelMapping
-> ReadPrec [OutputChannelMapping]
-> Read OutputChannelMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputChannelMapping]
$creadListPrec :: ReadPrec [OutputChannelMapping]
readPrec :: ReadPrec OutputChannelMapping
$creadPrec :: ReadPrec OutputChannelMapping
readList :: ReadS [OutputChannelMapping]
$creadList :: ReadS [OutputChannelMapping]
readsPrec :: Int -> ReadS OutputChannelMapping
$creadsPrec :: Int -> ReadS OutputChannelMapping
Prelude.Read, Int -> OutputChannelMapping -> ShowS
[OutputChannelMapping] -> ShowS
OutputChannelMapping -> String
(Int -> OutputChannelMapping -> ShowS)
-> (OutputChannelMapping -> String)
-> ([OutputChannelMapping] -> ShowS)
-> Show OutputChannelMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputChannelMapping] -> ShowS
$cshowList :: [OutputChannelMapping] -> ShowS
show :: OutputChannelMapping -> String
$cshow :: OutputChannelMapping -> String
showsPrec :: Int -> OutputChannelMapping -> ShowS
$cshowsPrec :: Int -> OutputChannelMapping -> ShowS
Prelude.Show, (forall x. OutputChannelMapping -> Rep OutputChannelMapping x)
-> (forall x. Rep OutputChannelMapping x -> OutputChannelMapping)
-> Generic OutputChannelMapping
forall x. Rep OutputChannelMapping x -> OutputChannelMapping
forall x. OutputChannelMapping -> Rep OutputChannelMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputChannelMapping x -> OutputChannelMapping
$cfrom :: forall x. OutputChannelMapping -> Rep OutputChannelMapping x
Prelude.Generic)

-- |
-- Create a value of 'OutputChannelMapping' 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:
--
-- 'inputChannelsFineTune', 'outputChannelMapping_inputChannelsFineTune' - Use this setting to specify your remix values when they have a decimal
-- component, such as -10.312, 0.08, or 4.9. MediaConvert rounds your
-- remixing values to the nearest thousandth.
--
-- 'inputChannels', 'outputChannelMapping_inputChannels' - Use this setting to specify your remix values when they are integers,
-- such as -10, 0, or 4.
newOutputChannelMapping ::
  OutputChannelMapping
newOutputChannelMapping :: OutputChannelMapping
newOutputChannelMapping =
  OutputChannelMapping' :: Maybe [Double] -> Maybe [Int] -> OutputChannelMapping
OutputChannelMapping'
    { $sel:inputChannelsFineTune:OutputChannelMapping' :: Maybe [Double]
inputChannelsFineTune =
        Maybe [Double]
forall a. Maybe a
Prelude.Nothing,
      $sel:inputChannels:OutputChannelMapping' :: Maybe [Int]
inputChannels = Maybe [Int]
forall a. Maybe a
Prelude.Nothing
    }

-- | Use this setting to specify your remix values when they have a decimal
-- component, such as -10.312, 0.08, or 4.9. MediaConvert rounds your
-- remixing values to the nearest thousandth.
outputChannelMapping_inputChannelsFineTune :: Lens.Lens' OutputChannelMapping (Prelude.Maybe [Prelude.Double])
outputChannelMapping_inputChannelsFineTune :: (Maybe [Double] -> f (Maybe [Double]))
-> OutputChannelMapping -> f OutputChannelMapping
outputChannelMapping_inputChannelsFineTune = (OutputChannelMapping -> Maybe [Double])
-> (OutputChannelMapping -> Maybe [Double] -> OutputChannelMapping)
-> Lens
     OutputChannelMapping
     OutputChannelMapping
     (Maybe [Double])
     (Maybe [Double])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputChannelMapping' {Maybe [Double]
inputChannelsFineTune :: Maybe [Double]
$sel:inputChannelsFineTune:OutputChannelMapping' :: OutputChannelMapping -> Maybe [Double]
inputChannelsFineTune} -> Maybe [Double]
inputChannelsFineTune) (\s :: OutputChannelMapping
s@OutputChannelMapping' {} Maybe [Double]
a -> OutputChannelMapping
s {$sel:inputChannelsFineTune:OutputChannelMapping' :: Maybe [Double]
inputChannelsFineTune = Maybe [Double]
a} :: OutputChannelMapping) ((Maybe [Double] -> f (Maybe [Double]))
 -> OutputChannelMapping -> f OutputChannelMapping)
-> ((Maybe [Double] -> f (Maybe [Double]))
    -> Maybe [Double] -> f (Maybe [Double]))
-> (Maybe [Double] -> f (Maybe [Double]))
-> OutputChannelMapping
-> f OutputChannelMapping
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Double] [Double] [Double] [Double]
-> Iso
     (Maybe [Double]) (Maybe [Double]) (Maybe [Double]) (Maybe [Double])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Double] [Double] [Double] [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Use this setting to specify your remix values when they are integers,
-- such as -10, 0, or 4.
outputChannelMapping_inputChannels :: Lens.Lens' OutputChannelMapping (Prelude.Maybe [Prelude.Int])
outputChannelMapping_inputChannels :: (Maybe [Int] -> f (Maybe [Int]))
-> OutputChannelMapping -> f OutputChannelMapping
outputChannelMapping_inputChannels = (OutputChannelMapping -> Maybe [Int])
-> (OutputChannelMapping -> Maybe [Int] -> OutputChannelMapping)
-> Lens
     OutputChannelMapping
     OutputChannelMapping
     (Maybe [Int])
     (Maybe [Int])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputChannelMapping' {Maybe [Int]
inputChannels :: Maybe [Int]
$sel:inputChannels:OutputChannelMapping' :: OutputChannelMapping -> Maybe [Int]
inputChannels} -> Maybe [Int]
inputChannels) (\s :: OutputChannelMapping
s@OutputChannelMapping' {} Maybe [Int]
a -> OutputChannelMapping
s {$sel:inputChannels:OutputChannelMapping' :: Maybe [Int]
inputChannels = Maybe [Int]
a} :: OutputChannelMapping) ((Maybe [Int] -> f (Maybe [Int]))
 -> OutputChannelMapping -> f OutputChannelMapping)
-> ((Maybe [Int] -> f (Maybe [Int]))
    -> Maybe [Int] -> f (Maybe [Int]))
-> (Maybe [Int] -> f (Maybe [Int]))
-> OutputChannelMapping
-> f OutputChannelMapping
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Int] [Int] [Int] [Int]
-> Iso (Maybe [Int]) (Maybe [Int]) (Maybe [Int]) (Maybe [Int])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Int] [Int] [Int] [Int]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON OutputChannelMapping where
  parseJSON :: Value -> Parser OutputChannelMapping
parseJSON =
    String
-> (Object -> Parser OutputChannelMapping)
-> Value
-> Parser OutputChannelMapping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OutputChannelMapping"
      ( \Object
x ->
          Maybe [Double] -> Maybe [Int] -> OutputChannelMapping
OutputChannelMapping'
            (Maybe [Double] -> Maybe [Int] -> OutputChannelMapping)
-> Parser (Maybe [Double])
-> Parser (Maybe [Int] -> OutputChannelMapping)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Double]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputChannelsFineTune"
                            Parser (Maybe (Maybe [Double]))
-> Maybe [Double] -> Parser (Maybe [Double])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Double]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [Int] -> OutputChannelMapping)
-> Parser (Maybe [Int]) -> Parser OutputChannelMapping
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Int]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputChannels" Parser (Maybe (Maybe [Int])) -> Maybe [Int] -> Parser (Maybe [Int])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Int]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable OutputChannelMapping

instance Prelude.NFData OutputChannelMapping

instance Core.ToJSON OutputChannelMapping where
  toJSON :: OutputChannelMapping -> Value
toJSON OutputChannelMapping' {Maybe [Double]
Maybe [Int]
inputChannels :: Maybe [Int]
inputChannelsFineTune :: Maybe [Double]
$sel:inputChannels:OutputChannelMapping' :: OutputChannelMapping -> Maybe [Int]
$sel:inputChannelsFineTune:OutputChannelMapping' :: OutputChannelMapping -> Maybe [Double]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"inputChannelsFineTune" Text -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Double] -> Pair) -> Maybe [Double] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Double]
inputChannelsFineTune,
            (Text
"inputChannels" Text -> [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Int] -> Pair) -> Maybe [Int] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Int]
inputChannels
          ]
      )