diff --git a/.gitignore b/.gitignore index f1c181ec..802ed0bb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out + +scripts/cross diff --git a/.gitmodules b/.gitmodules index 52c82405..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "cvendor/src/openh264"] - path = cvendor/src/openh264 - url = https://github.com/cisco/openh264.git diff --git a/Makefile b/Makefile deleted file mode 100644 index 2511ef0f..00000000 --- a/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -vendor_dir = cvendor -src_dir = $(vendor_dir)/src -lib_dir = $(vendor_dir)/lib -include_dir = $(vendor_dir)/include - -make_args.x86_64-windows = \ - CC=x86_64-w64-mingw32-gcc \ - CXX=x86_64-w64-mingw32-g++ \ - ARCH=x86_64 \ - OS=mingw_nt -make_args.x86_64-darwin = \ - CC=o64-clang \ - CXX=o64-clang++ \ - AR=llvm-ar \ - ARCH=x86_64 \ - OS=darwin - -.PHONY: vendor -vendor: \ - $(include_dir)/openh264 \ - cross-libraries - -$(include_dir)/openh264: $(src_dir)/openh264 - mkdir -p $@ - cp $^/codec/api/svc/*.h $@ - -$(lib_dir)/openh264/libopenh264.x86_64-linux.a: $(src_dir)/openh264 - $(MAKE) -C $^ clean \ - && $(MAKE) -C $^ libraries - mkdir -p $(dir $@) - cp $^/libopenh264.a $@ - -$(lib_dir)/openh264/libopenh264.x86_64-windows.a: $(src_dir)/openh264 - $(MAKE) -C $^ clean \ - && $(MAKE) -C $^ $(make_args.x86_64-windows) libraries - mkdir -p $(dir $@) - cp $^/libopenh264.a $@ - -$(lib_dir)/openh264/libopenh264.x86_64-darwin.a: $(src_dir)/openh264 - $(MAKE) -C $^ clean \ - && $(MAKE) -C $^ $(make_args.x86_64-darwin) libraries - mkdir -p $(dir $@) - cp $^/libopenh264.a $@ - -.PHONY: cross-libraries -cross-libraries: - docker build -t mediadevices-libs-builder -f libs-builder.Dockerfile . - docker run --rm \ - -v $(CURDIR):/go/src/github.com/pion/mediadevices \ - mediadevices-libs-builder make $(lib_dir)/openh264/libopenh264.x86_64-linux.a - docker run --rm \ - -v $(CURDIR):/go/src/github.com/pion/mediadevices \ - mediadevices-libs-builder make $(lib_dir)/openh264/libopenh264.x86_64-windows.a - docker run --rm \ - -v $(CURDIR):/go/src/github.com/pion/mediadevices \ - mediadevices-libs-builder make $(lib_dir)/openh264/libopenh264.x86_64-darwin.a diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..692b274a --- /dev/null +++ b/build.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +MEDIADEVICES_TOOLCHAIN_OWNER=lherman +MEDIADEVICES_TOOLCHAIN_PREFIX=cross +MEDIADEVICES_SCRIPT_PATH=$(realpath ./scripts) +MEDIADEVICES_TOOLCHAIN_PATH=${MEDIADEVICES_SCRIPT_PATH}/${MEDIADEVICES_TOOLCHAIN_PREFIX} +MEDIADEVICES_DOCKERFILES_PATH=dockerfiles + +# Reference: https://github.com/dockcross/dockcross#cross-compilers +MEDIADEVICES_TARGET_PLATFORMS=( + linux-armv7 + linux-arm64 + linux-x64 + windows-x64 + darwin-x64 +) + +if [[ -z ${VERBOSE} ]]; then + MEDIADEVICES_OUTPUT=/dev/null +else + MEDIADEVICES_OUTPUT=/dev/stdout +fi + +install_toolchains() { + bash ${MEDIADEVICES_DOCKERFILES_PATH}/build.sh &> ${MEDIADEVICES_OUTPUT} + for platform in ${MEDIADEVICES_TARGET_PLATFORMS[@]} + do + mkdir -p ${MEDIADEVICES_TOOLCHAIN_PATH} + image=${MEDIADEVICES_TOOLCHAIN_OWNER}/${MEDIADEVICES_TOOLCHAIN_PREFIX}-${platform} + bin_path=${MEDIADEVICES_TOOLCHAIN_PATH}/${MEDIADEVICES_TOOLCHAIN_PREFIX}-${platform} + docker run ${image} > ${bin_path} + chmod +x ${bin_path} + done +} + +build() { + sub_builds=$(find pkg -type f -name "build.sh") + for sub_build in ${sub_builds[@]} + do + sub_build=$(realpath ${sub_build}) + sub_build_dir=$(dirname ${sub_build}) + current_dir=${PWD} + cd $sub_build_dir + for platform in ${MEDIADEVICES_TARGET_PLATFORMS[@]} + do + export MEDIADEVICES_TOOLCHAIN_BIN=${MEDIADEVICES_TOOLCHAIN_PATH}/${MEDIADEVICES_TOOLCHAIN_PREFIX}-${platform} + # convert '-' to '_' since '_' is more common in library names + export MEDIADEVICES_TARGET_PLATFORM=${platform//-/_} + export MEDIADEVICES_TARGET_OS=$(echo $MEDIADEVICES_TARGET_PLATFORM | cut -d'_' -f1) + export MEDIADEVICES_TARGET_ARCH=${platform//${MEDIADEVICES_TARGET_OS}-/} + + echo "Building ${sub_build_dir}:" + echo " PLATFORM : ${MEDIADEVICES_TARGET_PLATFORM}" + echo " OS : ${MEDIADEVICES_TARGET_OS}" + echo " ARCH : ${MEDIADEVICES_TARGET_ARCH}" + echo " TOOLCHAIN_BIN : ${MEDIADEVICES_TOOLCHAIN_BIN}" + echo "" + + ${sub_build} &> ${MEDIADEVICES_OUTPUT} + done + cd ${current_dir} + done +} + +if [[ $# > 0 && $1 != "all" ]]; then + MEDIADEVICES_TARGET_PLATFORMS=($1) +fi + +install_toolchains +build diff --git a/cvendor/lib/openh264/libopenh264.x86_64-darwin.a b/cvendor/lib/openh264/libopenh264.x86_64-darwin.a deleted file mode 100644 index d2254dc7..00000000 Binary files a/cvendor/lib/openh264/libopenh264.x86_64-darwin.a and /dev/null differ diff --git a/cvendor/lib/openh264/libopenh264.x86_64-linux.a b/cvendor/lib/openh264/libopenh264.x86_64-linux.a deleted file mode 100644 index 40bc949f..00000000 Binary files a/cvendor/lib/openh264/libopenh264.x86_64-linux.a and /dev/null differ diff --git a/cvendor/lib/openh264/libopenh264.x86_64-windows.a b/cvendor/lib/openh264/libopenh264.x86_64-windows.a deleted file mode 100644 index 11839d4a..00000000 Binary files a/cvendor/lib/openh264/libopenh264.x86_64-windows.a and /dev/null differ diff --git a/cvendor/src/openh264 b/cvendor/src/openh264 deleted file mode 160000 index 71374015..00000000 --- a/cvendor/src/openh264 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 71374015cdf13f7aab4bc2d820f77905b3becfb8 diff --git a/dockerfiles/build.sh b/dockerfiles/build.sh new file mode 100755 index 00000000..d6ef91f1 --- /dev/null +++ b/dockerfiles/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cd $(dirname $0) + +OWNER=lherman +PREFIX=cross +IMAGES=$(ls *.Dockerfile) + +for image in ${IMAGES[@]} +do + tag=${OWNER}/cross-${image//.Dockerfile/} + docker build -t "${tag}" -f "$image" . +done diff --git a/dockerfiles/darwin-x64.Dockerfile b/dockerfiles/darwin-x64.Dockerfile new file mode 100644 index 00000000..85ea2f2c --- /dev/null +++ b/dockerfiles/darwin-x64.Dockerfile @@ -0,0 +1,20 @@ +FROM dockcross/base + +ENV OSX_CROSS_PATH=/osxcross + +COPY --from=dockercore/golang-cross "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/" +ENV PATH=${OSX_CROSS_PATH}/target/bin:$PATH + +COPY init.sh /tmp/init.sh +RUN bash /tmp/init.sh + +ENV CC=x86_64-apple-darwin14-clang \ + CXX=x86_64-apple-darwin14-clang++ \ + CPP=x86_64-apple-darwin14-clang++ \ + AR=x86_64-apple-darwin14-ar \ + AS=x86_64-apple-darwin14-as \ + LD=x86_64-apple-darwin14-ld + +ARG IMAGE=lherman/cross-darwin-x64 +ARG VERSION=latest +ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} diff --git a/dockerfiles/init.sh b/dockerfiles/init.sh new file mode 100755 index 00000000..36a8441e --- /dev/null +++ b/dockerfiles/init.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +apt-get update +apt-get install -y nasm clang llvm + +curl -L https://golang.org/dl/go1.15.6.linux-amd64.tar.gz | tar -C /usr/local -xzf - +ln -s /usr/local/go/bin/go /usr/local/bin/go diff --git a/dockerfiles/linux-arm64.Dockerfile b/dockerfiles/linux-arm64.Dockerfile new file mode 100644 index 00000000..d53c17dc --- /dev/null +++ b/dockerfiles/linux-arm64.Dockerfile @@ -0,0 +1,8 @@ +FROM dockcross/linux-arm64 + +ARG IMAGE=lherman/cross-linux-arm64 +ARG VERSION=latest +ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} + +COPY init.sh /tmp/init.sh +RUN bash /tmp/init.sh diff --git a/dockerfiles/linux-armv7.Dockerfile b/dockerfiles/linux-armv7.Dockerfile new file mode 100644 index 00000000..dab854ff --- /dev/null +++ b/dockerfiles/linux-armv7.Dockerfile @@ -0,0 +1,8 @@ +FROM dockcross/linux-armv7 + +ARG IMAGE=lherman/cross-linux-armv7 +ARG VERSION=latest +ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} + +COPY init.sh /tmp/init.sh +RUN bash /tmp/init.sh diff --git a/dockerfiles/linux-x64.Dockerfile b/dockerfiles/linux-x64.Dockerfile new file mode 100644 index 00000000..a34c76d3 --- /dev/null +++ b/dockerfiles/linux-x64.Dockerfile @@ -0,0 +1,8 @@ +FROM dockcross/linux-x64 + +ARG IMAGE=lherman/cross-linux-x64 +ARG VERSION=latest +ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} + +COPY init.sh /tmp/init.sh +RUN bash /tmp/init.sh diff --git a/dockerfiles/windows-x64.Dockerfile b/dockerfiles/windows-x64.Dockerfile new file mode 100644 index 00000000..eeaa3a01 --- /dev/null +++ b/dockerfiles/windows-x64.Dockerfile @@ -0,0 +1,11 @@ +FROM dockcross/windows-static-x64-posix + +ARG IMAGE=lherman/cross-windows-x64 +ARG VERSION=latest +ENV DEFAULT_DOCKCROSS_IMAGE ${IMAGE}:${VERSION} + +COPY init.sh /tmp/init.sh +RUN bash /tmp/init.sh +RUN ln -s /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static.posix-gcc /usr/bin/x86_64-w64-mingw32-gcc && \ + ln -s /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static.posix-g++ /usr/bin/x86_64-w64-mingw32-g++ && \ + ln -s /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static.posix-ar /usr/bin/x86_64-w64-mingw32-ar diff --git a/libs-builder.Dockerfile b/libs-builder.Dockerfile deleted file mode 100644 index b9577cfa..00000000 --- a/libs-builder.Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM dockercore/golang-cross - -RUN apt-get update -qq \ - && apt-get install -y \ - g++-mingw-w64 \ - nasm \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -VOLUME /go/src/github.com/pion/mediadevices -WORKDIR /go/src/github.com/pion/mediadevices diff --git a/pkg/codec/openh264/.gitignore b/pkg/codec/openh264/.gitignore new file mode 100644 index 00000000..85de9cf9 --- /dev/null +++ b/pkg/codec/openh264/.gitignore @@ -0,0 +1 @@ +src diff --git a/pkg/codec/openh264/LICENSE b/pkg/codec/openh264/LICENSE new file mode 100644 index 00000000..096ba5d1 --- /dev/null +++ b/pkg/codec/openh264/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2013, Cisco Systems +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkg/codec/openh264/build.sh b/pkg/codec/openh264/build.sh new file mode 100755 index 00000000..cf89480a --- /dev/null +++ b/pkg/codec/openh264/build.sh @@ -0,0 +1,36 @@ +GIT_URL=https://github.com/cisco/openh264.git +VERSION=v2.1.1 +SRC_DIR=src +LIB_DIR=lib +INCLUDE_DIR=include/openh264 +ROOT_DIR=${PWD} +LIB_PREFIX=libopenh264 + +OS=${MEDIADEVICES_TARGET_OS} +ARCH=${MEDIADEVICES_TARGET_ARCH} + +case ${MEDIADEVICES_TARGET_OS} in + windows) + OS=mingw_nt + ;; +esac + +case ${MEDIADEVICES_TARGET_ARCH} in + armv6 | armv7 | armv8) + ARCH=arm + ;; + x64) + ARCH=x86_64 + ;; +esac + +mkdir -p ${LIB_DIR} ${INCLUDE_DIR} + +git clone --depth=1 --branch=${VERSION} ${GIT_URL} ${SRC_DIR} +cd ${SRC_DIR} +${MEDIADEVICES_TOOLCHAIN_BIN} make -j2 ${LIB_PREFIX}.a OS=${OS} ARCH=${ARCH} +${MEDIADEVICES_TOOLCHAIN_BIN} echo $PATH +mv ${LIB_PREFIX}.a ${ROOT_DIR}/${LIB_DIR}/${LIB_PREFIX}_${MEDIADEVICES_TARGET_PLATFORM}.a +mkdir -p ${ROOT_DIR}/${INCLUDE_DIR} +cp codec/api/svc/*.h ${ROOT_DIR}/${INCLUDE_DIR} +make clean diff --git a/cvendor/include/openh264/codec_api.h b/pkg/codec/openh264/include/openh264/codec_api.h similarity index 100% rename from cvendor/include/openh264/codec_api.h rename to pkg/codec/openh264/include/openh264/codec_api.h diff --git a/cvendor/include/openh264/codec_app_def.h b/pkg/codec/openh264/include/openh264/codec_app_def.h similarity index 99% rename from cvendor/include/openh264/codec_app_def.h rename to pkg/codec/openh264/include/openh264/codec_app_def.h index 1e26f9f2..bb3c3d67 100644 --- a/cvendor/include/openh264/codec_app_def.h +++ b/pkg/codec/openh264/include/openh264/codec_app_def.h @@ -167,8 +167,8 @@ typedef enum { DECODER_OPTION_LEVEL, ///< get current AU level info,only is used in GetOption DECODER_OPTION_STATISTICS_LOG_INTERVAL,///< set log output interval DECODER_OPTION_IS_REF_PIC, ///< feedback current frame is ref pic or not - DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER ///< number of frames remaining in decoder buffer when pictures are required to re-ordered into display-order. - + DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER, ///< number of frames remaining in decoder buffer when pictures are required to re-ordered into display-order. + DECODER_OPTION_NUM_OF_THREADS, ///< number of decoding threads. The maximum thread count is equal or less than lesser of (cpu core counts and 16). } DECODER_OPTION; /** diff --git a/cvendor/include/openh264/codec_def.h b/pkg/codec/openh264/include/openh264/codec_def.h similarity index 99% rename from cvendor/include/openh264/codec_def.h rename to pkg/codec/openh264/include/openh264/codec_def.h index 4f7eb9d8..edde5f4a 100644 --- a/cvendor/include/openh264/codec_def.h +++ b/pkg/codec/openh264/include/openh264/codec_def.h @@ -201,6 +201,7 @@ typedef struct TagBufferInfo { union { SSysMEMBuffer sSystemBuffer; ///< memory info for one picture } UsrData; ///< output buffer info + unsigned char* pDst[3]; //point to picture YUV data } SBufferInfo; diff --git a/cvendor/include/openh264/codec_ver.h b/pkg/codec/openh264/include/openh264/codec_ver.h similarity index 53% rename from cvendor/include/openh264/codec_ver.h rename to pkg/codec/openh264/include/openh264/codec_ver.h index 06d5efcd..a4e494f6 100644 --- a/cvendor/include/openh264/codec_ver.h +++ b/pkg/codec/openh264/include/openh264/codec_ver.h @@ -4,12 +4,12 @@ #include "codec_app_def.h" -static const OpenH264Version g_stCodecVersion = {2, 0, 0, 1905}; -static const char* const g_strCodecVer = "OpenH264 version:2.0.0.1905"; +static const OpenH264Version g_stCodecVersion = {2, 1, 0, 2002}; +static const char* const g_strCodecVer = "OpenH264 version:2.1.0.2002"; #define OPENH264_MAJOR (2) -#define OPENH264_MINOR (0) +#define OPENH264_MINOR (1) #define OPENH264_REVISION (0) -#define OPENH264_RESERVED (1905) +#define OPENH264_RESERVED (2002) #endif // CODEC_VER_H diff --git a/pkg/codec/openh264/lib/libopenh264_darwin_x64.a b/pkg/codec/openh264/lib/libopenh264_darwin_x64.a new file mode 100644 index 00000000..3de6456d Binary files /dev/null and b/pkg/codec/openh264/lib/libopenh264_darwin_x64.a differ diff --git a/pkg/codec/openh264/lib/libopenh264_linux_arm64.a b/pkg/codec/openh264/lib/libopenh264_linux_arm64.a new file mode 100644 index 00000000..e2846ec2 Binary files /dev/null and b/pkg/codec/openh264/lib/libopenh264_linux_arm64.a differ diff --git a/pkg/codec/openh264/lib/libopenh264_linux_armv7.a b/pkg/codec/openh264/lib/libopenh264_linux_armv7.a new file mode 100644 index 00000000..71a91a1f Binary files /dev/null and b/pkg/codec/openh264/lib/libopenh264_linux_armv7.a differ diff --git a/pkg/codec/openh264/lib/libopenh264_linux_x64.a b/pkg/codec/openh264/lib/libopenh264_linux_x64.a new file mode 100644 index 00000000..1f3bdb81 Binary files /dev/null and b/pkg/codec/openh264/lib/libopenh264_linux_x64.a differ diff --git a/pkg/codec/openh264/lib/libopenh264_windows_x64.a b/pkg/codec/openh264/lib/libopenh264_windows_x64.a new file mode 100644 index 00000000..862555a2 Binary files /dev/null and b/pkg/codec/openh264/lib/libopenh264_windows_x64.a differ diff --git a/pkg/codec/openh264/openh264.go b/pkg/codec/openh264/openh264.go index f13e60cb..184a527f 100644 --- a/pkg/codec/openh264/openh264.go +++ b/pkg/codec/openh264/openh264.go @@ -1,7 +1,5 @@ package openh264 -// #cgo CFLAGS: -I${SRCDIR}/../../../cvendor/include -// #cgo CXXFLAGS: -I${SRCDIR}/../../../cvendor/include // #include // #include // #include diff --git a/pkg/codec/openh264/openh264_darwin.go b/pkg/codec/openh264/openh264_darwin.go deleted file mode 100644 index 73d5e357..00000000 --- a/pkg/codec/openh264/openh264_darwin.go +++ /dev/null @@ -1,6 +0,0 @@ -// +build !dynamic - -package openh264 - -// #cgo LDFLAGS: ${SRCDIR}/../../../cvendor/lib/openh264/libopenh264.x86_64-darwin.a -import "C" diff --git a/pkg/codec/openh264/openh264_linux.go b/pkg/codec/openh264/openh264_linux.go deleted file mode 100644 index d2157951..00000000 --- a/pkg/codec/openh264/openh264_linux.go +++ /dev/null @@ -1,6 +0,0 @@ -// +build !dynamic - -package openh264 - -// #cgo LDFLAGS: ${SRCDIR}/../../../cvendor/lib/openh264/libopenh264.x86_64-linux.a -import "C" diff --git a/pkg/codec/openh264/openh264_static.go b/pkg/codec/openh264/openh264_static.go new file mode 100644 index 00000000..31a4f300 --- /dev/null +++ b/pkg/codec/openh264/openh264_static.go @@ -0,0 +1,12 @@ +// +build !dynamic + +package openh264 + +//#cgo CFLAGS: -I${SRCDIR}/include +//#cgo CXXFLAGS: -I${SRCDIR}/include +//#cgo linux,arm LDFLAGS: ${SRCDIR}/lib/libopenh264_linux_armv7.a +//#cgo linux,arm64 LDFLAGS: ${SRCDIR}/lib/libopenh264_linux_arm64.a +//#cgo linux,amd64 LDFLAGS: ${SRCDIR}/lib/libopenh264_linux_x64.a +//#cgo darwin,amd64 LDFLAGS: ${SRCDIR}/lib/libopenh264_darwin_x64.a +//#cgo windows,amd64 LDFLAGS: ${SRCDIR}/lib/libopenh264_windows_x64.a -lssp +import "C" diff --git a/pkg/codec/openh264/openh264_windows.go b/pkg/codec/openh264/openh264_windows.go deleted file mode 100644 index 3b2c8ba1..00000000 --- a/pkg/codec/openh264/openh264_windows.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build !dynamic - -package openh264 - -// #cgo LDFLAGS: ${SRCDIR}/../../../cvendor/lib/openh264/libopenh264.x86_64-windows.a -lssp -// #include -// #include -// #if __MINGW64_VERSION_MAJOR < 6 -// // Workaround for the breaking ABI change between MinGW 5 and 6 -// FILE *__cdecl __acrt_iob_func(unsigned index) { return &(__iob_func()[index]); } -// typedef FILE *__cdecl (*_f__acrt_iob_func)(unsigned index); -// _f__acrt_iob_func __MINGW_IMP_SYMBOL(__acrt_iob_func) = __acrt_iob_func; -// #endif -import "C" diff --git a/scripts/install-dependencies b/scripts/install-dependencies deleted file mode 100755 index 4398c8da..00000000 --- a/scripts/install-dependencies +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess -import shutil -import sys - -TOOLCHAINS = { - 'windows': 'x86_64-w64-mingw32' -} - -TARGET_OS = os.environ.get('GOOS', '') -VALID_TARGETS = TOOLCHAINS.keys() -if TARGET_OS not in VALID_TARGETS: - sys.exit(f'{TARGET_OS} is not in supported targets: {",".join(VALID_TARGETS)}') - -TOOLCHAIN = TOOLCHAINS[TARGET_OS] - -''' -Format: - -Git Dependency: -name: -url: -version: -protocol: 'git' -cmd: - -HTTP Dependency: -name: -url: -extension: -protocol: 'http' -cmd: -''' -DEPENDENCIES = [] -ROOT_DIR = '/tmp' - - -def log(name, description): - print(f'{name}: {description}') - - -def run_cmd(command): - p = subprocess.run(command, shell=True, capture_output=True) - - # If a command fails, exit with the return code with the error message. - if p.returncode != 0: - sys.exit(p.stderr.decode('utf-8')) - - return p - - -def pull_from_git(dependency): - name = dependency['name'] - url = dependency['url'] - version = dependency['version'] - - run_cmd(f'git clone --branch={version} --depth=1 {url} {name}') - install(dependency) - - -def pull_from_http(dependency): - name = dependency['name'] - url = dependency['url'] - extension = dependency['extension'] - tar_name = f'{name}.{extension}' - - run_cmd(f'curl -L {url} > {tar_name}') - shutil.unpack_archive(tar_name, name) - - extracted = os.listdir(name) - - # If it's being wrapped with another folder, we move them - # one level higher so that we have all the source codes in the root - if len(extracted) == 1: - pwd = os.getcwd() - package_folder = os.path.join(pwd, name) - wrapper_folder = os.path.join(package_folder, extracted[0]) - if os.path.isdir(wrapper_folder): - for to_move in os.listdir(wrapper_folder): - src = os.path.join(name, wrapper_folder, to_move) - dst = os.path.join(package_folder, to_move) - shutil.move(src, dst) - - install(dependency) - - -def pull(dependency): - protocol = dependency['protocol'] - name = dependency['name'] - handlers = { - 'http': pull_from_http, - 'git': pull_from_git, - } - - log(name, f'pulling with {protocol} protocol') - return handlers[protocol](dependency) - - -def install(dependency): - name = dependency['name'] - cmd = dependency['cmd'] - - log(name, f'installing') - os.chdir(os.path.join(ROOT_DIR, name)) - run_cmd(cmd) - - -os.chdir(ROOT_DIR) -for dependency in DEPENDENCIES: - pull(dependency) - -print() -print('installed dependencies:') -p = run_cmd('pkg-config --list-all') -print(p.stdout.decode('utf-8')) diff --git a/windows.Dockerfile b/windows.Dockerfile deleted file mode 100644 index 3612c383..00000000 --- a/windows.Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM fedora - -ENV PYTHONUNBUFFERED=1 \ - # Somehow libopus.dll is installed under /usr/local/bin, so we need to add this - # path to WINEPATH so that wine can find this library - WINEPATH=/usr/local/bin \ - # Go and C default environments - GOOS=windows \ - GOARCH=amd64 \ - CGO_ENABLED=1 \ - GO111MODULE=on \ - CC=x86_64-w64-mingw32-gcc \ - CXX=x86_64-w64-mingw32-g++ - -COPY scripts /usr/bin/ - -RUN dnf install -y \ - diffutils \ - golang \ - make \ - mingw64-gcc \ - mingw64-gcc-c++ \ - mingw64-opus && \ - nasm \ - pkg-config \ - python3 \ - wine \ - dnf clean all && \ - install-dependencies && \ - rm -rf /tmp/* - -VOLUME /go/src/github.com/pion/mediadevices -WORKDIR /go/src/github.com/pion/mediadevices \ No newline at end of file