您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ AVThread类代码示例

51自学网 2021-06-03 12:04:41
  C++
这篇教程C++ AVThread类代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中AVThread的典型用法代码示例。如果您正苦于以下问题:C++ AVThread类的具体用法?C++ AVThread怎么用?C++ AVThread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

在下文中一共展示了AVThread类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: frameDeliveredNextFrame

void AVDemuxThread::frameDeliveredNextFrame(){    AVThread *thread = video_thread ? video_thread : audio_thread;    Q_ASSERT(thread);    if (nb_next_frame.deref()) {#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) || QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)        Q_ASSERT_X((int)nb_next_frame > 0, "frameDeliveredNextFrame", "internal error. frameDeliveredNextFrame must be > 0");#else        Q_ASSERT_X((int)nb_next_frame.load() > 0, "frameDeliveredNextFrame", "internal error. frameDeliveredNextFrame must be > 0");#endif        return;    }    QMutexLocker locker(&next_frame_mutex);    Q_UNUSED(locker);    disconnect(thread, SIGNAL(frameDelivered()), this, SLOT(frameDeliveredNextFrame()));    if (user_paused) {        pause(true); // restore pause state        emit requestClockPause(true); // need direct connection    // pause both video and audio thread        if (video_thread)            video_thread->pause(true);        if (audio_thread)            audio_thread->pause(true);    }    if (clock_type >= 0) {        thread->clock()->setClockAuto(clock_type & 1);        thread->clock()->setClockType(AVClock::ClockType(clock_type/2));        clock_type = -1;    }}
开发者ID:151706061,项目名称:QtAV,代码行数:30,


示例2: run

 void run() {     AVThread *avt = demux_thread->videoThread();     avt->packetQueue()->clear(); // clear here     if (pts <= 0) {         demux_thread->demuxer->seek(qint64(-pts*1000.0) - 500LL);         QVector<qreal> ts;         qreal t = -1.0;         while (t < -pts) {             demux_thread->demuxer->readFrame();             if (demux_thread->demuxer->stream() != demux_thread->demuxer->videoStream())                 continue;             t = demux_thread->demuxer->packet().pts;             ts.push_back(t);         }         const qreal t0 = ts.back();         ts.pop_back();         const qreal dt = t0 - ts.back();         pts = ts.back();         // FIXME: sometimes can not seek to the previous pts, the result pts is always current pts, so let the target pts a little earlier         pts -= dt/2.0;     }     qDebug("step backward: %lld, %f", qint64(pts*1000.0), pts);     demux_thread->video_thread->setDropFrameOnSeek(false);     demux_thread->seekInternal(qint64(pts*1000.0), AccurateSeek); }
开发者ID:fmoyaarnao,项目名称:QtAV,代码行数:25,


示例3: qWarning

void AVDemuxThread::stepBackward(){    if (!video_thread)        return;    AVThread *t = video_thread;    const qreal pre_pts = video_thread->previousHistoryPts();    if (pre_pts == 0.0) {        qWarning("can not get previous pts");        return;    }    end = false;    // queue maybe blocked by put()    if (audio_thread) {        audio_thread->packetQueue()->clear(); // will put new packets before task run    }    class stepBackwardTask : public QRunnable {    public:        stepBackwardTask(AVDemuxThread *dt, qreal t)            : demux_thread(dt)            , pts(t)        {}        void run() {            AVThread *avt = demux_thread->videoThread();            avt->packetQueue()->clear(); // clear here            if (pts <= 0) {                demux_thread->demuxer->seek(qint64(-pts*1000.0) - 1000LL);                QVector<qreal> ts;                qreal t = -1.0;                while (t < -pts) {                    demux_thread->demuxer->readFrame();                    if (demux_thread->demuxer->stream() != demux_thread->demuxer->videoStream())                        continue;                    t = demux_thread->demuxer->packet().pts;                    ts.push_back(t);                }                ts.pop_back();                pts = ts.back();                // FIXME: sometimes can not seek to the previous pts, the result pts is always current pts            }            qDebug("step backward: %lld, %f", qint64(pts*1000.0), pts);            demux_thread->video_thread->setDropFrameOnSeek(false);            demux_thread->seekInternal(qint64(pts*1000.0), AccurateSeek);        }    private:        AVDemuxThread *demux_thread;        qreal pts;    };    pause(true);    t->packetQueue()->clear(); // will put new packets before task run    t->packetQueue();    Packet pkt;    pkt.pts = pre_pts;    t->packetQueue()->put(pkt); // clear and put a seek packet to ensure not frames other than previous frame will be decoded and rendered    video_thread->pause(false);    newSeekRequest(new stepBackwardTask(this, pre_pts));}
开发者ID:JingSao,项目名称:QtAV,代码行数:58,


示例4: call

 virtual void call() {     if (!mDemuxThread)         return;     if (mDemuxThread->isEnd())         return;     mDemuxThread->updateBufferState(); // ensure detect buffering immediately     AVThread *thread = mDemuxThread->videoThread();     //qDebug("try wake up video queue");     if (thread)         thread->packetQueue()->blockFull(false);     //qDebug("try wake up audio queue");     thread = mDemuxThread->audioThread();     if (thread)         thread->packetQueue()->blockFull(false); }
开发者ID:151706061,项目名称:QtAV,代码行数:15,


示例5: eofDecodedOnStepForward

void AVDemuxThread::eofDecodedOnStepForward(){    AVThread *thread = video_thread ? video_thread : audio_thread;    Q_ASSERT(thread);    QMutexLocker locker(&next_frame_mutex);    Q_UNUSED(locker);    disconnect(thread, SIGNAL(frameDelivered()), this, SLOT(frameDeliveredOnStepForward()));    disconnect(thread, SIGNAL(eofDecoded()), this, SLOT(eofDecodedOnStepForward()));    pause(false);    end = true;    if (clock_type >= 0) {        thread->clock()->setClockAuto(clock_type & 1);        thread->clock()->setClockType(AVClock::ClockType(clock_type/2));        clock_type = -1;    }}
开发者ID:ZM-Team,项目名称:QtAV,代码行数:16,


示例6: locker

void AVDemuxThread::nextFrame(){    // clock type will be wrong if no lock because slot frameDeliveredNextFrame() is in video thread    QMutexLocker locker(&next_frame_mutex);    Q_UNUSED(locker);    pause(true); // must pause AVDemuxThread (set user_paused true)    AVThread* av[] = {video_thread, audio_thread};    bool connected = false;    for (size_t i = 0; i < sizeof(av)/sizeof(av[0]); ++i) {        AVThread *t = av[i];        if (!t)            continue;        // set clock first        if (clock_type < 0)            clock_type = (int)t->clock()->isClockAuto() + 2*(int)t->clock()->clockType();        t->clock()->setClockType(AVClock::VideoClock);        t->scheduleFrameDrop(false);        t->pause(false);        t->packetQueue()->blockFull(false);        if (!connected) {            connect(t, SIGNAL(frameDelivered()), this, SLOT(frameDeliveredNextFrame()), Qt::DirectConnection);            connected = true;        }    }    emit requestClockPause(false);    nb_next_frame.ref();    pauseInternal(false);}
开发者ID:151706061,项目名称:QtAV,代码行数:28,


示例7: seekOnPauseFinished

void AVDemuxThread::seekOnPauseFinished(){    AVThread *thread = video_thread ? video_thread : audio_thread;    Q_ASSERT(thread);    disconnect(thread, SIGNAL(seekFinished(qint64)), this, SLOT(seekOnPauseFinished()));    if (user_paused) {        pause(true); // restore pause state        emit requestClockPause(true); // need direct connection    // pause video/audio thread        if (video_thread)            video_thread->pause(true);        if (audio_thread)            audio_thread->pause(true);    }    if (clock_type >= 0) {        thread->clock()->setClockAuto(clock_type & 1);        thread->clock()->setClockType(AVClock::ClockType(clock_type/2));        clock_type = -1;    }}
开发者ID:ntibor22,项目名称:QtAV,代码行数:20,


示例8: qDebug

void AVDemuxThread::seekInternal(qint64 pos, SeekType type){    AVThread* av[] = { audio_thread, video_thread};    qDebug("seek to %s %lld ms (%f%%)", QTime(0, 0, 0).addMSecs(pos).toString().toUtf8().constData(), pos, double(pos - demuxer->startTime())/double(demuxer->duration())*100.0);    demuxer->setSeekType(type);    demuxer->seek(pos);    if (ademuxer) {        ademuxer->setSeekType(type);        ademuxer->seek(pos);    }    AVThread *watch_thread = 0;    // TODO: why queue may not empty?    int sync_id = 0;    for (size_t i = 0; i < sizeof(av)/sizeof(av[0]); ++i) {        AVThread *t = av[i];        if (!t)            continue;        if (!sync_id)            sync_id = t->clock()->syncStart(!!audio_thread + !!video_thread);        Q_ASSERT(sync_id != 0);        qDebug("demuxer sync id: %d/%d", sync_id, t->clock()->syncId());        t->packetQueue()->clear();        t->requestSeek();        // TODO: the first frame (key frame) will not be decoded correctly if flush() is called.        //PacketBuffer *pb = t->packetQueue();        //qDebug("%s put seek packet. %d/%d-%.3f, progress: %.3f", t->metaObject()->className(), pb->buffered(), pb->bufferValue(), pb->bufferMax(), pb->bufferProgress());        t->packetQueue()->setBlocking(false); // aqueue bufferValue can be small (1), we can not put and take        Packet pkt;        pkt.pts = qreal(pos)/1000.0;        pkt.position = sync_id;        t->packetQueue()->put(pkt);        t->packetQueue()->setBlocking(true); // blockEmpty was false when eof is read.        if (isPaused()) { //TODO: deal with pause in AVThread?            t->pause(false);            watch_thread = t;        }    }    if (watch_thread) {        pauseInternal(false);        Q_EMIT requestClockPause(false); // need direct connection        // direct connection is fine here        connect(watch_thread, SIGNAL(seekFinished(qint64)), this, SLOT(seekOnPauseFinished()), Qt::DirectConnection);    }}
开发者ID:ZM-Team,项目名称:QtAV,代码行数:45,


示例9: frameDeliveredOnStepForward

void AVDemuxThread::frameDeliveredOnStepForward(){    AVThread *thread = video_thread ? video_thread : audio_thread;    Q_ASSERT(thread);    QMutexLocker locker(&next_frame_mutex);    Q_UNUSED(locker);    disconnect(thread, SIGNAL(frameDelivered()), this, SLOT(frameDeliveredOnStepForward()));    disconnect(thread, SIGNAL(eofDecoded()), this, SLOT(eofDecodedOnStepForward()));    if (user_paused) {        pause(true); // restore pause state        Q_EMIT requestClockPause(true); // need direct connection    // pause both video and audio thread        if (video_thread)            video_thread->pause(true);        if (audio_thread)            audio_thread->pause(true);    }    if (clock_type >= 0) {        thread->clock()->setClockAuto(clock_type & 1);        thread->clock()->setClockType(AVClock::ClockType(clock_type/2));        clock_type = -1;        thread->clock()->updateExternalClock((thread->previousHistoryPts() - thread->clock()->initialValue())*1000.0);    }    Q_EMIT stepFinished();}
开发者ID:fmoyaarnao,项目名称:QtAV,代码行数:25,


示例10: frameDeliveredNextFrame

void AVDemuxThread::frameDeliveredNextFrame(){    AVThread *thread = video_thread ? video_thread : audio_thread;    Q_ASSERT(thread);    QMutexLocker locker(&next_frame_mutex);    Q_UNUSED(locker);    disconnect(thread, SIGNAL(frameDelivered()), this, SLOT(frameDeliveredNextFrame()));    if (user_paused) {        pause(true); // restore pause state        emit requestClockPause(true); // need direct connection    // pause both video and audio thread        if (video_thread)            video_thread->pause(true);        if (audio_thread)            audio_thread->pause(true);    }    if (clock_type >= 0) {        thread->clock()->setClockAuto(clock_type & 1);        thread->clock()->setClockType(AVClock::ClockType(clock_type/2));        clock_type = -1;    }}
开发者ID:ntibor22,项目名称:QtAV,代码行数:22,


示例11: qDebug

void AVPlayer::stop(){    if (!isPlaying())        return;    qDebug("AVPlayer::stop");            //blockSignals(true); //TODO: move emit stopped() before it. or connect avthread.finished() to tryEmitStop() {if (!called_by_stop) emit}    struct avthreads_t {        AVThread *thread;        const char *name;    } threads[] = {        { audio_thread, "audio thread" },        { video_thread, "video thread" },        { 0, 0 }    };    for (int i = 0; threads[i].name; ++i) {        AVThread *thread = threads[i].thread;        if (!thread)            continue;        if (thread->isRunning()) {            qDebug("stopping %s...", threads[i].name);            //avoid emit stopped multiple times. AVThread.stopped() connects to AVDemuxThread.stopped().            thread->blockSignals(true);            thread->stop();            if (!thread->wait(1000)) {                qWarning("Timeout waiting for %s stopped. Terminate it.", threads[i].name);                thread->terminate();            }            thread->blockSignals(false);        }    }    //stop demux thread after avthread is better. otherwise demux thread may be terminated when waiting for avthread ?    if (demuxer_thread->isRunning()) {        qDebug("stopping demux thread...");        demuxer_thread->stop();        //wait for finish then we can safely set the vars, e.g. a/v decoders        if (!demuxer_thread->wait(1000)) {            qWarning("Timeout waiting for demux thread stopped. Terminate it.");            demuxer_thread->terminate(); //Terminate() causes the wait condition destroyed without waking up        }    }    qDebug("all threads [a|v|d] stopped...");    emit stopped();}
开发者ID:tianqizi,项目名称:QtAV,代码行数:43,


示例12: stop

//No more data to put. So stop blocking the queue to take the reset elementsvoid AVDemuxThread::stop(){    //this will not affect the pause state if we pause the output    //TODO: why remove blockFull(false) can not play another file?    AVThread* av[] = { audio_thread, video_thread};    for (size_t i = 0; i < sizeof(av)/sizeof(av[0]); ++i) {        AVThread* t = av[i];        if (!t)            continue;        t->packetQueue()->clear();        t->packetQueue()->blockFull(false); //??        while (t->isRunning()) {            qDebug() << "stopping thread " << t;            t->stop();            t->wait(500);        }    }    pause(false);    cond.wakeAll();    qDebug("all avthread finished. try to exit demux thread<<<<<<");    end = true;}
开发者ID:151706061,项目名称:QtAV,代码行数:23,


示例13: pause

void AVDemuxThread::run(){    m_buffering = false;    end = false;    if (audio_thread && !audio_thread->isRunning())        audio_thread->start(QThread::HighPriority);    if (video_thread && !video_thread->isRunning())        video_thread->start();    int stream = 0;    Packet pkt;    pause(false);    qDebug("get av queue a/v thread = %p %p", audio_thread, video_thread);    PacketBuffer *aqueue = audio_thread ? audio_thread->packetQueue() : 0;    PacketBuffer *vqueue = video_thread ? video_thread->packetQueue() : 0;    // aqueue as a primary buffer: music with/without cover    AVThread* thread = !video_thread || (audio_thread && demuxer->hasAttacedPicture()) ? audio_thread : video_thread;    m_buffer = thread->packetQueue();    const qint64 buf2 = aqueue ? aqueue->bufferValue() : 1; // TODO: may be changed by user. Deal with audio track change    if (aqueue) {        aqueue->clear();        aqueue->setBlocking(true);    }    if (vqueue) {        vqueue->clear();        vqueue->setBlocking(true);    }    connect(thread, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished(qint64)), Qt::DirectConnection);    seek_tasks.clear();    bool was_end = false;    if (ademuxer) {        ademuxer->seek(0LL);    }    while (!end) {        processNextSeekTask();        //vthread maybe changed by AVPlayer.setPriority() from no dec case        vqueue = video_thread ? video_thread->packetQueue() : 0;        if (demuxer->atEnd()) {            // if avthread may skip 1st eof packet because of a/v sync            if (aqueue && (!was_end || aqueue->isEmpty())) {                aqueue->put(Packet::createEOF());                aqueue->blockEmpty(false); // do not block if buffer is not enough. block again on seek            }            if (vqueue && (!was_end || vqueue->isEmpty())) {                vqueue->put(Packet::createEOF());                vqueue->blockEmpty(false);            }            m_buffering = false;            Q_EMIT mediaStatusChanged(QtAV::BufferedMedia);            was_end = true;            // wait for a/v thread finished            msleep(100);            continue;        }        was_end = false;        if (tryPause()) {            continue; //the queue is empty and will block        }        updateBufferState();        if (!demuxer->readFrame()) {            continue;        }        stream = demuxer->stream();        pkt = demuxer->packet();        Packet apkt;        bool audio_has_pic = demuxer->hasAttacedPicture();        int a_ext = 0;        if (ademuxer) {            QMutexLocker locker(&buffer_mutex);            Q_UNUSED(locker);            if (ademuxer) {                a_ext = -1;                audio_has_pic = ademuxer->hasAttacedPicture();                // FIXME: buffer full but buffering!!!                // avoid read external track everytime. aqueue may not block full                // vqueue will not block if aqueue is not enough                if (!aqueue->isFull() || aqueue->isBuffering()) {                    if (ademuxer->readFrame()) {                        if (ademuxer->stream() == ademuxer->audioStream()) {                            a_ext = 1;                            apkt = ademuxer->packet();                        }                    }                    // no continue otherwise. ademuxer finished earlier than demuxer                }            }        }        //qDebug("vqueue: %d, aqueue: %d/isbuffering %d isfull: %d, buffer: %d/%d", vqueue->size(), aqueue->size(), aqueue->isBuffering(), aqueue->isFull(), aqueue->buffered(), aqueue->bufferValue());        //QMutexLocker locker(&buffer_mutex); //TODO: seems we do not need to lock        //Q_UNUSED(locker);        /*1 is empty but another is enough, then do not block to          ensure the empty one can put packets immediatly.          But usually it will not happen, why?        */        /* demux thread will be blocked only when 1 queue is full and still put         * if vqueue is full and aqueue becomes empty, then demux thread         * will be blocked. so we should wake up another queue when empty(or threshold?).         * TODO: the video stream and audio stream may be group by group. provide it         * stream data: aaaaaaavvvvvvvaaaaaaaavvvvvvvvvaaaaaa, it happens//.........这里部分代码省略.........
开发者ID:151706061,项目名称:QtAV,代码行数:101,


示例14: seek

void DemuxerThr::seek(bool doDemuxerSeek){	if (!doDemuxerSeek && skipBufferSeek)		return;	if (playC.seekTo >= 0 || playC.seekTo == SEEK_STREAM_RELOAD)	{		AVThread *aThr = (AVThread *)playC.aThr, *vThr = (AVThread *)playC.vThr;		emit playC.chText(tr("Seeking"));		playC.canUpdatePos = false;		bool seekInBuffer = !skipBufferSeek;		if (playC.seekTo == SEEK_STREAM_RELOAD) //po zmianie strumienia audio, wideo lub napisów lub po ponownym uruchomieniu odtwarzania		{			playC.seekTo = playC.pos;			seekInBuffer = false;		}		const bool backward = playC.seekTo < (int)playC.pos;		bool flush = false, aLocked = false, vLocked = false;		skipBufferSeek = false;		if (seekInBuffer && (!localStream || !backward))		{			playC.vPackets.lock();			playC.aPackets.lock();			playC.sPackets.lock();			if			(				(playC.vPackets.packetsCount() || playC.aPackets.packetsCount()) &&				playC.vPackets.seekTo(playC.seekTo, backward) &&				playC.aPackets.seekTo(playC.seekTo, backward) &&				playC.sPackets.seekTo(playC.seekTo, backward)			)			{				doDemuxerSeek = false;				flush = true;				time = Functions::gettime() - updateBufferedTime; //zapewni, 
C++ AVector类代码示例
C++ AVSValue类代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。