summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2005-07-26 16:16:56 +0000
committerdeva <deva>2005-07-26 16:16:56 +0000
commitaa76292f4ceb8bfa94066bd035dda81c95bc9052 (patch)
treee8bc68b7b1206cc5ee5ba623b2fef7800550af8b
parenteac2e19c2fea1c704cdeabcaf5e19f774d3f820b (diff)
Added fullscreen functionality.
-rw-r--r--src/camera.cc9
-rw-r--r--src/camera.h6
-rw-r--r--src/player.cc75
-rw-r--r--src/player.h18
-rw-r--r--src/videowidget.cc39
-rw-r--r--src/videowidget.h15
6 files changed, 96 insertions, 66 deletions
diff --git a/src/camera.cc b/src/camera.cc
index 1746030..75ec63a 100644
--- a/src/camera.cc
+++ b/src/camera.cc
@@ -31,6 +31,10 @@
/*
* $Log$
+ * Revision 1.22 2005/07/26 16:16:56 deva
+ *
+ * Added fullscreen functionality.
+ *
* Revision 1.21 2005/07/25 16:18:34 deva
* *** empty log message ***
*
@@ -225,9 +229,4 @@ void Camera::resize(int w, int h)
player->resize(w,h);
}
-void Camera::pause()
-{
- player->pause();
-}
-
#endif/* USE_GUI */
diff --git a/src/camera.h b/src/camera.h
index be2e584..92f11e8 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -31,6 +31,10 @@
/*
* $Log$
+ * Revision 1.17 2005/07/26 16:16:56 deva
+ *
+ * Added fullscreen functionality.
+ *
* Revision 1.16 2005/07/25 16:18:34 deva
* *** empty log message ***
*
@@ -114,8 +118,8 @@ public:
int getQueueLength();
+ // Indirect call to player->resize
void resize(int width, int height);
- void pause();
private:
// Info object passed to all sub objects.
diff --git a/src/player.cc b/src/player.cc
index 8556ce6..f98b9a0 100644
--- a/src/player.cc
+++ b/src/player.cc
@@ -39,6 +39,10 @@
/*
* $Log$
+ * Revision 1.31 2005/07/26 16:16:56 deva
+ *
+ * Added fullscreen functionality.
+ *
* Revision 1.30 2005/07/25 16:18:34 deva
* *** empty log message ***
*
@@ -80,6 +84,9 @@
#include <time.h>
+// For sleep
+#include <unistd.h>
+
Player::Player(Info *ginfo,
int w, int h,
volatile int *grunning,
@@ -104,8 +111,7 @@ Player::Player(Info *ginfo,
initSDL();
- doresize = false;
- dopause = false;
+ bypass = false;
}
Player::~Player()
@@ -137,10 +143,12 @@ void Player::initSDL()
return;
}
- screen = SDL_SetVideoMode(720,//width,
- 576,//height,
+ screen = SDL_SetVideoMode(width,
+ height,
0, // 0 bpp means 'use current display depth'
- SDL_HWSURFACE | SDL_ANYFORMAT | SDL_HWACCEL);
+ SDL_HWSURFACE |
+ SDL_ANYFORMAT |
+ SDL_HWACCEL );
if(!screen) {
info->error("Unable to set %dx%d video: %s.",
@@ -150,8 +158,8 @@ void Player::initSDL()
return;
}
- overlay = SDL_CreateYUVOverlay(720,//width,
- 576,//height,
+ overlay = SDL_CreateYUVOverlay(720,
+ 576,
SDL_YUY2_OVERLAY, // Match for the libdv decoder output
screen);
if(!overlay) {
@@ -160,13 +168,19 @@ void Player::initSDL()
printf("failed!\n");
return;
}
+
+ // Setup the displayarea.
+ rect.x = 0;
+ rect.y = 0;
+ rect.w = width;
+ rect.h = height;
+
printf("done!\n");
}
void Player::player()
{
SDL_Event event;
- SDL_Rect rect;
Frame *frame;
int pitches[3];
@@ -174,12 +188,6 @@ void Player::player()
struct timespec ts;
if(!noErrors) return; // FIXME: Gracefully exit...
-
- // Setup the displayarea.
- rect.x = 0;
- rect.y = 0;
- rect.w = width;
- rect.h = height;
bool first = true;
dv_decoder_t *decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE);
@@ -190,15 +198,7 @@ void Player::player()
sem_wait(&play_sem);
sem_post(&play_sem);
- if(doresize) {
- width = new_width;
- height = new_height;
- reinitSDL();
- doresize = false;
- dopause = false;
- }
-
- if(dopause) continue;
+ if(bypass) continue;
if(!SDL_WaitEvent(&event)) break; // FIXME: Gracefully exit...
@@ -283,16 +283,31 @@ void Player::stop()
sem_wait(&play_sem);
}
+// FIXME: Worst case genario: the loop takes more than 1 second
+// to stop displaying => crash, due to deinitialization
+// of SDL, while calling it.!
void Player::resize(int w, int h)
{
- new_width = w;
- new_height = h;
- doresize = true;
-}
+ printf("Resizing to: %d x %d\n", w, h);
-void Player::pause()
-{
- dopause = true;
+ // Tell loop to stop
+ bypass = true;
+
+ // Wait to ensure the current frame is done being displayed
+ sleep(1);
+
+ // Deinitialize SDL
+ deinitSDL();
+
+ // Set new size
+ width = w;
+ height = h;
+
+ // Initialize SDL
+ initSDL();
+
+ // Tell loop to go on.
+ bypass = false;
}
#endif /* USE_GUI */
diff --git a/src/player.h b/src/player.h
index cc7b512..b7394c6 100644
--- a/src/player.h
+++ b/src/player.h
@@ -39,6 +39,10 @@
/*
* $Log$
+ * Revision 1.13 2005/07/26 16:16:56 deva
+ *
+ * Added fullscreen functionality.
+ *
* Revision 1.12 2005/07/25 16:18:34 deva
* *** empty log message ***
*
@@ -104,8 +108,8 @@ public:
void start();
void stop();
+ // Used to reinitialize the SDL output width a new size
void resize(int width, int height);
- void pause();
void thread_main();
@@ -116,15 +120,13 @@ private:
void reinitSDL();
// Output dimensions (overlay)
- int width;
- int height;
+ volatile int width;
+ volatile int height;
+
+ SDL_Rect rect;
// Set to true, whenever a resize is requested.
- volatile bool doresize;
- volatile bool dopause;
- // New output dimensions (overlay)
- int new_width;
- int new_height;
+ volatile bool bypass;
Info *info;
diff --git a/src/videowidget.cc b/src/videowidget.cc
index e4477a4..8160833 100644
--- a/src/videowidget.cc
+++ b/src/videowidget.cc
@@ -31,6 +31,10 @@
/*
* $Log$
+ * Revision 1.8 2005/07/26 16:16:56 deva
+ *
+ * Added fullscreen functionality.
+ *
* Revision 1.7 2005/07/25 16:18:34 deva
* *** empty log message ***
*
@@ -49,18 +53,21 @@
* Revision 1.2 2005/05/01 09:56:26 deva
* Added Id and Log tags to all files
*/
-
#include <config.h>
#ifdef USE_GUI
#include "videowidget.h"
-VideoWidget::VideoWidget(QWidget *p, Camera *c) : QWidget(p, "")
+#include "miav_config.h"
+
+VideoWidget::VideoWidget(QWidget *p, Camera *c, QWidget* old) : QWidget(p, "")
{
camera = c;
parent = p;
+ oldWindow = old;
+
// A welltested hack to force SDL to draw in the QWidget
QString ids;
setenv("SDL_WINDOWID", ids.setNum(winId()), 1);
@@ -75,24 +82,22 @@ QPixmap VideoWidget::getScreenshot()
return QPixmap::grabWindow (winId());
}
-void VideoWidget::mousePressEvent(QMouseEvent *event)
+void VideoWidget::mouseReleaseEvent(QMouseEvent *event)
{
- camera->pause();
-
- if(isFullScreen()) {
- printf("Going normal\n");
-
- reparent(parent, 0, QPoint(10,10), FALSE);
-
- showNormal();
+ if(!parent) {
+ // We are a fullscreen window
+ QString ids;
+ setenv("SDL_WINDOWID", ids.setNum(oldWindow->winId()), 1);
+ camera->resize(oldWindow->width(), oldWindow->height());
+ destroy();
} else {
- printf("Going fullscreen\n");
-
- reparent(NULL, 0, QPoint(0,0), FALSE);
-
- showFullScreen();
+ // We are a nested window
+ VideoWidget *fs = new VideoWidget(NULL, camera, this);
+ fs->showFullScreen();
+ fs->setFixedWidth(config->readInt("pixel_width"));
+ fs->setFixedHeight(config->readInt("pixel_height"));
+ camera->resize(fs->width(), fs->height());
}
- camera->resize(width(), height());
}
#endif /* USE_GUI */
diff --git a/src/videowidget.h b/src/videowidget.h
index 2f8002e..05df0ae 100644
--- a/src/videowidget.h
+++ b/src/videowidget.h
@@ -31,6 +31,10 @@
/*
* $Log$
+ * Revision 1.7 2005/07/26 16:16:56 deva
+ *
+ * Added fullscreen functionality.
+ *
* Revision 1.6 2005/07/25 15:56:27 deva
* *** empty log message ***
*
@@ -60,17 +64,18 @@
class VideoWidget : public QWidget {
Q_OBJECT
public:
- VideoWidget(QWidget *parent, Camera *camera);
+ VideoWidget(QWidget *parent, Camera *camera, QWidget *old = NULL);
~VideoWidget();
QPixmap getScreenshot();
- void mousePressEvent(QMouseEvent *event);
-
-signals:
- void clicked();
+ void mouseReleaseEvent(QMouseEvent *event);
private:
Camera *camera;
+
QWidget *parent;
+
+ // Reassign SDL to this when closing (if non-NULL)
+ QWidget *oldWindow;
};
#endif /* __VIDEOWIDGET_H__ */