[Live-devel] Buffered MPEG2-TS to RTP how-to

Russell Brennan rjbrennn at gmail.com
Thu Jun 21 14:53:02 PDT 2007


Ok, after some hours of tinkering this (non-working) bit of code is what I
have come up with:
*********************
int pipeFile[2];   // Pipe file descriptors
FILE* fdFile;
....
if (pipe(pipeFile) == -1) // create the pipe
    {   perror ("pipe");
        exit(1);
    }
if ((fdFile = fdopen(pipeFile[0], "r")) == NULL) //open the read end of our
pipe as a FILE
    {   perror ("fdopen");
        exit(1);
    }
...
while (1) {
        // Grab to our unix pipe
        m_grabx(hin_, &cfInBuf_[0], ngot_); // this fills the buffer
cfInBuf_
        if (ngot_ > 0) {
        // Send out the packet to Unix pipe
          write(pipeFile[1], &cfInBuf_[0], ngot_*sizeof(real_4)); // write
to our pipe
        }
    }
...
and then,
ByteStreamFileSource* fileSource =
            ByteStreamFileSource::createNew(*env, fdFile, deleteFidOnClose,
inputDataChunkSize);
and so on.

However, I am getting the error
BasicTaskScheduler::SingleStep(): select() fails: Bad file descriptor

Does anything look awry offhand?  I would have like to have just passed
createNew my pipe file descriptor, but I had to convert to the FILE struct
to fit the createNew prototype.  Thanks!

Russell




On 6/20/07, Russell Brennan <rjbrennn at gmail.com> wrote:
>
> Well, I have been experimenting with piping and I can get file descriptors
> for pipes using the pipe() call, but it seems that I need a FILE sctruct
> rather than a file descriptor. Any ideas how to convert one to the other?
>
> Russell
>
>
> On 6/20/07, Russell Brennan <rjbrennn at gmail.com> wrote:
> >
> > Yes, I'm on RedHat 5... Piping it sounds liek a great idea to me, I'm
> > going to try to put something together and I'll post some code snippets for
> > future reference when I get things running smoothly.  Thanks,
> >
> > Russell
> >
> >
> >  On 6/19/07, Ross Finlayson <finlayson at live555.com > wrote:
> > >
> > > >I am trying to take a buffer of MPEG2-TS data which is constantly
> > > >written to, and hook it up to live555 for output via RTP.
> > >
> > > The best way to do this is to make your buffer an OS pipe, and then
> > > just have your LIVE555-based application read from this.  For
> > > example, if you write your MPEG-2 TS data to standard output (in one
> > > process), and then pipe this to your LIVE-555-based application (in
> > > another process), that reads from "stdin" (see below).
> > >
> > > If you do this, then you won't have to modify any existing code
> > > (except the name of the input file in "testMPEG2TransportStreamer").
> > >
> > > >  I am currently basing my work on the testMEPG2TransportStreamer
> > > >code, but obviously this was designed to stream a file.
> > >
> > > Yes - however, the special file name "stdin" can be used to read from
> > > standard input.
> > >
> > > (I'm assuming that you're running a Unix system (including Linux).
> > > If instead you're running Windows, then I don't know what you'd do
> > > (although I think Windows has 'named pipes').)
> > > --
> > >
> > > Ross Finlayson
> > > Live Networks, Inc.
> > > http://www.live555.com/
> > > _______________________________________________
> > > live-devel mailing list
> > > live-devel at lists.live555.com
> > > http://lists.live555.com/mailman/listinfo/live-devel
> > >
> >
> >
> >
> > --
> > Russell Brennan
> > RJBrennn at gmail.com
> > (708) 699-7314
>
>
>
>
> --
> Russell Brennan
> RJBrennn at gmail.com
> (708) 699-7314
>



-- 
Russell Brennan
RJBrennn at gmail.com
(708) 699-7314
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.live555.com/pipermail/live-devel/attachments/20070621/38e273b8/attachment.html 


More information about the live-devel mailing list