Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 77 lines (68 sloc) 2.593 kb
c729c0f Importing existing code
Diego Dompe authored
1 /*
2 * ipiped/src/main.vala
3 *
4 * Main function for Ipipe daemon - controlling IPIPE path on the Video Processing Subsystem
5 *
6 * Copyright (c) 2010, RidgeRun
7 * All rights reserved.
8 */
9
10 /*Global Variable*/
11 using Posix, GLib;
12 void on_bus_aquired (DBusConnection conn) {
13 string data, filename = "/usr/etc/ipiped.conf";
14 string video_processor="", sensor="";
15 AbstcVideoProcessor video_processor_abstract;
16 AbstcSensor sensor_abstract;
17 // A reference to the file
18 FILE file = FILE.open(filename, "r");
19
20 if ( file != null ){
21 char line [128]; /*maximum line size */
22 while ( (data =file.gets(line)) != null ) /* read a line */
23 {
24 var s= data.split("=", 2);
25 if (s[0] == "processor"){
26 video_processor = s[1].strip();
27 }else if (s[0] == "sensor"){
28 sensor = s[1].strip();
29 }
30 }
31 } else {
32 Posix.stderr.printf("Configuration file %s doesn't exist\n", filename);
33 return;
34 }
35
36 try {
37
38 if (video_processor == "dm365"){
39 var ipiped_dm365 = new Ipiped_dm365();
40 video_processor_abstract = ipiped_dm365;
41 conn.register_object ("/com/ridgerun/ipiped/ipipe", ipiped_dm365);
42 } else {
43 Posix.stderr.printf("Video processor doesn't match with available platforms \n");
44 return;
45 }
46
47 if (sensor == "mt9p031"){
48 var ipiped_mt9p031 = new Ipiped_mt9p031();
49 sensor_abstract=ipiped_mt9p031;
50 conn.register_object ("/com/ridgerun/ipiped/ipipe", ipiped_mt9p031);
51 } else {
52 Posix.stderr.printf("Sensor support doesn't exist \n");
53 return;
54 }
55 var ipipe = new Ipipe(sensor, video_processor, video_processor_abstract, sensor_abstract);
56 /* Try to register service in session bus */
57 conn.register_object ("/com/ridgerun/ipiped/ipipe", ipipe);
58 } catch (IOError e) {
59 GLib.stderr.printf ("Could not register service\n");
60 GLib.stderr.printf ("Ipiped: Error: %s\n", e.message);
61 }
62 }
63
64 public void main (string[]args) {
65
66 Bus.own_name (BusType.SYSTEM, "com.ridgerun.ipiped",
67 BusNameOwnerFlags.NONE,
68 on_bus_aquired,
69 () => {},
70 () => GLib.stderr.printf ("Ipiped: Failed to obtain primary ownership of " +
71 "the service\nThis usually means there is another instance of " +
72 " ipiped already running\n"));
73 /* Creating a GLib main loop with a default context */
74 new MainLoop ().run ();
75 }
76
Something went wrong with that request. Please try again.