70 lines
2.2 KiB
Ruby
70 lines
2.2 KiB
Ruby
class Libopusenc < Formula
|
|
desc "Convenience libraray for creating .opus files"
|
|
homepage "https://opus-codec.org/"
|
|
url "https://archive.mozilla.org/pub/opus/libopusenc-0.1.1.tar.gz"
|
|
sha256 "02e6e0b14cbbe0569d948a46420f9c9a81d93bba32dc576a4007cbf96da68ef3"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "f6465a7b4a3a1463682519d74dd19141bea1e7375eb099101877066f1fc63479" => :mojave
|
|
sha256 "6a9ff9eacc72069a2d16951445772dbd60ab0fe4347ab6c385e8cc42c6b94ee5" => :high_sierra
|
|
sha256 "611eace04f91c6f8685eb27e60c5bcd4f3f5edfe9904e267a476cce882016884" => :sierra
|
|
sha256 "9a957d7797f3e346e6aa85a85f96e463dd10c75e5ab3e32e32ee25952874a50f" => :el_capitan
|
|
end
|
|
|
|
head do
|
|
url "https://git.xiph.org/libopusenc.git"
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "opus"
|
|
|
|
def install
|
|
system "./autogen.sh" if build.head?
|
|
system "./configure", "--disable-dependency-tracking",
|
|
"--disable-silent-rules",
|
|
"--prefix=#{prefix}"
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <opusenc.h>
|
|
#include <assert.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
int main() {
|
|
OggOpusComments *comments = ope_comments_create();
|
|
assert(comments);
|
|
ope_comments_add(comments, "ARTIST", "Homebrew");
|
|
ope_comments_add(comments, "TITLE", "Test Track");
|
|
|
|
int error;
|
|
OggOpusEnc *enc = ope_encoder_create_file("test.opus",
|
|
comments, 48000, 2, 0, &error);;
|
|
assert(error == OPE_OK);
|
|
assert(enc);
|
|
ope_comments_destroy(comments);
|
|
|
|
int16_t *buffer = calloc(1920, 2*sizeof(*buffer));
|
|
error = ope_encoder_write(enc, buffer, 1920*2*sizeof(*buffer));
|
|
assert(error == OPE_OK);
|
|
|
|
error = ope_encoder_drain(enc);
|
|
assert(error == OPE_OK);
|
|
ope_encoder_destroy(enc);
|
|
|
|
return 0;
|
|
}
|
|
EOS
|
|
system ENV.cc, "test.c", "-o", "test", "-Wall",
|
|
"-I#{Formula["opus"].opt_include}/opus",
|
|
"-I#{include}/opus",
|
|
"-L#{lib}", "-lopusenc"
|
|
system "./test"
|
|
end
|
|
end
|