Skip to content

Commit

Permalink
comments on filter
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed May 14, 2016
1 parent 746a082 commit c0dadbf
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 33 deletions.
34 changes: 16 additions & 18 deletions src/QtAV/Filter.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2013)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -27,42 +27,41 @@
#include <QtAV/FilterContext.h>

namespace QtAV {

class AudioFormat;
class AVOutput;
class AVPlayer;
class FilterPrivate;
class Statistics;
class Frame;
// TODO: QObject?
class Q_AV_EXPORT Filter : public QObject
{
Q_OBJECT
DPTR_DECLARE_PRIVATE(Filter)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
public:
virtual ~Filter();
//isEnabled() then setContext
//TODO: parameter FrameContext
void setEnabled(bool enabled = true); //AVComponent.enabled
bool isEnabled() const;

/*!
* \brief setOwnedByTarget
* If a filter is owned by target, it's not safe to access the filter after it's installed to a target.
* QtAV will delete the installed filter internally if filter is owned by target AND it's parent (QObject) is null.
* \param value
*/
void setOwnedByTarget(bool value = true);
// default is false
bool isOwnedByTarget() const;
// setInput/Output: no need to call installTo
// bool setInput(Filter*);
// bool setOutput(Filter*);
// install to audio/video as an on frame filter. append to the filter chain
/*!
* \brief installTo
* Install filter to player can process every frame before rendering.
* Equals to player->installFilter(this)
*/
virtual bool installTo(AVPlayer *player) = 0;
// called in destructor automatically
bool uninstall();
public Q_SLOTS:
void setEnabled(bool enabled = true);
signals:
void enabledChanged(bool);
protected:
Expand All @@ -85,13 +84,13 @@ class Q_AV_EXPORT VideoFilter : public Filter
VideoFilterContext* context();
virtual bool isSupported(VideoFilterContext::Type ct) const;
bool installTo(AVPlayer *player);
/*
* filter.installTo(target,...) calls target.installFilter(filter)
* If filter is already registered in FilterManager, then return false
* Otherwise, call FilterManager.register(filter) and target.filters.push_back(filter), return true
* NOTE: the installed filter will be deleted by the target if filter is owned by target AND it's parent (QObject) is null.
/*!
* \brief installTo
* The process() function is in rendering thread. Used by
* 1. GPU filters
* 2. QPainter rendering on widget based renderers. Changing the frame has no effect
* \return false if already installed
*/
// install to an output and do not modify frames. e.g. OSD
bool installTo(AVOutput *output); //only for video. move to video filter installToRenderer
void apply(Statistics* statistics, VideoFrame *frame = 0);

Expand All @@ -117,5 +116,4 @@ class Q_AV_EXPORT AudioFilter : public Filter
};

} //namespace QtAV

#endif // QTAV_FILTER_H
6 changes: 3 additions & 3 deletions src/QtAV/FilterContext.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2013)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -43,7 +43,7 @@ class Q_AV_EXPORT VideoFilterContext
public:
enum Type { ////audio and video...
QtPainter,
OpenGL, //Not implemented
OpenGL,
Direct2D, //Not implemeted
GdiPlus, //Not implemented
X11,
Expand Down
12 changes: 9 additions & 3 deletions src/filter/Filter.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2013)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -130,6 +130,12 @@ bool VideoFilter::installTo(AVPlayer *player)
}

/*TODO: move to AVOutput.cpp to reduce dependency?*/
/*
* filter.installTo(target,...) calls target.installFilter(filter)
* If filter is already registered in FilterManager, then return false
* Otherwise, call FilterManager.register(filter) and target.filters.push_back(filter), return true
* NOTE: the installed filter will be deleted by the target if filter is owned by target AND it's parent (QObject) is null.
*/
bool VideoFilter::installTo(AVOutput *output)
{
return output->installFilter(this);
Expand Down
7 changes: 4 additions & 3 deletions src/filter/FilterContext.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2013)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -155,6 +155,7 @@ QPainterFilterContext::~QPainterFilterContext()
}
}

// TODO: use drawPixmap?
void QPainterFilterContext::drawImage(const QPointF &pos, const QImage &image, const QRectF& source, Qt::ImageConversionFlags flags)
{
if (!prepare())
Expand Down
6 changes: 3 additions & 3 deletions src/filter/FilterManager.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2013)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down
6 changes: 3 additions & 3 deletions src/filter/FilterManager.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2013)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down

0 comments on commit c0dadbf

Please sign in to comment.