[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Phonon-VLC] e50d01a: better naming in the media object
From: "Martin T.H.Sandsmark" <sandsmark () samfundet ! no>
Date: 2010-12-27 21:43:40
Message-ID: 20101227214340.D07D8A6090 () git ! kde ! org
[Download RAW message or body]
commit e50d01a22c53d0f24166e3d6beb46f2cc37e3f1f
branch master
Author: Martin T. H. Sandsmark <sandsmark@samfundet.no>
Date: Mon Dec 27 22:43:20 2010 +0100
better naming in the media object
diff --git a/test/phota/mediacontroller.cpp b/test/phota/mediacontroller.cpp
index f90bee2..f9cf27e 100644
--- a/test/phota/mediacontroller.cpp
+++ b/test/phota/mediacontroller.cpp
@@ -1,8 +1,10 @@
#include "mediacontroller.h"
#include <QtGui/QFileDialog>
-#include <Phonon/MediaSource>
-#include <Phonon/MediaObject>
+//#include <Phonon/MediaSource>
+//#include <Phonon/MediaObject>
+#include <phonon/mediasource.h>
+#include <phonon/mediaobject.h>
using namespace Phonon;
diff --git a/test/phota/videoeffects.cpp b/test/phota/videoeffects.cpp
index 23ed1e8..5583ebf 100644
--- a/test/phota/videoeffects.cpp
+++ b/test/phota/videoeffects.cpp
@@ -2,7 +2,8 @@
#include "ui_videoeffects.h"
#include <assert.h>
-#include <Phonon/VideoWidget>
+//#include <Phonon/VideoWidget>
+#include <phonon/videowidget.h>
VideoEffects::VideoEffects(Phonon::VideoWidget *_w, QWidget *parent) :
QDialog(parent),
diff --git a/vlc/mediaobject.cpp b/vlc/mediaobject.cpp
index 369a403..aa42859 100644
--- a/vlc/mediaobject.cpp
+++ b/vlc/mediaobject.cpp
@@ -49,15 +49,15 @@ namespace VLC
MediaObject::MediaObject(QObject *p_parent)
: QObject(p_parent)
{
- currentState = Phonon::StoppedState;
- p_video_widget = NULL;
- b_prefinish_mark_reached_emitted = false;
- b_about_to_finish_emitted = false;
- i_transition_time = 0;
+ m_currentState = Phonon::StoppedState;
+ m_videoWidget = NULL;
+ m_prefinishEmitted = false;
+ m_aboutToFinishEmitted = false;
+ m_transitionTime = 0;
// By default, no tick() signal
// FIXME: Not implemented yet
- i_tick_interval = 0;
+ m_tickInterval = 0;
qRegisterMetaType<QMultiMap<QString, QString> >("QMultiMap<QString, QString>");
@@ -70,8 +70,8 @@ MediaObject::MediaObject(QObject *p_parent)
connect(this, SIGNAL(moveToNext()),
SLOT(moveToNextSource()));
- p_next_source = MediaSource(QUrl());
- p_video_widget = NULL;
+ m_nextSource = MediaSource(QUrl());
+ m_videoWidget = NULL;
}
MediaObject::~MediaObject()
@@ -102,7 +102,7 @@ MediaObject::~MediaObject()
void MediaObject::setVideoWidget(BaseWidget *widget)
{
- this->p_video_widget = widget;
+ this->m_videoWidget = widget;
}
/**
@@ -113,11 +113,11 @@ void MediaObject::play()
{
qDebug() << __FUNCTION__;
- if (currentState == Phonon::PausedState) {
+ if (m_currentState == Phonon::PausedState) {
resume();
} else {
- b_prefinish_mark_reached_emitted = false;
- b_about_to_finish_emitted = false;
+ m_prefinishEmitted = false;
+ m_aboutToFinishEmitted = false;
// Play the file
playInternal();
}
@@ -138,11 +138,11 @@ void MediaObject::seek(qint64 milliseconds)
qint64 currentTime = this->currentTime();
qint64 totalTime = this->totalTime();
- if (currentTime < totalTime - i_prefinish_mark) {
- b_prefinish_mark_reached_emitted = false;
+ if (currentTime < totalTime - m_prefinishMark) {
+ m_prefinishEmitted = false;
}
if (currentTime < totalTime - ABOUT_TO_FINISH_TIME) {
- b_about_to_finish_emitted = false;
+ m_aboutToFinishEmitted = false;
}
}
@@ -156,16 +156,16 @@ void MediaObject::tickInternalSlot(qint64 currentTime)
{
qint64 totalTime = this->totalTime();
- if (i_tick_interval > 0) {
+ if (m_tickInterval > 0) {
// If _tickInternal == 0 means tick() signal is disabled
// Default is _tickInternal = 0
emit tick(currentTime);
}
- if (currentState == Phonon::PlayingState) {
- if (currentTime >= totalTime - i_prefinish_mark) {
- if (!b_prefinish_mark_reached_emitted) {
- b_prefinish_mark_reached_emitted = true;
+ if (m_currentState == Phonon::PlayingState) {
+ if (currentTime >= totalTime - m_prefinishMark) {
+ if (!m_prefinishEmitted) {
+ m_prefinishEmitted = true;
emit prefinishMarkReached(totalTime - currentTime);
}
}
@@ -199,7 +199,7 @@ void MediaObject::resume()
*/
qint32 MediaObject::tickInterval() const
{
- return i_tick_interval;
+ return m_tickInterval;
}
/**
@@ -208,7 +208,7 @@ qint32 MediaObject::tickInterval() const
*/
void MediaObject::setTickInterval(qint32 tickInterval)
{
- i_tick_interval = tickInterval;
+ m_tickInterval = tickInterval;
// if (_tickInterval <= 0) {
// _tickTimer->setInterval(50);
// } else {
@@ -257,7 +257,7 @@ qint64 MediaObject::currentTime() const
*/
Phonon::State MediaObject::state() const
{
- return currentState;
+ return m_currentState;
}
/**
@@ -273,7 +273,7 @@ Phonon::ErrorType MediaObject::errorType() const
*/
MediaSource MediaObject::source() const
{
- return mediaSource;
+ return m_mediaSource;
}
/**
@@ -298,7 +298,7 @@ void MediaObject::setSource(const MediaSource &source)
{
qDebug() << __FUNCTION__;
- mediaSource = source;
+ m_mediaSource = source;
QByteArray driverName;
QString deviceName;
@@ -329,14 +329,14 @@ void MediaObject::setSource(const MediaSource &source)
<< "Error: the MediaSource::Disc doesn't specify which one (Phonon::NoDisc)";
return;
case Phonon::Cd:
- qDebug() << mediaSource.deviceName();
- loadMedia("cdda://" + mediaSource.deviceName());
+ qDebug() << m_mediaSource.deviceName();
+ loadMedia("cdda://" + m_mediaSource.deviceName());
break;
case Phonon::Dvd:
- loadMedia("dvd://" + mediaSource.deviceName());
+ loadMedia("dvd://" + m_mediaSource.deviceName());
break;
case Phonon::Vcd:
- loadMedia(mediaSource.deviceName());
+ loadMedia(m_mediaSource.deviceName());
break;
default:
qCritical() << __FUNCTION__ << "Error: unsupported MediaSource::Disc:" << source.discType();
@@ -366,16 +366,16 @@ void MediaObject::setSource(const MediaSource &source)
break;
#endif // PHONON_VLC_NO_EXPERIMENTAL
case MediaSource::Stream:
- if (!source.url().isEmpty()) {
+// if (!source.url().isEmpty()) {
loadStream();
- }
+// }
break;
default:
qCritical() << __FUNCTION__ << "Error: Unsupported MediaSource Type:" << source.type();
break;
}
- emit currentSourceChanged(mediaSource);
+ emit currentSourceChanged(m_mediaSource);
}
/**
@@ -388,7 +388,9 @@ void MediaObject::setSource(const MediaSource &source)
*/
void MediaObject::loadStream()
{
- streamReader = new StreamReader(mediaSource);
+ m_streamReader = new StreamReader(m_mediaSource);
+
+ loadMedia("imem://");
#ifdef _MSC_VER
char formatstr[] = "0x%p";
@@ -406,9 +408,8 @@ void MediaObject::loadStream()
snprintf(sptr, sizeof(sptr), formatstr, streamSeekCallback);
char srptr[64];
- snprintf(srptr, sizeof(srptr), formatstr, streamReader);
+ snprintf(srptr, sizeof(srptr), formatstr, m_streamReader);
- loadMedia("imem://");
setOption("imem-cat=4");
setOption(QString("imem-data=%1").arg(srptr));
@@ -418,8 +419,8 @@ void MediaObject::loadStream()
// if stream has known size, we may pass it
// imem module will use it and pass it to demux
- if( streamReader->streamSize() > 0 )
- setOption(QString("imem-size=%1").arg( streamReader->streamSize() ));
+ if( m_streamReader->streamSize() > 0 )
+ setOption(QString("imem-size=%1").arg( m_streamReader->streamSize() ));
}
/**
@@ -428,38 +429,38 @@ void MediaObject::loadStream()
void MediaObject::setNextSource(const MediaSource &source)
{
qDebug() << __FUNCTION__;
- p_next_source = source;
+ m_nextSource = source;
}
qint32 MediaObject::prefinishMark() const
{
- return i_prefinish_mark;
+ return m_prefinishMark;
}
void MediaObject::setPrefinishMark(qint32 msecToEnd)
{
- i_prefinish_mark = msecToEnd;
- if (currentTime() < totalTime() - i_prefinish_mark) {
+ m_prefinishMark = msecToEnd;
+ if (currentTime() < totalTime() - m_prefinishMark) {
// Not about to finish
- b_prefinish_mark_reached_emitted = false;
+ m_prefinishEmitted = false;
}
}
qint32 MediaObject::transitionTime() const
{
- return i_transition_time;
+ return m_transitionTime;
}
void MediaObject::setTransitionTime(qint32 time)
{
- i_transition_time = time;
+ m_transitionTime = time;
}
void MediaObject::emitAboutToFinish()
{
- if (!b_about_to_finish_emitted) {
+ if (!m_aboutToFinishEmitted) {
// Track is about to finish
- b_about_to_finish_emitted = true;
+ m_aboutToFinishEmitted = true;
emit aboutToFinish();
}
}
@@ -471,22 +472,22 @@ void MediaObject::emitAboutToFinish()
void MediaObject::stateChangedInternal(Phonon::State newState)
{
qDebug() << __FUNCTION__ << "newState:" << PhononStateToString(newState)
- << "previousState:" << PhononStateToString(currentState) ;
+ << "previousState:" << PhononStateToString(m_currentState) ;
- if (newState == currentState) {
+ if (newState == m_currentState) {
// State not changed
return;
} else if (checkGaplessWaiting()) {
// This is a no-op, warn that we are....
qDebug() << __FUNCTION__ << "no-op gapless item awaiting in queue - "
- << p_next_source.type() ;
+ << m_nextSource.type() ;
return;
}
// State changed
- Phonon::State previousState = currentState;
- currentState = newState;
- emit stateChanged(currentState, previousState);
+ Phonon::State previousState = m_currentState;
+ m_currentState = newState;
+ emit stateChanged(m_currentState, previousState);
}
/**
@@ -526,19 +527,19 @@ QString MediaObject::PhononStateToString(Phonon::State newState)
*/
void MediaObject::moveToNextSource()
{
- if (p_next_source.type() == MediaSource::Invalid) {
+ if (m_nextSource.type() == MediaSource::Invalid) {
// No item is scheduled to be next...
return;
}
- setSource(p_next_source);
+ setSource(m_nextSource);
play();
- p_next_source = MediaSource(QUrl());
+ m_nextSource = MediaSource(QUrl());
}
bool MediaObject::checkGaplessWaiting()
{
- return p_next_source.type() != MediaSource::Invalid && p_next_source.type() != MediaSource::Empty;
+ return m_nextSource.type() != MediaSource::Invalid && m_nextSource.type() != MediaSource::Empty;
}
diff --git a/vlc/mediaobject.h b/vlc/mediaobject.h
index 2fb4ee0..f5ce33a 100644
--- a/vlc/mediaobject.h
+++ b/vlc/mediaobject.h
@@ -137,8 +137,8 @@ protected:
bool checkGaplessWaiting();
- BaseWidget *p_video_widget;
- MediaSource p_next_source;
+ BaseWidget *m_videoWidget;
+ MediaSource m_nextSource;
private slots:
@@ -157,17 +157,17 @@ private:
QString PhononStateToString(Phonon::State newState);
- MediaSource mediaSource;
- StreamReader *streamReader;
- Phonon::State currentState;
+ MediaSource m_mediaSource;
+ StreamReader *m_streamReader;
+ Phonon::State m_currentState;
- qint32 i_prefinish_mark;
- bool b_prefinish_mark_reached_emitted;
+ qint32 m_prefinishMark;
+ bool m_prefinishEmitted;
- bool b_about_to_finish_emitted;
+ bool m_aboutToFinishEmitted;
- qint32 i_tick_interval;
- qint32 i_transition_time;
+ qint32 m_tickInterval;
+ qint32 m_transitionTime;
};
}
diff --git a/vlc/videodataoutput.cpp b/vlc/videodataoutput.cpp
index 1c7252b..b33e0bf 100644
--- a/vlc/videodataoutput.cpp
+++ b/vlc/videodataoutput.cpp
@@ -28,6 +28,8 @@
#include <phonon/experimental/abstractvideodataoutput.h>
#include <phonon/experimental/videoframe2.h>
+#include <QMetaObject>
+
#include "mediaobject.h"
namespace Phonon
@@ -59,13 +61,14 @@ void VideoDataOutput::addToMedia(libvlc_media_t *media)
{
const int width = 300;
const int height = width;
- videoSizeChanged(width, height);
+// videoSizeChanged(width, height);
+ libvlc_media_add_option_flag(media, ":vmem-chroma=RV24", libvlc_media_option_trusted);
libvlc_video_set_callbacks(p_vlc_player, lock, unlock, 0, this);
}
void VideoDataOutput::videoSizeChanged(int width, int height)
{
- QSize size (width, height);
+ const QSize size (width, height);
if (m_img) {
if (size == m_img->size()) {
return; // False alarm.
@@ -73,8 +76,8 @@ void VideoDataOutput::videoSizeChanged(int width, int height)
delete m_img;
}
qDebug() << "changing video size to:" << size;
- m_img = new QImage(size, QImage::Format_RGB32);
- libvlc_video_set_format(p_vlc_player, "RV32", width, height, width * 4);
+ m_img = new QImage(size, QImage::Format_RGB888);
+ //libvlc_video_set_format(p_vlc_player, "RV24", width, height, width * 3);
}
void *VideoDataOutput::lock(void *data, void **bufRet)
@@ -83,11 +86,9 @@ void *VideoDataOutput::lock(void *data, void **bufRet)
VideoDataOutput *cw = (VideoDataOutput *)data;
cw->m_mutex.lock();
-// const int width = libvlc_video_get_width(cw->p_vlc_player);
-// const int height = libvlc_video_get_height(cw->p_vlc_player);
-
-// cw->m_buffer = new char[width * height];
-// *bufRet = cw->m_buffer;
+ const int width = libvlc_video_get_width(cw->p_vlc_player);
+ const int height = libvlc_video_get_height(cw->p_vlc_player);
+ cw->videoSizeChanged(width, height);
*bufRet = cw->m_img->bits();
@@ -112,7 +113,7 @@ void VideoDataOutput::unlock(void *data, void *id, void *const *pixels)
// FIXME: VideoFrame2 does not (yet) support RGB32, so we use 888 but really
// hope the frontend implementation will convert to RGB32 QImage.
Experimental::VideoFrame2::Format_RGB888,
- QByteArray::fromRawData((const char *)cw->m_img->bits(),
+ QByteArray::fromRawData((const char *)cw->m_img->constBits(),
cw->m_img->byteCount()), // data0
0, //data1
0 //data2
diff --git a/vlc/videodataoutput.h b/vlc/videodataoutput.h
index 4452aaa..fbb0dae 100644
--- a/vlc/videodataoutput.h
+++ b/vlc/videodataoutput.h
@@ -140,6 +140,9 @@ private:
QMutex m_mutex;
QImage *m_img;
+ char *m_buffer;
+ int m_height;
+ int m_width;
};
} // namespace VLC
} // namespace Phonon
diff --git a/vlc/vlcmediaobject.cpp b/vlc/vlcmediaobject.cpp
index 6ae441b..e3f1052 100644
--- a/vlc/vlcmediaobject.cpp
+++ b/vlc/vlcmediaobject.cpp
@@ -125,14 +125,14 @@ void VLCMediaObject::loadMediaInternal(const QString &filename)
void VLCMediaObject::setVLCVideoWidget()
{
// Nothing to do if there is no video widget
- if (!p_video_widget)
+ if (!m_videoWidget)
return;
// Get our media player to use our window
#if defined(Q_OS_MAC)
libvlc_media_player_set_nsobject(p_vlc_media_player, p_video_widget->cocoaView());
#elif defined(Q_OS_UNIX)
- libvlc_media_player_set_xwindow(p_vlc_media_player, p_video_widget->winId());
+ libvlc_media_player_set_xwindow(p_vlc_media_player, m_videoWidget->winId());
#elif defined(Q_OS_WIN)
libvlc_media_player_set_hwnd(p_vlc_media_player, p_video_widget->winId());
#endif
@@ -234,7 +234,7 @@ void VLCMediaObject::pause()
*/
void VLCMediaObject::stop()
{
- p_next_source = MediaSource(QUrl());
+ m_nextSource = MediaSource(QUrl());
libvlc_media_player_stop(p_vlc_media_player);
// unloadMedia();
emit stateChanged(Phonon::StoppedState);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic