[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    Re: Media Options for KDE 4
From:       Scott Wheeler <wheeler () kde ! org>
Date:       2003-02-24 20:13:18
[Download RAW message or body]

On Monday 24 February 2003 18:11, Neil Stevens wrote:
> You can point at GStreamer and Tim when you can use the full capability of 
> GStreamer without knowing one function of glib.

First I don't see what's so evil about glib that you seem so scared of it, but 
(a) that's unrelated to my point and (b) maybe I just haven't used it enough 
to be appropriately scared.  ;-)

Well, I get the feeling that this has already been said in this thread (what 
hasn't?) -- but could you please define "full capability"?

Is full capability being able to use the system without knowing anything about 
glib or being able to hack GStreamer plugins without knowing glib?

The first is possible and I'm attaching a copy of gstreamerplayer.cpp from JuK 
(there's one abstract class with both an aRts and GStreamer implementation).  
Nothing scarry there.  This was kind of a "proof of concept".

If you're talking about extending the system, well I don't think that's a fair 
requirement or one that's applied elsewhere in KDE.  i.e. We don't require X 
extensions to be comprehensible to average KDE developers, yet obviously this 
is accessible to some...

> (No, this is not an endorsement of GStreamer in KDE 4 :-)

:-)

And just to be sure -- I'm not sold on it either.  But it is an interesting 
option and worth paying some attention to.  The GStreamer guys (several of us 
at FOSDEM met with them) have been a pleasure to deal with and seem very 
interested in the possibility of working with us KDE folks.

Cheers,

-Scott

-- 
Peace and humptiness forever.
--Digital Underground

["gstreamerplayer.cpp" (text/x-c++src)]

/***************************************************************************
                          gstreamerplayer.cpp  -  description
                             -------------------
    begin                : Sat Feb 9 2003
    copyright            : (C) 2003 by Tim Jansen
    email                : tim@tjansen.de
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "../config.h"

#if HAVE_GSTREAMER

#include <kdebug.h>

#include <qfile.h>

#include <connect.h>
#include <flowsystem.h>

#include "gstreamerplayer.h"

using namespace QGst;
using namespace QGstPlay;

////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////

GStreamerPlayer::GStreamerPlayer() : QObject(0), Player()
{
    currentVolume = 1.0;
    positionNs = 0;
    durationNs = 0;

    setupPlayer();
}

GStreamerPlayer::~GStreamerPlayer()
{
    delete player;
}

void GStreamerPlayer::play(const QString &fileName, float volume)
{
    currentFile = fileName;
    if(!fileName.isNull())
	player->setLocation(fileName);  

    play(volume);
}

void GStreamerPlayer::play(float volume)
{
    // 1.0 is full volume
    positionNs = 0;
    durationNs = 0;
    if (player->getState() != Element::STATE_PLAYING) {
	player->setState(Element::STATE_PLAYING);
	player->setVolume(volume);
    }
}

void GStreamerPlayer::pause()
{
    if(player->getState() != Element::STATE_PAUSED)
	player->setState(Element::STATE_PAUSED);
}

void GStreamerPlayer::stop()
{
    if(player->getState() != Element::STATE_READY)
	player->setState(Element::STATE_READY);

}

void GStreamerPlayer::setVolume(float volume)
{
    // 1.0 is full volume
    player->setVolume(volume);
}

float GStreamerPlayer::getVolume() const
{
    // 1.0 is full volume
    return player->getVolume();
}

/////////////////////////////////////////////////////////////////////////////////
// player status functions
/////////////////////////////////////////////////////////////////////////////////

bool GStreamerPlayer::playing() const
{
    // true if playing
    return player->getState() == Element::STATE_PLAYING;
}

bool GStreamerPlayer::paused() const
{
    // true if paused
    return player->getState() == Element::STATE_PAUSED;
}

long GStreamerPlayer::totalTime() const
{
    return durationNs / 1000000000L;
}

long GStreamerPlayer::currentTime() const
{
    return positionNs / 1000000000L;
}

int GStreamerPlayer::position() const
{
    if (durationNs > 0)
	return (int)((positionNs * 1000.0) / durationNs);
    else
	return 0;
}

/////////////////////////////////////////////////////////////////////////////////
// player seek functions
/////////////////////////////////////////////////////////////////////////////////

void GStreamerPlayer::seek(long seekTime)
{
    // seek time in seconds?
    player->seekToTime(seekTime*1000000000);
}

void GStreamerPlayer::seekPosition(int position)
{
    // position unit is 1/1000th
    if(durationNs > 0)
	player->seekToTime(position * durationNs / 1000L);
    else
	player->seekToTime(0);

}

/////////////////////////////////////////////////////////////////////////////////
// private
/////////////////////////////////////////////////////////////////////////////////

void GStreamerPlayer::setDuration(long long d) 
{
    durationNs = d;
}

void GStreamerPlayer::setPosition(long long d)
{
    positionNs = d;
}

void GStreamerPlayer::setupPlayer()
{
    player = new Play(Play::PIPE_AUDIO_BUFFER_THREADED, this, "Play");
    connect(player, SIGNAL(timeTick(long long)), 
	    SLOT(setPosition(long long)));
    connect(player, SIGNAL(streamLength(long long)), 
	    SLOT(setDuration(long long)));
    connect(player, SIGNAL(streamEnd()), SLOT(stop()));
}

#include "gstreamerplayer.moc"

#endif

_______________________________________________
kde-multimedia mailing list
kde-multimedia@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-multimedia

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic