It is not an ActiveX component (?) it a normal plug in and it is Linux native code, web kit should use the NPAPI instead to show cubes
By the way I'm now trying to write my simple MediaPlayer starting from this example: http://doc.qt.io/archives/qt-4.8/qt-...n-example.html
The example works correctly so effectively the QtWebkit supports plugins but for some reasons it does not like VLC
This my simple html page:
<object type="video/mjpeg"
data="http://***/httppreview"
width="100%" height="400"></object>
<object type="video/mjpeg"
data="http://***/httppreview"
width="100%" height="400"></object>
To copy to clipboard, switch view to plain text mode
my factory:
mediaPlayerFactory
::mediaPlayerFactory(QObject *parent
) : QWebPluginFactory(parent)
{
manager = new QNetworkAccessManager(this);
};
{
if (mimeType != "video/mjpeg")
return 0;
//mediaPlayerView *view = new mediaPlayerView(argumentValues[argumentNames.indexOf("type")]);
mediaPlayerView *view = new mediaPlayerView(url);
QNetworkRequest request(url);
QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(readyRead()), view, SLOT(onReadyRead(reply)));
connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),
view,SLOT(onError(QNetworkReply::NetworkError)));
//connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
return view;
}
QList<QWebPluginFactory::Plugin> mediaPlayerFactory::plugins() const
{
QWebPluginFactory::MimeType mimeType;
mimeType.name = "video/mjpeg";
mimeType.description = "MediaPlayer";
QWebPluginFactory::Plugin plugin;
plugin.name = "MediaPlayer";
plugin.description = "A MediaPlayer Web plugin.";
plugin.mimeTypes = QList<MimeType>() << mimeType;
return QList<QWebPluginFactory::Plugin>() << plugin;
}
mediaPlayerFactory::mediaPlayerFactory(QObject *parent)
: QWebPluginFactory(parent)
{
manager = new QNetworkAccessManager(this);
};
QObject *mediaPlayerFactory::create(const QString &mimeType, const QUrl &url,
const QStringList &argumentNames,
const QStringList &argumentValues) const
{
if (mimeType != "video/mjpeg")
return 0;
//mediaPlayerView *view = new mediaPlayerView(argumentValues[argumentNames.indexOf("type")]);
mediaPlayerView *view = new mediaPlayerView(url);
QNetworkRequest request(url);
QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(readyRead()), view, SLOT(onReadyRead(reply)));
connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),
view,SLOT(onError(QNetworkReply::NetworkError)));
//connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
return view;
}
QList<QWebPluginFactory::Plugin> mediaPlayerFactory::plugins() const
{
QWebPluginFactory::MimeType mimeType;
mimeType.name = "video/mjpeg";
mimeType.description = "MediaPlayer";
mimeType.fileExtensions = QStringList() << "mjpeg";
QWebPluginFactory::Plugin plugin;
plugin.name = "MediaPlayer";
plugin.description = "A MediaPlayer Web plugin.";
plugin.mimeTypes = QList<MimeType>() << mimeType;
return QList<QWebPluginFactory::Plugin>() << plugin;
}
To copy to clipboard, switch view to plain text mode
My MediaplayerView:
mediaPlayerView
::mediaPlayerView(const QUrl &url,
QWidget *parent
){
this->url = url;
Log("Getting MJPEG stream from url: " + url.toString());
label->setWindowFlags(label->windowFlags() | Qt::FramelessWindowHint);
label->show();
Log("Ready to stream!");
}
mediaPlayerView::mediaPlayerView(const QUrl &url, QWidget *parent)
: QWidget(parent)
{
this->url = url;
Log("Getting MJPEG stream from url: " + url.toString());
label = new QLabel(this);
label->setWindowFlags(label->windowFlags() | Qt::FramelessWindowHint);
label->show();
Log("Ready to stream!");
}
To copy to clipboard, switch view to plain text mode
and I'm dead already! I never get the readyRead() signal!
The thing that I do not understand is why it is working correctly in a normal standalone application?
Inside onReadyRead() I process the image and display it in the Label 'label' I think it is not relevant as it is never called
Any ideas?
The ctor of mediaPlayerView is called the connections seem estabilished too:
ss -nap | grep 7171
ESTAB 0 0 ***:43506 ***:80 users:(("****",7171,23))
ss -nap | grep 7171
ESTAB 0 0 ***:43506 ***:80 users:(("****",7171,23))
To copy to clipboard, switch view to plain text mode
The camera shows the stream if you connect to its port 80, all very simple for me...
Added after 39 minutes:
I've found the problem!
I've forgotten that Qt makes in some way C++ a dynamic language in the sense that the program can now fails at runtime too.
The error was in the readyRead() connect it seems Qt does not like that the slot has a different prototype... readyRead() has no arguments but onReadyRead() wanted a QtNetworkReply * as argument... all compiled perfectly but an error was written on stderr:
QObject::connect: No such slot mediaPlayerView:
nReadyRead(reply) in src/mediaPlayerFactory.cpp:25
Luckily I can "recover" Reply on the onReadyRead() simply doing:
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
To copy to clipboard, switch view to plain text mode
It is working now but I've not understood how all the memory allocated with "new" is freed... I fear my next problem will be memory leak
Bookmarks