summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/camera.cc8
-rw-r--r--src/camera.h5
-rw-r--r--src/mainwindow.cc9
-rw-r--r--src/player.cc47
-rw-r--r--src/player.h13
-rw-r--r--src/videowidget.cc21
-rw-r--r--src/videowidget.h8
7 files changed, 86 insertions, 25 deletions
diff --git a/src/camera.cc b/src/camera.cc
index 833b048..62509f5 100644
--- a/src/camera.cc
+++ b/src/camera.cc
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.20 2005/07/25 15:56:27 deva
+ * *** empty log message ***
+ *
* Revision 1.19 2005/07/25 12:42:13 deva
* *** empty log message ***
*
@@ -214,4 +217,9 @@ int Camera::getQueueLength()
return encode_queue->length();
}
+void Camera::resize(int w, int h)
+{
+ player->resize(w,h);
+}
+
#endif/* USE_GUI */
diff --git a/src/camera.h b/src/camera.h
index 2da585b..59f3628 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.15 2005/07/25 15:56:27 deva
+ * *** empty log message ***
+ *
* Revision 1.14 2005/07/25 12:42:13 deva
* *** empty log message ***
*
@@ -108,6 +111,8 @@ public:
int getQueueLength();
+ void resize(int width, int height);
+
private:
// Info object passed to all sub objects.
Info *info;
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index b73e133..548f323 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.42 2005/07/25 15:56:27 deva
+ * *** empty log message ***
+ *
* Revision 1.41 2005/07/25 15:35:41 deva
* *** empty log message ***
*
@@ -174,10 +177,12 @@ MainWindow::MainWindow(QApplication *qApp, QWidget* parent, const char* name )
connect(timer, SIGNAL(timeout()), SLOT(redraw_edge()));
rec_edge_counter = 0.0f;
+ // This must be defined before the gui i created (img_live uses it as parameter)
+ camera = new Camera(info);
+
createGui();
show();
- camera = new Camera(info);
camera->connect(config->readString("server_addr")->c_str(),
config->readInt("server_port"),
img_live->width(), img_live->height());
@@ -291,7 +296,7 @@ void MainWindow::createGui()
img_recedge->setBackgroundColor(QColor(160,160,160));
img_recedge->setFixedSize(output_width, output_height);
- img_live = new VideoWidget(img_recedge);
+ img_live = new VideoWidget(img_recedge, camera);
img_live->setFixedSize(output_width - 20, output_height - 20);
img_live->move(10,10);
g1->addMultiCellWidget ( img_recedge, 0, 0, 0, 2, Qt::AlignHCenter);
diff --git a/src/player.cc b/src/player.cc
index 567ac2f..e42b332 100644
--- a/src/player.cc
+++ b/src/player.cc
@@ -39,6 +39,9 @@
/*
* $Log$
+ * Revision 1.28 2005/07/25 15:56:27 deva
+ * *** empty log message ***
+ *
* Revision 1.27 2005/07/25 14:27:14 deva
* *** empty log message ***
*
@@ -93,6 +96,30 @@ Player::Player(Info *ginfo,
sem_init(&play_sem, 0, 1);
+ initSDL();
+
+ doresize = false;
+}
+
+Player::~Player()
+{
+ deinitSDL();
+}
+
+void Player::reinitSDL()
+{
+ deinitSDL();
+ initSDL();
+}
+
+void Player::deinitSDL()
+{
+ SDL_FreeYUVOverlay(overlay);
+ SDL_Quit();
+}
+
+void Player::initSDL()
+{
if(SDL_Init(SDL_INIT_VIDEO) < 0) {
info->error("Unable to init SDL: %s.", SDL_GetError());
noErrors = false;
@@ -106,7 +133,7 @@ Player::Player(Info *ginfo,
if(!screen) {
info->error("Unable to set %dx%d video: %s.",
- width, height, SDL_GetError());
+ 720, 576, SDL_GetError());
noErrors = false;
return;
}
@@ -122,12 +149,6 @@ Player::Player(Info *ginfo,
}
}
-Player::~Player()
-{
- SDL_FreeYUVOverlay(overlay);
- SDL_Quit();
-}
-
void Player::player()
{
SDL_Event event;
@@ -155,6 +176,11 @@ void Player::player()
sem_wait(&play_sem);
sem_post(&play_sem);
+ if(doresize) {
+ doresize = false;
+ reinitSDL();
+ }
+
if(!SDL_WaitEvent(&event)) break; // FIXME: Gracefully exit...
switch(event.type) {
@@ -238,4 +264,11 @@ void Player::stop()
sem_wait(&play_sem);
}
+void Player::resize(int w, int h)
+{
+ width = w;
+ height = h;
+ doresize = true;
+}
+
#endif /* USE_GUI */
diff --git a/src/player.h b/src/player.h
index 23c517d..410b3e9 100644
--- a/src/player.h
+++ b/src/player.h
@@ -39,6 +39,9 @@
/*
* $Log$
+ * Revision 1.10 2005/07/25 15:56:27 deva
+ * *** empty log message ***
+ *
* Revision 1.9 2005/07/25 12:42:13 deva
* *** empty log message ***
*
@@ -95,13 +98,23 @@ public:
void start();
void stop();
+ void resize(int width, int height);
+
void thread_main();
private:
+
+ void initSDL();
+ void deinitSDL();
+ void reinitSDL();
+
// Output dimensions (overlay)
int width;
int height;
+ // Set to true, whenever a resize is requested.
+ volatile bool doresize;
+
Info *info;
void player();
diff --git a/src/videowidget.cc b/src/videowidget.cc
index 2aa7ba9..4633ff1 100644
--- a/src/videowidget.cc
+++ b/src/videowidget.cc
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.6 2005/07/25 15:56:27 deva
+ * *** empty log message ***
+ *
* Revision 1.5 2005/07/25 15:40:07 deva
* *** empty log message ***
*
@@ -50,8 +53,9 @@
#include "videowidget.h"
-VideoWidget::VideoWidget(QWidget *p) : QWidget(p, "")
+VideoWidget::VideoWidget(QWidget *p, Camera *c) : QWidget(p, "")
{
+ camera = c;
parent = p;
// A welltested hack to force SDL to draw in the QWidget
@@ -70,33 +74,20 @@ QPixmap VideoWidget::getScreenshot()
void VideoWidget::mousePressEvent(QMouseEvent *event)
{
- QString ids;
-
if(isFullScreen()) {
-
printf("Going normal\n");
- setenv("SDL_WINDOWID", ids.setNum(0), 1);
-
reparent(parent, 0, QPoint(10,10), FALSE);
- setenv("SDL_WINDOWID", ids.setNum(winId()), 1);
-
showNormal();
-
} else {
-
printf("Going fullscreen\n");
- setenv("SDL_WINDOWID", ids.setNum(0), 1);
-
reparent(NULL, 0, QPoint(0,0), FALSE);
- setenv("SDL_WINDOWID", ids.setNum(winId()), 1);
-
showFullScreen();
-
}
+ camera->resize(width(), height());
}
#endif /* USE_GUI */
diff --git a/src/videowidget.h b/src/videowidget.h
index 9283a8e..2f8002e 100644
--- a/src/videowidget.h
+++ b/src/videowidget.h
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.6 2005/07/25 15:56:27 deva
+ * *** empty log message ***
+ *
* Revision 1.5 2005/07/25 15:35:41 deva
* *** empty log message ***
*
@@ -52,10 +55,12 @@
#include <qwidget.h>
#include <qpixmap.h>
+#include "camera.h"
+
class VideoWidget : public QWidget {
Q_OBJECT
public:
- VideoWidget(QWidget *parent);
+ VideoWidget(QWidget *parent, Camera *camera);
~VideoWidget();
QPixmap getScreenshot();
void mousePressEvent(QMouseEvent *event);
@@ -64,6 +69,7 @@ signals:
void clicked();
private:
+ Camera *camera;
QWidget *parent;
};