Пример #1
0
void VideoInput::cleanup()
{
    deleteDecoder();

    if (detach(&sink_))
        sink_.stop();
}
Пример #2
0
void VideoInput::process()
{
    bool newDecoderCreated = false;

    if (switchPending_.exchange(false)) {
        deleteDecoder();
        createDecoder();
        newDecoderCreated = true;
    }

    if (not decoder_) {
        loop_.stop();
        return;
    }

    captureFrame();

    if (newDecoderCreated) {
        /* Signal the client about the new sink */
        Manager::instance().getVideoManager()->startedDecoding(sinkID_, sink_.openedName(),
                decoder_->getWidth(), decoder_->getHeight(), false);
        DEBUG("LOCAL: shm sink <%s> started: size = %dx%d",
              sink_.openedName().c_str(), decoder_->getWidth(),
              decoder_->getHeight());
    }
}
Пример #3
0
bool VideoInput::captureFrame()
{
    VideoPacket pkt;
    const auto ret = decoder_->decode(getNewFrame(), pkt);

    switch (ret) {
        case VideoDecoder::Status::FrameFinished:
            break;

        case VideoDecoder::Status::ReadError:
        case VideoDecoder::Status::DecodeError:
            loop_.stop();
            // fallthrough
        case VideoDecoder::Status::Success:
            return false;

            // Play in loop
        case VideoDecoder::Status::EOFError:
            deleteDecoder();
            createDecoder();
            return false;
    }

    publishFrame();
    return true;
}
Пример #4
0
void
VideoInput::cleanup()
{
    deleteDecoder(); // do it first to let a chance to last frame to be displayed
    detach(sink_.get());
    sink_->stop();
    RING_DBG("VideoInput closed");
}
Пример #5
0
void
VideoInput::createDecoder()
{
    deleteDecoder();

    switchPending_ = false;

    if (decOpts_.input.empty()) {
        foundDecOpts(decOpts_);
        return;
    }

    auto decoder = std::unique_ptr<MediaDecoder>(new MediaDecoder());

    if (emulateRate_)
        decoder->emulateRate();

    decoder->setInterruptCallback(
        [](void* data) -> int { return not static_cast<VideoInput*>(data)->isCapturing(); },
        this);

    if (decoder->openInput(decOpts_) < 0) {
        RING_ERR("Could not open input \"%s\"", decOpts_.input.c_str());
        foundDecOpts(decOpts_);
        return;
    }

    /* Data available, finish the decoding */
    if (decoder->setupFromVideoData() < 0) {
        RING_ERR("decoder IO startup failed");
        foundDecOpts(decOpts_);
        return;
    }

    decOpts_.width = decoder->getWidth();
    decOpts_.height = decoder->getHeight();
    decOpts_.framerate = decoder->getFps();

    RING_DBG("created decoder with video params : size=%dX%d, fps=%lf",
             decOpts_.width, decOpts_.height, decOpts_.framerate.real());

    decoder_ = std::move(decoder);
    foundDecOpts(decOpts_);

    /* Signal the client about readable sink */
    sink_->setFrameSize(decoder_->getWidth(), decoder_->getHeight());
}
Пример #6
0
// -----------------------------------------------------------------------------
// Implementation of CActive
// -----------------------------------------------------------------------------
//
void CMPXImageUtil::RunL()
    {
    TInt deleteDecoder( ETrue );
    switch( iState ) 
        {
        case EDecoding:
            {
            if( iStatus == KErrNone ) 
                {
                if ( !iScaleRquired )
                    {   
                    iState = EIdle;
                    iObserver.ExtractAlbumArtCompleted(iBitmap,KErrNone);
                    iBitmap = NULL;
                    }
                else 
                    {
                    deleteDecoder = EFalse;
                    ScaleL();
                    }
                break;
                }
            else
                {
                // some error
                if ( iBitmap )
                    {
                    delete iBitmap;
                    iBitmap = NULL;                        
                    }
                iState = EIdle;
                iObserver.ExtractAlbumArtCompleted(iBitmap, iStatus.Int());
                break;   
                }
            }
        case EScaling:
            {
            iState = EIdle;
            iObserver.ExtractAlbumArtCompleted(iBitmap,iStatus.Int());
            iBitmap = NULL; 
            }
            break;

        default: // some error
            {
            iState = EIdle;
            if ( iBitmap )
                {
                delete iBitmap;
                iBitmap = NULL;                        
                }
            iObserver.ExtractAlbumArtCompleted(iBitmap,iStatus.Int());
            break;
            }
        }

    // It's safe to destroy iImageData here
    delete iImageData;
    iImageData = NULL;
    
    if ( deleteDecoder )
        {
        delete iImageDecoder;
        iImageDecoder = NULL;
        }
    }