Skip to content

Commit

Permalink
add clock control test
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWang committed Jan 25, 2013
1 parent ee3181a commit 9a9d311
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 6 deletions.
6 changes: 3 additions & 3 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ defineTest(getBuildRoot) {
#for Qt2, Qt3 which does not have QT_VERSION. Qt4: $$[QT_VERSION]
defineTest(preparePaths) {
getBuildRoot($$1, $$2)
MOC_DIR = $$BUILD_DIR/.moc/$${QT_VERSION}
RCC_DIR = $$BUILD_DIR/.rcc/$${QT_VERSION}
UI_DIR = $$BUILD_DIR/.ui/$${QT_VERSION}
MOC_DIR = $$BUILD_DIR/.moc/$${QT_VERSION}/$$TARGET
RCC_DIR = $$BUILD_DIR/.rcc/$${QT_VERSION}/$$TARGET
UI_DIR = $$BUILD_DIR/.ui/$${QT_VERSION}/$$TARGET
#obj is platform dependent
OBJECTS_DIR = $$qtLongName($$BUILD_DIR/.obj/$$TARGET)
#before target name changed
Expand Down
5 changes: 5 additions & 0 deletions src/AVClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ AVClock::ClockType AVClock::clockType() const
return clock_type;
}

bool AVClock::isActive() const
{
return clock_type == AudioClock || timer.isValid();
}

void AVClock::setClockAuto(bool a)
{
auto_clock = a;
Expand Down
13 changes: 12 additions & 1 deletion src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void AVPlayer::play()
}

demuxer_thread->start();

emit started();
#if 0
avTimerId = startTimer(1000/demuxer.frameRate());
#endif
Expand Down Expand Up @@ -333,6 +333,7 @@ void AVPlayer::stop()
video_thread->terminate(); ///if time out
}
}
emit stopped();
}
//FIXME: If not playing, it will just play but not play one frame.
void AVPlayer::playNextFrame()
Expand All @@ -344,6 +345,11 @@ void AVPlayer::playNextFrame()
pause(true);
}

void AVPlayer::seek(qreal pos)
{
demuxer_thread->seek(pos);
}

void AVPlayer::seekForward()
{
demuxer_thread->seekForward();
Expand All @@ -354,6 +360,11 @@ void AVPlayer::seekBackward()
demuxer_thread->seekBackward();
}

void AVPlayer::updateClock(qint64 msecs)
{
clock->updateExternalClock(msecs);
}

//TODO: what if no audio stream?
void AVPlayer::timerEvent(QTimerEvent* e)
{
Expand Down
1 change: 1 addition & 0 deletions src/QtAV/AVClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Q_EXPORT AVClock : public QObject
AVClock(QObject* parent = 0);
void setClockType(ClockType ct);
ClockType clockType() const;
bool isActive() const;
/*
* auto clock: use audio clock if audio stream found, otherwise use external clock
*/
Expand Down
8 changes: 7 additions & 1 deletion src/QtAV/AVPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,25 @@ class Q_EXPORT AVPlayer : public QObject
bool captureVideo();
bool play(const QString& path);
bool isPlaying() const;
void pause(bool p);
bool isPaused() const;
void setRenderer(VideoRenderer* renderer);

void setMute(bool mute);
bool isMute() const;

signals:
void started();
void stopped();

public slots:
void pause(bool p);
void play(); //replay
void stop();
void playNextFrame();
void seek(qreal pos);
void seekForward();
void seekBackward();
void updateClock(qint64 msecs); //update AVClock's external clock

protected slots:
void resizeVideo(const QSize& size);
Expand Down
2 changes: 1 addition & 1 deletion tests/sharedoutput/sharedoutput.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PROJECTROOT = $$PWD/../..
include($$PROJECTROOT/src/libQtAV.pri)
preparePaths($$OUT_PWD/../../out)

SOURCES += main.cpp\
SOURCES += main.cpp \
widget.cpp

HEADERS += widget.h
1 change: 1 addition & 0 deletions tests/tests.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TEMPLATE = subdirs

SUBDIRS += \
clockcontrol \
sharedoutput

0 comments on commit 9a9d311

Please sign in to comment.