distmp3-0.1.9/0040755000076500007640000000000007177547241012711 5ustar gandalfgandalfdistmp3-0.1.9/distmp30100755000076500007640000001374107177542417014225 0ustar gandalfgandalf#!/usr/bin/perl # Distmp3, a program for distributing the encoding of music among several computers. # Copyright (C) 2000 Martin Josefsson # # 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. # # # Author: Martin Josefsson # use IO::Socket; use IO::Handle; use Net::hostent; $|=1; #---------------------------- $version = "0.1.9"; $config_file = "/etc/distmp3/distmp3.conf"; $RTR = "hejhopp_rtr"; $RTS = "hejhopp_rts"; $ACK = "hejhopp_ack"; $SRV_ID = "hejhopp_server_id"; $CLI_ID = "hejhopp_client_id"; #---------------------------- $SIG{INT} = sub { closedown("Caught INT signal, going down in flames..."); }; $SIG{TERM} = sub { closedown("Caught TERM signal, going up in smoke..."); }; sub parse_config_file { open(CONFIG,"<$_[0]") or die "Couldn't open config file $_[0]"; while ( ) { if ( !(/^\n/ || /^#/ || /^;/) ) { if ( /^CLIENT_/ ) { chomp; ($config_option,$config_value) = split("=",$_,2); $config_option =~ s/CLIENT_//; @config{$config_option} = $config_value; } } } close CONFIG; } sub parse_command_line { $row = -1; $notdash = 0; LOOP: while ( ++$row <= @ARGV ) { if ( $ARGV[$row] eq "-h" || $ARGV[$row] eq "--help" ) { print_usage(); exit(0); } if ( $ARGV[$row] eq "-p" ) { ++$row; @config{PORT} = $ARGV[$row]; next LOOP; } if ( $ARGV[$row] eq "-s" ) { ++$row; @config{DATASIZE} = $ARGV[$row]; next LOOP; } if ( $ARGV[$row] eq "-d" ) { ++$row; if ( $ARGV[$row] == 1 ) { @config{DEBUG} = 1; } else { undef @config{DEBUG}; } next LOOP; } if ( $ARGV[$row] eq "-df" ) { ++$row; @config{DEBUGFILE} = $ARGV[$row]; next LOOP; } if ( $notdash == 0 ) { @config{HOST} = $ARGV[$row]; ++$notdash; next LOOP; } if ( $notdash == 1 ) { @config{WAVFILE} = $ARGV[$row]; ++$notdash; next LOOP; } if ( $notdash == 2 ) { @config{MP3FILE} = $ARGV[$row]; ++$notdash; next LOOP; } } } sub print_usage { print "Usage: $0 [-p port] [-s datasize] [-d debug] [-df debugfile] host wav-file mp3-file\n"; } sub open_remote_connection { printd('Opening remote connection'); $remote = IO::Socket::INET->new(Proto => "tcp", PeerAddr => @config{HOST}, PeerPort => @config{PORT}) or die "Can't connect to @config{HOST} on port @config{PORT}: $!"; $remote->autoflush(1); printd( "Connected to @config{HOST} on port @config{PORT}"); } sub open_debug_file { open (DEBUG, ">>@config{DEBUGFILE}") or die "Couldn't open debug-file @config{DEBUGFILE}: $!"; } sub close_debug_file { close DEBUG; } sub open_wav_file { printd('opening wav-file'); open (WAV_FILE, "<@config{WAVFILE}") || die "Can't open file @config{WAVFILE} for reading: $!"; WAV_FILE->autoflush(1); $size_of_wavfile = sysseek(WAV_FILE,0,2); sysseek(WAV_FILE,0,0); } sub open_mp3_file { printd('opening mp3-file'); open (MP3_FILE, ">@config{MP3FILE}") || die "Can't open file @config{MP3FILE} for writing: $!"; MP3_FILE->autoflush(1); } sub close_wav_file { printd('closing wav-file'); close WAV_FILE; } sub close_mp3_file { printd('closing mp3-file'); close MP3_FILE; } sub send_data { $data = $_[0]; print $remote $data; } sub recieve_data { read $remote,$rdata,@config{DATASIZE}; return $rdata; } sub read_from_wav { read WAV_FILE,$wdata,@config{DATASIZE}; $data_read = $data_read + length($wdata); $persent_read = ($data_read*100)/$size_of_wavfile; printf "%.2f%% of $size_of_wavfile bytes done.\r", $persent_read; return $wdata; } sub write_to_mp3 { $mdata = $_[0]; print MP3_FILE $mdata; } sub handshake { printd('initiate handshake'); send_data($CLI_ID); printd('sent Client id'); read $remote,$answer,length($SRV_ID); printd('read Server id'); if ( $answer ne $SRV_ID ) { die "Server isn't who he should be..."; } printd('Ok, server id is what it should be'); send_data($ACK); printd('sent ack'); } sub printd { if ( @config{DEBUG} ) { $message = $_[0]; print "$message\n"; } if ( @config{DEBUGFILE} ) { $message = $_[0]; print DEBUG "$message\n"; } } sub closedown { if ( @config{DEBUG} || @config{DEBUGFILE} ) { printd("$_[0]\n"); } if ( @config{DEBUGFILE} ) { close DEBUG; } print "Exited gracefully...\n"; shutdown $remote,2; close WAV_FILE; close MP3_FILE; exit(1); }; #Main program if (@ARGV < 3) { print_usage(); exit(1); } parse_config_file($config_file); parse_command_line(); if ( @config{DEBUGFILE} ) { open_debug_file(); } printd("Distmp3 client version $version"); print "Encoding @config{WAVFILE} into @config{MP3FILE} on host @config{HOST}\n"; printd("Encoding @config{WAVFILE} into @config{MP3FILE} on host @config{HOST}"); open_remote_connection(); handshake(); printd('forking like a GNU'); read $remote,$answer,length($RTR); read $remote,$answer2,length($RTR); if ( ($answer eq $RTR || $answer eq $RTS) && ($answer2 eq $RTS || $answer2 eq $RTR) ) { unless ($pid = fork) { printd('forking child to send data'); open_wav_file(); while ( $data = read_from_wav() ) { send_data($data); } close_wav_file(); shutdown $remote,1; exit(0); } printd('entering code to recieve data'); open_mp3_file(); while ( $data2 = recieve_data() ) { write_to_mp3($data2); } close_mp3_file(); exit(0); waitpid($pid,0); } else { die "Server didn't send RTS and RTR!!!"; } if ( $debug_file ) { print DEBUG "Finished\n"; close_debug_file(); } print "\n"; distmp3-0.1.9/distmp3.conf0100664000076500007640000000302207177543606015140 0ustar gandalfgandalf#------------------------------------------------ # Configfile for distmp3/distmp3host # # Comments start with # or ; # # Options for distmp3host starts with SERVER_ # # Options for distmp3 starts with CLIENT_ # # The options can be overridden on the commandline # See 'distmp3 --help' and 'distmp3host --help' # for the syntax. # #-------------------- # Server part below | #-------------------- # if uncommented distmp3host prints debugmessages. ;SERVER_DEBUG=1 # if uncommented distmp3host prints debugmessages to the file. ;SERVER_DEBUGFILE=distmp3host.log # the fifo that the mp3encoder should use as input SERVER_WAVFIFO=/tmp/fifo.wav # the fifo that the mp3encoder should use as output SERVER_MP3FIFO=/tmp/fifo.mp3 # the port the server listens for connections on SERVER_PORT=4600 # the program that should be executed then a connection is made. # $wavfifo will be replaced with the path and name of the WAVFIFO # $mp3fifo will be replaced with the path and name of the MP3FIFO SERVER_PROGRAM=/usr/local/bin/bladeenc -br 192 $wavfifo $mp3fifo # the "chunk"-size that the data will be sent in. SERVER_DATASIZE=16384 #-------------------- # Client part below | #-------------------- # if uncommented distmp3 prints debugmessages. ;CLIENT_DEBUG=1 # if uncommented distmp3 prints debugmessages to the file. ;CLIENT_DEBUGFILE=distmp3.log # the port the client tries to connect to on the remote host. CLIENT_PORT=4600 # the "chunk"-size that the data will be sent in. CLIENT_DATASIZE=16384 #------------------------------------------------ distmp3-0.1.9/LICENSE0100664000076500007640000004312707064555364013724 0ustar gandalfgandalf 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. Copyright (C) 19yy 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) 19yy 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. , 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. distmp3-0.1.9/distmp3.10100664000076500007640000000324007177545400014347 0ustar gandalfgandalf.TH DISTMP3 1 .SH NAME distmp3 \- client for distributed mp3-encoding across multiple hosts on a network .SH SYNOPSIS .B distmp3 .I [-p port] .I [-s datasize] .I [-d debug] .I [-df debugfile] .I remotehost .I wav-file .I mp3-file .SH "DESCRIPTION" distmp3 is the client part of distmp3, a utility for distributed mp3-encoding across multiple hosts on a network. The client connects to a remote host on port 4600 and a handshake occurs. If the handshake goes well, the client will open the wav-file for reading and the mp3-file for writing. The client then starts sending raw data from the wav-file across the network to the daemon, which sends it back to the client who writes it down in a file. Default values are used if none specified, and those defaults are read from .B /etc/distmp3/distmp3.conf .SH OPTIONS .TP .B -p port The port on .B remotehost to connect to. .TP .B -s datasize The datachunksize to use when sending data to the distmp3host server. .TP .B -d debug If .B 1 then debugmessages will be printed on stdout, else suppressed. .TP .B -df debugfile If defined debugmessages will be printed to file .B debugfile . .TP .B remotehost The DNS hostname or IP address of the remote machine running distmp3host. .TP .B wav-file The local WAV format file to be encoded on .B remotehost. .TP .B mp3-file. The desired local destination for the finished mp3 file. If this file already exists and is writable, it will be overwritten. If it is not writable, distmp3 will exit with an error. .SH "SEE ALSO" distmp3host(1) .SH AUTHOR Martin Josefsson . Idea for distmp3 by Peter Lindqvist . Manpage written by Robert Woodcock . distmp3-0.1.9/distmp3host.10100664000076500007640000000354007177546416015260 0ustar gandalfgandalf.TH DISTMP3HOST 1 .SH NAME distmp3host \- daemon for distributed mp3-encoding across multiple hosts on a network .SH SYNOPSIS .B distmp3host .SH "DESCRIPTION" distmp3host is daemon part of distmp3, a utility for distributed mp3-encoding across multiple hosts on a network. The daemon binds port 4600 on localhost and waits for connections. The client connects to a remote host on port 4600 and a handshake occurs. If the handshake goes well the daemon creates two named-pipes (fifos) for the mp3-encoding program to use. It also forks one child as reading or writing from/to the fifos is a blocking system call. The daemon passes the recieved wav data to the output-fifo (which the mp3-encoding program reads its data from). The daemon reads the encoded mp3-data from the input-fifo (the one the mp3-encoder write it's encoded mp3 to) and sends it back to the client who writes it down in a file. Default values are used if none specified, and those defaults are read from .B /etc/distmp3/distmp3.conf .SH OPTIONS .TP .B -p port The port to listen on. .TP .B -s datasize The datachunksize to use when sending data to the distmp3host server. .TP .B -d debug If .B 1 then debugmessages will be printed on stdout, else suppressed. .TP .B -df debugfile If defined debugmessages will be printed to file .B debugfile . .TP .B -w wavfifo The fifo used for writing the wavfile to so the encoder can read it. .TP .B -m mp3fifo The fifo used by the encoder to write the mp3stream to. .TP .B -e "program $wavfifo $mp3fifo" The program used for encoding the wavdata into mp3. $wavfifo will be replaced with what was specified with -w $mp3fifo will be replaced with what was specified with -m .TP .SH "SEE ALSO" distmp3(1) .SH AUTHOR Martin Josefsson . Idea for distmp3 by Peter Lindqvist . Manpage written by Robert Woodcock . distmp3-0.1.9/README0100644000076500007640000000330407177543672013572 0ustar gandalfgandalfLicensed under the GPL! | see the file called LICENSE for details. | | -------------------------------------------| Distmp3 is a client and a daemon (both written in perl) for distributed mp3-encoding across multiple hosts on a network. The daemon binds port 4600 on localhost and waits for connections. The client connects to a remote host on port 4600 and a handshake occurs. If the handshake goes well the daemon creates two named-pipes (fifos) for the mp3-encoding program to use. It also forks two childs as reading or writing from/to the fifos is a blocking system call. The client will, if the handshake goes well, open the wav-file for reading and the mp3-file for writing. The client then starts sending raw data from the wav-file across the network to the daemon who passes the recieved data to the output-fifo (which the mp3-encoding program reads its data from). The daemon reads the encoded mp3-data from the input-fifo (the one the mp3-encoder write it's encoded mp3 to) and sends it back to the client who writes it down in a file. The mp3-encoding programs that I know works is 8hz-mp3. BladeEnc, l3enc, encoder refuses to cooperate, they probably doesn't like to not being able to seek to a certain position within the wav-file. Update: Now there's a config-file, /etc/distmp3/distmp3.conf All options are now configured in this file, but it's possible to override them on the command-line. The author of this program doesn't take any responsibility for any harm this program may do to you, your pet hamster, or anything else. Author: Martin Josefsson Idea: Peter Lindqvist Thanks to: nevyn, without him this program wouldn't exist. distmp3-0.1.9/Changelog0100664000076500007640000000236307177547175014534 0ustar gandalfgandalf2000-10-31 Martin Josefsson * Saw a new release of abcde on freshmeat and realized that I forgot about Distmp3 :( now I've fixed the last things for a 0.1.9 release (I hope) 2000-03-26 Martin Josefsson * Changed so that distmp3 and distmp3host only forks one child. The second child was not needed as the parent wasn't doing anything. * Moved the variable DATA_SIZE to distmp3.conf and renamed it to DATASIZE * Changed the config-file format. the server related parts starts with SERVER_ and the client related parts start with CLIENT_ * Made distmp3 also read the config-file. * distmp3 and distmp3host now takes command line options. * Commented the config-file * Fixed a bug in distmp3host, usin bladeenc without debug didn't work. 2000-03-19 Martin Josefsson * Changed the default mode of the fifos to 0600 * Now the fifos are removed upon exit * Removed some duplicate code from $SIG{INT} and $SIG{TERM} and put it in a common function. * Implemented a configfile * Fixed shutdown of the sockets. Maybe it's just my perl version that doesn't work as it should... (update: It was a kernelbug, it should be fixed in the newest versions) distmp3-0.1.9/distmp3host0100755000076500007640000001627207177544614015126 0ustar gandalfgandalf#!/usr/bin/perl # Distmp3, a program for distributing the encoding of music among several computers. # Copyright (C) 2000 Martin Josefsson # # 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. # # # Author: Martin Josefsson # use IO::Socket; use IO::Handle; use Net::hostent; $|=1; #---------------------------- $version = "0.1.9"; $config_file = "/etc/distmp3/distmp3.conf"; $RTR = "hejhopp_rtr"; $RTS = "hejhopp_rts"; $ACK = "hejhopp_ack"; $SRV_ID = "hejhopp_server_id"; $CLI_ID = "hejhopp_client_id"; #---------------------------- $SIG{INT} = sub { closedown("Caught INT signal, going down in flames..."); }; $SIG{TERM} = sub { closedown("Caught TERM signal, going up in smoke..."); }; sub parse_config_file { open(CONFIG,"<$_[0]") or die "Couldn't open config file $_[0]"; while ( ) { if ( !(/^\n/ || /^#/ || /^;/) ) { if ( /^SERVER_/ ) { chomp; ($config_option,$config_value) = split("=",$_,2); $config_option =~ s/SERVER_//; @config{$config_option} = $config_value; } } } close CONFIG; if ( @config{PROGRAM} ) { @config{PROGRAM} =~ s/\$mp3fifo/@config{MP3FIFO}/g; @config{PROGRAM} =~ s/\$wavfifo/@config{WAVFIFO}/g; @config{PROGRAM} =~ s/[\",\']//g; } } sub parse_command_line { $row = -1; LOOP: while ( ++$row <= @ARGV ) { if ( $ARGV[$row] eq "-h" || $ARGV[$row] eq "--help" ) { print_usage(); exit(0); } if ( $ARGV[$row] eq "-p" ) { ++$row; @config{PORT} = $ARGV[$row]; next LOOP; } if ( $ARGV[$row] eq "-s" ) { ++$row; @config{DATASIZE} = $ARGV[$row]; next LOOP; } if ( $ARGV[$row] eq "-d" ) { ++$row; if ( $ARGV[$row] == 1 ) { @config{DEBUG} = 1; } else { undef @config{DEBUG}; } next LOOP; } if ( $ARGV[$row] eq "-df" ) { ++$row; @config{DEBUGFILE} = $ARGV[$row]; next LOOP; } if ( $ARGV[$row] eq "-w" ) { ++$row; @config{WAVFIFO} = $ARGV[$row]; next LOOP; } if ( $ARGV[$row] eq "-m" ) { ++$row; @config{MP3FIFO} = $ARGV[$row]; next LOOP; } if ( $ARGV[$row] eq "-e" ) { ++$row; @config{PROGRAM} = $ARGV[$row]; @config{PROGRAM} =~ s/\$mp3fifo/@config{MP3FIFO}/g; @config{PROGRAM} =~ s/\$wavfifo/@config{WAVFIFO}/g; @config{PROGRAM} =~ s/[\",\']//g; next LOOP; } } } sub print_usage { print "Usage: $0 [-p port] [-s datasize] [-d debug] [-df debugfile] [-w wavfifo] [-m mp3fifo] [-e program]\n"; } sub open_local_connection { printd('Opening local Socket'); $local = IO::Socket::INET->new(Proto => "tcp", LocalPort => @config{PORT}, Listen => SOMAXCONN, Reuse => 1) or die "Can't bind port @config{PORT} on localhost: $!"; $local->autoflush(1); printd("Port @config{PORT} on localhost ready for connections"); } sub check_fifo { printd("creating mp3_fifo @config{MP3FIFO}"); unlink @config{MP3FIFO}; system('mknod', '-m 0600', @config{MP3FIFO}, 'p') && die "can't mknod @config{MP3FIFO}: $!"; printd("creating wav_fifo @config{WAVFIFO}"); unlink @config{WAVFIFO}; system('mknod', '-m 0600', @config{WAVFIFO}, 'p') && die "can't mknod @config{WAVFIFO}: $!"; } sub run_program { if ( @config{DEBUG} ) { $extra_param = "&"; } else { $extra_param = "&>/dev/null &"; } system "@config{PROGRAM} $extra_param"; if ( $? ne 0 ) { die "Couldn't run program @config{PROGRAM}"; } printd("Executed program @config{PROGRAM}"); } sub open_debug_file { open (DEBUG, ">>@config{DEBUGFILE}") or die "Couldn't open debug file @config{DEBUGFILE}"; } sub close_debug_file { close DEBUG; } sub open_wav_fifo { printd('opening wav-fifo'); open (WAV_FIFO, "> @config{WAVFIFO}") || die "Can't open fifo @config{WAVFIFO} for writing: $!"; WAV_FIFO->autoflush(1); } sub open_mp3_fifo { printd('opening mp3-fifo'); open (MP3_FIFO, "< @config{MP3FIFO}") || die "Can't open fifo @config{MP3FIFO} for reading: $!"; MP3_FIFO->autoflush(1); } sub close_wav_fifo { printd('closing wav-fifo'); close WAV_FIFO; } sub close_mp3_fifo { printd('closing mp3-fifo'); close MP3_FIFO; } sub send_data { $data = $_[0]; print $remote_client $data; } sub recieve_data { read $remote_client,$rdata,@config{DATASIZE}; return $rdata; } sub read_from_mp3 { read MP3_FIFO,$wdata,@config{DATASIZE}; return $wdata; } sub write_to_wav { $mdata = $_[0]; print WAV_FIFO $mdata; } sub handshake { printd('initiate handshake'); printd('waiting for CLI_ID'); read $remote_client,$answer,length($CLI_ID); printd('got CLI_ID'); if ( $answer ne $CLI_ID ) { $cli_error = 1; } if ( $cli_error eq 1 ) { printd("Client isn't who he should be"); $cli_error = 0; } else { $cli_error = 0; printd('Ok, Client id is what it should be'); send_data($SRV_ID); printd('Sent SRV_ID'); printd('Waiting for ACK'); read $remote_client,$answer,length($ACK); printd('got ACK'); if ( $answer ne $ACK ) { $ack_error = 1; } if ( $ack_error eq 1 ) { printd("Ack isn't Ack"); $ack_error = 0; } else { $ack_error = 0; printd('ACK ok'); return "1"; } } } sub printd { if ( @config{DEBUG} ) { $message = $_[0]; print "$message\n"; } if ( @config{DEBUGFILE} ) { $message = $_[0]; print DEBUG "$message\n"; } } sub closedown { if ( @config{DEBUG} || @config{DEBUGFILE} ) { printd("$_[0]\n"); } if ( @config{DEBUGFILE} ) { close DEBUG; } print "Exited gracefully...\n"; shutdown $local,2; close WAV_FIFO; close MP3_FIFO; unlink @config{MP3FIFO}; unlink @config{WAVFIFO}; exit(1); }; #Main program parse_config_file($config_file); parse_command_line(); if ( @config{DEBUGFILE} ) { open_debug_file(); } printd("Distmp3 daemon version $version"); check_fifo(); open_local_connection(); while ($remote_client = $local->accept()) { $remote_client->autoflush(1); if ( $hostinfo = gethostbyaddr($remote_client->peeraddr) ) { $remote_host = $hostinfo->name; } else { $remote_host = $remote_client->peerhost; } printd("Connect from $remote_host"); if ( handshake() ) { run_program(); printd('Forking like hell'); unless ($pid = fork) { printd('forking child for retrieving data from the client and sending it to the fifo'); send_data($RTR); printd('Sent RTR'); open_wav_fifo(); while ( $data2 = recieve_data() ) { write_to_wav($data2); } close_wav_fifo(); exit(0); } printd('entering code to read data from the fifo and sending it to the client'); send_data($RTS); printd('Sent RTS'); open_mp3_fifo(); while ( $data = read_from_mp3() ) { send_data($data); } close_mp3_fifo(); shutdown $remote_client,1; waitpid($pid,0); } printd("Connection from $remote_host terminated"); }