diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-11-08 16:46:28 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-11-08 16:46:28 +0000 |
commit | 1d637da186506754ddd06efd47c917dc89faf1c9 (patch) | |
tree | 0c3fe4ab9f83fa8bd1be5f1c126626bf7a8e6ce4 /rMD-exp | |
parent | ad5b05712d9ed8650fcc145373ac878f8e6b8829 (diff) |
purge rMD-exp module
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@155 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'rMD-exp')
37 files changed, 0 insertions, 5248 deletions
diff --git a/rMD-exp/AUTHORS b/rMD-exp/AUTHORS deleted file mode 100644 index 023898c..0000000 --- a/rMD-exp/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -NAME EMAIL -John Varouhakis johnvarouhakis@gmail.com diff --git a/rMD-exp/COPYING b/rMD-exp/COPYING deleted file mode 100644 index d60c31a..0000000 --- a/rMD-exp/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/rMD-exp/ChangeLog b/rMD-exp/ChangeLog deleted file mode 100644 index bdd5f6f..0000000 --- a/rMD-exp/ChangeLog +++ /dev/null @@ -1,80 +0,0 @@ -/*VERSION 0.2.1*/ -*Unupdated lines bug fixed. -*Fuzzy cursor at border bug fixed. -*Incorrect display of windows that -extended beyond recording height fixed. -*Size adjustement that resulted in extra -or missing pixels at borders has been corrected. -New adjustment is 8 pixels max,split evenly if possible. -*The option to drop frames has been added. -*The option to do better subsampling has been added. -*Default behavior now is to use shared memory when -size of image gets over 75% of total (or a user set threshold). -*Many other minor bugfixes. - - -/*VERSION 0.2.2*/ -*Changes to the configure script. -*BGR to YUV convertion corrected. - -/*VERSION 0.2.3*/ -*Problems on big-endian architectures, corrected -(thanks to Marcel Unbehaun for bringing up the problem -and providing the neccessary feedback to resolve it). -*Failure to respect change in channels number, while -opening soundcard, which resulted in crashes, segfaults -and repeated error-messages has been fixed. -*other minor bugfixes - -/*VERSION 0.2.4*/ -*Behavior on lack of $DISPLAY evironment -variable has been corrected. -*Size adjustment is now quantized at 16 pixels, -in order to avoid complete image distortion, -present at certain resolutions, when using shared memory -(conditional or not). -*Some other minor bugfixes, related mostly to default -values of options. - -/*VERSION 0.2.5*/ -*Drawing of the correct cursor is now supported through -the Xfixes extension. -*Change of behavior on lack of any Xserver extension and -failure to open sound device. The program now exits and informs -instead of continuing with a different configuration. -*Exit status also indicates the nature of any error that occured. -*Documentation has been updated with exit status explanations. -*Subsampling of the chroma planes is made by averaging, while -pixel discarding is an option(used to be otherwise). - - -/*VERSION 0.2.6*/ -*Behavior on stream desync has been changed. -Now, instead of dropping sound buffers, image -capturing speeds up. That is, waiting for timer to -expire is disabled until sync is achieved. -When not recording sound, this does not apply. -*Theora return values are now properly checked, -to avoid inserting corrupt packages into the stream. -*Major memory leaks have been fixed. These were related -to the rectangle insertion algorithm and discarding of -used sound buffers, -*Segmentation fault on seemingly random occasions has been -found and is now fixed. Reason was lack of thread safety over -libogg calls. - - -/*VERSION 0.3.0*/ -*Implemented cache functionality -(Encoding by default happens right after the recording) -*Corrected damage event handling. -*Saving under the same file-name,no longer deletes the previous one, -instead it saves under a number postfixed file. -*Opening the sound device doesn't block anymore. -*A few new options were added related to caching. -*Program now checks if it is run uder a known 3d compositing window manager -and set behavior accordingly, to reduce the need for extra options at launch. -*Updated documentation. -*Removed uneeded bitmap screenshot function. - - diff --git a/rMD-exp/INSTALL b/rMD-exp/INSTALL deleted file mode 100644 index 393bf2e..0000000 --- a/rMD-exp/INSTALL +++ /dev/null @@ -1,38 +0,0 @@ -To compile the program you have to go through the regular drill: - -~$ gzip -d recordmydesktop-x.y.z.tar.gz -~$ tar -x recordmydesktop-x.y.z.tar -~$ cd recordmydesktop-x.y.z -~$ ./configure -~$ make -~$ sudo make install - - -You will need the development headers(i.e. packages ending with -dev or -devel -depending on the distribution you use) for the following: - -alsa (libasound) -X -libXext -libXdamage -libXfixes -libogg -libvorbis -libtheora - -Additionally you may need libICE-dev. - -Last, you need the regular headers, plus the ones for pthreads -(both of which you should have if you have compiled anything else before). - -Of the above, the most likely to be missing are probably those of libXdamage and libtheora -but any recent linux distribution should offer an easy way to get them. - - - - -Compiling on *BSD or other *nix flavors is not going to work(because of the alsa dependency) -but it shouldn't be too much of a hassle to change that(at least by disabling sound capture). -Future versions might include support for OSS-based sound capture. -If you are interested in this please let me know. - diff --git a/rMD-exp/Makefile.am b/rMD-exp/Makefile.am deleted file mode 100644 index 86af0cd..0000000 --- a/rMD-exp/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -SUBDIRS = src doc - -EXTRA_DIST=include - diff --git a/rMD-exp/NEWS b/rMD-exp/NEWS deleted file mode 100644 index b28b04f..0000000 --- a/rMD-exp/NEWS +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/rMD-exp/README b/rMD-exp/README deleted file mode 100644 index a64d5a5..0000000 --- a/rMD-exp/README +++ /dev/null @@ -1,6 +0,0 @@ -This is the experimental branch of recordMyDesktop. Changes that will -take place here might render the program unusuable and/or unstable. -Any stable changes that influence the program positively and bugfixes -will be merged back into the main tree. - - diff --git a/rMD-exp/TODO b/rMD-exp/TODO deleted file mode 100644 index 62a2465..0000000 --- a/rMD-exp/TODO +++ /dev/null @@ -1,3 +0,0 @@ -1)write a TODO -2)? -3)Profit! diff --git a/rMD-exp/autogen.sh b/rMD-exp/autogen.sh deleted file mode 100644 index 06af23f..0000000 --- a/rMD-exp/autogen.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - - -aclocal -autoheader -automake --copy --add-missing -autoconf
\ No newline at end of file diff --git a/rMD-exp/configure.ac b/rMD-exp/configure.ac deleted file mode 100644 index c8dae65..0000000 --- a/rMD-exp/configure.ac +++ /dev/null @@ -1,71 +0,0 @@ - # -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT(src/recordmydesktop.c) -AM_INIT_AUTOMAKE(recordmydesktop,0.3.0,) - -AC_CONFIG_SRCDIR([src/recordmydesktop.c]) -AM_CONFIG_HEADER(config.h) - - - -# Checks for programs. - -AC_PROG_CC - -# Checks for header files. - -AC_HEADER_DIRENT -AC_HEADER_STDC - -AC_PATH_X -AC_PATH_XTRA - -if test "x$x_libraries" != "x" && test "x$x_libraries" != xNONE ; then - echo "X libraries are found in $x_libraries" - LIBS="-L$x_libraries $LIBS"; -fi - -if test "x$x_includes" != "x" && test "x$x_includes" != xNONE ; then - echo "X includes are found in $x_includes" - CFLAGS="-I$x_includes $CFLAGS"; -fi - - - -AC_CHECK_HEADER([alsa/asoundlib.h]) -AC_CHECK_HEADERS([sys/time.h unistd.h vorbis/vorbisfile.h ]) - -# Checks for libraries. - -AC_CHECK_LIB([m],[isnan],,) -AC_CHECK_LIB([z],[deflate],,) -AC_CHECK_LIB([ICE],[IceOpenConnection],,AC_MSG_ERROR([Can't find libICE]),) -AC_CHECK_LIB([SM],[SmcOpenConnection],,AC_MSG_ERROR([Can't find libSM]),) -AC_CHECK_LIB([X11],[XOpenDisplay],,AC_MSG_ERROR([Can't find libX11]), - -L$x_libraries $X_PRE_LIBS) -AC_CHECK_LIB([Xext],[XShmQueryVersion],,AC_MSG_ERROR([Can't find libXext])) -AC_CHECK_LIB([Xfixes], [XFixesQueryExtension],,AC_MSG_ERROR([Can't find libXfixes])) -AC_CHECK_LIB([Xdamage], [XDamageQueryExtension],,AC_MSG_ERROR([Can't find libXdamage])) -AC_CHECK_LIB([vorbis],[vorbis_info_clear],,AC_MSG_ERROR([Can't find libvorbis])) -AC_CHECK_LIB([vorbisfile],[ov_open],,AC_MSG_ERROR([Can't find libvorbisfile]),-lvorbis) -AC_CHECK_LIB([vorbisenc],[vorbis_encode_init],,AC_MSG_ERROR([Can't find libvorbisenc]),-lvorbis) -AC_CHECK_LIB([ogg],[ogg_stream_init],,AC_MSG_ERROR([Can't find libogg])) -AC_CHECK_LIB([theora],[theora_encode_YUVin],,AC_MSG_ERROR([Can't find libtheora])) -AC_CHECK_LIB([pthread],[pthread_mutex_lock],,AC_MSG_ERROR([Can't find libpthread])) -AC_CHECK_LIB([asound],[snd_pcm_drain],,AC_MSG_ERROR([Can't find libasound])) - - - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. -AC_FUNC_CLOSEDIR_VOID -AC_FUNC_MALLOC - -AC_CONFIG_FILES([Makefile - src/Makefile - doc/Makefile ]) -AC_OUTPUT - diff --git a/rMD-exp/doc/Makefile.am b/rMD-exp/doc/Makefile.am deleted file mode 100644 index 9780b6c..0000000 --- a/rMD-exp/doc/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -man_MANS = recordmydesktop.1 -EXTRA_DIST = $(man_MANS) diff --git a/rMD-exp/doc/recordmydesktop.1 b/rMD-exp/doc/recordmydesktop.1 deleted file mode 100644 index 6fa7da5..0000000 --- a/rMD-exp/doc/recordmydesktop.1 +++ /dev/null @@ -1,438 +0,0 @@ -.TH "RECORDMYDESKTOP" 1 "13/7/2006" "Linux" - - -.SH NAME -recordMyDesktop \- record desktop sessions to an Ogg\-Theora\-Vorbis file. - - -.SH SYNOPSIS - -.B recordmydesktop -[ -.B -Options -]^ -.B -filename -.br -.br -.SH DESCRIPTION -.PP - recordMyDesktop produces a file(default out.ogg) that contains a video and audio recording -.br -of a linux desktop session. The default behavior of recording is to mark areas that have changed(through libxdamage) -.br -and update the frame. This behavior can be changed (option -.B -\-\-full\-shots -) to produce a more accurate result -.br -or capture windows that do not generate events on change(windows with accelerated 3d context) -.br -but this will notably increase the workload. In this case, enabling the -.B -\-\-with\-shared -option is recommended -.br -(by default this option is switched on or off at every frame, according to the size of the area to be aquired). -.br -.br -recordMyDesktop doesn't have a commandline interface. -.br -After startup, it can be controled only through the following signals: -.br -.br -.B -SIGUSR1 -causes the program to pause if it's currently recording, and vice-versa. -.br -.B -SIGTERM -causes normal termination of the recording. -.br -.B -SIGINT -also causes normal termination. -.br -.B -SIGABRT -terminates the program and removes the specified output file. -.br -.br -.br -A typical scenario of recording can be a command as simple as: -.br -.B -~$ recordmydesktop -.br -which will produce a fullscreen recording named out.ogg -.br -while a command like: -.br -.B -~$ recordmydesktop foo.ogg -.br -will write output to foo.ogg -.br -.br -Since version 0.3, encoding will happen right after the recording finishes. -.br -While this behavior saves a lot of CPU, you can revert to the old one by entering the \-\-on\-the\-fly\-encoding switch. -.br -.br -To specify a region for recording you can type this: -.br -.B -~$ recordmydesktop -x X_pos -y Y_pos -width WIDTH -height HEIGHT -o foo.ogg -.br -where X_pos and Y_pos specify the offset in pixels from the upper left -.br -corner of your screen and WIDTH and HEIGHT the size of the window to be recorded(again in pixels). -.br -If the area extends beyond your current resolution, you will be notified appropriately and nothing will happen. -.br -Notice also, that if any option is entered you have to specify the output file with the \-o switch. -.br -If you try to save under a filename that already exists, the name will be post-fixed with a number (incremented if that name exists already) -.br -.br -.B -To normally end a recording you can press ctl-c. -.br -(which will send a -.B -SIGINT -to the program). -.br -.br -For further manipulation of the end result look at the -.B -OPTIONS -and -.B -NOTES -sections. -.br -.br -.br -.SH EXIT STATUS -0 is success -.br -Non-zero means an error occurred, which is printed in stderr. -.br -.br -The following error codes indicate the nature of the error: -.br -1 Error while parsing the arguments. -.br -2 Initializing the encoder failed(either vorbis or theora). -.br -3 Could not open/configure sound card. -.br -4 Xdamage extension not present. -.br -5 Shared memory extension not present. -.br -6 Xfixes extension not present. -.br -7 XInitThreads failed. -.br -8 No $DISPLAY environment variable and none specified as argument. -.br -9 Cannot connect to Xserver. -.br -10 Color depth is not 24bpp. -.br -11 Improper window specification. -.br -12 Cannot attach shared memory to proccess. -.br -13 Cannot open file for writting. -.br -.br -.SH OPTIONS -.PP -.B -Generic Options: -.br -.TP -.B - \-h or \-\-help - Print help summary and exit. -.br -.TP -.B - \-\-version - Print program version and exit. -.br -.PP -.br -.B -Image Options: -.br -.TP -.B - \-windowid id_of_window - id of window to be recorded. -.br -.TP -.B - \-display DISPLAY - Display to connect to. -.br -.TP -.B - \-x X - Offset in x direction. -.br -.TP -.B - \-y Y - Offset in y direction. -.br -.TP -.B - \-width N - Width of recorded window. -.br -.TP -.B - \-height N - Height of recorded window. -.br -.TP -.B -.br -.br -.TP -.B - \-dummy\-cursor color - Draw a dummy cursor, instead of the normal one.Value of color can be "black" or "white". -.br -.TP -.B - \-\-no\-cursor - Disable drawing of the cursor. -.br -.TP -.B - \-\-with\-shared - Enable usage of MIT\-shared memory extension at all times. -.br -.TP -.B - \-\-no\-cond\-shared - Do not use the MIT\-shared memory extension when aquiring large areas. -.br -.TP -.B - \-shared\-threshold n - Threshold over which shared memory is used(default 75). -.br -.TP -.B - \-\-full\-shots - Take full screenshot at every frame(Not recomended!). -.br -.TP -.B - \-\-quick\-subsampling - Do subsampling of the chroma planes by discarding extra pixels. -.br -.TP -.B - \-fps N(number>0.0) - A positive number denoting desired framerate. -.br -.br -.PP -.B -Sound Options: -.br -.TP -.B - \-channels N(number>0) - A positive number denoting desired sound channels in recording. -.br -.TP -.B - \-freq N(number>0) - A positive number denoting desired sound frequency. -.br -.TP -.B - \-device SOUND_DEVICE - Sound device(default hw0:0). -.br -.TP -.B - \-\-no\-sound - Do not record sound. -.br -.PP -.br -.B -Encoding Options: -.br -.TP -.B - \-\-on\-the\-fly\-encoding - Encode the audio-video data, while recording. -.br -.TP -.B - \-v_quality n - A number from 0 to 63 for desired encoded video quality(default 63). -.br -.TP -.B - \-v_bitrate n - A number from 45000 to 2000000 for desired encoded video bitrate(default 45000). -.br -.TP -.B - \-\-drop\-frames - Allow theora encoder to drop frames(this can significantly lower proccessing times). -.br -.TP -.B - \-s_quality n - Desired audio quality(\-1 to 10). -.br -.PP -.br -.B -Misc Options: -.br -.TP -.B - \-\-no\-wm\-check - When a 3d compositing window manager is detected the program will function as if the - \-\-full\-shots and \-\-with\-shared options have been specified. This option disables that - behavior alltogether. -.br -.TP -.B - \-\-zero\-compression - Image data are always cached uncompressed. -.br -.TP -.B - \-workdir DIR - Location where a temporary directory will be created to hold project files(default $HOME). -.br -.TP -.B - \-delay n[H|h|M|m] - Number of secs(default),minutes or hours before capture starts(number can be float). -.br -.TP -.B - \-\-overwrite - If there is already a file with the same name, delete it. - Default action is to add a number postfix to the new file. - For example when not specifying a name, if out.ogg exists, - the new file will be out.ogg.1 and if that exists too, out.ogg.2 - and so on (no ad-infinitum though, more like ad-short-integer...) -.br -.TP -.B - \-o filename - Name of recorded video(default out.ogg). - - - -.PP -.br -If no other option is specified, filename can be given without the \-o switch. -.br -.br -.SH USAGE -.TP -.B recordmydesktop -.br -[\-h| \-\-help| \-\-version| \-delay n[H|h|M|m]| \-windowid id_of_window| -.br -\-display DISPLAY| \-x X| \-y Y|\-width N| \-height N| \-fps N(number>0)| \-\-on\-the\-fly\-encoding| -.br -\-v_quality n| \-s_quality n| \-v_bitrate n| \-\-no\-framedrop| \-dummy\-cursor color| -.br -\-\-no\-cursor| \-freq N(number>0)| \-channels N(number>0)| \-device SOUND_DEVICE| -.br -\-\-no\-sound| \-\-with\-shared| \-\-no\-cond\-shared| \-shared\-threshold n| \-\-full\-shots| -.br -\-\-quick\-subsampling| \-workdir DIR| \-\-zero\-compression| \-\-no\-wm\-check| \-\-overwrite| \-o filename]^filename -.br -.br -.br -.br -.SH ENVIRONMENT -.TP -.B -DISPLAY -.br -Display environment variable, specifying X server to connect to. -.br -.SH NOTES -.br - Recording a window using the \-windowid option, doesn't track the window itself, but the region that it covers. -.br -Also when using that option the \-x,\-y,\-width and \-height options are relative to the specified window area. -.br -An easy way to find out the id of a window, is by using the -.B -xwininfo -program. -.br -Running a command like : -.br -.B -xwininfo |grep "Window id:"|sed \-e "s/xwininfo\\:\\ Window id:\\ // ;s/\\ \.*//" -.br -will give you only the id of the window(which should look like this: 0x4800005) -.br -More conviniently you can put all that in the command that launches recordMyDesktop like this: -.br -.B -~$recordmydesktop -windowid $(xwininfo |grep "Window id:"|sed \-e "s/xwininfo\\:\\ Window id:\\ // ;s/\\ \.*//" ) -.br -.br - Also, the lower quality you select on a video recording ( -.B --v_quality -option), the highest CPU-power that you will need. -.br -So -.B -if you are doing the encoding on the fly -,it's better to start with default values and manipulate -the end\-result with another program. -.br -An excellent converter is -.B -ffmpeg2theora -, which despite its name is also a theora to theora converter. -.br -Changing the quality of a recordng with it,can be as simple as : -.br -.B -ffmpeg2theora infile.ogg \-v 3 \-a 4 \-o outfile.ogg -.br -It can even perform resizing on the size of the recording, or change the overall duration. -.br -.br -.SH BUGS -Does not record 3d windows, if \-\-full\-shots isn't specified. -.br -Saving 65536 files with the same name, will result in upredictable behavior, -.br -which might manifest as an endless loop, or a segmentation fault. -.br -.SH AUTHORS -John Varouhakis(johnvarouhakis@gmail.com) -.br -.SH SEE ALSO -.BR xwininfo(1) -.br -.BR ffmpeg2theora(1) -.br
\ No newline at end of file diff --git a/rMD-exp/include/recordmydesktop.h b/rMD-exp/include/recordmydesktop.h deleted file mode 100644 index 4c3ad18..0000000 --- a/rMD-exp/include/recordmydesktop.h +++ /dev/null @@ -1,745 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#ifndef RECORDMYDESKTOP_H -#define RECORDMYDESKTOP_H 1 - -#ifdef HAVE_CONFIG_H - #include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <math.h> -#include <unistd.h> -#include <fcntl.h> -#include <time.h> -#include <signal.h> -#include <sys/time.h> -#include <sys/types.h> -#include <endian.h> -#include <limits.h> -#include <sys/stat.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#include <pthread.h> -#include <zlib.h> -#include <X11/Xlib.h> -#include <X11/Xlibint.h> -#include <X11/Xatom.h> -#include <X11/extensions/Xfixes.h> -#include <X11/extensions/Xdamage.h> -#include <X11/extensions/XShm.h> -#include <theora/theora.h> -#include <vorbis/codec.h> -#include <vorbis/vorbisenc.h> -#include <ogg/ogg.h> -#include <alsa/asoundlib.h> - - -//define whcih way we are reading a pixmap -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define __ABYTE 3 -#define __RBYTE 2 -#define __GBYTE 1 -#define __BBYTE 0 - -#define __RVALUE(tmp_val) (((tmp_val)&0x00ff0000)>>16) -#define __GVALUE(tmp_val) (((tmp_val)&0x0000ff00)>>8) -#define __BVALUE(tmp_val) (((tmp_val)&0x000000ff)) - -#elif __BYTE_ORDER == __BIG_ENDIAN - -#define __ABYTE 0 -#define __RBYTE 1 -#define __GBYTE 2 -#define __BBYTE 3 - -#define __RVALUE(tmp_val) (((tmp_val)&0x0000ff00)>>8) -#define __GVALUE(tmp_val) (((tmp_val)&0x00ff0000)>>16) -#define __BVALUE(tmp_val) (((tmp_val)&0xff000000)>>24) - -#else -#error Only little-endian and big-endian systems are supported -#endif - - -//do not be confused -//this is useless and obsolete. -//There are no plans for other fotmats -enum {UNSPECIFIED,OGG_THEORA_VORBIS}; - - -/**Structs*/ - -typedef struct _DisplaySpecs{ //this struct holds some basic information - int screen; //about the display,needed mostly for - uint width; //validity checks at startup - uint height; - Window root; - Visual *visual; - GC gc; - int depth; - unsigned long bpixel; - unsigned long wpixel; -}DisplaySpecs; - -typedef struct _WGeometry{ //basic geometry of a window or area - int x; - int y; - int width; - int height; -}WGeometry; - -typedef struct _RectArea{ //an area that has been damaged gets stored - WGeometry geom; //in a list comprised of structs of this type - struct _RectArea *prev,*next; -}RectArea; - -typedef struct _BRWindow{ //'basic recorded window' specs - WGeometry geom; //window attributes - WGeometry rgeom; //part of window that is recorded - int nbytes; //size of zpixmap when screenshoting - Window windowid; //id -}BRWindow; - -//defaults in the following comment lines may be out of sync with reality -//check DEFAULT_ARGS macro further bellow -typedef struct _ProgArgs{ - int delay; //start up delay - Window windowid; //window to record(default root) - char *display; //display to connect(default :0) - int x,y; //x,y offset(default 0,0) - int width,height; //defaults to window width and height - int quietmode; //no messages to stderr,stdout - char *filename; //output file(default out.[ogg|*]) - int encoding; //encoding(default OGG_THEORA_VORBIS) - int cursor_color; //black or white=>1 or 0 - int have_dummy_cursor;//disable/enable drawing of the dummy cursor - int xfixes_cursor; //disable/enable drawing of a cursor obtained - //through the xfixes extension - float fps; //desired framerate(default 15) - unsigned int frequency; //desired frequency (default 22050) - unsigned int channels; //no of channels(default 2) - char *device; //default sound device(default according to alsa or oss) - int nosound; //do not record sound(default 0) - int noshared; //do not use shared memory extension(default 1) - int nocondshared; //do not use shared memory on large image aquititions - int nowmcheck; //do not check if there's a 3d comp window manager - //(which changes full-shots and with-shared to 1) - int shared_thres; //threshold to use shared memory - int full_shots; //do not poll damage, take full screenshots - int no_quick_subsample;//average pixels in chroma planes - int v_bitrate,v_quality,s_quality;//video bitrate,video-sound quality - int dropframes; //option for theora encoder - int encOnTheFly; //encode while recording, no caching(default 0) - char *workdir; //directory to be used for cache files(default $HOME) - int zerocompression;//image data are always flushed uncompressed - int overwrite;//overwite a previously existing file(do not add a .number postfix) -}ProgArgs; - - -//this struct holds anything related to encoding AND -//writting out to file. -typedef struct _EncData{ - ogg_stream_state m_ogg_ts;//theora - ogg_stream_state m_ogg_vs;//vorbis - ogg_page m_ogg_pg;//this could be avoided since - // it is used only while initializing - ogg_packet m_ogg_pckt1;//theora stream - ogg_packet m_ogg_pckt2;//vorbis stream -//theora data - theora_state m_th_st; - theora_info m_th_inf; - theora_comment m_th_cmmnt; - yuv_buffer yuv; -//vorbis data - vorbis_info m_vo_inf; - vorbis_comment m_vo_cmmnt; - vorbis_dsp_state m_vo_dsp; - vorbis_block m_vo_block; -//these should be 0, since area is quantized -//before input - int x_offset, - y_offset; -//our file - FILE *fp; -}EncData; - -//this struct will hold a few basic -//information, needed for caching the frames. -typedef struct _CacheData{ - char *workdir, //The directory were the project will be stored, while recording. - //Since this will take a lot of space, the user must be - //able to change the location. - *projname, //This is the name of the folder that will hold the project. - //It is rMD-session-%d where %d is the pid of the current proccess. - //This way, running two instances will not create problems - //and also, a frontend can identify leftovers from a possible crash - //and delete them - *imgdata, //workdir+projname+img.out.gz - *audiodata; //workdir+projname+audio.pcm - - gzFile *ifp; //image data file pointer - FILE *afp; //audio data file pointer - -}CacheData; - -//sound buffer -//sound keeps coming so we que it in this list -//which we then traverse -typedef struct _SndBuffer{ - signed char *data; - struct _SndBuffer *next; -}SndBuffer; - -//this structure holds any data related to the program -//It's usage is mostly to be given as an argument to the -//threads,so they will have access to the program data, avoiding -//at the same time usage of any globals. -typedef struct _ProgData{ - ProgArgs args;//the program arguments - DisplaySpecs specs;//Display specific information - BRWindow brwin;//recording window - Display *dpy;//curtrent display - char *window_manager;//name of the window manager at program launch - XImage *image;//the image that holds the current full screenshot - XImage *shimage;//the image that holds the current full screenshot(shared memory) - unsigned char *dummy_pointer;//a dummy pointer to be drawn in every frame - //data is casted to unsigned for later use in YUV buffer - int dummy_p_size;//initially 16x16,always square - unsigned char npxl;//this is the no pixel convention when drawing the dummy pointer - char *datamain,//the data of image - *datash,//the data of shimage - *datatemp;//buffer for the temporary image,which will be - //preallocated in case shared memory is not used. - RectArea *rect_root[2];//the interchanging list roots for storing the changed regions - int list_selector,//selector for the above - damage_event,//damage event base code - damage_error,//damage error base code - running; - SndBuffer *sound_buffer; - EncData *enc_data; - CacheData *cache_data; - int hard_pause;//if sound device doesn't support pause - //we have to close and reopen - int avd;//syncronization among audio and video - unsigned int periodtime, - frametime; - pthread_mutex_t list_mutex[2],//mutexes for concurrency protection of the lists - sound_buffer_mutex, - libogg_mutex,//libogg is not thread safe - yuv_mutex;//this might not be needed since we only have - //one read-only and one write-only thread - //also on previous versions, y component was looped separately - //and then u and v so this was needed to avoid wrong coloring to render - //Currently this mutex only prevents the cursor from flickering - pthread_cond_t time_cond,//this gets a broadcast by the handler whenever it's time to get a screenshot - pause_cond,//this is blocks execution, when program is paused - sound_buffer_ready,//sound encoding finished - sound_data_read,//a buffer is ready for proccessing - image_buffer_ready;//image encoding finished - snd_pcm_t *sound_handle; - snd_pcm_uframes_t periodsize; -}ProgData; - - -//This is the header of every frame. -//Reconstruction will be correct only if made on -//the same platform. - -//We need the total number of blocks -//for each plane. - -//The number of the frame compared to the -//number of time expirations at the time of -//caching, will enable us to make up for lost frames. - -//default 4+4+2+2+2=14!bad! -//me add pad, make god of 2 happy! -typedef struct _FrameHeader{ - char frame_prefix[4];//always FRAM - u_int32_t frameno,//number of frame(cached frames) - current_total;//number of frames that should have been - //taken at time of caching this one - u_int16_t Ynum,//number of changed blocks in the Y plane - Unum,//number of changed blocks in the U plane - Vnum;//number of changed blocks in the V plane - u_int16_t pad;//always zero - -}FrameHeader; - -//The frame after retrieval. -//Based on the Header information -//we can read the correct amount of bytes. - - -typedef struct _CachedFrame{ - FrameHeader *header; - unsigned char *YBlocks;//identifying number on the grid, starting at top left - unsigned char *UBlocks;// >> >> - unsigned char *VBlocks;// >> >> - unsigned char *YData;//pointer to data for the blocks that have changed, - unsigned char *UData;//which have to be remapped on the buffer when reading - unsigned char *VData; -}CachedFrame; - - -/**Globals*/ -//I've read somewhere that I'll go to hell for using globals... - -int Paused,*Running,Aborted; -pthread_cond_t *time_cond,*pause_cond; -unsigned char Yr[256],Yg[256],Yb[256], - Ur[256],Ug[256],Ub[256], - Vr[256],Vg[256],Vb[256]; -//the following values are of no effect -//but they might be usefull later for profiling -unsigned int frames_total,//frames calculated by total time expirations - frames_lost;//the value of shame -//used to determine frame drop which can -//happen on failure to receive a signal over a condition variable -int capture_busy, - encoder_busy; - - -/**Macros*/ - -#define CLIP_EVENT_AREA(e,brwin,wgeom){\ - if(((e)->area.x<=(brwin)->rgeom.x)&&((e)->area.y<=(brwin)->rgeom.y)&&\ - ((e)->area.width>=(brwin)->rgeom.width)&&((e)->area.height<(brwin)->rgeom.height)){\ - (wgeom)->x=(brwin)->rgeom.x;\ - (wgeom)->y=(brwin)->rgeom.y;\ - (wgeom)->width=(brwin)->rgeom.width;\ - (wgeom)->height=(brwin)->rgeom.height;\ - }\ - else{\ - (wgeom)->x=((((e)->area.x+(e)->area.width>=(brwin)->rgeom.x)&&\ - ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\ - (((e)->area.x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(e)->area.x):-1);\ - \ - (wgeom)->y=((((e)->area.y+(e)->area.height>=(brwin)->rgeom.y)&&\ - ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\ - (((e)->area.y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(e)->area.y):-1);\ - \ - (wgeom)->width=((e)->area.x<=(brwin)->rgeom.x)?\ - (e)->area.width-((brwin)->rgeom.x-(e)->area.x):\ - ((e)->area.x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\ - (((brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x<(e)->area.width)?\ - (brwin)->rgeom.width-(e)->area.x+(brwin)->rgeom.x:e->area.width):-1;\ - \ - (wgeom)->height=((e)->area.y<=(brwin)->rgeom.y)?\ - (e)->area.height-((brwin)->rgeom.y-(e)->area.y):\ - ((e)->area.y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\ - (((brwin)->rgeom.height-(e)->area.y+(brwin)->rgeom.y<(e)->area.height)?\ - (brwin)->rgeom.height-(e)->area.y+(brwin)->rgeom.y:(e)->area.height):-1;\ - \ - if((wgeom)->width>(brwin)->rgeom.width)(wgeom)->width=(brwin)->rgeom.width;\ - if((wgeom)->height>(brwin)->rgeom.height)(wgeom)->height=(brwin)->rgeom.height;\ - }\ -} - -#define CLIP_DUMMY_POINTER_AREA(dummy_p_area,brwin,wgeom){\ - (wgeom)->x=((((dummy_p_area).x+(dummy_p_area).width>=(brwin)->rgeom.x)&&\ - ((dummy_p_area).x<=(brwin)->rgeom.x+(brwin)->rgeom.width))?\ - (((dummy_p_area).x<=(brwin)->rgeom.x)?(brwin)->rgeom.x:(dummy_p_area).x):-1);\ - (wgeom)->y=((((dummy_p_area).y+(dummy_p_area).height>=(brwin)->rgeom.y)&&\ - ((dummy_p_area).y<=(brwin)->rgeom.y+(brwin)->rgeom.height))?\ - (((dummy_p_area).y<=(brwin)->rgeom.y)?(brwin)->rgeom.y:(dummy_p_area).y):-1);\ - (wgeom)->width=((dummy_p_area).x<=(brwin)->rgeom.x)?\ - (dummy_p_area).width-((brwin)->rgeom.x-(dummy_p_area).x):\ - ((dummy_p_area).x<=(brwin)->rgeom.x+(brwin)->rgeom.width)?\ - ((brwin)->rgeom.width-(dummy_p_area).x+(brwin)->rgeom.x<(dummy_p_area).width)?\ - (brwin)->rgeom.width-(dummy_p_area).x+(brwin)->rgeom.x:(dummy_p_area).width:-1;\ - (wgeom)->height=((dummy_p_area).y<=(brwin)->rgeom.y)?\ - (dummy_p_area).height-((brwin)->rgeom.y-(dummy_p_area).y):\ - ((dummy_p_area).y<=(brwin)->rgeom.y+(brwin)->rgeom.height)?\ - ((brwin)->rgeom.height-(dummy_p_area).y+(brwin)->rgeom.y<(dummy_p_area).height)?\ - (brwin)->rgeom.height-(dummy_p_area).y+(brwin)->rgeom.y:(dummy_p_area).height:-1;\ - if((wgeom)->width>(brwin)->rgeom.width)(wgeom)->width=(brwin)->rgeom.width;\ - if((wgeom)->height>(brwin)->rgeom.height)(wgeom)->height=(brwin)->rgeom.height;\ -} - - - -#define DEFAULT_ARGS(args){\ - (args)->delay=0;\ - if(getenv("DISPLAY")!=NULL){\ - (args)->display=(char *)malloc(strlen(getenv("DISPLAY"))+1);\ - strcpy((args)->display,getenv("DISPLAY"));\ - }\ - else\ - (args)->display=NULL;\ - (args)->windowid=(args)->x=(args)->y\ - =(args)->width=(args)->height=(args)->quietmode\ - =(args)->nosound=(args)->full_shots=(args)->encOnTheFly\ - =(args)->zerocompression=(args)->nowmcheck\ - =(args)->overwrite=0;\ - (args)->noshared=1;\ - (args)->dropframes=(args)->nocondshared=0;\ - (args)->no_quick_subsample=1;\ - (args)->filename=(char *)malloc(8);\ - strcpy((args)->filename,"out.ogg");\ - (args)->encoding=OGG_THEORA_VORBIS;\ - (args)->cursor_color=1;\ - (args)->shared_thres=75;\ - (args)->have_dummy_cursor=0;\ - (args)->xfixes_cursor=1;\ - (args)->device=(char *)malloc(8);\ - strcpy((args)->device,"hw:0,0");\ - (args)->fps=15;\ - (args)->channels=1;\ - (args)->frequency=22050;\ - (args)->v_bitrate=45000;\ - (args)->v_quality=63;\ - (args)->s_quality=10;\ - (args)->workdir=(char *)malloc(strlen(getenv("HOME"))+1);\ - strcpy((args)->workdir,getenv("HOME"));\ -} - -#define QUERY_DISPLAY_SPECS(display,specstruct){\ - (specstruct)->screen=DefaultScreen(display);\ - (specstruct)->width=DisplayWidth(display,(specstruct)->screen);\ - (specstruct)->height=DisplayHeight(display,(specstruct)->screen);\ - (specstruct)->root=RootWindow(display,(specstruct)->screen);\ - (specstruct)->visual=DefaultVisual(display,(specstruct)->screen);\ - (specstruct)->gc=DefaultGC(display,(specstruct)->screen);\ - (specstruct)->depth=DefaultDepth(display,(specstruct)->screen);\ - (specstruct)->bpixel=XBlackPixel(display,(specstruct)->screen);\ - (specstruct)->wpixel=XWhitePixel(display,(specstruct)->screen);\ -} - -#define AVG_4_PIXELS(data_array,width_img,k_tm,i_tm,offset)\ - ((data_array[(k_tm*width_img+i_tm)*4+offset]+data_array[((k_tm-1)*width_img+i_tm)*4+offset]\ - +data_array[(k_tm*width_img+i_tm-1)*4+offset]+data_array[((k_tm-1)*width_img+i_tm-1)*4+offset])/4) - -#define UPDATE_YUV_BUFFER_SH(yuv,data,x_tm,y_tm,width_tm,height_tm){\ - int k,i;\ - register unsigned int t_val;\ - register unsigned int *datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width;\ - register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ - *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *_yr=Yr,*_yg=Yg,*_yb=Yb,\ - *_ur=Ur,*_ug=Ug,*_ub=Ub,\ - *_vr=Vr,*_vg=Vg,*_vb=Vb;\ -\ - for(k=0;k<height_tm;k++){\ - for(i=0;i<width_tm;i++){\ - t_val=*datapi;\ - *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\ - datapi++;\ - yuv_y++;\ - }\ - yuv_y+=yuv->y_width-width_tm;\ - datapi+=yuv->y_width-width_tm;\ - }\ - datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width;\ - for(k=0;k<height_tm;k+=2){\ - for(i=0;i<width_tm;i+=2){\ - t_val=*datapi;\ - *yuv_u=\ - _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\ - *yuv_v=\ - _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\ - datapi+=2;\ - yuv_u++;\ - yuv_v++;\ - }\ - yuv_u+=(yuv->y_width-width_tm)/2;\ - yuv_v+=(yuv->y_width-width_tm)/2;\ - datapi+=(2*yuv->y_width-width_tm);\ - }\ -} - -#define UPDATE_YUV_BUFFER_SH_AVG(yuv,data,x_tm,y_tm,width_tm,height_tm){\ - int k,i;\ - register unsigned int t_val,t1,t2,t3,t4;\ - register unsigned int *datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width,\ - *datapi_next=(unsigned int*)data+x_tm+(y_tm+1)*yuv->y_width;\ - register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ - *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *_yr=Yr,*_yg=Yg,*_yb=Yb,\ - *_ur=Ur,*_ug=Ug,*_ub=Ub,\ - *_vr=Vr,*_vg=Vg,*_vb=Vb;\ -\ - for(k=0;k<height_tm;k++){\ - for(i=0;i<width_tm;i++){\ - t_val=*datapi;\ - *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\ - datapi++;\ - yuv_y++;\ - }\ - yuv_y+=yuv->y_width-width_tm;\ - datapi+=yuv->y_width-width_tm;\ - }\ - datapi=(unsigned int*)data+x_tm+y_tm*yuv->y_width;\ - for(k=0;k<height_tm;k+=2){\ - for(i=0;i<width_tm;i+=2){\ - t1=*datapi;\ - t2=*(datapi+1);\ - t3=*datapi_next;\ - t4=*(datapi_next+1);\ - t_val=((((t1&0xff000000) +(t2&0xff000000)+\ - (t3&0xff000000)+(t4&0xff000000))/4)&0xff000000) \ - +((((t1&0x00ff0000) +(t2&0x00ff0000)+\ - (t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)\ - +((((t1&0x0000ff00) +(t2&0x0000ff00)+\ - (t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)\ - +((((t1&0x000000ff) +(t2&0x000000ff)+\ - (t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\ -\ - *yuv_u=\ - _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\ - *yuv_v=\ - _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\ - datapi+=2;\ - datapi_next+=2;\ - yuv_u++;\ - yuv_v++;\ - }\ - yuv_u+=(yuv->y_width-width_tm)/2;\ - yuv_v+=(yuv->y_width-width_tm)/2;\ - datapi+=(2*yuv->y_width-width_tm);\ - datapi_next+=(2*yuv->y_width-width_tm);\ - }\ -} - - - -#define UPDATE_YUV_BUFFER_IM(yuv,data,x_tm,y_tm,width_tm,height_tm){\ - int k,i;\ - register unsigned int t_val;\ - register unsigned int *datapi=(unsigned int*)data;\ - register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ - *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *_yr=Yr,*_yg=Yg,*_yb=Yb,\ - *_ur=Ur,*_ug=Ug,*_ub=Ub,\ - *_vr=Vr,*_vg=Vg,*_vb=Vb;\ -\ - for(k=0;k<height_tm;k++){\ - for(i=0;i<width_tm;i++){\ - t_val=*datapi;\ - *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\ - datapi++;\ - yuv_y++;\ - }\ - yuv_y+=yuv->y_width-width_tm;\ - }\ - datapi=(unsigned int*)data;\ - for(k=0;k<height_tm;k+=2){\ - for(i=0;i<width_tm;i+=2){\ - t_val=*datapi;\ - *yuv_u=\ - _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\ - *yuv_v=\ - _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\ - datapi+=2;\ - yuv_u++;\ - yuv_v++;\ - }\ - yuv_u+=(yuv->y_width-width_tm)/2;\ - yuv_v+=(yuv->y_width-width_tm)/2;\ - datapi+=width_tm;\ - }\ -} - -#define UPDATE_YUV_BUFFER_IM_AVG(yuv,data,x_tm,y_tm,width_tm,height_tm){\ - int k,i;\ - register unsigned int t_val,t1,t2,t3,t4;\ - register unsigned int *datapi=(unsigned int*)data,\ - *datapi_next=(unsigned int*)data+width_tm;\ - register unsigned char *yuv_y=yuv->y+x_tm+y_tm*yuv->y_width,\ - *yuv_u=yuv->u+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *yuv_v=yuv->v+x_tm/2+(y_tm*yuv->uv_width)/2,\ - *_yr=Yr,*_yg=Yg,*_yb=Yb,\ - *_ur=Ur,*_ug=Ug,*_ub=Ub,\ - *_vr=Vr,*_vg=Vg,*_vb=Vb;\ -\ - for(k=0;k<height_tm;k++){\ - for(i=0;i<width_tm;i++){\ - t_val=*datapi;\ - *yuv_y=_yr[__RVALUE(t_val)] + _yg[__GVALUE(t_val)] + _yb[__BVALUE(t_val)] ;\ - datapi++;\ - yuv_y++;\ - }\ - yuv_y+=yuv->y_width-width_tm;\ - }\ - datapi=(unsigned int*)data;\ - for(k=0;k<height_tm;k+=2){\ - for(i=0;i<width_tm;i+=2){\ - t1=*datapi;\ - t2=*(datapi+1);\ - t3=*datapi_next;\ - t4=*(datapi_next+1);\ - t_val=((((t1&0xff000000) +(t2&0xff000000)+\ - (t3&0xff000000)+(t4&0xff000000))/4)&0xff000000) \ - +((((t1&0x00ff0000) +(t2&0x00ff0000)+\ - (t3&0x00ff0000)+(t4&0x00ff0000))/4)&0x00ff0000)\ - +((((t1&0x0000ff00) +(t2&0x0000ff00)+\ - (t3&0x0000ff00)+(t4&0x0000ff00))/4)&0x0000ff00)\ - +((((t1&0x000000ff) +(t2&0x000000ff)+\ - (t3&0x000000ff)+(t4&0x000000ff))/4)&0x000000ff);\ -\ - *yuv_u=\ - _ur[__RVALUE(t_val)] + _ug[__GVALUE(t_val)] + _ub[__BVALUE(t_val)];\ - *yuv_v=\ - _vr[__RVALUE(t_val)] + _vg[__GVALUE(t_val)] + _vb[__BVALUE(t_val)];\ - datapi+=2;\ - datapi_next+=2;\ - yuv_u++;\ - yuv_v++;\ - }\ - yuv_u+=(yuv->y_width-width_tm)/2;\ - yuv_v+=(yuv->y_width-width_tm)/2;\ - datapi+=width_tm;\ - datapi_next+=width_tm;\ - }\ -} - - - -#define XFIXES_POINTER_TO_YUV(yuv,data,x_tm,y_tm,width_tm,height_tm,column_discard_stride){\ - int i,k,j=0;\ - unsigned char avg0,avg1,avg2,avg3;\ - int x_2=x_tm/2,y_2=y_tm/2;\ - for(k=0;k<height_tm;k++){\ - for(i=0;i<width_tm;i++){\ - yuv->y[x_tm+i+(k+y_tm)*yuv->y_width]=\ - (yuv->y[x_tm+i+(k+y_tm)*yuv->y_width]*(UCHAR_MAX-data[(j*4)+__ABYTE])+\ - (Yr[data[(j*4)+__RBYTE]] + Yg[data[(j*4)+__GBYTE]] + Yb[data[(j*4)+__BBYTE]])*data[(j*4)+__ABYTE])/UCHAR_MAX ;\ - if((k%2)&&(i%2)){\ - avg3=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__ABYTE);\ - avg2=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__RBYTE);\ - avg1=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__GBYTE);\ - avg0=AVG_4_PIXELS(data,(width_tm+column_discard_stride),k,i,__BBYTE);\ - yuv->u[x_2+i/2+(k/2+y_2)*yuv->uv_width]=\ - (yuv->u[x_2+i/2+(k/2+y_2)*yuv->uv_width]*(UCHAR_MAX-avg3)+\ - (Ur[avg2] + Ug[avg1] +Ub[avg0])*avg3)/UCHAR_MAX;\ - yuv->v[x_2+i/2+(k/2+y_2)*yuv->uv_width]=\ - (yuv->v[x_2+i/2+(k/2+y_2)*yuv->uv_width]*(UCHAR_MAX-avg3)+\ - (Vr[avg2] + Vg[avg1] +Vb[avg0])*avg3)/UCHAR_MAX;\ - }\ - j++;\ - }\ - j+=column_discard_stride;\ - }\ -} - -#define DUMMY_POINTER_TO_YUV(yuv,data_tm,x_tm,y_tm,width_tm,height_tm,no_pixel){\ - int i,k,j=0;\ - int x_2=x_tm/2,y_2=y_tm/2,y_width_2=(yuv)->y_width/2;\ - for(k=0;k<height_tm;k++){\ - for(i=0;i<width_tm;i++){\ - if(data_tm[(j*4)]!=(no_pixel)){\ - (yuv)->y[x_tm+i+(k+y_tm)*(yuv)->y_width]=Yr[data_tm[(j*4)+__RBYTE]] + Yg[data_tm[(j*4)+__GBYTE]] + Yb[data_tm[(j*4)+__BBYTE]];\ - if((k%2)&&(i%2)){\ - yuv->u[x_2+i/2+(k/2+y_2)*y_width_2]=Ur[data_tm[(k*width_tm+i)*4+__RBYTE]] + Ug[data_tm[(k*width_tm+i)*4+__GBYTE]] + Ub[data_tm[(k*width_tm+i)*4+__BBYTE]];\ - yuv->v[x_2+i/2+(k/2+y_2)*y_width_2]=Vr[data_tm[(k*width_tm+i)*4+__RBYTE]] + Vg[data_tm[(k*width_tm+i)*4+__GBYTE]] + Vb[data_tm[(k*width_tm+i)*4+__BBYTE]] ;\ - }\ - }\ - j++;\ - }\ - j+=16-width_tm;\ - }\ -} - - -#define I16TOA(number,buffer){\ - int t_num=(number),k=0,i=0;\ - char *t_buf=malloc(8);\ - t_num=t_num&((2<<15)-1);\ - while(t_num>0){\ - int digit=t_num%10;\ - t_buf[k]=digit+48;\ - t_num-=digit;\ - t_num/=10;\ - k++;\ - }\ - while(k>0)\ - (buffer)[i++]=t_buf[--k];\ - (buffer)[i]='\0';\ - free(t_buf);\ -};\ - -#define INIT_FRAME(frame_t,fheader_t,yuv_t){\ - (frame_t)->header=(fheader_t);\ - (frame_t)->YBlocks=malloc(256);\ - (frame_t)->UBlocks=malloc(64);\ - (frame_t)->VBlocks=malloc(64);\ - (frame_t)->YData=malloc((yuv_t)->y_width*(yuv_t)->y_height);\ - (frame_t)->UData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\ - (frame_t)->VData=malloc((yuv_t)->uv_width*(yuv_t)->uv_height);\ -}; - -#define CLEAR_FRAME(frame_t){\ - free((frame_t)->YBlocks);\ - free((frame_t)->UBlocks);\ - free((frame_t)->VBlocks);\ - free((frame_t)->YData);\ - free((frame_t)->UData);\ - free((frame_t)->VData);\ -}; - -/**Function prototypes*/ - -void *PollDamage(void *pdata); -void *GetFrame(void *pdata); -void *EncodeImageBuffer(void *pdata); -void *FlushToOgg(void *pdata); -void UpdateYUVBuffer(yuv_buffer *yuv,unsigned char *data,int x,int y,int width,int height); -void ClearList(RectArea **root); -int RectInsert(RectArea **root,WGeometry *wgeom); -int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,int *ngeoms); -void SetExpired(int signum); -void RegisterCallbacks(ProgArgs *args); -void UpdateImage(Display * dpy,yuv_buffer *yuv,pthread_mutex_t *yuv_mutex,DisplaySpecs *specs,RectArea **root,BRWindow *brwin,EncData *enc,char *datatemp,int noshmem,int no_quick_subsample); -int GetZPixmap(Display *dpy,Window root,char *data,int x,int y,int width,int height); -int ParseArgs(int argc,char **argv,ProgArgs *arg_return); -void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_error); -int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args); -unsigned char *MakeDummyPointer(DisplaySpecs *specs,int size,int color,int type,unsigned char *npxl); -void *CaptureSound(void *pdata); -void *EncodeSoundBuffer(void *pdata); -snd_pcm_t *OpenDev(const char *pcm_dev,unsigned int *channels,unsigned int *frequency,snd_pcm_uframes_t *periodsize,unsigned int *periodtime,int *hardpause); -void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready); -void MakeMatrices(); -void SizePack2_8_16(int *start,int *size,int limit); -void *CacheImageBuffer(void *pdata); -void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t); -void *CacheSoundBuffer(void *pdata); -void *LoadCache(void *pdata); -void SyncEncodeImageBuffer(ProgData *pdata); -void CancelTimer(void); -void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff); -char *rmdWMCheck(Display *dpy,Window root); -#endif - diff --git a/rMD-exp/src/Makefile.am b/rMD-exp/src/Makefile.am deleted file mode 100644 index d5fa847..0000000 --- a/rMD-exp/src/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -bin_PROGRAMS = recordmydesktop - - - -recordmydesktop_SOURCES= recordmydesktop.c\ - getzpixmap.c\ - parseargs.c\ - rectinsert.c\ - setbrwindow.c\ - queryextensions.c\ - register_callbacks.c\ - get_frame.c\ - update_image.c\ - poll_damage.c\ - encode_image_buffer.c\ - bgr_to_yuv.c\ - flush_to_ogg.c\ - make_dummy_pointer.c\ - opendev.c\ - capture_sound.c\ - encode_sound_buffer.c\ - init_encoder.c\ - cache_frame.c\ - cache_audio.c\ - rmd_cache.c\ - load_cache.c\ - wm_check.c - -INCLUDES= $(all_includes) -I../include - -recordmydesktop_LDFLAGS = @X_LIBS@ @X_EXTRA_LIBS@ @X_PRE_LIBS@ -recordmydesktop_CFLAGS = -D_THREAD_SAFE -pthread -Wall diff --git a/rMD-exp/src/bgr_to_yuv.c b/rMD-exp/src/bgr_to_yuv.c deleted file mode 100644 index 0f775e2..0000000 --- a/rMD-exp/src/bgr_to_yuv.c +++ /dev/null @@ -1,54 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void MakeMatrices(){ - int i; - - for(i=0;i<256;i++) - Yr[i]=(2104.0*i)/8192.0+8.0; - for(i=0;i<256;i++) - Yg[i]=(4130.0*i)/8192.0+8.0; - for(i=0;i<256;i++) - Yb[i]=(802.0*i)/8192.0; - - for(i=0;i<256;i++) - Ur[i]=37.8-(1204.0*i)/8192.0+8.0; - for(i=0;i<256;i++) - Ug[i]=74.2-(2384.0*i)/8192.0+8.0; - for(i=0;i<256;i++) - Ub[i]=(3598.0*i)/8192.0 ; - - for(i=0;i<256;i++) - Vr[i]=(3598.0*i)/8192.0; - for(i=0;i<256;i++) - Vg[i]=93.8-(3013.0*i)/8192.0+8.0; - for(i=0;i<256;i++) - Vb[i]=18.2-(585.0*i)/8192.0+8.0; -} - diff --git a/rMD-exp/src/cache_audio.c b/rMD-exp/src/cache_audio.c deleted file mode 100644 index 7b17d7b..0000000 --- a/rMD-exp/src/cache_audio.c +++ /dev/null @@ -1,67 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - -#include <recordmydesktop.h> -void *CacheSoundBuffer(void *pdata){ -//We are simply going to throw sound on the disk. -//It's sound is tiny compared to that of image, so -//compressing would reducethe overall size by only an -//insignificant fraction. - pthread_mutex_t smut; - pthread_mutex_init(&smut,NULL); - while((((ProgData *)pdata)->running)){ - SndBuffer *buff; - - if(Paused){ - pthread_mutex_t tmut; - pthread_mutex_init(&tmut,NULL); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&tmut); - } - - if(((ProgData *)pdata)->sound_buffer==NULL) - pthread_cond_wait(&((ProgData *)pdata)->sound_data_read,&smut); - - pthread_mutex_lock(&((ProgData *)pdata)->sound_buffer_mutex); - buff=((ProgData *)pdata)->sound_buffer; - //advance the list - ((ProgData *)pdata)->sound_buffer=((ProgData *)pdata)->sound_buffer->next; - pthread_mutex_unlock(&((ProgData *)pdata)->sound_buffer_mutex); - - fwrite(buff->data,((ProgData *)pdata)->periodsize,1,((ProgData *)pdata)->cache_data->afp); - - - - ((ProgData *)pdata)->avd-=((ProgData *)pdata)->periodtime; - - free(buff->data); - free(buff); - } - - fclose(((ProgData *)pdata)->cache_data->afp); - pthread_exit(&errno); -} - - diff --git a/rMD-exp/src/cache_frame.c b/rMD-exp/src/cache_frame.c deleted file mode 100644 index c100505..0000000 --- a/rMD-exp/src/cache_frame.c +++ /dev/null @@ -1,193 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - -#include <recordmydesktop.h> - - -int CompareBlocks(unsigned char *incoming,unsigned char *old,int blockno,int width, int height,int divisor){ - int j,i, - block_i=blockno/divisor,//place on the grid - block_k=blockno%divisor; - register unsigned char *incoming_reg=&(incoming[block_i*(width*height/divisor)+block_k*width/divisor]), - *old_reg=&(old[block_i*(width*height/divisor)+block_k*width/divisor]); - - for(j=0;j<height/divisor;j++){ - for(i=0;i<width/divisor;i++){ - if((*(incoming_reg++))!=(*(old_reg++))) - return 1; - } - incoming_reg+=(width-width/divisor); - old_reg+=(width-width/divisor); - } - - return 0; -} - -void FlushBlock(unsigned char *buf,int blockno,int width, int height,int divisor,gzFile *fp){ - int j, - block_i=blockno/divisor,//place on the grid - block_k=blockno%divisor; - register unsigned char *buf_reg=(&buf[block_i*(width*height/divisor)+block_k*width/divisor]); - for(j=0;j<height/divisor;j++){//we flush in rows - gzwrite(fp,(void *)buf_reg,width/divisor); - buf_reg+=width; - } -} - -void *CacheImageBuffer(void *pdata){ - pthread_mutex_t pmut,imut; - pthread_mutex_init(&pmut,NULL); - pthread_mutex_init(&imut,NULL); - yuv_buffer yuv[2]; - gzFile *fp=((ProgData *)pdata)->cache_data->ifp; - - if(fp==NULL)exit(13); - - int i,current=0,divisor=16,firstrun=1,frameno=0; - - for(i=0;i<2;i++){ - yuv[i].y_width=((ProgData *)pdata)->enc_data->yuv.y_width; - yuv[i].y_height=((ProgData *)pdata)->enc_data->yuv.y_height; - yuv[i].uv_width=((ProgData *)pdata)->enc_data->yuv.uv_width; - yuv[i].uv_height=((ProgData *)pdata)->enc_data->yuv.uv_height; - - yuv[i].y=(unsigned char *)malloc(yuv[i].y_width*yuv[i].y_height); - yuv[i].u=(unsigned char *)malloc(yuv[i].uv_width*yuv[i].uv_height); - yuv[i].v=(unsigned char *)malloc(yuv[i].uv_width*yuv[i].uv_height); - } - - - while(((ProgData *)pdata)->running){ - int prev; - int j; - unsigned short ynum,unum,vnum; - unsigned char yblocks[256],ublocks[64],vblocks[64]; - FrameHeader fheader; - ynum=unum=vnum=0; - - pthread_cond_wait(&((ProgData *)pdata)->image_buffer_ready,&imut); - if(Paused) - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); - - //rotate buffers - prev=current; - current=(current)?0:1; - //copy incoming - memcpy(yuv[current].y,((ProgData *)pdata)->enc_data->yuv.y,yuv[current].y_width*yuv[current].y_height); - memcpy(yuv[current].u,((ProgData *)pdata)->enc_data->yuv.u,yuv[current].uv_width*yuv[current].uv_height); - memcpy(yuv[current].v,((ProgData *)pdata)->enc_data->yuv.v,yuv[current].uv_width*yuv[current].uv_height); - //release main buffer - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); - //get checksums for new - - //find and flush different blocks - if(firstrun){ - firstrun=0; - for(j=0;j<pow(divisor,2);j++){ - ynum++; - yblocks[ynum-1]=j; - } - for(j=0;j<pow(divisor/2,2);j++){ - unum++; - ublocks[unum-1]=j; - } - for(j=0;j<pow(divisor/2,2);j++){ - vnum++; - vblocks[vnum-1]=j; - } - - } - else{ - for(j=0;j<pow(divisor,2);j++){ - if(CompareBlocks(yuv[current].y,yuv[prev].y,j,yuv[current].y_width,yuv[current].y_height,divisor)){ - ynum++; - yblocks[ynum-1]=j; - } - } - for(j=0;j<pow(divisor/2,2);j++){ - if(CompareBlocks(yuv[current].u,yuv[prev].u,j,yuv[current].uv_width,yuv[current].uv_height,divisor/2)){ - unum++; - ublocks[unum-1]=j; - } - } - for(j=0;j<pow(divisor/2,2);j++){ - if(CompareBlocks(yuv[current].v,yuv[prev].v,j,yuv[current].uv_width,yuv[current].uv_height,divisor/2)){ - vnum++; - vblocks[vnum-1]=j; - } - } - - } - /**WRITE FRAME TO DISK*/ - if(!((ProgData *)pdata)->args.zerocompression){ - if(ynum+unum+vnum>(pow(divisor,2)+pow(divisor/2,2)*2)/10) - gzsetparams (fp,1,Z_FILTERED); - else - gzsetparams (fp,0,Z_FILTERED); - } - - strncpy(fheader.frame_prefix,"FRAM",4); - fheader.frameno=++frameno; - fheader.current_total=frames_total; - fheader.Ynum=ynum; - fheader.Unum=unum; - fheader.Vnum=vnum; - fheader.pad=0; - gzwrite(fp,(void*)&fheader,sizeof(FrameHeader)); - //flush indexes - if(ynum)gzwrite(fp,yblocks,ynum); - if(unum)gzwrite(fp,ublocks,unum); - if(vnum)gzwrite(fp,vblocks,vnum); - - - //flush the blocks for each buffer - if(ynum) - for(j=0;j<ynum;j++) - FlushBlock(yuv[current].y,yblocks[j],yuv[current].y_width,yuv[current].y_height,divisor,fp); - if(unum) - for(j=0;j<unum;j++) - FlushBlock(yuv[current].u,ublocks[j],yuv[current].uv_width,yuv[current].uv_height,divisor/2,fp); - if(vnum) - for(j=0;j<vnum;j++) - FlushBlock(yuv[current].v,vblocks[j],yuv[current].uv_width,yuv[current].uv_height,divisor/2,fp); - - - /**@________________@**/ - ((ProgData *)pdata)->avd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels; - - } - - //clean up since we're not finished - for(i=0;i<2;i++){ - free(yuv[i].y); - free(yuv[i].u); - free(yuv[i].v); - } - fprintf(stderr,"Saved %d frames in a total of %d requests\n",frameno,frames_total); - gzclose(fp); - pthread_exit(&errno); -} diff --git a/rMD-exp/src/capture_sound.c b/rMD-exp/src/capture_sound.c deleted file mode 100644 index 3bda596..0000000 --- a/rMD-exp/src/capture_sound.c +++ /dev/null @@ -1,109 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void *CaptureSound(void *pdata){ - - int frames=((ProgData *)pdata)->periodsize>>((ProgData *)pdata)->args.channels; -// fprintf(stderr,"fr %d ps %d\n",frames,((ProgData *)pdata)->periodsize);fflush(stderr); - pthread_mutex_t pmut; - pthread_mutex_init(&pmut,NULL); - ((ProgData *)pdata)->sound_buffer=NULL; - - while(((ProgData *)pdata)->running){ - int sret=0; - SndBuffer *newbuf,*tmp; - if(Paused){ - if(!((ProgData *)pdata)->hard_pause){ - snd_pcm_pause(((ProgData *)pdata)->sound_handle,1); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); - snd_pcm_pause(((ProgData *)pdata)->sound_handle,0); - } - else{//device doesn't support pause(is this the norm?mine doesn't) - snd_pcm_close(((ProgData *)pdata)->sound_handle); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); - - ((ProgData *)pdata)->sound_handle= - OpenDev(((ProgData *)pdata)->args.device, - &((ProgData *)pdata)->args.channels, - &((ProgData *)pdata)->args.frequency, - NULL, - NULL, - NULL//let's hope that the device capabilities didn't magically change - ); - if(((ProgData *)pdata)->sound_handle==NULL){ - fprintf(stderr,"Couldn't reopen sound device.Exiting\n"); - ((ProgData *)pdata)->running=0; - errno=3; - pthread_exit(&errno); - } - } - } - - //create new buffer - newbuf=(SndBuffer *)malloc(sizeof(SndBuffer *)); - newbuf->data=(signed char *)malloc(((ProgData *)pdata)->periodsize); - newbuf->next=NULL; - - //read data into new buffer - while(sret<frames){ - int temp_sret=snd_pcm_readi(((ProgData *)pdata)->sound_handle, - newbuf->data+2*((ProgData *)pdata)->args.channels*sret, - frames-sret); - if(temp_sret==-EPIPE) - snd_pcm_prepare(((ProgData *)pdata)->sound_handle); - else if (temp_sret<0){ - fprintf(stderr,"An error occured while reading sound data:\n %s\n",snd_strerror(temp_sret)); - snd_pcm_prepare(((ProgData *)pdata)->sound_handle); - } - else - sret+=temp_sret; - } - - //queue the new buffer - pthread_mutex_lock(&((ProgData *)pdata)->sound_buffer_mutex); - tmp=((ProgData *)pdata)->sound_buffer; - if(((ProgData *)pdata)->sound_buffer==NULL) - ((ProgData *)pdata)->sound_buffer=newbuf; - else{ - while(tmp->next!=NULL) - tmp=tmp->next; - tmp->next=newbuf; - } - pthread_mutex_unlock(&((ProgData *)pdata)->sound_buffer_mutex); - - - //signal that there are data to be proccessed - pthread_cond_signal(&((ProgData *)pdata)->sound_data_read); - } - snd_pcm_close(((ProgData *)pdata)->sound_handle); - pthread_exit(&errno); -} - - - diff --git a/rMD-exp/src/encode_image_buffer.c b/rMD-exp/src/encode_image_buffer.c deleted file mode 100644 index 8ff9629..0000000 --- a/rMD-exp/src/encode_image_buffer.c +++ /dev/null @@ -1,83 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - -#include <recordmydesktop.h> -void *EncodeImageBuffer(void *pdata){ - pthread_mutex_t pmut,imut; - pthread_mutex_init(&pmut,NULL); - pthread_mutex_init(&imut,NULL); - while(((ProgData *)pdata)->running){ - pthread_cond_wait(&((ProgData *)pdata)->image_buffer_ready,&imut); - encoder_busy=1; - if(Paused) - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut);//this may not be needed - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); - if(theora_encode_YUVin(&((ProgData *)pdata)->enc_data->m_th_st,&((ProgData *)pdata)->enc_data->yuv)){ - fprintf(stderr,"Encoder not ready!\n"); - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); - } - else{ - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); - if(theora_encode_packetout(&((ProgData *)pdata)->enc_data->m_th_st,0,&((ProgData *)pdata)->enc_data->m_ogg_pckt1)==1){ - pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex); - ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_ts,&((ProgData *)pdata)->enc_data->m_ogg_pckt1); - pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex); - ((ProgData *)pdata)->avd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels; - } - } - encoder_busy=0; - } - //last packet - if(theora_encode_YUVin(&((ProgData *)pdata)->enc_data->m_th_st,&((ProgData *)pdata)->enc_data->yuv)){ - fprintf(stderr,"Encoder not ready!\n"); - } - - theora_encode_packetout(&((ProgData *)pdata)->enc_data->m_th_st,1,&((ProgData *)pdata)->enc_data->m_ogg_pckt1); - -// ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_ts,&((ProgData *)pdata)->enc_data->m_ogg_pckt); - - pthread_exit(&errno); -} - -//this function is meant to be called normally -//not through a thread of it's own -void SyncEncodeImageBuffer(ProgData *pdata){ - if(theora_encode_YUVin(&pdata->enc_data->m_th_st, - &pdata->enc_data->yuv)){ - fprintf(stderr,"Encoder not ready!\n"); - } - else{ - if(theora_encode_packetout(&pdata->enc_data->m_th_st,0, - &pdata->enc_data->m_ogg_pckt1)==1){ - pthread_mutex_lock(&pdata->libogg_mutex); - ogg_stream_packetin(&pdata->enc_data->m_ogg_ts, - &pdata->enc_data->m_ogg_pckt1); - pthread_mutex_unlock(&pdata->libogg_mutex); - pdata->avd+=pdata->frametime*2*pdata->args.channels; - } - } -} - diff --git a/rMD-exp/src/encode_sound_buffer.c b/rMD-exp/src/encode_sound_buffer.c deleted file mode 100644 index 73f6d48..0000000 --- a/rMD-exp/src/encode_sound_buffer.c +++ /dev/null @@ -1,121 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void *EncodeSoundBuffer(void *pdata){ - - int sampread=((ProgData *)pdata)->periodsize/(2*((ProgData *)pdata)->args.channels); - pthread_mutex_t smut; - pthread_mutex_init(&smut,NULL); - while((((ProgData *)pdata)->running)){ - float **vorbis_buffer; - int count=0,i,j; - SndBuffer *buff; - - if(Paused){ - pthread_mutex_t tmut; - pthread_mutex_init(&tmut,NULL); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&tmut); - } - - if(((ProgData *)pdata)->sound_buffer==NULL) - pthread_cond_wait(&((ProgData *)pdata)->sound_data_read,&smut); - - pthread_mutex_lock(&((ProgData *)pdata)->sound_buffer_mutex); - buff=((ProgData *)pdata)->sound_buffer; - //advance the list - ((ProgData *)pdata)->sound_buffer=((ProgData *)pdata)->sound_buffer->next; - pthread_mutex_unlock(&((ProgData *)pdata)->sound_buffer_mutex); - - vorbis_buffer=vorbis_analysis_buffer(&((ProgData *)pdata)->enc_data->m_vo_dsp,sampread); - for(i=0;i<sampread;i++){ - for(j=0;j<((ProgData *)pdata)->args.channels;j++){ - vorbis_buffer[j][i]=((buff->data[count+1]<<8)| - (0x00ff&(int)buff->data[count]))/32768.f; - count+=2; - } - } - vorbis_analysis_wrote(&((ProgData *)pdata)->enc_data->m_vo_dsp,sampread); - - while(vorbis_analysis_blockout(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_vo_block)==1){ - - vorbis_analysis(&((ProgData *)pdata)->enc_data->m_vo_block,NULL); - vorbis_bitrate_addblock(&((ProgData *)pdata)->enc_data->m_vo_block); - - while(vorbis_bitrate_flushpacket(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_ogg_pckt2)){ - pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex); - ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_vs,&((ProgData *)pdata)->enc_data->m_ogg_pckt2); - pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex); - } - } - ((ProgData *)pdata)->avd-=((ProgData *)pdata)->periodtime; - - free(buff->data); - free(buff); - } - - vorbis_analysis_wrote(&((ProgData *)pdata)->enc_data->m_vo_dsp,0); -// while(vorbis_analysis_blockout(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_vo_block)==1){ -// vorbis_analysis(&((ProgData *)pdata)->enc_data->m_vo_block,NULL); -// vorbis_bitrate_addblock(&((ProgData *)pdata)->enc_data->m_vo_block); -// while(vorbis_bitrate_flushpacket(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_ogg_pckt2)) -// ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_vs,&((ProgData *)pdata)->enc_data->m_ogg_pckt2); -// } - - pthread_exit(&errno); -} - -void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff){ - float **vorbis_buffer; - int count=0,i,j; - int sampread=pdata->periodsize/(2*pdata->args.channels); - vorbis_buffer=vorbis_analysis_buffer(&pdata->enc_data->m_vo_dsp,sampread); - for(i=0;i<sampread;i++){ - for(j=0;j<pdata->args.channels;j++){ - vorbis_buffer[j][i]=((buff[count+1]<<8)| - (0x00ff&(int)buff[count]))/32768.f; - count+=2; - } - } - - vorbis_analysis_wrote(&pdata->enc_data->m_vo_dsp,sampread); - - while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_vo_block)==1){ - - vorbis_analysis(&pdata->enc_data->m_vo_block,NULL); - vorbis_bitrate_addblock(&pdata->enc_data->m_vo_block); - - while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_ogg_pckt2)){ - pthread_mutex_lock(&pdata->libogg_mutex); - ogg_stream_packetin(&pdata->enc_data->m_ogg_vs,&pdata->enc_data->m_ogg_pckt2); - pthread_mutex_unlock(&pdata->libogg_mutex); - } - } - pdata->avd-=pdata->periodtime; -} - diff --git a/rMD-exp/src/flush_to_ogg.c b/rMD-exp/src/flush_to_ogg.c deleted file mode 100644 index fed07c5..0000000 --- a/rMD-exp/src/flush_to_ogg.c +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - -#include <recordmydesktop.h> - -void *FlushToOgg(void *pdata){ - int videoflag=0,audioflag=0; - double video_bytesout=0,audio_bytesout=0; - ogg_page videopage,audiopage; - while(((ProgData *)pdata)->running){ - pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex); - videoflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage); - pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex); - if(videoflag){ - video_bytesout+=fwrite(videopage.header,1,videopage.header_len,((ProgData *)pdata)->enc_data->fp); - video_bytesout+=fwrite(videopage.body,1,videopage.body_len,((ProgData *)pdata)->enc_data->fp); - videoflag=0; - if(!((ProgData *)pdata)->args.nosound){ - pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex); - audioflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_vs,&audiopage); - pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex); - if(audioflag){ - audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,((ProgData *)pdata)->enc_data->fp); - audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,((ProgData *)pdata)->enc_data->fp); - audioflag=0; - } - } - } - else - usleep(10000); - - } - //last packages - videoflag=ogg_stream_flush(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage); - if(videoflag){ - video_bytesout+=fwrite(videopage.header,1,videopage.header_len,((ProgData *)pdata)->enc_data->fp); - video_bytesout+=fwrite(videopage.body,1,videopage.body_len,((ProgData *)pdata)->enc_data->fp); - videoflag=0; - } - if(!((ProgData *)pdata)->args.nosound) - audioflag=ogg_stream_flush(&((ProgData *)pdata)->enc_data->m_ogg_vs,&audiopage); - if(audioflag){ - audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,((ProgData *)pdata)->enc_data->fp); - audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,((ProgData *)pdata)->enc_data->fp); - audioflag=0; - } - - ogg_stream_clear(&((ProgData *)pdata)->enc_data->m_ogg_ts); - if(!((ProgData *)pdata)->args.nosound) - ogg_stream_clear(&((ProgData *)pdata)->enc_data->m_ogg_vs); -//this always gives me a segfault :( -// theora_clear(&((ProgData *)pdata)->enc_data->m_th_st); - - if(((ProgData *)pdata)->enc_data->fp)fclose(((ProgData *)pdata)->enc_data->fp); - - fprintf(stderr,"\r \nDone.\nWritten %.0f bytes\n(%.0f of which were video data and %.0f audio data)\n\n",video_bytesout+audio_bytesout,video_bytesout,audio_bytesout); - pthread_exit(&errno); -} diff --git a/rMD-exp/src/get_frame.c b/rMD-exp/src/get_frame.c deleted file mode 100644 index b1da1fe..0000000 --- a/rMD-exp/src/get_frame.c +++ /dev/null @@ -1,209 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void *GetFrame(void *pdata){ - int tlist_sel=0; - pthread_mutex_t pmut,tmut; - uint msk_ret; - WGeometry mouse_pos_abs,mouse_pos_rel,mouse_pos_temp; - Window root_ret,child_ret; - int pixel_total=((ProgData *)pdata)->brwin.rgeom.width*((ProgData *)pdata)->brwin.rgeom.height; - XFixesCursorImage *xcim=NULL; - - mouse_pos_abs.x=mouse_pos_temp.x=0; - mouse_pos_abs.y=mouse_pos_temp.y=0; - mouse_pos_abs.width=mouse_pos_temp.width=((ProgData *)pdata)->dummy_p_size; - mouse_pos_abs.height=mouse_pos_temp.height=((ProgData *)pdata)->dummy_p_size; - pthread_mutex_init(&pmut,NULL); - pthread_mutex_init(&tmut,NULL); - - while(((ProgData *)pdata)->running){ - - //if we are left behind we must not wait. - //also before actually pausing we must make sure the streams - //are synced. sound stops so this should only happen quickly. - if(((ProgData *)pdata)->avd>0){ - pthread_cond_wait(&((ProgData *)pdata)->time_cond,&tmut); - if(Paused){ - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); - } - } - capture_busy=1; - - /*pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&((ProgData *)pdata)->pause_cond_mutex);*/ - //mutexes and lists with changes are useless when full_shots is enabled - if(!((ProgData *)pdata)->args.full_shots){ - tlist_sel=((ProgData *)pdata)->list_selector; - ((ProgData *)pdata)->list_selector=((((ProgData *)pdata)->list_selector+1)%2); - pthread_mutex_lock(&((ProgData *)pdata)->list_mutex[tlist_sel]); - } - //here we measure the list and decide which way we will go - if(!((ProgData *)pdata)->args.nocondshared){ - int level=0; - RectArea *temp=((ProgData *)pdata)->rect_root[tlist_sel]; - - if(temp!=NULL){ - do{ - level+=temp->geom.width*temp->geom.height; - temp=temp->next; - }while(temp!=NULL); - level*=100; - level/=pixel_total; - ((ProgData *)pdata)->args.noshared=(level<((ProgData *)pdata)->args.shared_thres); -// if(!((ProgData *)pdata)->args.noshared){ -// fprintf(stderr,"shared screenshot with %d\n",level); -// } - } - } - if(((ProgData *)pdata)->args.xfixes_cursor){ - //xfixes pointer sequence - //update previous_position - //(if full_shots is enabled this is skipped since it's pointless) - if(!((ProgData *)pdata)->args.full_shots){ - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)) - RectInsert(&((ProgData *)pdata)->rect_root[tlist_sel],&mouse_pos_temp); - } - xcim=XFixesGetCursorImage(((ProgData *)pdata)->dpy); - mouse_pos_abs.x=xcim->x; - mouse_pos_abs.y=xcim->y; - mouse_pos_abs.width=xcim->width; - mouse_pos_abs.height=xcim->height; - } - if(((ProgData *)pdata)->args.have_dummy_cursor){ - //dummy pointer sequence - //update previous_position - //(if full_shots is enabled this is skipped since it's pointless) - if(!((ProgData *)pdata)->args.full_shots){ - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)) - RectInsert(&((ProgData *)pdata)->rect_root[tlist_sel],&mouse_pos_temp); - } - //find new one - XQueryPointer(((ProgData *)pdata)->dpy, - ((ProgData *)pdata)->specs.root, - &root_ret,&child_ret, - &mouse_pos_abs.x,&mouse_pos_abs.y, - &mouse_pos_rel.x,&mouse_pos_rel.y,&msk_ret); - } - if(!((ProgData *)pdata)->args.noshared) - XShmGetImage(((ProgData *)pdata)->dpy,((ProgData *)pdata)->specs.root,((ProgData *)pdata)->shimage,(((ProgData *)pdata)->brwin.rgeom.x),(((ProgData *)pdata)->brwin.rgeom.y),AllPlanes); - if(!((ProgData *)pdata)->args.full_shots) - UpdateImage(((ProgData *)pdata)->dpy, - &((ProgData *)pdata)->enc_data->yuv, - &((ProgData *)pdata)->yuv_mutex, - &((ProgData *)pdata)->specs, - &((ProgData *)pdata)->rect_root[tlist_sel], - &((ProgData *)pdata)->brwin, - ((ProgData *)pdata)->enc_data, - ((((ProgData *)pdata)->args.noshared)?(((ProgData *)pdata)->datatemp):((ProgData *)pdata)->shimage->data), - ((ProgData *)pdata)->args.noshared, - ((ProgData *)pdata)->args.no_quick_subsample); - else{ - if(((ProgData *)pdata)->args.noshared){ - GetZPixmap( ((ProgData *)pdata)->dpy, - ((ProgData *)pdata)->specs.root, - ((ProgData *)pdata)->image->data, - ((ProgData *)pdata)->brwin.rgeom.x, - ((ProgData *)pdata)->brwin.rgeom.y, - ((ProgData *)pdata)->brwin.rgeom.width, - ((ProgData *)pdata)->brwin.rgeom.height); - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); - if(((ProgData *)pdata)->args.no_quick_subsample){ - UPDATE_YUV_BUFFER_IM_AVG((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->image->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); - } - else{ - UPDATE_YUV_BUFFER_IM((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->image->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); - } - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); - } - else{ - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); - if(((ProgData *)pdata)->args.no_quick_subsample){ - UPDATE_YUV_BUFFER_IM_AVG((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->shimage->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); - } - else{ - UPDATE_YUV_BUFFER_IM((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->shimage->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); - } - - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); - } - } - if(((ProgData *)pdata)->args.xfixes_cursor){ - //avoid segfaults - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); - //draw the cursor - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)){ - XFIXES_POINTER_TO_YUV((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)xcim->pixels), - (mouse_pos_temp.x-((ProgData *)pdata)->brwin.rgeom.x+((ProgData *)pdata)->enc_data->x_offset), - (mouse_pos_temp.y-((ProgData *)pdata)->brwin.rgeom.y+((ProgData *)pdata)->enc_data->y_offset), - mouse_pos_temp.width, - mouse_pos_temp.height, - (xcim->width-mouse_pos_temp.width)); - } - XFree(xcim); - xcim=NULL; - } - - if(((ProgData *)pdata)->args.have_dummy_cursor){ - //avoid segfaults - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); - //draw the cursor - if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)){ - DUMMY_POINTER_TO_YUV((&((ProgData *)pdata)->enc_data->yuv), - ((ProgData *)pdata)->dummy_pointer, - (mouse_pos_temp.x-((ProgData *)pdata)->brwin.rgeom.x+((ProgData *)pdata)->enc_data->x_offset), - (mouse_pos_temp.y-((ProgData *)pdata)->brwin.rgeom.y+((ProgData *)pdata)->enc_data->y_offset), - mouse_pos_temp.width, - mouse_pos_temp.height, - ((ProgData *)pdata)->npxl); - } - } - if(!((ProgData *)pdata)->args.full_shots){ - ClearList(&((ProgData *)pdata)->rect_root[tlist_sel]); - pthread_mutex_unlock(&((ProgData *)pdata)->list_mutex[tlist_sel]); - } - if(encoder_busy){ - frames_lost++; - } - pthread_cond_broadcast(&((ProgData *)pdata)->image_buffer_ready); - capture_busy=0; - } - pthread_cond_broadcast(&((ProgData *)pdata)->image_buffer_ready); - pthread_exit(&errno); -} - diff --git a/rMD-exp/src/getzpixmap.c b/rMD-exp/src/getzpixmap.c deleted file mode 100644 index 4a7a7de..0000000 --- a/rMD-exp/src/getzpixmap.c +++ /dev/null @@ -1,55 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -int GetZPixmap(Display *dpy,Window root,char *data,int x,int y,int width,int height) { - xGetImageReply reply; - xGetImageReq *request; - long nbytes; - - LockDisplay(dpy); - GetReq(GetImage,request); - request->drawable=root; - request->x=x; - request->y=y; - request->width=width; - request->height=height; - request->planeMask=AllPlanes; - request->format=ZPixmap; - if((!_XReply(dpy,(xReply *)&reply,0,xFalse))||(!reply.length)){ - UnlockDisplay(dpy); - SyncHandle(); - return 1; - } - nbytes=(long)reply.length<<2; - _XReadPad(dpy,data,nbytes); - UnlockDisplay(dpy); - SyncHandle(); - return 0; -} - diff --git a/rMD-exp/src/init_encoder.c b/rMD-exp/src/init_encoder.c deleted file mode 100644 index 84d36aa..0000000 --- a/rMD-exp/src/init_encoder.c +++ /dev/null @@ -1,202 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -int IncrementalNaming(char **name){ - struct stat buff; - char *base_name; - int i=0; - base_name=malloc(strlen(*name)); - strcpy(base_name,*name); - - //this will go on an endless loop if you have 65536? files with the same name - //or it will crash and die.anyone interested in trying ? - while (stat(*name,&buff)==0){ - //create new name - char *tname=malloc(strlen(*name)+10); - char numbuf[8]; - - strcpy(tname,base_name); - strcat(tname,"."); - I16TOA((++i),numbuf) - strcat(tname,numbuf); - //save new name - free(*name); - *name=malloc(strlen(tname)+1); - strcpy(*name,tname); - free(tname); - } - free(base_name); - return 0; -} - -void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready){ - int y1,y2; - (pdata)->enc_data=enc_data_t; - srand(time(NULL)); - y1=rand(); - y2=rand(); - y2+=(y1==y2); - - ogg_stream_init(&(enc_data_t)->m_ogg_ts,y1); - if(!pdata->args.nosound) - ogg_stream_init(&(enc_data_t)->m_ogg_vs,y2); - if(!pdata->args.overwrite) - IncrementalNaming(&(pdata)->args.filename); - (enc_data_t)->fp=fopen((pdata)->args.filename,"w"); - if((enc_data_t)->fp==NULL){ - fprintf(stderr,"Cannot open file %s for writting!\n",(pdata)->args.filename); - exit(13); - } - theora_info_init(&(enc_data_t)->m_th_inf); - (enc_data_t)->m_th_inf.frame_width=(pdata)->brwin.rgeom.width; - (enc_data_t)->m_th_inf.frame_height=(pdata)->brwin.rgeom.height; - (enc_data_t)->m_th_inf.width=(((enc_data_t)->m_th_inf.frame_width + 15) >>4)<<4; - (enc_data_t)->m_th_inf.height=(((enc_data_t)->m_th_inf.frame_height + 15) >>4)<<4; - (enc_data_t)->m_th_inf.offset_x=(((enc_data_t)->m_th_inf.width-(enc_data_t)->m_th_inf.frame_width)/2)&~1; - (enc_data_t)->m_th_inf.offset_y=(((enc_data_t)->m_th_inf.height-(enc_data_t)->m_th_inf.frame_height)/2)&~1; - (enc_data_t)->m_th_inf.fps_numerator=((pdata)->args.fps*100.0); - (enc_data_t)->m_th_inf.fps_denominator=100; - (enc_data_t)->m_th_inf.aspect_numerator=1;//(pdata)->brwin.rgeom.width; - (enc_data_t)->m_th_inf.aspect_denominator=1;//(pdata)->brwin.rgeom.height; - (enc_data_t)->m_th_inf.colorspace=OC_CS_UNSPECIFIED; - (enc_data_t)->m_th_inf.pixelformat=OC_PF_420; - (enc_data_t)->m_th_inf.target_bitrate=(pdata)->args.v_bitrate; - (enc_data_t)->m_th_inf.quality=(pdata)->args.v_quality; - (enc_data_t)->m_th_inf.dropframes_p=(pdata)->args.dropframes; - (enc_data_t)->m_th_inf.quick_p=1; - (enc_data_t)->m_th_inf.keyframe_auto_p=1; - (enc_data_t)->m_th_inf.keyframe_frequency=64; - (enc_data_t)->m_th_inf.keyframe_frequency_force=64; - (enc_data_t)->m_th_inf.keyframe_data_target_bitrate=(enc_data_t)->m_th_inf.quality*1.5; - (enc_data_t)->m_th_inf.keyframe_auto_threshold=80; - (enc_data_t)->m_th_inf.keyframe_mindistance=8; - (enc_data_t)->m_th_inf.noise_sensitivity=1; - (enc_data_t)->m_th_inf.sharpness=2; - - theora_encode_init(&(enc_data_t)->m_th_st,&(enc_data_t)->m_th_inf); - - - - if(!pdata->args.nosound){ - int ret; - vorbis_info_init(&(enc_data_t)->m_vo_inf); - ret = vorbis_encode_init_vbr(&(enc_data_t)->m_vo_inf,pdata->args.channels,pdata->args.frequency,(float)pdata->args.s_quality*0.1); - if(ret){ - fprintf(stderr,"Error while setting up vorbis stream quality!\n"); - exit(2); - } - vorbis_comment_init(&(enc_data_t)->m_vo_cmmnt); - vorbis_analysis_init(&(enc_data_t)->m_vo_dsp,&(enc_data_t)->m_vo_inf); - vorbis_block_init(&(enc_data_t)->m_vo_dsp,&(enc_data_t)->m_vo_block); - } - - - theora_encode_header(&(enc_data_t)->m_th_st,&(enc_data_t)->m_ogg_pckt1); - ogg_stream_packetin(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pckt1); - if(ogg_stream_pageout(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pg)!=1){ - fprintf(stderr,"Internal Ogg library error.\n"); - exit(2); - } - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); - - theora_comment_init(&(enc_data_t)->m_th_cmmnt); - theora_comment_add_tag(&(enc_data_t)->m_th_cmmnt,"recordMyDesktop",VERSION); - theora_encode_comment(&(enc_data_t)->m_th_cmmnt,&(enc_data_t)->m_ogg_pckt1); - ogg_stream_packetin(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pckt1); - theora_encode_tables(&(enc_data_t)->m_th_st,&(enc_data_t)->m_ogg_pckt1); - ogg_stream_packetin(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pckt1); - - - if(!pdata->args.nosound){ - ogg_packet header; - ogg_packet header_comm; - ogg_packet header_code; - - vorbis_analysis_headerout(&(enc_data_t)->m_vo_dsp,&(enc_data_t)->m_vo_cmmnt,&header,&header_comm,&header_code); - ogg_stream_packetin(&(enc_data_t)->m_ogg_vs,&header); - if(ogg_stream_pageout(&(enc_data_t)->m_ogg_vs,&(enc_data_t)->m_ogg_pg)!=1){ - fprintf(stderr,"Internal Ogg library error.\n"); - exit(2); - } - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); - - ogg_stream_packetin(&(enc_data_t)->m_ogg_vs,&header_comm); - ogg_stream_packetin(&(enc_data_t)->m_ogg_vs,&header_code); - } - - - - while(1){ - int result = ogg_stream_flush(&(enc_data_t)->m_ogg_ts,&(enc_data_t)->m_ogg_pg); - if(result<0){ - fprintf(stderr,"Internal Ogg library error.\n"); - exit(2); - } - if(result==0)break; - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); - } - - if(!pdata->args.nosound){ - while(1){ - int result=ogg_stream_flush(&(enc_data_t)->m_ogg_vs,&(enc_data_t)->m_ogg_pg); - if(result<0){ - fprintf(stderr,"Internal Ogg library error.\n"); - exit(2); - } - if(result==0)break; - fwrite((enc_data_t)->m_ogg_pg.header,1,(enc_data_t)->m_ogg_pg.header_len,(enc_data_t)->fp); - fwrite((enc_data_t)->m_ogg_pg.body,1,(enc_data_t)->m_ogg_pg.body_len,(enc_data_t)->fp); - } - } - - - if(!buffer_ready){ - (enc_data_t)->yuv.y=(unsigned char *)malloc((enc_data_t)->m_th_inf.height*(enc_data_t)->m_th_inf.width); - (enc_data_t)->yuv.u=(unsigned char *)malloc((enc_data_t)->m_th_inf.height*(enc_data_t)->m_th_inf.width/4); - (enc_data_t)->yuv.v=(unsigned char *)malloc((enc_data_t)->m_th_inf.height*(enc_data_t)->m_th_inf.width/4); - (enc_data_t)->yuv.y_width=(enc_data_t)->m_th_inf.width; - (enc_data_t)->yuv.y_height=(enc_data_t)->m_th_inf.height; - (enc_data_t)->yuv.y_stride=(enc_data_t)->m_th_inf.width; - - (enc_data_t)->yuv.uv_width=(enc_data_t)->m_th_inf.width/2; - (enc_data_t)->yuv.uv_height=(enc_data_t)->m_th_inf.height/2; - (enc_data_t)->yuv.uv_stride=(enc_data_t)->m_th_inf.width/2; - (enc_data_t)->x_offset=(enc_data_t)->m_th_inf.offset_x; - (enc_data_t)->y_offset=(enc_data_t)->m_th_inf.offset_y; - } - theora_info_clear(&(enc_data_t)->m_th_inf); - -} - - - - diff --git a/rMD-exp/src/load_cache.c b/rMD-exp/src/load_cache.c deleted file mode 100644 index cd09956..0000000 --- a/rMD-exp/src/load_cache.c +++ /dev/null @@ -1,187 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void LoadBlock(unsigned char *dest,unsigned char *source,int blockno,int width, int height,int divisor){ - int j, - block_i=blockno/divisor,//place on the grid - block_k=blockno%divisor; - - for(j=0;j<height/divisor;j++)//we copy rows - memcpy( &dest[block_i*(width*height/divisor)+j*width+block_k*width/divisor], - &source[j*width/divisor], - width/divisor); -} - - - -void *LoadCache(void *pdata){ - - yuv_buffer *yuv=&((ProgData *)pdata)->enc_data->yuv; - gzFile *ifp=((ProgData *)pdata)->cache_data->ifp; - FILE *afp=((ProgData *)pdata)->cache_data->afp; - FrameHeader fheader; - CachedFrame frame; - signed char *sound_data=(signed char *)malloc(((ProgData *)pdata)->periodsize); - - int j=0, - audio_end=0, - extra_frames=0,//total number of duplicated frames - missing_frames=0,//if this is found >0 current run will not load - //a frame but it will proccess the previous - thread_exit=0,//0 success, -1 couldn't find files,1 couldn't remove - divisor=16, - blockszy=0,//size of y plane block in bytes - blockszuv=0;//size of u,v plane blocks in bytes - //we allocate the frame that we will use - INIT_FRAME(&frame,&fheader,yuv) - //and the we open our files - ifp=gzopen(((ProgData *)pdata)->cache_data->imgdata,"rb"); - if(ifp==NULL){ - thread_exit=-1; - pthread_exit(&thread_exit); - } - - if(!((ProgData *)pdata)->args.nosound){ - afp=fopen(((ProgData *)pdata)->cache_data->audiodata,"rb"); - if(afp==NULL){ - thread_exit=-1; - pthread_exit(&thread_exit); - } - } - //these two are likely to be the same, but not guaranteed, especially on - //low resolutions - blockszy=(yuv->y_width*yuv->y_height )/pow(divisor,2); - blockszuv=(yuv->uv_width*yuv->uv_height)/pow(divisor/2,2); - - //this will be used now to define if we proccess audio or video - //on any given loop. - ((ProgData *)pdata)->avd=0; - //If sound finishes first,we go on with the video. - //If video ends we will do one more run to flush audio in the ogg file - - while(((ProgData *)pdata)->running){ - //video load and encoding - if(((ProgData *)pdata)->avd<=0 || ((ProgData *)pdata)->args.nosound || audio_end){ - if(missing_frames>0){ - extra_frames++; - missing_frames--; - SyncEncodeImageBuffer((ProgData *)pdata); - } - else if(gzread(ifp,frame.header,sizeof(FrameHeader))==sizeof(FrameHeader)){ - //sync - missing_frames+=frame.header->current_total-(extra_frames+frame.header->frameno); - fprintf(stdout,"\r[%d%%] ", - ((frame.header->frameno+extra_frames)*100)/frames_total); - - fflush(stdout); - if( (frame.header->Ynum<=pow(divisor,2)) && - (frame.header->Unum<=pow(divisor/2,2)) && - (frame.header->Vnum<=pow(divisor/2,2)) && - (gzread(ifp,frame.YBlocks,frame.header->Ynum)==frame.header->Ynum) && - (gzread(ifp,frame.UBlocks,frame.header->Unum)==frame.header->Unum) && - (gzread(ifp,frame.VBlocks,frame.header->Vnum)==frame.header->Vnum) && - (gzread(ifp,frame.YData,blockszy*frame.header->Ynum)==blockszy*frame.header->Ynum) && - (gzread(ifp,frame.UData,(blockszuv*frame.header->Unum))==(blockszuv*frame.header->Unum)) && - (gzread(ifp,frame.VData,(blockszuv*frame.header->Vnum))==(blockszuv*frame.header->Vnum))){ - //load the blocks for each buffer - if(frame.header->Ynum) - for(j=0;j<frame.header->Ynum;j++) - LoadBlock( yuv->y, - &frame.YData[j*blockszy], - frame.YBlocks[j], - yuv->y_width, - yuv->y_height, - divisor); - if(frame.header->Unum) - for(j=0;j<frame.header->Unum;j++) - LoadBlock( yuv->u, - &frame.UData[j*blockszuv], - frame.UBlocks[j], - yuv->uv_width, - yuv->uv_height, - divisor/2); - if(frame.header->Vnum) - for(j=0;j<frame.header->Vnum;j++) - LoadBlock( yuv->v, - &frame.VData[j*blockszuv], - frame.VBlocks[j], - yuv->uv_width, - yuv->uv_height, - divisor/2); - //encode. This is not made in a thread since now blocking is not a problem - //and this way sync problems can be avoided more easily. - SyncEncodeImageBuffer((ProgData *)pdata); - } - else{ - raise(SIGINT); - continue; - } - } - else{ - raise(SIGINT); - continue; - } - } - //audio load and encoding - else{ - if(!audio_end){ - int nbytes=fread(sound_data,((ProgData *)pdata)->periodsize,1,afp); - if(nbytes<=0) - audio_end=1; - else - SyncEncodeSoundBuffer((ProgData *)pdata,sound_data); - } - } - } - fprintf(stdout,"\n"); - CLEAR_FRAME(&frame) - free(sound_data); - gzclose(ifp); - - if(remove(((ProgData *)pdata)->cache_data->imgdata)){ - fprintf(stderr,"Couldn't remove temporary file %s",((ProgData *)pdata)->cache_data->imgdata); - thread_exit=1; - } - if(!((ProgData *)pdata)->args.nosound){ - fclose(afp); - if(remove(((ProgData *)pdata)->cache_data->audiodata)){ - fprintf(stderr,"Couldn't remove temporary file %s",((ProgData *)pdata)->cache_data->audiodata); - thread_exit=1; - } - } - if(remove(((ProgData *)pdata)->cache_data->projname)){ - fprintf(stderr,"Couldn't remove temporary directory %s",((ProgData *)pdata)->cache_data->projname); - thread_exit=1; - } - - pthread_exit(&thread_exit); - - -} - diff --git a/rMD-exp/src/make_dummy_pointer.c b/rMD-exp/src/make_dummy_pointer.c deleted file mode 100644 index 00a346e..0000000 --- a/rMD-exp/src/make_dummy_pointer.c +++ /dev/null @@ -1,76 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -unsigned char *MakeDummyPointer(DisplaySpecs *specs,int size,int color,int type,unsigned char *npxl){ - int i,k,o='.'; - unsigned long b=(color)?'w':'b', - w=(color)?'b':'w'; - char pmask[1][16][16]={{ - {w,w,w,w,w,w,o,o,o,o,o,o,o,o,o,o}, - {w,b,b,w,w,w,w,o,o,o,o,o,o,o,o,o}, - {w,b,b,b,w,w,w,w,o,o,o,o,o,o,o,o}, - {w,b,b,b,b,w,w,w,w,o,o,o,o,o,o,o}, - {w,b,b,b,b,b,w,w,w,w,o,o,o,o,o,o}, - {w,b,b,b,b,b,b,w,w,w,w,o,o,o,o,o}, - {w,b,b,b,b,b,b,b,w,w,w,w,o,o,o,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,b,b,b,b,b,b,b,b,b,w,w,w,w,o,o}, - {w,b,b,b,b,b,b,b,b,b,b,w,w,w,w,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,w,w,w,w,b,b,b,b,b,w,w,w,o,o,o}, - {w,w,w,w,w,w,b,b,b,b,w,w,w,o,o,o}, - {o,o,o,o,o,w,w,b,b,b,w,w,w,o,o,o}, - {o,o,o,o,o,o,w,w,w,w,w,w,w,o,o,o}} - }; - unsigned char *ret=malloc(size*sizeof(char[size*4])); - unsigned char wp[4]={ - ((specs->wpixel^0xff000000)>>24), - ((specs->wpixel^0x00ff0000)>>16), - ((specs->wpixel^0x0000ff00)>>8), - ((specs->wpixel^0x000000ff)) - }; - unsigned char bp[4]={ - ((specs->bpixel^0xff000000)>>24), - ((specs->bpixel^0x00ff0000)>>16), - ((specs->bpixel^0x0000ff00)>>8), - ((specs->bpixel^0x000000ff)) - }; - *npxl=((wp[0]-1)!=bp[0])?wp[0]-100:wp[0]-102; - for(i=0;i<size;i++){ - for(k=0;k<size;k++){ - ret[(i*size+k)*4+__ABYTE]=(pmask[type][i][k]=='w')?wp[0]:(pmask[type][i][k]=='b')?bp[0]:*npxl; - ret[(i*size+k)*4+__RBYTE]=(pmask[type][i][k]=='w')?wp[1]:(pmask[type][i][k]=='b')?bp[1]:*npxl; - ret[(i*size+k)*4+__GBYTE]=(pmask[type][i][k]=='w')?wp[2]:(pmask[type][i][k]=='b')?bp[2]:*npxl; - ret[(i*size+k)*4+__BBYTE]=(pmask[type][i][k]=='w')?wp[3]:(pmask[type][i][k]=='b')?bp[3]:*npxl; - } - } - - return ret; -} diff --git a/rMD-exp/src/opendev.c b/rMD-exp/src/opendev.c deleted file mode 100644 index 7eb5d2b..0000000 --- a/rMD-exp/src/opendev.c +++ /dev/null @@ -1,103 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - - - -#include <recordmydesktop.h> - - -snd_pcm_t *OpenDev(const char *pcm_dev,unsigned int *channels,unsigned int *frequency,snd_pcm_uframes_t *periodsize,unsigned int *periodtime,int *hard_pause){ - - snd_pcm_t *mhandle; - snd_pcm_hw_params_t *hwparams; - unsigned int periods=2; - unsigned int exactrate = *frequency; - - snd_pcm_hw_params_alloca(&hwparams); - snd_pcm_uframes_t buffsize=4096; - - if (snd_pcm_open(&mhandle, pcm_dev, SND_PCM_STREAM_CAPTURE, SND_PCM_ASYNC)<0){ - fprintf(stderr, "Couldn't open PCM device %s\n", pcm_dev); - return NULL; - } - if (snd_pcm_hw_params_any(mhandle, hwparams)<0){ - fprintf(stderr, "Couldn't configure PCM device.\n"); - return NULL; - } - if (snd_pcm_hw_params_set_access(mhandle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)<0) { - fprintf(stderr, "Couldn't set access.\n"); - return NULL; - } - if (snd_pcm_hw_params_set_format(mhandle, hwparams, SND_PCM_FORMAT_S16_LE)<0){ - fprintf(stderr, "Couldn't set format.\n"); - return NULL; - } - if (snd_pcm_hw_params_set_rate_near(mhandle, hwparams, &exactrate, 0)<0){ - fprintf(stderr, "Couldn't set frequency.\n"); - return NULL; - } - if (*frequency != exactrate){ - fprintf(stderr, "Playback frequency %dHz is not available...\nUsing %dHz instead.\n",*frequency,exactrate); - *frequency=exactrate; - } - if (snd_pcm_hw_params_set_channels_near(mhandle, hwparams, channels)<0){ - fprintf(stderr, "Couldn't set channels number.\n"); - return NULL; - } - if(*channels>2){ - fprintf(stderr,"Channels number should be 1(mono) or 2(stereo).\n"); - return NULL; - } - if (snd_pcm_hw_params_set_periods_near(mhandle, hwparams, &periods,0)<0) { - fprintf(stderr, "Couldn't set periods.\n"); - return NULL; - } - buffsize=(exactrate*(*channels))/2; - if (snd_pcm_hw_params_set_buffer_size_near(mhandle, hwparams,&buffsize)<0){ - fprintf(stderr, "Couldn't set buffer size.\n"); - return NULL; - } - if (snd_pcm_hw_params(mhandle, hwparams)<0){ - fprintf(stderr, "Couldn't set hardware parameters.\n"); - return NULL; - } - if(hard_pause!=NULL) - if(!snd_pcm_hw_params_can_pause(hwparams)){ -// fprintf(stderr, "Current sound device doesn't seem to support pausing!\nI will attempt to close/reopen device in case you opt to pause during recording.\n"); - *hard_pause=1; - } - if(periodsize!=NULL) - snd_pcm_hw_params_get_period_size(hwparams,periodsize,0); - if(periodtime!=NULL) - snd_pcm_hw_params_get_period_time(hwparams,periodtime,0); - fprintf(stderr,"Recording on device %s is set to:\n%d channels at %dHz\n",pcm_dev,*channels,*frequency); - snd_pcm_prepare(mhandle); - - return mhandle; -} - - diff --git a/rMD-exp/src/parseargs.c b/rMD-exp/src/parseargs.c deleted file mode 100644 index c7d20fd..0000000 --- a/rMD-exp/src/parseargs.c +++ /dev/null @@ -1,425 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - - -int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ - int i; - char *usage="\nUsage:\n" - "\trecordmydesktop [-h| --help| --version| -delay n[H|h|M|m]| -windowid id_of_window|\n" - "\t-display DISPLAY| -x X| -y Y|-width N| -height N| -fps N(number>0)| --on-the-fly-encoding|\n" - "\t -v_quality n| -s_quality n| -v_bitrate n| --no-framedrop| -dummy-cursor color|\n" - "\t --no-cursor| -freq N(number>0)| -channels N(number>0)| -device SOUND_DEVICE|\n" - "\t --no-sound| --with-shared| --no-cond-shared| -shared-threshold n| --full-shots|\n" - "\t --quick-subsampling| -workdir DIR| --zero-compression| --no-wm-check| --overwite| -o filename]^filename\n\n\n" - - "General Options:\n" - "\t-h or --help\t\tPrint this help and exit.\n" - "\t--version\t\tPrint program version and exit.\n\n" - - "Image Options:\n" - "\t-windowid id_of_window\tid of window to be recorded.\n" - "\t-display DISPLAY\tDisplay to connect to.\n" - "\t-x X\t\t\tOffset in x direction.\n" - "\t-y Y\t\t\tOffset in y direction.\n" - "\t-width N\t\tWidth of recorded window.\n" - "\t-height N\t\tHeight of recorded window.\n\n" - - "\t-dummy-cursor color\tColor of the dummy cursor [black|white]\n" - "\t--no-cursor\t\tDisable drawing of the cursor.\n" - "\t--with-shared\t\tEnable usage of MIT-shared memory extension at all times.\n" - "\t--no-cond-shared\tDo not use the MIT-shared memory extension when aquiring large areas.\n" - "\t-shared-threshold n\tThreshold over which shared memory is used(default 75).\n" - "\t--full-shots\t\tTake full screenshot at every frame(Not recomended!).\n" - "\t--quick-subsampling\tDo subsampling of the chroma planes by discarding,not averaging.\n" - "\t-fps N(number>0.0)\tA positive number denoting desired framerate.\n\n" - - "Sound Options:\n" - "\t-channels N(number>0)\tA positive number denoting desired sound channels in recording.\n" - "\t-freq N(number>0)\tA positive number denoting desired sound frequency.\n" - "\t-device SOUND_DEVICE\tSound device(default hw0:0).\n" - "\t--no-sound\t\tDo not record sound.\n\n" - - "Encoding Options\n" - "\t--on-the-fly-encoding\tEncode the audio-video data, while recording.\n" - "\t-v_quality n\t\tA number from 0 to 63 for desired encoded video quality(default 63).\n" - "\t-v_bitrate n\t\tA number from 45000 to 2000000 for desired encoded video bitrate(default 45000).\n" - "\t--drop-frames\t\tAllow theora encoder to drop frames.\n" - "\t-s_quality n\t\tDesired audio quality(-1 to 10).\n\n" - - "Misc Options:\n" - "\t--no-wm-check\tDo not try to detect the window manager(and set options according to it)\n" - "\t--zero-compression\tImage data are always cached uncompressed.\n" - "\t-workdir DIR\t\tLocation where a temporary directory will be created to hold project files(default $HOME).\n" - "\t-delay n[H|h|M|m]\tNumber of secs(default),minutes or hours before capture starts(number can be float)\n" - "\t--overwrite\t\tIf there is already a file with the same name, delete it\n" - "\t\t\t\t(default is to add a number postfix to the new one).\n" - "\t-o filename\t\tName of recorded video(default out.ogg).\n" - "\n\tIf no other options are specified, filename can be given without the -o switch.\n\n\n"; - - if(argc==2){ - if(argv[1][0]!='-'){ - free(arg_return->filename); - arg_return->filename=malloc(strlen(argv[1])+1); - strcpy(arg_return->filename,argv[1]); - return 0; - } - } - for(i=1;i<argc;i++){ - if(!strcmp(argv[i],"-delay")){ - if(i+1<argc){ - float num=atof(argv[i+1]); - if(num>0.0){ - int k; - for(k=0;k<strlen(argv[i+1]);k++){ - if((argv[i+1][k]=='M')||(argv[i+1][k]=='m')){ - num*=60.0; - break; - } - else if((argv[i+1][k]=='H')||(argv[i+1][k]=='h')){ - num*=3600.0; - break; - } - } - arg_return->delay=(int)num; - } - else{ - fprintf(stderr,"Argument Usage: -delay n[H|h|M|m]\nwhere n is a float number\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -delay n[H|h|M|m]\nwhere n is a float number\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-windowid")){ - if(i+1<argc){ - Window num=strtod(argv[i+1],NULL); - if(num>0) - arg_return->windowid=num; - else{ - fprintf(stderr,"Argument Usage: -windowid id_of_window(number)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -windowid id_of_window(number)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-display")){ - if(i+1<argc){ - if(arg_return->display!=NULL) - free(arg_return->display); - arg_return->display=malloc(strlen(argv[i+1])+1); - strcpy(arg_return->display,argv[i+1]); - } - else{ - fprintf(stderr,"Argument Usage: -display DISPLAY\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-x")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if(num>0) - arg_return->x=num; - else{ - fprintf(stderr,"Argument Usage: -x X(number>0)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -x X(number>0)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-y")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if(num>0) - arg_return->y=num; - else{ - fprintf(stderr,"Argument Usage: -y Y(number>0)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -y Y(number>0)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-width")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if(num>0) - arg_return->width=num; - else{ - fprintf(stderr,"Argument Usage: -width N(number>0)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -width N(number>0)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-height")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if(num>0) - arg_return->height=num; - else{ - fprintf(stderr,"Argument Usage: -height N(number>0)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -height N(number>0)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-o")){ - if(i+1<argc){ - free(arg_return->filename); - arg_return->filename=malloc(strlen(argv[i+1])+1); - strcpy(arg_return->filename,argv[i+1]); - } - else{ - fprintf(stderr,"Argument Usage: -o filename\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-fps")){ - if(i+1<argc){ - float num=atof(argv[i+1]); - if(num>0.0) - arg_return->fps=num; - else{ - fprintf(stderr,"Argument Usage: -fps N(number>0)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -fps N(number>0)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-v_quality")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if((num>=0)&&(num<64)) - arg_return->v_quality=num; - else{ - fprintf(stderr,"Argument Usage: -v_quality n(number 0-63)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -v_quality n(number 0-63)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-v_bitrate")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if((num>=45000)&&(num<=2000000)) - arg_return->v_bitrate=num; - else{ - fprintf(stderr,"Argument Usage: -v_bitrate n(number 45000-2000000)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -v_bitrate n(number 45000-2000000)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-dummy-cursor")){ - if(i+1<argc){ - if(!strcmp(argv[i+1],"white")) - arg_return->cursor_color=0; - else if(!strcmp(argv[i+1],"black")) - arg_return->cursor_color=1; - else{ - fprintf(stderr,"Argument Usage: -dummy-cursor [black|white]\n"); - return 1; - } - arg_return->have_dummy_cursor=1; - arg_return->xfixes_cursor=0; - } - else{ - fprintf(stderr,"Argument Usage: -dummy-cursor [black|white]\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"--no-cursor")) - arg_return->xfixes_cursor=0; - else if(!strcmp(argv[i],"-freq")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if(num>0) - arg_return->frequency=num; - else{ - fprintf(stderr,"Argument Usage: -freq N(number>0)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -freq N(number>0)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-channels")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if(num>0) - arg_return->channels=num; - else{ - fprintf(stderr,"Argument Usage: -channels N(number>0)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -channels N(number>0)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-s_quality")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if((num>=-1)&&(num<=10)) - arg_return->s_quality=num; - else{ - fprintf(stderr,"Argument Usage: -s_quality n(number -1 to 10)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -s_quality n(number -1 to 10)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-shared-threshold")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if((num>0)&&(num<100)) - arg_return->shared_thres=num; - else{ - fprintf(stderr,"Argument Usage: -shared-threshold N(0<number<100)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage: -shared-threshold N(0<number<100)\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-device")){ - if(i+1<argc){ - free(arg_return->device); - arg_return->device=malloc(strlen(argv[i+1])+1); - strcpy(arg_return->device,argv[i+1]); - } - else{ - fprintf(stderr,"Argument Usage: -device SOUND_DEVICE\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"-workdir")){ - if(i+1<argc){ - free(arg_return->workdir); - arg_return->workdir=malloc(strlen(argv[i+1])+1); - strcpy(arg_return->workdir,argv[i+1]); - } - else{ - fprintf(stderr,"Argument Usage: -workdir DIR\n"); - return 1; - } - i++; - } - else if(!strcmp(argv[i],"--no-sound")) - arg_return->nosound=1; - else if(!strcmp(argv[i],"--drop-frames")) - arg_return->dropframes=1; - else if(!strcmp(argv[i],"--with-shared")){ - arg_return->noshared=0; - arg_return->nocondshared=1; - } - else if(!strcmp(argv[i],"--no-cond-shared")) - arg_return->nocondshared=1; - else if(!strcmp(argv[i],"--full-shots")){ - arg_return->full_shots=1; - arg_return->nocondshared=1; - } - else if(!strcmp(argv[i],"--quick-subsampling")){ - arg_return->no_quick_subsample=0; - } - else if(!strcmp(argv[i],"--on-the-fly-encoding")){ - arg_return->encOnTheFly=1; - } - else if(!strcmp(argv[i],"--overwrite")) - arg_return->overwrite=1; - else if(!strcmp(argv[i],"--no-wm-check")) - arg_return->nowmcheck=1; - else if(!strcmp(argv[i],"--zero-compression")){ - arg_return->zerocompression=1; - } - else if(!strcmp(argv[i],"--help")||!strcmp(argv[i],"-h")){ - fprintf(stderr,"%s",usage); - return 1; - } - else if(!strcmp(argv[i],"--version")){ - fprintf(stderr,"recordMyDesktop v%s\n\n",VERSION); - return 1; - } - else{ - fprintf(stderr,"\n\tError parsing arguments.\n\tType --help or -h for usage.\n\n"); - return 1; - } - } - return 0; -} diff --git a/rMD-exp/src/poll_damage.c b/rMD-exp/src/poll_damage.c deleted file mode 100644 index 9bf7ee2..0000000 --- a/rMD-exp/src/poll_damage.c +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void *PollDamage(void *pdata){ - Window root_return, - parent_return, - *children; - unsigned int i, - nchildren, - inserts=0; - XEvent event; - - XSelectInput (((ProgData *)pdata)->dpy,((ProgData *)pdata)->specs.root, SubstructureNotifyMask); - - XQueryTree (((ProgData *)pdata)->dpy, - ((ProgData *)pdata)->specs.root, - &root_return, - &parent_return, - &children, - &nchildren); - - for (i = 0; i < nchildren; i++){ - XWindowAttributes attribs; - if (XGetWindowAttributes (((ProgData *)pdata)->dpy,children[i],&attribs)){ - if (!attribs.override_redirect && attribs.depth==((ProgData *)pdata)->specs.depth) - XDamageCreate (((ProgData *)pdata)->dpy, children[i],XDamageReportRawRectangles); - } - } - - XDamageCreate( ((ProgData *)pdata)->dpy, ((ProgData *)pdata)->brwin.windowid, XDamageReportRawRectangles); - - - while(((ProgData *)pdata)->running){ - //damage polling doesn't stop,eventually full image may be needed - //30/10/2006 : when and why did I write the above line? what did I mean? - XNextEvent(((ProgData *)pdata)->dpy,&event); - if (event.type == MapNotify ){ - XWindowAttributes attribs; - if (!((XMapEvent *)(&event))->override_redirect && XGetWindowAttributes (((ProgData *)pdata)->dpy, - event.xcreatewindow.window, - &attribs)){ - if (!attribs.override_redirect && attribs.depth==((ProgData *)pdata)->specs.depth) - XDamageCreate (((ProgData *)pdata)->dpy,event.xcreatewindow.window,XDamageReportRawRectangles); - } - } - else if(event.type == ((ProgData *)pdata)->damage_event + XDamageNotify ){ - XDamageNotifyEvent *e =(XDamageNotifyEvent *)( &event ); - WGeometry wgeom; - CLIP_EVENT_AREA(e,&(((ProgData *)pdata)->brwin),&wgeom); - if((wgeom.x>=0)&&(wgeom.y>=0)&&(wgeom.width>0)&&(wgeom.height>0)) - { - int tlist_sel=((ProgData *)pdata)->list_selector; - pthread_mutex_lock(&((ProgData *)pdata)->list_mutex[tlist_sel]); - inserts+=RectInsert(&((ProgData *)pdata)->rect_root[tlist_sel],&wgeom); - pthread_mutex_unlock(&((ProgData *)pdata)->list_mutex[tlist_sel]); - } - } - - } - pthread_exit(&errno); -} - diff --git a/rMD-exp/src/queryextensions.c b/rMD-exp/src/queryextensions.c deleted file mode 100644 index 0b311b9..0000000 --- a/rMD-exp/src/queryextensions.c +++ /dev/null @@ -1,48 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void QueryExtensions(Display *dpy,ProgArgs *args,int *damage_event,int *damage_error){ - int xf_event_basep, - xf_error_basep; - - if(!XDamageQueryExtension( dpy, damage_event, damage_error)){ - fprintf(stderr,"XDamage extension not found!!!\n"); - exit(4); - } - if((!args->noshared)&&(XShmQueryExtension(dpy)==False)){ - args->noshared=1; - fprintf(stderr,"Shared Memory extension not present!\nTry again removing the --with-shared option(if you used it)\nand add the --no-cond-shared option.\n"); - exit(5); - } - if((args->xfixes_cursor)&&(XFixesQueryExtension(dpy,&xf_event_basep,&xf_error_basep)==False)){ - args->xfixes_cursor=0; - fprintf(stderr,"Xfixes extension not present!\nPlease run with the -dummy-cursor or --no-cursor option.\n"); - exit(6); - } -} diff --git a/rMD-exp/src/recordmydesktop.c b/rMD-exp/src/recordmydesktop.c deleted file mode 100644 index 77c08ce..0000000 --- a/rMD-exp/src/recordmydesktop.c +++ /dev/null @@ -1,354 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - - -int main(int argc,char **argv){ - ProgData pdata; - int exit_status=0; - if(XInitThreads ()==0){ - fprintf(stderr,"Couldn't initialize thread support!\n"); - exit(7); - } - DEFAULT_ARGS(&pdata.args); - if(ParseArgs(argc,argv,&pdata.args)){ - exit(1); - } - if(pdata.args.display!=NULL) - pdata.dpy = XOpenDisplay(pdata.args.display); - else{ - fprintf(stderr,"No display specified for connection!\n"); - exit(8); - } - if (pdata.dpy == NULL) { - fprintf(stderr, "Cannot connect to X server %s\n",pdata.args.display); - exit(9); - } - else{ - EncData enc_data; - CacheData cache_data; - pthread_t poll_damage_t, - image_capture_t, - image_encode_t, - image_cache_t, - sound_capture_t, - sound_encode_t, - sound_cache_t, - flush_to_ogg_t, - load_cache_t; - XShmSegmentInfo shminfo; - int i; - - QUERY_DISPLAY_SPECS(pdata.dpy,&pdata.specs); - if(pdata.specs.depth!=24){ - fprintf(stderr,"Only 24bpp color depth mode is currently supported.\n"); - exit(10); - } - if(SetBRWindow(pdata.dpy,&pdata.brwin,&pdata.specs,&pdata.args)) - exit(11); - - - //check if we are under compiz or beryl,in which case we must enable full-shots - //and with it use of shared memory.User can override this - pdata.window_manager=((pdata.args.nowmcheck)?NULL:rmdWMCheck(pdata.dpy,pdata.specs.root)); - if(pdata.window_manager==NULL){ - fprintf(stderr,"Not taking window manager into account.\n"); - } - //Right now only wm's that I know of performing 3d compositing are beryl and compiz. - //No, the blue screen in metacity doesn't count :) - //names can be compiz for compiz and beryl/beryl-co/beryl-core for beryl(so it's strncmp ) - else if(!strcmp(pdata.window_manager,"compiz") || !strncmp(pdata.window_manager,"beryl",5)){ - fprintf(stderr,"\nDetected 3d compositing window manager.\n" - "Reverting to full screen capture at every frame.\n" - "To disable this check run with --no-wm-check\n" - "(though that is not advised, since it will probably produce faulty results).\n\n"); - pdata.args.full_shots=1; - pdata.args.noshared=0; - pdata.args.nocondshared=1; - } - - QueryExtensions(pdata.dpy,&pdata.args,&pdata.damage_event, &pdata.damage_error); - - - - - //init data - - //these are globals, look for them at the header - frames_total=frames_lost=encoder_busy=capture_busy=0; - - fprintf(stderr,"Initializing...\n"); - MakeMatrices(); - if(pdata.args.have_dummy_cursor){ - pdata.dummy_pointer=MakeDummyPointer(&pdata.specs,16,pdata.args.cursor_color,0,&pdata.npxl); - pdata.dummy_p_size=16; - } - - if((pdata.args.noshared)) - pdata.datamain=(char *)malloc(pdata.brwin.nbytes); - - if(pdata.args.noshared) - pdata.datatemp=(char *)malloc(pdata.brwin.nbytes); - pdata.rect_root[0]=pdata.rect_root[1]=NULL; - pthread_mutex_init(&pdata.list_mutex[0],NULL); - pthread_mutex_init(&pdata.list_mutex[1],NULL); - pthread_mutex_init(&pdata.sound_buffer_mutex,NULL); - pthread_mutex_init(&pdata.libogg_mutex,NULL); - pthread_mutex_init(&pdata.yuv_mutex,NULL); - - pthread_cond_init(&pdata.time_cond,NULL); - pthread_cond_init(&pdata.pause_cond,NULL); - pthread_cond_init(&pdata.image_buffer_ready,NULL); - pthread_cond_init(&pdata.sound_buffer_ready,NULL); - pthread_cond_init(&pdata.sound_data_read,NULL); - pdata.list_selector=Paused=Aborted=pdata.avd=0; - pdata.running=1; - time_cond=&pdata.time_cond; - pause_cond=&pdata.pause_cond; - Running=&pdata.running; - - if((pdata.args.noshared)){ - pdata.image=XCreateImage(pdata.dpy, pdata.specs.visual, pdata.specs.depth, ZPixmap, 0,pdata.datamain,pdata.brwin.rgeom.width, - pdata.brwin.rgeom.height, 8, 0); - XInitImage(pdata.image); - GetZPixmap(pdata.dpy,pdata.specs.root,pdata.image->data,pdata.brwin.rgeom.x,pdata.brwin.rgeom.y, - pdata.brwin.rgeom.width,pdata.brwin.rgeom.height); - } - if((!pdata.args.noshared)||(!pdata.args.nocondshared)){ - pdata.shimage=XShmCreateImage (pdata.dpy,pdata.specs.visual,pdata.specs.depth,ZPixmap,pdata.datash, - &shminfo, pdata.brwin.rgeom.width,pdata.brwin.rgeom.height); - shminfo.shmid = shmget (IPC_PRIVATE, - pdata.shimage->bytes_per_line * pdata.shimage->height, - IPC_CREAT|0777); - shminfo.shmaddr = pdata.shimage->data = shmat (shminfo.shmid, 0, 0); - shminfo.readOnly = False; - if(!XShmAttach(pdata.dpy,&shminfo)){ - fprintf(stderr,"Failed to attach shared memory to proccess.\n"); - exit(12); - } - XShmGetImage(pdata.dpy,pdata.specs.root,pdata.shimage,pdata.brwin.rgeom.x,pdata.brwin.rgeom.y,AllPlanes); - } - if(!pdata.args.nosound){ - pdata.sound_handle=OpenDev(pdata.args.device,&pdata.args.channels,&pdata.args.frequency,&pdata.periodsize, &pdata.periodtime,&pdata.hard_pause); - if(pdata.sound_handle==NULL){ - fprintf(stderr,"Error while opening/configuring soundcard %s\nTry running with the --no-sound or specify a correct device.\n",pdata.args.device); - exit(3); - } - } - - if(pdata.args.encOnTheFly) - InitEncoder(&pdata,&enc_data,0); - else - InitCacheData(&pdata,&enc_data,&cache_data); - - for(i=0;i<(pdata.enc_data->yuv.y_width*pdata.enc_data->yuv.y_height);i++) - pdata.enc_data->yuv.y[i]=0; - for(i=0;i<(pdata.enc_data->yuv.uv_width*pdata.enc_data->yuv.uv_height);i++){ - pdata.enc_data->yuv.v[i]=pdata.enc_data->yuv.u[i]=127; - } - - if((pdata.args.nocondshared)&&(!pdata.args.noshared)){ - if(pdata.args.no_quick_subsample){ - UPDATE_YUV_BUFFER_IM_AVG((&pdata.enc_data->yuv),((unsigned char*)pdata.shimage->data), - (pdata.enc_data->x_offset),(pdata.enc_data->y_offset), - (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height)); - } - else{ - UPDATE_YUV_BUFFER_IM((&pdata.enc_data->yuv),((unsigned char*)pdata.shimage->data), - (pdata.enc_data->x_offset),(pdata.enc_data->y_offset), - (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height)); - } - } - else{ - if(pdata.args.no_quick_subsample){ - UPDATE_YUV_BUFFER_IM_AVG((&pdata.enc_data->yuv),((unsigned char*)pdata.image->data), - (pdata.enc_data->x_offset),(pdata.enc_data->y_offset), - (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height)); - } - else{ - UPDATE_YUV_BUFFER_IM((&pdata.enc_data->yuv),((unsigned char*)pdata.image->data), - (pdata.enc_data->x_offset),(pdata.enc_data->y_offset), - (pdata.brwin.rgeom.width),(pdata.brwin.rgeom.height)); - } - } - - pdata.frametime=(1000000)/pdata.args.fps; - - if(pdata.args.delay>0){ - fprintf(stderr,"Will sleep for %d seconds now.\n",pdata.args.delay); - sleep(pdata.args.delay); - } - - /*start threads*/ - if(!pdata.args.full_shots) - pthread_create(&poll_damage_t,NULL,PollDamage,(void *)&pdata); - pthread_create(&image_capture_t,NULL,GetFrame,(void *)&pdata); - if(pdata.args.encOnTheFly) - pthread_create(&image_encode_t,NULL,EncodeImageBuffer,(void *)&pdata); - else - pthread_create(&image_cache_t,NULL,CacheImageBuffer,(void *)&pdata); - - if(!pdata.args.nosound){ - pthread_create(&sound_capture_t,NULL,CaptureSound,(void *)&pdata); - if(pdata.args.encOnTheFly) - pthread_create(&sound_encode_t,NULL,EncodeSoundBuffer,(void *)&pdata); - else - pthread_create(&sound_cache_t,NULL,CacheSoundBuffer,(void *)&pdata); - } - if(pdata.args.encOnTheFly) - pthread_create(&flush_to_ogg_t,NULL,FlushToOgg,(void *)&pdata); - - - RegisterCallbacks(&pdata.args); - fprintf(stderr,"Capturing!\n"); - - //wait all threads to finish - - pthread_join(image_capture_t,NULL); - fprintf(stderr,"Shutting down."); - //if no damage events have been received the thread will get stuck - pthread_cond_broadcast(&pdata.image_buffer_ready); - if(pdata.args.encOnTheFly) - pthread_join(image_encode_t,NULL); - else - pthread_join(image_cache_t,NULL); - - - fprintf(stderr,"."); - if(!pdata.args.nosound){ - int *snd_exit; - pthread_join(sound_capture_t,(void *)(&snd_exit)); - fprintf(stderr,"."); - - if(pdata.args.encOnTheFly){ - if(!(*snd_exit)) - pthread_join(sound_encode_t,NULL); - else{ - pthread_cancel(sound_encode_t); - exit_status=*snd_exit; - } - } - else{ - if(!(*snd_exit)) - pthread_join(sound_cache_t,NULL); - else{ - pthread_cancel(sound_cache_t); - exit_status=*snd_exit; - } - } - } - else - fprintf(stderr,".."); - - if(pdata.args.encOnTheFly) - pthread_join(flush_to_ogg_t,NULL); - fprintf(stderr,"."); - - if(!pdata.args.full_shots) - pthread_join(poll_damage_t,NULL); - - - fprintf(stderr,"."); - if((!pdata.args.noshared)||(!pdata.args.nocondshared)){ - XShmDetach (pdata.dpy, &shminfo); - shmdt (&shminfo.shmaddr); - shmctl (shminfo.shmid, IPC_RMID, 0); - } - fprintf(stderr,"\n"); - - - //Now that we are done with recording we cancel the timer - CancelTimer(); - -/** Encoding */ - if(!pdata.args.encOnTheFly){ - if(!Aborted){ - fprintf(stderr,"Encoding started!\nThis may take several minutes.\n" - "Pressing Ctrl-C will cancel the procedure (resuming will not be possible, but\n" - "any portion of the video, which is already encoded won't be deleted).\n" - "Please wait...\n"); - pdata.running=1; - InitEncoder(&pdata,&enc_data,1); - //load encoding and flushing threads - if(!pdata.args.nosound){ - //before we start loading again - //we need to free any left-overs - while(pdata.sound_buffer!=NULL){ - free(pdata.sound_buffer->data); - pdata.sound_buffer=pdata.sound_buffer->next; - } - } - pthread_create(&flush_to_ogg_t,NULL,FlushToOgg,(void *)&pdata); - - - //start loading image and audio - pthread_create(&load_cache_t,NULL,LoadCache,(void *)&pdata); - - //join and finish - pthread_join(load_cache_t,NULL); - fprintf(stderr,"Encoding finished!\nWait a moment please...\n"); - pthread_join(flush_to_ogg_t,NULL); - fprintf(stderr,"Done!!!\n"); - } - } -/**@_______________________________________________@*/ - - //This can happen earlier, but in some cases it might get stuck. - //So we must make sure the recording is not wasted. - XCloseDisplay(pdata.dpy); - - if(Aborted){ - if(remove(pdata.args.filename)){ - perror("Error while removing file:\n"); - return 1; - } - else{ - fprintf(stderr,"SIGABRT received,file %s removed\n",pdata.args.filename); - return 0; - } - } - else - fprintf(stderr,"Goodbye!\n"); - } - return exit_status; -} - - - - - - - - - - - - - - - diff --git a/rMD-exp/src/rectinsert.c b/rMD-exp/src/rectinsert.c deleted file mode 100644 index aefeb1e..0000000 --- a/rMD-exp/src/rectinsert.c +++ /dev/null @@ -1,499 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> -//return 1 and null if geom1 in geom2 ,2 and null if geom2 in geom1,0 if they don't collide -//-1 and two geoms if they collide and geom1 is broken.//-2 and one or two geoms if they collide and geom2 is broken. -//-10 if group and replace is possible -int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,int *ngeoms){ - //1 fits in 2 - if((wgeom1->x>=wgeom2->x)&& - (wgeom1->x+wgeom1->width<=wgeom2->x+wgeom2->width)&& - (wgeom1->y>=wgeom2->y)&& - (wgeom1->y+wgeom1->height<=wgeom2->y+wgeom2->height)){ - *ngeoms=0; - return 1; - } - //2 fits in 1 - else if((wgeom2->x>=wgeom1->x)&& - (wgeom2->x+wgeom2->width<=wgeom1->x+wgeom1->width)&& - (wgeom2->y>=wgeom1->y)&& - (wgeom2->y+wgeom2->height<=wgeom1->y+wgeom1->height)){ - *ngeoms=0; - return 2; - } - //no collision - else if((wgeom1->x+wgeom1->width<wgeom2->x)|| - (wgeom2->x+wgeom2->width<wgeom1->x)|| - (wgeom1->y+wgeom1->height<wgeom2->y)|| - (wgeom2->y+wgeom2->height<wgeom1->y)){ - *ngeoms=0; - return 0; - } - else{ -//overlapping points are considered enclosed -//this happens because libxdamage may generate many events for one change -//and some of them may be in the the exact same region -//so identical rects would be considered not colliding -//in order though to avoid endless recursion on the RectInsert -//function should always start at the next element(which is logical since -//if any rect makes it to a points none of it's part collides with previous -//nodes on the list, too) - int x1[2]={wgeom1->x,wgeom1->x+wgeom1->width}; - int y1[2]={wgeom1->y,wgeom1->y+wgeom1->height}; - int x2[2]={wgeom2->x,wgeom2->x+wgeom2->width}; - int y2[2]={wgeom2->y,wgeom2->y+wgeom2->height}; - int enclosed[2][4],tot1,tot2; - enclosed[0][0]=(((x1[0]>=x2[0])&&(x1[0]<=x2[1])&& - (y1[0]>=y2[0])&&(y1[0]<=y2[1]))?1:0); - enclosed[0][1]=(((x1[1]>=x2[0])&&(x1[1]<=x2[1])&& - (y1[0]>=y2[0])&&(y1[0]<=y2[1]))?1:0); - enclosed[0][2]=(((x1[0]>=x2[0])&&(x1[0]<=x2[1])&& - (y1[1]>=y2[0])&&(y1[1]<=y2[1]))?1:0); - enclosed[0][3]=(((x1[1]>=x2[0])&&(x1[1]<=x2[1])&& - (y1[1]>=y2[0])&&(y1[1]<=y2[1]))?1:0); - enclosed[1][0]=(((x2[0]>=x1[0])&&(x2[0]<=x1[1])&& - (y2[0]>=y1[0])&&(y2[0]<=y1[1]))?1:0); - enclosed[1][1]=(((x2[1]>=x1[0])&&(x2[1]<=x1[1])&& - (y2[0]>=y1[0])&&(y2[0]<=y1[1]))?1:0); - enclosed[1][2]=(((x2[0]>=x1[0])&&(x2[0]<=x1[1])&& - (y2[1]>=y1[0])&&(y2[1]<=y1[1]))?1:0); - enclosed[1][3]=(((x2[1]>=x1[0])&&(x2[1]<=x1[1])&& - (y2[1]>=y1[0])&&(y2[1]<=y1[1]))?1:0); - tot1=enclosed[0][0]+enclosed[0][1]+enclosed[0][2]+enclosed[0][3]; - tot2=enclosed[1][0]+enclosed[1][1]+enclosed[1][2]+enclosed[1][3]; - if((tot1==2)&&(tot2==2)){//same width or height, which is the best case - //group - if((enclosed[1][0]&&enclosed[1][1])&&(wgeom1->width==wgeom2->width)){ - wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); - *ngeoms=1; - wgeom_return[0]->x=wgeom1->x; - wgeom_return[0]->y=wgeom1->y; - wgeom_return[0]->width=wgeom1->width; - wgeom_return[0]->height=wgeom2->height+wgeom2->y-wgeom1->y; - return -10; - } - else if((enclosed[1][0]&&enclosed[1][2])&&(wgeom1->height==wgeom2->height)){ -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); - *ngeoms=1; - wgeom_return[0]->x=wgeom1->x; - wgeom_return[0]->y=wgeom1->y; - wgeom_return[0]->width=wgeom2->width+wgeom2->x-wgeom1->x; - wgeom_return[0]->height=wgeom1->height; - return -10; - } - else if((enclosed[1][3]&&enclosed[1][1])&&(wgeom1->height==wgeom2->height)){ -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); - *ngeoms=1; - wgeom_return[0]->x=wgeom2->x; - wgeom_return[0]->y=wgeom2->y; - wgeom_return[0]->width=wgeom1->width+wgeom1->x-wgeom2->x; - wgeom_return[0]->height=wgeom2->height; - return -10; - } - else if((enclosed[1][3]&&enclosed[1][2])&&(wgeom1->width==wgeom2->width)){ -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); - *ngeoms=1; - wgeom_return[0]->x=wgeom2->x; - wgeom_return[0]->y=wgeom2->y; - wgeom_return[0]->width=wgeom2->width; - wgeom_return[0]->height=wgeom1->height+wgeom1->y-wgeom2->y; - return -10; - } - //if control reaches here therewasn't a group and we go on - } - if(tot2==2){ - //break geom2 -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); - wgeom_return[0]->x=wgeom2->x; - wgeom_return[0]->y=wgeom2->y; - wgeom_return[0]->width=wgeom2->width; - wgeom_return[0]->height=wgeom2->height; - *ngeoms=1; - if(enclosed[1][0]&&enclosed[1][1]){ - wgeom_return[0]->y=y1[1]; - wgeom_return[0]->height-=y1[1]-y2[0]; - } - else if(enclosed[1][0]&&enclosed[1][2]){ - wgeom_return[0]->x=x1[1]; - wgeom_return[0]->width-=x1[1]-x2[0]; - } - else if(enclosed[1][3]&&enclosed[1][1]) - wgeom_return[0]->width-=x2[1]-x1[0]; - else if(enclosed[1][3]&&enclosed[1][2]) - wgeom_return[0]->height-=y2[1]-y1[0]; - return -2; - } - else if(tot1==2){ - //if the first one breaks(which is already inserted) - //then we reenter the part that was left and the one - //that was to be inserted -// wgeom_return[1]=wgeom2; - wgeom_return[1]->x=wgeom2->x; - wgeom_return[1]->y=wgeom2->y; - wgeom_return[1]->width=wgeom2->width; - wgeom_return[1]->height=wgeom2->height; -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); - wgeom_return[0]->x=wgeom1->x; - wgeom_return[0]->y=wgeom1->y; - wgeom_return[0]->width=wgeom1->width; - wgeom_return[0]->height=wgeom1->height; - *ngeoms=1; - if(enclosed[0][0]&&enclosed[0][1]){ - wgeom_return[0]->y=y2[1]; - wgeom_return[0]->height-=y2[1]-y1[0]; - } - else if(enclosed[0][0]&&enclosed[0][2]){ - wgeom_return[0]->x=x2[1]; - wgeom_return[0]->width-=x2[1]-x1[0]; - } - else if(enclosed[0][3]&&enclosed[0][1]) - wgeom_return[0]->width-=x1[1]-x2[0]; - else if(enclosed[0][3]&&enclosed[0][2]) - wgeom_return[0]->height-=y1[1]-y2[0]; - return -1; - - } - else if(tot2==1){//in which case there is also tot1==1 but we rather not break that - //break geom2 in two -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); -// wgeom_return[1]=(WGeometry *)malloc(sizeof(WGeometry)); - *ngeoms=2; - if(enclosed[1][0]){ -//first - wgeom_return[0]->x=x1[1]; - wgeom_return[0]->y=y2[0]; - wgeom_return[0]->width=wgeom2->width-x1[1]+x2[0]; - wgeom_return[0]->height=wgeom2->height; -//second - wgeom_return[1]->x=x2[0]; - wgeom_return[1]->y=y1[1]; - wgeom_return[1]->width=x1[1]-x2[0]; - wgeom_return[1]->height=wgeom2->height-y1[1]+y2[0]; - } - else if(enclosed[1][1]){ -//first - wgeom_return[0]->x=x2[0]; - wgeom_return[0]->y=y2[0]; - wgeom_return[0]->width=wgeom2->width-x2[1]+x1[0]; - wgeom_return[0]->height=wgeom2->height; -//second - wgeom_return[1]->x=x1[0]; - wgeom_return[1]->y=y1[1]; - wgeom_return[1]->width=x2[1]-x1[0]; - wgeom_return[1]->height=wgeom2->height-y1[1]+y2[0]; - } - else if(enclosed[1][2]){ -//first(same as [1][0]) - wgeom_return[0]->x=x1[1]; - wgeom_return[0]->y=y2[0]; - wgeom_return[0]->width=wgeom2->width-x1[1]+x2[0]; - wgeom_return[0]->height=wgeom2->height; -//second - wgeom_return[1]->x=x2[0]; - wgeom_return[1]->y=y2[0]; - wgeom_return[1]->width=x1[1]-x2[0]; - wgeom_return[1]->height=wgeom2->height-y2[1]+y1[0]; - } - else if(enclosed[1][3]){ -//first(same as [1][1]) - wgeom_return[0]->x=x2[0]; - wgeom_return[0]->y=y2[0]; - wgeom_return[0]->width=wgeom2->width-x2[1]+x1[0]; - wgeom_return[0]->height=wgeom2->height; -//second - wgeom_return[1]->x=x1[0]; - wgeom_return[1]->y=y2[0]; - wgeom_return[1]->width=x2[1]-x1[0]; - wgeom_return[1]->height=wgeom2->height-y2[1]+y1[0]; - } - return -2; - } - else{//polygons collide but no point of one is in the other - //so we just keep the two parts of geom2 that are outside geom1 - - //break geom2 in two - //two cases: - //geom2 crossing vertically geom1 - //and geom2 crossing horizontally geom1 - //The proper one can be found by simply checking x,y positions -// wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); -// wgeom_return[1]=(WGeometry *)malloc(sizeof(WGeometry)); - *ngeoms=2; - if(wgeom2->y<wgeom1->y){ - //common - wgeom_return[0]->x=wgeom_return[1]->x=x2[0]; - wgeom_return[0]->width=wgeom_return[1]->width=wgeom2->width; - - wgeom_return[0]->y=y2[0]; - wgeom_return[0]->height=wgeom2->height-y2[1]+y1[0]; - wgeom_return[1]->y=y1[1]; - wgeom_return[1]->height=y2[1]-y1[1]; - } - else{ - //common - wgeom_return[0]->y=wgeom_return[1]->y=y2[0]; - wgeom_return[0]->height=wgeom_return[1]->height=wgeom2->height; - - wgeom_return[0]->x=x2[0]; - wgeom_return[0]->width=wgeom2->width-x2[1]+x1[0]; - wgeom_return[1]->x=x1[1]; - wgeom_return[1]->width=x2[1]-x1[1]; - } - return -2; - } - } -} - -int RectInsert(RectArea **root,WGeometry *wgeom){ - - int total_insertions=0; - RectArea *temp=NULL,*newnode=(RectArea *)malloc(sizeof(RectArea)); - //align - //we do need to know boundaries - wgeom->width+=(wgeom->width%2)|(wgeom->x%2); - wgeom->height+=(wgeom->height%2)|(wgeom->y%2); - wgeom->width+=(wgeom->width%2); - wgeom->height+=(wgeom->height%2); - wgeom->x-=wgeom->x%2; - wgeom->y-=wgeom->y%2; -// fprintf(stderr," %d %d %d %d\n",wgeom->x, - - newnode->geom.x=wgeom->x; - newnode->geom.y=wgeom->y; - newnode->geom.width=wgeom->width; - newnode->geom.height=wgeom->height; - newnode->prev=newnode->next=NULL; - if(*root==NULL){ - *root=newnode; - total_insertions=1; - } - else{ - WGeometry *wgeom_return[2]; - wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); - wgeom_return[1]=(WGeometry *)malloc(sizeof(WGeometry)); - - int ngeoms=0,insert_ok=1,i=0; - temp=*root; - while(insert_ok){//if something is broken list does not procceed(except on -1 collres case) - int collres/*=0;//*/=CollideRects(&(temp->geom),wgeom,wgeom_return,&ngeoms); - if((!collres)) - insert_ok=1; - else{ - for(i=0;i<ngeoms;i++){ - wgeom_return[i]->width+=(wgeom_return[i]->width%2)|(wgeom_return[i]->x%2); - wgeom_return[i]->height+=(wgeom_return[i]->height%2)|(wgeom_return[i]->y%2); - wgeom_return[i]->width+=(wgeom_return[i]->width%2); - wgeom_return[i]->height+=(wgeom_return[i]->height%2); - wgeom_return[i]->x-=wgeom_return[i]->x%2; - wgeom_return[i]->y-=wgeom_return[i]->y%2; - } - insert_ok=0; - switch(collres){ - case 1://remove current node,reinsert new one - total_insertions--; - if(temp->prev!=NULL){//no root - if(temp->next!=NULL){// - RectArea *temp1=temp->next; - temp->prev->next=temp->next; - temp->next->prev=temp->prev; - free(temp); - if((wgeom->width>0)&&(wgeom->height>0)) - total_insertions+=RectInsert(&temp1,wgeom); - } - else{ - temp->prev->next=newnode; - newnode->prev=temp->prev; - total_insertions++; - free(temp); - } - } - else{//root - if((*root)->next!=NULL){ - (*root)=(*root)->next; - (*root)->prev=NULL; - if((wgeom->width>0)&&(wgeom->height>0)) - total_insertions+=RectInsert(root,wgeom); - } - else if((wgeom->width>0)&&(wgeom->height>0)){ - *root=newnode; - total_insertions++; - } - else{ - *root=NULL; - total_insertions++; - } - free(temp); - } - break; - case 2://done,area is already covered - free(newnode); - break; - case -1://current node is broken and reinserted(in same pos) - //newnode is also reinserted - if((wgeom_return[0]->width>0)&&(wgeom_return[0]->height>0)){ - temp->geom.x=wgeom_return[0]->x; - temp->geom.y=wgeom_return[0]->y; - temp->geom.width=wgeom_return[0]->width; - temp->geom.height=wgeom_return[0]->height; - if(temp->next==NULL){ - temp->next=newnode; - newnode->prev=temp; - total_insertions++; - } - else{ - insert_ok=1; - } - } - else{//it might happen that the old and now broken node - //is of zero width or height(so it isn't reinserted) - /*TODO this may cause lines to be left not updated - so maybe it is needed to increase the size by one - pixel(zero width or height cause BadValue*/ - if((temp->prev==NULL)&&(temp->next!=NULL)){ - *root=(*root)->next; - (*root)->prev=NULL; - } - else if((temp->next==NULL)&&(temp->prev!=NULL)){ - temp->prev->next=newnode; - newnode->prev=temp->prev; - } - else if((temp->next==NULL)&&(temp->prev==NULL)) - (*root)=newnode; - else{ - total_insertions--; - temp->next->prev=temp->prev; - temp->prev->next=temp->next; - total_insertions+=RectInsert(&temp->next,wgeom); - } - free(temp); - } - break; - case -2://new is broken and reinserted - if(temp->next==NULL){ - total_insertions+=ngeoms; - newnode->geom.x=wgeom_return[0]->x; - newnode->geom.y=wgeom_return[0]->y; - newnode->geom.width=wgeom_return[0]->width; - newnode->geom.height=wgeom_return[0]->height; - temp->next=newnode; - newnode->prev=temp; - if(ngeoms>1){ - RectArea *newnode1=(RectArea *)malloc(sizeof(RectArea)); - newnode1->geom.x=wgeom_return[1]->x; - newnode1->geom.y=wgeom_return[1]->y; - newnode1->geom.width=wgeom_return[1]->width; - newnode1->geom.height=wgeom_return[1]->height; - newnode->next=newnode1; - newnode1->prev=newnode; - newnode1->next=NULL; - } - } - else{ - for(i=0;i<ngeoms;i++){ - if((wgeom_return[i]->width>0)&&(wgeom_return[i]->height>0)) - total_insertions+=RectInsert(&temp->next,wgeom_return[i]); - } - } - break; - case -10://grouped - if(temp->prev==NULL){ - if(temp->next==NULL){//empty list - newnode->geom.x=wgeom_return[0]->x; - newnode->geom.y=wgeom_return[0]->y; - newnode->geom.width=wgeom_return[0]->width; - newnode->geom.height=wgeom_return[0]->height; - *root=newnode; - free(temp); - } - else{ - total_insertions--; - *root=temp->next; - (*root)->prev=NULL; - free(temp); - if((wgeom_return[0]->width>0)&&(wgeom_return[0]->height>0)) - total_insertions+=RectInsert(root,wgeom_return[0]); - } - } - else if(temp->next==NULL){//last, enter anyway - newnode->geom.x=wgeom_return[0]->x; - newnode->geom.y=wgeom_return[0]->y; - newnode->geom.width=wgeom_return[0]->width; - newnode->geom.height=wgeom_return[0]->height; - temp->prev->next=newnode; - newnode->prev=temp->prev; - free(temp); - } - else{//remove node and reinsert, starting where we were - total_insertions--; - RectArea *temp1=temp->next; - temp->prev->next=temp->next; - temp->next->prev=temp->prev; - free(temp); - if((wgeom_return[0]->width>0)&&(wgeom_return[0]->height>0)) - total_insertions+=RectInsert(&temp1,wgeom_return[0]); - } - break; - } - } - if(insert_ok){ - if(temp->next==NULL){ - temp->next=newnode; - newnode->prev=temp; - total_insertions++; - break; - } - else{ - temp=temp->next; - } - } - else{ - break; - } - }; - - free(wgeom_return[0]); - free(wgeom_return[1]); - } - return total_insertions; -} - -void ClearList(RectArea **root){ - - RectArea *temp; - temp=*root; - if(temp!=NULL){ - while(temp->next!=NULL){ - temp=temp->next; - free(temp->prev); - - } - free(temp); - *root=NULL; - } -} - diff --git a/rMD-exp/src/register_callbacks.c b/rMD-exp/src/register_callbacks.c deleted file mode 100644 index 08c528f..0000000 --- a/rMD-exp/src/register_callbacks.c +++ /dev/null @@ -1,91 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> -void SetExpired(int signum){ - frames_total++; - if(capture_busy){ - frames_lost++; - } - pthread_cond_broadcast(time_cond);//sig handlers should not call this func - //could be a set_expired and main thread - //doing a while(running) if set_expired broadcast else usleep(n) -} - -void SetPaused(int signum){ - if(!Paused) - Paused=1; - else{ -// pthread_cond_broadcast(pause_cond);//thsi should work, but it doesn't - int i;//this is a bug - Paused=0;//normally with the broadcast all the threads should restart, but sound capture thread - for(i=0;i<15;i++)//remains dead. If a bunch of signals, restarts all threads, why can't a broadcast do the same? - pthread_cond_signal(pause_cond);//if you have any idea please contact me. - //(misses the signal?) - } -} - - -void SetRunning(int signum){ - *Running=0; - if(signum==SIGABRT) - Aborted=1; -} - -void CancelTimer(void){ - struct itimerval value; - value.it_interval.tv_sec= - value.it_value.tv_sec= - value.it_interval.tv_usec= - value.it_value.tv_usec=0; - - setitimer(ITIMER_REAL,&value,NULL); -} - -void RegisterCallbacks(ProgArgs *args){ - - struct itimerval value; - struct sigaction time_act,pause_act,end_act; - - - value.it_interval.tv_sec=value.it_value.tv_sec=0; - value.it_interval.tv_usec=value.it_value.tv_usec=(1000000)/args->fps; - setitimer(ITIMER_REAL,&value,NULL); - time_act.sa_handler=SetExpired; - pause_act.sa_handler=SetPaused; - end_act.sa_handler=SetRunning; - sigfillset(&(time_act.sa_mask)); - sigfillset(&(pause_act.sa_mask)); - sigfillset(&(end_act.sa_mask)); - time_act.sa_flags=pause_act.sa_flags=end_act.sa_flags=0; - sigaction(SIGALRM,&time_act,NULL); - sigaction(SIGUSR1,&pause_act,NULL); - sigaction(SIGINT,&end_act,NULL); - sigaction(SIGTERM,&end_act,NULL); - sigaction(SIGABRT,&end_act,NULL); -} - diff --git a/rMD-exp/src/rmd_cache.c b/rMD-exp/src/rmd_cache.c deleted file mode 100644 index 9cb76d5..0000000 --- a/rMD-exp/src/rmd_cache.c +++ /dev/null @@ -1,102 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - -#include <recordmydesktop.h> - -void InitCacheData(ProgData *pdata,EncData *enc_data_t,CacheData *cache_data_t){ - int width,height,offset_x,offset_y,pid; - char pidbuf[8]; - - //we set the buffer only since there's - //no need to initialize the encoder from now. - width=((pdata->brwin.rgeom.width + 15) >>4)<<4; - height=((pdata->brwin.rgeom.height + 15) >>4)<<4; - offset_x=((width-pdata->brwin.rgeom.width)/2)&~1; - offset_y=((height-pdata->brwin.rgeom.height)/2)&~1; - - (pdata)->enc_data=enc_data_t; - - enc_data_t->yuv.y=(unsigned char *)malloc(height*width); - enc_data_t->yuv.u=(unsigned char *)malloc(height*width/4); - enc_data_t->yuv.v=(unsigned char *)malloc(height*width/4); - enc_data_t->yuv.y_width=width; - enc_data_t->yuv.y_height=height; - enc_data_t->yuv.y_stride=width; - - enc_data_t->yuv.uv_width=width/2; - enc_data_t->yuv.uv_height=height/2; - enc_data_t->yuv.uv_stride=width/2; - enc_data_t->x_offset=offset_x; - enc_data_t->y_offset=offset_y; - - - //now we set the cache files - (pdata)->cache_data=cache_data_t; - - cache_data_t->workdir=(pdata->args).workdir; - pid=getpid(); - - I16TOA(pid,pidbuf) - //names are stored relatively to current dir(i.e. no chdir) - cache_data_t->projname=malloc(strlen(cache_data_t->workdir)+12+strlen(pidbuf)+3); - //projname - strcpy(cache_data_t->projname,cache_data_t->workdir); - strcat(cache_data_t->projname,"/"); - strcat(cache_data_t->projname,"rMD-session-"); - strcat(cache_data_t->projname,pidbuf); - strcat(cache_data_t->projname,"/"); - //image data - cache_data_t->imgdata=malloc(strlen(cache_data_t->projname)+11); - strcpy(cache_data_t->imgdata,cache_data_t->projname); - strcat(cache_data_t->imgdata,"img.out.gz"); - //audio data - cache_data_t->audiodata=malloc(strlen(cache_data_t->projname)+10); - strcpy(cache_data_t->audiodata,cache_data_t->projname); - strcat(cache_data_t->audiodata,"audio.pcm"); - - //now that've got out buffers and our filenames we start - //creating the needed files - - if(mkdir(cache_data_t->projname,0777)){ - fprintf(stderr,"Could not create temporary directory %s !!!\n",cache_data_t->projname); - exit(13); - } - cache_data_t->ifp=gzopen(cache_data_t->imgdata,"wb0f"); - if(cache_data_t->ifp==NULL){ - fprintf(stderr,"Could not create temporary file %s !!!\n",cache_data_t->imgdata); - exit(13); - } - if(!pdata->args.nosound){ - cache_data_t->afp=fopen(cache_data_t->audiodata,"wb"); - if(cache_data_t->afp==NULL){ - fprintf(stderr,"Could not create temporary file %s !!!\n",cache_data_t->audiodata); - exit(13); - } - } - -} - - diff --git a/rMD-exp/src/setbrwindow.c b/rMD-exp/src/setbrwindow.c deleted file mode 100644 index 58dc34c..0000000 --- a/rMD-exp/src/setbrwindow.c +++ /dev/null @@ -1,176 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> -void SizePack2_8_16(int *start,int *size,int limit){ - int octoffset,hexoffset; - - //align in two - //an odd x can always go down and still be in recording area. - //Resolutions come in even numbers - //so if x is an odd numer, width max is an odd number, too - //thus since x will go down one then width can go up one too and still - //be inbounds - (*size)+=((*size)%2)|((*start)%2); - //but if x goes down 1 and width is already even,it becomes odd so: - (*size)+=((*size)%2); - (*start)-=(*start)%2; - - - //32 bit pack align - //we already have disible by two width,so - //it's 2, 4 or 6 - octoffset=((*size)%8); - if(octoffset==2){ - (*size)-=2; - - } - else if(octoffset==6){ - if((*size)+(*start)+2<=limit) - (*size)+=2; - else if((*start)>=2){ - (*start)-=2; - (*size)+=2; - } - else{ - (*start)+=2; - (*size)-=4; - } - } - - else if(octoffset==4){ - if(((*size)+(*start)+2<=limit)&&((*start)>=2)){ - (*start)-=2; - (*size)+=4; - } - else if((*size)+(*start)+4<=limit){ - (*size)+=4; - } - else if((*start)>=4){ - (*start)-=4; - (*size)+=4; - } - else{ - (*start)+=2; - (*size)-=4; - } - } - - //16 divisble width(needed for shared memory only,but applied anyway since theora wants it, too) - //we already have divisibility by 8 so module - //by 16 is euther 8 or 0 - hexoffset=((*size)%16); - if(hexoffset){ - if(((*size)+(*start)+4<=limit)&&((*start)>=4)){ - (*start)-=4; - (*size)+=8; - } - else if((*size)+(*start)+8<=limit){ - (*size)+=8; - } - else if((*start)>=8){ - (*start)-=8; - (*size)+=8; - } - else{ - (*start)+=4; - (*size)-=8; - } - } - -} - - - -int SetBRWindow(Display *dpy,BRWindow *brwin,DisplaySpecs *specs,ProgArgs *args){ - //before we start recording we have to make sure the ranges are valid - if(args->windowid==0){//root window - //first set it up - brwin->windowid=specs->root; - brwin->geom.x=brwin->geom.y=0; - brwin->geom.width=specs->width; - brwin->geom.height=specs->height; - brwin->rgeom.x=args->x; - brwin->rgeom.y=args->y; - brwin->rgeom.width=((args->width)?args->width:specs->width-brwin->rgeom.x); - brwin->rgeom.height=((args->height)?args->height:specs->height-brwin->rgeom.y); - //and then check validity - if((brwin->rgeom.x+brwin->rgeom.width>specs->width)|| - (brwin->rgeom.y+brwin->rgeom.height>specs->height)){ - fprintf(stderr,"Window size specification out of bounds!(current resolution:%dx%d)\n",specs->width,specs->height); - return 1; - } - } - else{ - Window wchid; - int transl_x,transl_y; - - XWindowAttributes attribs; - XGetWindowAttributes(dpy,args->windowid,&attribs); - if((attribs.map_state==IsUnviewable)||(attribs.map_state==IsUnmapped)){ - fprintf(stderr,"Window must be mapped and visible!\n"); - return 1; - } - XTranslateCoordinates(dpy,specs->root,args->windowid,attribs.x,attribs.y,&transl_x,&transl_y,&wchid); - brwin->windowid=specs->root; - brwin->geom.x=attribs.x-transl_x; - brwin->geom.y=attribs.y-transl_y; - brwin->geom.width=attribs.width; - brwin->geom.height=attribs.height; - if((brwin->geom.x+brwin->geom.width>specs->width)|| - (brwin->geom.y+brwin->geom.height>specs->height)){ - fprintf(stderr,"Window must be on visible screen area!\n"); - return 1; - } - - brwin->rgeom.x=brwin->geom.x+args->x; - brwin->rgeom.y=brwin->geom.y+args->y; - brwin->rgeom.width=((args->width)?args->width:brwin->geom.width-args->x); - brwin->rgeom.height=((args->height)?args->height:brwin->geom.height-args->y); - if((args->x+brwin->rgeom.width>brwin->geom.width)|| - (args->y+brwin->rgeom.height>brwin->geom.height)){ - fprintf(stderr,"Specified Area is larger than window!\n"); - return 1; - } - } - fprintf(stderr, "Initial recording window is set to:\n" - "X:%d Y:%d Width:%d Height:%d\n" - ,brwin->rgeom.x,brwin->rgeom.y,brwin->rgeom.width,brwin->rgeom.height); - SizePack2_8_16(&brwin->rgeom.x,&brwin->rgeom.width,specs->width); - SizePack2_8_16(&brwin->rgeom.y,&brwin->rgeom.height,specs->height); - - fprintf(stderr, "Adjusted recording window is set to:\n" - "X:%d Y:%d Width:%d Height:%d\n" - ,brwin->rgeom.x,brwin->rgeom.y,brwin->rgeom.width,brwin->rgeom.height); - - - - brwin->nbytes=(((brwin->rgeom.width+15)>>4)<<4)*(((brwin->rgeom.height+15)>>4)<<4)*4; - - - return 0; -} diff --git a/rMD-exp/src/update_image.c b/rMD-exp/src/update_image.c deleted file mode 100644 index 2725011..0000000 --- a/rMD-exp/src/update_image.c +++ /dev/null @@ -1,86 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -void UpdateImage(Display * dpy, - yuv_buffer *yuv, - pthread_mutex_t *yuv_mutex, - DisplaySpecs *specs, - RectArea **root, - BRWindow *brwin, - EncData *enc, - char *datatemp, - int noshmem, - int no_quick_subsample){ - RectArea *temp; - unsigned char *dtap=(unsigned char*)datatemp; - temp=*root; - - if(temp!=NULL){ - do{ - if(noshmem){ - GetZPixmap( dpy, - specs->root, - datatemp, - temp->geom.x, - temp->geom.y, - temp->geom.width, - temp->geom.height); - - pthread_mutex_lock(yuv_mutex); - if(no_quick_subsample){ - UPDATE_YUV_BUFFER_IM_AVG(yuv,dtap, - (temp->geom.x-brwin->rgeom.x+enc->x_offset),(temp->geom.y-brwin->rgeom.y+enc->y_offset), - (temp->geom.width),(temp->geom.height)); - } - else{ - UPDATE_YUV_BUFFER_IM(yuv,dtap, - (temp->geom.x-brwin->rgeom.x+enc->x_offset),(temp->geom.y-brwin->rgeom.y+enc->y_offset), - (temp->geom.width),(temp->geom.height)); - } - - pthread_mutex_unlock(yuv_mutex); - } - else{ - if(no_quick_subsample){ - UPDATE_YUV_BUFFER_SH_AVG(yuv,dtap, - (temp->geom.x-brwin->rgeom.x+enc->x_offset),(temp->geom.y-brwin->rgeom.y+enc->y_offset), - (temp->geom.width),(temp->geom.height)); - } - else{ - UPDATE_YUV_BUFFER_SH(yuv,dtap, - (temp->geom.x-brwin->rgeom.x+enc->x_offset),(temp->geom.y-brwin->rgeom.y+enc->y_offset), - (temp->geom.width),(temp->geom.height)); - } - - } - temp=temp->next; - }while(temp!=NULL); - } -} - diff --git a/rMD-exp/src/wm_check.c b/rMD-exp/src/wm_check.c deleted file mode 100644 index ee6b0ba..0000000 --- a/rMD-exp/src/wm_check.c +++ /dev/null @@ -1,68 +0,0 @@ -/********************************************************************************* -* recordMyDesktop * -********************************************************************************** -* * -* Copyright (C) 2006 John Varouhakis * -* * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* * -* * -* * -* For further information contact me at johnvarouhakis@gmail.com * -**********************************************************************************/ - - -#include <recordmydesktop.h> - -char *rmdWMCheck(Display *dpy,Window root){ - - Window *wm_child; - Atom nwm_atom, - utf8_string, - wm_name_atom, - rt; - unsigned long nbytes, - nitems; - - char *wm_name_str=NULL; - int fmt; - - utf8_string = XInternAtom(dpy, "UTF8_STRING", False); - - nwm_atom =XInternAtom(dpy,"_NET_SUPPORTING_WM_CHECK",True); - wm_name_atom =XInternAtom(dpy,"_NET_WM_NAME",True); - - if(nwm_atom!=None && wm_name_atom!=None){ - if(!((XGetWindowProperty( dpy,root,nwm_atom,0,100, - False,XA_WINDOW, - &rt,&fmt,&nitems, &nbytes, - (unsigned char **)((void*)&wm_child)) - ==Success ) && - (XGetWindowProperty( dpy,*wm_child,wm_name_atom,0,100, - False,utf8_string,&rt, - &fmt,&nitems, &nbytes, - (unsigned char **)((void*)&wm_name_str)) - ==Success ))){ - fprintf(stderr,"Warning!!!\nYour window manager appears to be non-compliant!\n"); - } - } - fprintf(stderr,"Your window manager appears to be %s\n\n", - ((wm_name_str!=NULL)?wm_name_str:"Uknown")); - - - return wm_name_str; -} - |