Skip to content

Commit

Permalink
Merge branch 'filter'
Browse files Browse the repository at this point in the history
Conflicts:
	i18n/QtAV_zh_CN.qm
	i18n/QtAV_zh_CN.ts
  • Loading branch information
wang-bin committed Mar 15, 2013
2 parents f26b44a b022674 commit 5ad38b5
Show file tree
Hide file tree
Showing 21 changed files with 533 additions and 58 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 16,7 @@ QtAV can meet your most demands

- Seek, pause/resume
- Video capture
- OSD
- Aspect ratio
- Transform video using GraphicsItemRenderer. (rotate, shear, etc)
- Playing frame by frame (currently support forward playing)
Expand Down Expand Up @@ -98,11 99,12 @@ For more detail to using QtAV, see the wiki [Use QtAV In Your Project](https://g

Default Shortcuts
-----------------
- Ctrl O: open a file
- Space: pause/continue
- F: fullscreen on/off
- T: stays on top on/off
- N: show next frame. Continue the playing by pressing "Space"
- O: open a file
- O: OSD
- P: replay
- Q/ESC: quit
- S: stop
Expand Down
2 changes: 2 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 11,8 @@ network stream
avio pause network

TODO:
Filter framework: use FrameContext instead of QByteArray. Render on vo or image

type.h
QtAV_Compat.h=>pch
external clock
Expand Down
Binary file modified i18n/QtAV_zh_CN.qm
Binary file not shown.
63 changes: 37 additions & 26 deletions i18n/QtAV_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,149 27,160 @@
<context>
<name>QtAV::EventFilter</name>
<message>
<location filename="../src/EventFilter.cpp" line="55"/>
<location filename="../src/EventFilter.cpp" line="56"/>
<source>Open a video</source>
<translation>打开视频</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="64"/>
<location filename="../src/EventFilter.cpp" line="65"/>
<source>Open an url</source>
<translation>打开 url</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="64"/>
<location filename="../src/EventFilter.cpp" line="65"/>
<source>Url</source>
<translation></translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="73"/>
<location filename="../src/EventFilter.cpp" line="74"/>
<source>About QtAV</source>
<translation>关于 QtAV</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="93"/>
<location filename="../src/EventFilter.cpp" line="263"/>
<location filename="../src/EventFilter.cpp" line="85"/>
<source>Ctrl O: open a file
</source>
<translation>Ctrl O: 打开文件</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="86"/>
<source>O: OSD
</source>
<translation>O: OSD</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="95"/>
<location filename="../src/EventFilter.cpp" line="272"/>
<source>Help</source>
<translation>帮助</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="78"/>
<location filename="../src/EventFilter.cpp" line="79"/>
<source>Drag and drop a file to player
</source>
<translation>拖放文件到播放器
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="79"/>
<location filename="../src/EventFilter.cpp" line="80"/>
<source>Shortcut:
</source>
<translation>快捷键:
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="80"/>
<location filename="../src/EventFilter.cpp" line="81"/>
<source>Space: pause/continue
</source>
<translation>空格: 暂停/继续
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="81"/>
<location filename="../src/EventFilter.cpp" line="82"/>
<source>F: fullscreen on/off
</source>
<translation>F: 全屏开关
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="82"/>
<location filename="../src/EventFilter.cpp" line="83"/>
<source>T: stays on top on/off
</source>
<translation>T: 窗口置顶开关
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="83"/>
<location filename="../src/EventFilter.cpp" line="84"/>
<source>N: show next frame. Continue the playing by pressing &apos;Space&apos;
</source>
<translation>N: 播放下一帧
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="84"/>
<source>O: open a file
</source>
<translation>O: 打开文件
<translation type="obsolete">O: 打开文件
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="85"/>
<location filename="../src/EventFilter.cpp" line="87"/>
<source>P: replay
</source>
<translation>P: 重新播放
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="86"/>
<location filename="../src/EventFilter.cpp" line="88"/>
<source>Q/ESC: quit
</source>
<translation>Q/ESC: 退出</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="87"/>
<location filename="../src/EventFilter.cpp" line="89"/>
<source>S: stop
</source>
<translation>S: 停止播放
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="88"/>
<location filename="../src/EventFilter.cpp" line="90"/>
<source>R: switch aspect ratio</source>
<translation>R: 切换显示比例</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="89"/>
<location filename="../src/EventFilter.cpp" line="91"/>
<source>M: mute on/off
</source>
<translation>M: 静音开关
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="90"/>
<location filename="../src/EventFilter.cpp" line="92"/>
<source>C: capture video</source>
<translation>C: 视频截图
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="91"/>
<location filename="../src/EventFilter.cpp" line="93"/>
<source>Up/Down: volume /-
</source>
<translation>光标上下: 音量增减
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="92"/>
<location filename="../src/EventFilter.cpp" line="94"/>
<source>-&gt;/&lt;-: seek forward/backward
</source>
<translation>光标左右: 快退 快进
</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="259"/>
<location filename="../src/EventFilter.cpp" line="268"/>
<source>Open</source>
<translation>打开</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="260"/>
<location filename="../src/EventFilter.cpp" line="269"/>
<source>Open Url</source>
<translation>打开 Url</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="262"/>
<location filename="../src/EventFilter.cpp" line="271"/>
<source>About</source>
<translation>关于</translation>
</message>
<message>
<location filename="../src/EventFilter.cpp" line="265"/>
<location filename="../src/EventFilter.cpp" line="274"/>
<source>About Qt</source>
<translation>关于 Qt</translation>
</message>
Expand Down
19 changes: 19 additions & 0 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 27,7 @@
#include <QEvent>
#include <QtCore/QDir>

#include <QtAV/OSDFilterQPainter.h>
#include <QtAV/AVDemuxer.h>
#include <QtAV/AudioThread.h>
#include <QtAV/Packet.h>
Expand Down Expand Up @@ -54,6 55,7 @@ namespace QtAV {
AVPlayer::AVPlayer(QObject *parent) :
QObject(parent),loaded(false),capture_dir("capture"),_renderer(0),_audio(0)
,event_filter(0),video_capture(0)
, osd(0)
{
qDebug("%s", aboutQtAV().toUtf8().constData());
/*
Expand Down Expand Up @@ -90,6 92,7 @@ AVPlayer::AVPlayer(QObject *parent) :

setPlayerEventFilter(new EventFilter(this));
setVideoCapture(new VideoCapture());
setOSDFilter(new OSDFilterQPainter());
}

AVPlayer::~AVPlayer()
Expand Down Expand Up @@ -231,6 234,19 @@ bool AVPlayer::captureVideo()
return true;
}

OSDFilter* AVPlayer::setOSDFilter(OSDFilter *osd)
{
OSDFilter *old = osd;
this->osd = osd;
video_thread->setOSDFilter(osd);
return old;
}

OSDFilter* AVPlayer::osdFilter()
{
return osd;
}

bool AVPlayer::play(const QString& path)
{
setFile(path);
Expand Down Expand Up @@ -339,6 355,9 @@ void AVPlayer::play()
Q_ASSERT(clock != 0);
clock->reset();

if (osd) {
osd->setTotalTime(duration());
}
if (aCodecCtx) {
qDebug("Starting audio thread...");
audio_thread->start(QThread::HighestPriority);
Expand Down
19 changes: 14 additions & 5 deletions src/EventFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 34,7 @@
#include <QtAV/AVPlayer.h>
#include <QtAV/AudioOutput.h>
#include <QtAV/VideoRenderer.h>
#include <QtAV/OSDFilter.h>

namespace QtAV {

Expand Down Expand Up @@ -81,7 82,8 @@ void EventFilter::help()
"<p>" tr("F: fullscreen on/off\n") "</p>"
"<p>" tr("T: stays on top on/off\n") "</p>"
"<p>" tr("N: show next frame. Continue the playing by pressing 'Space'\n") "</p>"
"<p>" tr("O: open a file\n") "</p>"
"<p>" tr("Ctrl O: open a file\n") "</p>"
"<p>" tr("O: OSD\n") "</p>"
"<p>" tr("P: replay\n") "</p>"
"<p>" tr("Q/ESC: quit\n") "</p>"
"<p>" tr("S: stop\n") "</p>"
Expand Down Expand Up @@ -113,7 115,8 @@ bool EventFilter::eventFilter(QObject *watched, QEvent *event)
return false;
break;
case QEvent::KeyPress: {
int key = static_cast<QKeyEvent*>(event)->key();
QKeyEvent *key_event = static_cast<QKeyEvent*>(event);
int key = key_event->key();
switch (key) {
case Qt::Key_C: //capture
player->captureVideo();
Expand Down Expand Up @@ -171,9 174,15 @@ bool EventFilter::eventFilter(QObject *watched, QEvent *event)
qDebug("vol = %.3f", player->audio()->volume());
}
break;
case Qt::Key_O:
//TODO: emit a signal so we can use custome dialogs?
openLocalFile();
case Qt::Key_O: {
Qt::KeyboardModifiers m = key_event->modifiers();
if (m == Qt::ControlModifier) {
//TODO: emit a signal so we can use custome dialogs?
openLocalFile();
} else/* if (m == Qt::NoModifier) */{
player->osdFilter()->useNextShowType();
}
}
break;
case Qt::Key_Left:
qDebug("<-");
Expand Down
37 changes: 37 additions & 0 deletions src/Filter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 1,37 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013 Wang Bin <[email protected]>
* This file is part of QtAV
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/

#include "QtAV/Filter.h"
#include "private/Filter_p.h"

namespace QtAV {

Filter::Filter(FilterPrivate &d)
:DPTR_INIT(&d)
{

}

Filter::~Filter()
{
}

} //namespace QtAV
8 changes: 2 additions & 6 deletions src/GraphicsItemRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 70,8 @@ void GraphicsItemRenderer::paint(QPainter *painter, const QStyleOptionGraphicsIt
Q_UNUSED(option);
Q_UNUSED(widget);
DPTR_D(GraphicsItemRenderer);
if (!d.scale_in_renderer) {
d.img_mutex.lock();
}
QMutexLocker locker(&d.img_mutex);
Q_UNUSED(locker);
//fill background color only when the displayed frame rect not equas to renderer's
if (d.out_rect != boundingRect()) {
painter->fillRect(boundingRect(), QColor(0, 0, 0));
Expand All @@ -88,9 87,6 @@ void GraphicsItemRenderer::paint(QPainter *painter, const QStyleOptionGraphicsIt
} else {
painter->drawImage(d.out_rect, d.image);
}
if (!d.scale_in_renderer) {
d.img_mutex.unlock();
}
}
//GraphicsWidget will lose focus forever if focus out. Why?

Expand Down
Loading

0 comments on commit 5ad38b5

Please sign in to comment.