[Live-devel] Question on streams in Windows

Chris Van Brederode cvanbrederode at gmail.com
Thu Feb 28 13:49:13 PST 2013


Hello,

I'm trying to develop a small program that reads output from an xvid
encoder through a pipe (named "\\.\pipe\file.m4e" as an example) and serves
it over RTSP - unicast.

I've got a small application based off of testOnDemandRTSPServer.cpp, and
it works if I save the bitstream to a file and give it that.  But once I
use the pipe, VLC times out trying to connect to the server, and the server
doesn't give any errors.

Upon digging into the code, I found this in ByteStreamSource.cpp:

#ifdef READ_FROM_FILES_SYNCHRONOUSLY
  fFrameSize = fread(fTo, 1, fMaxSize, fFid);
#else
  if (fFidIsSeekable) {
    fFrameSize = fread(fTo, 1, fMaxSize, fFid);
  } else {
    // For non-seekable files (e.g., pipes), call "read()" rather than
"fread()", to ensure that the read doesn't block:
    fFrameSize = read(fileno(fFid), fTo, fMaxSize);
  }
#endif

....and looking for READ_FROM_FILES_SYNCHRONOUSLY I find it defined in
InputFile.hh with the following note:

#define READ_FROM_FILES_SYNCHRONOUSLY 1
    // Because Windows is a silly toy operating system that doesn't
(reliably) treat
    // open files as being readable sockets (which can be handled within
the default
    // "BasicTaskScheduler" event loop, using "select()"), we implement
file reading
    // in Windows using synchronous, rather than asynchronous, I/O.  This
can severely
    // limit the scalability of servers using this code that run on Windows.
    // If this is a problem for you, then either use a better operating
system,
    // or else write your own Windows-specific event loop ("TaskScheduler"
subclass)
    // that can handle readable data in Windows open files as an event.

I'm working under the assumption that the problem is that the fread call is
blocking and cause the problems.

My question is this: can I safely undefine READ_FROM_FILES_SYNCHRONOUSLY
(on windows) and have non-blocking calls to read, or do I need to extend
ByteStreamSource with my own version that uses non-blocking IO in windows?

Thank you for any help...

Chris V.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20130228/6f675a0d/attachment.html>


More information about the live-devel mailing list