Overview
Submit package home:phils3r:branches:Multimedia / wxcam to package Multimedia / wxcam
wxcam.changes
Changed
x
1
2
-------------------------------------------------------------------
3
+Wed Mar 7 21:12:04 UTC 2012 - p.seiler@linuxmail.org
4
+
5
+- added patch and removed buildrequirement to prevent missing header file error
6
+v4l.h:30:30: fatal error: libv4l1-videodev.h: No such file or directory
7
+compilation terminated.
8
+
9
+-------------------------------------------------------------------
10
+Wed Mar 7 20:25:35 UTC 2012 - p.seiler@linuxmail.org
11
+
12
+- updated to version 1.1
13
+- modified patches to fit the new version
14
+- removed unneeded patch for CImg
15
+- added two more dependencies to compile new version
16
+
17
+-------------------------------------------------------------------
18
Fri Apr 1 15:46:56 UTC 2011 - pascal.bleser@opensuse.org
19
20
- add patch to fix Icon attribute in .desktop file; thanks to Stephan Hegel for
21
wxcam.spec
Changed
57
1
2
%define CImg_version 139
3
4
Name: wxcam
5
-Version: 1.0.7
6
+Version: 1.1
7
Release: 0
8
Summary: Webcam application for linux
9
-License: GNU General Public License version 2 or later (GPLv2 or later)
10
+License: GPL-2.0+
11
Group: Productivity/Graphics/Other
12
URL: http://wxcam.sourceforge.net
13
Source0: http://downloads.sourceforge.net/wxcam/wxcam-%{version}.tar.bz2
14
15
# See http://cimg.sourceforge.net/ for more information
16
Source1: CImg-%{CImg_version}.h.bz2
17
Source2: Licence_CeCILL_V2-en.txt
18
-Source100: %{name}.changes
19
-Patch0: wxcam-CImg.h.diff
20
-Patch1: %{name}-%{version}-fix_no_return_in_nonvoid_function.patch
21
+Patch1: %{name}-fix_no_return_in_nonvoid_function.patch
22
Patch2: wxcam-fix_desktop_file.patch
23
+%if 0%{?suse_version} <= 1140
24
+Patch3: remove-libv4l1-videdev.h.patch
25
+%endif
26
Buildrequires: gcc-c++ pkg-config perl-XML-Parser update-desktop-files
27
BuildRequires: gtk2-devel libglade2-devel libtiff-devel libjpeg-devel
28
-Buildrequires: xvid-devel mjpegtools-devel intltool
29
+Buildrequires: xvid-devel mjpegtools-devel intltool alsa-devel
30
%if 0%{?suse_version} > 1130
31
BuildRequires: wxWidgets-devel
32
%else
33
BuildRequires: wxGTK-devel
34
#wxGTK-gl wxGTK-compat
35
%endif
36
+%if 0%{?suse_version} > 1140
37
+BuildRequires: libv4l-devel
38
+%endif
39
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
40
41
%description
42
43
bzcat %{SOURCE1} > src/CImg.h
44
cp %{SOURCE2} License_CImg
45
46
-%patch0 -p0
47
-%patch1 -p0
48
+%patch1 -p1
49
%patch2 -p0
50
+%if 0%{?suse_version} <= 1140
51
+%patch3 -p1
52
+%endif
53
+
54
55
# set some reasonable permissions for documentation files
56
chmod 0644 COPYING
57
remove-libv4l1-videdev.h.patch
Added
30
1
2
+--- wxcam-1.1/src/v4l.h.bak 2012-03-07 22:04:36.850877420 +0100
3
++++ wxcam-1.1/src/v4l.h 2012-03-07 22:04:53.200831746 +0100
4
+@@ -24,11 +24,7 @@
5
+ #include <unistd.h>
6
+ #include <fcntl.h>
7
+ #include <sys/mman.h>
8
+-#ifdef HAVE_CAMV4L
9
+ #include <linux/videodev.h>
10
+-#else
11
+-#include <libv4l1-videodev.h>
12
+-#endif
13
+ #include <sys/ioctl.h>
14
+ #include <sys/types.h>
15
+ #include <sys/stat.h>
16
+--- wxcam-1.1/src/device.h.bak 2012-03-07 22:04:29.855896961 +0100
17
++++ wxcam-1.1/src/device.h 2012-03-07 22:05:03.023804303 +0100
18
+@@ -24,11 +24,7 @@
19
+ #include <unistd.h>
20
+ #include <fcntl.h>
21
+ #include <sys/mman.h>
22
+-#ifdef HAVE_CAMV4L
23
+ #include <linux/videodev.h>
24
+-#else
25
+-#include <libv4l1-videodev.h>
26
+-#endif
27
+ #include <sys/ioctl.h>
28
+ #include <sys/types.h>
29
+ #include <sys/stat.h>
30
wxcam-1.0.7-fix_no_return_in_nonvoid_function.patch
Deleted
22
1
2
---- src/audio.cpp.orig 2007-11-18 20:11:03.000000000 +0100
3
-+++ src/audio.cpp 2010-12-27 15:01:48.000000000 +0100
4
-@@ -106,6 +106,7 @@
5
- perror(message.c_str());
6
- }
7
- delete [] buffer;
8
-+ return 0;
9
- }
10
-
11
- std::vector<std::string> Audio::getAudioFrames()
12
---- src/device.cpp.orig 2010-08-10 10:58:51.000000000 +0200
13
-+++ src/device.cpp 2010-12-27 15:01:48.000000000 +0100
14
-@@ -340,6 +340,7 @@
15
- frmsize.index++;
16
- }
17
- }
18
-+ return true;
19
- }
20
-
21
- bool Device::getGain( int *agc ) /* VIDIOCPWCGAGC*/
22
wxcam-CImg.h.diff
Deleted
13
1
2
---- src/frame.h.orig 2009-01-12 00:04:14.000000000 +0100
3
-+++ src/frame.h 2009-01-12 00:04:44.000000000 +0100
4
-@@ -29,7 +29,7 @@
5
- #include "motion.h"
6
- #include <string>
7
- #include <list>
8
--#include <CImg.h>
9
-+#include "CImg.h"
10
-
11
- using namespace cimg_library;
12
-
13
wxcam-fix_no_return_in_nonvoid_function.patch
Added
22
1
2
+--- wxcam-1.1/src/device.cpp.bak 2012-03-07 20:59:19.774820103 +0100
3
++++ wxcam-1.1/src/device.cpp 2012-03-07 21:10:10.196003098 +0100
4
+@@ -577,6 +577,7 @@ bool Device::getResolutionList(wxArraySt
5
+ resw = resh * 16 / (float)9;
6
+ }
7
+ }
8
++return true;
9
+ }
10
+
11
+ bool Device::getGain( int *agc ) /* VIDIOCPWCGAGC*/
12
+--- wxcam-1.1/src/audio.cpp.bak 2012-03-07 20:59:06.161858133 +0100
13
++++ wxcam-1.1/src/audio.cpp 2012-03-07 21:04:34.971939575 +0100
14
+@@ -140,6 +140,7 @@ void* Audio::Entry()
15
+ snd_pcm_drain(handle);
16
+ snd_pcm_close(handle);
17
+ free(buffer);
18
++ return 0;
19
+ }
20
+
21
+ std::vector<std::string> Audio::getAudioFrames()
22
wxcam-1.0.7.tar.bz2/README -> wxcam-1.1.tar.bz2/README
Changed
12
1
2
+Compiling wxCam sources:
3
+-) Make sure you have wxWidgets installed on your distribution.
4
+(Ubuntu names: libwxgtk2.8 and libwxgtk2.8-dev)
5
+-) Make sure you have libxvidcore4 and libxvidcore4-dev
6
+-) Make sure you have libv4l-dev
7
+-) NEW: Make sure you have CImg library (cimg-dev). For wxcam versions >= 1.0.5, use at least cimg version 1.33. For older version, use CImg 1.2.
8
+-) NEW: Make sure you have mjpegtools (libmjpegtools-dev)
9
+-) NEW: Make sure you have alsa developement (libasound2-dev)
10
+-) You may also require: libgtk2.0-0 libgtk2.0-dev libglade2-dev
11
+-) Note for 64 bit systems: If you encounter the error "int_64 was already declared in this scope" in file mjpeg_types.h, this is a bug of mjpeg library. To overcome this bug, simply comment row 40 of your mjpeg_types.h file (ubuntu puts it in /usr/include/mjpegtools/mjpeg_types.h).
12
wxcam-1.0.7.tar.bz2/configure -> wxcam-1.1.tar.bz2/configure
Changed
83
1
2
#! /bin/sh
3
# Guess values for system-dependent variables and create Makefiles.
4
-# Generated by GNU Autoconf 2.67 for wxcam 1.0.7.
5
+# Generated by GNU Autoconf 2.67 for wxcam 1.1.
6
#
7
#
8
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
9
10
# Identity of this package.
11
PACKAGE_NAME='wxcam'
12
PACKAGE_TARNAME='wxcam'
13
-PACKAGE_VERSION='1.0.7'
14
-PACKAGE_STRING='wxcam 1.0.7'
15
+PACKAGE_VERSION='1.1'
16
+PACKAGE_STRING='wxcam 1.1'
17
PACKAGE_BUGREPORT=''
18
PACKAGE_URL=''
19
20
21
# Omit some internal or obsolete options to make the list less imposing.
22
# This message is too long to be a string in the A/UX 3.1 sh.
23
cat <<_ACEOF
24
-\`configure' configures wxcam 1.0.7 to adapt to many kinds of systems.
25
+\`configure' configures wxcam 1.1 to adapt to many kinds of systems.
26
27
Usage: $0 [OPTION]... [VAR=VALUE]...
28
29
30
31
if test -n "$ac_init_help"; then
32
case $ac_init_help in
33
- short | recursive ) echo "Configuration of wxcam 1.0.7:";;
34
+ short | recursive ) echo "Configuration of wxcam 1.1:";;
35
esac
36
cat <<\_ACEOF
37
38
39
test -n "$ac_init_help" && exit $ac_status
40
if $ac_init_version; then
41
cat <<\_ACEOF
42
-wxcam configure 1.0.7
43
+wxcam configure 1.1
44
generated by GNU Autoconf 2.67
45
46
Copyright (C) 2010 Free Software Foundation, Inc.
47
48
This file contains any messages produced by compilers while
49
running configure, to aid debugging if configure makes a mistake.
50
51
-It was created by wxcam $as_me 1.0.7, which was
52
+It was created by wxcam $as_me 1.1, which was
53
generated by GNU Autoconf 2.67. Invocation command line was
54
55
$ $0 $@
56
57
58
# Define the identity of the package.
59
PACKAGE=wxcam
60
- VERSION=1.0.7
61
+ VERSION=1.1
62
63
64
cat >>confdefs.h <<_ACEOF
65
66
# report actual input values of CONFIG_FILES etc. instead of their
67
# values after options handling.
68
ac_log="
69
-This file was extended by wxcam $as_me 1.0.7, which was
70
+This file was extended by wxcam $as_me 1.1, which was
71
generated by GNU Autoconf 2.67. Invocation command line was
72
73
CONFIG_FILES = $CONFIG_FILES
74
75
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
76
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
77
ac_cs_version="\\
78
-wxcam config.status 1.0.7
79
+wxcam config.status 1.1
80
configured by $0, generated by GNU Autoconf 2.67,
81
with options \\"\$ac_cs_config\\"
82
83
wxcam-1.0.7.tar.bz2/configure.ac -> wxcam-1.1.tar.bz2/configure.ac
Changed
10
1
2
dnl Process this file with autoconf to produce a configure script.
3
dnl Created by Anjuta application wizard.
4
5
-AC_INIT(wxcam, 1.0.7)
6
+AC_INIT(wxcam, 1.1)
7
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
8
9
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10
wxcam-1.0.7.tar.bz2/src/Makefile.am -> wxcam-1.1.tar.bz2/src/Makefile.am
Changed
16
1
2
tv.xpm
3
4
wxcam_LDFLAGS = \
5
- -lxvidcore\
6
- -llavjpeg\
7
- -lmjpegutils
8
+ -lxvidcore \
9
+ -llavjpeg \
10
+ -lmjpegutils \
11
+ -lX11 \
12
+ -lasound
13
14
wxcam_LDADD = \
15
\
16
wxcam-1.0.7.tar.bz2/src/Makefile.in -> wxcam-1.1.tar.bz2/src/Makefile.in
Changed
16
1
2
tv.xpm
3
4
wxcam_LDFLAGS = \
5
- -lxvidcore\
6
- -llavjpeg\
7
- -lmjpegutils
8
+ -lxvidcore \
9
+ -llavjpeg \
10
+ -lmjpegutils \
11
+ -lX11 \
12
+ -lasound
13
14
wxcam_LDADD = \
15
\
16
wxcam-1.0.7.tar.bz2/src/audio.cpp -> wxcam-1.1.tar.bz2/src/audio.cpp
Changed
170
1
2
#include <sys/ioctl.h>
3
#include <stdlib.h>
4
#include <stdio.h>
5
-#include <linux/soundcard.h>
6
#include <iostream>
7
8
Audio::Audio()
9
{
10
- end=1;
11
- device = Setting::GetInstance()->GetAudioDeviceFile();
12
+ end=1;
13
}
14
15
Audio::~Audio()
16
17
18
int Audio::Open()
19
{
20
- fd = open(device.c_str(), O_RDWR);
21
- if (fd < 0) {
22
- std::string message = "open of " + device + " failed";
23
- perror(message.c_str());
24
- return -1;
25
+ /* Open PCM device for recording (capture). */
26
+ rc = snd_pcm_open(&handle, "default",
27
+ SND_PCM_STREAM_CAPTURE, 0);
28
+ if (rc < 0) {
29
+ fprintf(stderr,
30
+ "unable to open pcm device: %s\n",
31
+ snd_strerror(rc));
32
+ return 1;
33
}
34
+
35
return 0;
36
}
37
38
-int Audio::startAcquisition(int channels, int rate, int sampleSize)
39
+int Audio::startAcquisition(int channels, int rate)
40
{
41
- int arg;
42
- int status;
43
- arg = sampleSize;
44
- status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
45
- if (status == -1)
46
- perror("SOUND_PCM_WRITE_BITS ioctl failed");
47
- if (arg != sampleSize)
48
- perror("unable to set sample size");
49
-
50
- arg = channels; /* mono or stereo */
51
- status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
52
- if (status == -1)
53
- perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
54
- if (arg != channels)
55
- perror("unable to set number of channels");
56
-
57
- arg = rate; /* sampling rate */
58
- status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
59
- if (status == -1)
60
- perror("SOUND_PCM_WRITE_WRITE ioctl failed");
61
-
62
- /*frequency: 100 Hz*/
63
- bufferSize = sampleSize*rate*channels/800;
64
- buffer = new unsigned char[bufferSize];
65
- return bufferSize;
66
+ this->channels = channels;
67
+ this->rate = rate;
68
+ /* Allocate a hardware parameters object. */
69
+ snd_pcm_hw_params_alloca(¶ms);
70
+
71
+ /* Fill it in with default values. */
72
+ snd_pcm_hw_params_any(handle, params);
73
+
74
+ /* Set the desired hardware parameters. */
75
+
76
+ /* Interleaved mode */
77
+ snd_pcm_hw_params_set_access(handle, params,
78
+ SND_PCM_ACCESS_RW_INTERLEAVED);
79
+
80
+ /* Signed 16-bit little-endian format */
81
+ snd_pcm_hw_params_set_format(handle, params,
82
+ SND_PCM_FORMAT_S16_LE);
83
+
84
+ /* Two channels (stereo) */
85
+ snd_pcm_hw_params_set_channels(handle, params, channels);
86
+
87
+ /* 44100 bits/second sampling rate (CD quality) */
88
+ val = rate;
89
+ snd_pcm_hw_params_set_rate_near(handle, params,
90
+ &val, &dir);
91
+
92
+ /* Set period size to 32 frames. */
93
+ frames = 32;
94
+ snd_pcm_hw_params_set_period_size_near(handle,
95
+ params, &frames, &dir);
96
+
97
+ /* Write the parameters to the driver */
98
+ rc = snd_pcm_hw_params(handle, params);
99
+ if (rc < 0) {
100
+ fprintf(stderr,
101
+ "unable to set hw parameters: %s\n",
102
+ snd_strerror(rc));
103
+ exit(1);
104
+ }
105
+
106
+ /* Use a buffer large enough to hold one period */
107
+ snd_pcm_hw_params_get_period_size(params,
108
+ &frames, &dir);
109
+ size = frames * 2 * channels; /* 2 bytes/sample, 2 channels */
110
+ buffer = (unsigned char *) malloc(size);
111
+
112
+ snd_pcm_hw_params_get_period_time(params,
113
+ &val, &dir);
114
+ return size;
115
}
116
117
void* Audio::Entry()
118
-{
119
- int status;
120
- while (true) {
121
- status = read(fd, buffer, bufferSize); /* record some sound */
122
+{
123
+ while (true) {
124
+ rc = snd_pcm_readi(handle, buffer, frames);
125
+ if (rc == -EPIPE) {
126
+ /* EPIPE means overrun */
127
+ fprintf(stderr, "overrun occurred\n");
128
+ snd_pcm_prepare(handle);
129
+ } else if (rc < 0) {
130
+ fprintf(stderr,
131
+ "error from read: %s\n",
132
+ snd_strerror(rc));
133
+ } else if (rc != (int) frames) {
134
+ fprintf(stderr, "short read, read %d frames\n", rc);
135
+ }
136
+
137
mutex.Lock();
138
if (!end) {
139
mutex.Unlock();
140
break;
141
}
142
- mutex.Unlock();
143
- if (status != bufferSize)
144
- perror("read wrong number of bytes");
145
- else {
146
- //printf("read %d bytes\n", bufferSize);
147
+ mutex.Unlock();
148
+
149
+ //queing frames
150
+ if (rc > 0) {
151
mutex.Lock();
152
- queue.push_back(std::string((char*)buffer, bufferSize));
153
+ queue.push_back(std::string((char*) buffer, rc * 2 * channels));
154
mutex.Unlock();
155
}
156
+
157
}
158
- status = close(fd);
159
- if(status < 0) {
160
- std::string message = "error closing " + device;
161
- perror(message.c_str());
162
- }
163
- delete [] buffer;
164
+ snd_pcm_drain(handle);
165
+ snd_pcm_close(handle);
166
+ free(buffer);
167
}
168
169
std::vector<std::string> Audio::getAudioFrames()
170
wxcam-1.0.7.tar.bz2/src/audio.h -> wxcam-1.1.tar.bz2/src/audio.h
Changed
45
1
2
***************************************************************************/
3
4
#include <wx/thread.h>
5
+#include <alsa/asoundlib.h>
6
#include <string>
7
#include <vector>
8
9
10
~Audio();
11
12
int Open();
13
- int startAcquisition(int channels = 1, int rate = 44100, int sampleSize = 16);
14
+ int startAcquisition(int channels = 2, int rate = 44100);
15
void stopAcquisition();
16
std::vector<std::string> getAudioFrames();
17
18
private:
19
void *Entry();
20
21
-private:
22
- std::string device;
23
- unsigned char *buffer;
24
- int bufferSize;
25
+private:
26
+ unsigned char *buffer;
27
int end;
28
std::vector<std::string> queue;
29
wxMutex mutex;
30
- int fps;
31
+
32
int channels;
33
int rate;
34
int sampleSize;
35
- int fd;
36
-
37
+ int rc;
38
+ int size;
39
+ snd_pcm_t *handle;
40
+ snd_pcm_hw_params_t *params;
41
+ unsigned int val;
42
+ int dir;
43
+ snd_pcm_uframes_t frames;
44
};
45
wxcam-1.0.7.tar.bz2/src/avi.h -> wxcam-1.1.tar.bz2/src/avi.h
Changed
10
1
2
3
class wxWindow;
4
5
-class Avi
6
+class Avi : public wxThread
7
{
8
public:
9
Avi() {dimFreeMem = 0;}
10
wxcam-1.0.7.tar.bz2/src/ccvt.c -> wxcam-1.1.tar.bz2/src/ccvt.c
Changed
28
1
2
3
}
4
5
-
6
void mjpegtoyuv420p(const unsigned char *src, unsigned char *dst,
7
int width, int height, unsigned int size) {
8
9
uint8_t *yuv[3];
10
unsigned char *y, *u, *v;
11
int loop;
12
-
13
+ static int interlaced = 0;
14
+
15
yuv[0] = malloc(width * height * sizeof(yuv[0][0]));
16
yuv[1] = malloc(width * height / 4 * sizeof(yuv[1][0]));
17
yuv[2] = malloc(width * height / 4 * sizeof(yuv[2][0]));
18
19
- decode_jpeg_raw((unsigned char*)src, size, 0, 420, width, height, yuv[0], yuv[1], yuv[2]);
20
+ int ret = decode_jpeg_raw((unsigned char*)src, size, interlaced, 420, width, height, yuv[0], yuv[1], yuv[2]);
21
+ if(ret) {
22
+ interlaced = 1;
23
+ decode_jpeg_raw((unsigned char*)src, size, interlaced, 420, width, height, yuv[0], yuv[1], yuv[2]);
24
+ }
25
26
y=dst;
27
u=y+width*height;
28
wxcam-1.0.7.tar.bz2/src/ccvt.h -> wxcam-1.1.tar.bz2/src/ccvt.h
Changed
10
1
2
void ccvt_uyvy_bgr24(int width, int height, const void *const src, void *const dst);
3
4
/*taken from motion sources*/
5
-void mjpegtoyuv420p(const unsigned char *src, unsigned char *dst,
6
+void mjpegtoyuv420p(const unsigned char *src, unsigned char *dst,
7
int width, int height, unsigned int size);
8
int sonix_decompress(unsigned char *outp, unsigned char *inp, int width, int height);
9
void bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height);
10
wxcam-1.0.7.tar.bz2/src/configure.cpp -> wxcam-1.1.tar.bz2/src/configure.cpp
Changed
114
1
2
strAviFormat[0] = _("&none (uncompressed)");
3
strAviFormat[1] = _("&xvid");
4
5
- aviFormat = new wxRadioBox(panel, ID_AVI_FORMAT, _("&Choose recording compression:"),
6
+ aviFormat = new wxRadioBox(panel, ID_AVI_FORMAT, _("&Choose compression:"),
7
wxDefaultPosition, wxSize(220, 80), 2, strAviFormat);
8
hSizer->Add(aviFormat, 0, wxGROW|wxALL, 10);
9
10
11
12
vSizer->Add(hSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 10);
13
14
- audio = new wxCheckBox(panel, ID_AUDIO, _("Enable audio recording (xvid only)") );
15
+ /*audio = new wxCheckBox(panel, ID_AUDIO, _("Enable audio recording (xvid only)") );
16
vSizer->Add(audio, wxGROW|wxALL, 15);
17
18
wxArrayString validValues = fillValidValues(wxString("dsp*", wxConvUTF8));
19
20
21
vSizer->Add(textAudioDevice, 0, wxALIGN_CENTER|wxALL, 5);
22
vSizer->Add(comboAudioDevice, 0, wxALIGN_CENTER|wxBOTTOM, 15);
23
-
24
+ */
25
silenceBox = new wxStaticBox(panel, wxID_ANY, _("Add silence for synchronization reason:"), wxDefaultPosition, wxSize(220, 80));
26
wxSizer *sSizer = new wxStaticBoxSizer(silenceBox, wxVERTICAL);
27
vSizer->Add(sSizer, 0, wxGROW|wxALL, 10);
28
29
textUnit = new wxStaticText(panel, -1, _("(hundredths of a second)"));
30
vSizer->Add(textUnit, wxGROW|wxALL, 15);
31
32
- boxSizer->Add(vSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 10);
33
+ boxSizer->Add(vSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 10);
34
35
- if(Setting::GetInstance()->GetAudioEnabled())
36
- audio->SetValue(true);
37
- else {
38
- audio->SetValue(false);
39
- silenceBox->Enable(false);
40
- comboAudioDevice->Enable(false);
41
- textAudioDevice->Enable(false);
42
- textUnit->Enable(false);
43
- hundredthsSlider->Enable(false);
44
- }
45
-
46
if((Setting::GetInstance()->GetCompression() == "none")) {
47
aviFormat->SetSelection(0);
48
staticCompressionLevelBox->Enable(false);
49
qualitySlider->Enable(false);
50
- comboAudioDevice->Enable(false);
51
- audio->Enable(false);
52
+ //comboAudioDevice->Enable(false);
53
+ //audio->Enable(false);
54
silenceBox->Enable(false);
55
textUnit->Enable(false);
56
- textAudioDevice->Enable(false);
57
+ //textAudioDevice->Enable(false);
58
hundredthsSlider->Enable(false);
59
}
60
else
61
62
std::string oldDevice = Setting::GetInstance()->GetDeviceFile();
63
std::string oldV4LAPI = Setting::GetInstance()->GetDriverAPI();
64
std::string oldFrameFormat = Setting::GetInstance()->GetFrameFormat();
65
- Setting::GetInstance()->SetDeviceFile((const char*)combo->GetValue().mb_str(wxConvUTF8));
66
- Setting::GetInstance()->SetAudioDeviceFile((const char*)comboAudioDevice->GetValue().mb_str(wxConvUTF8));
67
+ Setting::GetInstance()->SetDeviceFile((const char*)combo->GetValue().mb_str(wxConvUTF8));
68
Setting::GetInstance()->SetFrameFormat((const char*)rgbMode->GetStringSelection().mb_str(wxConvUTF8));
69
Setting::GetInstance()->SetDriverAPI((const char*)v4lVersion->GetStringSelection().mb_str(wxConvUTF8));
70
if(aviFormat->GetStringSelection() == wxString("xvid", wxConvUTF8))
71
Setting::GetInstance()->SetCompression((const char*)wxString("xvid", wxConvUTF8).mb_str(wxConvUTF8));
72
else
73
Setting::GetInstance()->SetCompression((const char*)wxString("none", wxConvUTF8).mb_str(wxConvUTF8));
74
- if(audio->IsChecked())
75
- Setting::GetInstance()->SetAudioEnabled(true);
76
- else
77
- Setting::GetInstance()->SetAudioEnabled(false);
78
+
79
+ Setting::GetInstance()->SetAudioEnabled(true);
80
Setting::GetInstance()->SetCompressionLevel(qualitySlider->GetValue());
81
Setting::GetInstance()->SetSilence(hundredthsSlider->GetValue());
82
if((oldV4LAPI != (const char*)v4lVersion->GetStringSelection().mb_str(wxConvUTF8))
83
84
{
85
if(aviFormat->GetSelection()) {
86
staticCompressionLevelBox->Enable(true);
87
- qualitySlider->Enable(true);
88
- audio->Enable(true);
89
- if(audio->IsChecked()) {
90
- silenceBox->Enable(true);
91
- comboAudioDevice->Enable(true);
92
- textUnit->Enable(true);
93
- textAudioDevice->Enable(true);
94
- hundredthsSlider->Enable(true);
95
- }
96
+ qualitySlider->Enable(true);
97
+ silenceBox->Enable(true);
98
+ textUnit->Enable(true);
99
+ hundredthsSlider->Enable(true);
100
+
101
}
102
else {
103
staticCompressionLevelBox->Enable(false);
104
- qualitySlider->Enable(false);
105
- audio->Enable(false);
106
- comboAudioDevice->Enable(false);
107
- silenceBox->Enable(false);
108
- textAudioDevice->Enable(false);
109
+ qualitySlider->Enable(false);
110
+ silenceBox->Enable(false);
111
textUnit->Enable(false);
112
hundredthsSlider->Enable(false);
113
}
114
wxcam-1.0.7.tar.bz2/src/device.cpp -> wxcam-1.1.tar.bz2/src/device.cpp
Changed
352
1
2
#include <stdio.h>
3
#include <sys/time.h>
4
#include <stdlib.h>
5
+#include <math.h>
6
#include <iostream>
7
#include <sstream>
8
+#include <linux/videodev2.h>
9
#include "errno.h"
10
#include "setting.h"
11
#include "device.h"
12
13
else {
14
cout<<"Determining video4linux API version..."<<endl;
15
struct v4l2_capability cap;
16
- if( !isPWC() && queryCapabilities(&cap) ) {
17
+ if( /*!isPWC() && */queryCapabilities(&cap) ) {
18
cout<<"Using video4linux 2 API"<<endl;
19
v4l = new VideoForLinux2();
20
isV4L2 = true;
21
22
if(isV4L2) {
23
struct v4l2_frmsizeenum frmsize;
24
memset(&frmsize, 0, sizeof(struct v4l2_frmsizeenum));
25
- if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) {
26
+ /*if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) {
27
perror( "VIDIOC_ENUM_FRAMESIZES" );
28
isV4L2 = false; // I will get resolution in v4l1 way
29
- }
30
+ }*/
31
}
32
33
if( !width || !height ) { //setting max resolution
34
35
Setting::GetInstance()->SetResolution(s.str());
36
}
37
else {
38
- int maxW, maxH;
39
- struct v4l2_frmsizeenum frmsize;
40
- memset(&frmsize, 0, sizeof(struct v4l2_frmsizeenum));
41
- if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) {
42
- perror( "VIDIOC_ENUM_FRAMESIZES" );
43
- return false;
44
+ int maxW = -1, maxH = -1;
45
+ int resw, resh;
46
+ struct v4l2_format fmt;
47
+
48
+ std::stringstream ss;
49
+ std::string str;
50
+
51
+ resw = 160;
52
+ resh = 120;
53
+
54
+ while (resw < 3000) {
55
+ memset(&fmt, 0, sizeof (struct v4l2_format));
56
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
57
+
58
+ fmt.fmt.pix.width = resw;
59
+ fmt.fmt.pix.height = resh;
60
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
61
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat();
62
+
63
+ if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) {
64
+ perror("VIDIOC_TRY_FMT");
65
+ printf("Resolution %dx%d not valid\n", resw, resh);
66
+ } else {
67
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
68
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
69
+ maxW = resw;
70
+ maxH = resh;
71
+ }
72
+ }
73
+ resh = resh * 1.5;
74
+ resw = resh * 4 / (float) 3;
75
}
76
- maxW = frmsize.discrete.width;
77
- maxH = frmsize.discrete.height;
78
- frmsize.index++;
79
- while(!ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) {
80
- if(maxW < frmsize.discrete.width) {
81
- maxW = frmsize.discrete.width;
82
- maxH = frmsize.discrete.height;
83
+
84
+ resw = 160;
85
+ resh = 120;
86
+
87
+ while (resw < 3000) {
88
+ memset(&fmt, 0, sizeof (struct v4l2_format));
89
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
90
+
91
+ fmt.fmt.pix.width = resw;
92
+ fmt.fmt.pix.height = resh;
93
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
94
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat();
95
+
96
+ if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) {
97
+ perror("VIDIOC_TRY_FMT");
98
+ printf("Resolution %dx%d not valid\n", resw, resh);
99
+ } else {
100
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
101
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
102
+ maxW = resw;
103
+ maxH = resh;
104
+ }
105
+ }
106
+ resh = resh * 2;
107
+ resw = resh * 4 / (float) 3;
108
+ }
109
+
110
+
111
+ resw = 160;
112
+ resh = 90;
113
+
114
+ while (resw < 3000) {
115
+ memset(&fmt, 0, sizeof (struct v4l2_format));
116
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
117
+
118
+ fmt.fmt.pix.width = resw;
119
+ fmt.fmt.pix.height = resh;
120
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
121
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat();
122
+
123
+ if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) {
124
+ perror("VIDIOC_TRY_FMT");
125
+ printf("Resolution %dx%d not valid\n", resw, resh);
126
+ } else {
127
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
128
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
129
+ maxW = resw;
130
+ maxH = resh;
131
+ }
132
+ }
133
+ resh = resh * 1.5;
134
+ resw = resh * 16 / (float) 9;
135
+ }
136
+
137
+ resw = 160;
138
+ resh = 90;
139
+
140
+ while (resw < 3000) {
141
+ memset(&fmt, 0, sizeof (struct v4l2_format));
142
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
143
+
144
+ fmt.fmt.pix.width = resw;
145
+ fmt.fmt.pix.height = resh;
146
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
147
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat();
148
+
149
+ if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) {
150
+ perror("VIDIOC_TRY_FMT");
151
+ printf("Resolution %dx%d not valid\n", resw, resh);
152
+ } else {
153
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
154
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
155
+ maxW = resw;
156
+ maxH = resh;
157
+ }
158
}
159
- frmsize.index++;
160
- }
161
+ resh = resh * 2;
162
+ resw = resh * 16 / (float) 9;
163
+ }
164
ostringstream s;
165
- s<<maxW<<"x"<<maxH;
166
- Setting::GetInstance()->SetResolution(s.str());
167
+ if(maxW == -1) {
168
+ s<<640<<"x"<<480;
169
+ Setting::GetInstance()->SetResolution(s.str());
170
+
171
+ width = 640;
172
+ height = 480;
173
+
174
+ } else {
175
+ s<<maxW<<"x"<<maxH;
176
+ Setting::GetInstance()->SetResolution(s.str());
177
+
178
+ width = maxW;
179
+ height = maxH;
180
+ }
181
}
182
}
183
184
185
bool Device::mMap(int w, int h)
186
{
187
if(v4l)
188
- return v4l->mMap(w, h);
189
+ return v4l->mMap(w, h, 0);
190
else
191
return false;
192
}
193
194
195
bool Device::queryCapabilities( struct video_capability *caps ) /*VIDIOCGCAP*/
196
{
197
- if ( ioctl( fd, VIDIOCGCAP, caps ) <0 ) {
198
- perror( "VIDIOCGCAP" );
199
+ if (ioctl(fd, VIDIOCGCAP, caps) < 0) {
200
+ perror("VIDIOCGCAP");
201
+ /*v4l2_capability v2caps;
202
+ if (ioctl(fd, VIDIOC_QUERYCAP, &v2caps) == -1) {
203
+ if (EINVAL == errno) {
204
+ return false;
205
+ }
206
+ else {
207
+ perror("VIDIOC_QUERYCAP");
208
+ return false;
209
+ }
210
+ }
211
+ strcpy(caps->name, (char*)(v2caps.card));*/
212
return false;
213
}
214
return true;
215
216
}
217
}
218
else {
219
- struct v4l2_frmsizeenum frmsize;
220
+ /*struct v4l2_frmsizeenum frmsize;
221
memset(&frmsize, 0, sizeof(struct v4l2_frmsizeenum));
222
if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) {
223
perror( "VIDIOC_ENUM_FRAMESIZES" );
224
225
str = ss.str();
226
validResolution.Add( wxString(str.c_str(), wxConvUTF8) );
227
frmsize.index++;
228
+ }*/
229
+ int resw, resh;
230
+ struct v4l2_format fmt;
231
+
232
+ std::stringstream ss;
233
+ std::string str;
234
+
235
+ resw = 160;
236
+ resh = 120;
237
+
238
+ while(resw < 3000) {
239
+ memset(&fmt, 0, sizeof(struct v4l2_format));
240
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
241
+
242
+ fmt.fmt.pix.width = resw;
243
+ fmt.fmt.pix.height = resh;
244
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
245
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat();
246
+
247
+ if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) {
248
+ perror("VIDIOC_TRY_FMT");
249
+ printf("Resolution %dx%d not valid\n", resw, resh);
250
+ } else {
251
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
252
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
253
+ ss.str("");
254
+ ss << resw << "x" << resh;
255
+ str = ss.str();
256
+ validResolution.Add(wxString(str.c_str(), wxConvUTF8));
257
+ }
258
+ }
259
+ resh = resh * 1.5;
260
+ resw = resh * 4 / (float)3;
261
}
262
- }
263
+
264
+ resw = 160;
265
+ resh = 120;
266
+
267
+ while(resw < 3000) {
268
+ memset(&fmt, 0, sizeof(struct v4l2_format));
269
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
270
+
271
+ fmt.fmt.pix.width = resw;
272
+ fmt.fmt.pix.height = resh;
273
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
274
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat();
275
+
276
+ if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) {
277
+ perror("VIDIOC_TRY_FMT");
278
+ printf("Resolution %dx%d not valid\n", resw, resh);
279
+ } else {
280
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
281
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
282
+ ss.str("");
283
+ ss << resw << "x" << resh;
284
+ str = ss.str();
285
+ validResolution.Add(wxString(str.c_str(), wxConvUTF8));
286
+ }
287
+ }
288
+ resh = resh * 2;
289
+ resw = resh * 4 / (float)3;
290
+ }
291
+
292
+
293
+ resw = 160;
294
+ resh = 90;
295
+
296
+ while(resw < 3000) {
297
+ memset(&fmt, 0, sizeof(struct v4l2_format));
298
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
299
+
300
+ fmt.fmt.pix.width = resw;
301
+ fmt.fmt.pix.height = resh;
302
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
303
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat();
304
+
305
+ if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) {
306
+ perror("VIDIOC_TRY_FMT");
307
+ printf("Resolution %dx%d not valid\n", resw, resh);
308
+ } else {
309
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
310
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
311
+ ss.str("");
312
+ ss << resw << "x" << resh;
313
+ str = ss.str();
314
+ validResolution.Add(wxString(str.c_str(), wxConvUTF8));
315
+ }
316
+ }
317
+ resh = resh * 1.5;
318
+ resw = resh * 16 / (float)9;
319
+ }
320
+
321
+ resw = 160;
322
+ resh = 90;
323
+
324
+ while(resw < 3000) {
325
+ memset(&fmt, 0, sizeof(struct v4l2_format));
326
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
327
+
328
+ fmt.fmt.pix.width = resw;
329
+ fmt.fmt.pix.height = resh;
330
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
331
+ fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat();
332
+
333
+ if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) {
334
+ perror("VIDIOC_TRY_FMT");
335
+ printf("Resolution %dx%d not valid\n", resw, resh);
336
+ } else {
337
+ if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) {
338
+ printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
339
+ ss.str("");
340
+ ss << resw << "x" << resh;
341
+ str = ss.str();
342
+ validResolution.Add(wxString(str.c_str(), wxConvUTF8));
343
+ }
344
+ }
345
+ resh = resh * 2;
346
+ resw = resh * 16 / (float)9;
347
+ }
348
+ }
349
}
350
351
bool Device::getGain( int *agc ) /* VIDIOCPWCGAGC*/
352
wxcam-1.0.7.tar.bz2/src/device.h -> wxcam-1.1.tar.bz2/src/device.h
Changed
13
1
2
#include <unistd.h>
3
#include <fcntl.h>
4
#include <sys/mman.h>
5
+#ifdef HAVE_CAMV4L
6
#include <linux/videodev.h>
7
+#else
8
+#include <libv4l1-videodev.h>
9
+#endif
10
#include <sys/ioctl.h>
11
#include <sys/types.h>
12
#include <sys/stat.h>
13
wxcam-1.0.7.tar.bz2/src/frame.cpp -> wxcam-1.1.tar.bz2/src/frame.cpp
Changed
40
1
2
//if ( !cam.isPWC() )
3
freq = assessFrequency;
4
rec->setParameters( this, filename, freq, width, height );
5
- if(compression == "none") {
6
- if ( static_cast<AviUncompressed*>(rec)->Create() != wxTHREAD_NO_ERROR ) {
7
- wxLogError( _( "Cannot create video recording thread!" ) );
8
- return;
9
- }
10
11
- static_cast<AviUncompressed*>(rec)->Run();
12
+ if ((rec)->Create() != wxTHREAD_NO_ERROR) {
13
+ wxLogError(_("Cannot create video recording thread!"));
14
+ return;
15
}
16
+ rec->Run();
17
18
- if( rec->setup() ) {
19
+ if( rec->setup() ) {
20
rstatus = REC_NONE;
21
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, STOP_REC );
22
event.SetInt(1);
23
24
} else {
25
rstatus = REC_CONTINUING;
26
}
27
+
28
}
29
else if ( rstatus == REC_CONTINUING ) {
30
wxDateTime now = wxDateTime::UNow();
31
32
int freq=0;
33
if( cam.isPWC() )
34
freq=atoi(frameRate.c_str());
35
+ else
36
+ freq = 0;
37
if ( !cam.setResolution( w, h, freq ) && deviceOpen ) {
38
wxMessageBox( _( "Frame rate/resolution setting not supported.\nPlease try a lower frame rate o resolution." ), _( "Error applying settings" ), wxICON_WARNING );
39
return false;
40
wxcam-1.0.7.tar.bz2/src/uncompressed.h -> wxcam-1.1.tar.bz2/src/uncompressed.h
Changed
10
1
2
typedef char byte;
3
class wxWindow;
4
5
-class AviUncompressed : public Avi, public wxThread
6
+class AviUncompressed : public Avi
7
{
8
public:
9
AviUncompressed();
10
wxcam-1.0.7.tar.bz2/src/v4l.h -> wxcam-1.1.tar.bz2/src/v4l.h
Changed
22
1
2
#include <unistd.h>
3
#include <fcntl.h>
4
#include <sys/mman.h>
5
+#ifdef HAVE_CAMV4L
6
#include <linux/videodev.h>
7
+#else
8
+#include <libv4l1-videodev.h>
9
+#endif
10
#include <sys/ioctl.h>
11
#include <sys/types.h>
12
#include <sys/stat.h>
13
14
this->adjustColors=adjustColors;
15
}
16
17
- virtual bool mMap(int w, int h) = 0;
18
+ virtual bool mMap(int w, int h, int frameRate=0) = 0;
19
virtual bool getFrame(char **buffer) = 0;
20
virtual bool setResolution(unsigned int width, unsigned int height, unsigned int frameRate=0) = 0;
21
virtual bool getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate) = 0;
22
wxcam-1.0.7.tar.bz2/src/v4l1.cpp -> wxcam-1.1.tar.bz2/src/v4l1.cpp
Changed
13
1
2
munmap( NULL, mmap_size );
3
}
4
5
-bool VideoForLinux1::mMap(int w, int h)
6
-{
7
+bool VideoForLinux1::mMap(int w, int h, int frameRate)
8
+{
9
+ frameRate = 0; //ignored
10
memset(&v, 0, sizeof(struct video_mmap));
11
v.format=frameFormat;
12
v.width=w; // from 32 to 924 (sometimes limited to 768)
13
wxcam-1.0.7.tar.bz2/src/v4l1.h -> wxcam-1.1.tar.bz2/src/v4l1.h
Changed
10
1
2
VideoForLinux1();
3
~VideoForLinux1();
4
5
- bool mMap(int w, int h);
6
+ bool mMap(int w, int h, int frameRate=0);
7
bool getFrame(char **buffer);
8
bool setResolution(unsigned int width, unsigned int height, unsigned int frameRate=0);
9
bool getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate);
10
wxcam-1.0.7.tar.bz2/src/v4l2.cpp -> wxcam-1.1.tar.bz2/src/v4l2.cpp
Changed
108
1
2
#include <wx/image.h>
3
#include <iostream>
4
5
+#include "pwc-ioctl.h"
6
+
7
VideoForLinux2::VideoForLinux2()
8
{
9
dev_name = Setting::GetInstance()->GetDeviceFile();
10
11
free(buffers);
12
}
13
14
-bool VideoForLinux2::mMap(int w, int h) {
15
+bool VideoForLinux2::mMap(int w, int h, int frameRate) {
16
struct v4l2_cropcap cropcap;
17
struct v4l2_crop crop;
18
struct v4l2_format fmt;
19
20
pixelFormat = V4L2_PIX_FMT_SBGGR8;
21
std::cout<<"Found V4L2_PIX_FMT_SBGGR8 pixel format"<<std::endl;
22
}
23
+ else if(argp.pixelformat == V4L2_PIX_FMT_SBGGR16) {
24
+ fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR16;
25
+ pixelFormat = V4L2_PIX_FMT_SBGGR16;
26
+ std::cout<<"Found V4L2_PIX_FMT_SBGGR16 pixel format"<<std::endl;
27
+ }
28
+ else if(argp.pixelformat == V4L2_PIX_FMT_SGBRG8) {
29
+ fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGBRG8;
30
+ pixelFormat = V4L2_PIX_FMT_SGBRG8;
31
+ std::cout<<"Found V4L2_PIX_FMT_SGBRG8 pixel format"<<std::endl;
32
+ }
33
+ else if(argp.pixelformat == V4L2_PIX_FMT_SGRBG8) {
34
+ fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGRBG8;
35
+ pixelFormat = V4L2_PIX_FMT_SGRBG8;
36
+ std::cout<<"Found V4L2_PIX_FMT_SGRBG8 pixel format"<<std::endl;
37
+ }
38
+ else if(argp.pixelformat == V4L2_PIX_FMT_SPCA561) {
39
+ fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SPCA561;
40
+ pixelFormat = V4L2_PIX_FMT_SPCA561;
41
+ std::cout<<"Found V4L2_PIX_FMT_SPCA561 pixel format"<<std::endl;
42
+ }
43
else if(argp.pixelformat == V4L2_PIX_FMT_BGR24) {
44
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24;
45
pixelFormat = V4L2_PIX_FMT_BGR24;
46
47
fmt.fmt.pix.width = w;
48
fmt.fmt.pix.height = h;
49
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
50
+
51
+ //setting frame rate
52
+ if(frameRate) {
53
+
54
+ /*
55
+ //many cams doesn't support these calls
56
+ v4l2_streamparm parm;
57
+
58
+ if (ioctl (fd, VIDIOC_G_PARM, &parm) == -1) {
59
+ perror("VIDIOC_G_PARM");
60
+ }
61
+
62
+ parm.parm.capture.timeperframe.numerator = 1;
63
+ parm.parm.capture.timeperframe.denominator = frameRate;
64
+
65
+ if (ioctl (fd, VIDIOC_S_PARM, &parm) == -1) {
66
+ perror("VIDIOC_S_PARM");
67
+ }
68
+ */
69
+
70
+ fmt.fmt.pix.priv &= ~PWC_FPS_FRMASK;
71
+ fmt.fmt.pix.priv |= ( frameRate << PWC_FPS_SHIFT );
72
+ }
73
74
/*enum v4l2_buf_type type;
75
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
76
77
bayer2rgb24(( unsigned char* ) *buffer, tmp_buffer, width, height);
78
free(tmp_buffer);
79
}
80
- else if(pixelFormat == V4L2_PIX_FMT_SBGGR8) {
81
+ else if(pixelFormat == V4L2_PIX_FMT_SBGGR8 ||
82
+ pixelFormat == V4L2_PIX_FMT_SBGGR16 ||
83
+ pixelFormat == V4L2_PIX_FMT_SGBRG8 ||
84
+ pixelFormat == V4L2_PIX_FMT_SPCA561 ||
85
+ pixelFormat == V4L2_PIX_FMT_SGRBG8) {
86
bayer2rgb24(( unsigned char* ) *buffer, ( unsigned char* ) buffers[buf.index].start, width, height);
87
}
88
else if(pixelFormat == V4L2_PIX_FMT_BGR24 || pixelFormat == V4L2_PIX_FMT_SN9C10X
89
90
91
bool VideoForLinux2::setResolution(unsigned int width, unsigned int height, unsigned int frameRate)
92
{
93
- frameRate=0; /*avoiding warning*/
94
- return mMap(width, height);
95
+ //frameRate=0; /*avoiding warning*/
96
+ return mMap(width, height, frameRate);
97
}
98
99
bool VideoForLinux2::getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate)
100
101
}
102
width = fmt.fmt.pix.width;
103
height = fmt.fmt.pix.height;
104
+ frameRate = ( fmt.fmt.pix.priv & PWC_FPS_FRMASK ) >> PWC_FPS_SHIFT;
105
printf("width: %d, height %d\n", width, height);
106
return true;
107
}
108
wxcam-1.0.7.tar.bz2/src/v4l2.h -> wxcam-1.1.tar.bz2/src/v4l2.h
Changed
22
1
2
~VideoForLinux2();
3
4
void closeDevice();
5
- bool mMap(int w, int h);
6
+ bool mMap(int w, int h, int frameRate=0);
7
bool getFrame(char **buffer);
8
bool setResolution(unsigned int width, unsigned int height, unsigned int frameRate=0);
9
bool getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate);
10
11
bool setSaturation(unsigned int value);
12
bool getSaturation(unsigned int &value);
13
bool setVideoStd(video_std std);
14
+
15
+ int getPixelFormat() {return pixelFormat;}
16
17
-private:
18
+private:
19
bool init_mmap();
20
void setControls();
21
void enumerateMenu(struct v4l2_queryctrl &queryctrl, struct v4l2_querymenu querymenu);
22
wxcam-1.0.7.tar.bz2/src/wxcam.cpp -> wxcam-1.1.tar.bz2/src/wxcam.cpp
Changed
136
1
2
#include <wx/aboutdlg.h>
3
#include <wx/thread.h>
4
5
+#include <linux/videodev2.h>
6
#include "device.h"
7
#include <iostream>
8
#include <sstream>
9
10
Setting::GetInstance()->SetAlreadyOpen();
11
struct video_capability caps;
12
struct video_picture pic;
13
- cam.queryCapabilities( &caps );
14
- wxString msg = _( "Device found in your system: " ) + wxString( "\n", wxConvUTF8 );
15
- msg += wxString(caps.name, wxConvUTF8);
16
+ wxString msg;
17
+ if(cam.queryCapabilities( &caps )) {
18
+ msg = _( "Device found in your system: " ) + wxString( "\n", wxConvUTF8 );
19
+ msg += wxString(caps.name, wxConvUTF8);
20
+ } else {
21
+ struct v4l2_capability v2caps;
22
+ cam.queryCapabilities(&v2caps);
23
+ msg = _( "Device found in your system: " ) + wxString( "\n", wxConvUTF8 );
24
+ msg += wxString((char*)v2caps.card, wxConvUTF8);
25
+ }
26
wxMessageBox( msg, _( "Hardware found" ), wxICON_INFORMATION );
27
+
28
/*cam.getPictureFunctions( &pic );
29
if ( pic.palette == VIDEO_PALETTE_YUV420P || frame->isPWC() ) {
30
Setting::GetInstance()->SetFrameFormat( "YUV420P" );
31
32
wxAboutDialogInfo info;
33
34
info.SetName( _T( "wxCam" ) );
35
- info.SetVersion( wxString("1.0.7", wxConvUTF8) );
36
+ info.SetVersion( wxString("1.1", wxConvUTF8) );
37
info.SetDescription( _( "A webcam application for linux" ) );
38
- info.SetCopyright( _T( "(C) 2010 Marco Lorrai" ) );
39
+ info.SetCopyright( _T( "(C) 2011 Marco Lorrai" ) );
40
info.AddDeveloper( _T( "Marco Lorrai" ) );
41
info.AddDeveloper( _T( "Örjan Medhage" ) );
42
+ info.SetWebSite(wxT("wxcam.sourceforge.net"));
43
// we can add a second developer
44
//info.AddDeveloper(_T("A.N. Other"));
45
46
47
{
48
struct video_capability caps;
49
if ( !cam.queryCapabilities( &caps ) ) {
50
- wxMessageBox( _( "Error querying webcam capabilities.\nPerhaps the device hasn't been correctly opened." ), _( "Capabilities" ), wxICON_WARNING );
51
- return;
52
+ //Trying v4l2 query...
53
+ struct v4l2_capability v2caps;
54
+ if ( !cam.queryCapabilities( &v2caps ) ) {
55
+ wxMessageBox( _( "Error querying webcam capabilities.\nPerhaps the device hasn't been correctly opened." ), _( "Capabilities" ), wxICON_WARNING );
56
+ return;
57
+ }
58
+ std::stringstream ss;
59
+ std::string str;
60
+ ss << (const char*) wxString(_("Driver: ")).mb_str(wxConvUTF8) << v2caps.driver << "\n";
61
+
62
+ ss << (const char*) wxString(_("Card: ")).mb_str(wxConvUTF8) << v2caps.card << "\n";
63
+ str = ss.str();
64
+
65
+ ss.str("");
66
+ if (v2caps.capabilities & V4L2_CAP_AUDIO)
67
+ ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("Yes")).mb_str(wxConvUTF8) << "\n";
68
+ else
69
+ ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("No")).mb_str(wxConvUTF8) << "\n";
70
+ str += ss.str();
71
+
72
+ wxMessageBox(wxString(str.c_str(), wxConvUTF8), _("Webcam Capabilities "), wxICON_INFORMATION);
73
+ } else {
74
+ std::stringstream ss;
75
+ std::string str;
76
+
77
+ ss << (const char*) wxString(_("Name: ")).mb_str(wxConvUTF8) << caps.name << "\n";
78
+
79
+ ss << (const char*) wxString(_("Channels: ")).mb_str(wxConvUTF8) << caps.channels << "\n";
80
+ str = ss.str();
81
+
82
+ ss.str("");
83
+ if (caps.audios)
84
+ ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("Yes")).mb_str(wxConvUTF8) << "\n";
85
+ else
86
+ ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("No")).mb_str(wxConvUTF8) << "\n";
87
+ str += ss.str();
88
+
89
+ ss.str("");
90
+ ss << (const char*) wxString(_("Min resolution: ")).mb_str(wxConvUTF8) << caps.minwidth << "x" << caps.minheight << "\n";
91
+ str += ss.str();
92
+
93
+ ss.str("");
94
+ ss << (const char*) wxString(_("Max resolution: ")).mb_str(wxConvUTF8) << caps.maxwidth << "x" << caps.maxheight << "\n";
95
+ str += ss.str();
96
+
97
+ wxMessageBox(wxString(str.c_str(), wxConvUTF8), _("Webcam Capabilities "), wxICON_INFORMATION);
98
}
99
-
100
- std::stringstream ss;
101
- std::string str;
102
-
103
- ss<<(const char*)wxString( _( "Name: " ) ).mb_str(wxConvUTF8) <<caps.name<<"\n";
104
-
105
- ss<<(const char*)wxString( _( "Channels: " ) ).mb_str(wxConvUTF8) <<caps.channels<<"\n";
106
- str = ss.str();
107
-
108
- ss.str( "" );
109
- if ( caps.audios )
110
- ss<<(const char*)wxString( _( "Audio: " ) ).mb_str(wxConvUTF8) <<(const char*)wxString( _( "Yes" ) ).mb_str(wxConvUTF8) <<"\n";
111
- else
112
- ss<<(const char*)wxString( _( "Audio: " ) ).mb_str(wxConvUTF8) <<(const char*)wxString( _( "No" ) ).mb_str(wxConvUTF8) <<"\n";
113
- str += ss.str();
114
-
115
- ss.str( "" );
116
- ss<<(const char*)wxString( _( "Min resolution: " ) ).mb_str(wxConvUTF8) <<caps.minwidth<<"x"<<caps.minheight<<"\n";
117
- str += ss.str();
118
-
119
- ss.str( "" );
120
- ss<<(const char*)wxString( _( "Max resolution: " ) ).mb_str(wxConvUTF8) <<caps.maxwidth<<"x"<<caps.maxheight<<"\n";
121
- str += ss.str();
122
-
123
- wxMessageBox( wxString(str.c_str(), wxConvUTF8), _( "Webcam Capabilities " ), wxICON_INFORMATION );
124
}
125
126
void wxCam::OnPictureFunctions( wxCommandEvent& WXUNUSED( event ) )
127
128
return;
129
130
wxString valueFrameRate = resDlg->GetFrameRate();
131
+ if(!valueFrameRate.size())
132
+ valueFrameRate = wxT("10");
133
/*if ( valueFrameRate == wxString("- - -", wxConvUTF8) || valueFrameRate.empty() )
134
return;*/
135
136
wxcam-1.0.7.tar.bz2/src/xvidcodec.cpp -> wxcam-1.1.tar.bz2/src/xvidcodec.cpp
Changed
240
1
2
#include "frame.h"
3
#include "audio.h"
4
5
+#define CHANNELS 2
6
+#define RATE 44100
7
+
8
using namespace std;
9
10
-Xvid::Xvid()
11
+Xvid::Xvid() : cond(mutex)
12
{
13
frameNumber=0;
14
audioFramesRecorded=0;
15
compression=0.5f;
16
audio=NULL;
17
ignoreVideo = false;
18
+ endRecord = false;
19
+ max=0;
20
}
21
22
Xvid::~Xvid()
23
24
}
25
26
void Xvid::addFrame(const char* frame)
27
-{
28
- bool videoIgnored = ignoreVideo;
29
-
30
+{
31
if(!frameNumber) {
32
if(hasAudio) {
33
- audioBufferSize = audio->startAcquisition();
34
+ audioBufferSize = audio->startAcquisition(CHANNELS, RATE);
35
if (audio->Create() != wxTHREAD_NO_ERROR ) {
36
cout<<"Can't create audio recording thread!";
37
return;
38
39
addSilence(Setting::GetInstance()->GetSilence());
40
}
41
}
42
-
43
- if(!ignoreVideo) {
44
- memcpy4( (char*)revelFrame.pixels, frame, width*height*4 );
45
- revError = Revel_EncodeFrame(encoderHandle, &revelFrame, &frameSize);
46
+
47
+ mutex.Lock();
48
+ queue.push_back(std::string(frame, frameSize));
49
+
50
+ /*revError = Revel_EncodeFrame(encoderHandle, &revelFrame, &frameSize);
51
if (revError != REVEL_ERR_NONE)
52
- printf("Revel Error while writing frame: %d\n", revError);
53
- }
54
+ printf("Revel Error while writing frame: %d\n", revError);*/
55
+
56
57
/*encoding audio*/
58
- int totalAudioBytes;
59
- if(frameNumber && hasAudio) {
60
- /*sync calculation*/
61
- double recDuration = (double)frameNumber/(double)fps;
62
- int audioFrame = (int)((double)100/(double)fps*frameNumber);
63
- audioFrame -= audioFramesRecorded;
64
+ if(hasAudio) {
65
std::vector<std::string> vectAudio = audio->getAudioFrames();
66
- int size = vectAudio.size();
67
- if(audioFrame > size * 2)
68
- ignoreVideo = true;
69
- else
70
- ignoreVideo = false;
71
- int frameToIgnore = size - audioFrame;
72
- /*if (frameToIgnore > 0)
73
- printf("Video frame %d: ignoring %d audio frames\n", frameNumber, frameToIgnore);
74
- else
75
- printf("Video frame %d: no frames to ignore: %d\n", frameNumber, frameToIgnore);*/
76
- //printf("Encoding %d audio frames\n", size);
77
- float mean = 0.0;
78
- if(frameToIgnore > 0)
79
- mean = (float)size/((float)frameToIgnore + 1);
80
-
81
- /*encoding frames*/
82
- int ignoredFrames = 0;
83
+ audio_queue.push_back(vectAudio);
84
+ /*int size = vectAudio.size();
85
std::vector<std::string>::iterator it = vectAudio.begin();
86
- for(int i=1; i<=size; i++) {
87
- if((ignoredFrames) < frameToIgnore) {
88
- if(i == (int)(mean*(ignoredFrames + 1) + 0.5)) {
89
- //printf("Frame ignored\n");
90
- ++it;
91
- ignoredFrames++;
92
- continue;
93
- }
94
- }
95
+ for(int i=1; i<=size; i++) {
96
std::string buffer = *it;
97
++it;
98
audioFramesRecorded++;
99
- revError = Revel_EncodeAudio(encoderHandle, (void*)buffer.c_str(), audioBufferSize, &totalAudioBytes);
100
+ revError = Revel_EncodeAudio(encoderHandle, (void*)buffer.c_str(), buffer.size(), &totalAudioBytes);
101
if (revError != REVEL_ERR_NONE) {
102
printf("Revel Error while writing audio: %d\n", revError);
103
+ }
104
+ }
105
+ */
106
+
107
+ }
108
+ cond.Signal();
109
+ mutex.Unlock();
110
+ frameNumber++;
111
+}
112
+
113
+void* Xvid::Entry() {
114
+ while(true) {
115
+ mutex.Lock();
116
+ while( (!queue.size() || !audio_queue.size())&& !endRecord)
117
+ cond.Wait();
118
+ //cout<<"Queue size: "<<queue_size<<endl<<flush;
119
+ if(endRecord && (!queue.size() || !audio_queue.size())) { //registration terminated
120
+ mutex.Unlock();
121
+
122
+ break;
123
+ }
124
+
125
+ string videoFrame = queue.front();
126
+ queue.pop_front();
127
+ vector<string> audioFrames;
128
+ if(hasAudio) {
129
+ audioFrames = audio_queue.front();
130
+ audio_queue.pop_front();
131
+ }
132
+
133
+ //max not yet initialize, first execution after calling record()
134
+ if(endRecord && !max) {
135
+ max = queue.size();
136
+ if(max > 10) {
137
+ wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, PROGRESS_DIALOG_START );
138
+ wxPostEvent( parent, event );
139
}
140
- //else
141
- // printf("Audio encoded\n");
142
- }
143
+ else
144
+ max=-1;
145
+ }
146
+
147
+ //max already initialized
148
+ if(endRecord && max > 0) {
149
+ wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, PROGRESS_DIALOG_EVENT );
150
+ int n = (int)(((float)max - (float)queue.size()) / (float)max * 100);
151
+ event.SetInt( n );
152
+
153
+ // send in a thread-safe way
154
+ wxPostEvent( parent, event );
155
+ }
156
+
157
+ mutex.Unlock();
158
+
159
+ int frameSize;
160
+ const char* frame = videoFrame.c_str();
161
+ //writing frame...
162
+ memcpy4( (char*)revelFrame.pixels, frame, width*height*4 );
163
+ revError = Revel_EncodeFrame(encoderHandle, &revelFrame, &frameSize);
164
+ if (revError != REVEL_ERR_NONE)
165
+ printf("Revel Error while writing frame: %d\n", revError);
166
+
167
+ if (hasAudio) {
168
+ int totalAudioBytes;
169
+ int size = audioFrames.size();
170
+ std::vector<std::string>::iterator it = audioFrames.begin();
171
+ for (int i = 1; i <= size; i++) {
172
+ std::string buffer = *it;
173
+ ++it;
174
+ audioFramesRecorded++;
175
+ revError = Revel_EncodeAudio(encoderHandle, (void*) buffer.c_str(), audioBufferSize, &totalAudioBytes);
176
+ if (revError != REVEL_ERR_NONE) {
177
+ printf("Revel Error while writing audio: %d\n", revError);
178
+ }
179
+ //printf("Recorded %d audio frames total\n", size);
180
+ }
181
+ }
182
}
183
+ if(max > 0) {
184
+ wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, PROGRESS_DIALOG_EVENT );
185
186
- if(!videoIgnored) {
187
- frameNumber++;
188
+ event.SetInt(-1); // that's all
189
+ wxPostEvent( parent, event );
190
}
191
+ wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, STOP_REC );
192
+ event.SetInt(0);
193
+ wxPostEvent( parent, event );
194
+ return NULL;
195
}
196
197
bool Xvid::checkAudio(Revel_Params *revParams)
198
{
199
int ret;
200
201
- hasAudio = Setting::GetInstance()->GetAudioEnabled();
202
+ hasAudio = true;
203
204
if (hasAudio) {
205
audio = new Audio();
206
207
event.SetInt(1);
208
wxPostEvent(parent, event);
209
audio->Delete();
210
+ audio = NULL;
211
} else {
212
- revParams->audioChannels = 1;
213
- revParams->audioRate = 44100;
214
+ revParams->audioChannels = CHANNELS;
215
+ revParams->audioRate = RATE;
216
revParams->audioBits = 16;
217
revParams->audioSampleFormat = REVEL_ASF_PCM;
218
}
219
220
void Xvid::record()
221
{
222
/*stopping audio acquisition*/
223
- if(hasAudio)
224
+ if(hasAudio) {
225
audio->stopAcquisition();
226
+ audio->Wait();
227
+ }
228
229
int totalSize;
230
revError = Revel_EncodeEnd(encoderHandle, &totalSize);
231
232
233
void Xvid::addSilence(int hundredthsSecond)
234
{
235
- int audioBufferSize = hundredthsSecond*882;
236
+ int audioBufferSize = hundredthsSecond*882*CHANNELS; //2 is the number of channels;
237
int totalAudioBytes;
238
char* buffer = new char[audioBufferSize];
239
memset(buffer, 0, audioBufferSize);
240
wxcam-1.0.7.tar.bz2/src/xvidcodec.h -> wxcam-1.1.tar.bz2/src/xvidcodec.h
Changed
33
1
2
#include "setting.h"
3
#include <sys/time.h>
4
#include <time.h>
5
+#include <wx/thread.h>
6
+
7
+#include <string>
8
+#include <list>
9
10
class Audio;
11
12
13
int setup();
14
15
private:
16
+ void *Entry();
17
void memcpy4(char* dest, const char* src, int size);
18
void addSilence(int hundredthsSecond);
19
bool checkAudio(Revel_Params *revParams);
20
21
-private:
22
+private:
23
+ wxMutex mutex;
24
+ wxCondition cond;
25
+ std::list<std::string> queue;
26
+ std::list< std::vector<std::string> > audio_queue;
27
+ bool endRecord;
28
+ int max;
29
+
30
Audio *audio;
31
int audioBufferSize;
32
int frameNumber;
33
Refresh
No build results available
Refresh
No rpmlint results available
Login required, please
login
or
signup
in order to comment
Request History
phils3r created request over 11 years ago
updated to most recent version and fixed an error with an 11.4 build
See comit log ;)
pbleser accepted request about 13 years ago
ok