Skip to content

Commit

Permalink
add signal seekFinished
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed May 5, 2015
1 parent e54f901 commit 8828cde
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions qml/QmlAV/QmlAVPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public Q_SLOTS:
void stopped();
void playing();
void seekableChanged();
void seekFinished();
void fastSeekChanged();
void bufferProgressChanged();
void videoCodecPriorityChanged();
Expand Down
1 change: 1 addition & 0 deletions qml/QmlAVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void QmlAVPlayer::classBegin()
connect(mpPlayer, SIGNAL(stopped()), SLOT(_q_stopped()));
connect(mpPlayer, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged()));
connect(mpPlayer, SIGNAL(seekableChanged()), SIGNAL(seekableChanged()));
connect(mpPlayer, SIGNAL(seekFinished()), this, SIGNAL(seekFinished()), Qt::DirectConnection);
connect(mpPlayer, SIGNAL(bufferProgressChanged(qreal)), SIGNAL(bufferProgressChanged()));
connect(this, SIGNAL(channelLayoutChanged()), SLOT(applyChannelLayout()));
// direct connection to ensure volume() in slots is correct
Expand Down
3 changes: 3 additions & 0 deletions qml/Video.qml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ Item {
*/
signal playing

signal seekFinished

VideoOutput2 {
id: videoOut
anchors.fill: video
Expand Down Expand Up @@ -351,6 +353,7 @@ Item {
onPaused: video.paused()
onStopped: video.stopped()
onPlaying: video.playing()
onSeekFinished: video.seekFinished()
}

/*!
Expand Down
1 change: 1 addition & 0 deletions qml/plugins.qmltypes
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ Module {
Signal { name: "paused" }
Signal { name: "stopped" }
Signal { name: "playing" }
Signal { name: "seekFinished" }
Signal {
name: "error"
Parameter { name: "error"; type: "Error" }
Expand Down
5 changes: 4 additions & 1 deletion src/AVDemuxThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ void AVDemuxThread::run()
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
m_buffer = !vqueue || (aqueue && demuxer->hasAttacedPicture()) ? aqueue : vqueue;
AVThread* thread = !video_thread || (audio_thread && demuxer->hasAttacedPicture()) ? audio_thread : video_thread;
m_buffer = thread->packetQueue();
const int buf2 = aqueue ? aqueue->bufferValue() : 1; // TODO: may be changed by user
if (aqueue) {
aqueue->clear();
Expand All @@ -404,6 +405,7 @@ void AVDemuxThread::run()
vqueue->clear();
vqueue->setBlocking(true);
}
connect(thread, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished(qint64)), Qt::DirectConnection);
seek_tasks.clear();
bool was_end = false;
while (!end) {
Expand Down Expand Up @@ -496,6 +498,7 @@ void AVDemuxThread::run()
vqueue->blockEmpty(false);
video_thread->wait(500);
}
disconnect(this, SIGNAL(seekFinished(qint64)));
qDebug("Demux thread stops running....");
emit mediaStatusChanged(QtAV::EndOfMedia);
}
Expand Down
1 change: 1 addition & 0 deletions src/AVDemuxThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public slots:
void requestClockPause(bool value);
void mediaStatusChanged(QtAV::MediaStatus);
void bufferProgressChanged(qreal);
void seekFinished(qint64 timestamp);

private slots:
void frameDeliveredSeekOnPause();
Expand Down
1 change: 1 addition & 0 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ AVPlayer::AVPlayer(QObject *parent) :
connect(d->read_thread, SIGNAL(requestClockPause(bool)), masterClock(), SLOT(pause(bool)), Qt::DirectConnection);
connect(d->read_thread, SIGNAL(mediaStatusChanged(QtAV::MediaStatus)), this, SLOT(updateMediaStatus(QtAV::MediaStatus)));
connect(d->read_thread, SIGNAL(bufferProgressChanged(qreal)), this, SIGNAL(bufferProgressChanged(qreal)));
connect(d->read_thread, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished()), Qt::DirectConnection);

d->vcapture = new VideoCapture(this);
}
Expand Down
6 changes: 5 additions & 1 deletion src/AVThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ public slots:

Q_SIGNALS:
void frameDelivered();

/*!
* \brief seekFinished
* \param timestamp the frame pts after seek
*/
void seekFinished(qint64 timestamp);
protected:
AVThread(AVThreadPrivate& d, QObject *parent = 0);
void resetState();
Expand Down
6 changes: 3 additions & 3 deletions src/QtAV/AVPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ class Q_AV_EXPORT AVPlayer : public QObject
QVariantHash optionsForAudioCodec() const;
void setOptionsForVideoCodec(const QVariantHash& dict);
QVariantHash optionsForVideoCodec() const;
// avfilter_init_dict

public slots:
void togglePause();
Expand Down Expand Up @@ -389,7 +388,7 @@ public slots:
void setHue(int val); //not implemented
void setSaturation(int val);

signals:
Q_SIGNALS:
void bufferProgressChanged(qreal);
void relativeTimeModeChanged();
void autoLoadChanged();
Expand All @@ -408,6 +407,7 @@ public slots:
void startPositionChanged(qint64 position);
void stopPositionChanged(qint64 position);
void seekableChanged();
void seekFinished();
void positionChanged(qint64 position);
void interruptTimeoutChanged();
void interruptOnTimeoutChanged();
Expand All @@ -416,7 +416,7 @@ public slots:
void contrastChanged(int val);
void hueChanged(int val);
void saturationChanged(int val);
private slots:
private Q_SLOTS:
void loadInternal(); // simply load
void unloadInternal();
void playInternal(); // simply play
Expand Down
1 change: 1 addition & 0 deletions src/VideoThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ void VideoThread::run()
if (seek_done_count > 1) { // theorically can't be >1 if seeking!
qDebug("reset render_pts0");
d.render_pts0 = 0;
Q_EMIT seekFinished(qint64(pts*1000.0));
}
}
if (seek_count == -1 && seek_done_count > 0)
Expand Down

0 comments on commit 8828cde

Please sign in to comment.