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

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideoArchivedMedia.Types.DASHFragmentSelectorType
import Amazonka.KinesisVideoArchivedMedia.Types.DASHTimestampRange
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:/ 'newDASHFragmentSelector' smart constructor.
data DASHFragmentSelector = DASHFragmentSelector'
  { -- | The source of the timestamps for the requested media.
    --
    -- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
    -- GetDASHStreamingSessionURLInput$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
    -- GetDASHStreamingSessionURLInput$MaxManifestFragmentResults 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 MPEG-DASH manifest 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
    -- GetDASHStreamingSessionURLInput$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 MPEG-DASH manifest. 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@.
    DASHFragmentSelector -> Maybe DASHFragmentSelectorType
fragmentSelectorType :: Prelude.Maybe DASHFragmentSelectorType,
    -- | The start and end of the timestamp range for the requested media.
    --
    -- This value should not be present if @PlaybackType@ is @LIVE@.
    DASHFragmentSelector -> Maybe DASHTimestampRange
timestampRange :: Prelude.Maybe DASHTimestampRange
  }
  deriving (DASHFragmentSelector -> DASHFragmentSelector -> Bool
(DASHFragmentSelector -> DASHFragmentSelector -> Bool)
-> (DASHFragmentSelector -> DASHFragmentSelector -> Bool)
-> Eq DASHFragmentSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DASHFragmentSelector -> DASHFragmentSelector -> Bool
$c/= :: DASHFragmentSelector -> DASHFragmentSelector -> Bool
== :: DASHFragmentSelector -> DASHFragmentSelector -> Bool
$c== :: DASHFragmentSelector -> DASHFragmentSelector -> Bool
Prelude.Eq, ReadPrec [DASHFragmentSelector]
ReadPrec DASHFragmentSelector
Int -> ReadS DASHFragmentSelector
ReadS [DASHFragmentSelector]
(Int -> ReadS DASHFragmentSelector)
-> ReadS [DASHFragmentSelector]
-> ReadPrec DASHFragmentSelector
-> ReadPrec [DASHFragmentSelector]
-> Read DASHFragmentSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DASHFragmentSelector]
$creadListPrec :: ReadPrec [DASHFragmentSelector]
readPrec :: ReadPrec DASHFragmentSelector
$creadPrec :: ReadPrec DASHFragmentSelector
readList :: ReadS [DASHFragmentSelector]
$creadList :: ReadS [DASHFragmentSelector]
readsPrec :: Int -> ReadS DASHFragmentSelector
$creadsPrec :: Int -> ReadS DASHFragmentSelector
Prelude.Read, Int -> DASHFragmentSelector -> ShowS
[DASHFragmentSelector] -> ShowS
DASHFragmentSelector -> String
(Int -> DASHFragmentSelector -> ShowS)
-> (DASHFragmentSelector -> String)
-> ([DASHFragmentSelector] -> ShowS)
-> Show DASHFragmentSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DASHFragmentSelector] -> ShowS
$cshowList :: [DASHFragmentSelector] -> ShowS
show :: DASHFragmentSelector -> String
$cshow :: DASHFragmentSelector -> String
showsPrec :: Int -> DASHFragmentSelector -> ShowS
$cshowsPrec :: Int -> DASHFragmentSelector -> ShowS
Prelude.Show, (forall x. DASHFragmentSelector -> Rep DASHFragmentSelector x)
-> (forall x. Rep DASHFragmentSelector x -> DASHFragmentSelector)
-> Generic DASHFragmentSelector
forall x. Rep DASHFragmentSelector x -> DASHFragmentSelector
forall x. DASHFragmentSelector -> Rep DASHFragmentSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DASHFragmentSelector x -> DASHFragmentSelector
$cfrom :: forall x. DASHFragmentSelector -> Rep DASHFragmentSelector x
Prelude.Generic)

-- |
-- Create a value of 'DASHFragmentSelector' 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', 'dASHFragmentSelector_fragmentSelectorType' - The source of the timestamps for the requested media.
--
-- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
-- GetDASHStreamingSessionURLInput$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
-- GetDASHStreamingSessionURLInput$MaxManifestFragmentResults 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 MPEG-DASH manifest 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
-- GetDASHStreamingSessionURLInput$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 MPEG-DASH manifest. 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', 'dASHFragmentSelector_timestampRange' - The start and end of the timestamp range for the requested media.
--
-- This value should not be present if @PlaybackType@ is @LIVE@.
newDASHFragmentSelector ::
  DASHFragmentSelector
newDASHFragmentSelector :: DASHFragmentSelector
newDASHFragmentSelector =
  DASHFragmentSelector' :: Maybe DASHFragmentSelectorType
-> Maybe DASHTimestampRange -> DASHFragmentSelector
DASHFragmentSelector'
    { $sel:fragmentSelectorType:DASHFragmentSelector' :: Maybe DASHFragmentSelectorType
fragmentSelectorType =
        Maybe DASHFragmentSelectorType
forall a. Maybe a
Prelude.Nothing,
      $sel:timestampRange:DASHFragmentSelector' :: Maybe DASHTimestampRange
timestampRange = Maybe DASHTimestampRange
forall a. Maybe a
Prelude.Nothing
    }

-- | The source of the timestamps for the requested media.
--
-- When @FragmentSelectorType@ is set to @PRODUCER_TIMESTAMP@ and
-- GetDASHStreamingSessionURLInput$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
-- GetDASHStreamingSessionURLInput$MaxManifestFragmentResults 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 MPEG-DASH manifest 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
-- GetDASHStreamingSessionURLInput$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 MPEG-DASH manifest. 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@.
dASHFragmentSelector_fragmentSelectorType :: Lens.Lens' DASHFragmentSelector (Prelude.Maybe DASHFragmentSelectorType)
dASHFragmentSelector_fragmentSelectorType :: (Maybe DASHFragmentSelectorType
 -> f (Maybe DASHFragmentSelectorType))
-> DASHFragmentSelector -> f DASHFragmentSelector
dASHFragmentSelector_fragmentSelectorType = (DASHFragmentSelector -> Maybe DASHFragmentSelectorType)
-> (DASHFragmentSelector
    -> Maybe DASHFragmentSelectorType -> DASHFragmentSelector)
-> Lens
     DASHFragmentSelector
     DASHFragmentSelector
     (Maybe DASHFragmentSelectorType)
     (Maybe DASHFragmentSelectorType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DASHFragmentSelector' {Maybe DASHFragmentSelectorType
fragmentSelectorType :: Maybe DASHFragmentSelectorType
$sel:fragmentSelectorType:DASHFragmentSelector' :: DASHFragmentSelector -> Maybe DASHFragmentSelectorType
fragmentSelectorType} -> Maybe DASHFragmentSelectorType
fragmentSelectorType) (\s :: DASHFragmentSelector
s@DASHFragmentSelector' {} Maybe DASHFragmentSelectorType
a -> DASHFragmentSelector
s {$sel:fragmentSelectorType:DASHFragmentSelector' :: Maybe DASHFragmentSelectorType
fragmentSelectorType = Maybe DASHFragmentSelectorType
a} :: DASHFragmentSelector)

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

instance Prelude.Hashable DASHFragmentSelector

instance Prelude.NFData DASHFragmentSelector

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