[Live-devel] How to create a custom sink that streams to both the network and a local file

Hoang Bui Vu buivuhoang15 at gmail.com
Sat Dec 10 06:44:50 PST 2011


Hi Ross,
I have been playing with the FramedFilter class for a while, and created a
simple filter that will just deliver its input to its output. However, it
is not working for some reason. Can you point me to the point that I'm
missing?

HistoryFilter::HistoryFilter(UsageEnvironment& env,
   FramedSource* inputSource)
  : FramedFilter(env, inputSource) {
}

HistoryFilter::~HistoryFilter() {
  Medium::close(fInputSource);
}

HistoryFilter* HistoryFilter::createNew(UsageEnvironment& env,
FramedSource* inputSource, char const* fileName)
{
return new HistoryFilter(env, inputSource);
}

void HistoryFilter::doGetNextFrame()
{
fFrameSize=0;
fInputSource->getNextFrame(fTo, fMaxSize, afterGettingFrame, this,
FramedSource::handleClosure, this);
}

void HistoryFilter::afterGettingFrame(void* clientData, unsigned
frameSize, unsigned /*numTruncatedBytes*/, struct timeval
presentationTime, unsigned /*durationInMicroseconds*/)
{
HistoryFilter* filter = (HistoryFilter*)clientData;
filter->afterGettingFrame1(frameSize, presentationTime);
}

void HistoryFilter::afterGettingFrame1(unsigned frameSize, struct timeval
presentationTime)
{
fFrameSize = frameSize;
fPresentationTime = presentationTime;
afterGetting(this);
}

In my main server play() function, I put in this code:

FramedSource* videoES = fileSource;
// Create a framer for the Video Elementary Stream:
videoSource = MPEG4VideoStreamFramer::createNew(*env, videoES);
historyFilter = HistoryFilter::createNew(*env, videoSource, "history.mp4");
// Finally, start playing:
*env << "Beginning to read from file...\n";
videoSink->startPlaying(*historyFilter, afterPlaying, videoSink);

Thank you for your time and patience.
On Fri, Dec 9, 2011 at 2:41 AM, Ross Finlayson <finlayson at live555.com>wrote:

> I'm currently doing a live camera streaming project that needs a history
> function. I've done some search and come to the solution of creating a
> custom sink that is the combination of MPEG4ESVideoRTPSink and FileSink,
> which will stream to both a local file and the network.
>
>
> A simpler solution would be to write a new 'filter' class (i.e., a
> subclass of "FramedFilter") that simply delivers its input to its output,
> but also writes to a file.  Then, add an object of this class to the end of
> your data stream (i.e., before you feed it into a sink).  That way, you
> won't need to create (or modify) any "MediaSink" class at all.
>
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20111210/831bc08d/attachment.html>


More information about the live-devel mailing list