Projects
Multimedia
wxcam
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 6
View file
wxcam.changes
Changed
@@ -1,4 +1,19 @@ ------------------------------------------------------------------- +Wed Mar 7 21:12:04 UTC 2012 - p.seiler@linuxmail.org + +- added patch and removed buildrequirement to prevent missing header file error +v4l.h:30:30: fatal error: libv4l1-videodev.h: No such file or directory +compilation terminated. + +------------------------------------------------------------------- +Wed Mar 7 20:25:35 UTC 2012 - p.seiler@linuxmail.org + +- updated to version 1.1 +- modified patches to fit the new version +- removed unneeded patch for CImg +- added two more dependencies to compile new version + +------------------------------------------------------------------- Fri Apr 1 15:46:56 UTC 2011 - pascal.bleser@opensuse.org - add patch to fix Icon attribute in .desktop file; thanks to Stephan Hegel for
View file
wxcam.spec
Changed
@@ -9,10 +9,10 @@ %define CImg_version 139 Name: wxcam -Version: 1.0.7 +Version: 1.1 Release: 0 Summary: Webcam application for linux -License: GNU General Public License version 2 or later (GPLv2 or later) +License: GPL-2.0+ Group: Productivity/Graphics/Other URL: http://wxcam.sourceforge.net Source0: http://downloads.sourceforge.net/wxcam/wxcam-%{version}.tar.bz2 @@ -21,19 +21,23 @@ # See http://cimg.sourceforge.net/ for more information Source1: CImg-%{CImg_version}.h.bz2 Source2: Licence_CeCILL_V2-en.txt -Source100: %{name}.changes -Patch0: wxcam-CImg.h.diff -Patch1: %{name}-%{version}-fix_no_return_in_nonvoid_function.patch +Patch1: %{name}-fix_no_return_in_nonvoid_function.patch Patch2: wxcam-fix_desktop_file.patch +%if 0%{?suse_version} <= 1140 +Patch3: remove-libv4l1-videdev.h.patch +%endif Buildrequires: gcc-c++ pkg-config perl-XML-Parser update-desktop-files BuildRequires: gtk2-devel libglade2-devel libtiff-devel libjpeg-devel -Buildrequires: xvid-devel mjpegtools-devel intltool +Buildrequires: xvid-devel mjpegtools-devel intltool alsa-devel %if 0%{?suse_version} > 1130 BuildRequires: wxWidgets-devel %else BuildRequires: wxGTK-devel #wxGTK-gl wxGTK-compat %endif +%if 0%{?suse_version} > 1140 +BuildRequires: libv4l-devel +%endif BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root %description @@ -49,9 +53,12 @@ bzcat %{SOURCE1} > src/CImg.h cp %{SOURCE2} License_CImg -%patch0 -p0 -%patch1 -p0 +%patch1 -p1 %patch2 -p0 +%if 0%{?suse_version} <= 1140 +%patch3 -p1 +%endif + # set some reasonable permissions for documentation files chmod 0644 COPYING
View file
remove-libv4l1-videdev.h.patch
Added
@@ -0,0 +1,28 @@ +--- wxcam-1.1/src/v4l.h.bak 2012-03-07 22:04:36.850877420 +0100 ++++ wxcam-1.1/src/v4l.h 2012-03-07 22:04:53.200831746 +0100 +@@ -24,11 +24,7 @@ + #include <unistd.h> + #include <fcntl.h> + #include <sys/mman.h> +-#ifdef HAVE_CAMV4L + #include <linux/videodev.h> +-#else +-#include <libv4l1-videodev.h> +-#endif + #include <sys/ioctl.h> + #include <sys/types.h> + #include <sys/stat.h> +--- wxcam-1.1/src/device.h.bak 2012-03-07 22:04:29.855896961 +0100 ++++ wxcam-1.1/src/device.h 2012-03-07 22:05:03.023804303 +0100 +@@ -24,11 +24,7 @@ + #include <unistd.h> + #include <fcntl.h> + #include <sys/mman.h> +-#ifdef HAVE_CAMV4L + #include <linux/videodev.h> +-#else +-#include <libv4l1-videodev.h> +-#endif + #include <sys/ioctl.h> + #include <sys/types.h> + #include <sys/stat.h>
View file
wxcam-1.0.7-fix_no_return_in_nonvoid_function.patch
Deleted
@@ -1,20 +0,0 @@ ---- src/audio.cpp.orig 2007-11-18 20:11:03.000000000 +0100 -+++ src/audio.cpp 2010-12-27 15:01:48.000000000 +0100 -@@ -106,6 +106,7 @@ - perror(message.c_str()); - } - delete [] buffer; -+ return 0; - } - - std::vector<std::string> Audio::getAudioFrames() ---- src/device.cpp.orig 2010-08-10 10:58:51.000000000 +0200 -+++ src/device.cpp 2010-12-27 15:01:48.000000000 +0100 -@@ -340,6 +340,7 @@ - frmsize.index++; - } - } -+ return true; - } - - bool Device::getGain( int *agc ) /* VIDIOCPWCGAGC*/
View file
wxcam-CImg.h.diff
Deleted
@@ -1,11 +0,0 @@ ---- src/frame.h.orig 2009-01-12 00:04:14.000000000 +0100 -+++ src/frame.h 2009-01-12 00:04:44.000000000 +0100 -@@ -29,7 +29,7 @@ - #include "motion.h" - #include <string> - #include <list> --#include <CImg.h> -+#include "CImg.h" - - using namespace cimg_library; -
View file
wxcam-fix_no_return_in_nonvoid_function.patch
Added
@@ -0,0 +1,20 @@ +--- wxcam-1.1/src/device.cpp.bak 2012-03-07 20:59:19.774820103 +0100 ++++ wxcam-1.1/src/device.cpp 2012-03-07 21:10:10.196003098 +0100 +@@ -577,6 +577,7 @@ bool Device::getResolutionList(wxArraySt + resw = resh * 16 / (float)9; + } + } ++return true; + } + + bool Device::getGain( int *agc ) /* VIDIOCPWCGAGC*/ +--- wxcam-1.1/src/audio.cpp.bak 2012-03-07 20:59:06.161858133 +0100 ++++ wxcam-1.1/src/audio.cpp 2012-03-07 21:04:34.971939575 +0100 +@@ -140,6 +140,7 @@ void* Audio::Entry() + snd_pcm_drain(handle); + snd_pcm_close(handle); + free(buffer); ++ return 0; + } + + std::vector<std::string> Audio::getAudioFrames()
View file
wxcam-1.0.7.tar.bz2/README -> wxcam-1.1.tar.bz2/README
Changed
@@ -0,0 +1,10 @@ +Compiling wxCam sources: +-) Make sure you have wxWidgets installed on your distribution. +(Ubuntu names: libwxgtk2.8 and libwxgtk2.8-dev) +-) Make sure you have libxvidcore4 and libxvidcore4-dev +-) Make sure you have libv4l-dev +-) 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. +-) NEW: Make sure you have mjpegtools (libmjpegtools-dev) +-) NEW: Make sure you have alsa developement (libasound2-dev) +-) You may also require: libgtk2.0-0 libgtk2.0-dev libglade2-dev +-) 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).
View file
wxcam-1.0.7.tar.bz2/configure -> wxcam-1.1.tar.bz2/configure
Changed
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for wxcam 1.0.7. +# Generated by GNU Autoconf 2.67 for wxcam 1.1. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -698,8 +698,8 @@ # Identity of this package. PACKAGE_NAME='wxcam' PACKAGE_TARNAME='wxcam' -PACKAGE_VERSION='1.0.7' -PACKAGE_STRING='wxcam 1.0.7' +PACKAGE_VERSION='1.1' +PACKAGE_STRING='wxcam 1.1' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1475,7 +1475,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures wxcam 1.0.7 to adapt to many kinds of systems. +\`configure' configures wxcam 1.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1545,7 +1545,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of wxcam 1.0.7:";; + short | recursive ) echo "Configuration of wxcam 1.1:";; esac cat <<\_ACEOF @@ -1655,7 +1655,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -wxcam configure 1.0.7 +wxcam configure 1.1 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2141,7 +2141,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by wxcam $as_me 1.0.7, which was +It was created by wxcam $as_me 1.1, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2969,7 +2969,7 @@ # Define the identity of the package. PACKAGE=wxcam - VERSION=1.0.7 + VERSION=1.1 cat >>confdefs.h <<_ACEOF @@ -17782,7 +17782,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by wxcam $as_me 1.0.7, which was +This file was extended by wxcam $as_me 1.1, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -17848,7 +17848,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -wxcam config.status 1.0.7 +wxcam config.status 1.1 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\"
View file
wxcam-1.0.7.tar.bz2/configure.ac -> wxcam-1.1.tar.bz2/configure.ac
Changed
@@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl Created by Anjuta application wizard. -AC_INIT(wxcam, 1.0.7) +AC_INIT(wxcam, 1.1) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
View file
wxcam-1.0.7.tar.bz2/src/Makefile.am -> wxcam-1.1.tar.bz2/src/Makefile.am
Changed
@@ -81,9 +81,11 @@ tv.xpm wxcam_LDFLAGS = \ - -lxvidcore\ - -llavjpeg\ - -lmjpegutils + -lxvidcore \ + -llavjpeg \ + -lmjpegutils \ + -lX11 \ + -lasound wxcam_LDADD = \ \
View file
wxcam-1.0.7.tar.bz2/src/Makefile.in -> wxcam-1.1.tar.bz2/src/Makefile.in
Changed
@@ -333,9 +333,11 @@ tv.xpm wxcam_LDFLAGS = \ - -lxvidcore\ - -llavjpeg\ - -lmjpegutils + -lxvidcore \ + -llavjpeg \ + -lmjpegutils \ + -lX11 \ + -lasound wxcam_LDADD = \ \
View file
wxcam-1.0.7.tar.bz2/src/audio.cpp -> wxcam-1.1.tar.bz2/src/audio.cpp
Changed
@@ -26,13 +26,11 @@ #include <sys/ioctl.h> #include <stdlib.h> #include <stdio.h> -#include <linux/soundcard.h> #include <iostream> Audio::Audio() { - end=1; - device = Setting::GetInstance()->GetAudioDeviceFile(); + end=1; } Audio::~Audio() @@ -42,70 +40,106 @@ int Audio::Open() { - fd = open(device.c_str(), O_RDWR); - if (fd < 0) { - std::string message = "open of " + device + " failed"; - perror(message.c_str()); - return -1; + /* Open PCM device for recording (capture). */ + rc = snd_pcm_open(&handle, "default", + SND_PCM_STREAM_CAPTURE, 0); + if (rc < 0) { + fprintf(stderr, + "unable to open pcm device: %s\n", + snd_strerror(rc)); + return 1; } + return 0; } -int Audio::startAcquisition(int channels, int rate, int sampleSize) +int Audio::startAcquisition(int channels, int rate) { - int arg; - int status; - arg = sampleSize; - status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg); - if (status == -1) - perror("SOUND_PCM_WRITE_BITS ioctl failed"); - if (arg != sampleSize) - perror("unable to set sample size"); - - arg = channels; /* mono or stereo */ - status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg); - if (status == -1) - perror("SOUND_PCM_WRITE_CHANNELS ioctl failed"); - if (arg != channels) - perror("unable to set number of channels"); - - arg = rate; /* sampling rate */ - status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); - if (status == -1) - perror("SOUND_PCM_WRITE_WRITE ioctl failed"); - - /*frequency: 100 Hz*/ - bufferSize = sampleSize*rate*channels/800; - buffer = new unsigned char[bufferSize]; - return bufferSize; + this->channels = channels; + this->rate = rate; + /* Allocate a hardware parameters object. */ + snd_pcm_hw_params_alloca(¶ms); + + /* Fill it in with default values. */ + snd_pcm_hw_params_any(handle, params); + + /* Set the desired hardware parameters. */ + + /* Interleaved mode */ + snd_pcm_hw_params_set_access(handle, params, + SND_PCM_ACCESS_RW_INTERLEAVED); + + /* Signed 16-bit little-endian format */ + snd_pcm_hw_params_set_format(handle, params, + SND_PCM_FORMAT_S16_LE); + + /* Two channels (stereo) */ + snd_pcm_hw_params_set_channels(handle, params, channels); + + /* 44100 bits/second sampling rate (CD quality) */ + val = rate; + snd_pcm_hw_params_set_rate_near(handle, params, + &val, &dir); + + /* Set period size to 32 frames. */ + frames = 32; + snd_pcm_hw_params_set_period_size_near(handle, + params, &frames, &dir); + + /* Write the parameters to the driver */ + rc = snd_pcm_hw_params(handle, params); + if (rc < 0) { + fprintf(stderr, + "unable to set hw parameters: %s\n", + snd_strerror(rc)); + exit(1); + } + + /* Use a buffer large enough to hold one period */ + snd_pcm_hw_params_get_period_size(params, + &frames, &dir); + size = frames * 2 * channels; /* 2 bytes/sample, 2 channels */ + buffer = (unsigned char *) malloc(size); + + snd_pcm_hw_params_get_period_time(params, + &val, &dir); + return size; } void* Audio::Entry() -{ - int status; - while (true) { - status = read(fd, buffer, bufferSize); /* record some sound */ +{ + while (true) { + rc = snd_pcm_readi(handle, buffer, frames); + if (rc == -EPIPE) { + /* EPIPE means overrun */ + fprintf(stderr, "overrun occurred\n"); + snd_pcm_prepare(handle); + } else if (rc < 0) { + fprintf(stderr, + "error from read: %s\n", + snd_strerror(rc)); + } else if (rc != (int) frames) { + fprintf(stderr, "short read, read %d frames\n", rc); + } + mutex.Lock(); if (!end) { mutex.Unlock(); break; } - mutex.Unlock(); - if (status != bufferSize) - perror("read wrong number of bytes"); - else { - //printf("read %d bytes\n", bufferSize); + mutex.Unlock(); + + //queing frames + if (rc > 0) { mutex.Lock(); - queue.push_back(std::string((char*)buffer, bufferSize)); + queue.push_back(std::string((char*) buffer, rc * 2 * channels)); mutex.Unlock(); } + } - status = close(fd); - if(status < 0) { - std::string message = "error closing " + device; - perror(message.c_str()); - } - delete [] buffer; + snd_pcm_drain(handle); + snd_pcm_close(handle); + free(buffer); } std::vector<std::string> Audio::getAudioFrames()
View file
wxcam-1.0.7.tar.bz2/src/audio.h -> wxcam-1.1.tar.bz2/src/audio.h
Changed
@@ -19,6 +19,7 @@ ***************************************************************************/ #include <wx/thread.h> +#include <alsa/asoundlib.h> #include <string> #include <vector> @@ -29,24 +30,27 @@ ~Audio(); int Open(); - int startAcquisition(int channels = 1, int rate = 44100, int sampleSize = 16); + int startAcquisition(int channels = 2, int rate = 44100); void stopAcquisition(); std::vector<std::string> getAudioFrames(); private: void *Entry(); -private: - std::string device; - unsigned char *buffer; - int bufferSize; +private: + unsigned char *buffer; int end; std::vector<std::string> queue; wxMutex mutex; - int fps; + int channels; int rate; int sampleSize; - int fd; - + int rc; + int size; + snd_pcm_t *handle; + snd_pcm_hw_params_t *params; + unsigned int val; + int dir; + snd_pcm_uframes_t frames; };
View file
wxcam-1.0.7.tar.bz2/src/avi.h -> wxcam-1.1.tar.bz2/src/avi.h
Changed
@@ -28,7 +28,7 @@ class wxWindow; -class Avi +class Avi : public wxThread { public: Avi() {dimFreeMem = 0;}
View file
wxcam-1.0.7.tar.bz2/src/ccvt.c -> wxcam-1.1.tar.bz2/src/ccvt.c
Changed
@@ -688,19 +688,23 @@ } - void mjpegtoyuv420p(const unsigned char *src, unsigned char *dst, int width, int height, unsigned int size) { uint8_t *yuv[3]; unsigned char *y, *u, *v; int loop; - + static int interlaced = 0; + yuv[0] = malloc(width * height * sizeof(yuv[0][0])); yuv[1] = malloc(width * height / 4 * sizeof(yuv[1][0])); yuv[2] = malloc(width * height / 4 * sizeof(yuv[2][0])); - decode_jpeg_raw((unsigned char*)src, size, 0, 420, width, height, yuv[0], yuv[1], yuv[2]); + int ret = decode_jpeg_raw((unsigned char*)src, size, interlaced, 420, width, height, yuv[0], yuv[1], yuv[2]); + if(ret) { + interlaced = 1; + decode_jpeg_raw((unsigned char*)src, size, interlaced, 420, width, height, yuv[0], yuv[1], yuv[2]); + } y=dst; u=y+width*height;
View file
wxcam-1.0.7.tar.bz2/src/ccvt.h -> wxcam-1.1.tar.bz2/src/ccvt.h
Changed
@@ -103,7 +103,7 @@ void ccvt_uyvy_bgr24(int width, int height, const void *const src, void *const dst); /*taken from motion sources*/ -void mjpegtoyuv420p(const unsigned char *src, unsigned char *dst, +void mjpegtoyuv420p(const unsigned char *src, unsigned char *dst, int width, int height, unsigned int size); int sonix_decompress(unsigned char *outp, unsigned char *inp, int width, int height); void bayer2rgb24(unsigned char *dst, unsigned char *src, long int width, long int height);
View file
wxcam-1.0.7.tar.bz2/src/configure.cpp -> wxcam-1.1.tar.bz2/src/configure.cpp
Changed
@@ -177,7 +177,7 @@ strAviFormat[0] = _("&none (uncompressed)"); strAviFormat[1] = _("&xvid"); - aviFormat = new wxRadioBox(panel, ID_AVI_FORMAT, _("&Choose recording compression:"), + aviFormat = new wxRadioBox(panel, ID_AVI_FORMAT, _("&Choose compression:"), wxDefaultPosition, wxSize(220, 80), 2, strAviFormat); hSizer->Add(aviFormat, 0, wxGROW|wxALL, 10); @@ -189,7 +189,7 @@ vSizer->Add(hSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 10); - audio = new wxCheckBox(panel, ID_AUDIO, _("Enable audio recording (xvid only)") ); + /*audio = new wxCheckBox(panel, ID_AUDIO, _("Enable audio recording (xvid only)") ); vSizer->Add(audio, wxGROW|wxALL, 15); wxArrayString validValues = fillValidValues(wxString("dsp*", wxConvUTF8)); @@ -200,7 +200,7 @@ vSizer->Add(textAudioDevice, 0, wxALIGN_CENTER|wxALL, 5); vSizer->Add(comboAudioDevice, 0, wxALIGN_CENTER|wxBOTTOM, 15); - + */ silenceBox = new wxStaticBox(panel, wxID_ANY, _("Add silence for synchronization reason:"), wxDefaultPosition, wxSize(220, 80)); wxSizer *sSizer = new wxStaticBoxSizer(silenceBox, wxVERTICAL); vSizer->Add(sSizer, 0, wxGROW|wxALL, 10); @@ -210,28 +210,17 @@ textUnit = new wxStaticText(panel, -1, _("(hundredths of a second)")); vSizer->Add(textUnit, wxGROW|wxALL, 15); - boxSizer->Add(vSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 10); + boxSizer->Add(vSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM|wxLEFT|wxRIGHT, 10); - if(Setting::GetInstance()->GetAudioEnabled()) - audio->SetValue(true); - else { - audio->SetValue(false); - silenceBox->Enable(false); - comboAudioDevice->Enable(false); - textAudioDevice->Enable(false); - textUnit->Enable(false); - hundredthsSlider->Enable(false); - } - if((Setting::GetInstance()->GetCompression() == "none")) { aviFormat->SetSelection(0); staticCompressionLevelBox->Enable(false); qualitySlider->Enable(false); - comboAudioDevice->Enable(false); - audio->Enable(false); + //comboAudioDevice->Enable(false); + //audio->Enable(false); silenceBox->Enable(false); textUnit->Enable(false); - textAudioDevice->Enable(false); + //textAudioDevice->Enable(false); hundredthsSlider->Enable(false); } else @@ -294,18 +283,15 @@ std::string oldDevice = Setting::GetInstance()->GetDeviceFile(); std::string oldV4LAPI = Setting::GetInstance()->GetDriverAPI(); std::string oldFrameFormat = Setting::GetInstance()->GetFrameFormat(); - Setting::GetInstance()->SetDeviceFile((const char*)combo->GetValue().mb_str(wxConvUTF8)); - Setting::GetInstance()->SetAudioDeviceFile((const char*)comboAudioDevice->GetValue().mb_str(wxConvUTF8)); + Setting::GetInstance()->SetDeviceFile((const char*)combo->GetValue().mb_str(wxConvUTF8)); Setting::GetInstance()->SetFrameFormat((const char*)rgbMode->GetStringSelection().mb_str(wxConvUTF8)); Setting::GetInstance()->SetDriverAPI((const char*)v4lVersion->GetStringSelection().mb_str(wxConvUTF8)); if(aviFormat->GetStringSelection() == wxString("xvid", wxConvUTF8)) Setting::GetInstance()->SetCompression((const char*)wxString("xvid", wxConvUTF8).mb_str(wxConvUTF8)); else Setting::GetInstance()->SetCompression((const char*)wxString("none", wxConvUTF8).mb_str(wxConvUTF8)); - if(audio->IsChecked()) - Setting::GetInstance()->SetAudioEnabled(true); - else - Setting::GetInstance()->SetAudioEnabled(false); + + Setting::GetInstance()->SetAudioEnabled(true); Setting::GetInstance()->SetCompressionLevel(qualitySlider->GetValue()); Setting::GetInstance()->SetSilence(hundredthsSlider->GetValue()); if((oldV4LAPI != (const char*)v4lVersion->GetStringSelection().mb_str(wxConvUTF8)) @@ -320,23 +306,16 @@ { if(aviFormat->GetSelection()) { staticCompressionLevelBox->Enable(true); - qualitySlider->Enable(true); - audio->Enable(true); - if(audio->IsChecked()) { - silenceBox->Enable(true); - comboAudioDevice->Enable(true); - textUnit->Enable(true); - textAudioDevice->Enable(true); - hundredthsSlider->Enable(true); - } + qualitySlider->Enable(true); + silenceBox->Enable(true); + textUnit->Enable(true); + hundredthsSlider->Enable(true); + } else { staticCompressionLevelBox->Enable(false); - qualitySlider->Enable(false); - audio->Enable(false); - comboAudioDevice->Enable(false); - silenceBox->Enable(false); - textAudioDevice->Enable(false); + qualitySlider->Enable(false); + silenceBox->Enable(false); textUnit->Enable(false); hundredthsSlider->Enable(false); }
View file
wxcam-1.0.7.tar.bz2/src/device.cpp -> wxcam-1.1.tar.bz2/src/device.cpp
Changed
@@ -21,8 +21,10 @@ #include <stdio.h> #include <sys/time.h> #include <stdlib.h> +#include <math.h> #include <iostream> #include <sstream> +#include <linux/videodev2.h> #include "errno.h" #include "setting.h" #include "device.h" @@ -83,7 +85,7 @@ else { cout<<"Determining video4linux API version..."<<endl; struct v4l2_capability cap; - if( !isPWC() && queryCapabilities(&cap) ) { + if( /*!isPWC() && */queryCapabilities(&cap) ) { cout<<"Using video4linux 2 API"<<endl; v4l = new VideoForLinux2(); isV4L2 = true; @@ -98,10 +100,10 @@ if(isV4L2) { struct v4l2_frmsizeenum frmsize; memset(&frmsize, 0, sizeof(struct v4l2_frmsizeenum)); - if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) { + /*if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) { perror( "VIDIOC_ENUM_FRAMESIZES" ); isV4L2 = false; // I will get resolution in v4l1 way - } + }*/ } if( !width || !height ) { //setting max resolution @@ -121,26 +123,132 @@ Setting::GetInstance()->SetResolution(s.str()); } else { - int maxW, maxH; - struct v4l2_frmsizeenum frmsize; - memset(&frmsize, 0, sizeof(struct v4l2_frmsizeenum)); - if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) { - perror( "VIDIOC_ENUM_FRAMESIZES" ); - return false; + int maxW = -1, maxH = -1; + int resw, resh; + struct v4l2_format fmt; + + std::stringstream ss; + std::string str; + + resw = 160; + resh = 120; + + while (resw < 3000) { + memset(&fmt, 0, sizeof (struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat(); + + if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + maxW = resw; + maxH = resh; + } + } + resh = resh * 1.5; + resw = resh * 4 / (float) 3; } - maxW = frmsize.discrete.width; - maxH = frmsize.discrete.height; - frmsize.index++; - while(!ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) { - if(maxW < frmsize.discrete.width) { - maxW = frmsize.discrete.width; - maxH = frmsize.discrete.height; + + resw = 160; + resh = 120; + + while (resw < 3000) { + memset(&fmt, 0, sizeof (struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat(); + + if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + maxW = resw; + maxH = resh; + } + } + resh = resh * 2; + resw = resh * 4 / (float) 3; + } + + + resw = 160; + resh = 90; + + while (resw < 3000) { + memset(&fmt, 0, sizeof (struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat(); + + if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + maxW = resw; + maxH = resh; + } + } + resh = resh * 1.5; + resw = resh * 16 / (float) 9; + } + + resw = 160; + resh = 90; + + while (resw < 3000) { + memset(&fmt, 0, sizeof (struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*> (v4l)->getPixelFormat(); + + if (ioctl(fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + maxW = resw; + maxH = resh; + } } - frmsize.index++; - } + resh = resh * 2; + resw = resh * 16 / (float) 9; + } ostringstream s; - s<<maxW<<"x"<<maxH; - Setting::GetInstance()->SetResolution(s.str()); + if(maxW == -1) { + s<<640<<"x"<<480; + Setting::GetInstance()->SetResolution(s.str()); + + width = 640; + height = 480; + + } else { + s<<maxW<<"x"<<maxH; + Setting::GetInstance()->SetResolution(s.str()); + + width = maxW; + height = maxH; + } } } @@ -159,7 +267,7 @@ bool Device::mMap(int w, int h) { if(v4l) - return v4l->mMap(w, h); + return v4l->mMap(w, h, 0); else return false; } @@ -262,8 +370,19 @@ bool Device::queryCapabilities( struct video_capability *caps ) /*VIDIOCGCAP*/ { - if ( ioctl( fd, VIDIOCGCAP, caps ) <0 ) { - perror( "VIDIOCGCAP" ); + if (ioctl(fd, VIDIOCGCAP, caps) < 0) { + perror("VIDIOCGCAP"); + /*v4l2_capability v2caps; + if (ioctl(fd, VIDIOC_QUERYCAP, &v2caps) == -1) { + if (EINVAL == errno) { + return false; + } + else { + perror("VIDIOC_QUERYCAP"); + return false; + } + } + strcpy(caps->name, (char*)(v2caps.card));*/ return false; } return true; @@ -320,7 +439,7 @@ } } else { - struct v4l2_frmsizeenum frmsize; + /*struct v4l2_frmsizeenum frmsize; memset(&frmsize, 0, sizeof(struct v4l2_frmsizeenum)); if(ioctl( fd, VIDIOC_ENUM_FRAMESIZES, &frmsize)) { perror( "VIDIOC_ENUM_FRAMESIZES" ); @@ -338,8 +457,126 @@ str = ss.str(); validResolution.Add( wxString(str.c_str(), wxConvUTF8) ); frmsize.index++; + }*/ + int resw, resh; + struct v4l2_format fmt; + + std::stringstream ss; + std::string str; + + resw = 160; + resh = 120; + + while(resw < 3000) { + memset(&fmt, 0, sizeof(struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat(); + + if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + ss.str(""); + ss << resw << "x" << resh; + str = ss.str(); + validResolution.Add(wxString(str.c_str(), wxConvUTF8)); + } + } + resh = resh * 1.5; + resw = resh * 4 / (float)3; } - } + + resw = 160; + resh = 120; + + while(resw < 3000) { + memset(&fmt, 0, sizeof(struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat(); + + if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + ss.str(""); + ss << resw << "x" << resh; + str = ss.str(); + validResolution.Add(wxString(str.c_str(), wxConvUTF8)); + } + } + resh = resh * 2; + resw = resh * 4 / (float)3; + } + + + resw = 160; + resh = 90; + + while(resw < 3000) { + memset(&fmt, 0, sizeof(struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat(); + + if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + ss.str(""); + ss << resw << "x" << resh; + str = ss.str(); + validResolution.Add(wxString(str.c_str(), wxConvUTF8)); + } + } + resh = resh * 1.5; + resw = resh * 16 / (float)9; + } + + resw = 160; + resh = 90; + + while(resw < 3000) { + memset(&fmt, 0, sizeof(struct v4l2_format)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + fmt.fmt.pix.width = resw; + fmt.fmt.pix.height = resh; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + fmt.fmt.pix.pixelformat = static_cast<VideoForLinux2*>(v4l)->getPixelFormat(); + + if (ioctl (fd, VIDIOC_TRY_FMT, &fmt) == -1) { + perror("VIDIOC_TRY_FMT"); + printf("Resolution %dx%d not valid\n", resw, resh); + } else { + if ((fmt.fmt.pix.width == resw) && (fmt.fmt.pix.height == resh)) { + printf("Resolution %dx%d valid\n", fmt.fmt.pix.width, fmt.fmt.pix.height); + ss.str(""); + ss << resw << "x" << resh; + str = ss.str(); + validResolution.Add(wxString(str.c_str(), wxConvUTF8)); + } + } + resh = resh * 2; + resw = resh * 16 / (float)9; + } + } } bool Device::getGain( int *agc ) /* VIDIOCPWCGAGC*/
View file
wxcam-1.0.7.tar.bz2/src/device.h -> wxcam-1.1.tar.bz2/src/device.h
Changed
@@ -24,7 +24,11 @@ #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> +#ifdef HAVE_CAMV4L #include <linux/videodev.h> +#else +#include <libv4l1-videodev.h> +#endif #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h>
View file
wxcam-1.0.7.tar.bz2/src/frame.cpp -> wxcam-1.1.tar.bz2/src/frame.cpp
Changed
@@ -184,16 +184,14 @@ //if ( !cam.isPWC() ) freq = assessFrequency; rec->setParameters( this, filename, freq, width, height ); - if(compression == "none") { - if ( static_cast<AviUncompressed*>(rec)->Create() != wxTHREAD_NO_ERROR ) { - wxLogError( _( "Cannot create video recording thread!" ) ); - return; - } - static_cast<AviUncompressed*>(rec)->Run(); + if ((rec)->Create() != wxTHREAD_NO_ERROR) { + wxLogError(_("Cannot create video recording thread!")); + return; } + rec->Run(); - if( rec->setup() ) { + if( rec->setup() ) { rstatus = REC_NONE; wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, STOP_REC ); event.SetInt(1); @@ -201,6 +199,7 @@ } else { rstatus = REC_CONTINUING; } + } else if ( rstatus == REC_CONTINUING ) { wxDateTime now = wxDateTime::UNow(); @@ -283,6 +282,8 @@ int freq=0; if( cam.isPWC() ) freq=atoi(frameRate.c_str()); + else + freq = 0; if ( !cam.setResolution( w, h, freq ) && deviceOpen ) { wxMessageBox( _( "Frame rate/resolution setting not supported.\nPlease try a lower frame rate o resolution." ), _( "Error applying settings" ), wxICON_WARNING ); return false;
View file
wxcam-1.0.7.tar.bz2/src/uncompressed.h -> wxcam-1.1.tar.bz2/src/uncompressed.h
Changed
@@ -35,7 +35,7 @@ typedef char byte; class wxWindow; -class AviUncompressed : public Avi, public wxThread +class AviUncompressed : public Avi { public: AviUncompressed();
View file
wxcam-1.0.7.tar.bz2/src/v4l.h -> wxcam-1.1.tar.bz2/src/v4l.h
Changed
@@ -24,7 +24,11 @@ #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> +#ifdef HAVE_CAMV4L #include <linux/videodev.h> +#else +#include <libv4l1-videodev.h> +#endif #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -75,7 +79,7 @@ this->adjustColors=adjustColors; } - virtual bool mMap(int w, int h) = 0; + virtual bool mMap(int w, int h, int frameRate=0) = 0; virtual bool getFrame(char **buffer) = 0; virtual bool setResolution(unsigned int width, unsigned int height, unsigned int frameRate=0) = 0; virtual bool getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate) = 0;
View file
wxcam-1.0.7.tar.bz2/src/v4l1.cpp -> wxcam-1.1.tar.bz2/src/v4l1.cpp
Changed
@@ -49,8 +49,9 @@ munmap( NULL, mmap_size ); } -bool VideoForLinux1::mMap(int w, int h) -{ +bool VideoForLinux1::mMap(int w, int h, int frameRate) +{ + frameRate = 0; //ignored memset(&v, 0, sizeof(struct video_mmap)); v.format=frameFormat; v.width=w; // from 32 to 924 (sometimes limited to 768)
View file
wxcam-1.0.7.tar.bz2/src/v4l1.h -> wxcam-1.1.tar.bz2/src/v4l1.h
Changed
@@ -30,7 +30,7 @@ VideoForLinux1(); ~VideoForLinux1(); - bool mMap(int w, int h); + bool mMap(int w, int h, int frameRate=0); bool getFrame(char **buffer); bool setResolution(unsigned int width, unsigned int height, unsigned int frameRate=0); bool getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate);
View file
wxcam-1.0.7.tar.bz2/src/v4l2.cpp -> wxcam-1.1.tar.bz2/src/v4l2.cpp
Changed
@@ -41,6 +41,8 @@ #include <wx/image.h> #include <iostream> +#include "pwc-ioctl.h" + VideoForLinux2::VideoForLinux2() { dev_name = Setting::GetInstance()->GetDeviceFile(); @@ -72,7 +74,7 @@ free(buffers); } -bool VideoForLinux2::mMap(int w, int h) { +bool VideoForLinux2::mMap(int w, int h, int frameRate) { struct v4l2_cropcap cropcap; struct v4l2_crop crop; struct v4l2_format fmt; @@ -176,6 +178,26 @@ pixelFormat = V4L2_PIX_FMT_SBGGR8; std::cout<<"Found V4L2_PIX_FMT_SBGGR8 pixel format"<<std::endl; } + else if(argp.pixelformat == V4L2_PIX_FMT_SBGGR16) { + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR16; + pixelFormat = V4L2_PIX_FMT_SBGGR16; + std::cout<<"Found V4L2_PIX_FMT_SBGGR16 pixel format"<<std::endl; + } + else if(argp.pixelformat == V4L2_PIX_FMT_SGBRG8) { + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGBRG8; + pixelFormat = V4L2_PIX_FMT_SGBRG8; + std::cout<<"Found V4L2_PIX_FMT_SGBRG8 pixel format"<<std::endl; + } + else if(argp.pixelformat == V4L2_PIX_FMT_SGRBG8) { + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGRBG8; + pixelFormat = V4L2_PIX_FMT_SGRBG8; + std::cout<<"Found V4L2_PIX_FMT_SGRBG8 pixel format"<<std::endl; + } + else if(argp.pixelformat == V4L2_PIX_FMT_SPCA561) { + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SPCA561; + pixelFormat = V4L2_PIX_FMT_SPCA561; + std::cout<<"Found V4L2_PIX_FMT_SPCA561 pixel format"<<std::endl; + } else if(argp.pixelformat == V4L2_PIX_FMT_BGR24) { fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24; pixelFormat = V4L2_PIX_FMT_BGR24; @@ -201,6 +223,29 @@ fmt.fmt.pix.width = w; fmt.fmt.pix.height = h; fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + + //setting frame rate + if(frameRate) { + + /* + //many cams doesn't support these calls + v4l2_streamparm parm; + + if (ioctl (fd, VIDIOC_G_PARM, &parm) == -1) { + perror("VIDIOC_G_PARM"); + } + + parm.parm.capture.timeperframe.numerator = 1; + parm.parm.capture.timeperframe.denominator = frameRate; + + if (ioctl (fd, VIDIOC_S_PARM, &parm) == -1) { + perror("VIDIOC_S_PARM"); + } + */ + + fmt.fmt.pix.priv &= ~PWC_FPS_FRMASK; + fmt.fmt.pix.priv |= ( frameRate << PWC_FPS_SHIFT ); + } /*enum v4l2_buf_type type; type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -427,7 +472,11 @@ bayer2rgb24(( unsigned char* ) *buffer, tmp_buffer, width, height); free(tmp_buffer); } - else if(pixelFormat == V4L2_PIX_FMT_SBGGR8) { + else if(pixelFormat == V4L2_PIX_FMT_SBGGR8 || + pixelFormat == V4L2_PIX_FMT_SBGGR16 || + pixelFormat == V4L2_PIX_FMT_SGBRG8 || + pixelFormat == V4L2_PIX_FMT_SPCA561 || + pixelFormat == V4L2_PIX_FMT_SGRBG8) { bayer2rgb24(( unsigned char* ) *buffer, ( unsigned char* ) buffers[buf.index].start, width, height); } else if(pixelFormat == V4L2_PIX_FMT_BGR24 || pixelFormat == V4L2_PIX_FMT_SN9C10X @@ -497,8 +546,8 @@ bool VideoForLinux2::setResolution(unsigned int width, unsigned int height, unsigned int frameRate) { - frameRate=0; /*avoiding warning*/ - return mMap(width, height); + //frameRate=0; /*avoiding warning*/ + return mMap(width, height, frameRate); } bool VideoForLinux2::getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate) @@ -513,6 +562,7 @@ } width = fmt.fmt.pix.width; height = fmt.fmt.pix.height; + frameRate = ( fmt.fmt.pix.priv & PWC_FPS_FRMASK ) >> PWC_FPS_SHIFT; printf("width: %d, height %d\n", width, height); return true; }
View file
wxcam-1.0.7.tar.bz2/src/v4l2.h -> wxcam-1.1.tar.bz2/src/v4l2.h
Changed
@@ -46,7 +46,7 @@ ~VideoForLinux2(); void closeDevice(); - bool mMap(int w, int h); + bool mMap(int w, int h, int frameRate=0); bool getFrame(char **buffer); bool setResolution(unsigned int width, unsigned int height, unsigned int frameRate=0); bool getResolution(unsigned int &width, unsigned int &height, unsigned int &frameRate); @@ -59,8 +59,10 @@ bool setSaturation(unsigned int value); bool getSaturation(unsigned int &value); bool setVideoStd(video_std std); + + int getPixelFormat() {return pixelFormat;} -private: +private: bool init_mmap(); void setControls(); void enumerateMenu(struct v4l2_queryctrl &queryctrl, struct v4l2_querymenu querymenu);
View file
wxcam-1.0.7.tar.bz2/src/wxcam.cpp -> wxcam-1.1.tar.bz2/src/wxcam.cpp
Changed
@@ -32,6 +32,7 @@ #include <wx/aboutdlg.h> #include <wx/thread.h> +#include <linux/videodev2.h> #include "device.h" #include <iostream> #include <sstream> @@ -130,10 +131,18 @@ Setting::GetInstance()->SetAlreadyOpen(); struct video_capability caps; struct video_picture pic; - cam.queryCapabilities( &caps ); - wxString msg = _( "Device found in your system: " ) + wxString( "\n", wxConvUTF8 ); - msg += wxString(caps.name, wxConvUTF8); + wxString msg; + if(cam.queryCapabilities( &caps )) { + msg = _( "Device found in your system: " ) + wxString( "\n", wxConvUTF8 ); + msg += wxString(caps.name, wxConvUTF8); + } else { + struct v4l2_capability v2caps; + cam.queryCapabilities(&v2caps); + msg = _( "Device found in your system: " ) + wxString( "\n", wxConvUTF8 ); + msg += wxString((char*)v2caps.card, wxConvUTF8); + } wxMessageBox( msg, _( "Hardware found" ), wxICON_INFORMATION ); + /*cam.getPictureFunctions( &pic ); if ( pic.palette == VIDEO_PALETTE_YUV420P || frame->isPWC() ) { Setting::GetInstance()->SetFrameFormat( "YUV420P" ); @@ -297,11 +306,12 @@ wxAboutDialogInfo info; info.SetName( _T( "wxCam" ) ); - info.SetVersion( wxString("1.0.7", wxConvUTF8) ); + info.SetVersion( wxString("1.1", wxConvUTF8) ); info.SetDescription( _( "A webcam application for linux" ) ); - info.SetCopyright( _T( "(C) 2010 Marco Lorrai" ) ); + info.SetCopyright( _T( "(C) 2011 Marco Lorrai" ) ); info.AddDeveloper( _T( "Marco Lorrai" ) ); info.AddDeveloper( _T( "Örjan Medhage" ) ); + info.SetWebSite(wxT("wxcam.sourceforge.net")); // we can add a second developer //info.AddDeveloper(_T("A.N. Other")); @@ -335,34 +345,53 @@ { struct video_capability caps; if ( !cam.queryCapabilities( &caps ) ) { - wxMessageBox( _( "Error querying webcam capabilities.\nPerhaps the device hasn't been correctly opened." ), _( "Capabilities" ), wxICON_WARNING ); - return; + //Trying v4l2 query... + struct v4l2_capability v2caps; + if ( !cam.queryCapabilities( &v2caps ) ) { + wxMessageBox( _( "Error querying webcam capabilities.\nPerhaps the device hasn't been correctly opened." ), _( "Capabilities" ), wxICON_WARNING ); + return; + } + std::stringstream ss; + std::string str; + ss << (const char*) wxString(_("Driver: ")).mb_str(wxConvUTF8) << v2caps.driver << "\n"; + + ss << (const char*) wxString(_("Card: ")).mb_str(wxConvUTF8) << v2caps.card << "\n"; + str = ss.str(); + + ss.str(""); + if (v2caps.capabilities & V4L2_CAP_AUDIO) + ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("Yes")).mb_str(wxConvUTF8) << "\n"; + else + ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("No")).mb_str(wxConvUTF8) << "\n"; + str += ss.str(); + + wxMessageBox(wxString(str.c_str(), wxConvUTF8), _("Webcam Capabilities "), wxICON_INFORMATION); + } else { + std::stringstream ss; + std::string str; + + ss << (const char*) wxString(_("Name: ")).mb_str(wxConvUTF8) << caps.name << "\n"; + + ss << (const char*) wxString(_("Channels: ")).mb_str(wxConvUTF8) << caps.channels << "\n"; + str = ss.str(); + + ss.str(""); + if (caps.audios) + ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("Yes")).mb_str(wxConvUTF8) << "\n"; + else + ss << (const char*) wxString(_("Audio: ")).mb_str(wxConvUTF8) << (const char*) wxString(_("No")).mb_str(wxConvUTF8) << "\n"; + str += ss.str(); + + ss.str(""); + ss << (const char*) wxString(_("Min resolution: ")).mb_str(wxConvUTF8) << caps.minwidth << "x" << caps.minheight << "\n"; + str += ss.str(); + + ss.str(""); + ss << (const char*) wxString(_("Max resolution: ")).mb_str(wxConvUTF8) << caps.maxwidth << "x" << caps.maxheight << "\n"; + str += ss.str(); + + wxMessageBox(wxString(str.c_str(), wxConvUTF8), _("Webcam Capabilities "), wxICON_INFORMATION); } - - std::stringstream ss; - std::string str; - - ss<<(const char*)wxString( _( "Name: " ) ).mb_str(wxConvUTF8) <<caps.name<<"\n"; - - ss<<(const char*)wxString( _( "Channels: " ) ).mb_str(wxConvUTF8) <<caps.channels<<"\n"; - str = ss.str(); - - ss.str( "" ); - if ( caps.audios ) - ss<<(const char*)wxString( _( "Audio: " ) ).mb_str(wxConvUTF8) <<(const char*)wxString( _( "Yes" ) ).mb_str(wxConvUTF8) <<"\n"; - else - ss<<(const char*)wxString( _( "Audio: " ) ).mb_str(wxConvUTF8) <<(const char*)wxString( _( "No" ) ).mb_str(wxConvUTF8) <<"\n"; - str += ss.str(); - - ss.str( "" ); - ss<<(const char*)wxString( _( "Min resolution: " ) ).mb_str(wxConvUTF8) <<caps.minwidth<<"x"<<caps.minheight<<"\n"; - str += ss.str(); - - ss.str( "" ); - ss<<(const char*)wxString( _( "Max resolution: " ) ).mb_str(wxConvUTF8) <<caps.maxwidth<<"x"<<caps.maxheight<<"\n"; - str += ss.str(); - - wxMessageBox( wxString(str.c_str(), wxConvUTF8), _( "Webcam Capabilities " ), wxICON_INFORMATION ); } void wxCam::OnPictureFunctions( wxCommandEvent& WXUNUSED( event ) ) @@ -396,6 +425,8 @@ return; wxString valueFrameRate = resDlg->GetFrameRate(); + if(!valueFrameRate.size()) + valueFrameRate = wxT("10"); /*if ( valueFrameRate == wxString("- - -", wxConvUTF8) || valueFrameRate.empty() ) return;*/
View file
wxcam-1.0.7.tar.bz2/src/xvidcodec.cpp -> wxcam-1.1.tar.bz2/src/xvidcodec.cpp
Changed
@@ -24,15 +24,20 @@ #include "frame.h" #include "audio.h" +#define CHANNELS 2 +#define RATE 44100 + using namespace std; -Xvid::Xvid() +Xvid::Xvid() : cond(mutex) { frameNumber=0; audioFramesRecorded=0; compression=0.5f; audio=NULL; ignoreVideo = false; + endRecord = false; + max=0; } Xvid::~Xvid() @@ -86,12 +91,10 @@ } void Xvid::addFrame(const char* frame) -{ - bool videoIgnored = ignoreVideo; - +{ if(!frameNumber) { if(hasAudio) { - audioBufferSize = audio->startAcquisition(); + audioBufferSize = audio->startAcquisition(CHANNELS, RATE); if (audio->Create() != wxTHREAD_NO_ERROR ) { cout<<"Can't create audio recording thread!"; return; @@ -100,71 +103,122 @@ addSilence(Setting::GetInstance()->GetSilence()); } } - - if(!ignoreVideo) { - memcpy4( (char*)revelFrame.pixels, frame, width*height*4 ); - revError = Revel_EncodeFrame(encoderHandle, &revelFrame, &frameSize); + + mutex.Lock(); + queue.push_back(std::string(frame, frameSize)); + + /*revError = Revel_EncodeFrame(encoderHandle, &revelFrame, &frameSize); if (revError != REVEL_ERR_NONE) - printf("Revel Error while writing frame: %d\n", revError); - } + printf("Revel Error while writing frame: %d\n", revError);*/ + /*encoding audio*/ - int totalAudioBytes; - if(frameNumber && hasAudio) { - /*sync calculation*/ - double recDuration = (double)frameNumber/(double)fps; - int audioFrame = (int)((double)100/(double)fps*frameNumber); - audioFrame -= audioFramesRecorded; + if(hasAudio) { std::vector<std::string> vectAudio = audio->getAudioFrames(); - int size = vectAudio.size(); - if(audioFrame > size * 2) - ignoreVideo = true; - else - ignoreVideo = false; - int frameToIgnore = size - audioFrame; - /*if (frameToIgnore > 0) - printf("Video frame %d: ignoring %d audio frames\n", frameNumber, frameToIgnore); - else - printf("Video frame %d: no frames to ignore: %d\n", frameNumber, frameToIgnore);*/ - //printf("Encoding %d audio frames\n", size); - float mean = 0.0; - if(frameToIgnore > 0) - mean = (float)size/((float)frameToIgnore + 1); - - /*encoding frames*/ - int ignoredFrames = 0; + audio_queue.push_back(vectAudio); + /*int size = vectAudio.size(); std::vector<std::string>::iterator it = vectAudio.begin(); - for(int i=1; i<=size; i++) { - if((ignoredFrames) < frameToIgnore) { - if(i == (int)(mean*(ignoredFrames + 1) + 0.5)) { - //printf("Frame ignored\n"); - ++it; - ignoredFrames++; - continue; - } - } + for(int i=1; i<=size; i++) { std::string buffer = *it; ++it; audioFramesRecorded++; - revError = Revel_EncodeAudio(encoderHandle, (void*)buffer.c_str(), audioBufferSize, &totalAudioBytes); + revError = Revel_EncodeAudio(encoderHandle, (void*)buffer.c_str(), buffer.size(), &totalAudioBytes); if (revError != REVEL_ERR_NONE) { printf("Revel Error while writing audio: %d\n", revError); + } + } + */ + + } + cond.Signal(); + mutex.Unlock(); + frameNumber++; +} + +void* Xvid::Entry() { + while(true) { + mutex.Lock(); + while( (!queue.size() || !audio_queue.size())&& !endRecord) + cond.Wait(); + //cout<<"Queue size: "<<queue_size<<endl<<flush; + if(endRecord && (!queue.size() || !audio_queue.size())) { //registration terminated + mutex.Unlock(); + + break; + } + + string videoFrame = queue.front(); + queue.pop_front(); + vector<string> audioFrames; + if(hasAudio) { + audioFrames = audio_queue.front(); + audio_queue.pop_front(); + } + + //max not yet initialize, first execution after calling record() + if(endRecord && !max) { + max = queue.size(); + if(max > 10) { + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, PROGRESS_DIALOG_START ); + wxPostEvent( parent, event ); } - //else - // printf("Audio encoded\n"); - } + else + max=-1; + } + + //max already initialized + if(endRecord && max > 0) { + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, PROGRESS_DIALOG_EVENT ); + int n = (int)(((float)max - (float)queue.size()) / (float)max * 100); + event.SetInt( n ); + + // send in a thread-safe way + wxPostEvent( parent, event ); + } + + mutex.Unlock(); + + int frameSize; + const char* frame = videoFrame.c_str(); + //writing frame... + memcpy4( (char*)revelFrame.pixels, frame, width*height*4 ); + revError = Revel_EncodeFrame(encoderHandle, &revelFrame, &frameSize); + if (revError != REVEL_ERR_NONE) + printf("Revel Error while writing frame: %d\n", revError); + + if (hasAudio) { + int totalAudioBytes; + int size = audioFrames.size(); + std::vector<std::string>::iterator it = audioFrames.begin(); + for (int i = 1; i <= size; i++) { + std::string buffer = *it; + ++it; + audioFramesRecorded++; + revError = Revel_EncodeAudio(encoderHandle, (void*) buffer.c_str(), audioBufferSize, &totalAudioBytes); + if (revError != REVEL_ERR_NONE) { + printf("Revel Error while writing audio: %d\n", revError); + } + //printf("Recorded %d audio frames total\n", size); + } + } } + if(max > 0) { + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, PROGRESS_DIALOG_EVENT ); - if(!videoIgnored) { - frameNumber++; + event.SetInt(-1); // that's all + wxPostEvent( parent, event ); } + wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, STOP_REC ); + event.SetInt(0); + wxPostEvent( parent, event ); + return NULL; } bool Xvid::checkAudio(Revel_Params *revParams) { int ret; - hasAudio = Setting::GetInstance()->GetAudioEnabled(); + hasAudio = true; if (hasAudio) { audio = new Audio(); @@ -176,9 +230,10 @@ event.SetInt(1); wxPostEvent(parent, event); audio->Delete(); + audio = NULL; } else { - revParams->audioChannels = 1; - revParams->audioRate = 44100; + revParams->audioChannels = CHANNELS; + revParams->audioRate = RATE; revParams->audioBits = 16; revParams->audioSampleFormat = REVEL_ASF_PCM; } @@ -191,8 +246,10 @@ void Xvid::record() { /*stopping audio acquisition*/ - if(hasAudio) + if(hasAudio) { audio->stopAcquisition(); + audio->Wait(); + } int totalSize; revError = Revel_EncodeEnd(encoderHandle, &totalSize); @@ -225,7 +282,7 @@ void Xvid::addSilence(int hundredthsSecond) { - int audioBufferSize = hundredthsSecond*882; + int audioBufferSize = hundredthsSecond*882*CHANNELS; //2 is the number of channels; int totalAudioBytes; char* buffer = new char[audioBufferSize]; memset(buffer, 0, audioBufferSize);
View file
wxcam-1.0.7.tar.bz2/src/xvidcodec.h -> wxcam-1.1.tar.bz2/src/xvidcodec.h
Changed
@@ -26,6 +26,10 @@ #include "setting.h" #include <sys/time.h> #include <time.h> +#include <wx/thread.h> + +#include <string> +#include <list> class Audio; @@ -40,11 +44,19 @@ int setup(); private: + void *Entry(); void memcpy4(char* dest, const char* src, int size); void addSilence(int hundredthsSecond); bool checkAudio(Revel_Params *revParams); -private: +private: + wxMutex mutex; + wxCondition cond; + std::list<std::string> queue; + std::list< std::vector<std::string> > audio_queue; + bool endRecord; + int max; + Audio *audio; int audioBufferSize; int frameNumber;
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.