xenko
10th July 2008, 16:02
Linux and windows can create what are called named pipes. They are basically a cross between a file and a pipe, or a socket.
For example, in linux this can be done using the mkfifo line command. This creates a permanent identifier in the file system which can be open by two or more programs and share data through it, as if it were a file, using the common file writing and reading calls from the system.
Windows offers as well some system calls to create named pipes in the file system, and use them while they are kept open by the application.
We're creating an image and video processing tool which communicates with the MPlayer application through this kind of pipes. Using sockets might be a bit of slow down, and the MPlayer is not prepared to work using common pipes.
To solve this we create a named pipe, and execute a copy of the MPlayer. We launch it properly configured to decode a video file or read from a digital camera and dump the data in an easy readable format to an end of the named pipe.
The other end is connected to an image processing thread created by our application.
We've created a class of the Qt style named QNamedPipe:
class QNamedPipe: public QObject
{
Q_OBJECT;
public:
QNamedPipe();
~QNamedPipe();
QString getInputFilePath() const;
QString getOutputFilePath() const;
};
Its basic usage is as follows: to create a named pipe, create an object from that class. To get an end's name, use functions 'getInputFilePath' and 'getOutputFilePath'. To destroy the named pipe just delete the object.
Could it be interesting to include such a class (or alike) to create named pipes in Qt? How could this be proposed to the trolls?
We've just developed the class to work on linux, but it may be helpful if it were also for windows.
For example, in linux this can be done using the mkfifo line command. This creates a permanent identifier in the file system which can be open by two or more programs and share data through it, as if it were a file, using the common file writing and reading calls from the system.
Windows offers as well some system calls to create named pipes in the file system, and use them while they are kept open by the application.
We're creating an image and video processing tool which communicates with the MPlayer application through this kind of pipes. Using sockets might be a bit of slow down, and the MPlayer is not prepared to work using common pipes.
To solve this we create a named pipe, and execute a copy of the MPlayer. We launch it properly configured to decode a video file or read from a digital camera and dump the data in an easy readable format to an end of the named pipe.
The other end is connected to an image processing thread created by our application.
We've created a class of the Qt style named QNamedPipe:
class QNamedPipe: public QObject
{
Q_OBJECT;
public:
QNamedPipe();
~QNamedPipe();
QString getInputFilePath() const;
QString getOutputFilePath() const;
};
Its basic usage is as follows: to create a named pipe, create an object from that class. To get an end's name, use functions 'getInputFilePath' and 'getOutputFilePath'. To destroy the named pipe just delete the object.
Could it be interesting to include such a class (or alike) to create named pipes in Qt? How could this be proposed to the trolls?
We've just developed the class to work on linux, but it may be helpful if it were also for windows.