forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qml: add bufferSize & internalVideoTracks property
from @Killerbeans
- Loading branch information
Showing
4 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Multimedia framework based on Qt and FFmpeg | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2017 Wang Bin <[email protected]> | ||
* This file is part of QtAV (from 2013) | ||
|
@@ -78,8 78,11 @@ class QmlAVPlayer : public QObject, public QQmlParserStatus | |
Q_PROPERTY(bool useWallclockAsTimestamps READ useWallclockAsTimestamps WRITE setWallclockAsTimestamps NOTIFY useWallclockAsTimestampsChanged) | ||
Q_PROPERTY(QtAV::VideoCapture *videoCapture READ videoCapture CONSTANT) | ||
Q_PROPERTY(int audioTrack READ audioTrack WRITE setAudioTrack NOTIFY audioTrackChanged) | ||
Q_PROPERTY(int videoTrack READ videoTrack WRITE setVideoTrack NOTIFY videoTrackChanged) | ||
Q_PROPERTY(int bufferSize READ bufferSize WRITE setBufferSize NOTIFY bufferSizeChanged) | ||
Q_PROPERTY(QUrl externalAudio READ externalAudio WRITE setExternalAudio NOTIFY externalAudioChanged) | ||
Q_PROPERTY(QVariantList internalAudioTracks READ internalAudioTracks NOTIFY internalAudioTracksChanged) | ||
Q_PROPERTY(QVariantList internalVideoTracks READ internalVideoTracks NOTIFY internalVideoTracksChanged) | ||
Q_PROPERTY(QVariantList externalAudioTracks READ externalAudioTracks NOTIFY externalAudioTracksChanged) | ||
Q_PROPERTY(QVariantList internalSubtitleTracks READ internalSubtitleTracks NOTIFY internalSubtitleTracksChanged) | ||
// internal subtitle, e.g. mkv embedded subtitles | ||
|
@@ -221,6 224,18 @@ class QmlAVPlayer : public QObject, public QQmlParserStatus | |
int audioTrack() const; | ||
void setAudioTrack(int value); | ||
QVariantList internalAudioTracks() const; | ||
/*! | ||
/*! | ||
* \brief videoTrack | ||
* The video stream number in current media. | ||
* Value can be: 0, 1, 2.... 0 means the 1st video stream in current media | ||
*/ | ||
int videoTrack() const; | ||
void setVideoTrack(int value); | ||
QVariantList internalVideoTracks() const; | ||
|
||
int bufferSize() const; | ||
void setBufferSize(int value); | ||
/*! | ||
* \brief externalAudio | ||
* If externalAudio url is valid, player will use audioTrack of external audio as audio source. | ||
|
@@ -285,10 300,13 @@ public Q_SLOTS: | |
void abortOnTimeoutChanged(); | ||
void audioTrackChanged(); | ||
void internalAudioTracksChanged(); | ||
void videoTrackChanged(); | ||
void internalVideoTracksChanged(); | ||
void externalAudioChanged(); | ||
void externalAudioTracksChanged(); | ||
void internalSubtitleTrackChanged(); | ||
void internalSubtitleTracksChanged(); | ||
void bufferSizeChanged(); | ||
|
||
void errorChanged(); | ||
void error(Error error, const QString &errorString); | ||
|
@@ -341,6 359,7 @@ private Q_SLOTS: | |
int m_timeout; | ||
bool m_abort_timeout; | ||
int m_audio_track; | ||
int m_video_track; | ||
QUrl m_audio; | ||
int m_sub_track; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Multimedia framework based on Qt and FFmpeg | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2017 Wang Bin <[email protected]> | ||
* This file is part of QtAV (from 2013) | ||
|
@@ -63,6 63,7 @@ QmlAVPlayer::QmlAVPlayer(QObject *parent) : | |
, m_timeout(30000) | ||
, m_abort_timeout(true) | ||
, m_audio_track(0) | ||
, m_video_track(0) | ||
, m_sub_track(0) | ||
, m_ao(AudioOutput::backendsAvailable()) | ||
{ | ||
|
@@ -76,6 77,7 @@ void QmlAVPlayer::classBegin() | |
mpPlayer = new AVPlayer(this); | ||
connect(mpPlayer, SIGNAL(internalSubtitleTracksChanged(QVariantList)), SIGNAL(internalSubtitleTracksChanged())); | ||
connect(mpPlayer, SIGNAL(internalAudioTracksChanged(QVariantList)), SIGNAL(internalAudioTracksChanged())); | ||
connect(mpPlayer, SIGNAL(internalVideoTracksChanged(QVariantList)), SIGNAL(internalVideoTracksChanged())); | ||
connect(mpPlayer, SIGNAL(externalAudioTracksChanged(QVariantList)), SIGNAL(externalAudioTracksChanged())); | ||
connect(mpPlayer, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged())); | ||
connect(mpPlayer, SIGNAL(mediaStatusChanged(QtAV::MediaStatus)), SLOT(_q_statusChanged())); | ||
|
@@ -393,6 395,36 @@ void QmlAVPlayer::setAudioTrack(int value) | |
mpPlayer->setAudioStream(value); | ||
} | ||
|
||
int QmlAVPlayer::videoTrack() const | ||
{ | ||
return m_video_track; | ||
} | ||
|
||
void QmlAVPlayer::setVideoTrack(int value) | ||
{ | ||
if (m_video_track == value) | ||
return; | ||
m_video_track = value; | ||
Q_EMIT videoTrackChanged(); | ||
if (mpPlayer) | ||
mpPlayer->setVideoStream(value); | ||
} | ||
|
||
int QmlAVPlayer::bufferSize() const | ||
{ | ||
return mpPlayer->bufferValue(); | ||
} | ||
|
||
void QmlAVPlayer::setBufferSize(int value) | ||
{ | ||
if (mpPlayer->bufferValue() == value) | ||
return; | ||
if (mpPlayer) { | ||
mpPlayer->setBufferValue(value); | ||
Q_EMIT bufferSizeChanged(); | ||
} | ||
} | ||
|
||
QUrl QmlAVPlayer::externalAudio() const | ||
{ | ||
return m_audio; | ||
|
@@ -417,6 449,11 @@ QVariantList QmlAVPlayer::internalAudioTracks() const | |
return mpPlayer ? mpPlayer->internalAudioTracks() : QVariantList(); | ||
} | ||
|
||
QVariantList QmlAVPlayer::internalVideoTracks() const | ||
{ | ||
return mpPlayer ? mpPlayer->internalVideoTracks() : QVariantList(); | ||
} | ||
|
||
int QmlAVPlayer::internalSubtitleTrack() const | ||
{ | ||
return m_sub_track; | ||
|
@@ -686,6 723,7 @@ void QmlAVPlayer::setPlaybackState(PlaybackState playbackState) | |
mpPlayer->setInterruptOnTimeout(m_abort_timeout); | ||
mpPlayer->setRepeat(mLoopCount - 1); | ||
mpPlayer->setAudioStream(m_audio_track); | ||
mpPlayer->setVideoStream(m_video_track); // will check in case of error | ||
mpPlayer->setSubtitleStream(m_sub_track); | ||
if (!vcodec_opt.isEmpty()) { | ||
QVariantHash vcopt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters