From kde-commits Tue Jan 17 10:43:07 2006 From: Matthias Kretz Date: Tue, 17 Jan 2006 10:43:07 +0000 To: kde-commits Subject: branches/work/kdelibs-phonon/phonon Message-Id: <1137494587.474833.9296.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=113749460124715 SVN commit 499223 by mkretz: implement the iface wrapper and adjust the iface header to the public API M +87 -1 bytestream.cpp M +1 -1 bytestream.h M +21 -7 ifaces/bytestream.h --- branches/work/kdelibs-phonon/phonon/bytestream.cpp #499222:499223 @@ -1,5 +1,5 @@ /* This file is part of the KDE project - Copyright (C) 2005 Matthias Kretz + Copyright (C) 2005-2006 Matthias Kretz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -24,12 +24,89 @@ { class ByteStream::Private { + public: + Private() + : aboutToFinishTime( 0 ) + , streamSize( -1 ) + , streamSeekable( false ) + { } + + long aboutToFinishTime; + long streamSize; + bool streamSeekable; }; PHONON_HEIR_IMPL( ByteStream, AbstractMediaProducer, AbstractMediaProducer ) +long ByteStream::totalTime() const +{ + return m_iface ? m_iface->totalTime() : -1; +} + +long ByteStream::remainingTime() const +{ + return m_iface ? m_iface->remainingTime() : -1; +} + +long ByteStream::aboutToFinishTime() const +{ + return m_iface ? m_iface->aboutToFinishTime() : d->aboutToFinishTime; +} + +long ByteStream::streamSize() const +{ + return m_iface ? m_iface->streamSize() : d->streamSize; +} + +bool ByteStream::streamSeekable() const +{ + return m_iface ? m_iface->streamSeekable() : d->streamSeekable; +} + +void ByteStream::setStreamSeekable( bool seekable ) +{ + if( m_iface ) + m_iface->setStreamSeekable( seekable ); + else + d->streamSeekable = seekable; +} + +void ByteStream::writeData( const QByteArray& data ) +{ + if( iface() ) + m_iface->writeData( data ); +} + +void ByteStream::setStreamSize( long streamSize ) +{ + if( m_iface ) + m_iface->setStreamSize( streamSize ); + else + d->streamSize = streamSize; +} + +void ByteStream::endOfData() +{ + if( iface() ) + m_iface->endOfData(); +} + +void ByteStream::setAboutToFinishTime( long newAboutToFinishTime ) +{ + if( m_iface ) + m_iface->setAboutToFinishTime( newAboutToFinishTime ); + else + d->aboutToFinishTime = newAboutToFinishTime; +} + bool ByteStream::aboutToDeleteIface() { + if( m_iface ) + { + d->aboutToFinishTime = m_iface->aboutToFinishTime(); + d->streamSize = m_iface->streamSize(); + d->streamSeekable = m_iface->streamSeekable(); + } return AbstractMediaProducer::aboutToDeleteIface(); } @@ -39,6 +116,15 @@ if( !m_iface ) return; + + connect( m_iface->qobject(), SIGNAL( finished() ), SIGNAL( finished() ) ); + connect( m_iface->qobject(), SIGNAL( aboutToFinish( long ) ), SIGNAL( aboutToFinish( long ) ) ); + connect( m_iface->qobject(), SIGNAL( length( long ) ), SIGNAL( length( long ) ) ); + connect( m_iface->qobject(), SIGNAL( needData() ), SIGNAL( needData() ) ); + connect( m_iface->qobject(), SIGNAL( enoughData() ), SIGNAL( enoughData() ) ); + connect( m_iface->qobject(), SIGNAL( seekStream( long ) ), SIGNAL( seekStream( long ) ) ); + + m_iface->setAboutToFinishTime( d->aboutToFinishTime ); } } //namespace Phonon --- branches/work/kdelibs-phonon/phonon/bytestream.h #499222:499223 @@ -54,6 +54,7 @@ */ bool streamSeekable() const; + public slots: /** * Tell the object whether you will support seeking in the * datastream. If you do, you have to react to the seekStream @@ -68,7 +69,6 @@ */ void setStreamSeekable( bool seekable ); - public slots: void writeData( const QByteArray& data ); /** --- branches/work/kdelibs-phonon/phonon/ifaces/bytestream.h #499222:499223 @@ -33,21 +33,35 @@ public: virtual ~ByteStream() {} - //virtual void writeBuffer( const QByteArray& buffer ) = 0; + virtual long totalTime() const = 0; + virtual long remainingTime() const = 0; + virtual long aboutToFinishTime() const = 0; + virtual long streamSize() const = 0; + virtual bool streamSeekable() const = 0; + virtual void setStreamSeekable( bool ) = 0; + virtual void writeData( const QByteArray& data ) = 0; + /** - * Called when there will be no more calls to writeBuffer + * Sets the total number of bytes that will be streamed via + * writeData */ - //virtual void endOfData() = 0; + virtual void setStreamSize( long ) = 0; /** - * Sets the total number of bytes that will be streamed via - * writeBuffer + * Called when there will be no more calls to writeBuffer */ - //virtual void toBeWritten() = 0; + virtual void endOfData() = 0; + virtual void setAboutToFinishTime( long ) = 0; + protected: //signals - //virtual void bufferUnderrun() = 0; + virtual void finished() = 0; + virtual void aboutToFinish( long ) = 0; + virtual void length( long ) = 0; + virtual void needData() = 0; + virtual void enoughData() = 0; + virtual void seekStream( long ) = 0; private: class Private;