From: Peter g. <pg...@co...> - 2008-10-08 17:22:15
|
Sat Aug 23 21:56:33 EDT 2008 Peter Gavin <pg...@gm...> * gstreamer: Format should not be an enumeration. Some values have special meanings, others will use FormatId hunk ./gstreamer/Media/Streaming/GStreamer/Core/Constants.hsc 33 +import Data.Int hunk ./gstreamer/Media/Streaming/GStreamer/Core/Constants.hsc 60 +-- | A format identifier. +newtype FormatId = FormatId #{type GstFormat} + deriving (Eq, Ord, Show) + +-- | An enumeration of standard predefined formats. +data Format = FormatUndefined -- ^ no format + | FormatDefault -- ^ the default format of the pad or element; this can be, e.g., samples for raw audio + | FormatBytes -- ^ bytes + | FormatTime -- ^ time in nanoseconds + | FormatBuffers -- ^ buffers + | FormatPercent -- ^ percentage of stream + | FormatUser FormatId -- ^ a user defined format + deriving (Eq, Ord, Show) +toFormat :: #{type GstFormat} -> Format +toFormat n | n == #{const GST_FORMAT_UNDEFINED} = FormatUndefined + | n == #{const GST_FORMAT_DEFAULT} = FormatDefault + | n == #{const GST_FORMAT_BYTES} = FormatBytes + | n == #{const GST_FORMAT_TIME} = FormatTime + | n == #{const GST_FORMAT_BUFFERS} = FormatBuffers + | n == #{const GST_FORMAT_PERCENT} = FormatPercent + | otherwise = FormatUser (FormatId n) +fromFormat :: Format -> #{type GstFormat} +fromFormat FormatUndefined = #{const GST_FORMAT_UNDEFINED} +fromFormat FormatDefault = #{const GST_FORMAT_DEFAULT} +fromFormat FormatBytes = #{const GST_FORMAT_BYTES} +fromFormat FormatTime = #{const GST_FORMAT_TIME} +fromFormat FormatBuffers = #{const GST_FORMAT_BUFFERS} +fromFormat FormatPercent = #{const GST_FORMAT_PERCENT} +fromFormat (FormatUser (FormatId id)) = id + +-- | The format value for 'FormatPercent' is between 0 and this value. +formatPercentMax :: Int64 +formatPercentMax = #{const GST_FORMAT_PERCENT_MAX} + +-- | The value used to scale down the reported 'FormatPercent' format +-- value to its real value. +formatPercentScale :: Int64 +formatPercentScale = #{const GST_FORMAT_PERCENT_SCALE} + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 636 - do poke destFormatPtr $ fromIntegral $ fromEnum destFormat + do poke destFormatPtr $ fromIntegral $ fromFormat destFormat hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 638 - (fromIntegral $ fromEnum srcFormat) - (fromIntegral srcVal) - destFormatPtr - destValPtr + (fromIntegral $ fromFormat srcFormat) + (fromIntegral srcVal) + destFormatPtr + destValPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 645 - return $ Just (toEnum $ fromIntegral destFormat, + return $ Just (toFormat $ fromIntegral destFormat, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 657 - do poke formatPtr $ fromIntegral $ fromEnum format + do poke formatPtr $ fromIntegral $ fromFormat format hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 662 - return $ Just (toEnum $ fromIntegral format, + return $ Just (toFormat $ fromIntegral format, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 674 - do poke formatPtr $ fromIntegral $ fromEnum format + do poke formatPtr $ fromIntegral $ fromFormat format hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 679 - return $ Just (toEnum $ fromIntegral format, + return $ Just (toFormat $ fromIntegral format, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 729 - (fromIntegral $ fromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 752 - (fromIntegral $ fromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Event.chs.pp 136 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Event.chs.pp 154 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Event.chs.pp 180 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Event.chs.pp 205 - format <- liftM cToEnum $ peek formatPtr + format <- liftM (toFormat . fromIntegral) $ peek formatPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Event.chs.pp 241 - format <- liftM cToEnum $ peek formatPtr + format <- liftM (toFormat . fromIntegral) $ peek formatPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Event.chs.pp 267 - format <- liftM cToEnum $ peek formatPtr + format <- liftM (toFormat . fromIntegral) $ peek formatPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Event.chs.pp 307 - format <- liftM cToEnum $ peek formatPtr + format <- liftM (toFormat . fromIntegral) $ peek formatPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Format.chs 31 + -- * Types hunk ./gstreamer/Media/Streaming/GStreamer/Core/Format.chs 33 + FormatDefinition(..), + FormatId, + [_$_] + -- * Format Operations + formatPercentMax, + formatPercentScale, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Format.chs 63 - fromIntegral $ fromEnum format) + fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Format.chs 68 - {# call format_to_quark #} . fromIntegral . fromEnum + {# call format_to_quark #} . fromIntegral . fromFormat hunk ./gstreamer/Media/Streaming/GStreamer/Core/Format.chs 74 - liftM (toEnum . fromIntegral) $ + liftM (toFormat . fromIntegral) $ hunk ./gstreamer/Media/Streaming/GStreamer/Core/Format.chs 82 - liftM cToEnum $ + liftM (toFormat . fromIntegral) $ hunk ./gstreamer/Media/Streaming/GStreamer/Core/Format.chs 96 - ({# call format_get_details #} $ cFromEnum format) >>= - peek . castPtr + ({# call format_get_details #} $ fromIntegral $ fromFormat format) >>= + maybePeek peek . castPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Index.chs 163 - (cFromEnum format) >>= + (fromIntegral $ fromFormat format) >>= hunk ./gstreamer/Media/Streaming/GStreamer/Core/Index.chs 204 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Index.chs 214 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Message.chs.pp 263 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Message.chs.pp 275 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Message.chs.pp 336 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Message.chs.pp 421 - format <- liftM cToEnum $ peek formatPtr + format <- liftM (toFormat . fromIntegral) $ peek formatPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Message.chs.pp 432 - format <- liftM cToEnum $ peek formatPtr + format <- liftM (toFormat . fromIntegral) $ peek formatPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Message.chs.pp 488 - format <- liftM cToEnum $ peek formatPtr + format <- liftM (toFormat . fromIntegral) $ peek formatPtr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 322 - return $ Just (toEnum $ fromIntegral format, + return $ Just (toFormat $ fromIntegral format, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 336 - return $ Just (toEnum $ fromIntegral format, + return $ Just (toFormat $ fromIntegral format, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 349 - (fromIntegral $ fromEnum srcFormat) + (fromIntegral $ fromFormat srcFormat) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 356 - return $ Just (toEnum $ fromIntegral destFormat, + return $ Just (toFormat $ fromIntegral destFormat, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 370 - return $ Just (toEnum $ fromIntegral format, + return $ Just (toFormat $ fromIntegral format, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 384 - return $ Just (toEnum $ fromIntegral format, + return $ Just (toFormat $ fromIntegral format, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 397 - (fromIntegral $ fromEnum srcFormat) + (fromIntegral $ fromFormat srcFormat) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 404 - return $ Just (toEnum $ fromIntegral destFormat, + return $ Just (toFormat $ fromIntegral destFormat, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Query.chs 113 - {# call query_new_convert #} (cFromEnum srcFormat) + {# call query_new_convert #} (fromIntegral $ fromFormat srcFormat) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Query.chs 115 - (cFromEnum destFormat) >>= + (fromIntegral $ fromFormat destFormat) >>= hunk ./gstreamer/Media/Streaming/GStreamer/Core/Segment.chs 61 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Segment.chs 78 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Segment.chs 89 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Segment.chs 106 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Segment.chs 126 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Segment.chs 144 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Segment.chs 154 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 48 - Format(..), hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 205 -{# enum GstFormat as Format {underscoreToCase} with prefix = "GST" deriving (Eq, Show) #} - -data FormatDefinition = FormatDefinition { formatValue :: Format - , formatNick :: String - , formatDescription :: String - , formatQuark :: Quark } - deriving (Eq, Show) +-- | A format definition. +data FormatDefinition = FormatDefinition { formatValue :: FormatId -- ^ the unique id of this format + , formatNick :: String -- ^ a short nickname for the format + , formatDescription :: String -- ^ a longer description of the format + , formatQuark :: Quark -- ^ a quark for the nickname + } deriving (Eq, Show) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 215 - do value <- liftM cToEnum $ {# get GstFormatDefinition->value #} ptr + do value <- liftM (FormatId . fromIntegral) $ {# get GstFormatDefinition->value #} ptr hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 406 - return $ IndexAssociation (cToEnum format) (fromIntegral value) + return $ IndexAssociation (toFormat $ fromIntegral format) (fromIntegral value) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 408 - do {# set GstIndexAssociation->format #} ptr $ cFromEnum format + do {# set GstIndexAssociation->format #} ptr $ fromIntegral (fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 741 - (cToEnum format) + (toFormat $ fromIntegral format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 760 - (cFromEnum format) + (fromIntegral $ fromFormat format) hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 763 - {# set GstSegment->format #} ptr $ cFromEnum format + {# set GstSegment->format #} ptr $ fromIntegral (fromFormat format) |