Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added header encoding with packet output for speex and vorbis

--HG--
extra : convert_revision : svn%3Aaec24677-d710-0410-a355-ac75e2bdf181/trunk%406123
  • Loading branch information...
commit a922db008d2dd6bb0d8081180494bda2e4a0b374 1 parent e1504f9
metamorph68@aec24677-d710-0410-a355-ac75e2bdf181 authored
View
1  configure.ac
@@ -207,6 +207,7 @@ AC_SUBST(PS2PDF) # TODO
# Finally create the Makefile and samples
AC_CONFIG_FILES([src/Makefile],[chmod a-w src/Makefile])
AC_CONFIG_FILES([examples/Makefile.wav2ogg],[chmod a-w examples/Makefile.wav2ogg])
+AC_CONFIG_FILES([examples/Makefile.ogg2wav],[chmod a-w examples/Makefile.ogg2wav])
AC_CONFIG_FILES([examples/Makefile.stream2wav],[chmod a-w examples/Makefile.stream2wav])
AC_CONFIG_FILES([src/META],[chmod a-w src/META])
AC_OUTPUT
View
2  examples/Makefile.ogg2wav → examples/Makefile.ogg2wav.in
@@ -1,7 +1,7 @@
SOURCES = ogg2wav.ml
RESULT = ogg2wav
LIBS = unix str ogg vorbis
-INCDIRS = ../src ../../ocaml-ogg/src
+INCDIRS = ../src @OCAMLOGG_INC@
all: nc
View
13 src/vorbis.ml
@@ -100,11 +100,18 @@ struct
external reset : t -> unit = "ocaml_vorbis_reset"
- external headerout : t -> Ogg.Stream.t -> (string * string) array -> unit = "ocaml_vorbis_analysis_headerout"
- let headerout state os tags =
+ external headerout_packetout : t -> (string * string) array -> Ogg.Stream.packet*Ogg.Stream.packet*Ogg.Stream.packet = "ocaml_vorbis_analysis_headerout"
+
+ let headerout_packetout state tags =
let tags = Array.of_list (tags@[("ENCODER", encoder_tag)]) in
- headerout state os tags
+ headerout_packetout state tags
+
+ let headerout state os tags =
+ let p1,p2,p3 = headerout_packetout state tags in
+ Ogg.Stream.put_packet os p1;
+ Ogg.Stream.put_packet os p2;
+ Ogg.Stream.put_packet os p3
external encode_buffer_float : t -> Ogg.Stream.t -> float array array -> int -> int -> unit = "ocaml_vorbis_encode_float"
View
6 src/vorbis.mli
@@ -137,6 +137,12 @@ sig
(** Encode a header given a list of tags. *)
val headerout : t -> Ogg.Stream.t -> (string * string) list -> unit
+ (** Encoder a header, but do not submit packet to
+ * Ogg Stream. Usefull when multiplexing ogg streams
+ * since the all first packets of each streams must be packed
+ * in the initial pages. *)
+ val headerout_packetout : t -> (string * string) list -> Ogg.Stream.packet*Ogg.Stream.packet*Ogg.Stream.packet
+
(** Encode a buffer of PCM data. *)
val encode_buffer_float : t -> Ogg.Stream.t -> float array array -> int -> int -> unit
View
15 src/vorbis_stubs.c
@@ -385,10 +385,11 @@ CAMLprim value ocaml_vorbis_reset(value vdsp)
return Val_unit;
}
-CAMLprim value ocaml_vorbis_analysis_headerout(value vdsp, value vogg, value comments)
+CAMLprim value ocaml_vorbis_analysis_headerout(value vdsp, value comments)
{
+ CAMLparam2(vdsp, comments);
+ CAMLlocal4(ret,p1,p2,p3);
vorbis_dsp_state *vd = Enc_dsp_state_val(vdsp);
- ogg_stream_state *os = Stream_state_val(vogg);
vorbis_comment vc;
ogg_packet header, header_comm, header_code;
int i;
@@ -398,11 +399,13 @@ CAMLprim value ocaml_vorbis_analysis_headerout(value vdsp, value vogg, value com
vorbis_comment_add_tag(&vc, String_val(Field(Field(comments, i), 0)), String_val(Field(Field(comments, i), 1)));
vorbis_analysis_headerout(vd, &vc, &header, &header_comm, &header_code);
vorbis_comment_clear(&vc);
- ogg_stream_packetin(os, &header);
- ogg_stream_packetin(os, &header_comm);
- ogg_stream_packetin(os, &header_code);
- return Val_unit;
+ ret = caml_alloc_tuple(3);
+ Store_field(ret,0,value_of_packet(&header));
+ Store_field(ret,1,value_of_packet(&header_comm));
+ Store_field(ret,2,value_of_packet(&header_code));
+
+ CAMLreturn(ret);
}
CAMLprim value ocaml_vorbis_encode_float(value vdsp, value vogg, value data, value _offs, value _len)
Please sign in to comment.
Something went wrong with that request. Please try again.