[streaming] named pipe in Windows
montez
montez at lcmi.ufsc.br
Fri Feb 7 20:30:41 CET 2003
Hi,
we have an Apollo MPEG-2 encoder that only has windows driver.
So we implemented a windows named pipe into vls code.
Apollo writes in the pipe (e.g. \\.\pipe\vls) and
vls (compiled for windows using msys+mingw) reads it and streams to
network.
We had success !!! :-) :-) :-)
It is enough to configure the input.cfg
BEGIN "1" Name = "mytest"
FileName = "\\.\pipe\vls"
Type = "Mpeg1-PS"
END
In file.h we added:
private:
HANDLE m_hHd; // <----- new !!!
The main changes in vls source code were made in file.cpp:
#ifdef _WIN32
#include <windows.h>
#endif
...
...
...
void C_File::Open(const C_String& strMode, int iPermissions)
{
#ifdef _WIN32
char *strPipeName;
if((strPipeName = strstr(m_strPath.GetString(),"\\\\.\\pipe\\")) != NULL)
{
#define BUFFER_IN_LEN 1000
#define BUFFER_OUT_LEN 1000
if ( (m_hHd = CreateNamedPipe(
strPipeName;,
PIPE_ACCESS_INBOUND,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
1, BUFFER_OUT_LEN,
BUFFER_IN_LEN,
30000, // time-out
NULL
)) == INVALID_HANDLE_VALUE )
{
printf("Error creating pipe\n" );
}
printf("Waiting client to connect with %s (buffer in=%d out=%d\n",
strPipeName;, BUFFER_IN_LEN, BUFFER_OUT_LEN );
if( ConnectNamedPipe( m_hHd, NULL ) == FALSE )
printf("Error connecting pipe\n" );
return;
}
else
#endif
m_hFd = fopen(m_strPath.GetString(), strMode.GetString());
...
...
...
int C_File::Read(byte* pBuff, int iSize)
{
ASSERT(pBuff);
ASSERT(iSize > 0);
int iRc = 0;
#ifdef _WIN32
if(m_hHd) // pipe?
{
DWORD cbRead;
do
{
if( !ReadFile( m_hHd, pBuff + iRc, iSize - iRc, &cbRead, NULL) )
{
printf("Error reading pipe\n");
return FILE_EOF;
}
iRc += cbRead;
if(iRc < iSize)
Sleep(0);
} while(iRc < iSize);
}
else
#endif
{
ASSERT(m_hFd ); // Make sure that the file has been opened
iRc = fread(pBuff, sizeof(byte), iSize, m_hFd);
}
...
...
...
int C_File::Seek(s64 iOffset, int iStartPos)
{
int iRc;
#ifdef _WIN32
if(m_hHd) // pipe?
iRc = 0;
else
#endif
{
ASSERT(m_hFd);
iRc = fseek(m_hFd, iOffset, iStartPos);
}
...
...
...
I hope the report of our experience helps somebody.
Carlos Montez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.videolan.org/pipermail/streaming/attachments/20030207/9ac60b04/attachment.htm
More information about the streaming
mailing list