{-# 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.ElasticTranscoder.Types.DetectedProperties
-- 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.ElasticTranscoder.Types.DetectedProperties where

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

-- | The detected properties of the input file. Elastic Transcoder identifies
-- these values from the input file.
--
-- /See:/ 'newDetectedProperties' smart constructor.
data DetectedProperties = DetectedProperties'
  { -- | The detected height of the input file, in pixels.
    DetectedProperties -> Maybe Int
height :: Prelude.Maybe Prelude.Int,
    -- | The detected frame rate of the input file, in frames per second.
    DetectedProperties -> Maybe Text
frameRate :: Prelude.Maybe Prelude.Text,
    -- | The detected file size of the input file, in bytes.
    DetectedProperties -> Maybe Integer
fileSize :: Prelude.Maybe Prelude.Integer,
    -- | The detected width of the input file, in pixels.
    DetectedProperties -> Maybe Int
width :: Prelude.Maybe Prelude.Int,
    -- | The detected duration of the input file, in milliseconds.
    DetectedProperties -> Maybe Integer
durationMillis :: Prelude.Maybe Prelude.Integer
  }
  deriving (DetectedProperties -> DetectedProperties -> Bool
(DetectedProperties -> DetectedProperties -> Bool)
-> (DetectedProperties -> DetectedProperties -> Bool)
-> Eq DetectedProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectedProperties -> DetectedProperties -> Bool
$c/= :: DetectedProperties -> DetectedProperties -> Bool
== :: DetectedProperties -> DetectedProperties -> Bool
$c== :: DetectedProperties -> DetectedProperties -> Bool
Prelude.Eq, ReadPrec [DetectedProperties]
ReadPrec DetectedProperties
Int -> ReadS DetectedProperties
ReadS [DetectedProperties]
(Int -> ReadS DetectedProperties)
-> ReadS [DetectedProperties]
-> ReadPrec DetectedProperties
-> ReadPrec [DetectedProperties]
-> Read DetectedProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectedProperties]
$creadListPrec :: ReadPrec [DetectedProperties]
readPrec :: ReadPrec DetectedProperties
$creadPrec :: ReadPrec DetectedProperties
readList :: ReadS [DetectedProperties]
$creadList :: ReadS [DetectedProperties]
readsPrec :: Int -> ReadS DetectedProperties
$creadsPrec :: Int -> ReadS DetectedProperties
Prelude.Read, Int -> DetectedProperties -> ShowS
[DetectedProperties] -> ShowS
DetectedProperties -> String
(Int -> DetectedProperties -> ShowS)
-> (DetectedProperties -> String)
-> ([DetectedProperties] -> ShowS)
-> Show DetectedProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectedProperties] -> ShowS
$cshowList :: [DetectedProperties] -> ShowS
show :: DetectedProperties -> String
$cshow :: DetectedProperties -> String
showsPrec :: Int -> DetectedProperties -> ShowS
$cshowsPrec :: Int -> DetectedProperties -> ShowS
Prelude.Show, (forall x. DetectedProperties -> Rep DetectedProperties x)
-> (forall x. Rep DetectedProperties x -> DetectedProperties)
-> Generic DetectedProperties
forall x. Rep DetectedProperties x -> DetectedProperties
forall x. DetectedProperties -> Rep DetectedProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectedProperties x -> DetectedProperties
$cfrom :: forall x. DetectedProperties -> Rep DetectedProperties x
Prelude.Generic)

-- |
-- Create a value of 'DetectedProperties' 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:
--
-- 'height', 'detectedProperties_height' - The detected height of the input file, in pixels.
--
-- 'frameRate', 'detectedProperties_frameRate' - The detected frame rate of the input file, in frames per second.
--
-- 'fileSize', 'detectedProperties_fileSize' - The detected file size of the input file, in bytes.
--
-- 'width', 'detectedProperties_width' - The detected width of the input file, in pixels.
--
-- 'durationMillis', 'detectedProperties_durationMillis' - The detected duration of the input file, in milliseconds.
newDetectedProperties ::
  DetectedProperties
newDetectedProperties :: DetectedProperties
newDetectedProperties =
  DetectedProperties' :: Maybe Int
-> Maybe Text
-> Maybe Integer
-> Maybe Int
-> Maybe Integer
-> DetectedProperties
DetectedProperties'
    { $sel:height:DetectedProperties' :: Maybe Int
height = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:frameRate:DetectedProperties' :: Maybe Text
frameRate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fileSize:DetectedProperties' :: Maybe Integer
fileSize = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:width:DetectedProperties' :: Maybe Int
width = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:durationMillis:DetectedProperties' :: Maybe Integer
durationMillis = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The detected height of the input file, in pixels.
detectedProperties_height :: Lens.Lens' DetectedProperties (Prelude.Maybe Prelude.Int)
detectedProperties_height :: (Maybe Int -> f (Maybe Int))
-> DetectedProperties -> f DetectedProperties
detectedProperties_height = (DetectedProperties -> Maybe Int)
-> (DetectedProperties -> Maybe Int -> DetectedProperties)
-> Lens
     DetectedProperties DetectedProperties (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedProperties' {Maybe Int
height :: Maybe Int
$sel:height:DetectedProperties' :: DetectedProperties -> Maybe Int
height} -> Maybe Int
height) (\s :: DetectedProperties
s@DetectedProperties' {} Maybe Int
a -> DetectedProperties
s {$sel:height:DetectedProperties' :: Maybe Int
height = Maybe Int
a} :: DetectedProperties)

-- | The detected frame rate of the input file, in frames per second.
detectedProperties_frameRate :: Lens.Lens' DetectedProperties (Prelude.Maybe Prelude.Text)
detectedProperties_frameRate :: (Maybe Text -> f (Maybe Text))
-> DetectedProperties -> f DetectedProperties
detectedProperties_frameRate = (DetectedProperties -> Maybe Text)
-> (DetectedProperties -> Maybe Text -> DetectedProperties)
-> Lens
     DetectedProperties DetectedProperties (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedProperties' {Maybe Text
frameRate :: Maybe Text
$sel:frameRate:DetectedProperties' :: DetectedProperties -> Maybe Text
frameRate} -> Maybe Text
frameRate) (\s :: DetectedProperties
s@DetectedProperties' {} Maybe Text
a -> DetectedProperties
s {$sel:frameRate:DetectedProperties' :: Maybe Text
frameRate = Maybe Text
a} :: DetectedProperties)

-- | The detected file size of the input file, in bytes.
detectedProperties_fileSize :: Lens.Lens' DetectedProperties (Prelude.Maybe Prelude.Integer)
detectedProperties_fileSize :: (Maybe Integer -> f (Maybe Integer))
-> DetectedProperties -> f DetectedProperties
detectedProperties_fileSize = (DetectedProperties -> Maybe Integer)
-> (DetectedProperties -> Maybe Integer -> DetectedProperties)
-> Lens
     DetectedProperties
     DetectedProperties
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedProperties' {Maybe Integer
fileSize :: Maybe Integer
$sel:fileSize:DetectedProperties' :: DetectedProperties -> Maybe Integer
fileSize} -> Maybe Integer
fileSize) (\s :: DetectedProperties
s@DetectedProperties' {} Maybe Integer
a -> DetectedProperties
s {$sel:fileSize:DetectedProperties' :: Maybe Integer
fileSize = Maybe Integer
a} :: DetectedProperties)

-- | The detected width of the input file, in pixels.
detectedProperties_width :: Lens.Lens' DetectedProperties (Prelude.Maybe Prelude.Int)
detectedProperties_width :: (Maybe Int -> f (Maybe Int))
-> DetectedProperties -> f DetectedProperties
detectedProperties_width = (DetectedProperties -> Maybe Int)
-> (DetectedProperties -> Maybe Int -> DetectedProperties)
-> Lens
     DetectedProperties DetectedProperties (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedProperties' {Maybe Int
width :: Maybe Int
$sel:width:DetectedProperties' :: DetectedProperties -> Maybe Int
width} -> Maybe Int
width) (\s :: DetectedProperties
s@DetectedProperties' {} Maybe Int
a -> DetectedProperties
s {$sel:width:DetectedProperties' :: Maybe Int
width = Maybe Int
a} :: DetectedProperties)

-- | The detected duration of the input file, in milliseconds.
detectedProperties_durationMillis :: Lens.Lens' DetectedProperties (Prelude.Maybe Prelude.Integer)
detectedProperties_durationMillis :: (Maybe Integer -> f (Maybe Integer))
-> DetectedProperties -> f DetectedProperties
detectedProperties_durationMillis = (DetectedProperties -> Maybe Integer)
-> (DetectedProperties -> Maybe Integer -> DetectedProperties)
-> Lens
     DetectedProperties
     DetectedProperties
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectedProperties' {Maybe Integer
durationMillis :: Maybe Integer
$sel:durationMillis:DetectedProperties' :: DetectedProperties -> Maybe Integer
durationMillis} -> Maybe Integer
durationMillis) (\s :: DetectedProperties
s@DetectedProperties' {} Maybe Integer
a -> DetectedProperties
s {$sel:durationMillis:DetectedProperties' :: Maybe Integer
durationMillis = Maybe Integer
a} :: DetectedProperties)

instance Core.FromJSON DetectedProperties where
  parseJSON :: Value -> Parser DetectedProperties
parseJSON =
    String
-> (Object -> Parser DetectedProperties)
-> Value
-> Parser DetectedProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DetectedProperties"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Maybe Integer
-> Maybe Int
-> Maybe Integer
-> DetectedProperties
DetectedProperties'
            (Maybe Int
 -> Maybe Text
 -> Maybe Integer
 -> Maybe Int
 -> Maybe Integer
 -> DetectedProperties)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe Integer
      -> Maybe Int
      -> Maybe Integer
      -> DetectedProperties)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Height")
            Parser
  (Maybe Text
   -> Maybe Integer
   -> Maybe Int
   -> Maybe Integer
   -> DetectedProperties)
-> Parser (Maybe Text)
-> Parser
     (Maybe Integer -> Maybe Int -> Maybe Integer -> DetectedProperties)
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
"FrameRate")
            Parser
  (Maybe Integer -> Maybe Int -> Maybe Integer -> DetectedProperties)
-> Parser (Maybe Integer)
-> Parser (Maybe Int -> Maybe Integer -> DetectedProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FileSize")
            Parser (Maybe Int -> Maybe Integer -> DetectedProperties)
-> Parser (Maybe Int)
-> Parser (Maybe Integer -> DetectedProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Width")
            Parser (Maybe Integer -> DetectedProperties)
-> Parser (Maybe Integer) -> Parser DetectedProperties
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DurationMillis")
      )

instance Prelude.Hashable DetectedProperties

instance Prelude.NFData DetectedProperties

instance Core.ToJSON DetectedProperties where
  toJSON :: DetectedProperties -> Value
toJSON DetectedProperties' {Maybe Int
Maybe Integer
Maybe Text
durationMillis :: Maybe Integer
width :: Maybe Int
fileSize :: Maybe Integer
frameRate :: Maybe Text
height :: Maybe Int
$sel:durationMillis:DetectedProperties' :: DetectedProperties -> Maybe Integer
$sel:width:DetectedProperties' :: DetectedProperties -> Maybe Int
$sel:fileSize:DetectedProperties' :: DetectedProperties -> Maybe Integer
$sel:frameRate:DetectedProperties' :: DetectedProperties -> Maybe Text
$sel:height:DetectedProperties' :: DetectedProperties -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Height" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
height,
            (Text
"FrameRate" 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
frameRate,
            (Text
"FileSize" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
fileSize,
            (Text
"Width" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
width,
            (Text
"DurationMillis" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
durationMillis
          ]
      )