summaryrefslogtreecommitdiff
path: root/src/camera.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/camera.cc')
-rw-r--r--src/camera.cc36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/camera.cc b/src/camera.cc
index 574caf3..ac23fc9 100644
--- a/src/camera.cc
+++ b/src/camera.cc
@@ -27,8 +27,14 @@
#include "camera.h"
-Camera::Camera(const char *ip, const int port)
+Camera::Camera()
{
+}
+
+void Camera::connect(const char *ip, const int port)
+{
+ errorstatus = new Error();
+
pthread_mutex_init (&mutex, NULL);
//mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -48,7 +54,8 @@ Camera::Camera(const char *ip, const int port)
sem_init(&encode_sem, 0, 0);
sem_init(&player_sem, 0, 0);
- decoder = new Decoder(device,
+ decoder = new Decoder(errorstatus,
+ device,
channel,
&encode_sem,
&player_sem,
@@ -59,14 +66,16 @@ Camera::Camera(const char *ip, const int port)
// ifmtctx = decoder->fc;
if(!decoder->fc) return;
- encoder = new Encoder(ip, port,
+ encoder = new Encoder(errorstatus,
+ ip, port,
&encode_sem,
encode_queue,
&mutex,
&running);
ofmtctx = encoder->fc;
- player = new Player(&running,
+ player = new Player(errorstatus,
+ &running,
&player_sem,
player_queue,
&mutex);
@@ -94,26 +103,31 @@ Camera::~Camera()
delete player_queue;
delete encode_queue;
+
+ delete errorstatus;
}
void Camera::setCpr(char *newcpr)
{
+
encoder->setCpr(newcpr);
}
void Camera::start()
{
- encoder->stop();
+ encoder->start();
}
void Camera::stop()
{
- encoder->start();
+ encoder->stop();
}
void Camera::freeze()
{
+ // FIXME: Ensure they freeze the same frame, i.e. the player
+ // shows the same frame that is actually fronzen on the server.
player->stop();
encoder->freeze();
}
@@ -128,4 +142,14 @@ void Camera::snapshot()
encoder->shoot();
}
+bool Camera::hasError()
+{
+ return errorstatus->hasError();
+}
+
+string Camera::getErrorString()
+{
+ return errorstatus->getErrorString();
+}
+
#endif/* USE_GUI */