{-# 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.AudioTrackSelection
-- 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.AudioTrackSelection 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.AudioDolbyEDecode
import Amazonka.MediaLive.Types.AudioTrack
import qualified Amazonka.Prelude as Prelude

-- | Audio Track Selection
--
-- /See:/ 'newAudioTrackSelection' smart constructor.
data AudioTrackSelection = AudioTrackSelection'
  { -- | Configure decoding options for Dolby E streams - these should be Dolby E
    -- frames carried in PCM streams tagged with SMPTE-337
    AudioTrackSelection -> Maybe AudioDolbyEDecode
dolbyEDecode :: Prelude.Maybe AudioDolbyEDecode,
    -- | Selects one or more unique audio tracks from within a source.
    AudioTrackSelection -> [AudioTrack]
tracks :: [AudioTrack]
  }
  deriving (AudioTrackSelection -> AudioTrackSelection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AudioTrackSelection -> AudioTrackSelection -> Bool
$c/= :: AudioTrackSelection -> AudioTrackSelection -> Bool
== :: AudioTrackSelection -> AudioTrackSelection -> Bool
$c== :: AudioTrackSelection -> AudioTrackSelection -> Bool
Prelude.Eq, ReadPrec [AudioTrackSelection]
ReadPrec AudioTrackSelection
Int -> ReadS AudioTrackSelection
ReadS [AudioTrackSelection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AudioTrackSelection]
$creadListPrec :: ReadPrec [AudioTrackSelection]
readPrec :: ReadPrec AudioTrackSelection
$creadPrec :: ReadPrec AudioTrackSelection
readList :: ReadS [AudioTrackSelection]
$creadList :: ReadS [AudioTrackSelection]
readsPrec :: Int -> ReadS AudioTrackSelection
$creadsPrec :: Int -> ReadS AudioTrackSelection
Prelude.Read, Int -> AudioTrackSelection -> ShowS
[AudioTrackSelection] -> ShowS
AudioTrackSelection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AudioTrackSelection] -> ShowS
$cshowList :: [AudioTrackSelection] -> ShowS
show :: AudioTrackSelection -> String
$cshow :: AudioTrackSelection -> String
showsPrec :: Int -> AudioTrackSelection -> ShowS
$cshowsPrec :: Int -> AudioTrackSelection -> ShowS
Prelude.Show, forall x. Rep AudioTrackSelection x -> AudioTrackSelection
forall x. AudioTrackSelection -> Rep AudioTrackSelection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AudioTrackSelection x -> AudioTrackSelection
$cfrom :: forall x. AudioTrackSelection -> Rep AudioTrackSelection x
Prelude.Generic)

-- |
-- Create a value of 'AudioTrackSelection' 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:
--
-- 'dolbyEDecode', 'audioTrackSelection_dolbyEDecode' - Configure decoding options for Dolby E streams - these should be Dolby E
-- frames carried in PCM streams tagged with SMPTE-337
--
-- 'tracks', 'audioTrackSelection_tracks' - Selects one or more unique audio tracks from within a source.
newAudioTrackSelection ::
  AudioTrackSelection
newAudioTrackSelection :: AudioTrackSelection
newAudioTrackSelection =
  AudioTrackSelection'
    { $sel:dolbyEDecode:AudioTrackSelection' :: Maybe AudioDolbyEDecode
dolbyEDecode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tracks:AudioTrackSelection' :: [AudioTrack]
tracks = forall a. Monoid a => a
Prelude.mempty
    }

-- | Configure decoding options for Dolby E streams - these should be Dolby E
-- frames carried in PCM streams tagged with SMPTE-337
audioTrackSelection_dolbyEDecode :: Lens.Lens' AudioTrackSelection (Prelude.Maybe AudioDolbyEDecode)
audioTrackSelection_dolbyEDecode :: Lens' AudioTrackSelection (Maybe AudioDolbyEDecode)
audioTrackSelection_dolbyEDecode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioTrackSelection' {Maybe AudioDolbyEDecode
dolbyEDecode :: Maybe AudioDolbyEDecode
$sel:dolbyEDecode:AudioTrackSelection' :: AudioTrackSelection -> Maybe AudioDolbyEDecode
dolbyEDecode} -> Maybe AudioDolbyEDecode
dolbyEDecode) (\s :: AudioTrackSelection
s@AudioTrackSelection' {} Maybe AudioDolbyEDecode
a -> AudioTrackSelection
s {$sel:dolbyEDecode:AudioTrackSelection' :: Maybe AudioDolbyEDecode
dolbyEDecode = Maybe AudioDolbyEDecode
a} :: AudioTrackSelection)

-- | Selects one or more unique audio tracks from within a source.
audioTrackSelection_tracks :: Lens.Lens' AudioTrackSelection [AudioTrack]
audioTrackSelection_tracks :: Lens' AudioTrackSelection [AudioTrack]
audioTrackSelection_tracks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AudioTrackSelection' {[AudioTrack]
tracks :: [AudioTrack]
$sel:tracks:AudioTrackSelection' :: AudioTrackSelection -> [AudioTrack]
tracks} -> [AudioTrack]
tracks) (\s :: AudioTrackSelection
s@AudioTrackSelection' {} [AudioTrack]
a -> AudioTrackSelection
s {$sel:tracks:AudioTrackSelection' :: [AudioTrack]
tracks = [AudioTrack]
a} :: AudioTrackSelection) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AudioTrackSelection where
  parseJSON :: Value -> Parser AudioTrackSelection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AudioTrackSelection"
      ( \Object
x ->
          Maybe AudioDolbyEDecode -> [AudioTrack] -> AudioTrackSelection
AudioTrackSelection'
            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
"dolbyEDecode")
            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
"tracks" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AudioTrackSelection where
  hashWithSalt :: Int -> AudioTrackSelection -> Int
hashWithSalt Int
_salt AudioTrackSelection' {[AudioTrack]
Maybe AudioDolbyEDecode
tracks :: [AudioTrack]
dolbyEDecode :: Maybe AudioDolbyEDecode
$sel:tracks:AudioTrackSelection' :: AudioTrackSelection -> [AudioTrack]
$sel:dolbyEDecode:AudioTrackSelection' :: AudioTrackSelection -> Maybe AudioDolbyEDecode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AudioDolbyEDecode
dolbyEDecode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AudioTrack]
tracks

instance Prelude.NFData AudioTrackSelection where
  rnf :: AudioTrackSelection -> ()
rnf AudioTrackSelection' {[AudioTrack]
Maybe AudioDolbyEDecode
tracks :: [AudioTrack]
dolbyEDecode :: Maybe AudioDolbyEDecode
$sel:tracks:AudioTrackSelection' :: AudioTrackSelection -> [AudioTrack]
$sel:dolbyEDecode:AudioTrackSelection' :: AudioTrackSelection -> Maybe AudioDolbyEDecode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AudioDolbyEDecode
dolbyEDecode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AudioTrack]
tracks

instance Data.ToJSON AudioTrackSelection where
  toJSON :: AudioTrackSelection -> Value
toJSON AudioTrackSelection' {[AudioTrack]
Maybe AudioDolbyEDecode
tracks :: [AudioTrack]
dolbyEDecode :: Maybe AudioDolbyEDecode
$sel:tracks:AudioTrackSelection' :: AudioTrackSelection -> [AudioTrack]
$sel:dolbyEDecode:AudioTrackSelection' :: AudioTrackSelection -> Maybe AudioDolbyEDecode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"dolbyEDecode" 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 AudioDolbyEDecode
dolbyEDecode,
            forall a. a -> Maybe a
Prelude.Just (Key
"tracks" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AudioTrack]
tracks)
          ]
      )