Skip to content

Commit

Permalink
Cleanup some debug stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Nov 12, 2012
1 parent 6297e39 commit 8bcd3c9
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/encoder/gstreamer_encoder.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ type gst =


let encoder id ext = let encoder id ext =
GU.init (); GU.init ();
let channels = ext.channels in let channels =
Encoder.GStreamer.audio_channels ext
in
let mutex = Mutex.create () in let mutex = Mutex.create () in
let samples = ref 0 in let samples = ref 0 in
let decr_samples = let decr_samples =
Expand All @@ -49,9 +51,6 @@ let encoder id ext =
incr samples) incr samples)
in in
let on_sample () = let on_sample () =
Printf.printf "Got sample!\n%!";
(* Will we finally get there????....... *)
exit (-1);
incr_samples(); incr_samples();
in in


Expand All @@ -75,7 +74,6 @@ let encoder id ext =
(Stdlib.some_or "" audio_pipeline) (Stdlib.some_or "" audio_pipeline)
(Stdlib.some_or "" video_pipeline) (Stdlib.some_or "" video_pipeline)
in in
Printf.printf "pipeline: %s\n%!" pipeline;
let bin = Gstreamer.Pipeline.parse_launch pipeline in let bin = Gstreamer.Pipeline.parse_launch pipeline in
let audio_src = let audio_src =
Gstreamer.App_src.of_element (Gstreamer.Bin.get_by_name bin "audio_src") Gstreamer.App_src.of_element (Gstreamer.Bin.get_by_name bin "audio_src")
Expand Down Expand Up @@ -109,21 +107,21 @@ let encoder id ext =
let now = ref Int64.zero in let now = ref Int64.zero in


let encode h frame start len = let encode h frame start len =
Printf.printf "Encode@%Lu.\n%!" !now;
let nanolen = Int64.of_float (Frame.seconds_of_master len *. 1000000000.) in let nanolen = Int64.of_float (Frame.seconds_of_master len *. 1000000000.) in
let content = Frame.content_of_type frame start { Frame.audio = channels; video = 1; midi = 0 } in let content = Frame.content_of_type frame start { Frame.audio = channels; video = 1; midi = 0 } in
(* Put audio. *) if channels > 0 then
let astart = Frame.audio_of_master start in begin
let alen = Frame.audio_of_master len in (* Put audio. *)
let pcm = content.Frame.audio in let astart = Frame.audio_of_master start in
let data = String.create (2*channels*alen) in let alen = Frame.audio_of_master len in
Audio.S16LE.of_audio pcm astart data 0 alen; let pcm = content.Frame.audio in
let gstbuf = Gstreamer.Buffer.of_string data 0 (String.length data) in let data = String.create (2*channels*alen) in
Gstreamer.Buffer.set_presentation_time gstbuf !now; Audio.S16LE.of_audio pcm astart data 0 alen;
Gstreamer.Buffer.set_duration gstbuf nanolen; let gstbuf = Gstreamer.Buffer.of_string data 0 (String.length data) in
Printf.printf "Put audio... %!"; Gstreamer.Buffer.set_presentation_time gstbuf !now;
Gstreamer.App_src.push_buffer gst.audio_src gstbuf; Gstreamer.Buffer.set_duration gstbuf nanolen;
Printf.printf "done.\n%!"; Gstreamer.App_src.push_buffer gst.audio_src gstbuf;
end;
(* Put video. *) (* Put video. *)
let vbuf = content.Frame.video in let vbuf = content.Frame.video in
let vbuf = vbuf.(0) in let vbuf = vbuf.(0) in
Expand All @@ -132,9 +130,7 @@ let encoder id ext =
let gstbuf = Gstreamer.Buffer.of_data data 0 (Bigarray.Array1.dim data) in let gstbuf = Gstreamer.Buffer.of_data data 0 (Bigarray.Array1.dim data) in
Gstreamer.Buffer.set_presentation_time gstbuf !now; Gstreamer.Buffer.set_presentation_time gstbuf !now;
Gstreamer.Buffer.set_duration gstbuf nanolen; Gstreamer.Buffer.set_duration gstbuf nanolen;
Printf.printf "Put video... %!";
Gstreamer.App_src.push_buffer gst.video_src gstbuf; Gstreamer.App_src.push_buffer gst.video_src gstbuf;
Printf.printf "done.\n%!"
done; done;
(* Return result. *) (* Return result. *)
now := Int64.add !now nanolen; now := Int64.add !now nanolen;
Expand Down

0 comments on commit 8bcd3c9

Please sign in to comment.