diff --git a/conf/gcs/papgets.xml b/conf/gcs/papgets.xml index 6cb5a5b916..c71ebc985c 100644 --- a/conf/gcs/papgets.xml +++ b/conf/gcs/papgets.xml @@ -1,6 +1,13 @@ + diff --git a/sw/ground_segment/cockpit/papgets.ml b/sw/ground_segment/cockpit/papgets.ml index 6fe6f5a643..77d27c0092 100644 --- a/sw/ground_segment/cockpit/papgets.ml +++ b/sw/ground_segment/cockpit/papgets.ml @@ -130,6 +130,18 @@ let create = fun canvas_group papget -> let p = (p :> Papget.item) in register_papget p + | "video_plugin" -> + let renderer = + match display with + "mplayer" -> + (new Papget_renderer.canvas_mplayer canvas_group ~config x y :> Papget_renderer.t) + | _ -> failwith (sprintf "Unexpected papget display: %s" display) in + + let properties = locked papget in + let p = new Papget.canvas_video_plugin_item properties renderer in + let p = (p :> Papget.item) in + register_papget p + | _ -> failwith (sprintf "Unexpected papget type: %s" type_) diff --git a/sw/lib/ocaml/papget.ml b/sw/lib/ocaml/papget.ml index c3d781f8ed..cb37e4140c 100644 --- a/sw/lib/ocaml/papget.ml +++ b/sw/lib/ocaml/papget.ml @@ -295,3 +295,20 @@ class canvas_variable_setting_item = fun properties callback (canvas_renderer:PR object inherit canvas_clickable_item "variable_setting" properties callback canvas_renderer end + + + +(****************************************************************************) +class canvas_video_plugin_item = fun properties (canvas_renderer:PR.t) -> + object + inherit canvas_item ~config:properties canvas_renderer as item + method config = fun () -> + let props = renderer#config () in + let (x, y) = item#xy in + let attrs = + [ "type", "video_plugin"; + "display", String.lowercase item#renderer#tag; + "x", sprintf "%.0f" x; "y", sprintf "%.0f" y ] in + Xml.Element ("papget", attrs, properties@props) + end + diff --git a/sw/lib/ocaml/papget.mli b/sw/lib/ocaml/papget.mli index 6c42924d98..d202521440 100644 --- a/sw/lib/ocaml/papget.mli +++ b/sw/lib/ocaml/papget.mli @@ -93,3 +93,22 @@ class canvas_variable_setting_item : method update : string -> unit method xy : float * float end + +class canvas_video_plugin_item : + Xml.xml list -> + Papget_renderer.t -> + object + inherit canvas_item_type + method config : unit -> Xml.xml +(* + + method connect : unit -> unit + method deleted : bool + method edit : unit -> unit + method event : GnoCanvas.item_event -> bool + method renderer : Papget_renderer.t + method update : string -> unit + method xy : float * float +*) + end + diff --git a/sw/lib/ocaml/papget_renderer.ml b/sw/lib/ocaml/papget_renderer.ml index c58d21dca5..ce8368f713 100644 --- a/sw/lib/ocaml/papget_renderer.ml +++ b/sw/lib/ocaml/papget_renderer.ml @@ -251,9 +251,38 @@ class canvas_button = fun ?(config=[]) canvas_group x y -> method update = fun (value:string) -> () method config = fun () -> [ PC.property "icon" icon] + initializer + group#raise_to_top (); end +(****************************************************************************) +class canvas_mplayer = fun ?(config=[]) canvas_group x y -> + let video_feed = PC.get_prop "video_feed" config "video_URI" in + let width = float_of_string (PC.get_prop "width" config "320.") + and height = float_of_string (PC.get_prop "height" config "240.") in + let socket = GWindow.socket () in + let group = GnoCanvas.group ~x ~y canvas_group in + let _item = GnoCanvas.widget ~width ~height ~widget:socket group in + + object + method tag = "Mplayer" + method item = (group :> movable_item) + method edit = fun (pack:GObj.widget -> unit) -> () + method update = fun (value:string) -> () + method config = fun () -> + [ PC.property "video_feed" video_feed; + PC.float_property "width" width; + PC.float_property "height" height ] + initializer + group#lower_to_bottom (); + let com = sprintf "exec mplayer -vo xv -really-quiet -nomouseinput %s -wid 0x%lx -geometry %.0fx%.0f" video_feed socket#xwindow width height in + let dev_null = Unix.descr_of_out_channel (open_out "/dev/null") in + ignore (Unix.create_process "/bin/sh" [|"/bin/sh"; "-c"; com|] dev_null dev_null dev_null) + end + + + let renderers = [ (new canvas_text :> ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t); (new canvas_ruler :> ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t); diff --git a/sw/lib/ocaml/papget_renderer.mli b/sw/lib/ocaml/papget_renderer.mli index 763597bff1..e2cde91dd1 100644 --- a/sw/lib/ocaml/papget_renderer.mli +++ b/sw/lib/ocaml/papget_renderer.mli @@ -40,13 +40,21 @@ class type t = end class canvas_text : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t +(** [canvas_text config group x y] *) class canvas_ruler : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t +(** [canvas_ruler config group x y] *) class canvas_gauge : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t +(** [canvas_gauge config group x y] *) class canvas_button : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t +(** [canvas_button config group x y] *) + +class canvas_mplayer : ?config:Xml.xml list -> #GnoCanvas.group -> float -> float -> t +(** [canvas_mplayer config group x y] *) val lazy_tagged_renderers : (string * (?config:Xml.xml list -> GnoCanvas.group -> float -> float -> t)) list lazy_t +(** List of renderers available to display a telemetry field value *)