summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>2010-03-15 04:54:25 (GMT)
committerDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>2010-03-15 04:54:25 (GMT)
commit4d4ed81c6df7954d89dad554267cba8d3cfd6bde (patch)
treef125ef0e8cccd286950c6cdda011ce8a5e7b1fca /src/plugins
parent751a45bc22aa1f27a5dab3ce18e83c0f699ee05f (diff)
parentcffc92bac940fd7fcae0a9ff82a54a124d70ebed (diff)
downloadQt-4d4ed81c6df7954d89dad554267cba8d3cfd6bde.zip
Qt-4d4ed81c6df7954d89dad554267cba8d3cfd6bde.tar.gz
Qt-4d4ed81c6df7954d89dad554267cba8d3cfd6bde.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.7
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/bearer.pro2
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.h5
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm163
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp14
-rw-r--r--src/plugins/bearer/generic/qgenericengine.h3
-rw-r--r--src/plugins/bearer/icd/qicdengine.cpp23
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.cpp13
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.cpp98
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.h4
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp8
-rw-r--r--src/plugins/bearer/nla/qnlaengine.cpp56
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp56
-rw-r--r--src/plugins/bearer/qnetworksession_impl.h9
-rw-r--r--src/plugins/codecs/cn/qgb18030codec.cpp59
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp33
-rw-r--r--src/plugins/mediaservices/directshow/directshow.pro2
-rw-r--r--src/plugins/mediaservices/gstreamer/gstreamer.pro2
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp191
-rw-r--r--src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h13
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp52
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h1
-rw-r--r--src/plugins/mediaservices/qt7/qt7.pro2
22 files changed, 546 insertions, 263 deletions
diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro
index 7ba62b3..a67c8f6 100644
--- a/src/plugins/bearer/bearer.pro
+++ b/src/plugins/bearer/bearer.pro
@@ -6,7 +6,7 @@ TEMPLATE = subdirs
#win32:SUBDIRS += nla
win32:SUBDIRS += generic
win32:!wince*:SUBDIRS += nativewifi
-macx:SUBDIRS += corewlan
+macx:contains(QT_CONFIG, corewlan):SUBDIRS += corewlan
macx:SUBDIRS += generic
symbian:SUBDIRS += symbian
maemo6:contains(QT_CONFIG, dbus):SUBDIRS += icd
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h
index cfd89e4..cbaa9d6 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.h
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.h
@@ -78,7 +78,9 @@ public:
QNetworkConfigurationPrivatePointer defaultConfiguration();
- bool getAllScInterfaces();
+ bool getWifiInterfaces();
+
+ bool requiresPolling() const;
private Q_SLOTS:
void doRequestUpdate();
@@ -86,7 +88,6 @@ private Q_SLOTS:
private:
bool isWifiReady(const QString &dev);
QMap<QString, QString> configurationInterface;
- QTimer pollTimer;
QStringList scanForSsids(const QString &interfaceName);
bool isKnownSsid(const QString &interfaceName, const QString &ssid);
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 2d33d36..cb278d9 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -61,44 +61,78 @@
#include <Foundation/NSEnumerator.h>
#include <Foundation/NSKeyValueObserving.h>
#include <Foundation/NSAutoreleasePool.h>
+#include <Foundation/NSLock.h>
#include <SystemConfiguration/SCNetworkConfiguration.h>
+#include <private/qt_cocoa_helpers_mac_p.h>
+#include "private/qcore_mac_p.h"
+
QMap <QString, QString> networkInterfaces;
-QT_BEGIN_NAMESPACE
+#ifdef MAC_SDK_10_6
+@interface QNSListener : NSObject
+{
+ NSNotificationCenter *center;
+ CWInterface *currentInterface;
+ QCoreWlanEngine *engine;
+ NSAutoreleasePool *autoreleasepool;
+ NSLock *locker;
+}
+- (void)notificationHandler:(NSNotification *)notification;
+- (void)remove;
+- (void)setEngine:(QCoreWlanEngine *)coreEngine;
+- (void)dealloc;
-inline QString cfstringRefToQstring(CFStringRef cfStringRef) {
-// return QString([cfStringRef UTF8String]);
- QString retVal;
- CFIndex maxLength = 2 * CFStringGetLength(cfStringRef) + 1/*zero term*/; // max UTF8
- char *cstring = new char[maxLength];
- if (CFStringGetCString(CFStringRef(cfStringRef), cstring, maxLength, kCFStringEncodingUTF8)) {
- retVal = QString::fromUtf8(cstring);
- }
- delete[] cstring;
- return retVal;
+@property (assign) QCoreWlanEngine* engine;
+
+@end
+
+@implementation QNSListener
+- (id) init
+{
+ [locker lock];
+ autoreleasepool = [[NSAutoreleasePool alloc] init];
+ center = [NSNotificationCenter defaultCenter];
+ currentInterface = [CWInterface interface];
+// [center addObserver:self selector:@selector(notificationHandler:) name:kCWLinkDidChangeNotification object:nil];
+ [center addObserver:self selector:@selector(notificationHandler:) name:kCWPowerDidChangeNotification object:nil];
+ [locker unlock];
+ return self;
}
-inline CFStringRef qstringToCFStringRef(const QString &string)
+-(void)dealloc
{
- return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(string.unicode()),
- string.length());
+ [autoreleasepool release];
+ [super dealloc];
}
-inline NSString *qstringToNSString(const QString &qstr)
-{ return [reinterpret_cast<const NSString *>(qstringToCFStringRef(qstr)) autorelease]; }
+-(void)setEngine:(QCoreWlanEngine *)coreEngine
+{
+ [locker lock];
+ if(!engine)
+ engine = coreEngine;
+ [locker unlock];
+}
-inline QString nsstringToQString(const NSString *nsstr)
-{ return cfstringRefToQstring(reinterpret_cast<const CFStringRef>(nsstr)); }
+-(void)remove
+{
+ [locker lock];
+ [center removeObserver:self];
+ [locker unlock];
+}
-inline QStringList nsarrayToQStringList(void *nsarray)
+- (void)notificationHandler:(NSNotification *)notification
{
- QStringList result;
- NSArray *array = static_cast<NSArray *>(nsarray);
- for (NSUInteger i=0; i<[array count]; ++i)
- result << nsstringToQString([array objectAtIndex:i]);
- return result;
+ engine->requestUpdate();
}
+@end
+
+QNSListener *listener = 0;
+
+#endif
+
+QT_BEGIN_NAMESPACE
+
static QString qGetInterfaceType(const QString &interfaceString)
{
@@ -109,8 +143,8 @@ void networkChangeCallback(SCDynamicStoreRef/* store*/, CFArrayRef changedKeys,
{
for ( long i = 0; i < CFArrayGetCount(changedKeys); i++) {
- CFStringRef changed = (CFStringRef)CFArrayGetValueAtIndex(changedKeys, i);
- if( cfstringRefToQstring(changed).contains("/Network/Global/IPv4")) {
+ QString changed = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(changedKeys, i));
+ if( changed.contains("/Network/Global/IPv4")) {
QCoreWlanEngine* wlanEngine = static_cast<QCoreWlanEngine*>(info);
wlanEngine->requestUpdate();
}
@@ -122,12 +156,23 @@ QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
: QBearerEngineImpl(parent)
{
startNetworkChangeLoop();
+
+#if defined(MAC_SDK_10_6)
+ if(!listener) {
+ listener = [[QNSListener alloc] init];
+ listener.engine = this;
+ }
+#endif
}
QCoreWlanEngine::~QCoreWlanEngine()
{
while (!foundConfigurations.isEmpty())
delete foundConfigurations.takeFirst();
+#if defined(MAC_SDK_10_6)
+ [listener remove];
+ [listener release];
+#endif
}
QString QCoreWlanEngine::getInterfaceFromId(const QString &id)
@@ -153,7 +198,7 @@ void QCoreWlanEngine::connectToId(const QString &id)
if(networkInterfaces.value(interfaceString) == "WLAN") {
#if defined(MAC_SDK_10_6)
- CWInterface *wifiInterface = [CWInterface interfaceWithName: qstringToNSString(interfaceString)];
+ CWInterface *wifiInterface = [CWInterface interfaceWithName: qt_mac_QStringToNSString(interfaceString)];
CWConfiguration *userConfig = [ wifiInterface configuration];
NSSet *remNets = [userConfig rememberedNetworks]; //CWWirelessProfile
@@ -170,7 +215,7 @@ void QCoreWlanEngine::connectToId(const QString &id)
while ((wProfile = [enumerator nextObject])) { //CWWirelessProfile
- if(id == QString::number(qHash(QLatin1String("corewlan:") + nsstringToQString([wProfile ssid])))) {
+ if(id == QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString([wProfile ssid])))) {
user8021XProfile = nil;
user8021XProfile = [ wProfile user8021XProfile];
@@ -224,7 +269,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
if(networkInterfaces.value(getInterfaceFromId(id)) == "WLAN") { //wifi only for now
#if defined(MAC_SDK_10_6)
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- CWInterface *wifiInterface = [CWInterface interfaceWithName: qstringToNSString(interfaceString)];
+ CWInterface *wifiInterface = [CWInterface interfaceWithName: qt_mac_QStringToNSString(interfaceString)];
[wifiInterface disassociate];
if([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
emit connectionError(id, DisconnectionError);
@@ -242,15 +287,14 @@ void QCoreWlanEngine::requestUpdate()
{
QMutexLocker locker(&mutex);
- pollTimer.stop();
- QTimer::singleShot(0, this, SLOT(doRequestUpdate()));
+ doRequestUpdate();
}
void QCoreWlanEngine::doRequestUpdate()
{
QMutexLocker locker(&mutex);
- getAllScInterfaces();
+ getWifiInterfaces();
QStringList previous = accessPointConfigurations.keys();
@@ -328,8 +372,6 @@ void QCoreWlanEngine::doRequestUpdate()
emit configurationRemoved(ptr);
}
- pollTimer.start();
-
emit updateCompleted();
}
@@ -340,9 +382,9 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
QStringList found;
#if defined(MAC_SDK_10_6)
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacCocoaAutoReleasePool pool;
- CWInterface *currentInterface = [CWInterface interfaceWithName:qstringToNSString(interfaceName)];
+ CWInterface *currentInterface = [CWInterface interfaceWithName:qt_mac_QStringToNSString(interfaceName)];
if([currentInterface power]) {
NSError *err = nil;
NSDictionary *parametersDict = nil;
@@ -351,11 +393,10 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
CWNetwork *apNetwork;
if (!err) {
for(uint row=0; row < [apArray count]; row++ ) {
- NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init];
apNetwork = [apArray objectAtIndex:row];
- const QString networkSsid = nsstringToQString([apNetwork ssid]);
+ const QString networkSsid = qt_mac_NSStringToQString([apNetwork ssid]);
const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
found.append(id);
@@ -363,7 +404,7 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
if ([currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
- if (networkSsid == nsstringToQString([currentInterface ssid]))
+ if (networkSsid == qt_mac_NSStringToQString([currentInterface ssid]))
state = QNetworkConfiguration::Active;
} else {
if (isKnownSsid(interfaceName, networkSsid))
@@ -414,11 +455,9 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
emit configurationAdded(ptr);
}
- [looppool release];
}
}
}
- [autoreleasepool drain];
#else
Q_UNUSED(interfaceName);
#endif
@@ -430,7 +469,7 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
QMutexLocker locker(&mutex);
#if defined(MAC_SDK_10_6)
- CWInterface *defaultInterface = [CWInterface interfaceWithName: qstringToNSString(wifiDeviceName)];
+ CWInterface *defaultInterface = [CWInterface interfaceWithName: qt_mac_QStringToNSString(wifiDeviceName)];
if([defaultInterface power])
return true;
#else
@@ -444,11 +483,11 @@ bool QCoreWlanEngine::isKnownSsid(const QString &interfaceName, const QString &s
QMutexLocker locker(&mutex);
#if defined(MAC_SDK_10_6)
- CWInterface *wifiInterface = [CWInterface interfaceWithName: qstringToNSString(interfaceName)];
+ CWInterface *wifiInterface = [CWInterface interfaceWithName: qt_mac_QStringToNSString(interfaceName)];
CWConfiguration *userConfig = [wifiInterface configuration];
NSSet *remNets = [userConfig rememberedNetworks];
for (CWWirelessProfile *wProfile in remNets) {
- if(ssid == nsstringToQString([wProfile ssid]))
+ if(ssid == qt_mac_NSStringToQString([wProfile ssid]))
return true;
}
#else
@@ -458,39 +497,18 @@ bool QCoreWlanEngine::isKnownSsid(const QString &interfaceName, const QString &s
return false;
}
-bool QCoreWlanEngine::getAllScInterfaces()
+bool QCoreWlanEngine::getWifiInterfaces()
{
QMutexLocker locker(&mutex);
networkInterfaces.clear();
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QMacCocoaAutoReleasePool pool;
- CFArrayRef interfaces = SCNetworkInterfaceCopyAll();
- if (interfaces != NULL) {
- CFIndex interfaceCount;
- CFIndex interfaceIndex;
- interfaceCount = CFArrayGetCount(interfaces);
- for (interfaceIndex = 0; interfaceIndex < interfaceCount; interfaceIndex++) {
- NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init];
-
- CFStringRef bsdName;
- CFTypeRef thisInterface = CFArrayGetValueAtIndex(interfaces, interfaceIndex);
- bsdName = SCNetworkInterfaceGetBSDName((SCNetworkInterfaceRef)thisInterface);
- QString interfaceName = cfstringRefToQstring(bsdName);
- QString typeStr;
- CFStringRef type = SCNetworkInterfaceGetInterfaceType((SCNetworkInterfaceRef)thisInterface);
- if ( CFEqual(type, kSCNetworkInterfaceTypeIEEE80211)) {
- typeStr = "WLAN";
- }
- if(!networkInterfaces.contains(interfaceName) && !typeStr.isEmpty()) {
- networkInterfaces.insert(interfaceName,typeStr);
- }
- [looppool release];
- }
+ NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
+ for(uint row=0; row < [wifiInterfaces count]; row++ ) {
+ networkInterfaces.insert( qt_mac_NSStringToQString([wifiInterfaces objectAtIndex:row]),"WLAN");
}
- CFRelease(interfaces);
- [autoreleasepool drain];
return true;
}
@@ -589,4 +607,9 @@ QNetworkConfigurationPrivatePointer QCoreWlanEngine::defaultConfiguration()
return QNetworkConfigurationPrivatePointer();
}
+bool QCoreWlanEngine::requiresPolling() const
+{
+ return true;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index e6c871d..a9e78b2 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -142,9 +142,6 @@ static QString qGetInterfaceType(const QString &interface)
QGenericEngine::QGenericEngine(QObject *parent)
: QBearerEngineImpl(parent)
{
- connect(&pollTimer, SIGNAL(timeout()), this, SLOT(doRequestUpdate()));
- pollTimer.setInterval(10000);
- doRequestUpdate();
}
QGenericEngine::~QGenericEngine()
@@ -179,8 +176,7 @@ void QGenericEngine::requestUpdate()
{
QMutexLocker locker(&mutex);
- pollTimer.stop();
- QTimer::singleShot(0, this, SLOT(doRequestUpdate()));
+ doRequestUpdate();
}
void QGenericEngine::doRequestUpdate()
@@ -282,8 +278,6 @@ void QGenericEngine::doRequestUpdate()
emit configurationRemoved(ptr);
}
- pollTimer.start();
-
emit updateCompleted();
}
@@ -328,5 +322,11 @@ QNetworkConfigurationPrivatePointer QGenericEngine::defaultConfiguration()
return QNetworkConfigurationPrivatePointer();
}
+
+bool QGenericEngine::requiresPolling() const
+{
+ return true;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h
index cd9a976..a1b9167 100644
--- a/src/plugins/bearer/generic/qgenericengine.h
+++ b/src/plugins/bearer/generic/qgenericengine.h
@@ -78,12 +78,13 @@ public:
QNetworkConfigurationPrivatePointer defaultConfiguration();
+ bool requiresPolling() const;
+
private Q_SLOTS:
void doRequestUpdate();
private:
QMap<QString, QString> configurationInterface;
- QTimer pollTimer;
};
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp
index 206a6fd..5e506ef 100644
--- a/src/plugins/bearer/icd/qicdengine.cpp
+++ b/src/plugins/bearer/icd/qicdengine.cpp
@@ -206,14 +206,11 @@ void QIcdEngine::doRequestUpdate()
QString iap_type = saved_ap.value("type").toString();
if (iap_type.startsWith("WLAN")) {
ssid = saved_ap.value("wlan_ssid").toByteArray();
- if (ssid.isEmpty()) {
- qWarning() << "Cannot get ssid for" << iap_id;
+ if (ssid.isEmpty())
continue;
- }
QString security_method = saved_ap.value("wlan_security").toString();
} else if (iap_type.isEmpty()) {
- qWarning() << "IAP" << iap_id << "network type is not set! Skipping it";
continue;
} else {
#ifdef BEARER_MANAGEMENT_DEBUG
@@ -270,7 +267,9 @@ void QIcdEngine::doRequestUpdate()
scanned,
error);
if (!error.isEmpty()) {
- qWarning() << "Network scanning failed" << error;
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug() << "Network scanning failed" << error;
+#endif
} else {
#ifdef BEARER_MANAGEMENT_DEBUG
if (!scanned.isEmpty())
@@ -379,19 +378,13 @@ void QIcdEngine::deleteConfiguration(const QString &iap_id)
* or read all the IAPs from db because it might take too much power
* (multiple applications would need to scan and read all IAPs from db)
*/
- if (accessPointConfigurations.contains(iap_id)) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(iap_id);
-
- if (ptr) {
- ptr->isValid = false;
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(iap_id);
+ if (ptr) {
#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "IAP" << iap_id << "was removed from storage.";
+ qDebug() << "IAP" << iap_id << "was removed from storage.";
#endif
- emit configurationRemoved(ptr);
- } else {
- qWarning("Configuration not found for IAP %s", iap_id.toAscii().data());
- }
+ emit configurationRemoved(ptr);
} else {
#ifdef BEARER_MANAGEMENT_DEBUG
qDebug("IAP: %s, already missing from the known list", iap_id.toAscii().data());
diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp
index 03624fa..bb81408 100644
--- a/src/plugins/bearer/icd/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp
@@ -140,7 +140,9 @@ static DBusHandlerResult signal_handler(DBusConnection *,
DBUS_TYPE_STRING, &network_type,
DBUS_TYPE_STRING, &state,
DBUS_TYPE_INVALID) == FALSE) {
- qWarning() << QString("Failed to parse icd status signal: %1").arg(error.message);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug() << QString("Failed to parse icd status signal: %1").arg(error.message);
+#endif
} else {
QString _iap_id(iap_id);
QString _network_type(network_type);
@@ -166,7 +168,6 @@ void IcdListener::setup(QNetworkSessionPrivateImpl *d)
dbus_connection = get_dbus_conn(&error);
if (dbus_error_is_set(&error)) {
- qWarning() << "Cannot get dbus connection.";
dbus_error_free(&error);
return;
}
@@ -176,7 +177,6 @@ void IcdListener::setup(QNetworkSessionPrivateImpl *d)
dbus_bus_add_match(dbus_connection, ICD_DBUS_MATCH, &error);
if (dbus_error_is_set(&error)) {
- qWarning() << "Cannot add match" << ICD_DBUS_MATCH;
dbus_error_free(&error);
return;
}
@@ -185,7 +185,6 @@ void IcdListener::setup(QNetworkSessionPrivateImpl *d)
ICD_DBUS_PATH,
&icd_vtable,
(void*)this) == FALSE) {
- qWarning() << "Cannot register dbus signal handler, interface"<< ICD_DBUS_INTERFACE << "path" << ICD_DBUS_PATH;
dbus_error_free(&error);
return;
}
@@ -340,8 +339,6 @@ void QNetworkSessionPrivateImpl::updateIdentifier(QString &newId)
} else {
toIcdConfig(privateConfiguration(publicConfig))->network_attrs |= ICD_NW_ATTR_IAPNAME;
if (privateConfiguration(publicConfig)->id != newId) {
- qWarning() << "Your config id changed from" << privateConfiguration(publicConfig)->id
- << "to" << newId;
privateConfiguration(publicConfig)->id = newId;
}
}
@@ -1015,25 +1012,21 @@ void QNetworkSessionPrivateImpl::stop()
void QNetworkSessionPrivateImpl::migrate()
{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
}
void QNetworkSessionPrivateImpl::accept()
{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
}
void QNetworkSessionPrivateImpl::ignore()
{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
}
void QNetworkSessionPrivateImpl::reject()
{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
}
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
index c8015d8..b6522ad 100644
--- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
+++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
@@ -83,8 +83,10 @@ QNativeWifiEngine::QNativeWifiEngine(QObject *parent)
DWORD result = local_WlanOpenHandle(1, 0, &clientVersion, &handle);
if (result != ERROR_SUCCESS) {
+#ifdef BEARER_MANAGEMENT_DEBUG
if (result != ERROR_SERVICE_NOT_ACTIVE)
- qWarning("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result);
+ qDebug("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result);
+#endif
return;
}
@@ -92,13 +94,11 @@ QNativeWifiEngine::QNativeWifiEngine(QObject *parent)
result = local_WlanRegisterNotification(handle, WLAN_NOTIFICATION_SOURCE_ALL, true,
WLAN_NOTIFICATION_CALLBACK(qNotificationCallback),
this, 0, 0);
+#ifdef BEARER_MANAGEMENT_DEBUG
if (result != ERROR_SUCCESS)
- qWarning("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result);
+ qDebug("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result);
+#endif
- // On Windows XP SP2 and SP3 only connection and disconnection notifications are available.
- // We need to poll for changes in available wireless networks.
- connect(&pollTimer, SIGNAL(timeout()), this, SLOT(scanComplete()));
- pollTimer.setInterval(10000);
scanComplete();
}
@@ -111,16 +111,22 @@ void QNativeWifiEngine::scanComplete()
{
QMutexLocker locker(&mutex);
- QStringList previous = accessPointConfigurations.keys();
-
// enumerate interfaces
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
+
+ locker.unlock();
+ emit updateCompleted();
+
return;
}
+ QStringList previous = accessPointConfigurations.keys();
+
for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
@@ -128,8 +134,10 @@ void QNativeWifiEngine::scanComplete()
result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
3, 0, &networkList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
+ __FUNCTION__, result);
+#endif
continue;
}
@@ -222,8 +230,6 @@ void QNativeWifiEngine::scanComplete()
emit configurationRemoved(ptr);
}
- pollTimer.start();
-
emit updateCompleted();
}
@@ -235,7 +241,9 @@ QString QNativeWifiEngine::getInterfaceFromId(const QString &id)
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
return QString();
}
@@ -248,8 +256,10 @@ QString QNativeWifiEngine::getInterfaceFromId(const QString &id)
wlan_intf_opcode_current_connection, 0, &dataSize,
reinterpret_cast<PVOID *>(&connectionAttributes), 0);
if (result != ERROR_SUCCESS) {
+#ifdef BEARER_MANAGEMENT_DEBUG
if (result != ERROR_INVALID_STATE)
- qWarning("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result);
+ qDebug("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result);
+#endif
continue;
}
@@ -286,7 +296,9 @@ bool QNativeWifiEngine::hasIdentifier(const QString &id)
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
return false;
}
@@ -297,8 +309,10 @@ bool QNativeWifiEngine::hasIdentifier(const QString &id)
result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
3, 0, &networkList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
+ __FUNCTION__, result);
+#endif
continue;
}
@@ -341,7 +355,9 @@ void QNativeWifiEngine::connectToId(const QString &id)
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
emit connectionError(id, InterfaceLookupError);
return;
}
@@ -355,8 +371,10 @@ void QNativeWifiEngine::connectToId(const QString &id)
result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
3, 0, &networkList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
+ __FUNCTION__, result);
+#endif
continue;
}
@@ -384,7 +402,9 @@ void QNativeWifiEngine::connectToId(const QString &id)
DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, &parameters, 0);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result);
+#endif
emit connectionError(id, ConnectError);
break;
}
@@ -423,7 +443,9 @@ void QNativeWifiEngine::disconnectFromId(const QString &id)
DWORD result = local_WlanDisconnect(handle, &guid, 0);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result);
+#endif
emit connectionError(id, DisconnectionError);
return;
}
@@ -437,17 +459,34 @@ void QNativeWifiEngine::requestUpdate()
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
+
+ locker.unlock();
+ emit updateCompleted();
+
return;
}
+ bool requested = false;
for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
result = local_WlanScan(handle, &interfaceList->InterfaceInfo[i].InterfaceGuid, 0, 0, 0);
- if (result != ERROR_SUCCESS)
- qWarning("%s: WlanScan failed with error %ld\n", __FUNCTION__, result);
+ if (result != ERROR_SUCCESS) {
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanScan failed with error %ld\n", __FUNCTION__, result);
+#endif
+ } else {
+ requested = true;
+ }
}
local_WlanFreeMemory(interfaceList);
+
+ if (!requested) {
+ locker.unlock();
+ emit updateCompleted();
+ }
}
QNetworkSession::State QNativeWifiEngine::sessionStateForId(const QString &id)
@@ -492,4 +531,11 @@ QNetworkConfigurationPrivatePointer QNativeWifiEngine::defaultConfiguration()
return QNetworkConfigurationPrivatePointer();
}
+bool QNativeWifiEngine::requiresPolling() const
+{
+ // On Windows XP SP2 and SP3 only connection and disconnection notifications are available.
+ // We need to poll for changes in available wireless networks.
+ return true;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h
index a9a9375..56489b6 100644
--- a/src/plugins/bearer/nativewifi/qnativewifiengine.h
+++ b/src/plugins/bearer/nativewifi/qnativewifiengine.h
@@ -90,12 +90,12 @@ public:
inline bool available() const { return handle != 0; }
+ bool requiresPolling() const;
+
public Q_SLOTS:
void scanComplete();
private:
- QTimer pollTimer;
-
Qt::HANDLE handle;
};
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
index c780fbc..d23bb0d 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
@@ -199,7 +199,6 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q
dbusConnection);
if (!d->connectionInterface->isValid()) {
d->valid = false;
- qWarning() << "Could not find InterfaceAccessPoint";
return;
}
d->valid = true;
@@ -308,7 +307,6 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de
dbusConnection);
if (!d->connectionInterface->isValid()) {
d->valid = false;
- qWarning() << "Could not find NetworkManagerInterfaceDevice";
return;
}
d->valid = true;
@@ -400,7 +398,6 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
- qWarning() << "Could not find InterfaceDeviceWired";
return;
}
d->valid = true;
@@ -478,7 +475,6 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
- qWarning() << "Could not find InterfaceDeviceWireless";
return;
}
d->valid = true;
@@ -596,7 +592,6 @@ QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService,
dbusConnection);
if (!d->connectionInterface->isValid()) {
d->valid = false;
- //qWarning() << "Could not find NetworkManagerSettings";
return;
}
d->valid = true;
@@ -660,7 +655,6 @@ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QStri
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
- //qWarning() << "Could not find NetworkManagerSettingsConnection";
d->valid = false;
return;
}
@@ -883,7 +877,6 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
- //qWarning() << "Could not find NetworkManagerSettingsConnection";
return;
}
d->valid = true;
@@ -978,7 +971,6 @@ QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectP
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
- //qWarning() << "Could not find NetworkManagerIp4Config";
return;
}
d->valid = true;
diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp
index ff334e5..334eb14 100644
--- a/src/plugins/bearer/nla/qnlaengine.cpp
+++ b/src/plugins/bearer/nla/qnlaengine.cpp
@@ -228,8 +228,11 @@ QNlaThread::~QNlaThread()
if (handle) {
/* cancel completion event */
- if (WSALookupServiceEnd(handle) == SOCKET_ERROR)
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
+ if (WSALookupServiceEnd(handle) == SOCKET_ERROR) {
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("WSALookupServiceEnd error %d", WSAGetLastError());
+#endif
+ }
}
mutex.unlock();
@@ -252,8 +255,11 @@ void QNlaThread::forceUpdate()
if (handle) {
/* cancel completion event */
- if (WSALookupServiceEnd(handle) == SOCKET_ERROR)
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
+ if (WSALookupServiceEnd(handle) == SOCKET_ERROR) {
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("WSALookupServiceEnd error %d", WSAGetLastError());
+#endif
+ }
handle = 0;
}
mutex.unlock();
@@ -262,10 +268,8 @@ void QNlaThread::forceUpdate()
void QNlaThread::run()
{
WSAEVENT changeEvent = WSACreateEvent();
- if (changeEvent == WSA_INVALID_EVENT) {
- qWarning("WSACreateEvent error %d", WSAGetLastError());
+ if (changeEvent == WSA_INVALID_EVENT)
return;
- }
while (true) {
fetchConfigurations();
@@ -284,10 +288,8 @@ void QNlaThread::run()
int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL, &handle);
mutex.unlock();
- if (result == SOCKET_ERROR) {
- qWarning("%s: WSALookupServiceBegin error %d", __FUNCTION__, WSAGetLastError());
+ if (result == SOCKET_ERROR)
break;
- }
WSACOMPLETION completion;
WSAOVERLAPPED overlapped;
@@ -303,11 +305,8 @@ void QNlaThread::run()
result = WSANSPIoctl(handle, SIO_NSP_NOTIFY_CHANGE, 0, 0, 0, 0,
&bytesReturned, &completion);
if (result == SOCKET_ERROR) {
- int error = WSAGetLastError();
- if (error != WSA_IO_PENDING) {
- qWarning("WSANSPIoctl error %d", error);
+ if (WSAGetLastError() != WSA_IO_PENDING)
break;
- }
}
#ifndef Q_OS_WINCE
@@ -325,7 +324,6 @@ void QNlaThread::run()
if (handle) {
result = WSALookupServiceEnd(handle);
if (result == SOCKET_ERROR) {
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
mutex.unlock();
break;
}
@@ -360,7 +358,7 @@ DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv
switch (blob->header.type) {
case NLA_RAW_DATA:
#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_RAW_DATA", __FUNCTION__);
+ qDebug("%s: unhandled header type NLA_RAW_DATA", __FUNCTION__);
#endif
break;
case NLA_INTERFACE:
@@ -372,7 +370,7 @@ DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv
break;
case NLA_802_1X_LOCATION:
#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_802_1X_LOCATION", __FUNCTION__);
+ qDebug("%s: unhandled header type NLA_802_1X_LOCATION", __FUNCTION__);
#endif
break;
case NLA_CONNECTIVITY:
@@ -380,18 +378,15 @@ DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv
cpPriv->internet = true;
else
cpPriv->internet = false;
-#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_CONNECTIVITY", __FUNCTION__);
-#endif
break;
case NLA_ICS:
#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_ICS", __FUNCTION__);
+ qDebug("%s: unhandled header type NLA_ICS", __FUNCTION__);
#endif
break;
default:
#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type %d", __FUNCTION__, blob->header.type);
+ qDebug("%s: unhandled header type %d", __FUNCTION__, blob->header.type);
#endif
;
}
@@ -462,7 +457,6 @@ void QNlaThread::fetchConfigurations()
int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL | LUP_DEEP, &hLookup);
if (result == SOCKET_ERROR) {
- qWarning("%s: WSALookupServiceBegin error %d", __FUNCTION__, WSAGetLastError());
mutex.lock();
fetchedConfigurations.clear();
mutex.unlock();
@@ -474,18 +468,8 @@ void QNlaThread::fetchConfigurations()
result = WSALookupServiceNext(hLookup, LUP_RETURN_ALL,
&bufferLength, reinterpret_cast<WSAQUERYSET *>(buffer));
- if (result == SOCKET_ERROR) {
- int error = WSAGetLastError();
-
- if (error == WSA_E_NO_MORE)
- break;
-
- if (error == WSAEFAULT)
- break;
-
- qWarning("WSALookupServiceNext error %d", WSAGetLastError());
+ if (result == SOCKET_ERROR)
break;
- }
QNetworkConfigurationPrivate *cpPriv =
parseQuerySet(reinterpret_cast<WSAQUERYSET *>(buffer));
@@ -496,7 +480,9 @@ void QNlaThread::fetchConfigurations()
if (hLookup) {
result = WSALookupServiceEnd(hLookup);
if (result == SOCKET_ERROR) {
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("WSALookupServiceEnd error %d", WSAGetLastError());
+#endif
}
}
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index 11585ef..db1759c 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -100,9 +100,6 @@ void QNetworkSessionManagerPrivate::forceSessionClose(const QNetworkConfiguratio
void QNetworkSessionPrivateImpl::syncStateWithInterface()
{
- connect(&manager, SIGNAL(updateCompleted()), this, SLOT(networkConfigurationsChanged()));
- connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)),
- this, SLOT(configurationChanged(QNetworkConfiguration)));
connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)),
this, SLOT(forcedSessionClose(QNetworkConfiguration)));
@@ -119,6 +116,10 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface()
activeConfig = publicConfig;
engine = getEngineFromId(activeConfig.identifier());
if (engine) {
+ qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
+ connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ Qt::QueuedConnection);
connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
Qt::QueuedConnection);
@@ -203,22 +204,18 @@ void QNetworkSessionPrivateImpl::stop()
void QNetworkSessionPrivateImpl::migrate()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
void QNetworkSessionPrivateImpl::accept()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
void QNetworkSessionPrivateImpl::ignore()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
void QNetworkSessionPrivateImpl::reject()
{
- qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO);
}
QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
@@ -233,13 +230,37 @@ QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
return QNetworkInterface::interfaceFromName(interface);
}
-QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString& /*key*/) const
+QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString &key) const
{
+ if (key == QLatin1String("AutoCloseSessionTimeout")) {
+ if (engine && engine->requiresPolling() &&
+ !(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
+ if (sessionTimeout >= 0)
+ return sessionTimeout * 10000;
+ else
+ return -1;
+ }
+ }
+
return QVariant();
}
-void QNetworkSessionPrivateImpl::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/)
+void QNetworkSessionPrivateImpl::setSessionProperty(const QString &key, const QVariant &value)
{
+ if (key == QLatin1String("AutoCloseSessionTimeout")) {
+ if (engine && engine->requiresPolling() &&
+ !(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
+ int timeout = value.toInt();
+ if (timeout >= 0) {
+ connect(engine, SIGNAL(updateCompleted()),
+ this, SLOT(decrementTimeout()), Qt::UniqueConnection);
+ sessionTimeout = timeout / 10000; // convert to poll intervals
+ } else {
+ disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
+ sessionTimeout = -1;
+ }
+ }
+ }
}
QString QNetworkSessionPrivateImpl::errorString() const
@@ -364,12 +385,14 @@ void QNetworkSessionPrivateImpl::networkConfigurationsChanged()
startTime = engine->startTime(activeConfig.identifier());
}
-void QNetworkSessionPrivateImpl::configurationChanged(const QNetworkConfiguration &config)
+void QNetworkSessionPrivateImpl::configurationChanged(QNetworkConfigurationPrivatePointer config)
{
- if (serviceConfig.isValid() && (config == serviceConfig || config == activeConfig))
+ if (serviceConfig.isValid() &&
+ (config->id == serviceConfig.identifier() || config->id == activeConfig.identifier())) {
updateStateFromServiceNetwork();
- else if (config == activeConfig)
+ } else if (config->id == activeConfig.identifier()) {
updateStateFromActiveConfig();
+ }
}
void QNetworkSessionPrivateImpl::forcedSessionClose(const QNetworkConfiguration &config)
@@ -406,4 +429,13 @@ void QNetworkSessionPrivateImpl::connectionError(const QString &id,
}
}
+void QNetworkSessionPrivateImpl::decrementTimeout()
+{
+ if (--sessionTimeout <= 0) {
+ disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
+ sessionTimeout = -1;
+ close();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/qnetworksession_impl.h b/src/plugins/bearer/qnetworksession_impl.h
index 7349e77..c644174 100644
--- a/src/plugins/bearer/qnetworksession_impl.h
+++ b/src/plugins/bearer/qnetworksession_impl.h
@@ -69,7 +69,7 @@ class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate
Q_OBJECT
public:
QNetworkSessionPrivateImpl()
- : startTime(0)
+ : startTime(0), sessionTimeout(-1)
{
}
@@ -108,13 +108,12 @@ private:
private Q_SLOTS:
void networkConfigurationsChanged();
- void configurationChanged(const QNetworkConfiguration &config);
+ void configurationChanged(QNetworkConfigurationPrivatePointer config);
void forcedSessionClose(const QNetworkConfiguration &config);
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error);
+ void decrementTimeout();
private:
- QNetworkConfigurationManager manager;
-
bool opened;
QBearerEngineImpl *engine;
@@ -122,6 +121,8 @@ private:
QNetworkSession::SessionError lastError;
quint64 startTime;
+
+ int sessionTimeout;
};
QT_END_NAMESPACE
diff --git a/src/plugins/codecs/cn/qgb18030codec.cpp b/src/plugins/codecs/cn/qgb18030codec.cpp
index 5537cf7..3f2eec7 100644
--- a/src/plugins/codecs/cn/qgb18030codec.cpp
+++ b/src/plugins/codecs/cn/qgb18030codec.cpp
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
#define Is3rdByte(c) (InRange((c), 0x81, 0xFE))
#define Is4thByte(c) (InRange((c), 0x30, 0x39))
-#define QValidChar(u) ((u) ? QChar((ushort)(u)) : QChar(QChar::ReplacementCharacter))
+#define qValidChar(u) ((u) ? (u) : static_cast<ushort>(QChar::ReplacementCharacter))
/* User-defined areas: UDA 1: 0xAAA1 - 0xAFFE (564/0)
UDA 2: 0xF8A1 - 0xFEFE (658/0)
@@ -160,7 +160,7 @@ QString QGb18030Codec::convertToUnicode(const char* chars, int len, ConverterSta
{
uchar buf[4];
int nbuf = 0;
- QChar replacement = QChar::ReplacementCharacter;
+ ushort replacement = QChar::ReplacementCharacter;
if (state) {
if (state->flags & ConvertInvalidToNull)
replacement = QChar::Null;
@@ -173,6 +173,9 @@ QString QGb18030Codec::convertToUnicode(const char* chars, int len, ConverterSta
int invalid = 0;
QString result;
+ result.resize(len);
+ int unicodeLen = 0;
+ ushort *const resultData = reinterpret_cast<ushort*>(result.data());
//qDebug("QGb18030Decoder::toUnicode(const char* chars, int len = %d)", len);
for (int i = 0; i < len; i++) {
uchar ch = chars[i];
@@ -180,14 +183,16 @@ QString QGb18030Codec::convertToUnicode(const char* chars, int len, ConverterSta
case 0:
if (ch < 0x80) {
// ASCII
- result += QLatin1Char(ch);
+ resultData[unicodeLen] = ch;
+ ++unicodeLen;
} else if (Is1stByte(ch)) {
// GB18030?
buf[0] = ch;
nbuf = 1;
} else {
// Invalid
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
}
break;
@@ -198,9 +203,11 @@ QString QGb18030Codec::convertToUnicode(const char* chars, int len, ConverterSta
int clen = 2;
uint u = qt_Gb18030ToUnicode(buf, clen);
if (clen == 2) {
- result += QValidChar(u);
+ resultData[unicodeLen] = qValidChar(static_cast<ushort>(u));
+ ++unicodeLen;
} else {
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
}
nbuf = 0;
@@ -209,7 +216,8 @@ QString QGb18030Codec::convertToUnicode(const char* chars, int len, ConverterSta
nbuf = 2;
} else {
// Error
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
nbuf = 0;
}
@@ -220,7 +228,8 @@ QString QGb18030Codec::convertToUnicode(const char* chars, int len, ConverterSta
buf[2] = ch;
nbuf = 3;
} else {
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
nbuf = 0;
}
@@ -232,19 +241,24 @@ QString QGb18030Codec::convertToUnicode(const char* chars, int len, ConverterSta
int clen = 4;
uint u = qt_Gb18030ToUnicode(buf, clen);
if (clen == 4) {
- result += QValidChar(u);
+ resultData[unicodeLen] = qValidChar(u);
+ ++unicodeLen;
} else {
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
}
} else {
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
}
nbuf = 0;
break;
}
}
+ result.resize(unicodeLen);
+
if (state) {
state->remainingChars = nbuf;
state->state_data[0] = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
@@ -342,7 +356,7 @@ QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState *
int clen = 2;
uint u = qt_Gb18030ToUnicode(buf, clen);
if (clen == 2) {
- result += QValidChar(u);
+ result += qValidChar(u);
} else {
result += replacement;
++invalid;
@@ -445,7 +459,7 @@ QString QGb2312Codec::convertToUnicode(const char* chars, int len, ConverterStat
{
uchar buf[2];
int nbuf = 0;
- QChar replacement = QChar::ReplacementCharacter;
+ ushort replacement = QChar::ReplacementCharacter;
if (state) {
if (state->flags & ConvertInvalidToNull)
replacement = QChar::Null;
@@ -456,6 +470,9 @@ QString QGb2312Codec::convertToUnicode(const char* chars, int len, ConverterStat
int invalid = 0;
QString result;
+ result.resize(len);
+ int unicodeLen = 0;
+ ushort *const resultData = reinterpret_cast<ushort*>(result.data());
//qDebug("QGb2312Decoder::toUnicode(const char* chars, int len = %d)", len);
for (int i=0; i<len; i++) {
uchar ch = chars[i];
@@ -463,14 +480,16 @@ QString QGb2312Codec::convertToUnicode(const char* chars, int len, ConverterStat
case 0:
if (ch < 0x80) {
// ASCII
- result += QLatin1Char(ch);
+ resultData[unicodeLen] = ch;
+ ++unicodeLen;
} else if (IsByteInGb2312(ch)) {
// GB2312 1st byte?
buf[0] = ch;
nbuf = 1;
} else {
// Invalid
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
}
break;
@@ -481,21 +500,25 @@ QString QGb2312Codec::convertToUnicode(const char* chars, int len, ConverterStat
int clen = 2;
uint u = qt_Gb18030ToUnicode(buf, clen);
if (clen == 2) {
- result += QValidChar(u);
+ resultData[unicodeLen] = qValidChar(static_cast<ushort>(u));
+ ++unicodeLen;
} else {
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
}
nbuf = 0;
} else {
// Error
- result += replacement;
+ resultData[unicodeLen] = replacement;
+ ++unicodeLen;
++invalid;
nbuf = 0;
}
break;
}
}
+ result.resize(unicodeLen);
if (state) {
state->remainingChars = nbuf;
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index 6eed824..0f0d6f6 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -793,15 +793,16 @@ bool QJpegHandler::supportsOption(ImageOption option) const
QVariant QJpegHandler::option(ImageOption option) const
{
- if (option == Quality) {
+ switch(option) {
+ case Quality:
return quality;
- } else if (option == ScaledSize) {
+ case ScaledSize:
return scaledSize;
- } else if (option == ScaledClipRect) {
+ case ScaledClipRect:
return scaledClipRect;
- } else if (option == ClipRect) {
+ case ClipRect:
return clipRect;
- } else if (option == Size) {
+ case Size:
if (canRead() && !device()->isSequential()) {
qint64 pos = device()->pos();
int width = 0;
@@ -810,7 +811,8 @@ QVariant QJpegHandler::option(ImageOption option) const
device()->seek(pos);
return QSize(width, height);
}
- } else if (option == ImageFormat) {
+ return QVariant();
+ case ImageFormat:
if (canRead() && !device()->isSequential()) {
qint64 pos = device()->pos();
QImage::Format format = QImage::Format_Invalid;
@@ -819,20 +821,29 @@ QVariant QJpegHandler::option(ImageOption option) const
return format;
}
return QImage::Format_Invalid;
+ default:
+ return QVariant();
}
- return QVariant();
}
void QJpegHandler::setOption(ImageOption option, const QVariant &value)
{
- if (option == Quality)
+ switch(option) {
+ case Quality:
quality = value.toInt();
- else if ( option == ScaledSize )
+ break;
+ case ScaledSize:
scaledSize = value.toSize();
- else if ( option == ScaledClipRect )
+ break;
+ case ScaledClipRect:
scaledClipRect = value.toRect();
- else if ( option == ClipRect )
+ break;
+ case ClipRect:
clipRect = value.toRect();
+ break;
+ default:
+ break;
+ }
}
QByteArray QJpegHandler::name() const
diff --git a/src/plugins/mediaservices/directshow/directshow.pro b/src/plugins/mediaservices/directshow/directshow.pro
index a3080d3..ea133f9 100644
--- a/src/plugins/mediaservices/directshow/directshow.pro
+++ b/src/plugins/mediaservices/directshow/directshow.pro
@@ -9,6 +9,6 @@ SOURCES += dsserviceplugin.cpp
include(mediaplayer/mediaplayer.pri)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices
-target.path = $$[QT_INSTALL_PLUGINS]/plugins/mediaservices
+target.path = $$[QT_INSTALL_PLUGINS]/mediaservices
INSTALLS += target
diff --git a/src/plugins/mediaservices/gstreamer/gstreamer.pro b/src/plugins/mediaservices/gstreamer/gstreamer.pro
index 22e3c16..d1bfe44 100644
--- a/src/plugins/mediaservices/gstreamer/gstreamer.pro
+++ b/src/plugins/mediaservices/gstreamer/gstreamer.pro
@@ -46,5 +46,5 @@ SOURCES += \
include(mediaplayer/mediaplayer.pri)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices
-target.path = $$[QT_INSTALL_PLUGINS]/plugins/mediaservices
+target.path = $$[QT_INSTALL_PLUGINS]/mediaservices
INSTALLS += target
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
index 392a7a8..56cdb04 100644
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
+++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp
@@ -51,6 +51,9 @@
//#define USE_PLAYBIN2
+//#define DEBUG_VO_BIN_DUMP
+//#define DEBUG_PLAYBIN_STATES
+
QT_BEGIN_NAMESPACE
@@ -59,7 +62,9 @@ QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent)
m_state(QMediaPlayer::StoppedState),
m_busHelper(0),
m_playbin(0),
- m_nullVideoOutput(0),
+ m_videoSink(0),
+ m_pendingVideoSink(0),
+ m_nullVideoSink(0),
m_bus(0),
m_renderer(0),
m_volume(100),
@@ -83,6 +88,25 @@ QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent)
m_playbin = gst_element_factory_make("playbin", NULL);
#endif
+ m_videoOutputBin = gst_bin_new("video-output-bin");
+ gst_object_ref(GST_OBJECT(m_videoOutputBin));
+
+ m_videoIdentity = gst_element_factory_make("identity", "identity-vo");
+ m_colorSpace = gst_element_factory_make("ffmpegcolorspace", "ffmpegcolorspace-vo");
+ m_videoScale = gst_element_factory_make("videoscale","videoscale-vo");
+ m_nullVideoSink = gst_element_factory_make("fakesink", NULL);
+ gst_object_ref(GST_OBJECT(m_nullVideoSink));
+ gst_bin_add_many(GST_BIN(m_videoOutputBin), m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL);
+ gst_element_link_many(m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL);
+
+ m_videoSink = m_nullVideoSink;
+
+ // add ghostpads
+ GstPad *pad = gst_element_get_static_pad(m_videoIdentity,"sink");
+ gst_element_add_pad(GST_ELEMENT(m_videoOutputBin), gst_ghost_pad_new("videosink", pad));
+ gst_object_unref(GST_OBJECT(pad));
+
+
if (m_playbin != 0) {
// Sort out messages
m_bus = gst_element_get_bus(m_playbin);
@@ -90,9 +114,7 @@ QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent)
connect(m_busHelper, SIGNAL(message(QGstreamerMessage)), SLOT(busMessage(QGstreamerMessage)));
m_busHelper->installSyncEventFilter(this);
- m_nullVideoOutput = gst_element_factory_make("fakesink", NULL);
- gst_object_ref(GST_OBJECT(m_nullVideoOutput));
- g_object_set(G_OBJECT(m_playbin), "video-sink", m_nullVideoOutput, NULL);
+ g_object_set(G_OBJECT(m_playbin), "video-sink", m_videoOutputBin, NULL);
// Initial volume
double volume = 1.0;
@@ -109,7 +131,8 @@ QGstreamerPlayerSession::~QGstreamerPlayerSession()
delete m_busHelper;
gst_object_unref(GST_OBJECT(m_bus));
gst_object_unref(GST_OBJECT(m_playbin));
- gst_object_unref(GST_OBJECT(m_nullVideoOutput));
+ gst_object_unref(GST_OBJECT(m_nullVideoSink));
+ gst_object_unref(GST_OBJECT(m_videoOutputBin));
}
}
@@ -242,13 +265,141 @@ bool QGstreamerPlayerSession::isAudioAvailable() const
return m_audioAvailable;
}
+static void block_pad_cb(GstPad *pad, gboolean blocked, gpointer user_data)
+{
+ Q_UNUSED(pad);
+ //qDebug() << "block_pad_cb" << blocked;
+
+ if (blocked && user_data) {
+ QGstreamerPlayerSession *session = reinterpret_cast<QGstreamerPlayerSession*>(user_data);
+ QMetaObject::invokeMethod(session, "finishVideoOutputChange", Qt::QueuedConnection);
+ }
+}
+
+#ifdef DEBUG_VO_BIN_DUMP
+ static int dumpNum = 0;
+#endif
+
void QGstreamerPlayerSession::setVideoRenderer(QObject *videoOutput)
{
- m_renderer = qobject_cast<QGstreamerVideoRendererInterface*>(videoOutput);
- if (m_renderer)
- g_object_set(G_OBJECT(m_playbin), "video-sink", m_renderer->videoSink(), NULL);
- else
- g_object_set(G_OBJECT(m_playbin), "video-sink", m_nullVideoOutput, NULL);
+ QGstreamerVideoRendererInterface* renderer = qobject_cast<QGstreamerVideoRendererInterface*>(videoOutput);
+
+ if (m_renderer == renderer)
+ return;
+
+#ifdef DEBUG_VO_BIN_DUMP
+ dumpNum++;
+
+ _gst_debug_bin_to_dot_file(GST_BIN(m_videoOutputBin),
+ GstDebugGraphDetails(GST_DEBUG_GRAPH_SHOW_ALL /* GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES*/),
+ QString("video_output_change_%1_set").arg(dumpNum).toAscii().constData());
+#endif
+
+ m_renderer = renderer;
+
+ GstElement *videoSink = m_renderer ? m_renderer->videoSink() : m_nullVideoSink;
+
+ if (m_state == QMediaPlayer::StoppedState) {
+ m_pendingVideoSink = 0;
+ gst_element_unlink(m_videoScale, m_videoSink);
+
+ gst_bin_remove(GST_BIN(m_videoOutputBin), m_videoSink);
+
+ m_videoSink = videoSink;
+
+ gst_bin_add(GST_BIN(m_videoOutputBin), m_videoSink);
+ gst_element_link(m_videoScale, m_videoSink);
+
+ } else {
+ if (m_pendingVideoSink) {
+ m_pendingVideoSink = videoSink;
+ return;
+ }
+
+ m_pendingVideoSink = videoSink;
+
+ //block pads, async to avoid locking in paused state
+ GstPad *srcPad = gst_element_get_static_pad(m_videoIdentity, "src");
+ gst_pad_set_blocked_async(srcPad, true, &block_pad_cb, this);
+ gst_object_unref(GST_OBJECT(srcPad));
+ }
+}
+
+void QGstreamerPlayerSession::finishVideoOutputChange()
+{
+ if (!m_pendingVideoSink)
+ return;
+
+ GstPad *srcPad = gst_element_get_static_pad(m_videoIdentity, "src");
+
+ if (!gst_pad_is_blocked(srcPad)) {
+ //pad is not blocked, it's possible to swap outputs only in the null state
+ GstState identityElementState = GST_STATE_NULL;
+ gst_element_get_state(m_videoIdentity, &identityElementState, NULL, GST_CLOCK_TIME_NONE);
+ if (identityElementState != GST_STATE_NULL) {
+ gst_object_unref(GST_OBJECT(srcPad));
+ return; //can't change vo yet, received async call from the previous change
+ }
+
+ }
+
+ if (m_pendingVideoSink == m_videoSink) {
+ //video output was change back to the current one,
+ //no need to torment the pipeline, just unblock the pad
+ if (gst_pad_is_blocked(srcPad))
+ gst_pad_set_blocked_async(srcPad, false, &block_pad_cb, 0);
+
+ m_pendingVideoSink = 0;
+ gst_object_unref(GST_OBJECT(srcPad));
+ return;
+ }
+
+ gst_element_set_state(m_colorSpace, GST_STATE_NULL);
+ gst_element_set_state(m_videoScale, GST_STATE_NULL);
+ gst_element_set_state(m_videoSink, GST_STATE_NULL);
+
+ gst_element_unlink(m_videoScale, m_videoSink);
+
+ gst_bin_remove(GST_BIN(m_videoOutputBin), m_videoSink);
+
+ m_videoSink = m_pendingVideoSink;
+ m_pendingVideoSink = 0;
+
+ gst_bin_add(GST_BIN(m_videoOutputBin), m_videoSink);
+ if (!gst_element_link(m_videoScale, m_videoSink))
+ qWarning() << "Linking video output element failed";
+
+ GstState state;
+
+ switch (m_state) {
+ case QMediaPlayer::StoppedState:
+ state = GST_STATE_NULL;
+ break;
+ case QMediaPlayer::PausedState:
+ state = GST_STATE_PAUSED;
+ break;
+ case QMediaPlayer::PlayingState:
+ state = GST_STATE_PLAYING;
+ break;
+ }
+
+ gst_element_set_state(m_colorSpace, state);
+ gst_element_set_state(m_videoScale, state);
+ gst_element_set_state(m_videoSink, state);
+
+ //don't have to wait here, it will unblock eventually
+ if (gst_pad_is_blocked(srcPad))
+ gst_pad_set_blocked_async(srcPad, false, &block_pad_cb, 0);
+ gst_object_unref(GST_OBJECT(srcPad));
+
+#ifdef DEBUG_VO_BIN_DUMP
+ dumpNum++;
+
+ _gst_debug_bin_to_dot_file(GST_BIN(m_videoOutputBin),
+ GstDebugGraphDetails(/*GST_DEBUG_GRAPH_SHOW_ALL */ GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES),
+ QString("video_output_change_%1_finish").arg(dumpNum).toAscii().constData());
+#endif
+
}
bool QGstreamerPlayerSession::isVideoAvailable() const
@@ -298,16 +449,22 @@ void QGstreamerPlayerSession::stop()
if (m_playbin) {
gst_element_set_state(m_playbin, GST_STATE_NULL);
+ QMediaPlayer::State oldState = QMediaPlayer::StoppedState;
+ m_state = QMediaPlayer::StoppedState;
+
+ finishVideoOutputChange();
+
//we have to do it here, since gstreamer will not emit bus messages any more
- if (m_state != QMediaPlayer::StoppedState)
- emit stateChanged(m_state = QMediaPlayer::StoppedState);
+ if (oldState != m_state)
+ emit stateChanged(m_state);
}
}
bool QGstreamerPlayerSession::seek(qint64 ms)
{
- if (m_playbin && m_state != QMediaPlayer::StoppedState) {
- gint64 position = (gint64)ms * 1000000;
+ //seek locks when the video output sink is changing and pad is blocked
+ if (m_playbin && !m_pendingVideoSink && m_state != QMediaPlayer::StoppedState) {
+ gint64 position = qMax(ms,qint64(0)) * 1000000;
return gst_element_seek_simple(m_playbin, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, position);
}
@@ -466,13 +623,15 @@ void QGstreamerPlayerSession::busMessage(const QGstreamerMessage &message)
gst_message_parse_state_changed(gm, &oldState, &newState, &pending);
- /*QStringList states;
+#ifdef DEBUG_PLAYBIN_STATES
+ QStringList states;
states << "GST_STATE_VOID_PENDING" << "GST_STATE_NULL" << "GST_STATE_READY" << "GST_STATE_PAUSED" << "GST_STATE_PLAYING";
qDebug() << QString("state changed: old: %1 new: %2 pending: %3") \
.arg(states[oldState]) \
.arg(states[newState]) \
- .arg(states[pending]);*/
+ .arg(states[pending]);
+#endif
switch (newState) {
case GST_STATE_VOID_PENDING:
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
index edfec5b..867a0e0 100644
--- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
+++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.h
@@ -99,7 +99,7 @@ public:
// int activeStream(QMediaStreamsControl::StreamType streamType) const;
// void setActiveStream(QMediaStreamsControl::StreamType streamType, int streamNumber);
- bool processSyncMessage(const QGstreamerMessage &message);
+ bool processSyncMessage(const QGstreamerMessage &message);
public slots:
void load(const QUrl &url);
@@ -133,13 +133,22 @@ private slots:
void busMessage(const QGstreamerMessage &message);
void getStreamsInfo();
void setSeekable(bool);
+ void finishVideoOutputChange();
private:
QUrl m_url;
QMediaPlayer::State m_state;
QGstreamerBusHelper* m_busHelper;
GstElement* m_playbin;
- GstElement* m_nullVideoOutput;
+
+ GstElement* m_videoOutputBin;
+ GstElement* m_videoIdentity;
+ GstElement* m_colorSpace;
+ GstElement* m_videoScale;
+ GstElement* m_videoSink;
+ GstElement* m_pendingVideoSink;
+ GstElement* m_nullVideoSink;
+
GstBus* m_bus;
QGstreamerVideoRendererInterface *m_renderer;
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
index 47fb451..8307aa5 100644
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
+++ b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
@@ -99,9 +99,26 @@ protected:
QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent)
: QVideoWidgetControl(parent)
, m_videoSink(0)
- , m_widget(new QGstreamerVideoWidget)
+ , m_widget(0)
, m_fullScreen(false)
+{
+}
+
+QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl()
+{
+ if (m_videoSink)
+ gst_object_unref(GST_OBJECT(m_videoSink));
+
+ delete m_widget;
+}
+
+void QGstreamerVideoWidgetControl::createVideoWidget()
{
+ if (m_widget)
+ return;
+
+ m_widget = new QGstreamerVideoWidget;
+
m_widget->installEventFilter(this);
m_windowId = m_widget->winId();
@@ -125,22 +142,15 @@ QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent)
gst_object_sink (GST_OBJECT (m_videoSink));
}
-QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl()
-{
- if (m_videoSink)
- gst_object_unref(GST_OBJECT(m_videoSink));
-
- delete m_widget;
-}
-
GstElement *QGstreamerVideoWidgetControl::videoSink()
{
+ createVideoWidget();
return m_videoSink;
}
bool QGstreamerVideoWidgetControl::eventFilter(QObject *object, QEvent *e)
{
- if (object == m_widget) {
+ if (m_widget && object == m_widget) {
if (e->type() == QEvent::ParentChange || e->type() == QEvent::Show) {
WId newWId = m_widget->winId();
if (newWId != m_windowId) {
@@ -205,7 +215,8 @@ void QGstreamerVideoWidgetControl::updateNativeVideoSize()
gst_caps_unref(caps);
}
} else {
- m_widget->setNativeSize(QSize());
+ if (m_widget)
+ m_widget->setNativeSize(QSize());
}
}
@@ -218,6 +229,7 @@ void QGstreamerVideoWidgetControl::windowExposed()
QWidget *QGstreamerVideoWidgetControl::videoWidget()
{
+ createVideoWidget();
return m_widget;
}
@@ -252,7 +264,7 @@ int QGstreamerVideoWidgetControl::brightness() const
{
int brightness = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness"))
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness"))
g_object_get(G_OBJECT(m_videoSink), "brightness", &brightness, NULL);
return brightness / 10;
@@ -260,7 +272,7 @@ int QGstreamerVideoWidgetControl::brightness() const
void QGstreamerVideoWidgetControl::setBrightness(int brightness)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) {
g_object_set(G_OBJECT(m_videoSink), "brightness", brightness * 10, NULL);
emit brightnessChanged(brightness);
@@ -271,15 +283,15 @@ int QGstreamerVideoWidgetControl::contrast() const
{
int contrast = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast"))
- g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL);
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast"))
+ g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL);
return contrast / 10;
}
void QGstreamerVideoWidgetControl::setContrast(int contrast)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) {
g_object_set(G_OBJECT(m_videoSink), "contrast", contrast * 10, NULL);
emit contrastChanged(contrast);
@@ -290,7 +302,7 @@ int QGstreamerVideoWidgetControl::hue() const
{
int hue = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue"))
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue"))
g_object_get(G_OBJECT(m_videoSink), "hue", &hue, NULL);
return hue / 10;
@@ -298,7 +310,7 @@ int QGstreamerVideoWidgetControl::hue() const
void QGstreamerVideoWidgetControl::setHue(int hue)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) {
g_object_set(G_OBJECT(m_videoSink), "hue", hue * 10, NULL);
emit hueChanged(hue);
@@ -309,7 +321,7 @@ int QGstreamerVideoWidgetControl::saturation() const
{
int saturation = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation"))
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation"))
g_object_get(G_OBJECT(m_videoSink), "saturation", &saturation, NULL);
return saturation / 10;
@@ -317,7 +329,7 @@ int QGstreamerVideoWidgetControl::saturation() const
void QGstreamerVideoWidgetControl::setSaturation(int saturation)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) {
g_object_set(G_OBJECT(m_videoSink), "saturation", saturation * 10, NULL);
emit saturationChanged(saturation);
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
index 7b966b7..6a4c0f3 100644
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
+++ b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
@@ -93,6 +93,7 @@ public slots:
void updateNativeVideoSize();
private:
+ void createVideoWidget();
void windowExposed();
GstElement *m_videoSink;
diff --git a/src/plugins/mediaservices/qt7/qt7.pro b/src/plugins/mediaservices/qt7/qt7.pro
index 13d14d7..6624d13 100644
--- a/src/plugins/mediaservices/qt7/qt7.pro
+++ b/src/plugins/mediaservices/qt7/qt7.pro
@@ -40,6 +40,6 @@ OBJECTIVE_SOURCES += \
include(mediaplayer/mediaplayer.pri)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices
-target.path = $$[QT_INSTALL_PLUGINS]/plugins/mediaservices
+target.path = $$[QT_INSTALL_PLUGINS]/mediaservices
INSTALLS += target