private void LogFormat(MMALEventFormat format, PortBase port)
        {
            StringBuilder sb = new StringBuilder();

            if (port != null)
            {
                switch (port.PortType)
                {
                case PortType.Input:
                    sb.AppendLine("Port Type: Input");
                    break;

                case PortType.Output:
                    sb.AppendLine("Port Type: Output");
                    break;

                case PortType.Control:
                    sb.AppendLine("Port Type: Control");
                    break;
                }
            }

            sb.AppendLine($"FourCC: {format.FourCC}");
            sb.AppendLine($"Width: {format.Width}");
            sb.AppendLine($"Height: {format.Height}");
            sb.AppendLine($"Crop: {format.CropX}, {format.CropY}, {format.CropWidth}, {format.CropHeight}");
            sb.AppendLine($"Pixel aspect ratio: {format.ParNum}, {format.ParDen}. Frame rate: {format.FramerateNum}, {format.FramerateDen}");

            if (port != null)
            {
                sb.AppendLine($"Port info: Buffers num: {port.BufferNum}(opt {port.BufferNumRecommended}, min {port.BufferNumMin}). Size: {port.BufferSize} (opt {port.BufferSizeRecommended}, min {port.BufferSizeMin}). Alignment: {port.BufferAlignmentMin}");
            }

            MMALLog.Logger.Info(sb.ToString());
        }
        private void ProcessFormatChangedEvent(MMALBufferImpl buffer, int outputPort = 0)
        {
            MMALLog.Logger.Info("Received MMAL_EVENT_FORMAT_CHANGED event");

            var ev = MMALEventFormat.GetEventFormat(buffer);

            MMALLog.Logger.Info("-- Event format changed from -- ");
            this.LogFormat(new MMALEventFormat(this.Outputs[outputPort].Format), this.Outputs[outputPort]);

            MMALLog.Logger.Info("-- To -- ");
            this.LogFormat(ev, null);

            buffer.Release();

            this.Outputs[outputPort].DisablePort();

            while (this.Outputs[outputPort].BufferPool.Queue.QueueLength() < this.Outputs[outputPort].BufferPool.HeadersNum)
            {
                MMALLog.Logger.Debug("Queue length less than buffer pool num");

                MMALLog.Logger.Debug("Getting buffer via Queue.Wait");
                var tempBuf = WorkingQueue.Wait();
                tempBuf.Release();
            }

            this.Outputs[outputPort].BufferPool.Dispose();

            this.Outputs[outputPort].FullCopy(ev);

            this.ConfigureOutputPortWithoutInit(0, this.Outputs[outputPort].EncodingType);

            this.Outputs[outputPort].EnableOutputPort(false);
        }
Exemple #3
0
        private void ProcessFormatChangedEvent(IBuffer buffer)
        {
            MMALLog.Logger.LogInformation("Received MMAL_EVENT_FORMAT_CHANGED event");

            var ev = MMALEventFormat.GetEventFormat(buffer);

            MMALLog.Logger.LogInformation("-- Event format changed from -- ");
            this.LogFormat(new MMALEventFormat(this.Format), this);

            MMALLog.Logger.LogInformation("-- To -- ");
            this.LogFormat(ev, null);

            MMALLog.Logger.LogDebug("Finished processing MMAL_EVENT_FORMAT_CHANGED event");
        }