Skip to content

Commit

Permalink
no stl types that break abi
Browse files Browse the repository at this point in the history
most algorithms and containers are fine. no std::string, exception
  • Loading branch information
wang-bin committed Sep 13, 2015
1 parent 96714b4 commit 8058ac5
Show file tree
Hide file tree
Showing 81 changed files with 504 additions and 628 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ branches:
- prelease
- ci/travis
- /^travis-.*$/
- dev

git:
submodules: true
Expand Down
10 changes: 5 additions & 5 deletions examples/filters/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ int main(int argc, char *argv[])
VideoRenderer *renderer = 0;
bool textfilter = false;
if (vo == QLatin1String("gl")) {
renderer = VideoRendererFactory::create(VideoRendererId_GLWidget);
renderer = VideoRenderer::create(VideoRendererId_GLWidget);
textfilter = true;
} else if (vo == QLatin1String("d2d")) {
renderer = VideoRendererFactory::create(VideoRendererId_Direct2D);
renderer = VideoRenderer::create(VideoRendererId_Direct2D);
} else if (vo == QLatin1String("gdi")) {
renderer = VideoRendererFactory::create(VideoRendererId_GDI);
renderer = VideoRenderer::create(VideoRendererId_GDI);
} else if (vo == QLatin1String("xv")) {
renderer = VideoRendererFactory::create(VideoRendererId_XV);
renderer = VideoRenderer::create(VideoRendererId_XV);
} else {
renderer = VideoRendererFactory::create(VideoRendererId_Widget);
renderer = VideoRenderer::create(VideoRendererId_Widget);
textfilter = true;
}
if (!renderer) {
Expand Down
10 changes: 7 additions & 3 deletions examples/player/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void MainWindow::changeVO(QAction *action)
return;
}
VideoRendererId vid = (VideoRendererId)action->data().toInt();
VideoRenderer *vo = VideoRendererFactory::create(vid);
VideoRenderer *vo = VideoRenderer::create(vid);
if (vo && vo->isAvailable()) {

setRenderer(vo);
Expand Down Expand Up @@ -740,7 +740,7 @@ void MainWindow::setVideoDecoderNames(const QStringList &vd)
vdnames << v.toLower();
}
QStringList vidp;
QStringList vids = idsToNames(GetRegistedVideoDecoderIds());
QStringList vids = idsToNames(VideoDecoder::registered());
foreach (const QString& v, vids) {
if (vdnames.contains(v.toLower())) {
vidp.append(v);
Expand Down Expand Up @@ -1284,7 +1284,11 @@ void MainWindow::handleError(const AVError &e)
void MainWindow::onMediaStatusChanged()
{
QString status;
AVPlayer *player = qobject_cast<AVPlayer*>(sender());
AVPlayer *player = reinterpret_cast<AVPlayer*>(sender());
if (!player) { //why it happens? reinterpret_cast works.
qWarning() << "invalid sender() " << sender() << player;
return;
}
switch (player->mediaStatus()) {
case NoMedia:
status = tr("No media");
Expand Down
12 changes: 6 additions & 6 deletions examples/player/config/DecoderConfigPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static QVector<QtAV::VideoDecoderId> sPriorityUi;
QStringList idsToNames(QVector<VideoDecoderId> ids) {
QStringList decs;
foreach (int id, ids) {
decs.append(QString::fromLatin1(VideoDecoderFactory::name(id).c_str()));
decs.append(QString::fromLatin1(VideoDecoder::name(id)));
}
return decs;
}
Expand All @@ -53,7 +53,7 @@ QVector<VideoDecoderId> idsFromNames(const QStringList& names) {
foreach (QString name, names) {
if (name.isEmpty())
continue;
VideoDecoderId id = VideoDecoderFactory::id(name.toStdString(), false);
VideoDecoderId id = VideoDecoder::id(name.toLatin1().constData());
if (id == 0)
continue;
decs.append(id);
Expand Down Expand Up @@ -182,7 +182,7 @@ DecoderConfigPage::DecoderConfigPage(QWidget *parent) :
sPriorityUi = idsFromNames(Config::instance().decoderPriorityNames());
QStringList vds = Config::instance().decoderPriorityNames();
QVector<VideoDecoderId> vids = idsFromNames(vds);
std::vector<QtAV::VideoDecoderId> vds_all = VideoDecoderFactory::registeredIds();
QVector<QtAV::VideoDecoderId> vds_all = VideoDecoder::registered();
QVector<QtAV::VideoDecoderId> all = vids;
foreach (QtAV::VideoDecoderId vid, vds_all) {
if (!vids.contains(vid))
Expand All @@ -191,7 +191,7 @@ DecoderConfigPage::DecoderConfigPage(QWidget *parent) :
mpDecLayout = new QVBoxLayout;

foreach (QtAV::VideoDecoderId vid, all) {
VideoDecoder *vd = VideoDecoderFactory::create(vid);
VideoDecoder *vd = VideoDecoder::create(vid);
DecoderItemWidget *iw = new DecoderItemWidget(scrollAreaWidgetContents);
iw->buildUiFor(vd);
mDecItems.append(iw);
Expand All @@ -204,7 +204,7 @@ DecoderConfigPage::DecoderConfigPage(QWidget *parent) :
delete vd;
}/*
for (int i = 0; i < vds_all.size(); ++i) {
VideoDecoder *vd = VideoDecoderFactory::create(vds_all.at(i));
VideoDecoder *vd = VideoDecoder::create(vds_all.at(i));
DecoderItemWidget *iw = new DecoderItemWidget();
iw->buildUiFor(vd);
mDecItems.append(iw);
Expand Down Expand Up @@ -393,7 +393,7 @@ void DecoderConfigPage::updateDecodersUi()
void DecoderConfigPage::onConfigChanged()
{
sPriorityUi = idsFromNames(Config::instance().decoderPriorityNames());
sDecodersUi = QVector<VideoDecoderId>::fromStdVector(VideoDecoderFactory::registeredIds());
sDecodersUi = VideoDecoder::registered();
updateDecodersUi();
}

Expand Down
1 change: 1 addition & 0 deletions examples/videocapture/playerwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using namespace QtAV;

PlayerWindow::PlayerWindow(QWidget *parent) : QWidget(parent)
{
QtAV::Widgets::registerRenderers();
setWindowTitle(QString::fromLatin1("QtAV simple player example"));
m_player = new AVPlayer(this);
QVBoxLayout *vl = new QVBoxLayout();
Expand Down
2 changes: 1 addition & 1 deletion examples/videogroup/videogroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void VideoGroup::addRenderer()
v = VideoRendererId_GDI;
else if (vid == QLatin1String("xv"))
v = VideoRendererId_XV;
VideoRenderer* renderer = VideoRendererFactory::create(v);
VideoRenderer* renderer = VideoRenderer::create(v);
mRenderers = mpPlayer->videoOutputs();
mRenderers.append(renderer);
renderer->widget()->setAttribute(Qt::WA_DeleteOnClose);
Expand Down
2 changes: 1 addition & 1 deletion examples/videowall/VideoWall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void VideoWall::show()
v = VideoRendererId_XV;
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
VideoRenderer* renderer = VideoRendererFactory::create(v);
VideoRenderer* renderer = VideoRenderer::create(v);
renderer->widget()->setWindowFlags(renderer->widget()->windowFlags()| Qt::FramelessWindowHint);
renderer->widget()->setAttribute(Qt::WA_DeleteOnClose);
renderer->widget()->resize(w, h);
Expand Down
11 changes: 3 additions & 8 deletions qml/QQuickItemRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,17 @@
#include <QtQuick/QQuickWindow>
#include <QtQuick/QSGFlatColorMaterial>
#include <QtQuick/QSGSimpleTextureNode>
#include <QtAV/FactoryDefine.h>
#include <QtAV/AVPlayer.h>
#include <QtAV/OpenGLVideo.h>
#include <QtAV/VideoRendererTypes.h> //it declares a factory we need
#include "QtAV/private/mkid.h"
#include "QtAV/private/prepost.h"
#include "QtAV/private/factory.h"
#include "QtAV/private/VideoRenderer_p.h"
#include "QmlAV/QmlAVPlayer.h"
#include "QmlAV/SGVideoNode.h"

namespace QtAV
{
namespace QtAV {
static const VideoRendererId VideoRendererId_QQuickItem = mkid::id32base36_6<'Q','Q','I','t','e','m'>::value;

FACTORY_REGISTER_ID_AUTO(VideoRenderer, QQuickItem, "QQuickItem")

FACTORY_REGISTER(VideoRenderer, QQuickItem, "QQuickItem")

class QQuickItemRendererPrivate : public VideoRendererPrivate
{
Expand Down
15 changes: 7 additions & 8 deletions qml/QmlAVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,23 @@
#include <QtAV/AVPlayer.h>
#include <QtAV/AudioOutput.h>
#include <QtAV/VideoCapture.h>
#include <QDebug>

template<typename ID, typename Factory>
template<typename ID, typename T>
static QStringList idsToNames(QVector<ID> ids) {
QStringList decs;
foreach (ID id, ids) {
decs.append(QString::fromUtf8(Factory::name(id).c_str()));
decs.append(QString::fromLatin1(T::name(id)));
}
return decs;
}

template<typename ID, typename Factory>
template<typename ID, typename T>
static QVector<ID> idsFromNames(const QStringList& names) {
QVector<ID> decs;
foreach (const QString& name, names) {
if (name.isEmpty())
continue;
ID id = Factory::id(name.toStdString(), false);
ID id = T::id(name.toLatin1().constData());
if (id == 0)
continue;
decs.append(id);
Expand All @@ -49,11 +48,11 @@ static QVector<ID> idsFromNames(const QStringList& names) {
}

static inline QStringList VideoDecodersToNames(QVector<QtAV::VideoDecoderId> ids) {
return idsToNames<QtAV::VideoDecoderId, VideoDecoderFactory>(ids);
return idsToNames<QtAV::VideoDecoderId, VideoDecoder>(ids);
}

static inline QVector<VideoDecoderId> VideoDecodersFromNames(const QStringList& names) {
return idsFromNames<QtAV::VideoDecoderId, VideoDecoderFactory>(names);
return idsFromNames<QtAV::VideoDecoderId, VideoDecoder>(names);
}

QmlAVPlayer::QmlAVPlayer(QObject *parent) :
Expand Down Expand Up @@ -227,7 +226,7 @@ VideoCapture *QmlAVPlayer::videoCapture() const

QStringList QmlAVPlayer::videoCodecs() const
{
return VideoDecodersToNames(QtAV::GetRegistedVideoDecoderIds());
return VideoDecodersToNames(VideoDecoder::registered());
}

void QmlAVPlayer::setVideoCodecPriority(const QStringList &p)
Expand Down
5 changes: 2 additions & 3 deletions qml/QuickFBORenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
#include "QmlAV/QuickFBORenderer.h"
#include "QmlAV/QmlAVPlayer.h"
#include "QtAV/AVPlayer.h"
#include "QtAV/FactoryDefine.h"
#include "QtAV/OpenGLVideo.h"
#include "QtAV/private/VideoRenderer_p.h"
#include "QtAV/private/mkid.h"
#include "QtAV/private/prepost.h"
#include "QtAV/private/factory.h"
#include <QtCore/QCoreApplication>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtQuick/QQuickWindow>
Expand All @@ -40,7 +39,7 @@

namespace QtAV {
static const VideoRendererId VideoRendererId_QuickFBO = mkid::id32base36_4<'Q','F','B','O'>::value;
FACTORY_REGISTER_ID_AUTO(VideoRenderer, QuickFBO, "QuickFBO")
FACTORY_REGISTER(VideoRenderer, QuickFBO, "QuickFBO")

class FBORenderer : public QQuickFramebufferObject::Renderer
{
Expand Down
1 change: 0 additions & 1 deletion src/AVCompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
******************************************************************************/

#include "QtAV/private/AVCompat.h"
#include "QtAV/private/prepost.h"
#include "QtAV/version.h"

#ifndef av_err2str
Expand Down
2 changes: 1 addition & 1 deletion src/AVDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ bool AVDemuxer::setMedia(QIODevice* device)
}
}
if (!d->input)
d->input = MediaIO::create(QStringLiteral("QIODevice"));
d->input = MediaIO::create("QIODevice");
QIODevice* old_dev = d->input->property("device").value<QIODevice*>();
d->media_changed = old_dev != device;
if (d->media_changed) {
Expand Down
2 changes: 1 addition & 1 deletion src/AVMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ bool AVMuxer::setMedia(QIODevice* device)
}
}
if (!d->io)
d->io = MediaIO::create(QStringLiteral("QIODevice"));
d->io = MediaIO::create("QIODevice");
QIODevice* old_dev = d->io->property("device").value<QIODevice*>();
d->media_changed = old_dev != device;
if (d->media_changed) {
Expand Down
6 changes: 3 additions & 3 deletions src/AVPlayerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ bool AVPlayer::Private::tryApplyDecoderPriority(AVPlayer *player)
VideoDecoder *vd = NULL;
AVCodecContext *avctx = demuxer.videoCodecContext();
foreach(VideoDecoderId vid, vc_ids) {
qDebug("**********trying video decoder: %s...", VideoDecoderFactory::name(vid).c_str());
qDebug("**********trying video decoder: %s...", VideoDecoder::name(vid));
vd = VideoDecoder::create(vid);
if (!vd)
continue;
Expand Down Expand Up @@ -512,8 +512,8 @@ bool AVPlayer::Private::setupVideoThread(AVPlayer *player)
vdec = 0;
}
foreach(VideoDecoderId vid, vc_ids) {
qDebug("**********trying video decoder: %s...", VideoDecoderFactory::name(vid).c_str());
VideoDecoder *vd = VideoDecoderFactory::create(vid);
qDebug("**********trying video decoder: %s...", VideoDecoder::name(vid));
VideoDecoder *vd = VideoDecoder::create(vid);
if (!vd) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/AudioFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ AudioFrame AudioFrame::to(const AudioFormat &fmt) const
AudioResampler *conv = d->conv;
QScopedPointer<AudioResampler> c;
if (!conv) {
conv = AudioResamplerFactory::create(AudioResamplerId_FF);
conv = AudioResampler::create(AudioResamplerId_FF);
if (!conv)
conv = AudioResamplerFactory::create(AudioResamplerId_Libav);
conv = AudioResampler::create(AudioResamplerId_Libav);
if (!conv) {
qWarning("no audio resampler is available");
return AudioFrame();
Expand Down
2 changes: 1 addition & 1 deletion src/AudioResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include "QtAV/AudioFormat.h"
#include "QtAV/private/AudioResampler_p.h"
#include "QtAV/private/factory.h"
#include "utils/Logger.h"

namespace QtAV {

FACTORY_DEFINE(AudioResampler)

AudioResampler::AudioResampler()
Expand Down
18 changes: 5 additions & 13 deletions src/AudioResamplerTemplate.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand All @@ -23,7 +23,7 @@
#include "QtAV/AudioResampler.h"
#include "QtAV/private/AudioResampler_p.h"
#include "QtAV/private/AVCompat.h"
#include "QtAV/private/prepost.h"
#include "QtAV/private/factory.h"
#include "utils/Logger.h"

namespace QtAV {
Expand All @@ -32,7 +32,7 @@ namespace QtAV {
#define AudioResamplerFF AudioResamplerLibav
#define AudioResamplerFFPrivate AudioResamplerLibavPrivate
#define AudioResamplerId_FF AudioResamplerId_Libav
#define __create_AudioResamplerFF __create_AudioResamplerLibav
#define RegisterAudioResamplerFF_Man RegisterAudioResamplerLibav_Man
#define FF Libav
static const char kName[] = "Libav";
#else
Expand All @@ -49,15 +49,7 @@ class AudioResamplerFF : public AudioResampler
virtual bool prepare();
};
extern AudioResamplerId AudioResamplerId_FF;
namespace {
static const struct init {
static AudioResampler* __create_AudioResamplerFF() { return new AudioResamplerFF();}
inline init() {
AudioResamplerFactory::registerCreator(AudioResamplerId_FF, __create_AudioResamplerFF);
AudioResamplerFactory::registerIdName(AudioResamplerId_FF, kName);
}
} _init;
}
FACTORY_REGISTER(AudioResampler, FF, kName)

class AudioResamplerFFPrivate : public AudioResamplerPrivate
{
Expand All @@ -72,7 +64,7 @@ class AudioResamplerFFPrivate : public AudioResamplerPrivate
SwrContext *context;
// defined in swr<1
#ifndef SWR_CH_MAX
#define SWR_CH_MAX 63
#define SWR_CH_MAX 64
#endif
int channel_map[SWR_CH_MAX];
};
Expand Down
1 change: 1 addition & 0 deletions src/ImageConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "QtAV/private/AVCompat.h"
#include "QtAV/private/factory.h"
#include "ImageConverter.h"
#include "utils/Logger.h"

namespace QtAV {

Expand Down
Loading

0 comments on commit 8058ac5

Please sign in to comment.