示例#1
0
 private double GetTimeBetweenCaptures(MegacoolRecordingConfig config)
 {
     if (config != null && config._HasFrameRate())
     {
         return(1.0 / config.FrameRate);
     }
     return(1.0 / MegacoolConfiguration.Instance.recordingFrameRate);
 }
    private AndroidJavaObject RecordingConfigToJavaObject(MegacoolRecordingConfig config)
    {
        if (config == null)
        {
            return(null);
        }
        AndroidJavaObject jConfig = new AndroidJavaObject("co.megacool.megacool.RecordingConfig");

        if (config._HasRecordingId())
        {
            jConfig.Call <AndroidJavaObject>("id", config.RecordingId);
        }
        if (config._HasMaxFrames())
        {
            jConfig.Call <AndroidJavaObject>("maxFrames", config.MaxFrames);
        }
        if (config._HasFrameRate())
        {
            jConfig.Call <AndroidJavaObject>("frameRate", config.FrameRate);
        }
        if (config._HasPlaybackFrameRate())
        {
            jConfig.Call <AndroidJavaObject>("playbackFrameRate", config.PlaybackFrameRate);
        }
        if (config._HasLastFrameDelay())
        {
            jConfig.Call <AndroidJavaObject>("lastFrameDelay", config.LastFrameDelay);
        }
        if (config._HasPeakLocation())
        {
            jConfig.Call <AndroidJavaObject>("peakLocation", config.PeakLocation);
        }
        if (config.LastFrameOverlay != null)
        {
            jConfig.Call <AndroidJavaObject>("lastFrameOverlayAsset", config.LastFrameOverlay);
        }
        if (config._HasOverflowStrategy())
        {
            AndroidJavaClass  overflowStrategyClass = new AndroidJavaClass("co.megacool.megacool.OverflowStrategy");
            AndroidJavaObject jOverflowStrategy;
            if (config.OverflowStrategy == MegacoolOverflowStrategy.HIGHLIGHT)
            {
                jOverflowStrategy = overflowStrategyClass.GetStatic <AndroidJavaObject>("HIGHLIGHT");
            }
            else if (config.OverflowStrategy == MegacoolOverflowStrategy.TIMELAPSE)
            {
                jOverflowStrategy = overflowStrategyClass.GetStatic <AndroidJavaObject>("TIMELAPSE");
            }
            else
            {
                jOverflowStrategy = overflowStrategyClass.GetStatic <AndroidJavaObject>("LATEST");
            }
            jConfig.Call <AndroidJavaObject>("overflowStrategy", jOverflowStrategy);
        }
        return(jConfig);
    }
    private MCLRecordingConfig GetNativeRecordingConfig(MegacoolRecordingConfig config)
    {
        MCLRecordingConfig nativeConfig = new MCLRecordingConfig {
            overflowStrategy  = -1,
            maxFrames         = -1,
            frameRate         = -1,
            playbackFrameRate = -1,
            peakLocation      = -1.0,
            lastFrameDelay    = -1,
        };

        if (config._HasOverflowStrategy())
        {
            nativeConfig.overflowStrategy = (int)config.OverflowStrategy;
        }
        if (config._HasFrameRate())
        {
            nativeConfig.frameRate = config.FrameRate;
        }
        if (config._HasPlaybackFrameRate())
        {
            nativeConfig.playbackFrameRate = config.PlaybackFrameRate;
        }
        if (config._HasMaxFrames())
        {
            nativeConfig.maxFrames = config.MaxFrames;
        }
        if (config._HasRecordingId())
        {
            nativeConfig.recordingId = config.RecordingId;
        }
        if (config._HasPeakLocation())
        {
            nativeConfig.peakLocation = config.PeakLocation;
        }
        if (config._HasLastFrameDelay())
        {
            nativeConfig.lastFrameDelay = config.LastFrameDelay;
        }
        if (config.LastFrameOverlay != null)
        {
            nativeConfig.lastFrameOverlay =
                Application.streamingAssetsPath + "/" + config.LastFrameOverlay;
        }
        return(nativeConfig);
    }
    MegacoolRecordingConfig MergeWithDefault(MegacoolRecordingConfig config)
    {
        if (config == null)
        {
            return(DefaultRecordingConfig);
        }
        MegacoolRecordingConfig merged = new MegacoolRecordingConfig();

        merged.MaxFrames         = config._HasMaxFrames() ? config.MaxFrames : DefaultRecordingConfig.MaxFrames;
        merged.FrameRate         = config._HasFrameRate() ? config.FrameRate : DefaultRecordingConfig.FrameRate;
        merged.LastFrameDelay    = config._HasLastFrameDelay() ? config.LastFrameDelay : DefaultRecordingConfig.LastFrameDelay;
        merged.LastFrameOverlay  = config.LastFrameOverlay ?? DefaultRecordingConfig.LastFrameOverlay;
        merged.OverflowStrategy  = config._HasOverflowStrategy() ? config.OverflowStrategy : DefaultRecordingConfig.OverflowStrategy;
        merged.PeakLocation      = config._HasPeakLocation() ? config.PeakLocation : DefaultRecordingConfig.PeakLocation;
        merged.RecordingId       = config._HasRecordingId() ? config.RecordingId : DefaultRecordingConfig.RecordingId;
        merged.PlaybackFrameRate = config._HasPlaybackFrameRate() ? config.PlaybackFrameRate : DefaultRecordingConfig.PlaybackFrameRate;
        return(merged);
    }