36b8f289创建于 3月26日历史提交
# Copyright (c) 2026 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

pkgname=librtmp
pkgver=6f6bb1353fc84f4cc37138baa99f586750028a01
pkgrel=0
pkgdesc="rtmpdump is a toolkit for RTMP streams. All forms of RTMP are supported, including rtmp://, rtmpt://, rtmpe://, rtmpte://, and rtmps://."
url="http://rtmpdump.mplayerhq.hu/"
archs=("armeabi-v7a" "arm64-v8a" "x86_64")
license=("LGPL")
depends=("openssl_3.4.3")
makedepends=()

#source="http://rtmpdump.mplayerhq.hu/download/$pkgname-$pkgver.tgz"
#没有tag,用commit id
source="https://github.com/mirror/rtmpdump/archive/$pkgver.zip"

autounpack=true
downloadpackage=true
buildtools="make"

builddir=rtmpdump-${pkgver}
packagename=$builddir.zip

libdir=lib
opensslver=openssl_3.4.3
source envset.sh

prepare() {
    echo $packagename
    cp -rf $builddir $builddir-$ARCH-build
    cd $builddir-$ARCH-build

    if [ -f ../test_librtmp.patch ]; then
        patch -p1 < ../test_librtmp.patch >> $buildlog 2>&1
    fi

    if [ $ARCH == "armeabi-v7a" ]; then
        setarm32ENV
    elif [ $ARCH == "arm64-v8a" ]; then
        setarm64ENV
    elif [ $ARCH == "x86_64" ]; then
        setx86_64ENV
        libdir=lib64
    else
        echo "${ARCH} not support"
        return -1
    fi
    ld=${OHOS_SDK}/native/llvm/bin/ld.lld
    ar=${OHOS_SDK}/native/llvm/bin/llvm-ar
    cd $OLDPWD
}

build() {
    cd $builddir-$ARCH-build

    $MAKE SHARED=no CC="$CC" AR="$AR" LD="$LD" \
            XCFLAGS="-D__MUSL__=1 -I$LYCIUM_ROOT/usr/$opensslver/$ARCH/include" \
            XLDFLAGS="-L$LYCIUM_ROOT/usr/$opensslver/$ARCH/$libdir" > $buildlog 2>&1
    ret=$?
    if [ $ret -eq 0 ]; then
        $CXX test_librtmp.cpp -o test_librtmp \
            -I. \
            -I$LYCIUM_ROOT/usr/$opensslver/$ARCH/include \
            -L./librtmp \
            -L$LYCIUM_ROOT/usr/$opensslver/$ARCH/$libdir \
            -lrtmp -lssl -lcrypto -lz -pthread >> $buildlog 2>&1
        ret=$?
    fi
    cd $OLDPWD
    return $ret
}

package() {
    cd $builddir-$ARCH-build
    $MAKE SHARED=no LDFLAGS="-L$LYCIUM_ROOT/usr/$opensslver/$ARCH/$libdir" install prefix=$LYCIUM_ROOT/usr/$pkgname/$ARCH >> $buildlog 2>&1
    ret=$?
    cd $OLDPWD
    return $ret
}

check() {
    echo "The test must be on an OpenHarmony device!"
}

recoverpkgbuildenv() {
    if [ $ARCH == "armeabi-v7a" ]; then
        unsetarm32ENV
    elif [ $ARCH == "arm64-v8a" ]; then
        unsetarm64ENV
    elif [ $ARCH == "x86_64" ]; then
        unsetx86_64ENV
    fi
}

# 清理环境
cleanbuild() {
    rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build  $builddir-arm64-v8a-build $builddir-x86_64-build# ${PWD}/$packagename
}