[Live-devel] MPEG4VideoStreamDiscreteFramer

Thiago A. Corrêa thiago at remotevideo.com.br
Wed Sep 15 14:33:14 PDT 2004


Actually, my source class checks if the timestamp is higher than the last
timestamp fed to the framer, if not simply returns.

The only change I did to this working implementation was insert "Discrete"
into the class name *smile*, then it became quite CPU hungry. :(
This is my framedsource class:

class StreamChannel
{
public:
    QImage* currentImage;
    QMutex imageLock;
    const char* SDPLine; // This is fairly constant.
    uint volatile lastFrameTime;
    StreamChannel() : currentImage(0), SDPLine(0), lastFrameTime(0)
    {
    }
    ~StreamChannel()
    {
        delete [] SDPLine;
    }
};

class RVDeviceSource : public FramedSource
{
    StreamChannel* channel;
    FFMPEG_Encoder codec;
    QByteArray d;
    uint lastFrameTime;
public:
    RVDeviceSource( UsageEnvironment& env, uint cam ) : FramedSource( env ),
lastFrameTime(0)
    {
        channel = StreamServer::instance()->channel(cam);
    }
    ~RVDeviceSource()
    {
    }
private:
    void deliverFrame()
    {
        QMutexLocker lock( &channel->imageLock );
        d = codec.compress( *channel->currentImage );
        nextTask()
            = envir().taskScheduler().scheduleDelayedTask(0,
(TaskFunc*)afterGetting, this);
    }
    void doGetNextFrame()
    {
        if ( channel->lastFrameTime <= lastFrameTime ) // not ready
            return;
        deliverFrame();
        memcpy( fTo, d.data(), QMIN(d.size(),fMaxSize) );
        if ( fMaxSize < d.size() )
        {
            fNumTruncatedBytes = d.size() - fMaxSize;
            fFrameSize = fMaxSize;
        }
        else
            fFrameSize = d.size();
    }
};

Thanks for your support.

Best Regards,
    Thiago A. Corrêa


----- Original Message ----- 
From: "Ross Finlayson" <finlayson at live.com>
To: "LIVE.COM Streaming Media - development & use" <live-devel at ns.live.com>
Sent: Tuesday, September 14, 2004 7:21 PM
Subject: Re: [Live-devel] MPEG4VideoStreamDiscreteFramer


>
> >   I tried replacing the MPEG4VideoStreamFramer::createNew() call in my
> > code to use the newer MPEG4VideoStreamDiscreteFramer, but it somehow
> > instead of improving performance, made it at lot worst. The CPU usage
> > rises from 40% to 100% and it appears to "want more"
>
> Take a look at the implementation of your input source class (the class
> that reads mpeg-4 video frames from <whatever>, to be fed to
> "MPEG4VideoStreamDiscreteFramer").  It sounds like that class may be
> 'polling' for data - i.e, spinning in a loop.  It shouldn't do
> this.  Instead, it should return immediately if no new frame data is
available.
>
>
> Ross Finlayson
> LIVE.COM
> <http://www.live.com/>
>
> _______________________________________________
> live-devel mailing list
> live-devel at lists.live.com
> http://lists.live.com/mailman/listinfo/live-devel
>



More information about the live-devel mailing list