VLC iminds experiment example
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 25 Sep 2014 17:15:36 +0000 (19:15 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 25 Sep 2014 17:15:36 +0000 (19:15 +0200)
examples/omf/iminds_omf6_vlc.py
examples/omf/nitos_omf6_vlc.py

index 18f6ebd..2c4b474 100644 (file)
@@ -95,7 +95,7 @@ iface1 = ec.register_resource("OMFWifiInterface")
 ec.set(iface1, "name", "wlan0")
 ec.set(iface1, "mode", "adhoc")
 ec.set(iface1, "hw_mode", "g")
-ec.set(iface1, "essid", "ping")
+ec.set(iface1, "essid", "vlc")
 ec.set(iface1, "ip", "192.168.0.1/24")
 ec.register_connection(iface1, node1)
 
@@ -124,49 +124,59 @@ client_ip = "192.168.0.2"
 # Create and Configure the Application
 app1 = ec.register_resource("OMFApplication")
 ec.set(app1, "command", 
-    "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=%s,port=5004,mux=ts}'" % client_ip) 
+    "/root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=%s,port=5004,mux=ts}'" % client_ip) 
 ec.register_connection(app1, node1)
 
-## Add a OMFApplication to run the client VLC and count the numer of bytes 
-## transmitted,  using wc.
+## Add a OMFApplication to run the client VLC
 app2 = ec.register_resource("OMFApplication")
 ## Send the transmitted video to a file.
-ec.set(app2, "command", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc rtp://%s:5004 --sout '#standard{access=file,mux=ts,dst=/root/video}'" % client_ip)
-
-## Alternativelly, you can try to send the video to standard output and 
-## recover it using the stdout trace. However, it seems that sending 
-## binary messages back to the client is not well supported by the OMF 6 RC
-#ec.set(app2, "command", "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc rtp://%s:5004 --sout '#standard{access=file,mux=ts,dst=-}'" % client_ip)
+ec.set(app2, "command", "/root/vlc/vlc-1.1.13/cvlc rtp://%s:5004 --sout '#standard{access=file,mux=ts,dst=/root/video.ts}'" % client_ip)
 ec.register_connection(app2, node2)
 
-## stop app1 65s after it started
-ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "65s")
+## Add a OMFApplication to count the number of bytes in the transmitted video
+app3 = ec.register_resource("OMFApplication")
+## Send the transmitted video to a file.
+ec.set(app3, "command", "ls -lah /root/video.ts")
+ec.register_connection(app3, node2)
+
+app4 = ec.register_resource("OMFApplication")
+ec.set(app4, "command", "/usr/bin/killall vlc_app")
+ec.register_connection(app4, node1)
+
+app5 = ec.register_resource("OMFApplication")
+ec.set(app5, "command", "/usr/bin/killall vlc_app")
+ec.register_connection(app5, node2)
+
 ## start app2 5s after app1
 ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "5s")
+# start app3 after app2 stopped
+ec.register_condition(app3, ResourceAction.START, app2, ResourceState.STOPPED , "5s")
+# start the kill of vlc processes after they stopped
+ec.register_condition(app4, ResourceAction.START, app1, ResourceState.STOPPED , "5s")
+ec.register_condition(app5, ResourceAction.START, app2, ResourceState.STOPPED , "5s")
+
+## We need to explicitly STOP all applications
+## stop app1 65s after it started
+ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "65s")
 ## stop app2 5 seconds after app2
 ec.register_condition(app2, ResourceAction.STOP, app1, ResourceState.STOPPED , "5s")
+# stop app3 after 5s
+ec.register_condition(app3, ResourceAction.STOP, app3, ResourceState.STOPPED , "5s")
+# stop app4 
+ec.register_condition(app4, ResourceAction.STOP, app4, ResourceState.STARTED , "5s")
+# stop app5 
+ec.register_condition(app5, ResourceAction.STOP, app5, ResourceState.STARTED , "5s")
 
 # Deploy
 ec.deploy()
 
-ec.wait_finished([app2])
+# DO NOT WAIT FOR THE VLC applications or it will never stop
+ec.wait_finished([app4, app5])
 
-# Retrieve the bytes transmitted count and print it
-byte_count = ec.trace(app2, "stdout")
+# Retrieve the bytes transmitted output and print it
+byte_count = ec.trace(app3, "stdout")
 print "BYTES transmitted", byte_count
 
-## If you redirected the video to standard output, you can try to 
-## retrieve the stdout of the VLC client
-## video = ec.trace(app2, "stdout")
-#f = open("video.ts", "w")
-#f.write(video)
-#f.close()
-
-# Stop Experiment
-ec.shutdown()
-# RESULT
-print ec.trace(app1, "stdout")
-
 # Stop Experiment
 ec.shutdown()
 
index 749dd35..ec7f7be 100644 (file)
@@ -92,7 +92,7 @@ iface1 = ec.register_resource("OMFWifiInterface")
 ec.set(iface1, "name", "wlan0")
 ec.set(iface1, "mode", "adhoc")
 ec.set(iface1, "hw_mode", "g")
-ec.set(iface1, "essid", "ping")
+ec.set(iface1, "essid", "vlc")
 ec.set(iface1, "ip", "192.168.0.%s/24" % nodex[-2:]) 
 ec.register_connection(node1, iface1)
 
@@ -109,7 +109,7 @@ iface2 = ec.register_resource("OMFWifiInterface")
 ec.set(iface2, "name", "wlan0")
 ec.set(iface2, "mode", "adhoc")
 ec.set(iface2, "hw_mode", "g")
-ec.set(iface2, "essid", "ping")
+ec.set(iface2, "essid", "vlc")
 ec.set(iface2, "ip", "192.168.0.%s/24" % nodez[-2:]) 
 ec.register_connection(node2, iface2)