/* SliMP3 emulator - an emulator for the SliMP3 network MP3 player. Copyright (C) 2001 Jacob Potter 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. */ #include #include #include #include #include int server_sock, sf, id=0; struct sockaddr_in server_address; void get_next_chunk() { char message[] = "r__"; printf("Getting Chunk #%d...\n", id); message[1] = (id % (255 << 8)) >> 8; message[2] = id % 255; if (sendto(server_sock, message, sizeof(message), 0, (struct sockaddr*)&server_address, sizeof(server_address))<0) { perror("sendto()"); return; } id++; } int start_stream(int s_sock, struct sockaddr_in *s_addr) { printf(" --- --- RECIEVING MP3 STREAM TO SliMP3.mp3 --- ---\n"); server_sock = s_sock; server_address = *s_addr; id = 0; sf = open("/tmp/SliMP3.mp3", O_WRONLY | O_CREAT | O_APPEND ); if (sf == 0) { printf ("OPEN failed\n"); return 0; } else { get_next_chunk(); return 1; } } int stop_stream() { printf(" --- --- FINISHED MP3 STREAM --- ---\n"); close(sf); return 0; }