]> git.sesse.net Git - vlc/blob - python/vlrs/streamer.py
* modules/gui/skins2: ignore WM_PAINT events on the vout window
[vlc] / python / vlrs / streamer.py
1 #!/usr/bin/python -O
2 #
3 # VideoLAN RTSP Server
4 #
5 # Author: Cyril Deguet <asmax@via.ecp.fr>
6
7 import cfg, vlc
8
9
10 class VlcError(Exception):
11     "Exception class for libvlc calls"
12     pass
13
14
15
16 class VlcStreamer:
17     "Manage a streamer with libvlc"
18     
19     def __init__(self, file, address):
20         "Create the streamer"
21         self.file = file
22         self.address = address
23         self.id = vlc.create()
24         if self.id < 0:        
25             raise VlcError
26         if vlc.init(self.id, self.address) < 0:
27             raise VlcError
28         if vlc.addTarget(self.id, self.file) < 0:
29             raise VlcError
30             
31     def play(self):
32         "Play the stream"
33         if vlc.play(self.id) < 0:
34             raise VlcError
35             
36     def stop(self):
37         "Stop the stream"
38         if vlc.stop(self.id) < 0:
39             raise VlcError
40             
41     def pause(self):
42         "Pause the stream"
43         if vlc.pause(self.id) < 0:
44             raise VlcError
45
46