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

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

-- | Settings specific to caption sources that are specified by track number.
-- Currently, this is only IMSC captions in an IMF package. If your caption
-- source is IMSC 1.1 in a separate xml file, use FileSourceSettings
-- instead of TrackSourceSettings.
--
-- /See:/ 'newTrackSourceSettings' smart constructor.
data TrackSourceSettings = TrackSourceSettings'
  { -- | Use this setting to select a single captions track from a source. Track
    -- numbers correspond to the order in the captions source file. For IMF
    -- sources, track numbering is based on the order that the captions appear
    -- in the CPL. For example, use 1 to select the captions asset that is
    -- listed first in the CPL. To include more than one captions track in your
    -- job outputs, create multiple input captions selectors. Specify one track
    -- per selector.
    TrackSourceSettings -> Maybe Natural
trackNumber :: Prelude.Maybe Prelude.Natural
  }
  deriving (TrackSourceSettings -> TrackSourceSettings -> Bool
(TrackSourceSettings -> TrackSourceSettings -> Bool)
-> (TrackSourceSettings -> TrackSourceSettings -> Bool)
-> Eq TrackSourceSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrackSourceSettings -> TrackSourceSettings -> Bool
$c/= :: TrackSourceSettings -> TrackSourceSettings -> Bool
== :: TrackSourceSettings -> TrackSourceSettings -> Bool
$c== :: TrackSourceSettings -> TrackSourceSettings -> Bool
Prelude.Eq, ReadPrec [TrackSourceSettings]
ReadPrec TrackSourceSettings
Int -> ReadS TrackSourceSettings
ReadS [TrackSourceSettings]
(Int -> ReadS TrackSourceSettings)
-> ReadS [TrackSourceSettings]
-> ReadPrec TrackSourceSettings
-> ReadPrec [TrackSourceSettings]
-> Read TrackSourceSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrackSourceSettings]
$creadListPrec :: ReadPrec [TrackSourceSettings]
readPrec :: ReadPrec TrackSourceSettings
$creadPrec :: ReadPrec TrackSourceSettings
readList :: ReadS [TrackSourceSettings]
$creadList :: ReadS [TrackSourceSettings]
readsPrec :: Int -> ReadS TrackSourceSettings
$creadsPrec :: Int -> ReadS TrackSourceSettings
Prelude.Read, Int -> TrackSourceSettings -> ShowS
[TrackSourceSettings] -> ShowS
TrackSourceSettings -> String
(Int -> TrackSourceSettings -> ShowS)
-> (TrackSourceSettings -> String)
-> ([TrackSourceSettings] -> ShowS)
-> Show TrackSourceSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrackSourceSettings] -> ShowS
$cshowList :: [TrackSourceSettings] -> ShowS
show :: TrackSourceSettings -> String
$cshow :: TrackSourceSettings -> String
showsPrec :: Int -> TrackSourceSettings -> ShowS
$cshowsPrec :: Int -> TrackSourceSettings -> ShowS
Prelude.Show, (forall x. TrackSourceSettings -> Rep TrackSourceSettings x)
-> (forall x. Rep TrackSourceSettings x -> TrackSourceSettings)
-> Generic TrackSourceSettings
forall x. Rep TrackSourceSettings x -> TrackSourceSettings
forall x. TrackSourceSettings -> Rep TrackSourceSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrackSourceSettings x -> TrackSourceSettings
$cfrom :: forall x. TrackSourceSettings -> Rep TrackSourceSettings x
Prelude.Generic)

-- |
-- Create a value of 'TrackSourceSettings' 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:
--
-- 'trackNumber', 'trackSourceSettings_trackNumber' - Use this setting to select a single captions track from a source. Track
-- numbers correspond to the order in the captions source file. For IMF
-- sources, track numbering is based on the order that the captions appear
-- in the CPL. For example, use 1 to select the captions asset that is
-- listed first in the CPL. To include more than one captions track in your
-- job outputs, create multiple input captions selectors. Specify one track
-- per selector.
newTrackSourceSettings ::
  TrackSourceSettings
newTrackSourceSettings :: TrackSourceSettings
newTrackSourceSettings =
  TrackSourceSettings' :: Maybe Natural -> TrackSourceSettings
TrackSourceSettings' {$sel:trackNumber:TrackSourceSettings' :: Maybe Natural
trackNumber = Maybe Natural
forall a. Maybe a
Prelude.Nothing}

-- | Use this setting to select a single captions track from a source. Track
-- numbers correspond to the order in the captions source file. For IMF
-- sources, track numbering is based on the order that the captions appear
-- in the CPL. For example, use 1 to select the captions asset that is
-- listed first in the CPL. To include more than one captions track in your
-- job outputs, create multiple input captions selectors. Specify one track
-- per selector.
trackSourceSettings_trackNumber :: Lens.Lens' TrackSourceSettings (Prelude.Maybe Prelude.Natural)
trackSourceSettings_trackNumber :: (Maybe Natural -> f (Maybe Natural))
-> TrackSourceSettings -> f TrackSourceSettings
trackSourceSettings_trackNumber = (TrackSourceSettings -> Maybe Natural)
-> (TrackSourceSettings -> Maybe Natural -> TrackSourceSettings)
-> Lens
     TrackSourceSettings
     TrackSourceSettings
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrackSourceSettings' {Maybe Natural
trackNumber :: Maybe Natural
$sel:trackNumber:TrackSourceSettings' :: TrackSourceSettings -> Maybe Natural
trackNumber} -> Maybe Natural
trackNumber) (\s :: TrackSourceSettings
s@TrackSourceSettings' {} Maybe Natural
a -> TrackSourceSettings
s {$sel:trackNumber:TrackSourceSettings' :: Maybe Natural
trackNumber = Maybe Natural
a} :: TrackSourceSettings)

instance Core.FromJSON TrackSourceSettings where
  parseJSON :: Value -> Parser TrackSourceSettings
parseJSON =
    String
-> (Object -> Parser TrackSourceSettings)
-> Value
-> Parser TrackSourceSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TrackSourceSettings"
      ( \Object
x ->
          Maybe Natural -> TrackSourceSettings
TrackSourceSettings'
            (Maybe Natural -> TrackSourceSettings)
-> Parser (Maybe Natural) -> Parser TrackSourceSettings
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
"trackNumber")
      )

instance Prelude.Hashable TrackSourceSettings

instance Prelude.NFData TrackSourceSettings

instance Core.ToJSON TrackSourceSettings where
  toJSON :: TrackSourceSettings -> Value
toJSON TrackSourceSettings' {Maybe Natural
trackNumber :: Maybe Natural
$sel:trackNumber:TrackSourceSettings' :: TrackSourceSettings -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"trackNumber" 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
trackNumber]
      )