mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Do HTTP(s) streaming by ourselves instead of passing the URL to phonon
This commit is contained in:
@@ -639,8 +639,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
|||||||
|
|
||||||
setCurrentTrack( result );
|
setCurrentTrack( result );
|
||||||
|
|
||||||
if ( !TomahawkUtils::isHttpResult( d->currentTrack->url() ) &&
|
if ( !TomahawkUtils::isLocalResult( d->currentTrack->url() ) )
|
||||||
!TomahawkUtils::isLocalResult( d->currentTrack->url() ) )
|
|
||||||
{
|
{
|
||||||
boost::function< void ( QSharedPointer< QIODevice >& ) > callback =
|
boost::function< void ( QSharedPointer< QIODevice >& ) > callback =
|
||||||
boost::bind( &AudioEngine::performLoadTrack, this, result, _1 );
|
boost::bind( &AudioEngine::performLoadTrack, this, result, _1 );
|
||||||
@@ -661,9 +660,7 @@ AudioEngine::performLoadTrack( const Tomahawk::result_ptr& result, QSharedPointe
|
|||||||
|
|
||||||
bool err = false;
|
bool err = false;
|
||||||
{
|
{
|
||||||
if ( !TomahawkUtils::isHttpResult( d->currentTrack->url() ) &&
|
if ( !TomahawkUtils::isLocalResult( d->currentTrack->url() ) && ( !io || io.isNull() ) )
|
||||||
!TomahawkUtils::isLocalResult( d->currentTrack->url() ) &&
|
|
||||||
( !io || io.isNull() ) )
|
|
||||||
{
|
{
|
||||||
tLog() << "Error getting iodevice for" << result->url();
|
tLog() << "Error getting iodevice for" << result->url();
|
||||||
err = true;
|
err = true;
|
||||||
@@ -675,8 +672,7 @@ AudioEngine::performLoadTrack( const Tomahawk::result_ptr& result, QSharedPointe
|
|||||||
d->state = Loading;
|
d->state = Loading;
|
||||||
emit loading( d->currentTrack );
|
emit loading( d->currentTrack );
|
||||||
|
|
||||||
if ( !TomahawkUtils::isHttpResult( d->currentTrack->url() ) &&
|
if ( !TomahawkUtils::isLocalResult( d->currentTrack->url() ) )
|
||||||
!TomahawkUtils::isLocalResult( d->currentTrack->url() ) )
|
|
||||||
{
|
{
|
||||||
if ( QNetworkReply* qnr_io = qobject_cast< QNetworkReply* >( io.data() ) )
|
if ( QNetworkReply* qnr_io = qobject_cast< QNetworkReply* >( io.data() ) )
|
||||||
d->mediaObject->setCurrentSource( new QNR_IODeviceStream( qnr_io, this ) );
|
d->mediaObject->setCurrentSource( new QNR_IODeviceStream( qnr_io, this ) );
|
||||||
@@ -686,6 +682,9 @@ AudioEngine::performLoadTrack( const Tomahawk::result_ptr& result, QSharedPointe
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* TODO: Do we need this anymore as we now do HTTP streaming ourselves?
|
||||||
|
* Maybe this can be useful for letting phonon do other protocols?
|
||||||
if ( !TomahawkUtils::isLocalResult( d->currentTrack->url() ) )
|
if ( !TomahawkUtils::isLocalResult( d->currentTrack->url() ) )
|
||||||
{
|
{
|
||||||
QUrl furl = d->currentTrack->url();
|
QUrl furl = d->currentTrack->url();
|
||||||
@@ -698,7 +697,7 @@ AudioEngine::performLoadTrack( const Tomahawk::result_ptr& result, QSharedPointe
|
|||||||
tLog( LOGVERBOSE ) << "Passing to Phonon:" << furl;
|
tLog( LOGVERBOSE ) << "Passing to Phonon:" << furl;
|
||||||
d->mediaObject->setCurrentSource( furl );
|
d->mediaObject->setCurrentSource( furl );
|
||||||
}
|
}
|
||||||
else
|
else*/
|
||||||
{
|
{
|
||||||
QString furl = d->currentTrack->url();
|
QString furl = d->currentTrack->url();
|
||||||
if ( furl.startsWith( "file://" ) )
|
if ( furl.startsWith( "file://" ) )
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/NetworkAccessManager.h"
|
#include "utils/NetworkAccessManager.h"
|
||||||
|
#include "utils/NetworkReply.h"
|
||||||
|
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
#include "ControlConnection.h"
|
#include "ControlConnection.h"
|
||||||
@@ -62,6 +63,7 @@ Q_DECLARE_METATYPE( QList< SipInfo > )
|
|||||||
Q_DECLARE_METATYPE( Connection* )
|
Q_DECLARE_METATYPE( Connection* )
|
||||||
Q_DECLARE_METATYPE( QTcpSocketExtra* )
|
Q_DECLARE_METATYPE( QTcpSocketExtra* )
|
||||||
Q_DECLARE_METATYPE( Tomahawk::peerinfo_ptr )
|
Q_DECLARE_METATYPE( Tomahawk::peerinfo_ptr )
|
||||||
|
Q_DECLARE_METATYPE( IODeviceCallback )
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -1402,10 +1404,20 @@ Servent::httpIODeviceFactory( const Tomahawk::result_ptr& result,
|
|||||||
boost::function< void ( QSharedPointer< QIODevice >& ) > callback )
|
boost::function< void ( QSharedPointer< QIODevice >& ) > callback )
|
||||||
{
|
{
|
||||||
QNetworkRequest req( result->url() );
|
QNetworkRequest req( result->url() );
|
||||||
QNetworkReply* reply = Tomahawk::Utils::nam()->get( req );
|
// Follow HTTP Redirects
|
||||||
|
NetworkReply* reply = new NetworkReply( Tomahawk::Utils::nam()->get( req ) );
|
||||||
|
qRegisterMetaType<NetworkReply*>("NetworkReply*");
|
||||||
|
qRegisterMetaType<IODeviceCallback>("IODeviceCallback");
|
||||||
|
NewClosure( reply, SIGNAL( finished() ),
|
||||||
|
this, SLOT( httpIODeviceReady( NetworkReply*, IODeviceCallback ) ),
|
||||||
|
reply, callback );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Servent::httpIODeviceReady( NetworkReply* reply, IODeviceCallback callback )
|
||||||
|
{
|
||||||
//boost::functions cannot accept temporaries as parameters
|
//boost::functions cannot accept temporaries as parameters
|
||||||
QSharedPointer< QIODevice > sp = QSharedPointer< QIODevice >( reply, &QObject::deleteLater );
|
QSharedPointer< QIODevice > sp = QSharedPointer< QIODevice >( reply->reply(), &QObject::deleteLater );
|
||||||
callback( sp );
|
callback( sp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,13 +36,14 @@
|
|||||||
class Connection;
|
class Connection;
|
||||||
class Connector;
|
class Connector;
|
||||||
class ControlConnection;
|
class ControlConnection;
|
||||||
class StreamConnection;
|
class NetworkReply;
|
||||||
|
class PeerInfo;
|
||||||
|
class PortFwdThread;
|
||||||
class ProxyConnection;
|
class ProxyConnection;
|
||||||
class QTcpSocketExtra;
|
class QTcpSocketExtra;
|
||||||
class RemoteCollectionConnection;
|
class RemoteCollectionConnection;
|
||||||
class PortFwdThread;
|
|
||||||
class PeerInfo;
|
|
||||||
class SipInfo;
|
class SipInfo;
|
||||||
|
class StreamConnection;
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@@ -51,6 +52,7 @@ namespace boost
|
|||||||
|
|
||||||
typedef boost::function< void( const Tomahawk::result_ptr&,
|
typedef boost::function< void( const Tomahawk::result_ptr&,
|
||||||
boost::function< void( QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
|
boost::function< void( QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
|
||||||
|
typedef boost::function< void ( QSharedPointer< QIODevice >& ) > IODeviceCallback;
|
||||||
|
|
||||||
class ServentPrivate;
|
class ServentPrivate;
|
||||||
|
|
||||||
@@ -162,6 +164,7 @@ public slots:
|
|||||||
void triggerDBSync();
|
void triggerDBSync();
|
||||||
|
|
||||||
void onSipInfoChanged();
|
void onSipInfoChanged();
|
||||||
|
void httpIODeviceReady( NetworkReply* reply, IODeviceCallback callback );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void deleteLazyOffer( const QString& key );
|
void deleteLazyOffer( const QString& key );
|
||||||
|
@@ -61,4 +61,6 @@ private:
|
|||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE( QSharedPointer<NetworkReply> )
|
||||||
|
|
||||||
#endif // NETWORKREPLY_H
|
#endif // NETWORKREPLY_H
|
||||||
|
Reference in New Issue
Block a user