Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/python 2 # -*- coding: utf-8 -*- 3 # 4 # Copyright (C) 2006-2011 Guillaume Pellerin 5 6 # <yomguy@parisson.com> 7 8 # This software is a computer program whose purpose is to stream audio 9 # and video data through icecast2 servers. 10 11 # This software is governed by the CeCILL license under French law and 12 # abiding by the rules of distribution of free software. You can use, 13 # modify and/ or redistribute the software under the terms of the CeCILL 14 # license as circulated by CEA, CNRS and INRIA at the following URL 15 # "http://www.cecill.info". 16 17 # As a counterpart to the access to the source code and rights to copy, 18 # modify and redistribute granted by the license, users are provided only 19 # with a limited warranty and the software's author, the holder of the 20 # economic rights, and the successive licensors have only limited 21 # liability. 22 23 # In this respect, the user's attention is drawn to the risks associated 24 # with loading, using, modifying and/or developing or reproducing the 25 # software by the user in light of its specific status of free software, 26 # that may mean that it is complicated to manipulate, and that also 27 # therefore means that it is reserved for developers and experienced 28 # professionals having in-depth computer knowledge. Users are therefore 29 # encouraged to load and test the software's suitability as regards their 30 # requirements in conditions enabling the security of their systems and/or 31 # data to be ensured and, more generally, to use and operate it in the 32 # same conditions as regards security. 33 34 # The fact that you are presently reading this means that you have had 35 # knowledge of the CeCILL license and that you accept its terms. 36 37 # Author: Guillaume Pellerin <yomguy@parisson.com> 38 39 from relay import * 4042 """A file streaming iterator""" 4310345 self.main_buffer_size = 0x100000 46 self.relay_queue_size = 0x100000 47 self.sub_buffer_size = 0x1000048 5153 self.url = url 54 self.relay = Relay(self.sub_buffer_size, self.relay_queue_size) 55 self.relay.set_url(self.url) 56 self.relay.open() 57 self.relay.start() 58 self.queue = self.relay.queue59 6264 """Read media and stream data through a generator.""" 65 m = open(self.media, 'r') 66 while True: 67 __main_chunk = m.read(self.sub_buffer_size) 68 if not __main_chunk: 69 break 70 yield __main_chunk 71 m.close()7274 """Read a bigger part of the media and stream the little parts 75 of the data through a generator""" 76 m = open(self.media, 'r') 77 while True: 78 self.main_chunk = m.read(self.main_buffer_size) 79 if not self.main_chunk: 80 break 81 i = 0 82 while True: 83 start = i * self.sub_buffer_size 84 end = self.sub_buffer_size + (i * self.sub_buffer_size) 85 self.sub_chunk = self.main_chunk[start:end] 86 if not self.sub_chunk: 87 break 88 yield self.sub_chunk 89 i += 1 90 self.main_chunk = 0 91 self.sub_chunk = 0 92 m.close()93
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jul 15 13:14:17 2011 | http://epydoc.sourceforge.net |