Skip to content

Commit

Permalink
Merge pull request #2 from wang-bin/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
zrmei authored Jul 23, 2021
2 parents 8f36010 + 305e540 commit f51fc7e
Show file tree
Hide file tree
Showing 21 changed files with 167 additions and 73 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_PLAYERS "Build players" ON)
option(BUILD_TESTS "Build tests" ON)
option(BUILD_QT5OPENGL "Build with Qt5 OpenGL module" ON)
option(BUILD_QML "Build QML interfaces" ON)

list(APPEND CMAKE_FIND_ROOT_PATH ${QTDIR})

Expand Down Expand Up @@ -74,7 +75,7 @@ if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(QTAV_INSTALL_HEADERS ${CMAKE_INSTALL_PREFIX}/include)
set(QTAV_INSTALL_LIBS ${CMAKE_INSTALL_PREFIX}/lib)
set(QTAV_INSTALL_BINS ${CMAKE_INSTALL_PREFIX}/bin)
set(QTAV_INSTALL_QML ${CMAKE_INSTALL_PREFIX}/qml)
set(QTAV_INSTALL_QML ${QTAV_INSTALL_LIBS}/qml)
else()
set(CMAKE_INSTALL_PREFIX ${QT_INSTALL_PREFIX} CACHE PATH "default install path" FORCE)
set(QTAV_INSTALL_HEADERS ${QT_INSTALL_HEADERS})
Expand Down Expand Up @@ -116,13 +117,17 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio.*")
endif()

add_subdirectory(src)

find_package(Qt5Widgets)
if(Qt5Widgets_FOUND)
add_subdirectory(widgets)
endif()
find_package(Qt5 COMPONENTS Qml Quick)
if(Qt5Qml_FOUND AND Qt5Quick_FOUND)
add_subdirectory(qml)

if(BUILD_QML)
find_package(Qt5 COMPONENTS Qml Quick)
if(Qt5Qml_FOUND AND Qt5Quick_FOUND)
add_subdirectory(qml)
endif()
endif()

if(BUILD_EXAMPLES OR BUILD_PLAYERS)
Expand Down
22 changes: 15 additions & 7 deletions cmake/FindQtAV.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,25 @@ find_path(QTAV_INCLUDE_DIR NAMES QtAV.h
HINTS ${QT_INSTALL_HEADERS}
PATH_SUFFIXES QtAV
)
find_library(QTAV_LIBRARY NAMES QtAV QtAV1
HINTS ${QT_INSTALL_LIBS}
)

find_path(QTAVWIDGETS_INCLUDE_DIR NAMES QtAVWidgets.h
HINTS ${QT_INSTALL_HEADERS}
PATH_SUFFIXES QtAVWidgets
)
find_library(QTAVWIDGETS_LIBRARY NAMES QtAVWidgets QtAVWidgets1
HINTS ${QT_INSTALL_LIBS}
)
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
find_library(QTAV_LIBRARY NAMES QtAVd QtAVd1
HINTS ${QT_INSTALL_LIBS}
)
find_library(QTAVWIDGETS_LIBRARY NAMES QtAVWidgetsd QtAVWidgetsd1
HINTS ${QT_INSTALL_LIBS}
)
else()
find_library(QTAV_LIBRARY NAMES QtAV QtAV1
HINTS ${QT_INSTALL_LIBS}
)
find_library(QTAVWIDGETS_LIBRARY NAMES QtAVWidgets QtAVWidgets1
HINTS ${QT_INSTALL_LIBS}
)
endif()

set(QTAV_INCLUDE_DIRS ${QTAV_INCLUDE_DIR} ${QTAV_INCLUDE_DIR}/..)
set(QTAV_LIBRARIES ${QTAV_LIBRARY})
Expand Down
6 changes: 5 additions & 1 deletion common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ defineReplace(platformTargetSuffix) {
CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac: return($${suffix}_debug)
win32: return($${suffix}d)
win32: {
win32-g++: return($${suffix})
!win32-g++: return($${suffix}d)
}
}
}
return($$suffix)
Expand All @@ -134,6 +137,7 @@ defineReplace(qtLibName) {
}
}
RET = $$RET$$platformTargetSuffix()
qtAtLeast(5, 14):android:RET = $${RET}_$$ANDROID_TARGET_ARCH
!win32: return($$RET)

isEmpty(2): VERSION_EXT = $$VERSION
Expand Down
14 changes: 7 additions & 7 deletions deploy.pri
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ INSTALL_PREFIX = /usr/local
share.files = $$PROJECTROOT/qtc_packaging/common/changelog \
$$PROJECTROOT/qtc_packaging/common/copyright \
$$PROJECTROOT/qtc_packaging/common/README
share.path = /usr/share/doc/$${TARGET}
share.path = $$[QT_INSTALL_PREFIX]/share/doc/$${TARGET}

isEqual(TEMPLATE, app) {
unix:!symbian {
!isEmpty(MEEGO_VERSION_MAJOR) {
DEFINES += CACHE_APPDIR
INSTALL_PREFIX = /opt/$${TARGET}
desktopfile.files = $$PROJECTROOT/qtc_packaging/debian_harmattan/$${TARGET}.desktop
desktopfile.path = /usr/share/applications
desktopfile.path = $$[QT_INSTALL_PREFIX]/share/applications
icon.files = $$PROJECTROOT/qtc_packaging/debian_harmattan/$${TARGET}.png
icon.path = /usr/share/icons/hicolor/80x80/apps
icon.path = $$[QT_INSTALL_PREFIX]/share/icons/hicolor/80x80/apps
#debian.files = $$PROJECTROOT/qtc_packaging/harmattan/control
} else:maemo5 {
INSTALL_PREFIX = /opt/$${TARGET}
desktopfile.files = $$PROJECTROOT/qtc_packaging/debian_fremantle/$${TARGET}.desktop
desktopfile.path = /usr/share/applications/hildon
desktopfile.path = $$[QT_INSTALL_PREFIX]/share/applications/hildon
icon.files = $$PROJECTROOT/qtc_packaging/debian_fremantle/$${TARGET}.png
icon.path = /usr/share/icons/hicolor/64x64/apps
icon.path = $$[QT_INSTALL_PREFIX]/share/icons/hicolor/64x64/apps
#debian.files = $$PROJECTROOT/qtc_packaging/fremantle/control
} else {
desktopfile.files = $$PROJECTROOT/qtc_packaging/debian_generic/$${TARGET}.desktop
desktopfile.path = /usr/share/applications
desktopfile.path = $$[QT_INSTALL_PREFIX]/share/applications
icon.files = $$PROJECTROOT/qtc_packaging/debian_generic/$${TARGET}.png
icon.path = /usr/share/icons/hicolor/64x64/apps
icon.path = $$[QT_INSTALL_PREFIX]/share/icons/hicolor/64x64/apps
#debian.files = $$PROJECTROOT/qtc_packaging/generic/control
}
INSTALLS += desktopfile icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ android-no-sdk {
} else:unix {
maemo5 {
desktopfile.files = $${TARGET}.desktop
desktopfile.path = /usr/share/applications/hildon
desktopfile.path = $$[QT_INSTALL_PREFIX]/share/applications/hildon
icon.files = $${TARGET}64.png
icon.path = /usr/share/icons/hicolor/64x64/apps
icon.path = $$[QT_INSTALL_PREFIX]/share/icons/hicolor/64x64/apps
} else:!isEmpty(MEEGO_VERSION_MAJOR) {
desktopfile.files = $${TARGET}_harmattan.desktop
desktopfile.path = /usr/share/applications
desktopfile.path = $$[QT_INSTALL_PREFIX]/share/applications
icon.files = $${TARGET}80.png
icon.path = /usr/share/icons/hicolor/80x80/apps
icon.path = $$[QT_INSTALL_PREFIX]/share/icons/hicolor/80x80/apps
} else { # Assumed to be a Desktop Unix
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
Expand Down
8 changes: 6 additions & 2 deletions qml/QmlAV/QmlAVPlayer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******************************************************************************
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2017 Wang Bin <[email protected]>
Expand Down Expand Up @@ -98,6 +98,7 @@ class QmlAVPlayer : public QObject, public QQmlParserStatus
// TODO: startPosition/stopPosition
Q_PROPERTY(QStringList audioBackends READ audioBackends WRITE setAudioBackends NOTIFY audioBackendsChanged)
Q_PROPERTY(QStringList supportedAudioBackends READ supportedAudioBackends)
Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged)
public:
enum Loop { Infinite = -1 };
// use (1<<31)-1
Expand Down Expand Up @@ -280,6 +281,7 @@ class QmlAVPlayer : public QObject, public QQmlParserStatus
QStringList supportedAudioBackends() const;
QStringList audioBackends() const;
void setAudioBackends(const QStringList& value);
int notifyInterval() const;

public Q_SLOTS:
void play();
Expand All @@ -290,7 +292,7 @@ public Q_SLOTS:
void seek(int offset);
void seekForward();
void seekBackward();

void setNotifyInterval(int notifyInterval);
Q_SIGNALS:
void volumeChanged();
void mutedChanged();
Expand Down Expand Up @@ -340,6 +342,8 @@ public Q_SLOTS:
void statusChanged();
void mediaObjectChanged();
void audioBackendsChanged();
void notifyIntervalChanged();

private Q_SLOTS:
// connect to signals from player
void _q_error(const QtAV::AVError& e);
Expand Down
18 changes: 17 additions & 1 deletion qml/QmlAVPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******************************************************************************
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2017 Wang Bin <[email protected]>
Expand Down Expand Up @@ -89,6 +89,7 @@ void QmlAVPlayer::classBegin()
connect(mpPlayer, SIGNAL(seekableChanged()), SIGNAL(seekableChanged()));
connect(mpPlayer, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished()), Qt::DirectConnection);
connect(mpPlayer, SIGNAL(bufferProgressChanged(qreal)), SIGNAL(bufferProgressChanged()));
connect(mpPlayer, SIGNAL(notifyIntervalChanged()), this,SIGNAL(notifyIntervalChanged()));
connect(this, SIGNAL(channelLayoutChanged()), SLOT(applyChannelLayout()));
// direct connection to ensure volume() in slots is correct
connect(mpPlayer->audio(), SIGNAL(volumeChanged(qreal)), SLOT(applyVolume()), Qt::DirectConnection);
Expand Down Expand Up @@ -604,6 +605,13 @@ void QmlAVPlayer::setAudioBackends(const QStringList &value)
Q_EMIT audioBackendsChanged();
}

int QmlAVPlayer::notifyInterval() const
{
if(!mpPlayer)
return -1;
return mpPlayer->notifyInterval();
}

QStringList QmlAVPlayer::supportedAudioBackends() const
{
return AudioOutput::backendsAvailable();
Expand Down Expand Up @@ -898,6 +906,14 @@ void QmlAVPlayer::seekBackward()
mpPlayer->seekBackward();
}

void QmlAVPlayer::setNotifyInterval(int notifyInterval)
{
if (!mpPlayer)
return;
mpPlayer->setNotifyInterval(notifyInterval);
}


void QmlAVPlayer::_q_error(const AVError &e)
{
mError = NoError;
Expand Down
1 change: 1 addition & 0 deletions qml/SGVideoNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "QtAV/VideoFrame.h"
#include <QtCore/QScopedPointer>
#include <QtGui/QOpenGLFunctions>
#include <QtQuick/QSGMaterial>
#include <QtQuick/QSGMaterialShader>

// all in QSGRenderThread
Expand Down
3 changes: 2 additions & 1 deletion qml/Video.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


import QtQuick 2.0
import QtAV 1.7

Expand Down Expand Up @@ -91,6 +91,7 @@ Item {
property alias internalVideoTracks: player.internalVideoTracks
property alias internalSubtitleTracks: player.internalSubtitleTracks
property alias internalSubtitleTrack: player.internalSubtitleTrack
property alias notifyInterval: player.notifyInterval
/*** Properties of VideoOutput ***/
/*!
\qmlproperty enumeration Video::fillMode
Expand Down
3 changes: 2 additions & 1 deletion qml/plugins.qmltypes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import QtQuick.tooling 1.1
import QtQuick.tooling 1.1

// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
Expand Down Expand Up @@ -248,6 +248,7 @@ Module {
Property { name: "videoFilters"; type: "QuickVideoFilter"; isList: true; isReadonly: true }
Property { name: "audioBackends"; type: "QStringList" }
Property { name: "supportedAudioBackends"; type: "QStringList"; isReadonly: true }
Property { name: "notifyInterval"; type: "int" }
Signal { name: "loopCountChanged" }
Signal { name: "videoOutChanged" }
Signal { name: "paused" }
Expand Down
1 change: 1 addition & 0 deletions src/AVDemuxThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ void AVDemuxThread::run()
break;
pause(true);
Q_EMIT requestClockPause(true);
Q_EMIT mediaEndActionPauseTriggered();
if (aqueue)
aqueue->blockEmpty(true);
if (vqueue)
Expand Down
1 change: 1 addition & 0 deletions src/AVDemuxThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class AVDemuxThread : public QThread
bool hasSeekTasks();
Q_SIGNALS:
void requestClockPause(bool value);
void mediaEndActionPauseTriggered();
void mediaStatusChanged(QtAV::MediaStatus);
void bufferProgressChanged(qreal);
void seekFinished(qint64 timestamp);
Expand Down
18 changes: 18 additions & 0 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ AVPlayer::AVPlayer(QObject *parent) :
//direct connection can not sure slot order?
connect(d->read_thread, SIGNAL(finished()), this, SLOT(stopFromDemuxerThread()), Qt::DirectConnection);
connect(d->read_thread, SIGNAL(requestClockPause(bool)), masterClock(), SLOT(pause(bool)), Qt::DirectConnection);
connect(d->read_thread, SIGNAL(mediaEndActionPauseTriggered()), this, SLOT(onMediaEndActionPauseTriggered()));
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, SLOT(onSeekFinished(qint64)), Qt::DirectConnection);
connect(d->read_thread, SIGNAL(stepFinished()), this, SLOT(onStepFinished()), Qt::DirectConnection);
connect(d->read_thread, SIGNAL(internalSubtitlePacketRead(int, QtAV::Packet)), this, SIGNAL(internalSubtitlePacketRead(int, QtAV::Packet)), Qt::DirectConnection);
d->vcapture = new VideoCapture(this);
}
Expand Down Expand Up @@ -1403,6 +1405,16 @@ void AVPlayer::updateMediaStatus(QtAV::MediaStatus status)
Q_EMIT mediaStatusChanged(d->status);
}

void AVPlayer::onMediaEndActionPauseTriggered()
{
if(d->state == PausedState)
return;

d->state = PausedState;
Q_EMIT stateChanged(d->state);
Q_EMIT paused(true);
}

void AVPlayer::onSeekFinished(qint64 value)
{
d->seeking = false;
Expand All @@ -1414,6 +1426,11 @@ void AVPlayer::onSeekFinished(qint64 value)
Q_EMIT positionChanged(value);
}

void AVPlayer::onStepFinished()
{
Q_EMIT stepFinished();
}

void AVPlayer::tryClearVideoRenderers()
{
if (!d->vthread) {
Expand Down Expand Up @@ -1514,6 +1531,7 @@ void AVPlayer::timerEvent(QTimerEvent *te)
if (te->timerId() == d->timer_id) {
// killTimer() should be in the same thread as object. kill here?
if (isPaused()) {
d->clock->pause(true);
//return; //ensure positionChanged emitted for stepForward()
}
// active only when playing
Expand Down
4 changes: 3 additions & 1 deletion src/AVPlayerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ void AVPlayer::Private::initCommonStatistics(int s, Statistics::Common *st, AVCo
#if (defined FF_API_R_FRAME_RATE && FF_API_R_FRAME_RATE) //removed in libav10
//FIXME: which 1 should we choose? avg_frame_rate may be nan, r_frame_rate may be wrong(guessed value)
else if (stream->r_frame_rate.den && stream->r_frame_rate.num) {
st->frame_rate = av_q2d(stream->r_frame_rate);
if (stream->r_frame_rate.num < 90000)
st->frame_rate = av_q2d(stream->r_frame_rate);

qDebug("%d/%d", stream->r_frame_rate.num, stream->r_frame_rate.den);
}
#endif //FF_API_R_FRAME_RATE
Expand Down
Loading

0 comments on commit f51fc7e

Please sign in to comment.