-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public final class ReplayCache implements Closeable
A basic in-memory and disk cache for Session Replay frames. Frames are stored in order under the SentryOptions.cacheDirPath + replayId folder. The class is also capable of creating an mp4 video segment out of the stored frames, provided start time and duration using the available on-device android.media.MediaCodec.
This class is not thread-safe, meaning, addFrame cannot be called concurrently with createVideoOf, and they should be invoked from the same thread.
-
-
Constructor Summary
Constructors Constructor Description ReplayCache(SentryOptions options, SentryId replayId)
-
Method Summary
Modifier and Type Method Description final UnitaddFrame(File screenshot, Long frameTimestamp, String screen)Same as addFrame, but accepts frame screenshot as File, the file should contain a bitmap/image by the time createVideoOf is invoked. final GeneratedVideocreateVideoOf(Long duration, Long from, Integer segmentId, Integer height, Integer width, Integer frameRate, Integer bitRate, File videoFile)Creates a video out of currently stored frames given the start time and duration using the on-device codecs android.media.MediaCodec. Unitclose()-
-
Method Detail
-
addFrame
final Unit addFrame(File screenshot, Long frameTimestamp, String screen)
Same as addFrame, but accepts frame screenshot as File, the file should contain a bitmap/image by the time createVideoOf is invoked.
This method is not thread-safe.
- Parameters:
screenshot- file containing the frame screenshotframeTimestamp- the timestamp when the frame screenshot was taken
-
createVideoOf
final GeneratedVideo createVideoOf(Long duration, Long from, Integer segmentId, Integer height, Integer width, Integer frameRate, Integer bitRate, File videoFile)
Creates a video out of currently stored frames given the start time and duration using the on-device codecs android.media.MediaCodec. The generated video will be stored in videoFile location, which defaults to "replayCacheDir/segmentId.mp4".
This method is not thread-safe.
- Parameters:
duration- desired video duration in millisecondsfrom- desired start of the video represented as unix timestamp in millisecondssegmentId- current segment id, used for inferring the filename to store the result video under replayCacheDir, e.g.height- desired height of the video in pixels (e.g.width- desired width of the video in pixels (e.g.videoFile- optional, location of the file to store the result video.
-
-
-
-