summaryrefslogtreecommitdiff
path: root/tasks/vlc_stream_rtp
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-24 21:05:27 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-24 21:05:27 +0100
commit8081a5520a441b43a8a7a73f3a90c7aacfaa8e10 (patch)
treec7f49bd33ed19d53afc0ee9df8b2c82c200c5910 /tasks/vlc_stream_rtp
parent9963b74f777edf985540eac71b1ca095f88b8bca (diff)
Move everything one level up
Diffstat (limited to 'tasks/vlc_stream_rtp')
-rw-r--r--tasks/vlc_stream_rtp/howtos/en/index.html94
-rw-r--r--tasks/vlc_stream_rtp/howtos/images/1.pngbin0 -> 8681 bytes
-rw-r--r--tasks/vlc_stream_rtp/howtos/images/playlist.PNGbin0 -> 48064 bytes
-rw-r--r--tasks/vlc_stream_rtp/howtos/images/stream_finish.PNGbin0 -> 57437 bytes
-rw-r--r--tasks/vlc_stream_rtp/howtos/images/stream_menu.pngbin0 -> 80030 bytes
-rw-r--r--tasks/vlc_stream_rtp/howtos/images/stream_open.PNGbin0 -> 62759 bytes
-rw-r--r--tasks/vlc_stream_rtp/howtos/images/stream_output.PNGbin0 -> 53770 bytes
-rw-r--r--tasks/vlc_stream_rtp/howtos/images/stream_transcoding.PNGbin0 -> 88906 bytes
-rw-r--r--tasks/vlc_stream_rtp/howtos/si/index.html93
-rw-r--r--tasks/vlc_stream_rtp/task.py110
10 files changed, 297 insertions, 0 deletions
diff --git a/tasks/vlc_stream_rtp/howtos/en/index.html b/tasks/vlc_stream_rtp/howtos/en/index.html
new file mode 100644
index 0000000..c9e2714
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/en/index.html
@@ -0,0 +1,94 @@
+<html>
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=utf-8">
+</head>
+
+
+<body><font face="Georgia, Times New Roman, Times, serif">
+
+<h2> Summary </h1>
+
+<ol>
+ <li>Set up a virtual machine</li>
+ <li>Install VLC</li>
+ <li>Create RTP video stream</li>
+ <li>Make sure the stream is accessible from the internet</li>
+</ol>
+
+ <h2>Instructions</h1>
+
+ <ol>
+ <li>
+ <h4>Set up a virtual machine </h3>
+ <p> Use disk simpleArbiter. You can get it <a href="http://polz.si/media/uploads/kpov/virtualke/">here</a>. </p>
+ </li>
+
+ <li>
+ <h4>Install VLC</h3>
+ <p>
+ In file <code>/etc/apt/sources.list</code> replace <code>wheezy</code> with
+ <code>testing</code> or if missing, add rows:
+ </p>
+ <p>
+ <code>
+ deb http://ftp.at.debian.org/debian wheezy main contrib non-free <br>
+ deb-src http://ftp.at.debian.org/debian wheezy main contrib non-free
+ </code>
+ </p>
+ <img alt="slika-01" src="../images/1.png" style="width: 640px;" />
+ <p>
+ Check for updates and install VLC with the following commands:
+ </p>
+ <p>
+ <code>
+ apt-get update <br>
+ apt-get install vlc
+ </code>
+ </p>
+ </li>
+
+ <li>
+ <h4>Create a new stream </h3>
+
+ <p>
+ Open VLC. In Media menu select Stream.
+ </p>
+ <img src="../images/stream_menu.png" style="width: 640px;" alt="menu">
+ <p>
+ Here we choose stream source. This can be a file, a network stream or a capture device. <br>
+ For this excercise, add one or more video file by clicking <i>Add ...</i> Continue with a click on button Stream.
+ </p>
+ <img src="../images/playlist.PNG" style="width: 640px;" alt="stream source">
+ <p>
+ We must also choose the stream destination. For this excercise, choose RTP/MPEG Transport Stream and click Add.
+ You can configure multiple destinations simultaneously.
+ </p>
+ <p>
+ Configure destination settings. Enter address and stream name.
+ </p>
+ <img src="../images/stream_output.PNG" style="width: 640px;" alt="stream destination">
+ <p>
+ Next, we can set transcoding, encapsulation, audio and video codecs and also subtitles. When you finish, click Save and Next.
+ </p>
+ <img src="../images/stream_transcoding.PNG" style="width: 640px;" alt="stream settings">
+ <p>
+ In the last step, it is important to check option Stream all elementary streams.
+ In the text area, we can see the string that can be used to run the stream from a command line.
+ This is useful if you want to run stream from a computer without graphic interface.
+ </p>
+ <img src="../images/stream_finish.PNG" style="width: 640px;">
+ </li>
+
+ <li>
+ <h4>Open stream </h3>
+ <p>
+ We can now play the stream from another device using VLC.
+ </p>
+ <img src="../images/stream_open.PNG" style="width: 640px;" alt="play stream">
+ </li>
+</ol>
+
+</body>
+
+</html> \ No newline at end of file
diff --git a/tasks/vlc_stream_rtp/howtos/images/1.png b/tasks/vlc_stream_rtp/howtos/images/1.png
new file mode 100644
index 0000000..903be70
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/images/1.png
Binary files differ
diff --git a/tasks/vlc_stream_rtp/howtos/images/playlist.PNG b/tasks/vlc_stream_rtp/howtos/images/playlist.PNG
new file mode 100644
index 0000000..b815098
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/images/playlist.PNG
Binary files differ
diff --git a/tasks/vlc_stream_rtp/howtos/images/stream_finish.PNG b/tasks/vlc_stream_rtp/howtos/images/stream_finish.PNG
new file mode 100644
index 0000000..f429a9b
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/images/stream_finish.PNG
Binary files differ
diff --git a/tasks/vlc_stream_rtp/howtos/images/stream_menu.png b/tasks/vlc_stream_rtp/howtos/images/stream_menu.png
new file mode 100644
index 0000000..01f52c6
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/images/stream_menu.png
Binary files differ
diff --git a/tasks/vlc_stream_rtp/howtos/images/stream_open.PNG b/tasks/vlc_stream_rtp/howtos/images/stream_open.PNG
new file mode 100644
index 0000000..772ffe8
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/images/stream_open.PNG
Binary files differ
diff --git a/tasks/vlc_stream_rtp/howtos/images/stream_output.PNG b/tasks/vlc_stream_rtp/howtos/images/stream_output.PNG
new file mode 100644
index 0000000..c3dc2a7
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/images/stream_output.PNG
Binary files differ
diff --git a/tasks/vlc_stream_rtp/howtos/images/stream_transcoding.PNG b/tasks/vlc_stream_rtp/howtos/images/stream_transcoding.PNG
new file mode 100644
index 0000000..1fbc9f3
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/images/stream_transcoding.PNG
Binary files differ
diff --git a/tasks/vlc_stream_rtp/howtos/si/index.html b/tasks/vlc_stream_rtp/howtos/si/index.html
new file mode 100644
index 0000000..c94044b
--- /dev/null
+++ b/tasks/vlc_stream_rtp/howtos/si/index.html
@@ -0,0 +1,93 @@
+<html>
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=utf-8">
+</head>
+
+
+<body><font face="Georgia, Times New Roman, Times, serif">
+
+<h2> Naloga na hitro </h1>
+
+<ol>
+ <li>Postavi navidezni računalnik</li>
+ <li>Naloži VLC</li>
+ <li>Ustvari RTP video tok</li>
+ <li>Poskrbi, da bo tok dostopen na internetu</li>
+</ol>
+
+ <h2>Navodila</h1>
+
+ <ol>
+ <li>
+ <h4>Postavi navidezni računalnik </h3>
+ <p> Uporabi disk simpleArbiter. Dobiš ga lahko <a href="http://polz.si/media/uploads/kpov/virtualke/">tu</a>. </p>
+ </li>
+
+ <li>
+ <h4>Naloži VLC </h3>
+ <p>
+ V <code>/etc/apt/sources.list</code> v spodnjih vrsticah zamenjaj <code>wheezy</code> z
+ <code>testing</code> oziroma dodaj vrstice če niso napisane:
+ </p>
+ <p>
+ <code>
+ deb http://ftp.at.debian.org/debian wheezy main contrib non-free <br>
+ deb-src http://ftp.at.debian.org/debian wheezy main contrib non-free
+ </code>
+ </p>
+ <img alt="slika-01" src="../images/1.png" style="width: 640px;" />
+ <p>
+ Poglej za posodobitve in nato naloži VLC z naslednjimi ukazi:
+ </p>
+ <p>
+ <code>
+ apt-get update <br>
+ apt-get install vlc
+ </code>
+ </p>
+ </li>
+
+ <li>
+ <h4>Ustvari nov tok </h3>
+
+ <p>
+ Odpri VLC. V meniju Media izberi Stream.
+ </p>
+ <img src="../images/stream_menu.png" style="width: 640px;" alt="Meni">
+ <p>
+ V oknu "Open Media" izberemo vir toka. Ta je lahko datoteka, že obstoječ omrežni tok ali pa snemalne naprave. <br>
+ Za namen te naloge lahko z klikom na gumb <i>Add ...</i> dodamo eno ali več video datotek. Nadaljujemo z klikom na Stream.
+ </p>
+ <img src="../images/playlist.PNG" style="width: 640px;" alt="Vir toka">
+ <p>
+ Določiti moramo tudi destinacijo toka. Za to nalogo izberemo RTP/MPEG Transport Stream in kliknemo Add.
+ Možno je nastaviti več destinacij hkrati.
+ </p>
+ <p>
+ Nato izpolnimo nastavitve destinacije z naslovom in imenom toka.
+ </p>
+ <img src="../images/stream_output.PNG" style="width: 640px;" alt="Destinacija toka">
+ <p>
+ V naslednjem koraku lahko nastavimo kodiranje, enkapsulacijo, avdio in video nastavitve ter podnapise.
+ </p>
+ <img src="../images/stream_transcoding.PNG" style="width: 640px;" alt="Nastavitve Toka">
+ <p>
+ V zadnjem koraku je pomembno obkljukati možnost Stream all elementary streams.
+ V spodnjem tekstovnem polju dobimo niz, ki ga lahko uporabimo za zagon toka iz ukazne vrstice.
+ </p>
+ <img src="../images/stream_finish.PNG" style="width: 640px;">
+ </li>
+
+ <li>
+ <h4>Odpri tok </h3>
+ <p>
+ Na drugem računalniku lahko ustvarjen video tok predvajamo z VLC.
+ </p>
+ <img src="../images/stream_open.PNG" style="width: 640px;" alt="Predvajanje toka">
+ </li>
+</ol>
+
+</body>
+
+</html> \ No newline at end of file
diff --git a/tasks/vlc_stream_rtp/task.py b/tasks/vlc_stream_rtp/task.py
new file mode 100644
index 0000000..427fc0e
--- /dev/null
+++ b/tasks/vlc_stream_rtp/task.py
@@ -0,0 +1,110 @@
+# kpov_util should be imported by add_assignment.py
+
+# Postavi nek film na Internet tako, da ga bodo lahko ostali videli.
+# TODO: finish this
+
+instructions = {
+ 'si': '''\
+<p>
+Postavi navidezni računalnik <em>SimpleArbiter</em> in <em>StudentVLC</em>. Poskrbi, da bosta na istem omrežju, od koder bosta imela dostop tudi do interneta.
+
+<p>
+Na <em>StudentVLC</em> posodobi datoteko <code>/etc/apt/sources.list</code>, preveri posodobitve in naloži VLC.
+
+<p>
+Posnemi ali kako drugače ustvari film ter poskrbi, da bo film dostopen na lokalnem omrežju prek RTP z imenom toka <code>{{TOK}}</code> na naslovu <code>{{NASLOV}}</code>, vrata <code>{{PORT}}</code>. Računaj, da bodo film lahko videli tvoji sošolci. Kršenje avtorskih pravic je pri reševanju te naloge strogo prepovedano.
+''',
+ 'en': '''\
+<p>
+Set up a virtual computer called <em>SimpleArbiter</em> using the simpleArbiter disk and
+a virtual computer called <em>StudentVLC</em> using the student-VLC disk. Make sure they
+are on the same network and that they have access to the Internet.
+
+<p>
+On StundentVLC, update /etc/apt/sources.list, check the for updates and install VLC.
+
+<p>
+Record or otherwise create a movie and make sure the movie is avaliable on your local network via RTP with the name of the stream <code>{{TOK}}</code> at the address <code>{{NASLOV}}</code> on port <code>{{PORT}}</code>. Take into account that the movie may be seen by your classmates. Copyright infrigement while solving this task is strictly prohibited.
+''',
+}
+
+computers = {
+ 'SimpleArbiter': {
+ 'disks': [
+ { 'name': 'simpleArbiter',
+ },
+ ],
+ 'network_interfaces': [{'network': 'test-net'}],
+ 'flavor': 'm1.tiny',
+ 'config_drive': False
+ },
+ 'StudentVLC': {
+ 'disks': [
+ { 'name': 'student-VLC',
+ },
+ ],
+ 'network_interfaces': [{'network': 'test-net'}],
+ 'flavor': 'm1.tiny',
+ 'config_drive': False
+ }
+
+}
+
+networks = { 'test-net': {'public': True} }
+
+params_meta = {
+ 'NASLOV': {'descriptions': {'si': 'RTP multicast IP naslov'}, 'w': False, 'public':True, 'type': 'stream_name', 'generated': True},
+ 'PORT': {'descriptions': {'si': 'RTP VRATA'}, 'w': False, 'public':True, 'type': 'port', 'generated': True},
+ 'TOK': {'descriptions': {'si': 'Naslov (ime) toka'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
+}
+
+def task(NASLOV, TOK):
+ import pexpect
+ results = dict()
+ results['ps'] = pexpect.run('ps xa')
+ results['tcpdump_hex'] = pexpect.run('sudo /usr/sbin/tcpdump -x -c 2 dst host 239.255.255.255 and port 9875'.format(NASLOV))
+ results['tcpdump'] = pexpect.run('sudo /usr/sbin/tcpdump -c 8 dst host {}'.format(NASLOV))
+ return results
+
+def gen_params(user_id, params_meta):
+ params = dict()
+ r = random.Random(user_id)
+ net = kpov_util.IPv4_net_gen(r, min_hosts = 16,
+ local=True, multicast=True)
+ params['NASLOV'] = kpov_util.IPv4_addr_gen(r, net, 1)[0]
+ params['PORT'] = str(r.randint(5000, 6000))
+ params['TOK'] = kpov_util.hostname_gen(r)
+ return params
+
+def task_check(results, params):
+ import re
+ score = 0
+ hints = []
+ p1_s = ""
+ sname = ""
+ try:
+ packs = results['tcpdump_hex'].split('> 239.255.255.255.9875: UDP, length')
+ p1 = packs[1]
+ p1_l = p1.split('\n')
+ p1_d = p1_l[1:-1]
+ p1_s = ""
+ for i in p1_d:
+ p1_s = p1_s + "".join([j.strip() for j in i.split(' ')[1:]])
+ sname = "".join([hex(ord(i))[2:] for i in params['TOK']])
+ except:
+ hints.append("problem parsing RTP stream capture result")
+ if p1_s.find(sname) > 2:
+ score += 5
+ else:
+ hints.append("stream name not found in stream announcement")
+ s = "IP [^ ]* > {}.{}: UDP, length [0-9]+".format(
+ re.escape(params['NASLOV']),
+ params['PORT'])
+ if re.search(s, results['tcpdump']):
+ score += 5
+ else:
+ hints.append("RTP stream not detected in " + results['tcpdump'])
+ return score, hints
+
+def prepare_disks(templates, task_params, global_params):
+ write_default_config(templates['simpleArbiter'], global_params)