From ffebdfb9c65fce3547fa58706673e0c75266ec63 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 7 Sep 2007 01:22:32 +0000 Subject: [PATCH] * First import --- AUTHORS | 10 + COPYING | 10 + INSTALL | 10 + README | 10 + d-fuzz.py | 175 ++++++ myfuzz.xml | 38 ++ old/d-fuzz.py | 73 +++ old/d-fuzz_loop.sh | 6 + old/d-fuzz_template.xml | 11 + old/d-fuzz_tools.py | 85 +++ old/xmltodict.py | 55 ++ shout-python/COPYING | 482 ++++++++++++++ shout-python/INSTALL | 11 + shout-python/MANIFEST | 7 + shout-python/README | 7 + .../build/lib.linux-i686-2.4/shout.so | Bin 0 -> 37718 bytes shout-python/example.py | 51 ++ shout-python/setup.py | 61 ++ shout-python/shout.c | 586 ++++++++++++++++++ tools.py | 73 +++ xmltodict.py | 48 ++ 21 files changed, 1809 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 INSTALL create mode 100644 README create mode 100755 d-fuzz.py create mode 100644 myfuzz.xml create mode 100755 old/d-fuzz.py create mode 100755 old/d-fuzz_loop.sh create mode 100644 old/d-fuzz_template.xml create mode 100755 old/d-fuzz_tools.py create mode 100644 old/xmltodict.py create mode 100644 shout-python/COPYING create mode 100644 shout-python/INSTALL create mode 100644 shout-python/MANIFEST create mode 100644 shout-python/README create mode 100755 shout-python/build/lib.linux-i686-2.4/shout.so create mode 100755 shout-python/example.py create mode 100644 shout-python/setup.py create mode 100644 shout-python/shout.c create mode 100755 tools.py create mode 100644 xmltodict.py diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..a3c9349 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2007-2007 Guillaume Pellerin +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/d-fuzz/DFuzzLicense. +# +# Author: Guillaume Pellerin \ No newline at end of file diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a3c9349 --- /dev/null +++ b/COPYING @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2007-2007 Guillaume Pellerin +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/d-fuzz/DFuzzLicense. +# +# Author: Guillaume Pellerin \ No newline at end of file diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..a3c9349 --- /dev/null +++ b/INSTALL @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2007-2007 Guillaume Pellerin +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/d-fuzz/DFuzzLicense. +# +# Author: Guillaume Pellerin \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..a3c9349 --- /dev/null +++ b/README @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2007-2007 Guillaume Pellerin +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/d-fuzz/DFuzzLicense. +# +# Author: Guillaume Pellerin \ No newline at end of file diff --git a/d-fuzz.py b/d-fuzz.py new file mode 100755 index 0000000..8dfac3e --- /dev/null +++ b/d-fuzz.py @@ -0,0 +1,175 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# Copyright (c) 2007-2007 Guillaume Pellerin +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/d-fuzz/DFuzzLicense. +# +# Author: Guillaume Pellerin + +import os +import sys +import shout +import string +from tools import * +from xmltodict import xmltodict +from mutagen.oggvorbis import OggVorbis + + +class DFuzz: + """A d-fuzz station""" + + def __init__(self, conf_file): + self.conf_file = conf_file + self.work_dir = os.environ['HOME']+'.d-fuzz' + self.conf = [] + + + def prog_info(self): + return """ + d-fuzz : easy and light streaming tool + + Copyright (c) 2007-2007 Guillaume Pellerin + All rights reserved. + + This software is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at http://svn.parisson.org/d-fuzz/DFuzzLicense.2 + + depends : ezstream (patched), icecast2, python, + + Usage : d-fuzz $1 + where $1 is the path for a config file + ex: d-fuzz /etc/d-fuzz/myfuzz.conf + + see http://parisson.com/d-fuzz/ for more details + """ + + def get_conf_dict(self): + conf = open(self.conf_file,'r') + conf_xml = conf.readlines() + self.conf = xmltodict(conf_xml) + + def get_station_names(self): + return self.conf['station']['name'] + + + + def check_work_dir(self): + if not os.isdir.exists(self.work_dir): + os.mkdir(self.work_dir) + + def get_playlist(self): + file_list = [] + for root, dirs, files in os.walk(self.media_dir): + for file in files: + file_list.append(root + os.sep + file) + return file_list + + + + for i in range(1,nb_ch+1): + ch_name_i = radio_name+'_'+type+'_'+str(i) + ch_ice_name_i = radio_name+'_'+str(i) + ch_pre_i = work_dir+os.sep+ch_name_i + fi_xml = open(ch_pre_i+'.xml','w') + fi_xml.write('\n') + +fi_xml.write('http://'+server+':'+port+'/'+ch_ice_name_i+'.'+type+'\ +n') + fi_xml.write(''+string.upper(type)+'\n') + fi_xml.write('script\n') + fi_xml.write(''+ch_pre_i+'.py\n') + for line in l_descr: + fi_xml.write(line) + fi_xml.write('') + fi_xml.close() + fi_py = open(ch_pre_i+'.py','w') + fi_py.write('#!/usr/bin/python\n\n') + fi_py.write('import sys, os, random\n\n') + fi_py.write('Playdir="'+audio_dir+os.sep+'"\n') + fi_py.write('IndexFile="'+ch_pre_i+'_index.txt"\n') + +fi_py.write('RandomIndexListFile="'+ch_pre_i+'_random_index_list.txt"\n') + +fi_py.write('PlaylistLengthOrigFile="'+ch_pre_i+'_playlist_length.txt"\n\n') + for line in l_tools: + fi_py.write(line) + fi_py.close() + os.chmod(work_dir+os.sep+ch_name_i+'.py',0755) + + def stream(self, media_dir): + """Looped stream of the media_dir""" + + + for station in conf_dict['station']: + + s = shout.Shout() + print "Using libshout version %s" % shout.version() + + s.host = self.server['host'] + s.port = self.server['port'] + s.user = 'source' + s.password = self.conf['sourcepassword'] + s.mount = self.mountpoint + s.format = self.conf['format'] + s.protocol = 'http' + # | 'xaudiocast' | 'icy' + s.name = self.conf['name'] + s.genre = self.conf['genre'] + # s.url = '' + # s.public = 0 | 1 + # s.audio_info = { 'key': 'val', ... } + # (keys are shout.SHOUT_AI_BITRATE, shout.SHOUT_AI_SAMPLERATE, + # shout.SHOUT_AI_CHANNELS, shout.SHOUT_AI_QUALITY) + + s.open() + + total = 0 + st = time.time() + for fa in sys.argv[1:]: + print "opening file %s" % fa + f = open(fa) + s.set_metadata({'song': fa}) + + nbuf = f.read(4096) + while 1: + buf = nbuf + nbuf = f.read(4096) + total = total + len(buf) + if len(buf) == 0: + break + s.send(buf) + s.sync() + f.close() + + et = time.time() + br = total*0.008/(et-st) + print "Sent %d bytes in %d seconds (%f kbps)" % (total, et-st, br) + + print s.close() + + #os.system('d-fuzz_loop '+ch_pre_i+' &') + print ch_pre_i+' started !' + + + +class Stream: + + def __init__(self): + self.buffer_size = 0xFFFF + + def process: + + if len(sys.argv) == 2: + station = DFuzz(sys.argv[1]) + sys.exit('') + + + # Processing (streaming + cache writing) + stream = self.core_process(self.command,self.buffer_size,self.dest) + for chunk in stream: + yield chunk diff --git a/myfuzz.xml b/myfuzz.xml new file mode 100644 index 0000000..5423f58 --- /dev/null +++ b/myfuzz.xml @@ -0,0 +1,38 @@ + + + + + + Cellar Playlist + + Cellar @ D-Fuzz, Paris (100% Mix Techno, House and Groove !) + + The Best Techno, House and Groove Stuff from Paris - 100% Mix ! + + http://cellar.parisson.com + Techno/House + + 2 + + + + localhost + 8000 + source2parisson + 1 + + + /home/momo/music/music3/mp3/Roger Troutman/ + + mp3 + 192 + 7 + 44100 + + 2 + + + + diff --git a/old/d-fuzz.py b/old/d-fuzz.py new file mode 100755 index 0000000..189796b --- /dev/null +++ b/old/d-fuzz.py @@ -0,0 +1,73 @@ +#!/usr/bin/python + +import sys, os, string + +if len(sys.argv) == 1: + print """ + dfuzz : easy and light streaming tool + + Copyright (c) 2006 Guillaume Pellerin + distributed under the terms of the GNU Public License v2 + + depends : ezstream (patched), icecast2, python, + + Usage : dfuzz $1 $2 $3 $4 $5 + where $1 : station name + $2 : type (mp3 or ogg) + $3 : number of sub-channels + $4 : working directory + $5 : audio directory + $6 : icecast2 server name + $7 : icecast2 port + """ + sys.exit('') + +radio_name = sys.argv[1] +nb_ch = int(sys.argv[3]) +type = sys.argv[2] +work_dir = sys.argv[4] +audio_dir = sys.argv[5] +server = sys.argv[6] +port = sys.argv[7] +radio_description_file = work_dir+os.sep+radio_name+'.xml' +dfuzz_dir = '/usr/local/share/d-fuzz' +ez_tools_file = dfuzz_dir+os.sep+'d-fuzz_tools.py' + +f_descr = open(radio_description_file,'r') +l_descr = f_descr.readlines() +f_descr.close() + +f_ez_tools = open(ez_tools_file,'r') +l_tools = f_ez_tools.readlines() +f_ez_tools.close() + +for i in range(1,nb_ch+1): + ch_name_i = radio_name+'_'+type+'_'+str(i) + ch_ice_name_i = radio_name+'_'+str(i) + ch_pre_i = work_dir+os.sep+ch_name_i + fi_xml = open(ch_pre_i+'.xml','w') + fi_xml.write('\n') + fi_xml.write('http://'+server+':'+port+'/'+ch_ice_name_i+'.'+type+'\n') + fi_xml.write(''+string.upper(type)+'\n') + fi_xml.write('script\n') + fi_xml.write(''+ch_pre_i+'.py\n') + for line in l_descr: + fi_xml.write(line) + fi_xml.write('') + fi_xml.close() + fi_py = open(ch_pre_i+'.py','w') + fi_py.write('#!/usr/bin/python\n\n') + fi_py.write('import sys, os, random\n\n') + fi_py.write('Playdir="'+audio_dir+os.sep+'"\n') + fi_py.write('IndexFile="'+ch_pre_i+'_index.txt"\n') + fi_py.write('RandomIndexListFile="'+ch_pre_i+'_random_index_list.txt"\n') + fi_py.write('PlaylistLengthOrigFile="'+ch_pre_i+'_playlist_length.txt"\n\n') + for line in l_tools: + fi_py.write(line) + fi_py.close() + os.chmod(work_dir+os.sep+ch_name_i+'.py',0755) + os.system('d-fuzz_loop '+ch_pre_i+' &') + sys.exit(ch_pre_i+' started !') + + + diff --git a/old/d-fuzz_loop.sh b/old/d-fuzz_loop.sh new file mode 100755 index 0000000..6c2feaf --- /dev/null +++ b/old/d-fuzz_loop.sh @@ -0,0 +1,6 @@ +#!/bin/sh +ulimit -c unlimited +while true; do +ezstream -c $1.xml > /dev/null; +sleep 3 +done diff --git a/old/d-fuzz_template.xml b/old/d-fuzz_template.xml new file mode 100644 index 0000000..a0dc5ca --- /dev/null +++ b/old/d-fuzz_template.xml @@ -0,0 +1,11 @@ +xxxxxxxxx +Your title here +Your URL here +Your genre here +Your station description here +You nominal bitrate here + + +The number of voices per channel +The samplerate +1 diff --git a/old/d-fuzz_tools.py b/old/d-fuzz_tools.py new file mode 100755 index 0000000..851942b --- /dev/null +++ b/old/d-fuzz_tools.py @@ -0,0 +1,85 @@ +#!/usr/bin/python + +#import sys, os, random + +#Playdir='/home/cellar/Cellar_playlist/' +#IndexFile='/home/cellar/stream/d-fuzz_1_index.txt' +#RandomIndexListFile='/home/cellar/stream/d-fuzz_1_random_index_list.txt' +#PlaylistLengthOrigFile='/home/cellar/stream/d-fuzz_1_playlist_length.txt' + +def randrange(start, stop): + values = range(start, stop) + random.shuffle(values) + while values: + yield values.pop() + raise StopIteration + +if not os.path.exists(IndexFile): + fi=open(IndexFile,'w') + fi.write("%d\n" % 0) + fi.close() +if not os.path.exists(RandomIndexListFile): + fil=open(RandomIndexListFile,'w') + fil.write("%d\n" % 0) + fil.close() +if not os.path.exists(PlaylistLengthOrigFile): + fill=open(PlaylistLengthOrigFile,'w') + fill.write("%d\n" % 0) + fill.close() + +playlist = os.listdir(Playdir) +nf = len(playlist) +#print nf + +fill=open(PlaylistLengthOrigFile,'rw') + +nforig=int(fill.readline()) + +if not nf == nforig: + fil=open(RandomIndexListFile,'w') + ril=randrange(0,nf) + #print ril + k=1 + for i in ril: + fil.write("%d\n" % (i)) +# fil.close() + +fi=open(IndexFile,'rw') +fil=open(RandomIndexListFile,'rw') + +#print nforig +if nforig < nf: + nforig = nf + +f_index=int(fi.readline()) + +#tmpil = fil.readlines() +f_index_list = range(nforig) +j = 0 +for i in fil.readlines(): + f_index_list[j] = int(i) + j+=1 + #print f_index_list[j] + +fi.close() +fil.close() +fill.close() + +if f_index == nf or f_index > nf: + f_index = 0 + +#print f_index_list[f_index] +#print f_index +print Playdir + playlist[f_index_list[f_index]] + +f_index+=1 + +fi = open(IndexFile,'w') +fi.write("%d" % (f_index)) +fi.close() + +fill=open(PlaylistLengthOrigFile,'w') +fill.write("%d" % (nf)) +fill.close() + + diff --git a/old/xmltodict.py b/old/xmltodict.py new file mode 100644 index 0000000..0d0fe44 --- /dev/null +++ b/old/xmltodict.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# Easily import simple XML data to Python dictionary +# http://www.gmta.info/publications/parsing-simple-xml-structure-to-a-python-dictionary + +import xml.dom.minidom + +def haschilds(dom): + + # Checks whether an element has any childs + # containing real tags opposed to just text. + + for childnode in dom.childNodes: + if childnode.nodeName != "#text" and childnode.nodeName != "#cdata-section": + return True + + return False + +def indexchilds(dom, enc): + + childsdict = dict() + + for childnode in dom.childNodes: + + name = childnode.nodeName.encode(enc) + + if name == "#text" or name == "#cdata-section": + # ignore whitespaces + continue + + if haschilds(childnode): + v = indexchilds(childnode, enc) + else: + v = childnode.childNodes[0].nodeValue.encode(enc) + + if name in childsdict: + + if isinstance(childsdict[name], dict): + # there is multiple instances of this node - convert to list + childsdict[name] = [childsdict[name]] + + childsdict[name].append(v) + + else: + + childsdict[name] = v + + return childsdict + +def xmltodict(data, enc=None): + + dom = xml.dom.minidom.parseString(data.strip()) + return indexchilds(dom, enc) + + diff --git a/shout-python/COPYING b/shout-python/COPYING new file mode 100644 index 0000000..bf50f20 --- /dev/null +++ b/shout-python/COPYING @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 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. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, 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 library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, 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 companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; 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. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/shout-python/INSTALL b/shout-python/INSTALL new file mode 100644 index 0000000..5e4f1b6 --- /dev/null +++ b/shout-python/INSTALL @@ -0,0 +1,11 @@ +Prerequisites +------------- + +You need to have libshout 2 installed. If you have pkg-config installed, +make sure it can find shout (you may need to adjust PKG_CONFIG_PATH to +contain $shout_prefix/lib/pkgcofig). Otherwise, shout-config must appear in +your path. + +Installation +------------ +run 'python setup.py install' \ No newline at end of file diff --git a/shout-python/MANIFEST b/shout-python/MANIFEST new file mode 100644 index 0000000..530e5e9 --- /dev/null +++ b/shout-python/MANIFEST @@ -0,0 +1,7 @@ +MANIFEST +README +INSTALL +COPYING +setup.py +shout.c +example.py diff --git a/shout-python/README b/shout-python/README new file mode 100644 index 0000000..399d78a --- /dev/null +++ b/shout-python/README @@ -0,0 +1,7 @@ +This is shout-python, a set of bindings for libshout 2. + +shout-python allows you to act as a source for icecast 1 and 2, and +shoutcast. This module includes inline documentation, or see +the included example.py for a demonstration of its usage. + +shout-python is licensed under the GNU LGPL. See COPYING for details. diff --git a/shout-python/build/lib.linux-i686-2.4/shout.so b/shout-python/build/lib.linux-i686-2.4/shout.so new file mode 100755 index 0000000000000000000000000000000000000000..e5c6ec0af7a2a9f8adb651f085756fa812bd33e0 GIT binary patch literal 37718 zcmeHwe_&MAmH&G)6J|&qM{~*08xIVBtf*c!z7s`qe*6*AN;DV z;D9xaaiP%KA6BWl)>?Jhib~aOQ7r1#wv?)Cch#j;+fcBDYOPys`F=j<-aGR$(004K z-~H$NeQ@X8bI-ZwoO|wh_ulv3eJ?jOEM8#Swq*{t<+g~$PqnOBfNy?MQD#{|%VSNo z$^diRine{aWib^H4Oog^jl51T_$}*2q!F6#0xSW|r1ya{k?ukI=v%1{fD;ZwuLtD{ zO>F_3jkFYLD$;VKDx?`mrywmsT7+~S(z!?j79Xa#K2`SUgW zC}5+`pA9%g=LuFI)gm<@%}1Jvv>3^GTn=QJE|{j_96-3v8n1DJGmz>WII|aNoNeb3 zL|Vwqf8!|r8|s#5UWA1;_RrKi>(7*%VuV2U7_D;^fR)+OT&5J+b8@KUM&UPrREBh> zlvvhW4KD?}5UB|1Vx-APHAtr;@wh|*>og6=Xn2{14Alup^E6(r;Uo?7!CD3k4!7kK z$n%AV+bR?|pTUU3Ef!hUsw}R&zJ;AGbnO)yAUIoTS-vc;JQc{|0ijEPBj>hM&%D4! z3x10AE5`{+?o0CUAG(EA&I|VCZxm|n0wnIs<1gn4i-W!-eL&Y=uklnK|1Fw-yQV*w zN54$ddHzsduckA$1=sS|YWx$L|8w9Yy;;+dm3X+B8GW$5<$3xJ>-wzA^zl4;o0j*q zrr(-JpT$85hiUI43YA~#J5}>D1}XoCS|1rm=U8G6;y*J8Ao1U8{riw-eU_Q{8jJWU z&(r@AEuZ5F`ES$sts1{e9wuk2k`8VkLH)=eS z=bt}ly5WBzkG>=izf9}rxl8%iYkeHYi9e`u_1iW8+klc&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zp)Iw+DA#)Rw_oyH z$c-C@1!1VNDg;$N8_$L-rFK(rn3W=3hpusayIGg2(9edEF_O&E@!9UJOJ?1E!tPrW zXX=m2V*osP z0l;xleF$2cDC0oRI>#tAY+rLk?upChrCie@i3IljhSIdJf>vq@aYA2hr!(G_Y6W20$H8q=c{x@>i5d87+Fe{e%S RR%A`?Z&`&LvoWT{{{sU)ySxAZ literal 0 HcmV?d00001 diff --git a/shout-python/example.py b/shout-python/example.py new file mode 100755 index 0000000..de4ce05 --- /dev/null +++ b/shout-python/example.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +# usage: ./example.py /path/to/file1 /path/to/file2 ... +import shout +import sys +import string +import time + +s = shout.Shout() +print "Using libshout version %s" % shout.version() + +# s.host = 'localhost' +# s.port = 8000 +# s.user = 'source' +s.password = 'hackme' +s.mount = "/pyshout" +# s.format = 'vorbis' | 'mp3' +# s.protocol = 'http' | 'xaudiocast' | 'icy' +# s.name = '' +# s.genre = '' +# s.url = '' +# s.public = 0 | 1 +# s.audio_info = { 'key': 'val', ... } +# (keys are shout.SHOUT_AI_BITRATE, shout.SHOUT_AI_SAMPLERATE, +# shout.SHOUT_AI_CHANNELS, shout.SHOUT_AI_QUALITY) + +s.open() + +total = 0 +st = time.time() +for fa in sys.argv[1:]: + print "opening file %s" % fa + f = open(fa) + s.set_metadata({'song': fa}) + + nbuf = f.read(4096) + while 1: + buf = nbuf + nbuf = f.read(4096) + total = total + len(buf) + if len(buf) == 0: + break + s.send(buf) + s.sync() + f.close() + + et = time.time() + br = total*0.008/(et-st) + print "Sent %d bytes in %d seconds (%f kbps)" % (total, et-st, br) + +print s.close() diff --git a/shout-python/setup.py b/shout-python/setup.py new file mode 100644 index 0000000..c33ff4c --- /dev/null +++ b/shout-python/setup.py @@ -0,0 +1,61 @@ +# distutils build script +# To install shout-python, run 'python setup.py install' + +from distutils.core import setup, Extension +import os +import sys + +ver = '0.2' + +# write default shout.pc path into environment if PKG_CONFIG_PATH is unset +if not os.environ.has_key('PKG_CONFIG_PATH'): + os.environ['PKG_CONFIG_PATH'] = '/usr/local/lib/pkgconfig' + +# Find shout compiler/linker flag via pkgconfig or shout-config +if os.system('pkg-config --exists shout 2> /dev/null') == 0: + pkgcfg = os.popen('pkg-config --cflags shout') + cflags = pkgcfg.readline().strip() + pkgcfg.close() + pkgcfg = os.popen('pkg-config --libs shout') + libs = pkgcfg.readline().strip() + pkgcfg.close() + +else: + if os.system('pkg-config --usage 2> /dev/null') == 0: + print "pkg-config could not find libshout: check PKG_CONFIG_PATH" + if os.system('shout-config 2> /dev/null') == 0: + scfg = os.popen('shout-config --cflags') + cflags = scfg.readline().strip() + scfg.close() + scfg = os.popen('shout-config --libs') + libs = scfg.readline().strip() + scfg.close() + + else: + print "pkg-config and shout-config unavailable, build terminated" + sys.exit(1) + +# there must be an easier way to set up these flags! +iflags = [x[2:] for x in cflags.split() if x[0:2] == '-I'] +extra_cflags = [x for x in cflags.split() if x[0:2] != '-I'] +libdirs = [x[2:] for x in libs.split() if x[0:2] == '-L'] +libsonly = [x[2:] for x in libs.split() if x[0:2] == '-l'] + +# include_dirs=[] +# libraries=[] +# runtime_library_dirs=[] +# extra_objects, extra_compile_args, extra_link_args +shout = Extension('shout', sources = ['shout.c'], + include_dirs = iflags, + extra_compile_args = extra_cflags, + library_dirs = libdirs, + libraries = libsonly) + +# data_files = [] +setup (name = 'shout-python', + version = ver, + description = 'Bindings for libshout 2', + url = 'http://icecast.org/download.php', + author = 'Brendan Cully', + author_email = 'brendan@xiph.org', + ext_modules = [shout]) diff --git a/shout-python/shout.c b/shout-python/shout.c new file mode 100644 index 0000000..729f211 --- /dev/null +++ b/shout-python/shout.c @@ -0,0 +1,586 @@ +/* shout.c: python bindings to libshout + * Copyright (c) 2003,5 Brendan Cully + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307 USA. + * + * $Id: shout.c 8919 2005-02-14 19:48:33Z brendan $ + */ + +#include +#include + +static PyObject* ShoutError; + +typedef struct { + PyObject_HEAD + shout_t* conn; + PyObject* attr; +} ShoutObject; + +typedef int(*pshout_set_shout)(shout_t*); +typedef int(*pshout_set_shout_int)(shout_t*, int); +typedef int(*pshout_set_shout_str)(shout_t*, const char*); + +typedef struct _ShoutObjectAttr { + const char* name; + pshout_set_shout set_shout; + int(*set)(struct _ShoutObjectAttr*, ShoutObject*, PyObject*); +} ShoutObjectAttr; + +typedef struct { + const char* name; + int val; +} kv_strint; + +/* -- module prototypes -- */ +static PyObject* pshout_version(PyObject* self, PyObject* args); + +/* -- ShoutObject instance prototypes -- */ +static PyObject* pshoutobj_new(PyObject* self, PyObject* args); +static void pshoutobj_initattrs(PyObject* self); +static void pshoutobj_free(PyObject* self); +static PyObject* pshoutobj_getattr(PyObject* self, char* name); +static int pshoutobj_setattr(PyObject* self, char* name, PyObject* v); + +static PyObject* pshoutobj_open(ShoutObject* self); +static PyObject* pshoutobj_close(ShoutObject* self); +static PyObject* pshoutobj_send(ShoutObject* self, PyObject* args); +static PyObject* pshoutobj_sync(ShoutObject* self); +static PyObject* pshoutobj_delay(ShoutObject* self); +static PyObject* pshoutobj_queuelen(ShoutObject* self); +static PyObject* pshoutobj_set_metadata(ShoutObject* self, PyObject* args); + +/* -- attr prototypes -- */ +static int pshoutobj_set_str(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v); +static int pshoutobj_set_int(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v); +static int pshoutobj_set_bool(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v); +static int pshoutobj_set_proto(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v); +static int pshoutobj_set_fmt(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v); +static int pshoutobj_set_audio_info(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v); + +static char docstring[] = "Shout library v2 interface\n\n" + "Use this module to send audio data to an icecast (or shoutcast) server\n" + "shout.Shout() creates a new Shout object.\n\n" + + "Shout\n\n" + "Use this object to send data to an icecast server.\n" + "Set the connection attributes before calling \"open\" (at least\n" + "\"host\", \"port\", \"password\" and \"mount\" must be specified).\n\n" + "Methods:\n" + " open() - connect to server\n" + " close() - disconnect from server\n" + " send(data) - send audio data to server\n" + " sync() - sleep until server needs more data. This is equal to\n" + " the time it takes to play data sent since last sync\n" + " delay() - return milliseconds to wait before sending more data\n" + " queuelen() - return number of bytes on the nonblocking write queue\n" + "set_metadata(dict) - update stream metadata on server (current known key is\n" + " \"song\". Not currently supported for ogg.\n\n" + "Attributes:\n" + " host - name or address of destination server\n" + " port - port of destination server\n" + " user - source user name (optional)\n" + " password - source password\n" + " mount - mount point on server (relative URL, eg \"/stream.ogg\")\n" + " protocol - server protocol: \"http\" (the default) for icecast 2,\n" + " \"xaudiocast\" for icecast 1, or \"icy\" for shoutcast\n" + "nonblocking - use nonblocking send\n" + " format - audio format: \"ogg\" (the default) or \"mp3\"\n" + " name - stream name\n" + " url - stream web page\n" + " genre - stream genre\n" + "description - longer stream description\n" + " audio_info - dictionary of stream audio parameters, for YP information.\n" + " Useful keys include \"bitrate\" (in kbps), \"samplerate\"\n" + " (in Hz), \"channels\" and \"quality\" (Ogg encoding\n" + " quality). All dictionary values should be strings. The known\n" + " keys are defined as the SHOUT_AI_* constants, but any other\n" + " will be passed along to the server as well.\n" + " dumpfile - file name to record stream to on server (not supported on\n" + " all servers)\n" + " agent - for customizing the HTTP user-agent header\n\n"; + +static PyTypeObject ShoutObject_Type = { + PyObject_HEAD_INIT(NULL) + 0, + "shout.Shout", + sizeof(ShoutObject), + 0, + pshoutobj_free, /* tp_dealloc */ + 0, /* tp_print */ + pshoutobj_getattr, + pshoutobj_setattr, + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + "See shout module help: help(shout)\n" +}; + +static PyMethodDef ShoutMethods[] = { + { "version", pshout_version, METH_VARARGS, + "Return the version of libshout being used, as a string." }, + { "Shout", pshoutobj_new, METH_VARARGS, + "Create a new Shout object." }, + { NULL, NULL, 0, NULL } +}; + +static ShoutObjectAttr ShoutObjectAttrs[] = { + { "host", (pshout_set_shout)shout_set_host, pshoutobj_set_str }, + { "port", (pshout_set_shout)shout_set_port, pshoutobj_set_int }, + { "user", (pshout_set_shout)shout_set_user, pshoutobj_set_str }, + { "password", (pshout_set_shout)shout_set_password, pshoutobj_set_str }, + { "agent", (pshout_set_shout)shout_set_agent, pshoutobj_set_str }, + { "format", (pshout_set_shout)shout_set_format, pshoutobj_set_fmt }, + { "protocol", (pshout_set_shout)shout_set_protocol, pshoutobj_set_proto }, + { "nonblocking", (pshout_set_shout)shout_set_nonblocking, pshoutobj_set_bool }, + { "mount", (pshout_set_shout)shout_set_mount, pshoutobj_set_str }, + { "name", (pshout_set_shout)shout_set_name, pshoutobj_set_str }, + { "url", (pshout_set_shout)shout_set_url, pshoutobj_set_str }, + { "genre", (pshout_set_shout)shout_set_genre, pshoutobj_set_str }, + { "description", (pshout_set_shout)shout_set_description, pshoutobj_set_str }, + { "public", (pshout_set_shout)shout_set_public, pshoutobj_set_int }, + { "dumpfile", (pshout_set_shout)shout_set_dumpfile, pshoutobj_set_str }, + { "audio_info", NULL, pshoutobj_set_audio_info }, + { NULL, NULL, NULL } +}; + +static kv_strint ShoutProtocolMap[] = { + { "http", SHOUT_PROTOCOL_HTTP }, + { "xaudiocast", SHOUT_PROTOCOL_XAUDIOCAST }, + { "icy", SHOUT_PROTOCOL_ICY }, + { NULL, 0 } +}; + +static kv_strint ShoutFormatMap[] = { + { "ogg", SHOUT_FORMAT_OGG }, + { "mp3", SHOUT_FORMAT_MP3 }, + { "vorbis", SHOUT_FORMAT_OGG }, /* for backwards compatability */ + { NULL, 0 } +}; + +static PyMethodDef ShoutObjectMethods[] = { + { "open", (PyCFunction)pshoutobj_open, METH_NOARGS, + "Connect to server." }, + { "close", (PyCFunction)pshoutobj_close, METH_NOARGS, + "Close connection to server." }, + { "send", (PyCFunction)pshoutobj_send, METH_VARARGS, + "Send audio data to server." }, + { "sync", (PyCFunction)pshoutobj_sync, METH_NOARGS, + "Sleep for time required to play previously sent audio data." }, + { "delay", (PyCFunction)pshoutobj_delay, METH_NOARGS, + "Return amount of time in milliseconds to wait before sending more data." }, + { "queuelen", (PyCFunction)pshoutobj_queuelen, METH_NOARGS, + "Return the number of bytes currently on the write queue for nonblocking send" }, + { "set_metadata", (PyCFunction)pshoutobj_set_metadata, METH_VARARGS, + "Update stream metadata on server (takes a dictionary argument. Current keys are: \"song\"" }, + + /* attributes (cribbed from Arc's ogg-python technique) */ + { "host", NULL, 0, NULL }, + { "port", NULL, 0, NULL }, + { "user", NULL, 0, NULL }, + { "password", NULL, 0, NULL }, + { "agent", NULL, 0, NULL }, + { "format", NULL, 0, NULL }, + { "protocol", NULL, 0, NULL }, + { "nonblocking", NULL, 0, NULL }, + { "mount", NULL, 0, NULL }, + { "name", NULL, 0, NULL }, + { "url", NULL, 0, NULL }, + { "genre", NULL, 0, NULL }, + { "description", NULL, 0, NULL }, + { "public", NULL, 0, NULL }, + { "dumpfile", NULL, 0, NULL }, + { "audio_info", NULL, 0, NULL }, + + /* sentinel */ + { NULL, NULL, 0, NULL } +}; + +void initshout(void) { + PyObject* mod; + PyObject* dict; + + ShoutObject_Type.ob_type = &PyType_Type; + + mod = Py_InitModule3("shout", ShoutMethods, docstring); + dict = PyModule_GetDict(mod); + ShoutError = PyErr_NewException("shout.ShoutException", NULL, NULL); + PyDict_SetItemString(dict, "ShoutException", ShoutError); + + PyModule_AddIntConstant(mod, "SHOUTERR_SUCCESS", SHOUTERR_SUCCESS); + PyModule_AddIntConstant(mod, "SHOUTERR_INSANE", SHOUTERR_INSANE); + PyModule_AddIntConstant(mod, "SHOUTERR_NOCONNECT", SHOUTERR_NOCONNECT); + PyModule_AddIntConstant(mod, "SHOUTERR_NOLOGIN", SHOUTERR_NOLOGIN); + PyModule_AddIntConstant(mod, "SHOUTERR_SOCKET", SHOUTERR_SOCKET); + PyModule_AddIntConstant(mod, "SHOUTERR_MALLOC", SHOUTERR_MALLOC); + PyModule_AddIntConstant(mod, "SHOUTERR_METADATA", SHOUTERR_METADATA); + PyModule_AddIntConstant(mod, "SHOUTERR_CONNECTED", SHOUTERR_CONNECTED); + PyModule_AddIntConstant(mod, "SHOUTERR_UNCONNECTED", SHOUTERR_UNCONNECTED); + PyModule_AddIntConstant(mod, "SHOUTERR_UNSUPPORTED", SHOUTERR_UNSUPPORTED); + PyModule_AddIntConstant(mod, "SHOUTERR_BUSY", SHOUTERR_BUSY); + + PyModule_AddStringConstant(mod, "SHOUT_AI_BITRATE", SHOUT_AI_BITRATE); + PyModule_AddStringConstant(mod, "SHOUT_AI_SAMPLERATE", SHOUT_AI_SAMPLERATE); + PyModule_AddStringConstant(mod, "SHOUT_AI_CHANNELS", SHOUT_AI_CHANNELS); + PyModule_AddStringConstant(mod, "SHOUT_AI_QUALITY", SHOUT_AI_QUALITY); +} + +/* -- shout module methods -- */ + +static PyObject* pshout_version(PyObject* self, PyObject* args) { + if (!PyArg_ParseTuple(args, "")) + return NULL; + + return Py_BuildValue("s", shout_version(NULL, NULL, NULL)); +} + +/* -- ShoutObject instance methods -- */ + +static PyObject* pshoutobj_new(PyObject* self, PyObject* args) { + ShoutObject* me; + + if (!PyArg_ParseTuple(args, "")) + return NULL; + + if (!(me = PyObject_New(ShoutObject, &ShoutObject_Type))) + return NULL; + + me->attr = NULL; + + if (!(me->conn = shout_new())) { + PyErr_NoMemory(); + PyObject_Del(self); + + return NULL; + } + + return (PyObject*)me; +} + +static void pshoutobj_free(PyObject* self) { + ShoutObject* me = (ShoutObject*)self; + + Py_XDECREF(me->attr); + shout_free(me->conn); + PyObject_Del(self); +} + +static void pshoutobj_initattrs(PyObject* self) { + shout_t* conn = ((ShoutObject*)self)->conn; + int val, i; + + pshoutobj_setattr(self, "host", Py_BuildValue("s", shout_get_host(conn))); + pshoutobj_setattr(self, "port", Py_BuildValue("i", shout_get_port(conn))); + pshoutobj_setattr(self, "user", Py_BuildValue("s", shout_get_user(conn))); + pshoutobj_setattr(self, "password", Py_BuildValue("")); + pshoutobj_setattr(self, "mount", Py_BuildValue("")); + pshoutobj_setattr(self, "name", Py_BuildValue("")); + pshoutobj_setattr(self, "url", Py_BuildValue("")); + pshoutobj_setattr(self, "genre", Py_BuildValue("")); + pshoutobj_setattr(self, "description", Py_BuildValue("")); + pshoutobj_setattr(self, "audio_info", Py_BuildValue("")); + pshoutobj_setattr(self, "dumpfile", Py_BuildValue("")); + pshoutobj_setattr(self, "agent", Py_BuildValue("s", shout_get_agent(conn))); + pshoutobj_setattr(self, "protocol", Py_BuildValue("")); + pshoutobj_setattr(self, "nonblocking", shout_get_nonblocking(conn) ? Py_True : Py_False); + pshoutobj_setattr(self, "format", Py_BuildValue("")); + + val = shout_get_protocol(conn); + for (i = 0; ShoutProtocolMap[i].name; i++) + if (ShoutProtocolMap[i].val == val) { + pshoutobj_setattr(self, "protocol", Py_BuildValue("s", ShoutProtocolMap[i].name)); + break; + } + + val = shout_get_format(conn); + for (i = 0; ShoutFormatMap[i].name; i++) + if (ShoutFormatMap[i].val == val) { + pshoutobj_setattr(self, "format", Py_BuildValue("s", ShoutFormatMap[i].name)); + break; + } +} + +static PyObject* pshoutobj_getattr(PyObject* self, char* name) { + ShoutObject* me = (ShoutObject*)self; + + if (!me->attr) + pshoutobj_initattrs(self); + + if (me->attr) { + PyObject* v = PyDict_GetItemString(me->attr, name); + if (v) { + Py_INCREF(v); + return v; + } + } + return Py_FindMethod(ShoutObjectMethods, self, name); +} + +static int pshoutobj_setattr(PyObject* self, char* name, PyObject* v) { + ShoutObject* me = (ShoutObject*)self; + ShoutObjectAttr* attr; + + if (!me->attr && !(me->attr = PyDict_New())) + return -1; + + if (v == NULL) + return -1; + + for (attr = ShoutObjectAttrs; attr->name; attr++) { + if (!strcmp(attr->name, name)) { + if (v != Py_None && attr->set(attr, me, v) != SHOUTERR_SUCCESS) { + if (!PyErr_Occurred()) + PyErr_SetString(ShoutError, shout_get_error(me->conn)); + return -1; + } + break; + } + } + + return PyDict_SetItemString(me->attr, name, v); +} + +static PyObject* pshoutobj_open(ShoutObject* self) { + if (shout_open(self->conn) != SHOUTERR_SUCCESS) { + PyErr_SetString(ShoutError, shout_get_error(self->conn)); + + return NULL; + } + + return Py_BuildValue("i", 1); +} + +static PyObject* pshoutobj_close(ShoutObject* self) { + if (shout_close(self->conn) != SHOUTERR_SUCCESS) { + PyErr_SetString(ShoutError, shout_get_error(self->conn)); + + return NULL; + } + + return Py_BuildValue("i", 1); +} + +static PyObject* pshoutobj_send(ShoutObject* self, PyObject* args) { + const unsigned char* data; + size_t len; + + if (!PyArg_ParseTuple(args, "s#", &data, &len)) + return NULL; + + if (shout_send(self->conn, data, len) != SHOUTERR_SUCCESS) { + PyErr_SetString(ShoutError, shout_get_error(self->conn)); + + return NULL; + } + + return Py_BuildValue("i", 1); +} + +static PyObject* pshoutobj_sync(ShoutObject* self) { + shout_sync(self->conn); + + return Py_BuildValue("i", 1); +} + +static PyObject* pshoutobj_delay(ShoutObject* self) { + return Py_BuildValue("i", shout_delay(self->conn)); +} + +static PyObject* pshoutobj_queuelen(ShoutObject* self) { + return Py_BuildValue("i", shout_queuelen(self->conn)); +} + +static PyObject* pshoutobj_set_metadata(ShoutObject* self, PyObject* args) { + shout_metadata_t* metadata; + PyObject* dict; + PyObject* key; + PyObject* val; + const char* skey; + const char* sval; + int i = 0; + int rc; + + if (!(metadata = shout_metadata_new())) { + PyErr_NoMemory(); + return NULL; + } + + if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict)) + return NULL; + + while (PyDict_Next(dict, &i, &key, &val)) { + if (!PyString_Check(key)) { + PyErr_SetString(PyExc_TypeError, "Dictionary key must be string"); + shout_metadata_free(metadata); + return NULL; + } + if (!PyString_Check(val)) { + PyErr_SetString(PyExc_TypeError, "Dictionary value must be string"); + shout_metadata_free(metadata); + return NULL; + } + + skey = PyString_AsString(key); + sval = PyString_AsString(val); + + if ((rc = shout_metadata_add(metadata, skey, sval)) != SHOUTERR_SUCCESS) { + if (rc == SHOUTERR_MALLOC) + PyErr_NoMemory(); + else if (rc == SHOUTERR_INSANE) + PyErr_SetString(PyExc_TypeError, "Dictionary key must not be empty"); + shout_metadata_free(metadata); + return NULL; + } + } + + rc = shout_set_metadata(self->conn, metadata); + shout_metadata_free(metadata); + + if (rc != SHOUTERR_SUCCESS) { + PyErr_SetString(ShoutError, "Metadata not supported in this connection"); + return NULL; + } + + return Py_BuildValue("i", 1); +} + +static int pshoutobj_set_str(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { + const char* str; + pshout_set_shout_str set_shout; + + if (!PyString_Check(v)) { + PyErr_SetString(PyExc_TypeError, "String argument required"); + return -1; + } + + str = PyString_AsString(v); + set_shout = (pshout_set_shout_str)attr->set_shout; + return set_shout(self->conn, str); +} + +static int pshoutobj_set_int(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { + long val; + pshout_set_shout_int set_shout; + + if (!PyInt_Check(v)) { + PyErr_SetString(PyExc_TypeError, "Numerical argument required"); + return -1; + } + + val = PyLong_AsLong(v); + set_shout = (pshout_set_shout_int)attr->set_shout; + return set_shout(self->conn, val); +} + +static int pshoutobj_set_bool(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { + long val; + pshout_set_shout_int set_shout; + + if (!PyBool_Check(v)) { + PyErr_SetString(PyExc_TypeError, "Boolean argument required"); + return -1; + } + + val = (v == Py_True) ? 1 : 0; + set_shout = (pshout_set_shout_int)attr->set_shout; + return set_shout(self->conn, val); +} + +static int pshoutobj_set_fmt(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { + const char* val; + kv_strint* fmt_map; + pshout_set_shout_int set_shout; + + if (!PyString_Check(v)) { + PyErr_SetString(PyExc_TypeError, "String argument required"); + return SHOUTERR_INSANE; + } + + val = PyString_AsString(v); + for (fmt_map = ShoutFormatMap; fmt_map->name; fmt_map++) { + if (!strcmp(fmt_map->name, val)) { + set_shout = (pshout_set_shout_int)attr->set_shout; + return set_shout(self->conn, fmt_map->val); + } + } + + PyErr_SetString(ShoutError, "Unsupported format"); + return SHOUTERR_UNSUPPORTED; +} + +static int pshoutobj_set_proto(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { + const char* val; + kv_strint* proto_map; + pshout_set_shout_int set_shout; + + if (!PyString_Check(v)) { + PyErr_SetString(PyExc_TypeError, "String argument required"); + return SHOUTERR_INSANE; + } + + val = PyString_AsString(v); + for (proto_map = ShoutProtocolMap; proto_map->name; proto_map++) { + if (!strcmp(proto_map->name, val)) { + set_shout = (pshout_set_shout_int)attr->set_shout; + return set_shout(self->conn, proto_map->val); + } + } + + PyErr_SetString(ShoutError, "Unsupported protocol"); + return SHOUTERR_UNSUPPORTED; +} + +static int pshoutobj_set_audio_info(ShoutObjectAttr* attr, ShoutObject* self, PyObject* v) { + PyObject* key; + PyObject* val; + const char* skey; + const char* sval; + int i = 0; + int rc; + + if (!PyDict_Check(v)) { + PyErr_SetString(PyExc_TypeError, "Dictionary argument required"); + return SHOUTERR_INSANE; + } + + while (PyDict_Next(v, &i, &key, &val)) { + if (!PyString_Check(key)) { + PyErr_SetString(PyExc_TypeError, "Dictionary key must be string"); + return SHOUTERR_INSANE; + } + if (!PyString_Check(val)) { + PyErr_SetString(PyExc_TypeError, "Dictionary value must be string"); + return SHOUTERR_INSANE; + } + + skey = PyString_AsString(key); + sval = PyString_AsString(val); + + if ((rc = shout_set_audio_info(self->conn, skey, sval)) != SHOUTERR_SUCCESS) + return rc; + } + + return SHOUTERR_SUCCESS; +} diff --git a/tools.py b/tools.py new file mode 100755 index 0000000..cbe821b --- /dev/null +++ b/tools.py @@ -0,0 +1,73 @@ +#!/usr/bin/python + +import sys, os, random + +#Playdir='/home/cellar/Cellar_playlist/' +#IndexFile='/home/cellar/stream/d-fuzz_1_index.txt' +#RandomIndexListFile='/home/cellar/stream/d-fuzz_1_random_index_list.txt' +#PlaylistLengthOrigFile='/home/cellar/stream/d-fuzz_1_playlist_length.txt' + +def randrange(start, stop): + values = range(start, stop) + random.shuffle(values) + while values: + yield values.pop() + raise StopIteration + + + + +#print nf + +fill=open(PlaylistLengthOrigFile,'rw') + +nforig=int(fill.readline()) + +if not nf == nforig: + fil=open(RandomIndexListFile,'w') + ril=randrange(0,nf) + #print ril + k=1 + for i in ril: + fil.write("%d\n" % (i)) +# fil.close() + +fi=open(IndexFile,'rw') +fil=open(RandomIndexListFile,'rw') + +#print nforig +if nforig < nf: + nforig = nf + +f_index=int(fi.readline()) + +#tmpil = fil.readlines() +f_index_list = range(nforig) +j = 0 +for i in fil.readlines(): + f_index_list[j] = int(i) + j+=1 + #print f_index_list[j] + +fi.close() +fil.close() +fill.close() + +if f_index == nf or f_index > nf: + f_index = 0 + +#print f_index_list[f_index] +#print f_index +print Playdir + playlist[f_index_list[f_index]] + +f_index+=1 + +fi = open(IndexFile,'w') +fi.write("%d" % (f_index)) +fi.close() + +fill=open(PlaylistLengthOrigFile,'w') +fill.write("%d" % (nf)) +fill.close() + + diff --git a/xmltodict.py b/xmltodict.py new file mode 100644 index 0000000..e9a2f3f --- /dev/null +++ b/xmltodict.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +# Easily import simple XML data to Python dictionary +# http://www.gmta.info/publications/parsing-simple-xml-structure-to-a-python-dictionary + +import xml.dom.minidom + +def haschilds(dom): + + # Checks whether an element has any childs + # containing real tags opposed to just text. + + for childnode in dom.childNodes: + if childnode.nodeName != "#text" and \ + childnode.nodeName != "#cdata-section": + return True + + return False + +def indexchilds(dom, enc): + childsdict = dict() + + for childnode in dom.childNodes: + name = childnode.nodeName.encode(enc) + if name == "#text" or name == "#cdata-section": + # ignore whitespaces + continue + + if haschilds(childnode): + v = indexchilds(childnode, enc) + else: + v = childnode.childNodes[0].nodeValue.encode(enc) + + if name in childsdict: + if isinstance(childsdict[name], dict): + # there is multiple instances of this node - convert to list + childsdict[name] = [childsdict[name]] + childsdict[name].append(v) + else: + childsdict[name] = v + + return childsdict + +def xmltodict(data, enc=None): + dom = xml.dom.minidom.parseString(data.strip()) + return indexchilds(dom, enc) + + -- 2.39.5