PDA

View Full Version : Vlc browser plugin (npapi-vlc) does not load in Qt Webkit browser



fanoI
24th October 2018, 15:28
I'm having problem to make the browser load the vlc plugin I've an html page that has this code inside:


<OBJECT type="applications/x-vlc-plugin" classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"

codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,6,0"
width="640"
height="480"
id="vlc"
version="VideoLAN.VLCPlugin.2">
<param name="MRL" id="mrlid" value="rtsp://***********" />
<param name="ShowDisplay" value="True" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
<param name="Volume" value="50" />
<param name="StartTime" value="0" />
<EMBED pluginspage="http://www.videolan.org" type="application/x-vlc-plugin" progid="VideoLAN.VLCPlugin.2" width="640" height="480" name="vlce"></EMBED>
</OBJECT>


Instead of a movie I simply obtain a weird blue cube with '?' inside... no error, no debug anything...

I think to have enabled plugins in all possibles ways:

I've added in the QApplication ctor this code:



QWebSettings *settings = QWebSettings::globalSettings();
settings->setAttribute(QWebSettings::JavascriptEnabled, true);
settings->setAttribute(QWebSettings::PluginsEnabled, true);


I've done this in any QWebView that is created too...

Another thing I've tried is to force Qt to search plugins where npapi-vlc is installed doing in this way:



QCoreApplication::addLibraryPath("/usr/lib64/mozilla/plugins/");


and I continue to get a cube instead of a movie :mad::mad::mad:

What is the trick? There is some strange file to edit in some weird place to enable / disable some security that is blocking it?

The version of Qt I'm using is 5.6.1-3.

Please help me.

Thank you!

ChrisW67
30th October 2018, 10:33
I am not sure that it is reasonable to expect an ActiveX component, i.e. developed for Windows and very dependent on things like the registry, to work in a Linux/UNIX environment.

fanoI
14th November 2018, 11:12
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-webkit-simplewebplugin-example.html

The example works correctly so effectively the QtWebkit supports plugins but for some reasons it does not like VLC :mad:

This my simple html page:



<object type="video/mjpeg"
data="http://***/httppreview"
width="100%" height="400"></object>


my factory:



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::NetworkE rror)),
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;
}


My MediaplayerView:



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!");
}



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 :crying:

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))


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::onReadyRead(reply) in src/mediaPlayerFactory.cpp:25


Luckily I can "recover" Reply on the onReadyRead() simply doing:



QNetworkReply *reply = static_cast<QNetworkReply *>(sender());


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 :crying: