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

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

-- | To insert ID3 tags in your output, specify two values. Use ID3 tag (Id3)
-- to specify the base 64 encoded string and use Timecode (TimeCode) to
-- specify the time when the tag should be inserted. To insert multiple ID3
-- tags in your output, create multiple instances of ID3 insertion
-- (Id3Insertion).
--
-- /See:/ 'newId3Insertion' smart constructor.
data Id3Insertion = Id3Insertion'
  { -- | Use ID3 tag (Id3) to provide a tag value in base64-encode format.
    Id3Insertion -> Maybe Text
id3 :: Prelude.Maybe Prelude.Text,
    -- | Provide a Timecode (TimeCode) in HH:MM:SS:FF or HH:MM:SS;FF format.
    Id3Insertion -> Maybe Text
timecode :: Prelude.Maybe Prelude.Text
  }
  deriving (Id3Insertion -> Id3Insertion -> Bool
(Id3Insertion -> Id3Insertion -> Bool)
-> (Id3Insertion -> Id3Insertion -> Bool) -> Eq Id3Insertion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Id3Insertion -> Id3Insertion -> Bool
$c/= :: Id3Insertion -> Id3Insertion -> Bool
== :: Id3Insertion -> Id3Insertion -> Bool
$c== :: Id3Insertion -> Id3Insertion -> Bool
Prelude.Eq, ReadPrec [Id3Insertion]
ReadPrec Id3Insertion
Int -> ReadS Id3Insertion
ReadS [Id3Insertion]
(Int -> ReadS Id3Insertion)
-> ReadS [Id3Insertion]
-> ReadPrec Id3Insertion
-> ReadPrec [Id3Insertion]
-> Read Id3Insertion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Id3Insertion]
$creadListPrec :: ReadPrec [Id3Insertion]
readPrec :: ReadPrec Id3Insertion
$creadPrec :: ReadPrec Id3Insertion
readList :: ReadS [Id3Insertion]
$creadList :: ReadS [Id3Insertion]
readsPrec :: Int -> ReadS Id3Insertion
$creadsPrec :: Int -> ReadS Id3Insertion
Prelude.Read, Int -> Id3Insertion -> ShowS
[Id3Insertion] -> ShowS
Id3Insertion -> String
(Int -> Id3Insertion -> ShowS)
-> (Id3Insertion -> String)
-> ([Id3Insertion] -> ShowS)
-> Show Id3Insertion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Id3Insertion] -> ShowS
$cshowList :: [Id3Insertion] -> ShowS
show :: Id3Insertion -> String
$cshow :: Id3Insertion -> String
showsPrec :: Int -> Id3Insertion -> ShowS
$cshowsPrec :: Int -> Id3Insertion -> ShowS
Prelude.Show, (forall x. Id3Insertion -> Rep Id3Insertion x)
-> (forall x. Rep Id3Insertion x -> Id3Insertion)
-> Generic Id3Insertion
forall x. Rep Id3Insertion x -> Id3Insertion
forall x. Id3Insertion -> Rep Id3Insertion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Id3Insertion x -> Id3Insertion
$cfrom :: forall x. Id3Insertion -> Rep Id3Insertion x
Prelude.Generic)

-- |
-- Create a value of 'Id3Insertion' 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:
--
-- 'id3', 'id3Insertion_id3' - Use ID3 tag (Id3) to provide a tag value in base64-encode format.
--
-- 'timecode', 'id3Insertion_timecode' - Provide a Timecode (TimeCode) in HH:MM:SS:FF or HH:MM:SS;FF format.
newId3Insertion ::
  Id3Insertion
newId3Insertion :: Id3Insertion
newId3Insertion =
  Id3Insertion' :: Maybe Text -> Maybe Text -> Id3Insertion
Id3Insertion'
    { $sel:id3:Id3Insertion' :: Maybe Text
id3 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timecode:Id3Insertion' :: Maybe Text
timecode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Use ID3 tag (Id3) to provide a tag value in base64-encode format.
id3Insertion_id3 :: Lens.Lens' Id3Insertion (Prelude.Maybe Prelude.Text)
id3Insertion_id3 :: (Maybe Text -> f (Maybe Text)) -> Id3Insertion -> f Id3Insertion
id3Insertion_id3 = (Id3Insertion -> Maybe Text)
-> (Id3Insertion -> Maybe Text -> Id3Insertion)
-> Lens Id3Insertion Id3Insertion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Id3Insertion' {Maybe Text
id3 :: Maybe Text
$sel:id3:Id3Insertion' :: Id3Insertion -> Maybe Text
id3} -> Maybe Text
id3) (\s :: Id3Insertion
s@Id3Insertion' {} Maybe Text
a -> Id3Insertion
s {$sel:id3:Id3Insertion' :: Maybe Text
id3 = Maybe Text
a} :: Id3Insertion)

-- | Provide a Timecode (TimeCode) in HH:MM:SS:FF or HH:MM:SS;FF format.
id3Insertion_timecode :: Lens.Lens' Id3Insertion (Prelude.Maybe Prelude.Text)
id3Insertion_timecode :: (Maybe Text -> f (Maybe Text)) -> Id3Insertion -> f Id3Insertion
id3Insertion_timecode = (Id3Insertion -> Maybe Text)
-> (Id3Insertion -> Maybe Text -> Id3Insertion)
-> Lens Id3Insertion Id3Insertion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Id3Insertion' {Maybe Text
timecode :: Maybe Text
$sel:timecode:Id3Insertion' :: Id3Insertion -> Maybe Text
timecode} -> Maybe Text
timecode) (\s :: Id3Insertion
s@Id3Insertion' {} Maybe Text
a -> Id3Insertion
s {$sel:timecode:Id3Insertion' :: Maybe Text
timecode = Maybe Text
a} :: Id3Insertion)

instance Core.FromJSON Id3Insertion where
  parseJSON :: Value -> Parser Id3Insertion
parseJSON =
    String
-> (Object -> Parser Id3Insertion) -> Value -> Parser Id3Insertion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Id3Insertion"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Id3Insertion
Id3Insertion'
            (Maybe Text -> Maybe Text -> Id3Insertion)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Id3Insertion)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"id3")
            Parser (Maybe Text -> Id3Insertion)
-> Parser (Maybe Text) -> Parser Id3Insertion
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timecode")
      )

instance Prelude.Hashable Id3Insertion

instance Prelude.NFData Id3Insertion

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