{-# 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.KinesisVideoArchivedMedia.Types.HLSFragmentSelector
-- 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.KinesisVideoArchivedMedia.Types.HLSFragmentSelector where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideoArchivedMedia.Types.HLSFragmentSelectorType
import Amazonka.KinesisVideoArchivedMedia.Types.HLSTimestampRange
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the range of timestamps for the requested media, and the source
-- of the timestamps.
--
-- /See:/ 'newHLSFragmentSelector' smart constructor.
data HLSFragmentSelector = HLSFragmentSelector'
  { -- | The source of the timestamps for the requested media.
    --
    -- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
    -- GetHLSStreamingSessionURLInput$PlaybackMode is @ON_DEMAND@ or
    -- @LIVE_REPLAY@, the first fragment ingested with a producer timestamp
    -- within the specified FragmentSelector$TimestampRange is included in the
    -- media playlist. In addition, the fragments with producer timestamps
    -- within the @TimestampRange@ ingested immediately following the first
    -- fragment (up to the
    -- GetHLSStreamingSessionURLInput$MaxMediaPlaylistFragmentResults value)
    -- are included.
    --
    -- Fragments that have duplicate producer timestamps are deduplicated. This
    -- means that if producers are producing a stream of fragments with
    -- producer timestamps that are approximately equal to the true clock time,
    -- the HLS media playlists will contain all of the fragments within the
    -- requested timestamp range. If some fragments are ingested within the
    -- same time range and very different points in time, only the oldest
    -- ingested collection of fragments are returned.
    --
    -- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
    -- GetHLSStreamingSessionURLInput$PlaybackMode is @LIVE@, the producer
    -- timestamps are used in the MP4 fragments and for deduplication. But the
    -- most recently ingested fragments based on server timestamps are included
    -- in the HLS media playlist. This means that even if fragments ingested in
    -- the past have producer timestamps with values now, they are not included
    -- in the HLS media playlist.
    --
    -- The default is @SERVER_TIMESTAMP@.
    HLSFragmentSelector -> Maybe HLSFragmentSelectorType
fragmentSelectorType :: Prelude.Maybe HLSFragmentSelectorType,
    -- | The start and end of the timestamp range for the requested media.
    --
    -- This value should not be present if @PlaybackType@ is @LIVE@.
    HLSFragmentSelector -> Maybe HLSTimestampRange
timestampRange :: Prelude.Maybe HLSTimestampRange
  }
  deriving (HLSFragmentSelector -> HLSFragmentSelector -> Bool
(HLSFragmentSelector -> HLSFragmentSelector -> Bool)
-> (HLSFragmentSelector -> HLSFragmentSelector -> Bool)
-> Eq HLSFragmentSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HLSFragmentSelector -> HLSFragmentSelector -> Bool
$c/= :: HLSFragmentSelector -> HLSFragmentSelector -> Bool
== :: HLSFragmentSelector -> HLSFragmentSelector -> Bool
$c== :: HLSFragmentSelector -> HLSFragmentSelector -> Bool
Prelude.Eq, ReadPrec [HLSFragmentSelector]
ReadPrec HLSFragmentSelector
Int -> ReadS HLSFragmentSelector
ReadS [HLSFragmentSelector]
(Int -> ReadS HLSFragmentSelector)
-> ReadS [HLSFragmentSelector]
-> ReadPrec HLSFragmentSelector
-> ReadPrec [HLSFragmentSelector]
-> Read HLSFragmentSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HLSFragmentSelector]
$creadListPrec :: ReadPrec [HLSFragmentSelector]
readPrec :: ReadPrec HLSFragmentSelector
$creadPrec :: ReadPrec HLSFragmentSelector
readList :: ReadS [HLSFragmentSelector]
$creadList :: ReadS [HLSFragmentSelector]
readsPrec :: Int -> ReadS HLSFragmentSelector
$creadsPrec :: Int -> ReadS HLSFragmentSelector
Prelude.Read, Int -> HLSFragmentSelector -> ShowS
[HLSFragmentSelector] -> ShowS
HLSFragmentSelector -> String
(Int -> HLSFragmentSelector -> ShowS)
-> (HLSFragmentSelector -> String)
-> ([HLSFragmentSelector] -> ShowS)
-> Show HLSFragmentSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HLSFragmentSelector] -> ShowS
$cshowList :: [HLSFragmentSelector] -> ShowS
show :: HLSFragmentSelector -> String
$cshow :: HLSFragmentSelector -> String
showsPrec :: Int -> HLSFragmentSelector -> ShowS
$cshowsPrec :: Int -> HLSFragmentSelector -> ShowS
Prelude.Show, (forall x. HLSFragmentSelector -> Rep HLSFragmentSelector x)
-> (forall x. Rep HLSFragmentSelector x -> HLSFragmentSelector)
-> Generic HLSFragmentSelector
forall x. Rep HLSFragmentSelector x -> HLSFragmentSelector
forall x. HLSFragmentSelector -> Rep HLSFragmentSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HLSFragmentSelector x -> HLSFragmentSelector
$cfrom :: forall x. HLSFragmentSelector -> Rep HLSFragmentSelector x
Prelude.Generic)

-- |
-- Create a value of 'HLSFragmentSelector' 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:
--
-- 'fragmentSelectorType', 'hLSFragmentSelector_fragmentSelectorType' - The source of the timestamps for the requested media.
--
-- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
-- GetHLSStreamingSessionURLInput$PlaybackMode is @ON_DEMAND@ or
-- @LIVE_REPLAY@, the first fragment ingested with a producer timestamp
-- within the specified FragmentSelector$TimestampRange is included in the
-- media playlist. In addition, the fragments with producer timestamps
-- within the @TimestampRange@ ingested immediately following the first
-- fragment (up to the
-- GetHLSStreamingSessionURLInput$MaxMediaPlaylistFragmentResults value)
-- are included.
--
-- Fragments that have duplicate producer timestamps are deduplicated. This
-- means that if producers are producing a stream of fragments with
-- producer timestamps that are approximately equal to the true clock time,
-- the HLS media playlists will contain all of the fragments within the
-- requested timestamp range. If some fragments are ingested within the
-- same time range and very different points in time, only the oldest
-- ingested collection of fragments are returned.
--
-- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
-- GetHLSStreamingSessionURLInput$PlaybackMode is @LIVE@, the producer
-- timestamps are used in the MP4 fragments and for deduplication. But the
-- most recently ingested fragments based on server timestamps are included
-- in the HLS media playlist. This means that even if fragments ingested in
-- the past have producer timestamps with values now, they are not included
-- in the HLS media playlist.
--
-- The default is @SERVER_TIMESTAMP@.
--
-- 'timestampRange', 'hLSFragmentSelector_timestampRange' - The start and end of the timestamp range for the requested media.
--
-- This value should not be present if @PlaybackType@ is @LIVE@.
newHLSFragmentSelector ::
  HLSFragmentSelector
newHLSFragmentSelector :: HLSFragmentSelector
newHLSFragmentSelector =
  HLSFragmentSelector' :: Maybe HLSFragmentSelectorType
-> Maybe HLSTimestampRange -> HLSFragmentSelector
HLSFragmentSelector'
    { $sel:fragmentSelectorType:HLSFragmentSelector' :: Maybe HLSFragmentSelectorType
fragmentSelectorType =
        Maybe HLSFragmentSelectorType
forall a. Maybe a
Prelude.Nothing,
      $sel:timestampRange:HLSFragmentSelector' :: Maybe HLSTimestampRange
timestampRange = Maybe HLSTimestampRange
forall a. Maybe a
Prelude.Nothing
    }

-- | The source of the timestamps for the requested media.
--
-- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
-- GetHLSStreamingSessionURLInput$PlaybackMode is @ON_DEMAND@ or
-- @LIVE_REPLAY@, the first fragment ingested with a producer timestamp
-- within the specified FragmentSelector$TimestampRange is included in the
-- media playlist. In addition, the fragments with producer timestamps
-- within the @TimestampRange@ ingested immediately following the first
-- fragment (up to the
-- GetHLSStreamingSessionURLInput$MaxMediaPlaylistFragmentResults value)
-- are included.
--
-- Fragments that have duplicate producer timestamps are deduplicated. This
-- means that if producers are producing a stream of fragments with
-- producer timestamps that are approximately equal to the true clock time,
-- the HLS media playlists will contain all of the fragments within the
-- requested timestamp range. If some fragments are ingested within the
-- same time range and very different points in time, only the oldest
-- ingested collection of fragments are returned.
--
-- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
-- GetHLSStreamingSessionURLInput$PlaybackMode is @LIVE@, the producer
-- timestamps are used in the MP4 fragments and for deduplication. But the
-- most recently ingested fragments based on server timestamps are included
-- in the HLS media playlist. This means that even if fragments ingested in
-- the past have producer timestamps with values now, they are not included
-- in the HLS media playlist.
--
-- The default is @SERVER_TIMESTAMP@.
hLSFragmentSelector_fragmentSelectorType :: Lens.Lens' HLSFragmentSelector (Prelude.Maybe HLSFragmentSelectorType)
hLSFragmentSelector_fragmentSelectorType :: (Maybe HLSFragmentSelectorType
 -> f (Maybe HLSFragmentSelectorType))
-> HLSFragmentSelector -> f HLSFragmentSelector
hLSFragmentSelector_fragmentSelectorType = (HLSFragmentSelector -> Maybe HLSFragmentSelectorType)
-> (HLSFragmentSelector
    -> Maybe HLSFragmentSelectorType -> HLSFragmentSelector)
-> Lens
     HLSFragmentSelector
     HLSFragmentSelector
     (Maybe HLSFragmentSelectorType)
     (Maybe HLSFragmentSelectorType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HLSFragmentSelector' {Maybe HLSFragmentSelectorType
fragmentSelectorType :: Maybe HLSFragmentSelectorType
$sel:fragmentSelectorType:HLSFragmentSelector' :: HLSFragmentSelector -> Maybe HLSFragmentSelectorType
fragmentSelectorType} -> Maybe HLSFragmentSelectorType
fragmentSelectorType) (\s :: HLSFragmentSelector
s@HLSFragmentSelector' {} Maybe HLSFragmentSelectorType
a -> HLSFragmentSelector
s {$sel:fragmentSelectorType:HLSFragmentSelector' :: Maybe HLSFragmentSelectorType
fragmentSelectorType = Maybe HLSFragmentSelectorType
a} :: HLSFragmentSelector)

-- | The start and end of the timestamp range for the requested media.
--
-- This value should not be present if @PlaybackType@ is @LIVE@.
hLSFragmentSelector_timestampRange :: Lens.Lens' HLSFragmentSelector (Prelude.Maybe HLSTimestampRange)
hLSFragmentSelector_timestampRange :: (Maybe HLSTimestampRange -> f (Maybe HLSTimestampRange))
-> HLSFragmentSelector -> f HLSFragmentSelector
hLSFragmentSelector_timestampRange = (HLSFragmentSelector -> Maybe HLSTimestampRange)
-> (HLSFragmentSelector
    -> Maybe HLSTimestampRange -> HLSFragmentSelector)
-> Lens
     HLSFragmentSelector
     HLSFragmentSelector
     (Maybe HLSTimestampRange)
     (Maybe HLSTimestampRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HLSFragmentSelector' {Maybe HLSTimestampRange
timestampRange :: Maybe HLSTimestampRange
$sel:timestampRange:HLSFragmentSelector' :: HLSFragmentSelector -> Maybe HLSTimestampRange
timestampRange} -> Maybe HLSTimestampRange
timestampRange) (\s :: HLSFragmentSelector
s@HLSFragmentSelector' {} Maybe HLSTimestampRange
a -> HLSFragmentSelector
s {$sel:timestampRange:HLSFragmentSelector' :: Maybe HLSTimestampRange
timestampRange = Maybe HLSTimestampRange
a} :: HLSFragmentSelector)

instance Prelude.Hashable HLSFragmentSelector

instance Prelude.NFData HLSFragmentSelector

instance Core.ToJSON HLSFragmentSelector where
  toJSON :: HLSFragmentSelector -> Value
toJSON HLSFragmentSelector' {Maybe HLSFragmentSelectorType
Maybe HLSTimestampRange
timestampRange :: Maybe HLSTimestampRange
fragmentSelectorType :: Maybe HLSFragmentSelectorType
$sel:timestampRange:HLSFragmentSelector' :: HLSFragmentSelector -> Maybe HLSTimestampRange
$sel:fragmentSelectorType:HLSFragmentSelector' :: HLSFragmentSelector -> Maybe HLSFragmentSelectorType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FragmentSelectorType" Text -> HLSFragmentSelectorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HLSFragmentSelectorType -> Pair)
-> Maybe HLSFragmentSelectorType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HLSFragmentSelectorType
fragmentSelectorType,
            (Text
"TimestampRange" Text -> HLSTimestampRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HLSTimestampRange -> Pair)
-> Maybe HLSTimestampRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HLSTimestampRange
timestampRange
          ]
      )