public bool Start(int modeIndex = -1, int videoInputIndex = -1) { if (AVProLiveCameraPlugin.StartDevice(_deviceIndex, modeIndex, videoInputIndex)) { Debug.Log("[AVProLiveCamera] Started device using mode index " + modeIndex); // Get format mode properties int width = AVProLiveCameraPlugin.GetWidth(_deviceIndex); int height = AVProLiveCameraPlugin.GetHeight(_deviceIndex); AVProLiveCameraPlugin.VideoFrameFormat format = (AVProLiveCameraPlugin.VideoFrameFormat)AVProLiveCameraPlugin.GetFormat(_deviceIndex); _width = width; _height = height; _format = format.ToString(); _deviceFormat = AVProLiveCameraPlugin.GetDeviceFormat(_deviceIndex); _frameRate = AVProLiveCameraPlugin.GetFrameRate(_deviceIndex); _frameDurationHNS = AVProLiveCameraPlugin.GetFrameDurationHNS(_deviceIndex); // Validate properties if (width <= 0 || width > MaxVideoResolution || height <= 0 || height > MaxVideoResolution) { Debug.LogWarning("[AVProLiveCamera] invalid width or height"); Close(); return(false); } // Create format converter _isTopDown = AVProLiveCameraPlugin.IsFrameTopDown(_deviceIndex); if (!_formatConverter.Build(width, height, format, _flipX, _isTopDown != _flipY, Deinterlace)) { Debug.LogWarning("[AVProLiveCamera] unable to convert camera format"); Close(); return(false); } // Run camera IsActive = true; IsRunning = false; IsPicture = false; IsPaused = true; _lastModeIndex = modeIndex; _lastVideoInputIndex = videoInputIndex; Play(); return(IsRunning); } Debug.LogWarning("[AVProLiveCamera] unable to start camera"); Close(); return(false); }
private static bool CompareMode(string internalMode, AVProLiveCameraPlugin.VideoFrameFormat pluginMode) { if (internalMode == pluginMode.ToString()) { return(true); } bool result = false; switch (pluginMode) { case AVProLiveCameraPlugin.VideoFrameFormat.RAW_BGRA32: result = (internalMode == "BGRA32" || internalMode == "ARGB32" || internalMode == "RGB32"); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_YUY2: result = (internalMode == "YUV_YUY2"); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_UYVY: result = (internalMode == "YUV_UYVY"); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_YVYU: result = (internalMode == "YUV_YVYU"); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_422_HDYC: result = (internalMode == "YUV_UYVY_HDYC"); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_420_PLANAR_YV12: result = (internalMode == "YUV_PLANAR_YV12"); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_420_PLANAR_I420: result = (internalMode == "YUV_PLANAR_I420"); break; case AVProLiveCameraPlugin.VideoFrameFormat.RAW_RGB24: result = (internalMode == "RGB24"); break; case AVProLiveCameraPlugin.VideoFrameFormat.RAW_MONO8: result = (internalMode == "MONO8" || internalMode == "Mono_Y800"); break; case AVProLiveCameraPlugin.VideoFrameFormat.RGB_10BPP: result = (internalMode == "RGB_10BPP" || internalMode == "RGBX_10BPP" || internalMode == "RGBXLE_10BPP"); break; case AVProLiveCameraPlugin.VideoFrameFormat.YUV_10BPP_V210: result = (internalMode == "YUV_10BPP_V210"); break; case AVProLiveCameraPlugin.VideoFrameFormat.MPEG: result = (internalMode == "MJPG"); break; } return(result); }
public bool Start(AVProLiveCameraDeviceMode mode, int videoInputIndex = -1) { // Resolve the internal mode index int internalModeIndex = -1; if (mode != null) { internalModeIndex = mode.InternalIndex; } // Start the device if (AVProLiveCameraPlugin.StartDevice(_deviceIndex, internalModeIndex, videoInputIndex)) { int modeIndex = -1; if (mode != null) { for (int i = 0; i < _modes.Count; i++) { if (_modes[i] == mode) { modeIndex = i; break; } } } Debug.Log("[AVProLiveCamera] Started device using mode index " + modeIndex + " (internal index " + internalModeIndex + ")"); // Get format mode properties int width = AVProLiveCameraPlugin.GetWidth(_deviceIndex); int height = AVProLiveCameraPlugin.GetHeight(_deviceIndex); AVProLiveCameraPlugin.VideoFrameFormat format = (AVProLiveCameraPlugin.VideoFrameFormat)AVProLiveCameraPlugin.GetFormat(_deviceIndex); _width = width; _height = height; _format = format.ToString(); _deviceFormat = AVProLiveCameraPlugin.GetDeviceFormat(_deviceIndex); _frameRate = AVProLiveCameraPlugin.GetFrameRate(_deviceIndex); _frameDurationHNS = AVProLiveCameraPlugin.GetFrameDurationHNS(_deviceIndex); // Validate properties if (width <= 0 || width > MaxVideoResolution || height <= 0 || height > MaxVideoResolution) { Debug.LogWarning("[AVProLiveCamera] invalid width or height"); Close(); return(false); } // Create format converter _isTopDown = AVProLiveCameraPlugin.IsFrameTopDown(_deviceIndex); bool allowTransparency = (SupportsTransparency && AllowTransparency); if (!_formatConverter.Build(width, height, format, allowTransparency, _flipX, _isTopDown != _flipY, Deinterlace)) { Debug.LogWarning("[AVProLiveCamera] unable to convert camera format"); Close(); return(false); } // Run camera IsActive = true; IsRunning = false; IsPicture = false; IsPaused = true; _lastModeIndex = modeIndex; _lastVideoInputIndex = videoInputIndex; Play(); return(IsRunning); } Debug.LogWarning("[AVProLiveCamera] unable to start camera"); Close(); return(false); }