/// <summary> /// Delegate to process the buffer header containing image data /// </summary> /// <param name="buffer">The buffer header we're currently processing</param> /// <param name="port">The port we're currently processing on</param> public override void ManagedOutputCallback(MMALBufferImpl buffer, MMALPortBase port) { if (this.PrepareSplit && buffer.Properties.Any(c => c == MMALBufferProperties.MMAL_BUFFER_HEADER_FLAG_CONFIG)) { ((VideoStreamCaptureHandler)this.Handler).Split(); this.LastSplit = DateTime.Now; this.PrepareSplit = false; } //Ensure that if we need to split then this is done before processing the buffer data. if (this.Split != null) { if (!this.LastSplit.HasValue) { this.LastSplit = DateTime.Now; } if (DateTime.Now.CompareTo(this.CalculateSplit()) > 0) { this.PrepareSplit = true; port.SetParameter(MMALParametersVideo.MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME, true); } } base.ManagedOutputCallback(buffer, port); }
/// <summary> /// Remove a callback handler for a given port. /// </summary> /// <param name="port">The port we are removing the callback handler on.</param> public static void RemoveCallback(MMALPortBase port) { if (WorkingHandlers.ContainsKey(port)) { WorkingHandlers.Remove(port); } }
/// <summary> /// This is the camera's control port callback function. The callback is used if /// MMALCameraConfig.SetChangeEventRequest is set to true. /// </summary> /// <seealso cref="MMALCameraConfig.SetChangeEventRequest" /> /// <param name="buffer">The buffer header being sent from MMAL.</param> /// <param name="port">The managed control port instance.</param> internal unsafe void CameraControlCallback(MMALBufferImpl buffer, MMALPortBase port) { if (buffer.Cmd == MMALEvents.MMAL_EVENT_PARAMETER_CHANGED) { var data = (MMAL_EVENT_PARAMETER_CHANGED_T *)buffer.Data; if (data->Hdr.Id == MMALParametersCamera.MMAL_PARAMETER_CAMERA_SETTINGS) { var settings = (MMAL_PARAMETER_CAMERA_SETTINGS_T *)data; MMALLog.Logger.Debug($"Analog gain num {settings->AnalogGain.Num}"); MMALLog.Logger.Debug($"Analog gain den {settings->AnalogGain.Den}"); MMALLog.Logger.Debug($"Exposure {settings->Exposure}"); MMALLog.Logger.Debug($"Focus position {settings->FocusPosition}"); } } else if (buffer.Cmd == MMALEvents.MMAL_EVENT_ERROR) { MMALLog.Logger.Info("No data received from sensor. Check all connections, including the Sunny one on the camera board"); } else { MMALLog.Logger.Info("Received unexpected camera control callback event"); } }
/// <summary> /// Finds and returns a <see cref="OutputCallbackHandlerBase"/> for a given port. If no handler is registered, a /// <see cref="DefaultOutputCallbackHandler"/> will be returned. /// </summary> /// <param name="port">The port we are retrieving the callback handler on.</param> /// <returns>A <see cref="OutputCallbackHandlerBase"/> for a given port. If no handler is registered, a /// <see cref="DefaultOutputCallbackHandler"/> will be returned.</returns> public static OutputCallbackHandlerBase FindCallback(MMALPortBase port) { if (WorkingHandlers.ContainsKey(port)) { return(WorkingHandlers[port]); } return(new DefaultOutputCallbackHandler(port)); }
protected InputCallbackHandlerBase(MMALPortBase port, MMALEncoding encodingType) { this.WorkingPort = port; this.EncodingType = encodingType; }
protected InputCallbackHandlerBase(MMALPortBase port) { this.WorkingPort = port; }
public DefaultOutputCallbackHandler(MMALPortBase port, MMALEncoding encodingType) : base(port, encodingType) { }
public DefaultOutputCallbackHandler(MMALPortBase port) : base(port) { }
/// <summary> /// If it exists, removes a <see cref="ConnectionCallbackHandlerBase"/> on the port specified. /// </summary> /// <param name="port">The port with a created connection.</param> public void RemoveConnectionCallback(MMALPortBase port) => ConnectionCallbackProvider.RemoveCallback(port.ConnectedReference);
public VideoOutputCallbackHandler(MMALPortBase port, MMALEncoding encoding) : base(port, encoding) { }
public VideoOutputCallbackHandler(MMALPortBase port) : base(port) { }