Compare commits
7 Commits
khorben/ca
...
master
Author | SHA1 | Date | |
---|---|---|---|
e3de8157ed | |||
8d2931f8ea | |||
88701c479b | |||
9e855dad62 | |||
3b5399a8d2 | |||
fd1e4419fa | |||
1e01aa9d63 |
50
po/es.po
50
po/es.po
|
@ -5,10 +5,10 @@
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Camera 0.1.0\n"
|
"Project-Id-Version: Camera 0.3.1\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2020-01-23 20:01+0100\n"
|
"POT-Creation-Date: 2024-07-30 02:46+0200\n"
|
||||||
"PO-Revision-Date: 2015-02-16 07:20+0100\n"
|
"PO-Revision-Date: 2025-02-20 17:45+0100\n"
|
||||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||||
"Language-Team: Spanish\n"
|
"Language-Team: Spanish\n"
|
||||||
"Language: es\n"
|
"Language: es\n"
|
||||||
|
@ -23,7 +23,7 @@ msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:216
|
#: ../src/camera.c:216
|
||||||
msgid "Gallery"
|
msgid "Gallery"
|
||||||
msgstr ""
|
msgstr "Galería"
|
||||||
|
|
||||||
#: ../src/camera.c:220 ../src/camera.c:227 ../src/camera.c:899
|
#: ../src/camera.c:220 ../src/camera.c:227 ../src/camera.c:899
|
||||||
#: ../src/camera.c:909
|
#: ../src/camera.c:909
|
||||||
|
@ -36,7 +36,7 @@ msgstr "Preferencias"
|
||||||
|
|
||||||
#: ../src/camera.c:303
|
#: ../src/camera.c:303
|
||||||
msgid "Fullscreen"
|
msgid "Fullscreen"
|
||||||
msgstr ""
|
msgstr "Pantalla completa"
|
||||||
|
|
||||||
#: ../src/camera.c:701
|
#: ../src/camera.c:701
|
||||||
msgid "Nearest"
|
msgid "Nearest"
|
||||||
|
@ -72,7 +72,7 @@ msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:759
|
#: ../src/camera.c:759
|
||||||
msgid "Picture"
|
msgid "Picture"
|
||||||
msgstr ""
|
msgstr "Imagen"
|
||||||
|
|
||||||
#: ../src/camera.c:765
|
#: ../src/camera.c:765
|
||||||
msgid "Format: "
|
msgid "Format: "
|
||||||
|
@ -102,65 +102,65 @@ msgstr ""
|
||||||
msgid "Capabilities: "
|
msgid "Capabilities: "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1005 ../src/camera.c:1009 ../src/camera.c:1028
|
#: ../src/camera.c:1005 ../src/camera.c:1009 ../src/camera.c:1029
|
||||||
#: ../src/camera.c:1047 ../src/camera.c:1073 ../src/camera.c:1093
|
#: ../src/camera.c:1048 ../src/camera.c:1074 ../src/camera.c:1094
|
||||||
#: ../src/camera.c:1246
|
#: ../src/camera.c:1247
|
||||||
msgid "Could not save picture"
|
msgid "Could not save picture"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1095
|
#: ../src/camera.c:1096
|
||||||
msgid "Unknown error"
|
msgid "Unknown error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1199 ../src/camera.c:1203
|
#: ../src/camera.c:1200 ../src/camera.c:1204
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr "Error"
|
msgstr "Error"
|
||||||
|
|
||||||
#: ../src/camera.c:1432
|
#: ../src/camera.c:1433
|
||||||
msgid "Could not open the video capture device"
|
msgid "Could not open the video capture device"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1473
|
#: ../src/camera.c:1474
|
||||||
msgid "Could not obtain the capabilities"
|
msgid "Could not obtain the capabilities"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1477
|
#: ../src/camera.c:1478
|
||||||
msgid "Not a video capture device"
|
msgid "Not a video capture device"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1490
|
#: ../src/camera.c:1491
|
||||||
msgid "Cropping not supported"
|
msgid "Cropping not supported"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1495
|
#: ../src/camera.c:1497
|
||||||
msgid "Could not obtain the video capture format"
|
msgid "Could not obtain the video capture format"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1499
|
#: ../src/camera.c:1501
|
||||||
msgid "Unsupported video capture type"
|
msgid "Unsupported video capture type"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1510
|
#: ../src/camera.c:1512
|
||||||
msgid "Unsupported capabilities"
|
msgid "Unsupported capabilities"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1545
|
#: ../src/camera.c:1547
|
||||||
msgid "Could not request buffers"
|
msgid "Could not request buffers"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1548
|
#: ../src/camera.c:1550
|
||||||
msgid "Could not obtain enough buffers"
|
msgid "Could not obtain enough buffers"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1552
|
#: ../src/camera.c:1554
|
||||||
msgid "Could not allocate buffers"
|
msgid "Could not allocate buffers"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1568
|
#: ../src/camera.c:1570
|
||||||
msgid "Could not setup buffers"
|
msgid "Could not setup buffers"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/camera.c:1574
|
#: ../src/camera.c:1576
|
||||||
msgid "Could not map buffers"
|
msgid "Could not map buffers"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ msgstr "_Preferencias"
|
||||||
|
|
||||||
#: ../src/window.c:132
|
#: ../src/window.c:132
|
||||||
msgid "_Fullscreen"
|
msgid "_Fullscreen"
|
||||||
msgstr ""
|
msgstr "_Pantalla completa"
|
||||||
|
|
||||||
#: ../src/window.c:143
|
#: ../src/window.c:143
|
||||||
msgid "_Contents"
|
msgid "_Contents"
|
||||||
|
@ -233,7 +233,7 @@ msgstr ""
|
||||||
|
|
||||||
#: ../src/window.c:202
|
#: ../src/window.c:202
|
||||||
msgid "Camera"
|
msgid "Camera"
|
||||||
msgstr ""
|
msgstr "Cámara"
|
||||||
|
|
||||||
#: ../src/window.c:422
|
#: ../src/window.c:422
|
||||||
msgid "Simple webcam application for the DeforaOS desktop"
|
msgid "Simple webcam application for the DeforaOS desktop"
|
||||||
|
|
40
po/fr.po
40
po/fr.po
|
@ -5,10 +5,10 @@
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Camera 0.1.0\n"
|
"Project-Id-Version: Camera 0.3.1\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2020-01-23 20:01+0100\n"
|
"POT-Creation-Date: 2024-07-30 02:46+0200\n"
|
||||||
"PO-Revision-Date: 2013-01-18 22:31+0100\n"
|
"PO-Revision-Date: 2025-02-20 17:45+0100\n"
|
||||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||||
"Language-Team: French\n"
|
"Language-Team: French\n"
|
||||||
"Language: fr\n"
|
"Language: fr\n"
|
||||||
|
@ -102,65 +102,65 @@ msgstr "Version : "
|
||||||
msgid "Capabilities: "
|
msgid "Capabilities: "
|
||||||
msgstr "Capacités : "
|
msgstr "Capacités : "
|
||||||
|
|
||||||
#: ../src/camera.c:1005 ../src/camera.c:1009 ../src/camera.c:1028
|
#: ../src/camera.c:1005 ../src/camera.c:1009 ../src/camera.c:1029
|
||||||
#: ../src/camera.c:1047 ../src/camera.c:1073 ../src/camera.c:1093
|
#: ../src/camera.c:1048 ../src/camera.c:1074 ../src/camera.c:1094
|
||||||
#: ../src/camera.c:1246
|
#: ../src/camera.c:1247
|
||||||
msgid "Could not save picture"
|
msgid "Could not save picture"
|
||||||
msgstr "Impossible d'enregistrer l'image"
|
msgstr "Impossible d'enregistrer l'image"
|
||||||
|
|
||||||
#: ../src/camera.c:1095
|
#: ../src/camera.c:1096
|
||||||
msgid "Unknown error"
|
msgid "Unknown error"
|
||||||
msgstr "Erreur inconnue"
|
msgstr "Erreur inconnue"
|
||||||
|
|
||||||
#: ../src/camera.c:1199 ../src/camera.c:1203
|
#: ../src/camera.c:1200 ../src/camera.c:1204
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr "Erreur"
|
msgstr "Erreur"
|
||||||
|
|
||||||
#: ../src/camera.c:1432
|
#: ../src/camera.c:1433
|
||||||
msgid "Could not open the video capture device"
|
msgid "Could not open the video capture device"
|
||||||
msgstr "Impossible d'ouvrir le périphérique de capture vidéo"
|
msgstr "Impossible d'ouvrir le périphérique de capture vidéo"
|
||||||
|
|
||||||
#: ../src/camera.c:1473
|
#: ../src/camera.c:1474
|
||||||
msgid "Could not obtain the capabilities"
|
msgid "Could not obtain the capabilities"
|
||||||
msgstr "Impossible d'obtenir les capacités"
|
msgstr "Impossible d'obtenir les capacités"
|
||||||
|
|
||||||
#: ../src/camera.c:1477
|
#: ../src/camera.c:1478
|
||||||
msgid "Not a video capture device"
|
msgid "Not a video capture device"
|
||||||
msgstr "Pas de périphérique de capture vidéo"
|
msgstr "Pas de périphérique de capture vidéo"
|
||||||
|
|
||||||
#: ../src/camera.c:1490
|
#: ../src/camera.c:1491
|
||||||
msgid "Cropping not supported"
|
msgid "Cropping not supported"
|
||||||
msgstr "Recadrage non supporté"
|
msgstr "Recadrage non supporté"
|
||||||
|
|
||||||
#: ../src/camera.c:1495
|
#: ../src/camera.c:1497
|
||||||
msgid "Could not obtain the video capture format"
|
msgid "Could not obtain the video capture format"
|
||||||
msgstr "Impossible d'obtenir le format de capture vidéo"
|
msgstr "Impossible d'obtenir le format de capture vidéo"
|
||||||
|
|
||||||
#: ../src/camera.c:1499
|
#: ../src/camera.c:1501
|
||||||
msgid "Unsupported video capture type"
|
msgid "Unsupported video capture type"
|
||||||
msgstr "Type de capture vidéo non supporté"
|
msgstr "Type de capture vidéo non supporté"
|
||||||
|
|
||||||
#: ../src/camera.c:1510
|
#: ../src/camera.c:1512
|
||||||
msgid "Unsupported capabilities"
|
msgid "Unsupported capabilities"
|
||||||
msgstr "Capacités non supportées"
|
msgstr "Capacités non supportées"
|
||||||
|
|
||||||
#: ../src/camera.c:1545
|
#: ../src/camera.c:1547
|
||||||
msgid "Could not request buffers"
|
msgid "Could not request buffers"
|
||||||
msgstr "Impossible de demander le cache"
|
msgstr "Impossible de demander le cache"
|
||||||
|
|
||||||
#: ../src/camera.c:1548
|
#: ../src/camera.c:1550
|
||||||
msgid "Could not obtain enough buffers"
|
msgid "Could not obtain enough buffers"
|
||||||
msgstr "Impossible d'obtenir suffisamment de cache"
|
msgstr "Impossible d'obtenir suffisamment de cache"
|
||||||
|
|
||||||
#: ../src/camera.c:1552
|
#: ../src/camera.c:1554
|
||||||
msgid "Could not allocate buffers"
|
msgid "Could not allocate buffers"
|
||||||
msgstr "Impossible d'allouer le cache"
|
msgstr "Impossible d'allouer le cache"
|
||||||
|
|
||||||
#: ../src/camera.c:1568
|
#: ../src/camera.c:1570
|
||||||
msgid "Could not setup buffers"
|
msgid "Could not setup buffers"
|
||||||
msgstr "Impossible de configurer le cache"
|
msgstr "Impossible de configurer le cache"
|
||||||
|
|
||||||
#: ../src/camera.c:1574
|
#: ../src/camera.c:1576
|
||||||
msgid "Could not map buffers"
|
msgid "Could not map buffers"
|
||||||
msgstr "Impossible d'étaler le cache"
|
msgstr "Impossible d'étaler le cache"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package=Camera
|
package=Camera
|
||||||
version=0.3.0
|
version=0.3.1
|
||||||
vendor=Desktop
|
vendor=Desktop
|
||||||
config=h,sh
|
config=h,sh
|
||||||
|
|
||||||
|
|
99
src/camera.c
99
src/camera.c
|
@ -94,6 +94,7 @@ struct _Camera
|
||||||
|
|
||||||
guint source;
|
guint source;
|
||||||
int fd;
|
int fd;
|
||||||
|
struct v4l2_buffer buf;
|
||||||
struct v4l2_capability cap;
|
struct v4l2_capability cap;
|
||||||
struct v4l2_format format;
|
struct v4l2_format format;
|
||||||
|
|
||||||
|
@ -1190,6 +1191,8 @@ void camera_stop(Camera * camera)
|
||||||
if((char *)camera->rgb_buffer != camera->raw_buffer)
|
if((char *)camera->rgb_buffer != camera->raw_buffer)
|
||||||
free(camera->rgb_buffer);
|
free(camera->rgb_buffer);
|
||||||
camera->rgb_buffer = NULL;
|
camera->rgb_buffer = NULL;
|
||||||
|
if(camera->buffers_cnt > 0)
|
||||||
|
{
|
||||||
for(i = 0; i < camera->buffers_cnt; i++)
|
for(i = 0; i < camera->buffers_cnt; i++)
|
||||||
if(camera->buffers[i].start != MAP_FAILED)
|
if(camera->buffers[i].start != MAP_FAILED)
|
||||||
munmap(camera->buffers[i].start,
|
munmap(camera->buffers[i].start,
|
||||||
|
@ -1197,8 +1200,11 @@ void camera_stop(Camera * camera)
|
||||||
free(camera->buffers);
|
free(camera->buffers);
|
||||||
camera->buffers = NULL;
|
camera->buffers = NULL;
|
||||||
camera->buffers_cnt = 0;
|
camera->buffers_cnt = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
free(camera->raw_buffer);
|
free(camera->raw_buffer);
|
||||||
camera->raw_buffer = NULL;
|
camera->raw_buffer = NULL;
|
||||||
|
camera->raw_buffer_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1275,29 +1281,38 @@ static gboolean _camera_on_can_mmap(GIOChannel * channel,
|
||||||
GIOCondition condition, gpointer data)
|
GIOCondition condition, gpointer data)
|
||||||
{
|
{
|
||||||
Camera * camera = data;
|
Camera * camera = data;
|
||||||
struct v4l2_buffer buf;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
if(channel != camera->channel || condition != G_IO_IN)
|
if(channel != camera->channel || condition != G_IO_IN)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(_camera_ioctl(camera, VIDIOC_DQBUF, &buf) == -1)
|
memset(&camera->buf, 0, sizeof(camera->buf));
|
||||||
|
camera->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
camera->buf.memory = V4L2_MEMORY_MMAP;
|
||||||
|
if(_camera_ioctl(camera, VIDIOC_DQBUF, &camera->buf) == -1)
|
||||||
{
|
{
|
||||||
_camera_error(camera, _("Could not save picture"), 1);
|
_camera_error(camera, _("Could not dequeue buffer"), 1);
|
||||||
|
camera->source = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
camera->raw_buffer = camera->buffers[buf.index].start;
|
if(camera->buf.index >= camera->buffers_cnt)
|
||||||
camera->raw_buffer_cnt = buf.bytesused;
|
{
|
||||||
#if 0 /* FIXME the raw buffer is not meant to be free()'d */
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() %u >= %zu\n", __func__,
|
||||||
|
camera->buf.index, camera->buffers_cnt);
|
||||||
|
#endif
|
||||||
|
_camera_error(camera, _("Invalid buffer index"), 1);
|
||||||
|
camera->source = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
camera->raw_buffer = camera->buffers[camera->buf.index].start;
|
||||||
|
camera->raw_buffer_cnt = camera->buffers[camera->buf.index].length;
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() %lu\n", __func__, camera->raw_buffer_cnt);
|
||||||
|
#endif
|
||||||
camera->source = g_idle_add(_camera_on_refresh, camera);
|
camera->source = g_idle_add(_camera_on_refresh, camera);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#else
|
|
||||||
_camera_on_refresh(camera);
|
|
||||||
camera->raw_buffer = NULL;
|
|
||||||
camera->raw_buffer_cnt = 0;
|
|
||||||
return TRUE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1315,6 +1330,7 @@ static gboolean _camera_on_can_read(GIOChannel * channel,
|
||||||
#endif
|
#endif
|
||||||
if(channel != camera->channel || condition != G_IO_IN)
|
if(channel != camera->channel || condition != G_IO_IN)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
size = camera->raw_buffer_cnt;
|
||||||
status = g_io_channel_read_chars(channel, camera->raw_buffer,
|
status = g_io_channel_read_chars(channel, camera->raw_buffer,
|
||||||
camera->raw_buffer_cnt, &size, &error);
|
camera->raw_buffer_cnt, &size, &error);
|
||||||
/* this status can be ignored */
|
/* this status can be ignored */
|
||||||
|
@ -1517,9 +1533,6 @@ static gboolean _camera_on_open(gpointer data)
|
||||||
gtk_widget_set_sensitive(
|
gtk_widget_set_sensitive(
|
||||||
GTK_WIDGET(_camera_toolbar[CT_PROPERTIES].widget),
|
GTK_WIDGET(_camera_toolbar[CT_PROPERTIES].widget),
|
||||||
TRUE);
|
TRUE);
|
||||||
/* FIXME allow the window to be smaller */
|
|
||||||
gtk_widget_set_size_request(camera->area, camera->format.fmt.pix.width,
|
|
||||||
camera->format.fmt.pix.height);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1575,9 +1588,14 @@ static int _open_setup(Camera * camera)
|
||||||
_("Unsupported video capture type"));
|
_("Unsupported video capture type"));
|
||||||
if((camera->cap.capabilities & V4L2_CAP_STREAMING) != 0)
|
if((camera->cap.capabilities & V4L2_CAP_STREAMING) != 0)
|
||||||
{
|
{
|
||||||
if((ret = _open_setup_mmap(camera)) != 0)
|
if((ret = _open_setup_mmap(camera)) != 0
|
||||||
|
&& (camera->cap.capabilities
|
||||||
|
& V4L2_CAP_READWRITE) != 0)
|
||||||
|
{
|
||||||
|
camera_stop(camera);
|
||||||
ret = _open_setup_read(camera);
|
ret = _open_setup_read(camera);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if((camera->cap.capabilities & V4L2_CAP_READWRITE) != 0)
|
else if((camera->cap.capabilities & V4L2_CAP_READWRITE) != 0)
|
||||||
ret = _open_setup_read(camera);
|
ret = _open_setup_read(camera);
|
||||||
else
|
else
|
||||||
|
@ -1607,6 +1625,8 @@ static int _open_setup_mmap(Camera * camera)
|
||||||
size_t i;
|
size_t i;
|
||||||
struct v4l2_buffer buf;
|
struct v4l2_buffer buf;
|
||||||
enum v4l2_buf_type type;
|
enum v4l2_buf_type type;
|
||||||
|
size_t cnt;
|
||||||
|
char * p;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
|
@ -1618,17 +1638,18 @@ static int _open_setup_mmap(Camera * camera)
|
||||||
if(_camera_ioctl(camera, VIDIOC_REQBUFS, &req) == -1)
|
if(_camera_ioctl(camera, VIDIOC_REQBUFS, &req) == -1)
|
||||||
return -error_set_code(1, "%s: %s", camera->device,
|
return -error_set_code(1, "%s: %s", camera->device,
|
||||||
_("Could not request buffers"));
|
_("Could not request buffers"));
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s() frames=%u\n", __func__, req.count);
|
||||||
|
#endif
|
||||||
if(req.count < 2)
|
if(req.count < 2)
|
||||||
return -error_set_code(1, "%s: %s", camera->device,
|
return -error_set_code(1, "%s: %s", camera->device,
|
||||||
_("Could not obtain enough buffers"));
|
_("Could not obtain enough buffers"));
|
||||||
if((camera->buffers = malloc(sizeof(*camera->buffers) * req.count))
|
/* initialize the buffers */
|
||||||
|
if((camera->buffers = calloc(req.count, sizeof(*camera->buffers)))
|
||||||
== NULL)
|
== NULL)
|
||||||
return -error_set_code(1, "%s: %s", camera->device,
|
return -error_set_code(1, "%s: %s", camera->device,
|
||||||
_("Could not allocate buffers"));
|
_("Could not allocate buffers"));
|
||||||
camera->buffers_cnt = req.count;
|
camera->buffers_cnt = req.count;
|
||||||
/* initialize the buffers */
|
|
||||||
memset(camera->buffers, 0, sizeof(*camera->buffers)
|
|
||||||
* camera->buffers_cnt);
|
|
||||||
for(i = 0; i < camera->buffers_cnt; i++)
|
for(i = 0; i < camera->buffers_cnt; i++)
|
||||||
camera->buffers[i].start = MAP_FAILED;
|
camera->buffers[i].start = MAP_FAILED;
|
||||||
/* map the buffers */
|
/* map the buffers */
|
||||||
|
@ -1649,11 +1670,28 @@ static int _open_setup_mmap(Camera * camera)
|
||||||
_("Could not map buffers"));
|
_("Could not map buffers"));
|
||||||
camera->buffers[i].length = buf.length;
|
camera->buffers[i].length = buf.length;
|
||||||
}
|
}
|
||||||
|
for(i = 0; i < camera->buffers_cnt; i++)
|
||||||
|
{
|
||||||
|
memset(&camera->buf, 0, sizeof(camera->buf));
|
||||||
|
camera->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
camera->buf.memory = V4L2_MEMORY_MMAP;
|
||||||
|
camera->buf.index = i;
|
||||||
|
if(_camera_ioctl(camera, VIDIOC_QBUF, &camera->buf) == -1)
|
||||||
|
return -error_set_code(1, "%s: %s", camera->device,
|
||||||
|
_("Could not queue buffers"));
|
||||||
|
}
|
||||||
/* start the stream */
|
/* start the stream */
|
||||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
if(_camera_ioctl(camera, VIDIOC_STREAMON, &type) == -1)
|
if(_camera_ioctl(camera, VIDIOC_STREAMON, &type) == -1)
|
||||||
return -error_set_code(1, "%s: %s", camera->device,
|
return -error_set_code(1, "%s: %s", camera->device,
|
||||||
_("Could not start the stream"));
|
_("Could not start the stream"));
|
||||||
|
/* allocate the RGB buffer */
|
||||||
|
cnt = camera->format.fmt.pix.width * camera->format.fmt.pix.height * 3;
|
||||||
|
if((p = realloc(camera->rgb_buffer, cnt)) == NULL)
|
||||||
|
return error_set_code(-errno, "%s: %s", camera->device,
|
||||||
|
strerror(errno));
|
||||||
|
camera->rgb_buffer = (unsigned char *)p;
|
||||||
|
camera->rgb_buffer_cnt = cnt;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,7 +1711,7 @@ static int _open_setup_read(Camera * camera)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
camera->raw_buffer = p;
|
camera->raw_buffer = p;
|
||||||
camera->raw_buffer_cnt = cnt;
|
camera->raw_buffer_cnt = cnt;
|
||||||
/* allocate the rgb buffer */
|
/* allocate the RGB buffer */
|
||||||
cnt = camera->format.fmt.pix.width * camera->format.fmt.pix.height * 3;
|
cnt = camera->format.fmt.pix.width * camera->format.fmt.pix.height * 3;
|
||||||
if((p = realloc(camera->rgb_buffer, cnt)) == NULL)
|
if((p = realloc(camera->rgb_buffer, cnt)) == NULL)
|
||||||
return error_set_code(-errno, "%s: %s", camera->device,
|
return error_set_code(-errno, "%s: %s", camera->device,
|
||||||
|
@ -1718,8 +1756,8 @@ static gboolean _camera_on_refresh(gpointer data)
|
||||||
Camera * camera = data;
|
Camera * camera = data;
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
cairo_t * cr;
|
cairo_t * cr;
|
||||||
#endif
|
|
||||||
GtkAllocation * allocation = &camera->area_allocation;
|
GtkAllocation * allocation = &camera->area_allocation;
|
||||||
|
#endif
|
||||||
int width = camera->format.fmt.pix.width;
|
int width = camera->format.fmt.pix.width;
|
||||||
int height = camera->format.fmt.pix.height;
|
int height = camera->format.fmt.pix.height;
|
||||||
|
|
||||||
|
@ -1737,8 +1775,6 @@ static gboolean _camera_on_refresh(gpointer data)
|
||||||
/* render directly */
|
/* render directly */
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
cr = cairo_create(camera->surface);
|
cr = cairo_create(camera->surface);
|
||||||
if(camera->pixbuf != NULL)
|
|
||||||
g_object_unref(camera->pixbuf);
|
|
||||||
camera->pixbuf = gdk_pixbuf_new_from_data(camera->rgb_buffer,
|
camera->pixbuf = gdk_pixbuf_new_from_data(camera->rgb_buffer,
|
||||||
GDK_COLORSPACE_RGB, FALSE, 8, width, height,
|
GDK_COLORSPACE_RGB, FALSE, 8, width, height,
|
||||||
width * 3, NULL, NULL);
|
width * 3, NULL, NULL);
|
||||||
|
@ -1776,9 +1812,20 @@ static gboolean _camera_on_refresh(gpointer data)
|
||||||
}
|
}
|
||||||
/* force a refresh */
|
/* force a refresh */
|
||||||
gtk_widget_queue_draw(camera->area);
|
gtk_widget_queue_draw(camera->area);
|
||||||
|
/* read from the camera again */
|
||||||
|
if(camera->buffers != NULL)
|
||||||
|
{
|
||||||
|
if(_camera_ioctl(camera, VIDIOC_QBUF, &camera->buf) == -1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s\n", strerror(errno));
|
||||||
|
_camera_error(camera, _("Could not queue buffer"), 1);
|
||||||
|
}
|
||||||
camera->source = g_io_add_watch(camera->channel, G_IO_IN,
|
camera->source = g_io_add_watch(camera->channel, G_IO_IN,
|
||||||
(camera->buffers != NULL) ? _camera_on_can_mmap
|
_camera_on_can_mmap, camera);
|
||||||
: _camera_on_can_read, camera);
|
}
|
||||||
|
else
|
||||||
|
camera->source = g_io_add_watch(camera->channel, G_IO_IN,
|
||||||
|
_camera_on_can_read, camera);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,7 @@ CameraWindow * camerawindow_new(char const * device)
|
||||||
# endif
|
# endif
|
||||||
gtk_window_set_title(GTK_WINDOW(camera->window), _("Camera"));
|
gtk_window_set_title(GTK_WINDOW(camera->window), _("Camera"));
|
||||||
#endif
|
#endif
|
||||||
|
gtk_window_set_default_size(GTK_WINDOW(camera->window), 640, 480);
|
||||||
g_signal_connect_swapped(camera->window, "delete-event", G_CALLBACK(
|
g_signal_connect_swapped(camera->window, "delete-event", G_CALLBACK(
|
||||||
_camerawindow_on_closex), camera);
|
_camerawindow_on_closex), camera);
|
||||||
g_signal_connect(camera->window, "window-state-event", G_CALLBACK(
|
g_signal_connect(camera->window, "window-state-event", G_CALLBACK(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user