예제 #1
0
        private MMalPort[] CreatePorts(MMal.MMAL_PORT_T **ports, uint numPort, string[] subFormat)
        {
            MMalPort[] array = new MMalPort[numPort];
            for (int i = 0; i < numPort; i++)
            {
                switch (ports[i]->format->type)
                {
                case MMal.MMAL_ES_TYPE_T.MMAL_ES_TYPE_UNKNOWN:
                    array[i] = new MMalPort(ports[i], subFormat);
                    break;

                case MMal.MMAL_ES_TYPE_T.MMAL_ES_TYPE_CONTROL:
                    array[i] = new MMalPort(ports[i], new string[] { });
                    break;

                case MMal.MMAL_ES_TYPE_T.MMAL_ES_TYPE_VIDEO:
                    array[i] = new MMalVideoPort(ports[i], subFormat);
                    break;

                case MMal.MMAL_ES_TYPE_T.MMAL_ES_TYPE_AUDIO:
                    array[i] = new MMalAudioPort(ports[i], subFormat);
                    break;

                // TODO case MMal.MMAL_ES_TYPE_T.MMAL_ES_TYPE_SUBPICTURE:
                default:
                    throw new Exception(String.Format("Invalid port format type {0}", ports[i]->format->type));
                }
            }

            return(array);
        }
예제 #2
0
 public MMalPortPool(MMalPort port)
 {
     MMal.MMAL_POOL_T *pool = MMal.mmal_port_pool_create(port.Pointer, port.Pointer->buffer_num, port.Pointer->buffer_size);
     if (pool == null)
     {
         throw new Exception(String.Format("failed to create buffer header pool for port {0}", port.Name));
     }
     Port = port;
     base.Initialize(pool);
 }
예제 #3
0
        //Get a buffer from the pool's queue and send it to *port*. *block* and
        //*timeout* act as they do in :meth:`get_buffer`. If no buffer is
        //available(for the values of* block* and* timeout*,
        //:exc:`~picamera.PiCameraMMALError` is raised).
        public virtual void SendBuffer(MMalPort port, bool block, int timeout)
        {
            var buf = GetBuffer(block, timeout);

            if (buf == null)
            {
                throw new Exception("no buffers available");
            }
            port.SendBuffer(buf);
        }
예제 #4
0
 public override string ToString()
 {
     if (_port != null)
     {
         return(new StringBuilder().
                AppendFormat("(MMalAudioPort {0}: format={1} buffers={2}x{3})",
                             Name, MMalPort.FormatToString(Format), _port->buffer_num, _port->buffer_size).ToString());
     }
     else
     {
         return("MMalAudioPort closed");
     }
 }
예제 #5
0
 public override string ToString()
 {
     if (_port != null)
     {
         return(new StringBuilder().
                AppendFormat("(MMALVideoPort {0}: format={1} buffers={2}x{3} frames={4}@{5}fps)",
                             Name, MMalPort.FormatToString(Format), _port->buffer_num, _port->buffer_size, Framesize, Framerate).ToString());
     }
     else
     {
         return("MMALVideoPort closed");
     }
 }
예제 #6
0
        public virtual void SendAllBuffers(MMalPort port = null, bool block = true, int timeout = 0)
        {
            int num = (int)MMal.mmal_queue_length(_pool->queue);

            if (num == 0)
            {
                throw new Exception("Pool queue is empty");
            }
            for (int i = 0; i < num; i++)
            {
                SendBuffer(port, block, timeout);
            }
        }
예제 #7
0
        public virtual void Close()
        {
            if (Source != null)
            {
                Source.Connection = null;
            }
            Source = null;
            if (Target != null)
            {
                Target.Connection = null;
            }

            Target = null;
        }
예제 #8
0
        public MMalBaseConnection(MMalPort source, MMalPort target, uint[] formats)
        {
            Tuple <string, string>[] compatible_opaque_formats =
            { new Tuple <string,                     string>("OPQV-single", "OPQV-single"),
              new Tuple <string, string>("OPQV-dual",   "OPQV-dual"),
              new Tuple <string, string>("OPQV-strips", "OPQV-strips"),
              new Tuple <string, string>("OPQV-dual",   "OPQV-single"),
              new Tuple <string, string>("OPQV-single", "OPQV-dual"),                          //# recent firmwares permit this
            };

            if (source.PortType != MMal.MMAL_PORT_TYPE_T.MMAL_PORT_TYPE_OUTPUT)
            {
                throw new Exception("source is not an output port");
            }
            if (target.PortType != MMal.MMAL_PORT_TYPE_T.MMAL_PORT_TYPE_INPUT)
            {
                throw new Exception("target is not an input port");
            }
            if (source.Connection != null)
            {
                throw new Exception("source port is already connected");
            }
            if (target.Connection != null)
            {
                throw new Exception("target port is already connected");
            }
            if (formats == null)
            {
                _formats = new uint[] { }
            }
            ;
            Source = source;
            Target = target;

            //try:

            //	iter(formats)
            //except TypeError:

            //	formats = (formats,)

            NegotiateFormat(formats);
            source.Connection = (MMalConnection)this;
            target.Connection = (MMalConnection)this;
            // # Descendents continue with connection implementation..)
        }