Package 

Class ReplayCache

  • 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)
    • Constructor Detail

      • ReplayCache

        ReplayCache(SentryOptions options, SentryId replayId)
        Parameters:
        options - SentryOptions instance, used for logging and cacheDir
        replayId - the current replay id, used for giving a unique name to the replay folder
    • 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 screenshot
        frameTimestamp - 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 milliseconds
        from - desired start of the video represented as unix timestamp in milliseconds
        segmentId - 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.