diff --git a/.github/workflows/RockyArm64_build.yml b/.github/workflows/RockyArm64_build.yml deleted file mode 100644 index a07eaa0..0000000 --- a/.github/workflows/RockyArm64_build.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: rocky Arm64 build workflows - -on: - push: - branches: - - 'develop' - paths: - - 'XEngine_Source/**' - - 'XEngine_Release/**' - - '.github/**' - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-24.04 - env: - IMAGE_NAME: rockylinux/rockylinux:9.5 - - strategy: - fail-fast: false - matrix: - arch: [linux/arm64] - - steps: - # 检出您的主仓库代码 - - name: Checkout main repository code - uses: actions/checkout@v4 - with: - ref: 'develop' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Build ${{ matrix.arch }} - run: | - docker run --platform ${{ matrix.arch }} --rm \ - -v ${{ github.workspace }}:/workspace \ - -w /workspace ${{ env.IMAGE_NAME }} /bin/sh -c ' - set -e - dnf update -y - dnf install --allowerasing git make g++ wget curl jq unzip -y - - git config --global --add safe.directory /workspace - git submodule init - git submodule update - - latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) - wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_RockyLinux_9_Arm64.zip - unzip ./XEngine_RockyLinux_9_Arm64.zip -d ./XEngine_RockyLinux_9_Arm64 - cd XEngine_RockyLinux_9_Arm64 - - chmod 777 ./XEngine_LINEnv.sh - ./XEngine_LINEnv.sh -i 0 - - dnf install libsrtp-devel srt-devel -y - - cp -rf ./XEngine_Include /usr/local/include - find ./XEngine_Linux -name "*.so" -exec cp {} /usr/lib64 \; - ldconfig - cd .. - - cd XEngine_Source - make ARCH=Arm64 RELEASE=1 - make FLAGS=InstallAll - make FLAGS=CleanAll - cd .. - - cd XEngine_Release - ./XEngine_StreamMediaApp -t - chown -R $(id -u):$(id -g) . - chmod -R a+r . ' - - - name: Upload folder as artifact with RockyLinux - uses: actions/upload-artifact@v4 - with: - name: XEngine_StreamMediaApp-RockyLinux_9_Arm64 - path: XEngine_Release/ - retention-days: 1 diff --git a/.github/workflows/Rocky_build.yml b/.github/workflows/Rocky_build.yml new file mode 100644 index 0000000..d3376a8 --- /dev/null +++ b/.github/workflows/Rocky_build.yml @@ -0,0 +1,106 @@ +name: rocky build workflows + +on: + push: + branches: + - develop + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' + - '.github/**' + +permissions: + contents: read + +jobs: + build: + runs-on: ${{ matrix.runner }} + container: + image: rockylinux/rockylinux:${{ matrix.version }} + options: --platform ${{ matrix.platform }} + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + artifact: x86-64 + version: 9 + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + artifact: x86-64 + version: 10 + - arch: arm64 + runner: ubuntu-24.04-arm + platform: linux/arm64 + artifact: Arm64 + version: 9 + - arch: arm64 + runner: ubuntu-24.04-arm + platform: linux/arm64 + artifact: Arm64 + version: 10 + + steps: + - name: Checkout main repository code + uses: actions/checkout@v4 + with: + ref: 'develop' + + - name: Checkout dependency repository (xengine) + uses: actions/checkout@v4 + with: + repository: libxengine/libxengine + path: libxengine + + - name: sub module checkout (opensource) + uses: actions/checkout@v4 + with: + repository: libxengine/XEngine_OPenSource + path: XEngine_Source/XEngine_DependLibrary + + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + + - name: install system package + run: | + dnf clean all + dnf makecache + dnf distro-sync -y + dnf update -y + dnf install gcc g++ make git jq unzip wget -y + - name: install xengine library + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_RockyLinux_${{ matrix.version }}_${{ matrix.artifact }}.zip + unzip ./XEngine_RockyLinux_${{ matrix.version }}_${{ matrix.artifact }}.zip -d ./XEngine_RockyLinux_${{ matrix.version }}_${{ matrix.artifact }} + cd XEngine_RockyLinux_${{ matrix.version }}_${{ matrix.artifact }} + + chmod 777 * + ./XEngine_LINEnv.sh -i 3 + - name: install depend library + run: dnf install libsrtp-devel srt-devel -y + + - name: make + run: | + cd XEngine_Source + make + make FLAGS=InstallAll + make FLAGS=CleanAll + + make RELEASE=1 + make FLAGS=InstallAll + make FLAGS=CleanAll + + - name: test + run: | + cd XEngine_Release + ./XEngine_StreamMediaApp -t + + - name: Upload folder as artifact with RockyLinux + uses: actions/upload-artifact@v4 + with: + name: XEngine_StreamMediaApp-RockyLinux_${{ matrix.version }}_${{ matrix.artifact }} + path: XEngine_Release/ + retention-days: 1 diff --git a/.github/workflows/UbuntuArm64_build.yml b/.github/workflows/UbuntuArm64_build.yml deleted file mode 100644 index f564013..0000000 --- a/.github/workflows/UbuntuArm64_build.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: ubuntu Arm64 build workflows - -on: - push: - branches: - - 'develop' - paths: - - 'XEngine_Source/**' - - 'XEngine_Release/**' - - '.github/**' - -jobs: - build: - runs-on: ubuntu-24.04 - env: - IMAGE_NAME: ubuntu:24.04 - - strategy: - fail-fast: false - matrix: - arch: [linux/arm64] - - steps: - - name: Checkout main repository code - uses: actions/checkout@v4 - with: - ref: 'develop' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Build ${{ matrix.arch }} - run: | - docker run --platform ${{ matrix.arch }} --rm \ - -v ${{ github.workspace }}:/workspace \ - -w /workspace ${{ env.IMAGE_NAME }} /bin/sh -c ' - set -e - apt update -y - apt install git make g++ wget curl jq unzip -y - apt install libsrt-gnutls-dev libsrtp2-dev -y - - git config --global --add safe.directory /workspace - git submodule init - git submodule update - - latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) - wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_24.04_Arm64.zip - unzip ./XEngine_UBuntu_24.04_Arm64.zip -d ./XEngine_UBuntu_24.04_Arm64 - cd XEngine_UBuntu_24.04_Arm64 - - chmod 777 ./XEngine_LINEnv.sh - ./XEngine_LINEnv.sh -i 0 - - cp -rf ./XEngine_Include /usr/local/include - find ./XEngine_Linux -name "*.so" -exec cp {} /usr/local/lib \; - ldconfig - cd .. - - cd XEngine_Source - make ARCH=Arm64 RELEASE=1 - make FLAGS=InstallAll - make FLAGS=CleanAll - cd .. - - cd XEngine_Release - ./XEngine_StreamMediaApp -t - chown -R $(id -u):$(id -g) . - chmod -R a+r . ' - - - name: Upload folder as artifact with ubuntu Arm64 - uses: actions/upload-artifact@v4 - with: - name: XEngine_StreamMediaApp-Ubuntu_24.04_Arm64 - path: XEngine_Release/ - retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 265c9b2..68215a0 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -3,7 +3,7 @@ name: CodeQL Advanced on: push: branches: - - 'develop' + - develop paths: - 'XEngine_Source/**' - 'XEngine_Release/**' @@ -40,6 +40,9 @@ jobs: git submodule init git submodule update + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + - name: Set up Dependency Environment run: | cd libxengine diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 279b03f..f21ee6e 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -3,7 +3,7 @@ name: cpp check workflows on: push: branches: - - 'develop' + - develop paths: - 'XEngine_Source/**' - 'XEngine_Release/**' diff --git a/.github/workflows/RockyX86_64_build.yml b/.github/workflows/debian_build.yml similarity index 55% rename from .github/workflows/RockyX86_64_build.yml rename to .github/workflows/debian_build.yml index de5c3a7..94031c2 100644 --- a/.github/workflows/RockyX86_64_build.yml +++ b/.github/workflows/debian_build.yml @@ -1,31 +1,37 @@ -name: rocky x86_64 build workflows +name: debian build workflows on: push: - branches: - - 'develop' + branches: + - develop paths: - 'XEngine_Source/**' - 'XEngine_Release/**' - '.github/**' - + permissions: contents: read - + jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.runner }} container: - image: rockylinux/rockylinux:9.5 + image: debian:bookworm + options: --platform ${{ matrix.platform }} + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + artifact: x86-64 steps: - # 检出您的主仓库代码 - name: Checkout main repository code uses: actions/checkout@v4 with: ref: 'develop' - - # 检出依赖的xengine仓库到指定的xengine目录 + - name: Checkout dependency repository (xengine) uses: actions/checkout@v4 with: @@ -36,33 +42,28 @@ jobs: uses: actions/checkout@v4 with: repository: libxengine/XEngine_OPenSource - path: XEngine_Source/XEngine_Depend + path: XEngine_Source/XEngine_DependLibrary + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + - name: install system package run: | - dnf update -y - dnf install gcc g++ make git jq unzip -y - # 设置依赖库的环境变量 - - name: Set up Dependency rocky linux Environment - run: | - cd libxengine - chmod 777 * - ./XEngine_LINEnv.sh -i 0 - dnf install libsrtp-devel srt-devel -y - + apt update -y + apt install gcc g++ make git jq unzip curl wget -y + apt install libsrt-gnutls-dev libsrtp2-dev -y + - name: install xengine library - run: | + run: | latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) - wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_RockyLinux_9_x86-64.zip - unzip ./XEngine_RockyLinux_9_x86-64.zip -d ./XEngine_RockyLinux_9_x86-64 - cd XEngine_RockyLinux_9_x86-64 + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Debian_12_${{ matrix.artifact }}.zip + unzip ./XEngine_Debian_12_${{ matrix.artifact }}.zip -d ./XEngine_Debian_12_${{ matrix.artifact }} + cd XEngine_Debian_12_${{ matrix.artifact }} - cp -rf ./XEngine_Include /usr/local/include - find ./XEngine_Linux -name "*.so" -exec cp {} /usr/lib64 \; - ldconfig - + chmod 777 * + ./XEngine_LINEnv.sh -i 3 - name: make - run: | + run: | cd XEngine_Source make make FLAGS=InstallAll @@ -71,15 +72,15 @@ jobs: make RELEASE=1 make FLAGS=InstallAll make FLAGS=CleanAll - + cd .. - name: test run: | cd XEngine_Release ./XEngine_StreamMediaApp -t - - name: Upload folder as artifact with RockyLinux + - name: Upload folder as artifact uses: actions/upload-artifact@v4 with: - name: XEngine_StreamMediaApp-RockyLinux_9_x86_64 + name: XEngine_StreamMediaApp-Debian_12_x86-64 path: XEngine_Release/ - retention-days: 1 + retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/fedora_build.yml b/.github/workflows/fedora_build.yml new file mode 100644 index 0000000..16206d3 --- /dev/null +++ b/.github/workflows/fedora_build.yml @@ -0,0 +1,90 @@ +name: fedora build workflows + +on: + push: + branches: + - develop + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' + - '.github/**' + +permissions: + contents: read + +jobs: + build: + runs-on: ${{ matrix.runner }} + container: + image: fedora:${{ matrix.fedora-version }} + options: --platform ${{ matrix.platform }} + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + fedora-version: 42 + artifact: x86-64 + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + fedora-version: 41 + artifact: x86-64 + + steps: + - name: Checkout main repository code + uses: actions/checkout@v4 + + - name: Checkout dependency repository (xengine) + uses: actions/checkout@v4 + with: + repository: libxengine/libxengine + path: libxengine + + - name: sub module checkout (opensource) + uses: actions/checkout@v4 + with: + repository: libxengine/XEngine_OPenSource + path: XEngine_Source/XEngine_DependLibrary + + - name: install system package + run: | + dnf update -y + dnf install gcc g++ make git jq unzip wget -y + dnf install libsrtp-devel srt-devel -y + + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + + - name: install xengine library + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }}.zip + unzip ./XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }}.zip -d ./XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }} + cd XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }} + + chmod 777 * + ./XEngine_LINEnv.sh -i 3 + - name: make + run: | + cd XEngine_Source + make + make FLAGS=InstallAll + make FLAGS=CleanAll + + make RELEASE=1 + make FLAGS=InstallAll + make FLAGS=CleanAll + cd .. + - name: test + run: | + cd XEngine_Release + ./XEngine_StreamMediaApp -t + + - name: Upload folder as artifact + uses: actions/upload-artifact@v4 + with: + name: XEngine_XEngine_StreamMediaAppProxyServiceApp-Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }} + path: XEngine_Release/ + retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/macbuild.yml b/.github/workflows/macbuild.yml index 2e814f0..f1296eb 100644 --- a/.github/workflows/macbuild.yml +++ b/.github/workflows/macbuild.yml @@ -3,7 +3,7 @@ name: macos build workflows on: push: branches: - - 'develop' + - develop paths: - 'XEngine_Source/**' - 'XEngine_Release/**' @@ -44,6 +44,9 @@ jobs: - name: install library run: brew install srt srtp + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + - name: Set up Dependency x86_64 Environment if: matrix.os == 'macos-13' run: | @@ -53,19 +56,13 @@ jobs: - name: Set up Dependency Arm64 Environment if: matrix.os == 'macos-14' run: | - cd libxengine - chmod 777 * - ./XEngine_LINEnv.sh -i 0 - latest_tag=$(git ls-remote --tags --sort="v:refname" https://github.com/libxengine/libxengine.git | awk '{print $2}' | sed 's/refs\/tags\///' | tail -n 1) wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Mac_Arm64.zip unzip ./XEngine_Mac_Arm64.zip -d ./XEngine_Mac_Arm64 cd XEngine_Mac_Arm64 - sudo mkdir -p /usr/local/include - sudo mkdir -p /usr/local/lib - sudo cp -rf ./XEngine_Include /usr/local/include - sudo find ./XEngine_Mac -name "*.dylib" -exec cp {} /usr/local/lib \; + chmod 777 * + ./XEngine_LINEnv.sh -i 3 - name: make debug run: | @@ -76,14 +73,14 @@ jobs: - name: make release run: | cd XEngine_Source - make PLATFORM=mac RELEASE=1 + make PLATFORM=mac RELEASE=0 make PLATFORM=mac FLAGS=InstallAll make PLATFORM=mac FLAGS=CleanAll - name: test (srt bug on macos,not run) run: | cd XEngine_Release - ./XEngine_StreamMediaApp -t + #./XEngine_StreamMediaApp -t - name: Upload folder as artifact with mac x64 if: matrix.os == 'macos-13' diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 7795dc7..5772171 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -3,7 +3,7 @@ name: windows build workflows on: push: branches: - - 'develop' + - develop paths: - 'XEngine_Source/**' - 'XEngine_Release/**' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99bd874..46e80dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,37 +15,37 @@ jobs: with: fetch-depth: 0 - - name: Download x86_64 ubuntu build + - name: Download ubuntu build uses: dawidd6/action-download-artifact@v6 with: - workflow: ubuntux86_64_build.yml + workflow: ubuntu_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true if_no_artifact_found: fail path: ./XRelease/ - - name: Download Arm64 ubuntu build + - name: Download debian build uses: dawidd6/action-download-artifact@v6 with: - workflow: UbuntuArm64_build.yml + workflow: debian_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true if_no_artifact_found: fail path: ./XRelease/ - - name: Download x86_64 rockylinux build + - name: Download fedora build uses: dawidd6/action-download-artifact@v6 with: - workflow: RockyX86_64_build.yml + workflow: fedora_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true if_no_artifact_found: fail path: ./XRelease/ - - name: Download Arm64 rockylinux build + - name: Download Rocky build uses: dawidd6/action-download-artifact@v6 with: - workflow: RockyArm64_build.yml + workflow: Rocky_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true @@ -85,7 +85,7 @@ jobs: build=$(echo $latest_tag | cut -d '.' -f 4) new_minor=$((patch + 1)) - new_version="$major.$minor.$new_minor.$build" + new_version="$major.$new_minor.$patch.$build" echo "New version: $new_version" echo "new_tag=$new_version" >> $GITHUB_OUTPUT echo "prev_tag=$latest_tag" >> $GITHUB_OUTPUT diff --git a/.github/workflows/ubuntux86_64_build.yml b/.github/workflows/ubuntu_build.yml similarity index 54% rename from .github/workflows/ubuntux86_64_build.yml rename to .github/workflows/ubuntu_build.yml index 3516963..06356ec 100644 --- a/.github/workflows/ubuntux86_64_build.yml +++ b/.github/workflows/ubuntu_build.yml @@ -3,7 +3,7 @@ name: ubuntu build workflows on: push: branches: - - 'develop' + - develop paths: - 'XEngine_Source/**' - 'XEngine_Release/**' @@ -21,6 +21,8 @@ jobs: include: - os: ubuntu-22.04 - os: ubuntu-24.04 + - os: ubuntu-22.04-arm + - os: ubuntu-24.04-arm runs-on: ${{ matrix.os }} steps: @@ -45,27 +47,45 @@ jobs: - name: install library run: sudo apt install libsrt-gnutls-dev libsrtp2-dev -y - - name: Set up Dependency ubuntu24.04 Environment + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + + - name: Set up Dependency ubuntu24.04 x86-64 Environment if: matrix.os == 'ubuntu-24.04' run: | cd libxengine chmod 777 * sudo ./XEngine_LINEnv.sh -i 3 - - name: Set up Dependency ubuntu22.04 Environment + - name: Set up Dependency ubuntu22.04 x86-64 Environment if: matrix.os == 'ubuntu-22.04' run: | - cd libxengine - chmod 777 * - sudo ./XEngine_LINEnv.sh -i 0 - latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_22.04_x86-64.zip unzip ./XEngine_UBuntu_22.04_x86-64.zip -d ./XEngine_UBuntu_22.04_x86-64 cd XEngine_UBuntu_22.04_x86-64 - sudo cp -rf ./XEngine_Include /usr/local/include - sudo find ./XEngine_Linux -name "*.so" -exec cp {} /usr/local/lib \; - sudo ldconfig + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 3 + - name: Set up Dependency ubuntu22.04 Arm64 Environment + if: matrix.os == 'ubuntu-22.04-arm' + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_22.04_Arm64.zip + unzip ./XEngine_UBuntu_22.04_Arm64.zip -d ./XEngine_UBuntu_22.04_Arm64 + cd XEngine_UBuntu_22.04_Arm64 + + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 3 + - name: Set up Dependency ubuntu24.04 Arm64 Environment + if: matrix.os == 'ubuntu-24.04-arm' + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_24.04_Arm64.zip + unzip ./XEngine_UBuntu_24.04_Arm64.zip -d ./XEngine_UBuntu_24.04_Arm64 + cd XEngine_UBuntu_24.04_Arm64 + + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 3 - name: make run: | @@ -83,17 +103,31 @@ jobs: cd XEngine_Release ./XEngine_StreamMediaApp -t - - name: Upload folder as artifact with ubuntu22.04 + - name: Upload folder as artifact with ubuntu22.04-x86-64 if: matrix.os == 'ubuntu-22.04' uses: actions/upload-artifact@v4 with: name: XEngine_StreamMediaApp-Ubuntu_22.04_x86_64 path: XEngine_Release/ retention-days: 1 - - name: Upload folder as artifact with ubuntu24.04 + - name: Upload folder as artifact with ubuntu24.04-x86-64 if: matrix.os == 'ubuntu-24.04' uses: actions/upload-artifact@v4 with: name: XEngine_StreamMediaApp-Ubuntu_24.04_x86_64 path: XEngine_Release/ + retention-days: 1 + - name: Upload folder as artifact with ubuntu22.04-arm + if: matrix.os == 'ubuntu-22.04-arm' + uses: actions/upload-artifact@v4 + with: + name: XEngine_StreamMediaApp-Ubuntu_22.04_Arm64 + path: XEngine_Release/ + retention-days: 1 + - name: Upload folder as artifact with ubuntu24.04-arm + if: matrix.os == 'ubuntu-24.04-arm' + uses: actions/upload-artifact@v4 + with: + name: XEngine_StreamMediaApp-Ubuntu_24.04_Arm64 + path: XEngine_Release/ retention-days: 1 \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 1cc1974..3949a92 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "XEngine_Source/XEngine_Depend"] - path = XEngine_Source/XEngine_Depend + path = XEngine_Source/XEngine_DependLibrary url = https://github.com/libxengine/XEngine_OPenSource.git diff --git a/CHANGELOG b/CHANGELOG index fc79fc3..2f0160b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,27 @@ +XEngine_StreamMedia V2.12.0.1001 + +added:webrtc push stream test code +added:configure log level support +added:ci rocky linux 10 support +update:depend library +improved:make file build flags +modify:bcd codec support +modify:start parameter are not case sensitive +modify:Move submodule XEngine_Depend to XEngine_DependLibrary +fixed:configure parse failed +fixed:report info not time count + +增加:webrtc 推流测试服务代码 +增加:配置日志级别支持 +增加:CI的rockylinux10系统支持 +更新:依赖库 +优化:构建编译脚本选项 +修改:bcd编码支持 +修改:启动参数不区分大小写 +修改:移动子模块目录到新的文件夹 +修正:配置解析错误 +修正:报告信息没有统计的问题 +======================================================= XEngine_StreamMedia V2.11.1.1001 修正:rtmp推流CSID处理不正确导致推流不正确的问题 diff --git a/README.en.md b/README.en.md index 06b75dc..5bdfaa1 100644 --- a/README.en.md +++ b/README.en.md @@ -35,7 +35,7 @@ Publish Stream: | -------- | --------- | -------- | -------- | | RTMP | H264 | AAC | Completed | | SRT | H264 | AAC | Completed | -| WEBRTC | H264 | OPUS | Not Start | +| WEBRTC | H264 | OPUS | Processing | | GB28181 | H264 | AAC | Not Start | | JT1078 | H264 | AAC | Completed | | XStream | H264 | AAC | Completed | @@ -67,7 +67,7 @@ Linux Exection:sudo ./XEngine_LINEnv.sh -i 3 Macos Exection:./XEngine_LINEnv.sh -i 3 #### sub module -Due to the dependent sub-modules, after you checkout the warehouse, execute the following command in the warehouse directory to pull the sub-modules +Due to the dependent sub-modules, after you checkout the resprepository, execute the following command in the resprepository directory to pull the sub-modules git submodule init git submodule update diff --git a/README.md b/README.md index ffb1b12..2073f4c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ c c++ streammedia server | -------- | --------- | -------- | -------- | | RTMP | H264 | AAC | 已完成 | | SRT | H264 | AAC | 已完成 | -| WEBRTC | H264 | OPUS | 未开始 | +| WEBRTC | H264 | OPUS | 进行中 | | GB28181 | H264 | AAC | 未开始 | | JT1078 | H264 | AAC | 已完成 | | XStream | H264 | AAC | 已完成 | @@ -75,7 +75,7 @@ macos执行:./XEngine_LINEnv.sh -i 3 由于依赖的子模块,在你checkout仓库后,在仓库目录下执行下面的命令拉取子模块 git submodule init git submodule update -如果github访问失败,你也可以clone该项目,在主目录下使用命令:git clone https://gitee.com/xengine/XEngine_OPenSource.git XEngine_Source/XEngine_Depend +如果github访问失败,你也可以clone该项目,在主目录下使用命令:git clone https://gitee.com/xengine/XEngine_OPenSource.git XEngine_Source/XEngine_DependLibrary #### Windows diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json index d3e9688..6e14b45 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Config.json +++ b/XEngine_Release/XEngine_Config/XEngine_Config.json @@ -1,13 +1,14 @@ { "tszSMSUrl": "rtmp://app.xyry.org/live", - "tszIPAddr": "10.0.1.88", + "tszIPAddr": "127.0.0.1", "bDeamon": 0, "nRTMPPort": 1935, "nHttpPort": 5600, "nXStreamPort": 5601, "nJT1078Port": 5602, "nSrtPort": 5603, - "nRTCPort": 5604, + "nRTCWhepPort": 5604, + "nRTCWhipPort": 5605, "XMax": { "nMaxClient": 10000, "nMaxQueue": 10000, @@ -48,7 +49,7 @@ "nARTCPPort": 56004 }, "RTC": { - "bEnable": false, + "bEnable": true, "bPrePull": false, "tszICEUser": "xengine", "tszICEPass": "3321308h8i6vt3769r6638l1409d50jz", diff --git a/XEngine_Release/XEngine_Config/XEngine_Version.json b/XEngine_Release/XEngine_Config/XEngine_Version.json index fb4e6f9..f7739c4 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Version.json +++ b/XEngine_Release/XEngine_Config/XEngine_Version.json @@ -1,5 +1,6 @@ { "XVer": [ + "V2.12.0.1001 Build20250815", "V2.11.1.1001 Build20250409", "V2.11.0.1001 Build20250426", "V2.10.0.1001 Build20250124", diff --git a/XEngine_Release/XEngine_Key/server.der b/XEngine_Release/XEngine_Key/server.der new file mode 100644 index 0000000..58087cc Binary files /dev/null and b/XEngine_Release/XEngine_Key/server.der differ diff --git a/XEngine_Source/Makefile b/XEngine_Source/Makefile index 281a075..1ba3576 100644 --- a/XEngine_Source/Makefile +++ b/XEngine_Source/Makefile @@ -3,8 +3,8 @@ UNICODE = 0 PLATFORM=linux FLAGS= #要编译的模块 -THIRDPART_MODULE_JSONCPP = ./XEngine_Depend/XEngine_Module/jsoncpp -THIRDPART_MODULE_REPORT = ./XEngine_Depend/XEngine_Module/XEngine_InfoReport +THIRDPART_MODULE_JSONCPP = ./XEngine_DependLibrary/XEngine_Module/jsoncpp +THIRDPART_MODULE_REPORT = ./XEngine_DependLibrary/XEngine_Module/XEngine_InfoReport MODULE_CONFIGURE_PATH = ./XEngine_ModuleConfigure MODULE_HELP_PATH = ./XEngine_ModuleHelp @@ -32,25 +32,25 @@ libjsoncpp.so: ifeq ($(FLAGS), InstallAll) cp $(THIRDPART_MODULE_JSONCPP)/libjsoncpp.$(FILEEXT) ../XEngine_Release/ else - make -C $(THIRDPART_MODULE_JSONCPP) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(THIRDPART_MODULE_JSONCPP) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) endif libXEngine_InfoReport.so: ifeq ($(FLAGS), InstallAll) cp $(THIRDPART_MODULE_REPORT)/libXEngine_InfoReport.$(FILEEXT) ../XEngine_Release/ else - make -C $(THIRDPART_MODULE_REPORT) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(THIRDPART_MODULE_REPORT) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) endif libXEngine_ModuleConfigure.so: - make -C $(MODULE_CONFIGURE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(MODULE_CONFIGURE_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) libXEngine_ModuleHelp.so: - make -C $(MODULE_HELP_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(MODULE_HELP_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) libXEngine_ModuleProtocol.so: - make -C $(MODULE_PROTOCOL_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(MODULE_PROTOCOL_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) libXEngine_ModuleSession.so: - make -C $(MODULE_SESSION_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(MODULE_SESSION_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) libXEngine_ModuleQueue.so: - make -C $(MODULE_QUEUE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(MODULE_QUEUE_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) XEngine_StreamMediaApp.exe: - make -C $(APP_STREAMMEDIA_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(APP_STREAMMEDIA_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) diff --git a/XEngine_Source/XEngine.sln b/XEngine_Source/XEngine.sln index cfdc81a..bc16292 100644 --- a/XEngine_Source/XEngine.sln +++ b/XEngine_Source/XEngine.sln @@ -38,11 +38,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_StreamMediaApp", "X EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_ModuleQueue", "XEngine_ModuleQueue\XEngine_ModuleQueue.vcxproj", "{9FF6FA78-456E-4A7E-86B1-17E4DB5403C9}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "XEngine_Depend", "XEngine_Depend", "{6A753FB6-282E-4E86-91BB-BE97618B65A4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "XEngine_DependLibrary", "XEngine_DependLibrary", "{6A753FB6-282E-4E86-91BB-BE97618B65A4}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsoncpp", "XEngine_Depend\XEngine_Module\jsoncpp\jsoncpp.vcxproj", "{F1736B3F-03A2-4FC7-B045-A12BA8D724FB}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsoncpp", "XEngine_DependLibrary\XEngine_Module\jsoncpp\jsoncpp.vcxproj", "{F1736B3F-03A2-4FC7-B045-A12BA8D724FB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_InfoReport", "XEngine_Depend\XEngine_Module\XEngine_InfoReport\XEngine_InfoReport.vcxproj", "{F6520D2C-BB8E-45BB-964B-F5D6A4318A89}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_InfoReport", "XEngine_DependLibrary\XEngine_Module\XEngine_InfoReport\XEngine_InfoReport.vcxproj", "{F6520D2C-BB8E-45BB-964B-F5D6A4318A89}" ProjectSection(ProjectDependencies) = postProject {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} EndProjectSection diff --git a/XEngine_Source/XEngine_Depend b/XEngine_Source/XEngine_Depend deleted file mode 160000 index fda9f7d..0000000 --- a/XEngine_Source/XEngine_Depend +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fda9f7d9140cc6a32eecb499e2acb67e8e1c7e6f diff --git a/XEngine_Source/XEngine_DependLibrary b/XEngine_Source/XEngine_DependLibrary new file mode 160000 index 0000000..269830b --- /dev/null +++ b/XEngine_Source/XEngine_DependLibrary @@ -0,0 +1 @@ +Subproject commit 269830be96d7e95646ce43533294156063178509 diff --git a/XEngine_Source/XEngine_ModuleConfigure/Makefile b/XEngine_Source/XEngine_ModuleConfigure/Makefile index 55722b1..5471e07 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/Makefile +++ b/XEngine_Source/XEngine_ModuleConfigure/Makefile @@ -1,43 +1,37 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 -LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp -LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp +LOADHDR = -I ./ -I ../XEngine_DependLibrary/XEngine_Module/jsoncpp +LOADSO = -L ../XEngine_DependLibrary/XEngine_Module/jsoncpp LIB = -ljsoncpp LIBEX = OBJECTS = ModuleConfigure_Json.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h index 8868fc4..c9b137d 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h @@ -15,7 +15,7 @@ ////////////////////////////////////////////////////////////////////////// typedef struct tag_XEngine_ServiceConfig { - XCHAR tszSMSUrl[MAX_PATH]; //流媒体服务器地址 + XCHAR tszSMSUrl[XPATH_MAX]; //流媒体服务器地址 XCHAR tszIPAddr[128]; //本机IP地址,根据需要配置 bool bDeamon; //是否以守护进程启动,LINUX有效 bool bDebug; //是否使用DEBUG @@ -24,7 +24,8 @@ typedef struct tag_XEngine_ServiceConfig int nXStreamPort; //X流协议服务 int nJT1078Port; //JT1078协议流支持 int nSrtPort; //srt协议端口 - int nRTCPort; //webrtc推拉流端口 + int nRTCWhepPort; //webrtc 拉流端口 + int nRTCWhipPort; //webrtc 推流端口 struct { int nMaxClient; //最大客户端个数 @@ -47,7 +48,7 @@ typedef struct tag_XEngine_ServiceConfig }st_XTime; //次数*时间=超时 struct { - XCHAR tszLogFile[MAX_PATH]; + XCHAR tszLogFile[XPATH_MAX]; int nMaxSize; //最大日志大小 int nMaxCount; //最大日志个数 int nLogLeave; //日志等级 @@ -73,7 +74,7 @@ typedef struct tag_XEngine_ServiceConfig }st_PullFlv; struct { - XCHAR tszHLSPath[MAX_PATH]; + XCHAR tszHLSPath[XPATH_MAX]; int nTime; bool bEnable; bool bPrePull; @@ -100,18 +101,18 @@ typedef struct tag_XEngine_ServiceConfig }st_PullRtsp; struct { - XCHAR tszICEUser[MAX_PATH]; - XCHAR tszICEPass[MAX_PATH]; - XCHAR tszCertStr[MAX_PATH]; - XCHAR tszKeyStr[MAX_PATH]; - XCHAR tszDerStr[MAX_PATH]; + XCHAR tszICEUser[XPATH_MAX]; + XCHAR tszICEPass[XPATH_MAX]; + XCHAR tszCertStr[XPATH_MAX]; + XCHAR tszKeyStr[XPATH_MAX]; + XCHAR tszDerStr[XPATH_MAX]; bool bEnable; bool bPrePull; }st_PullWebRtc; }st_XPull; struct { - XCHAR tszAPIUrl[MAX_PATH]; + XCHAR tszAPIUrl[XPATH_MAX]; XCHAR tszServiceName[128]; bool bEnable; }st_XReport; diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp index e3b4cee..ec4e1b2 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp @@ -61,21 +61,12 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_OPENFILE; return false; } - size_t nCount = 0; - XCHAR tszMsgBuffer[4096]; - while (1) - { - size_t nRet = fread(tszMsgBuffer + nCount, 1, 2048, pSt_File); - if (nRet <= 0) - { - break; - } - nCount += nRet; - } + XCHAR tszMsgBuffer[8192] = {}; + size_t nRet = fread(tszMsgBuffer, 1, sizeof(tszMsgBuffer), pSt_File); fclose(pSt_File); //开始解析配置文件 std::unique_ptr const pSt_JsonReader(st_JsonBuilder.newCharReader()); - if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nCount, &st_JsonRoot, &st_JsonError)) + if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nRet, &st_JsonRoot, &st_JsonError)) { Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_PARSE; @@ -84,13 +75,13 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE _tcsxcpy(pSt_ServerConfig->tszSMSUrl, st_JsonRoot["tszSMSUrl"].asCString()); _tcsxcpy(pSt_ServerConfig->tszIPAddr, st_JsonRoot["tszIPAddr"].asCString()); pSt_ServerConfig->bDeamon = st_JsonRoot["bDeamon"].asInt(); - pSt_ServerConfig->nRTMPPort = st_JsonRoot["nRTMPPort"].asInt(); pSt_ServerConfig->nHttpPort = st_JsonRoot["nHttpPort"].asInt(); pSt_ServerConfig->nXStreamPort = st_JsonRoot["nXStreamPort"].asInt(); pSt_ServerConfig->nJT1078Port = st_JsonRoot["nJT1078Port"].asInt(); pSt_ServerConfig->nSrtPort = st_JsonRoot["nSrtPort"].asInt(); - pSt_ServerConfig->nRTCPort = st_JsonRoot["nRTCPort"].asInt(); + pSt_ServerConfig->nRTCWhepPort = st_JsonRoot["nRTCWhepPort"].asInt(); + pSt_ServerConfig->nRTCWhipPort = st_JsonRoot["nRTCWhipPort"].asInt(); //最大配置 if (st_JsonRoot["XMax"].empty() || (8 != st_JsonRoot["XMax"].size())) { @@ -137,7 +128,6 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE Json::Value st_PullWebRtc = st_Pull["RTC"]; Json::Value st_PullSrt = st_Pull["SRT"]; Json::Value st_PullTs = st_Pull["TS"]; - pSt_ServerConfig->st_XPull.st_PullXStream.bEnable = st_PullXStream["bEnable"].asBool(); pSt_ServerConfig->st_XPull.st_PullXStream.bPrePull = st_PullXStream["bPrePull"].asBool(); diff --git a/XEngine_Source/XEngine_ModuleConfigure/XEngine_ModuleConfigure.vcxproj b/XEngine_Source/XEngine_ModuleConfigure/XEngine_ModuleConfigure.vcxproj index c721427..273138f 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/XEngine_ModuleConfigure.vcxproj +++ b/XEngine_Source/XEngine_ModuleConfigure/XEngine_ModuleConfigure.vcxproj @@ -99,30 +99,30 @@ true - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;..\XEngine_ModuleConfigure;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;..\XEngine_ModuleConfigure;$(IncludePath) $(XEngine_Lib32);$(LibraryPath) false - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_Lib32);$(LibraryPath) true - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) true - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) false - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_Lib64);$(LibraryPath) false - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_LibArm64);$(LibraryPath) diff --git a/XEngine_Source/XEngine_ModuleHelp/Makefile b/XEngine_Source/XEngine_ModuleHelp/Makefile index 6b5ec21..94b98ea 100644 --- a/XEngine_Source/XEngine_ModuleHelp/Makefile +++ b/XEngine_Source/XEngine_ModuleHelp/Makefile @@ -1,11 +1,7 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ LOADSO = LIB = -lXEngine_BaseLib -lXEngine_Cryption -lNetHelp_APIAddr @@ -32,31 +28,29 @@ ifeq ($(MACRO_RTC_SUPPORT),1) endif ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -65,7 +59,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LOADHDR += -I /opt/homebrew/opt/srt/include -I /opt/homebrew/opt/srtp/include LOADSO += -L /opt/homebrew/opt/srt/lib -L /opt/homebrew/opt/srtp/lib diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.cpp b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.cpp index 29f2022..556186b 100644 --- a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.cpp +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.cpp @@ -46,7 +46,7 @@ bool CModuleHelp_JT1078::ModuleHelp_JT1078_BCDToString(XBYTE bySIMNumber[6], XCH } for (int i = 0, nPos = 0; i < 6; i++) { - Cryption_Codec_BCDTo2Bytes(bySIMNumber[i], &ptszMsgBuffer[nPos]); + ModuleHelp_JT1078_BCDTo2Bytes(bySIMNumber[i], &ptszMsgBuffer[nPos]); nPos += 2; } return true; @@ -81,8 +81,124 @@ bool CModuleHelp_JT1078::ModuleHelp_JT1078_StringToBCD(LPCXSTR lpszMsgBuffer, XB } for (int i = 0, nPos = 0; i < 6; i++) { - Cryption_Codec_2BytesToBCD(&lpszMsgBuffer[i], pbySIMNumber[nPos]); + ModuleHelp_JT1078_2BytesToBCD(&lpszMsgBuffer[i], pbySIMNumber[nPos]); nPos += 2; } return true; +} +////////////////////////////////////////////////////////////////////////// +// 保护函数 +////////////////////////////////////////////////////////////////////////// +/******************************************************************** +函数名称:ModuleHelp_JT1078_2BytesToBCD +函数功能:两个字符转BCD编码 + 参数.一:lpszSource + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入一段要编码的数据 + 参数.二:chBCD + In/Out:Out + 类型:无符号字符 + 可空:N + 意思:输出编码好的数据 +返回值 + 类型:无 + 意思: +备注: +*********************************************************************/ +void CModuleHelp_JT1078::ModuleHelp_JT1078_2BytesToBCD(LPCXSTR lpszSource, XBYTE& chBCD) +{ + ModuleHelp_IsErrorOccur = false; + + XBYTE uszBsd; + uszBsd = lpszSource[0] - '0'; + uszBsd = uszBsd << 4; + chBCD |= uszBsd; + uszBsd = lpszSource[1] - '0'; + uszBsd = uszBsd & 0x0f; + chBCD |= uszBsd; +} +/******************************************************************** +函数名称:ModuleHelp_JT1078_BCDTo2Bytes +函数功能:BCD编码转字符 + 参数.一:chBCD + In/Out:In + 类型:无符号字符 + 可空:N + 意思:输入要解码的BCD字符 + 参数.二:ptszDest + In/Out:Out + 类型:字符指针 + 可空:N + 意思:输出解码后的字符串 +返回值 + 类型:无 + 意思: +备注: +*********************************************************************/ +void CModuleHelp_JT1078::ModuleHelp_JT1078_BCDTo2Bytes(XBYTE chBCD, XCHAR* ptszDest) +{ + ModuleHelp_IsErrorOccur = false; + + XBYTE uszBsd; + + uszBsd = chBCD & 0x0f; + ptszDest[1] = uszBsd + '0'; + uszBsd = chBCD & 0xf0; + uszBsd = uszBsd >> 4; + ptszDest[0] = uszBsd + '0'; +} +/******************************************************************** +函数名称:ModuleHelp_JT1078_BCDToInt +函数功能:BCD编码转整数型 + 参数.一:chBCD + In/Out:In + 类型:无符号字符 + 可空:N + 意思:输入要解码的BCD字符 +返回值 + 类型:整数型 + 意思:输出解码数据 +备注: +*********************************************************************/ +int CModuleHelp_JT1078::ModuleHelp_JT1078_BCDToInt(XBYTE chBCD) +{ + ModuleHelp_IsErrorOccur = false; + + XBYTE uszBsd1, uszBsd2, uszBsd3; + + uszBsd1 = chBCD & 0x0f; + uszBsd2 = chBCD & 0xf0; + uszBsd2 = uszBsd2 >> 4; + uszBsd3 = uszBsd2 * 10 + uszBsd1; + return uszBsd3; +} +/******************************************************************** +函数名称:ModuleHelp_JT1078_IntToBCD +函数功能:将00-99的整数存放成1个字节的BCD + 参数.一:uszInt + In/Out:In + 类型:无符号字符 + 可空:N + 意思:输入要编码的整数 +返回值 + 类型:无符号字符 + 意思:输出编码数据 +备注: +*********************************************************************/ +XBYTE CModuleHelp_JT1078::ModuleHelp_JT1078_IntToBCD(XBYTE uszInt) +{ + ModuleHelp_IsErrorOccur = false; + + XBYTE usBCD; + XBYTE nRet; + + nRet = 0; + usBCD = uszInt / 10; + usBCD = usBCD << 4; + nRet |= usBCD; + usBCD = uszInt % 10; + nRet |= usBCD; + return nRet; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.h b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.h index deb5329..0d39f8e 100644 --- a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.h +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_JT1078/ModuleHelp_JT1078.h @@ -20,5 +20,10 @@ class CModuleHelp_JT1078 public: bool ModuleHelp_JT1078_BCDToString(XBYTE bySIMNumber[6], XCHAR* ptszMsgBuffer); bool ModuleHelp_JT1078_StringToBCD(LPCXSTR lpszMsgBuffer, XBYTE* pbySIMNumber); +protected: + void ModuleHelp_JT1078_2BytesToBCD(LPCXSTR lpszSource, XBYTE& chBCD); + void ModuleHelp_JT1078_BCDTo2Bytes(XBYTE chBCD, XCHAR* ptszDest); + int ModuleHelp_JT1078_BCDToInt(XBYTE chBCD); + XBYTE ModuleHelp_JT1078_IntToBCD(XBYTE uszInt); private: }; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Rtmp/ModuleHelp_Rtmp.h b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Rtmp/ModuleHelp_Rtmp.h index 98f8278..f7369aa 100644 --- a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Rtmp/ModuleHelp_Rtmp.h +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Rtmp/ModuleHelp_Rtmp.h @@ -13,8 +13,8 @@ typedef struct { - XCHAR tszLiveName[MAX_PATH]; - XCHAR tszURLStr[MAX_PATH]; + XCHAR tszLiveName[XPATH_MAX]; + XCHAR tszURLStr[XPATH_MAX]; }RTMPPROTOCOL_CLIENTINFO; class CModuleHelp_Rtmp diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_SRtp/ModuleHelp_SRTPCore.cpp b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_SRtp/ModuleHelp_SRTPCore.cpp index d4371c0..cc102ff 100644 --- a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_SRtp/ModuleHelp_SRTPCore.cpp +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_SRtp/ModuleHelp_SRTPCore.cpp @@ -141,7 +141,7 @@ bool CModuleHelp_SRTPCore::ModuleHelp_SRTPCore_RTPINProtect(XCHAR* ptszMSGBuffer ModuleHelp_IsErrorOccur = false; #if 1 == _XENGINE_STREAMMEDIA_BUILDSWITCH_RTC - + int nRet = srtp_protect(st_SRTPCore.pSt_SRTPSendCtx, ptszMSGBuffer, pInt_MSGLen); if (srtp_err_status_ok != nRet) { @@ -177,7 +177,7 @@ bool CModuleHelp_SRTPCore::ModuleHelp_SRTPCore_RTPUNProtect(XCHAR* ptszMSGBuffer #if 1 == _XENGINE_STREAMMEDIA_BUILDSWITCH_RTC - int nRet = srtp_unprotect(st_SRTPCore.pSt_SRTPSendCtx, ptszMSGBuffer, pInt_MSGLen); + int nRet = srtp_unprotect(st_SRTPCore.pSt_SRTPRecvCtx, ptszMSGBuffer, pInt_MSGLen); if (srtp_err_status_ok != nRet) { ModuleHelp_IsErrorOccur = true; @@ -212,7 +212,7 @@ bool CModuleHelp_SRTPCore::ModuleHelp_SRTPCore_RTCPINProtect(XCHAR* ptszMSGBuffe #if 1 == _XENGINE_STREAMMEDIA_BUILDSWITCH_RTC - int nRet = srtp_protect_rtcp(st_SRTPCore.pSt_SRTPRecvCtx, ptszMSGBuffer, pInt_MSGLen); + int nRet = srtp_protect_rtcp(st_SRTPCore.pSt_SRTPSendCtx, ptszMSGBuffer, pInt_MSGLen); if (srtp_err_status_ok != nRet) { ModuleHelp_IsErrorOccur = true; diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.cpp b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.cpp index 5517f1a..cadc6a8 100644 --- a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.cpp +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.cpp @@ -288,9 +288,9 @@ bool CModuleHelp_SrtCore::ModuleHelp_SrtCore_GetStreamID(XSOCKET hSocket, XCHAR* return false; } //#!::h=live/livestream,m=publish - XCHAR tszTmpStr[MAX_PATH]; - XCHAR tszSMSAddr[MAX_PATH]; - XCHAR tszSMSMode[MAX_PATH]; + XCHAR tszTmpStr[XPATH_MAX]; + XCHAR tszSMSAddr[XPATH_MAX]; + XCHAR tszSMSMode[XPATH_MAX]; memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); memset(tszSMSMode, '\0', sizeof(tszSMSMode)); @@ -488,7 +488,7 @@ bool CModuleHelp_SrtCore::ModuleHelp_SrtCore_Leave(XSOCKET hSocket) ////////////////////////////////////////////////////////////////////////// // 线程函数 ////////////////////////////////////////////////////////////////////////// -XHTHREAD CALLBACK CModuleHelp_SrtCore::ModuleHelp_SrtCore_Thread(XPVOID lParam) +XHTHREAD XCALLBACK CModuleHelp_SrtCore::ModuleHelp_SrtCore_Thread(XPVOID lParam) { #if 1 == _XENGINE_STREAMMEDIA_BUILDSWITCH_SRT CModuleHelp_SrtCore* pClass_This = (CModuleHelp_SrtCore*)lParam; diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.h b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.h index 88d8b5d..5757cc0 100644 --- a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.h +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Srt/ModuleHelp_SrtCore.h @@ -13,7 +13,7 @@ typedef struct { XCHAR tszStreamBuffer[512]; - XCHAR tszClientAddr[MAX_PATH]; + XCHAR tszClientAddr[XPATH_MAX]; int nIDLen; XSOCKET hSocket; @@ -38,7 +38,7 @@ class CModuleHelp_SrtCore bool ModuleHelp_SrtCore_Recv(XSOCKET hSocket); bool ModuleHelp_SrtCore_Leave(XSOCKET hSocket); protected: - static XHTHREAD CALLBACK ModuleHelp_SrtCore_Thread(XPVOID lParam); + static XHTHREAD XCALLBACK ModuleHelp_SrtCore_Thread(XPVOID lParam); private: bool bRun = false; int hSRTEPoll = 0; diff --git a/XEngine_Source/XEngine_ModuleProtocol/Makefile b/XEngine_Source/XEngine_ModuleProtocol/Makefile index 2d5ca9e..1e5eb9f 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/Makefile +++ b/XEngine_Source/XEngine_ModuleProtocol/Makefile @@ -1,43 +1,37 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 -LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp -LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp +LOADHDR = -I ./ -I ../XEngine_DependLibrary/XEngine_Module/jsoncpp +LOADSO = -L ../XEngine_DependLibrary/XEngine_Module/jsoncpp LIB = -ljsoncpp LIBEX = OBJECTS = ModuleProtocol_Packet.o ModuleProtocol_Parse.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl diff --git a/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj b/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj index 932b5f3..1d93f42 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj +++ b/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj @@ -99,32 +99,32 @@ true - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_Lib32);$(LibraryPath) false - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_Lib32);$(LibraryPath) true - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_Lib64);$(LibraryPath) true - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_LibArm64);$(LibraryPath) false - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_Lib64);$(LibraryPath) false - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_DependLibrary/XEngine_Module/jsoncpp;$(IncludePath) $(XEngine_LibArm64);$(LibraryPath) diff --git a/XEngine_Source/XEngine_ModuleQueue/Makefile b/XEngine_Source/XEngine_ModuleQueue/Makefile index 458cc7a..f999a52 100644 --- a/XEngine_Source/XEngine_ModuleQueue/Makefile +++ b/XEngine_Source/XEngine_ModuleQueue/Makefile @@ -1,11 +1,7 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ LOADSO = LIB = @@ -13,31 +9,29 @@ LIBEX = OBJECTS = ModuleQueue_JT1078.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl diff --git a/XEngine_Source/XEngine_ModuleSession/Makefile b/XEngine_Source/XEngine_ModuleSession/Makefile index dd87837..7a824c8 100644 --- a/XEngine_Source/XEngine_ModuleSession/Makefile +++ b/XEngine_Source/XEngine_ModuleSession/Makefile @@ -1,11 +1,7 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ LOADSO = LIB = -lXEngine_BaseLib -lXEngine_SystemApi @@ -13,31 +9,29 @@ LIBEX = OBJECTS = ModuleSession_PullStream.o ModuleSession_PushStream.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h index 0fc0df8..0d7e3f5 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h @@ -18,7 +18,7 @@ typedef struct typedef struct { XENGINE_PROTOCOL_AVINFO st_AVInfo; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE enStreamType; int nClientCount; }STREAMMEDIA_PUBLISHINFO; @@ -26,24 +26,24 @@ typedef struct { struct { - XCHAR tszTokenStr[MAX_PATH]; - XCHAR tszICEUser[MAX_PATH]; - XCHAR tszICEPass[MAX_PATH]; - XCHAR tszHMacStr[MAX_PATH]; + XCHAR tszTokenStr[XPATH_MAX]; + XCHAR tszICEUser[XPATH_MAX]; + XCHAR tszICEPass[XPATH_MAX]; + XCHAR tszHMacStr[XPATH_MAX]; XCHAR tszClientAddr[128]; bool bConnect; XCHAR tszVSSrcStr[128]; - XCHAR tszVideoCName[MAX_PATH]; - XCHAR tszVideoLabel[MAX_PATH]; + XCHAR tszVideoCName[XPATH_MAX]; + XCHAR tszVideoLabel[XPATH_MAX]; XCHAR tszASSrcStr[128]; - XCHAR tszAudioCName[MAX_PATH]; - XCHAR tszAudioLabel[MAX_PATH]; + XCHAR tszAudioCName[XPATH_MAX]; + XCHAR tszAudioLabel[XPATH_MAX]; }st_WEBRtc; - XCHAR tszClientAddr[MAX_PATH]; - XCHAR tszSMSAddr[MAX_PATH]; - XCHAR tszPushAddr[MAX_PATH]; + XCHAR tszClientAddr[XPATH_MAX]; + XCHAR tszSMSAddr[XPATH_MAX]; + XCHAR tszPushAddr[XPATH_MAX]; int nFLVTag; ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE enStreamType; @@ -842,4 +842,128 @@ extern "C" bool ModuleSession_PushStream_AudioCodecSet(LPCXSTR lpszClientAddr, X 意思:是否成功 备注: *********************************************************************/ -extern "C" bool ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec); \ No newline at end of file +extern "C" bool ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec); +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCConnSet +函数功能:设置RTC连接状态 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:bConnect + In/Out:In + 类型:逻辑型 + 可空:N + 意思:输入连接状态 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_PushStream_RTCConnSet(LPCXSTR lpszClientAddr, bool bConnect); +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCConnGet +函数功能:获取RTC连接状态 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:pbConnect + In/Out:Out + 类型:逻辑型指针 + 可空:N + 意思:输出连接状态 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_PushStream_RTCConnGet(LPCXSTR lpszClientAddr, bool* pbConnect); +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCAddrSet +函数功能:设置RTC的数据通信地址 + 参数.一:lpszClientUser + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的用户 + 参数.二:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入绑定的地址 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_PushStream_RTCAddrSet(LPCXSTR lpszClientUser, LPCXSTR lpszClientAddr); +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCAddrGet +函数功能:获取地址绑定的用户 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的地址 + 参数.二:ptszClientUser + In/Out:Out + 类型:字符指针 + 可空:N + 意思:输出绑定的用户 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_PushStream_RTCAddrGet(LPCXSTR lpszClientAddr, XCHAR* ptszClientUser); +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCIndexSet +函数功能:设置RTP包媒体索引 + 参数.一:lpszClientUser + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:nVideoIndex + In/Out:In + 类型:整数型 + 可空:N + 意思:输入RTP的包视频索引 + 参数.三:nAudioIndex + In/Out:In + 类型:整数型 + 可空:N + 意思:输入RTP的包音频索引 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_PushStream_RTCIndexSet(LPCXSTR lpszClientUser, int nVideoIndex, int nAudioIndex); +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCIndexGet +函数功能:获取RTP包媒体索引 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:pInt_VideoIndex + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出RTP的包视频索引 + 参数.三:pInt_AudioIndex + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出RTP的包音频索引 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_PushStream_RTCIndexGet(LPCXSTR lpszClientAddr, int* pInt_VideoIndex, int* pInt_AudioIndex); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.cpp b/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.cpp index a5a1f5f..bd3f6e5 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.cpp +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.cpp @@ -547,8 +547,8 @@ bool CModuleSession_PushStream::ModuleSession_PushStream_HLSInsert(LPCXSTR lpszC st_Locker.unlock_shared(); return false; } - XCHAR tszFilePath[MAX_PATH] = {}; - XCHAR tszFileName[MAX_PATH] = {}; + XCHAR tszFilePath[XPATH_MAX] = {}; + XCHAR tszFileName[XPATH_MAX] = {}; //获得文件名和路径 BaseLib_String_GetFileAndPath(lpszTSFile, tszFilePath, tszFileName); SystemApi_File_CreateMutilFolder(tszFilePath); @@ -704,7 +704,7 @@ bool CModuleSession_PushStream::ModuleSession_PushStream_HLSClose(LPCXSTR lpszCl { fclose(stl_MapIterator->second->st_HLSFile.pSt_File); } - memset(stl_MapIterator->second->st_HLSFile.tszFileName, '\0', MAX_PATH); + memset(stl_MapIterator->second->st_HLSFile.tszFileName, '\0', XPATH_MAX); st_Locker.unlock_shared(); return true; } @@ -889,6 +889,308 @@ bool CModuleSession_PushStream::ModuleSession_PushStream_AudioCodecGet(LPCXSTR l *pxhAudioEncodec = stl_MapIterator->second->st_AVCodec.xhAudioEncodec; *pxhAudioDecodec = stl_MapIterator->second->st_AVCodec.xhAudioDecodec; + st_Locker.unlock_shared(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCAddrSet +函数功能:设置RTC的数据通信地址 + 参数.一:lpszClientUser + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的用户 + 参数.二:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入绑定的地址 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_PushStream::ModuleSession_PushStream_RTCAddrSet(LPCXSTR lpszClientUser, LPCXSTR lpszClientAddr) +{ + Session_IsErrorOccur = false; + + if (NULL == lpszClientAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT; + return false; + } + //是否存在 + st_Locker.lock_shared(); + unordered_map::iterator stl_MapIterator = stl_MapPushStream.find(lpszClientUser); + if (stl_MapIterator == stl_MapPushStream.end()) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND; + st_Locker.unlock_shared(); + return false; + } + _tcsxcpy(stl_MapIterator->second->st_RTCInfo.tszClientAddr, lpszClientAddr); + st_Locker.unlock_shared(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCAddrGet +函数功能:获取地址绑定的用户 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的地址 + 参数.二:ptszClientUser + In/Out:Out + 类型:字符指针 + 可空:N + 意思:输出绑定的用户 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_PushStream::ModuleSession_PushStream_RTCAddrGet(LPCXSTR lpszClientAddr, XCHAR* ptszClientUser) +{ + Session_IsErrorOccur = false; + if (NULL == lpszClientAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT; + return false; + } + bool bFound = false; + //是否存在 + st_Locker.lock_shared(); + unordered_map::iterator stl_MapIterator = stl_MapPushStream.begin(); + for (; stl_MapIterator != stl_MapPushStream.end(); stl_MapIterator++) + { + if (0 == _tcsxnicmp(lpszClientAddr, stl_MapIterator->second->st_RTCInfo.tszClientAddr, _tcsxlen(lpszClientAddr))) + { + bFound = true; + _tcsxcpy(ptszClientUser, stl_MapIterator->first.c_str()); + break; + } + } + st_Locker.unlock_shared(); + if (!bFound) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND; + return false; + } + + return true; +} +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCConnSet +函数功能:设置RTC连接状态 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:bConnect + In/Out:In + 类型:逻辑型 + 可空:N + 意思:输入连接状态 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_PushStream::ModuleSession_PushStream_RTCConnSet(LPCXSTR lpszClientAddr, bool bConnect) +{ + Session_IsErrorOccur = false; + + if (NULL == lpszClientAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT; + return false; + } + bool bFound = false; + //是否存在 + st_Locker.lock_shared(); + unordered_map::iterator stl_MapIterator = stl_MapPushStream.begin(); + for (; stl_MapIterator != stl_MapPushStream.end(); stl_MapIterator++) + { + if (0 == _tcsxnicmp(lpszClientAddr, stl_MapIterator->second->st_RTCInfo.tszClientAddr, _tcsxlen(lpszClientAddr))) + { + bFound = true; + stl_MapIterator->second->st_RTCInfo.bConnect = bConnect; + break; + } + } + st_Locker.unlock_shared(); + if (!bFound) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND; + return false; + } + return true; +} +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCConnGet +函数功能:获取RTC连接状态 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:pbConnect + In/Out:Out + 类型:逻辑型指针 + 可空:N + 意思:输出连接状态 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_PushStream::ModuleSession_PushStream_RTCConnGet(LPCXSTR lpszClientAddr, bool* pbConnect) +{ + Session_IsErrorOccur = false; + if (NULL == lpszClientAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT; + return false; + } + bool bFound = false; + //是否存在 + st_Locker.lock_shared(); + unordered_map::iterator stl_MapIterator = stl_MapPushStream.begin(); + for (; stl_MapIterator != stl_MapPushStream.end(); stl_MapIterator++) + { + if (0 == _tcsxnicmp(lpszClientAddr, stl_MapIterator->second->st_RTCInfo.tszClientAddr, _tcsxlen(lpszClientAddr))) + { + bFound = true; + break; + } + } + if (!bFound) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND; + st_Locker.unlock_shared(); + return false; + } + *pbConnect = stl_MapIterator->second->st_RTCInfo.bConnect; + st_Locker.unlock_shared(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCIndexSet +函数功能:设置RTP包媒体索引 + 参数.一:lpszClientUser + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:nVideoIndex + In/Out:In + 类型:整数型 + 可空:N + 意思:输入RTP的包视频索引 + 参数.三:nAudioIndex + In/Out:In + 类型:整数型 + 可空:N + 意思:输入RTP的包音频索引 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_PushStream::ModuleSession_PushStream_RTCIndexSet(LPCXSTR lpszClientUser, int nVideoIndex, int nAudioIndex) +{ + Session_IsErrorOccur = false; + if (NULL == lpszClientUser) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT; + return false; + } + bool bFound = false; + //是否存在 + st_Locker.lock_shared(); + unordered_map::iterator stl_MapIterator = stl_MapPushStream.find(lpszClientUser); + if (stl_MapIterator == stl_MapPushStream.end()) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND; + st_Locker.unlock_shared(); + return false; + } + stl_MapIterator->second->st_RTCInfo.nIndexVideo = nVideoIndex; + stl_MapIterator->second->st_RTCInfo.nIndexAudio = nAudioIndex; + st_Locker.unlock_shared(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_PushStream_RTCIndexGet +函数功能:获取RTP包媒体索引 + 参数.一:lpszClientAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的客户端 + 参数.二:pInt_VideoIndex + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出RTP的包视频索引 + 参数.三:pInt_AudioIndex + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出RTP的包音频索引 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_PushStream::ModuleSession_PushStream_RTCIndexGet(LPCXSTR lpszClientAddr, int* pInt_VideoIndex, int* pInt_AudioIndex) +{ + Session_IsErrorOccur = false; + if (NULL == lpszClientAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_PARAMENT; + return false; + } + bool bFound = false; + //是否存在 + st_Locker.lock_shared(); + unordered_map::iterator stl_MapIterator = stl_MapPushStream.begin(); + for (; stl_MapIterator != stl_MapPushStream.end(); stl_MapIterator++) + { + if (0 == _tcsxnicmp(lpszClientAddr, stl_MapIterator->second->st_RTCInfo.tszClientAddr, _tcsxlen(lpszClientAddr))) + { + bFound = true; + break; + } + } + if (!bFound) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_STREAMMEDIA_MODULE_SESSION_NOTFOUND; + st_Locker.unlock_shared(); + return false; + } + if (NULL != pInt_VideoIndex) + { + *pInt_VideoIndex = stl_MapIterator->second->st_RTCInfo.nIndexVideo; + } + if (NULL != pInt_AudioIndex) + { + *pInt_AudioIndex = stl_MapIterator->second->st_RTCInfo.nIndexAudio; + } st_Locker.unlock_shared(); return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.h index 382b4ae..f312ba0 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.h +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_PushStream/ModuleSession_PushStream.h @@ -14,18 +14,26 @@ typedef struct { struct { - XCHAR tszFileName[MAX_PATH]; + XCHAR tszFileName[XPATH_MAX]; XNETHANDLE xhToken; __int64u nTime; FILE* pSt_File; }st_HLSFile; struct + { + XCHAR tszClientAddr[XPATH_MAX]; + XCHAR tszRTPStr[128]; + int nIndexVideo; + int nIndexAudio; + bool bConnect; + }st_RTCInfo; + struct { XNETHANDLE xhAudioDecodec; XNETHANDLE xhAudioEncodec; }st_AVCodec; XENGINE_PROTOCOL_AVINFO st_AVInfo; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE enStreamType; unique_ptr st_ClientLocker; @@ -59,6 +67,13 @@ class CModuleSession_PushStream public: bool ModuleSession_PushStream_AudioCodecSet(LPCXSTR lpszClientAddr, XNETHANDLE xhAudioDecodec, XNETHANDLE xhAudioEncodec); bool ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec); +public: + bool ModuleSession_PushStream_RTCAddrSet(LPCXSTR lpszClientUser, LPCXSTR lpszClientAddr); + bool ModuleSession_PushStream_RTCAddrGet(LPCXSTR lpszClientAddr, XCHAR* ptszClientUser); + bool ModuleSession_PushStream_RTCConnSet(LPCXSTR lpszClientAddr, bool bConnect); + bool ModuleSession_PushStream_RTCConnGet(LPCXSTR lpszClientAddr, bool* pbConnect); + bool ModuleSession_PushStream_RTCIndexSet(LPCXSTR lpszClientUser, int nVideoIndex, int nAudioIndex); + bool ModuleSession_PushStream_RTCIndexGet(LPCXSTR lpszClientAddr, int* pInt_VideoIndex, int* pInt_AudioIndex); private: shared_mutex st_Locker; private: diff --git a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def index bb12091..7cdbf74 100644 --- a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def +++ b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def @@ -43,4 +43,10 @@ EXPORTS ModuleSession_PushStream_HLSTimeGet ModuleSession_PushStream_AudioCodecSet - ModuleSession_PushStream_AudioCodecGet \ No newline at end of file + ModuleSession_PushStream_AudioCodecGet + ModuleSession_PushStream_RTCConnSet + ModuleSession_PushStream_RTCConnGet + ModuleSession_PushStream_RTCAddrSet + ModuleSession_PushStream_RTCAddrGet + ModuleSession_PushStream_RTCIndexSet + ModuleSession_PushStream_RTCIndexGet \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/pch.cpp b/XEngine_Source/XEngine_ModuleSession/pch.cpp index 0505e13..a01f330 100644 --- a/XEngine_Source/XEngine_ModuleSession/pch.cpp +++ b/XEngine_Source/XEngine_ModuleSession/pch.cpp @@ -183,4 +183,28 @@ extern "C" bool ModuleSession_PushStream_AudioCodecSet(LPCXSTR lpszClientAddr, X extern "C" bool ModuleSession_PushStream_AudioCodecGet(LPCXSTR lpszClientAddr, XNETHANDLE* pxhAudioDecodec, XNETHANDLE* pxhAudioEncodec) { return m_PushStream.ModuleSession_PushStream_AudioCodecGet(lpszClientAddr, pxhAudioDecodec, pxhAudioEncodec); +} +extern "C" bool ModuleSession_PushStream_RTCConnSet(LPCXSTR lpszClientAddr, bool bConnect) +{ + return m_PushStream.ModuleSession_PushStream_RTCConnSet(lpszClientAddr, bConnect); +} +extern "C" bool ModuleSession_PushStream_RTCConnGet(LPCXSTR lpszClientAddr, bool* pbConnect) +{ + return m_PushStream.ModuleSession_PushStream_RTCConnGet(lpszClientAddr, pbConnect); +} +extern "C" bool ModuleSession_PushStream_RTCAddrSet(LPCXSTR lpszClientUser, LPCXSTR lpszClientAddr) +{ + return m_PushStream.ModuleSession_PushStream_RTCAddrSet(lpszClientUser, lpszClientAddr); +} +extern "C" bool ModuleSession_PushStream_RTCAddrGet(LPCXSTR lpszClientAddr, XCHAR* ptszClientUser) +{ + return m_PushStream.ModuleSession_PushStream_RTCAddrGet(lpszClientAddr, ptszClientUser); +} +extern "C" bool ModuleSession_PushStream_RTCIndexSet(LPCXSTR lpszClientUser, int nVideoIndex, int nAudioIndex) +{ + return m_PushStream.ModuleSession_PushStream_RTCIndexSet(lpszClientUser, nVideoIndex, nAudioIndex); +} +extern "C" bool ModuleSession_PushStream_RTCIndexGet(LPCXSTR lpszClientAddr, int* pInt_VideoIndex, int* pInt_AudioIndex) +{ + return m_PushStream.ModuleSession_PushStream_RTCIndexGet(lpszClientAddr, pInt_VideoIndex, pInt_AudioIndex); } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/Makefile b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/Makefile index 57e3cf2..d978688 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/Makefile +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/Makefile @@ -1,15 +1,12 @@ CC = g++ -Wall -std=c++20 -PLATFORM = linux PLATVER = -PLATDIR = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ LOADSO = -L ../../XEngine_ModuleConfigure -L ../../XEngine_ModuleProtocol -L ../../XEngine_ModuleSession -L ../../XEngine_ModuleHelp -L ../../XEngine_ModuleQueue \ - -L ../../XEngine_Depend/XEngine_Module/jsoncpp -L ../../XEngine_Depend/XEngine_Module/XEngine_InfoReport + -L ../../XEngine_DependLibrary/XEngine_Module/jsoncpp -L ../../XEngine_DependLibrary/XEngine_Module/XEngine_InfoReport LIB = -lXEngine_BaseLib -lXEngine_Algorithm \ -lXEngine_Core -lXEngine_ManagePool -lXEngine_Cryption \ -lXClient_Stream \ + -lXEngine_SystemApi \ -lHelpComponents_XLog -lHelpComponents_Packets \ -lNetHelp_APIHelp -lNetHelp_XSocket -lNetHelp_APIAddr \ -lRfcComponents_HttpProtocol -lRfcComponents_NatProtocol \ @@ -19,13 +16,13 @@ LIB = -lXEngine_BaseLib -lXEngine_Algorithm \ -ljsoncpp -lXEngine_InfoReport LIBEX = OBJECTS = PullStream_ClientGet.o PullStream_ClientRtsp.o PullStream_ClientWebRtc.o \ - PushStream_JT1078Task.o PushStream_RTMPTask.o PushStream_XStreamTask.o PushStream_SrtTask.o \ + PushStream_JT1078Task.o PushStream_RTMPTask.o PushStream_XStreamTask.o PushStream_SrtTask.o PushStream_ClientWebRtc.o \ StreamMedia_HTTPApi.o \ XEngine_AVPacket.o XEngine_Configure.o XEngine_HttpTask.o XEngine_Network.o XEngine_StreamMediaApp.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c @@ -37,18 +34,16 @@ else endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif CC += -Wno-format-overflow LIBEX = -lpthread -lrt -ldl @@ -56,7 +51,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac LIBEX = -lpthread -ldl LOADBIN = -Wl,-rpath,@loader_path/./ endif @@ -79,6 +73,8 @@ PushStream_RTMPTask.o:./StreamMedia_PushStream/PushStream_RTMPTask.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./StreamMedia_PushStream/PushStream_RTMPTask.cpp PushStream_SrtTask.o:./StreamMedia_PushStream/PushStream_SrtTask.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./StreamMedia_PushStream/PushStream_SrtTask.cpp +PushStream_ClientWebRtc.o:./StreamMedia_PushStream/PushStream_ClientWebRtc.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./StreamMedia_PushStream/PushStream_ClientWebRtc.cpp StreamMedia_HTTPApi.o:./StreamMedia_HTTPApi/StreamMedia_HTTPApi.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./StreamMedia_HTTPApi/StreamMedia_HTTPApi.cpp diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_HTTPApi/StreamMedia_HTTPApi.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_HTTPApi/StreamMedia_HTTPApi.cpp index 36ab3aa..6c8079f 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_HTTPApi/StreamMedia_HTTPApi.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_HTTPApi/StreamMedia_HTTPApi.cpp @@ -16,8 +16,8 @@ bool HTTPApi_Management_Task(LPCXSTR lpszClientAddr, XCHAR*** ppptszListHdr, int int nSDLen = 0; XCHAR tszRVBuffer[4096]; XCHAR tszSDBuffer[4096]; - XCHAR tszKeyBuffer[MAX_PATH]; - XCHAR tszVluBuffer[MAX_PATH]; + XCHAR tszKeyBuffer[XPATH_MAX]; + XCHAR tszVluBuffer[XPATH_MAX]; LPCXSTR lpszAPIPublish = _X("publish"); LPCXSTR lpszAPIPull = _X("pull"); LPCXSTR lpszAPIGet = _X("get"); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientGet.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientGet.cpp index 88b1313..f202a5f 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientGet.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientGet.cpp @@ -82,8 +82,8 @@ bool PullStream_ClientGet_Handle(LPCXSTR lpszClientAddr, XCHAR*** ppptszListHdr, int nSDLen = 0; XCHAR tszRVBuffer[4096]; XCHAR tszSDBuffer[4096]; - XCHAR tszKeyBuffer[MAX_PATH]; - XCHAR tszVluBuffer[MAX_PATH]; + XCHAR tszKeyBuffer[XPATH_MAX]; + XCHAR tszVluBuffer[XPATH_MAX]; LPCXSTR lpszStreamPlay = _X("play"); LPCXSTR lpszStreamStop = _X("stop"); RFCCOMPONENTS_HTTP_HDRPARAM st_HDRParam; @@ -102,8 +102,8 @@ bool PullStream_ClientGet_Handle(LPCXSTR lpszClientAddr, XCHAR*** ppptszListHdr, if (0 == _tcsxnicmp(lpszStreamPlay, tszVluBuffer, _tcsxlen(lpszStreamPlay))) { //播放流:http://127.0.0.1:5600/api?stream=play&sms=live/qyt&type=flv - XCHAR tszPushAddr[MAX_PATH]; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszPushAddr[XPATH_MAX]; + XCHAR tszSMSAddr[XPATH_MAX]; memset(tszPushAddr, '\0', sizeof(tszPushAddr)); memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); @@ -241,8 +241,8 @@ bool PullStream_ClientGet_Handle(LPCXSTR lpszClientAddr, XCHAR*** ppptszListHdr, else if (0 == _tcsxnicmp(lpszStreamStop, tszVluBuffer, _tcsxlen(lpszStreamStop))) { //停止拉流,:http://127.0.0.1:5600/api?stream=stop - XCHAR tszSMSAddr[MAX_PATH]; - XCHAR tszPushAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; + XCHAR tszPushAddr[XPATH_MAX]; memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); memset(tszPushAddr, '\0', sizeof(tszPushAddr)); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientRtsp.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientRtsp.cpp index 8ef6a3e..24a4723 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientRtsp.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientRtsp.cpp @@ -80,9 +80,9 @@ bool PullStream_ClientRtsp_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LP if (ENUM_RTSPPROTOCOL_METHOD_TYPE_OPTIONS == st_RTSPRequest.enMethod) { //OPTIONS rtsp://10.0.1.89:554/480p.264 RTSP/1.0 - XCHAR tszKeyStr[MAX_PATH]; - XCHAR tszPushAddr[MAX_PATH]; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszKeyStr[XPATH_MAX]; + XCHAR tszPushAddr[XPATH_MAX]; + XCHAR tszSMSAddr[XPATH_MAX]; memset(tszPushAddr, '\0', sizeof(tszPushAddr)); memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); @@ -110,9 +110,9 @@ bool PullStream_ClientRtsp_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LP else if (ENUM_RTSPPROTOCOL_METHOD_TYPE_DESCRIBE == st_RTSPRequest.enMethod) { //DESCRIBE rtsp://10.0.1.89:554/480p.264 RTSP/1.0 - XCHAR tszKeyStr[MAX_PATH]; - XCHAR tszPushAddr[MAX_PATH]; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszKeyStr[XPATH_MAX]; + XCHAR tszPushAddr[XPATH_MAX]; + XCHAR tszSMSAddr[XPATH_MAX]; XENGINE_PROTOCOL_AVINFO st_AVInfo; memset(tszPushAddr, '\0', sizeof(tszPushAddr)); @@ -165,7 +165,7 @@ bool PullStream_ClientRtsp_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LP st_SDPMediaVideo.nTrackID = 0; st_SDPMediaVideo.st_RTPMap.nSampleRate = 90000; _tcsxcpy(st_SDPMediaVideo.st_RTPMap.tszCodecName, _X("H264")); - SDPProtocol_Packet_VideoFmt(xhSDPToken, 96, &st_SDPMediaVideo); + SDPProtocol_Packet_VideoFmt(xhSDPToken, nRTPVIndex, &st_SDPMediaVideo); SDPProtocol_Packet_Control(xhSDPToken, 0); //配置音频属性 _tcsxcpy(pptszAVList[0], _X("98")); @@ -186,7 +186,7 @@ bool PullStream_ClientRtsp_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LP _tcsxcpy(st_SDPMediaAudio.st_RTPMap.tszCodecName, _X("mpeg4-generic")); _tcsxcpy(st_SDPMediaAudio.st_FmtpAudio.tszMode, "AAC-hbr"); - SDPProtocol_Packet_AudioFmt(xhSDPToken, 98, &st_SDPMediaAudio); + SDPProtocol_Packet_AudioFmt(xhSDPToken, nRTPAIndex, &st_SDPMediaAudio); SDPProtocol_Packet_Control(xhSDPToken, 1); SDPProtocol_Packet_GetPacket(xhSDPToken, tszRVBuffer, &nRVLen); @@ -240,9 +240,9 @@ bool PullStream_ClientRtsp_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LP } else if (ENUM_RTSPPROTOCOL_METHOD_TYPE_PLAY == st_RTSPRequest.enMethod) { - XCHAR tszKeyStr[MAX_PATH]; - XCHAR tszPushAddr[MAX_PATH]; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszKeyStr[XPATH_MAX]; + XCHAR tszPushAddr[XPATH_MAX]; + XCHAR tszSMSAddr[XPATH_MAX]; XENGINE_PROTOCOL_AVINFO st_AVInfo; memset(tszPushAddr, '\0', sizeof(tszPushAddr)); @@ -272,21 +272,23 @@ bool PullStream_ClientRtsp_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LP ModuleHelp_Rtsp_GetSsrc(lpszClientAddr, tszSSRCVideo, true); ModuleHelp_Rtsp_GetSsrc(lpszClientAddr, tszSSRCAudio, false); //创建RTP包管理器 - RTPProtocol_Packet_Insert(tszSSRCVideo, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_H264); - RTPProtocol_Packet_Insert(tszSSRCAudio, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_AAC); + RTPProtocol_Packet_Insert(tszSSRCVideo); + RTPProtocol_Packet_SetLink(tszSSRCVideo, nRTPVIndex, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_H264); + RTPProtocol_Packet_Insert(tszSSRCAudio); + RTPProtocol_Packet_SetLink(tszSSRCAudio, nRTPAIndex, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_AAC); if (st_AVInfo.st_VideoInfo.nFrameRate > 0) { - RTPProtocol_Packet_SetTime(tszSSRCVideo, st_AVInfo.st_VideoInfo.nFrameRate); - RTPProtocol_Packet_GetTime(tszSSRCVideo, &st_RTSPResponse.ppSt_RTPInfo[0]->nNTPTime); - RTPProtocol_Packet_GetCSeq(tszSSRCVideo, &st_RTSPResponse.ppSt_RTPInfo[0]->nCSeq); + RTPProtocol_Packet_SetTime(tszSSRCVideo, nRTPVIndex, st_AVInfo.st_VideoInfo.nFrameRate); + RTPProtocol_Packet_GetTime(tszSSRCVideo, nRTPVIndex, &st_RTSPResponse.ppSt_RTPInfo[0]->nNTPTime); + RTPProtocol_Packet_GetCSeq(tszSSRCVideo, nRTPVIndex, &st_RTSPResponse.ppSt_RTPInfo[0]->nCSeq); _xstprintf(st_RTSPResponse.ppSt_RTPInfo[0]->tszURLStr, _X("%s/trackID=0"), st_RTSPRequest.tszUrl); } if (st_AVInfo.st_AudioInfo.nSampleRate > 0) { - RTPProtocol_Packet_SetTime(tszSSRCAudio, st_AVInfo.st_AudioInfo.nSampleRate); - RTPProtocol_Packet_GetTime(tszSSRCAudio, &st_RTSPResponse.ppSt_RTPInfo[1]->nNTPTime); - RTPProtocol_Packet_GetCSeq(tszSSRCAudio, &st_RTSPResponse.ppSt_RTPInfo[1]->nCSeq); + RTPProtocol_Packet_SetTime(tszSSRCAudio, nRTPAIndex, st_AVInfo.st_AudioInfo.nSampleRate); + RTPProtocol_Packet_GetTime(tszSSRCAudio, nRTPAIndex, &st_RTSPResponse.ppSt_RTPInfo[1]->nNTPTime); + RTPProtocol_Packet_GetCSeq(tszSSRCAudio, nRTPAIndex, &st_RTSPResponse.ppSt_RTPInfo[1]->nCSeq); _xstprintf(st_RTSPResponse.ppSt_RTPInfo[1]->tszURLStr, _X("%s/trackID=1"), st_RTSPRequest.tszUrl); } RTSPProtocol_REPPacket_Response(tszSDBuffer, &nSDLen, &st_RTSPResponse); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.cpp index fe137ac..1889280 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.cpp @@ -44,16 +44,16 @@ bool PullStream_ClientProtocol_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, L } else { - bool bRet = Cryption_Server_AcceptMemoryEx(xhRTCSsl, hSocket, lpszClientAddr, tszSDBuffer, &nSDLen, lpszMsgBuffer, nMsgLen); + bool bRet = Cryption_Server_AcceptMemoryEx(xhRTCWhepSsl, hSocket, lpszClientAddr, tszSDBuffer, &nSDLen, lpszMsgBuffer, nMsgLen); if (nSDLen > 0) { - XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_RTC); + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PULL_RTC); } if (bRet) { - XBYTE tszKEYBuffer[MAX_PATH] = {}; - Cryption_Server_GetKeyEx(xhRTCSsl, lpszClientAddr, tszKEYBuffer); + XBYTE tszKEYBuffer[XPATH_MAX] = {}; + Cryption_Server_GetKeyEx(xhRTCWhepSsl, lpszClientAddr, tszKEYBuffer); ModuleHelp_SRTPCore_Create(tszKEYBuffer); XCHAR tszSMSName[128] = {}; @@ -111,8 +111,8 @@ bool PullStream_ClientProtocol_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, L NatProtocol_StunNat_Packet(tszSDBuffer, &nSDLen, (LPCXSTR)st_NatClient.byTokenStr, RFCCOMPONENTS_NATCLIENT_PROTOCOL_STUN_CLASS_RESPONSE, RFCCOMPONENTS_NATCLIENT_PROTOCOL_STUN_ATTR_MAPPED_ADDRESS, tszRVBuffer, true, st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEPass, true); //更新绑定的地址 ModuleSession_PullStream_RTCAddrSet(tszUserStr, lpszClientAddr); - SocketOpt_HeartBeat_ActiveAddrEx(xhRTCHeart, tszUserStr); //激活一次心跳 - XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_RTC); + SocketOpt_HeartBeat_ActiveAddrEx(xhRTCWhepHeart, tszUserStr); //激活一次心跳 + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PULL_RTC); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,请求的STUN协议处理成功,请求的用户:%s"), lpszClientAddr, tszUserStr); } else if (((XBYTE)lpszMsgBuffer[0] >> 6) == 2) @@ -145,7 +145,7 @@ bool PullStream_ClientProtocol_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, L else { //RTP - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,请求的RTP协议处理成功"), lpszClientAddr); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,%d,请求的RTP协议处理成功"), lpszClientAddr, nMsgLen); } } else @@ -158,7 +158,7 @@ bool PullStream_ClientProtocol_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, L bool PullStream_ClientWebRtc_SDKPacket(XNETHANDLE xhPacket, LPCXSTR lpszClientID, bool bVideo, int nAVIndex, STREAMMEDIA_SDPPROTOCOL_MEDIAINFO* pSt_SDPMediaInfo, XENGINE_PROTOCOL_AVINFO *pSt_AVInfo) { XCHAR** pptszAVList; - BaseLib_Memory_Malloc((XPPPMEM)&pptszAVList, 1, MAX_PATH); + BaseLib_Memory_Malloc((XPPPMEM)&pptszAVList, 1, XPATH_MAX); if (bVideo) { @@ -176,8 +176,8 @@ bool PullStream_ClientWebRtc_SDKPacket(XNETHANDLE xhPacket, LPCXSTR lpszClientID SDPProtocol_Packet_ICEUser(xhPacket, st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEUser, st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEPass); int nDLen = 0; - XBYTE tszDigestStr[MAX_PATH] = {}; - XCHAR tszDigestHex[MAX_PATH] = {}; + XBYTE tszDigestStr[XPATH_MAX] = {}; + XCHAR tszDigestHex[XPATH_MAX] = {}; int nPos = _xstprintf(tszDigestHex, _X("sha-256 ")); Cryption_Api_Digest(st_ServiceConfig.st_XPull.st_PullWebRtc.tszDerStr, tszDigestStr, &nDLen, true, ENUM_XENGINE_CRYPTION_DIGEST_SHA256); for (int i = 0; i < nDLen; i++) @@ -201,9 +201,9 @@ bool PullStream_ClientWebRtc_SDKPacket(XNETHANDLE xhPacket, LPCXSTR lpszClientID //BaseLib_Handle_CreateStr(tszSSrcStr, 8, 1); SDPProtocol_Packet_CName(xhPacket, _ttxoll(tszSSrcStr), _X("79a9722580589zr5"), _X("video-666q08to")); ModuleSession_PullStream_RTCSSrcSet(lpszClientID, tszSSrcStr, _X("79a9722580589zr5"), _X("video-666q08to")); - RTPProtocol_Packet_Insert(tszSSrcStr, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_H264); - RTPProtocol_Packet_SetPType(tszSSrcStr, nAVIndex); - RTPProtocol_Packet_SetTime(tszSSrcStr, pSt_AVInfo->st_VideoInfo.nFrameRate); + RTPProtocol_Packet_Insert(tszSSrcStr); + RTPProtocol_Packet_SetLink(tszSSrcStr, nAVIndex, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_H264); + RTPProtocol_Packet_SetTime(tszSSrcStr, nAVIndex, pSt_AVInfo->st_VideoInfo.nFrameRate); } else { @@ -216,14 +216,14 @@ bool PullStream_ClientWebRtc_SDKPacket(XNETHANDLE xhPacket, LPCXSTR lpszClientID //BaseLib_Handle_CreateStr(tszSSrcStr, 8, 1); SDPProtocol_Packet_CName(xhPacket, _ttxoll(tszSSrcStr), _X("79a9722580589zr5"), _X("audio-23z8fj2g")); ModuleSession_PullStream_RTCSSrcSet(lpszClientID, tszSSrcStr, _X("79a9722580589zr5"), _X("audio-23z8fj2g"), false); - RTPProtocol_Packet_Insert(tszSSrcStr, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_AAC); - RTPProtocol_Packet_SetPType(tszSSrcStr, nAVIndex); + RTPProtocol_Packet_Insert(tszSSrcStr); + RTPProtocol_Packet_SetLink(tszSSrcStr, nAVIndex, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_AAC); } - SDPProtocol_Packet_OptionalCandidate(xhPacket, st_ServiceConfig.tszIPAddr, st_ServiceConfig.nRTCPort); + SDPProtocol_Packet_OptionalCandidate(xhPacket, st_ServiceConfig.tszIPAddr, st_ServiceConfig.nRTCWhepPort); BaseLib_Memory_Free((XPPPMEM)&pptszAVList, 1); return true; } -bool PullStream_ClientWebRtc_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen) +bool PullStream_ClientWhep_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen) { int nRVLen = 0; int nSDLen = 0; @@ -265,10 +265,10 @@ bool PullStream_ClientWebRtc_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, int nIndex1 = -1; int nIndex2 = -1; int nListCount = 0; - XCHAR tszICEUser[MAX_PATH] = {}; - XCHAR tszICEPass[MAX_PATH] = {}; - XCHAR tszAlgType[MAX_PATH] = {}; - XCHAR tszHMacStr[MAX_PATH] = {}; + XCHAR tszICEUser[XPATH_MAX] = {}; + XCHAR tszICEPass[XPATH_MAX] = {}; + XCHAR tszAlgType[XPATH_MAX] = {}; + XCHAR tszHMacStr[XPATH_MAX] = {}; STREAMMEDIA_SDPPROTOCOL_ATTR** ppSt_ListAttr; SDPProtocol_Parse_GetAttr(xhParse, &ppSt_ListAttr, &nListCount); @@ -342,9 +342,9 @@ bool PullStream_ClientWebRtc_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, SDPProtocol_Packet_OptionalAddAttr(xhPacket, _X("ice-lite")); SDPProtocol_Packet_OptionalAddAttr(xhPacket, _X("msid-semantic"), _X("WMS live/livestream")); - XCHAR tszTokenStr[MAX_PATH] = {}; - XCHAR tszHDRStr[MAX_PATH] = {}; - XCHAR tszUserStr[MAX_PATH] = {}; + XCHAR tszTokenStr[XPATH_MAX] = {}; + XCHAR tszHDRStr[XPATH_MAX] = {}; + XCHAR tszUserStr[XPATH_MAX] = {}; BaseLib_Handle_CreateStr(tszTokenStr, 10); _xstprintf(tszUserStr, _X("%s:%s"), st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEUser, tszICEUser); @@ -352,7 +352,7 @@ bool PullStream_ClientWebRtc_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, ModuleSession_PullStream_Insert(tszUserStr, tszSMSAddr, tszPushAddr, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PULL_RTC); ModuleSession_PullStream_RTCSet(tszUserStr, tszTokenStr, tszICEUser, tszICEPass, tszHMacStr); - SocketOpt_HeartBeat_InsertAddrEx(xhRTCHeart, tszUserStr); //需要加入心跳,不然没法知道超时 + SocketOpt_HeartBeat_InsertAddrEx(xhRTCWhepHeart, tszUserStr); //需要加入心跳,不然没法知道超时 if (nIndex1 >= 0 && nIndex2 >= 0) { diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.h index fbd62f9..898e945 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PullStream/PullStream_ClientWebRtc.h @@ -11,4 +11,4 @@ // History: *********************************************************************/ bool PullStream_ClientProtocol_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszMsgBuffer, int nMsgLen); -bool PullStream_ClientWebRtc_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen); \ No newline at end of file +bool PullStream_ClientWhep_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_ClientWebRtc.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_ClientWebRtc.cpp new file mode 100644 index 0000000..8c4d629 --- /dev/null +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_ClientWebRtc.cpp @@ -0,0 +1,426 @@ +#include "../XEngine_Hdr.h" +/******************************************************************** +// Created: 2024/01/11 10:31:20 +// File Name: D:\XEngine_StreamMedia\XEngine_Source\XEngine_ServiceApp\XEngine_StreamMediaApp\StreamMedia_PullStream\PullStream_ClientWebRtc.cpp +// File Path: D:\XEngine_StreamMedia\XEngine_Source\XEngine_ServiceApp\XEngine_StreamMediaApp\StreamMedia_PullStream +// File Base: PullStream_ClientWebRtc +// File Ext: cpp +// Project: XEngine(网络通信引擎) +// Author: qyt +// Purpose: WEBRTC拉流服务 +// History: +*********************************************************************/ +bool PushStream_ClientProtocol_Dtls(LPCXSTR lpszMSGBuffer, int nMSGLen) +{ + // DTLS有可能以多种不同的记录层类型开头,这里检查它是否是handshake(0x16) + return ((nMSGLen >= 13) && (lpszMSGBuffer[0] == 0x16)); +} +bool PushStream_ClientProtocol_Stun(LPCXSTR lpszMSGBuffer, int nMSGLen) +{ + // STUN消息的类型字段(前两位为00)以及魔术cookie字段 + return (nMSGLen >= 20) && ((lpszMSGBuffer[0] & 0xC0) == 0x00) && (lpszMSGBuffer[4] == 0x21) && (lpszMSGBuffer[5] == 0x12) && ((XBYTE)lpszMSGBuffer[6] == 0xA4) && (lpszMSGBuffer[7] == 0x42); +} +bool PushStream_ClientProtocol_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszMsgBuffer, int nMsgLen) +{ + int nRVLen = 0; + int nSDLen = 0; + XCHAR tszRVBuffer[2048] = {}; + XCHAR tszSDBuffer[2048] = {}; + + if (PushStream_ClientProtocol_Dtls(lpszMsgBuffer, nMsgLen)) + { + nSDLen = 2048; + bool bConnect = false; + + if (!ModuleSession_PushStream_RTCConnGet(lpszClientAddr, &bConnect)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC客户端:%s,请求的DTLS协议处理失败,地址不存在"), lpszClientAddr); + return false; + } + + if (bConnect) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("RTC客户端:%s,请求的DTLS协议已经链接成功,但是发送了一段未知协议"), lpszClientAddr); + } + else + { + bool bRet = Cryption_Server_AcceptMemoryEx(xhRTCWhipSsl, hSocket, lpszClientAddr, tszSDBuffer, &nSDLen, lpszMsgBuffer, nMsgLen); + if (nSDLen > 0) + { + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_RTC); + } + + if (bRet) + { + XBYTE tszKEYBuffer[XPATH_MAX] = {}; + Cryption_Server_GetKeyEx(xhRTCWhipSsl, lpszClientAddr, tszKEYBuffer); + //创建SRTPCore + ModuleHelp_SRTPCore_Create(tszKEYBuffer); + //创建RTC会话 + ModuleSession_PushStream_RTCConnSet(lpszClientAddr, true); + //创建RTC会话 + int nIndexVideo = 0; + int nIndexAudio = 0; + ModuleSession_PushStream_RTCIndexGet(lpszClientAddr, &nIndexVideo, &nIndexAudio); + RTPProtocol_Parse_Insert(lpszClientAddr); + RTPProtocol_Parse_SetLink(lpszClientAddr, nIndexVideo, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_H264); + RTPProtocol_Parse_SetLink(lpszClientAddr, nIndexAudio, ENUM_STREAMMEDIA_RTPPROTOCOL_PAYLOAD_TYPE_OPUS); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,请求的DTLS握手协议处理成功,视频索引:%d,音频索引:%d"), lpszClientAddr, nIndexVideo, nIndexAudio); + } + else + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,请求的DTLS握手协议,还需要进一步处理,响应大小:%d"), lpszClientAddr, nSDLen); + } + } + } + else if (PushStream_ClientProtocol_Stun(lpszMsgBuffer, nMsgLen)) + { + int nAttrCount = 0; + RFCCOMPONENTS_NATATTR** ppSt_ListAttr; + RFCCOMPONENTS_NATSTUN st_NatClient = {}; + + if (!NatProtocol_StunNat_Parse(lpszMsgBuffer, nMsgLen, &st_NatClient, &ppSt_ListAttr, &nAttrCount)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC客户端:%s,请求的STUN协议不正确,解析失败,错误:%lX"), lpszClientAddr, NatProtocol_GetLastError()); + return false; + } + XCHAR tszUserStr[128] = {}; + for (int i = 0; i < nAttrCount; i++) + { + if (RFCCOMPONENTS_NATCLIENT_PROTOCOL_STUN_ATTR_USERNAME == ppSt_ListAttr[i]->wAttr) + { + memcpy(tszUserStr, ppSt_ListAttr[i]->tszMsgBuffer, ppSt_ListAttr[i]->wLen); + break; + } + } + BaseLib_Memory_Free((XPPPMEM)&ppSt_ListAttr, nAttrCount); + + int nPort = 0; + XCHAR tszIPPort[128] = {}; + _tcsxcpy(tszIPPort, lpszClientAddr); + APIAddr_IPAddr_SegAddr(tszIPPort, &nPort); + + NatProtocol_StunNat_BuildAttr(tszRVBuffer, &nRVLen, RFCCOMPONENTS_NATCLIENT_PROTOCOL_STUN_ATTR_USERNAME, tszUserStr, _tcsxlen(tszUserStr)); + NatProtocol_StunNat_BuildMapAddress(tszRVBuffer + nRVLen, &nRVLen, tszIPPort, nPort, true); + nSDLen = nRVLen; + NatProtocol_StunNat_Packet(tszSDBuffer, &nSDLen, (LPCXSTR)st_NatClient.byTokenStr, RFCCOMPONENTS_NATCLIENT_PROTOCOL_STUN_CLASS_RESPONSE, RFCCOMPONENTS_NATCLIENT_PROTOCOL_STUN_ATTR_MAPPED_ADDRESS, tszRVBuffer, true, st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEPass, true); + SocketOpt_HeartBeat_ActiveAddrEx(xhRTCWhipHeart, tszUserStr); //激活一次心跳 + //更新绑定地址 + ModuleSession_PushStream_RTCAddrSet(tszUserStr, lpszClientAddr); + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_RTC); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,请求的STUN协议处理成功,请求的用户:%s"), lpszClientAddr, tszUserStr); + } + else if (((XBYTE)lpszMsgBuffer[0] >> 6) == 2) + { + if (((XBYTE)lpszMsgBuffer[1] >= 200) && ((XBYTE)lpszMsgBuffer[1] <= 207)) + { + nRVLen = nMsgLen; + memcpy(tszRVBuffer, lpszMsgBuffer, nMsgLen); + + if (!ModuleHelp_SRTPCore_RTCPUNProtect(tszRVBuffer, &nRVLen)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC客户端:%s,RTCP协议解密失败,大小:%d,错误码:%lX"), lpszClientAddr, nMsgLen, ModuleHelp_GetLastError()); + return false; + } + //RTCP + RTCPPROTOCOL_RTCPHDR st_RTCPHdr = {}; + if (!RTCPProtocol_Parse_Header(tszRVBuffer, nRVLen, &st_RTCPHdr)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC客户端:%s,RTCP协议解析失败,大小:%d,错误码:%lX"), lpszClientAddr, nMsgLen, RTCPProtocol_GetLastError()); + return false; + } + int nPos = sizeof(RTCPPROTOCOL_RTCPHDR); + + int nListCount = 0; + RTCPPROTOCOL_RTCPRECVER** ppSt_ListRecvInfo; + RTCPProtocol_Parse_Recver(tszRVBuffer + nPos, nRVLen - nPos, &st_RTCPHdr, &ppSt_ListRecvInfo, &nListCount); + BaseLib_Memory_Free((XPPPMEM)&ppSt_ListRecvInfo, nListCount); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,请求的RTCP协议处理成功,请求处理的协议:%d"), lpszClientAddr, st_RTCPHdr.byPT); + } + else + { + nRVLen = nMsgLen; + memcpy(tszRVBuffer, lpszMsgBuffer, nMsgLen); + if (!ModuleHelp_SRTPCore_RTPUNProtect(tszRVBuffer, &nRVLen)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC客户端:%s,RTP协议解密失败,大小:%d,错误码:%lX"), lpszClientAddr, nMsgLen, ModuleHelp_GetLastError()); + return false; + } + /* + fwrite(tszRVBuffer, 1, nRVLen, pSt_VFile); + + XCHAR tszFileSize[64] = {}; + int nRet = _xstprintf(tszFileSize, _X("%d\r\n"), nRVLen); + fwrite(tszFileSize, 1, nRet, pSt_AFile); + */ + //RTP + if (!RTPProtocol_Parse_Send(lpszClientAddr, tszRVBuffer, nRVLen)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC客户端:%s,RTP协议解析失败,大小:%d,错误码:%lX"), lpszClientAddr, nMsgLen, RTPProtocol_GetLastError()); + return false; + } + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("RTC客户端:%s,%d,请求的RTP协议处理成功"), lpszClientAddr, nMsgLen); + } + } + else + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC客户端:%s,发送了不能识别的协议,大小:%d,首位值:%02X"), lpszClientAddr, nMsgLen, (XBYTE)lpszMsgBuffer[0]); + } + + return true; +} +bool PushStream_ClientProtocol_Thread() +{ + while (bIsRun) + { + RTPProtocol_Parse_WaitEvent(1); + + int nListCount = 0; + XENGINE_MANAGEPOOL_TASKEVENT** ppSt_ListAddr; + RTPProtocol_Parse_GetPool(1, &ppSt_ListAddr, &nListCount); + for (int i = 0; i < nListCount; i++) + { + int nVideoIndex = 0; + int nAudioIndex = 0; + ModuleSession_PushStream_RTCIndexGet(ppSt_ListAddr[i]->tszClientAddr, &nVideoIndex, &nAudioIndex); + while (true) + { + STREAMMEDIA_RTPPROTOCOL_HDR st_RTPHdr = {}; + int nMSGLen = 0; + st_RTPHdr.nPayID = nVideoIndex; + XCHAR* ptszMSGBuffer = NULL; + if (!RTPProtocol_Parse_Recv(ppSt_ListAddr[i]->tszClientAddr, &ptszMSGBuffer, &nMSGLen, &st_RTPHdr)) + { + break; + } + //fwrite(ptszMSGBuffer, 1, nMSGLen, pSt_VFile); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMSGBuffer); + } + while (true) + { + STREAMMEDIA_RTPPROTOCOL_HDR st_RTPHdr = {}; + int nMSGLen = 0; + st_RTPHdr.nPayID = nAudioIndex; + XCHAR* ptszMSGBuffer = NULL; + if (!RTPProtocol_Parse_Recv(ppSt_ListAddr[i]->tszClientAddr, &ptszMSGBuffer, &nMSGLen, &st_RTPHdr)) + { + break; + } + //fwrite(ptszMSGBuffer, 1, nRVLen, pSt_AFile); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMSGBuffer); + } + } + BaseLib_Memory_Free((XPPPMEM)&ppSt_ListAddr, nListCount); + } + return true; +} +bool PushStream_ClientWebRtc_SDKPacket(XNETHANDLE xhPacket, LPCXSTR lpszClientID, bool bVideo, int nAVIndex, STREAMMEDIA_SDPPROTOCOL_MEDIAINFO* pSt_SDPMediaInfo) +{ + XCHAR** pptszAVList; + BaseLib_Memory_Malloc((XPPPMEM)&pptszAVList, 1, XPATH_MAX); + + if (bVideo) + { + _xstprintf(pptszAVList[0], "%d", nAVIndex); + SDPProtocol_Packet_AddMedia(xhPacket, _X("video"), _X("UDP/TLS/RTP/SAVPF"), &pptszAVList, 1, 1, 9); + SDPProtocol_Packet_ClientInet(xhPacket); + } + else + { + _xstprintf(pptszAVList[0], "%d", nAVIndex); + SDPProtocol_Packet_AddMedia(xhPacket, _X("audio"), _X("UDP/TLS/RTP/SAVPF"), &pptszAVList, 1, 0, 9); + SDPProtocol_Packet_ClientInet(xhPacket); + } + //生成用户和密码 + SDPProtocol_Packet_ICEUser(xhPacket, st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEUser, st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEPass); + + int nDLen = 0; + XBYTE tszDigestStr[XPATH_MAX] = {}; + XCHAR tszDigestHex[XPATH_MAX] = {}; + int nPos = _xstprintf(tszDigestHex, _X("sha-256 ")); + Cryption_Api_Digest(st_ServiceConfig.st_XPull.st_PullWebRtc.tszDerStr, tszDigestStr, &nDLen, true, ENUM_XENGINE_CRYPTION_DIGEST_SHA256); + for (int i = 0; i < nDLen; i++) + { + int nRet = _xstprintf(tszDigestHex + nPos, _X("%02X"), tszDigestStr[i]); + nPos += nRet; + tszDigestHex[nPos] = ':'; + nPos++; + } + tszDigestHex[nPos - 1] = '\0'; + SDPProtocol_Packet_OptionalAddAttr(xhPacket, _X("fingerprint"), tszDigestHex); + SDPProtocol_Packet_OptionalAddAttr(xhPacket, _X("setup"), _X("passive")); + if (bVideo) + { + SDPProtocol_Packet_OnlyRWFlag(xhPacket); + SDPProtocol_Packet_RtcpComm(xhPacket, true, true); + SDPProtocol_Packet_VideoFmt(xhPacket, nAVIndex, pSt_SDPMediaInfo, true); + } + else + { + SDPProtocol_Packet_OnlyRWFlag(xhPacket); + SDPProtocol_Packet_RtcpComm(xhPacket, true, true); + SDPProtocol_Packet_AudioFmt(xhPacket, nAVIndex, pSt_SDPMediaInfo, true); + } + SDPProtocol_Packet_OptionalCandidate(xhPacket, st_ServiceConfig.tszIPAddr, st_ServiceConfig.nRTCWhipPort); + BaseLib_Memory_Free((XPPPMEM)&pptszAVList, 1); + return true; +} +bool PushStream_ClientWhip_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen) +{ + int nRVLen = 0; + int nSDLen = 0; + XNETHANDLE xhParse = 0; + XNETHANDLE xhPacket = 0; + XCHAR tszRVBuffer[4096] = {}; + XCHAR tszSDBuffer[4096] = {}; + XENGINE_PROTOCOL_AVINFO st_AVInfo = {}; + RFCCOMPONENTS_HTTP_HDRPARAM st_HDRParam = {}; + + st_HDRParam.nHttpCode = 200; //HTTP CODE码 + st_HDRParam.bIsClose = true; //收到回复后就关闭 + + XCHAR tszSMSAddr[128] = {}; + BaseLib_String_GetStartEnd(pSt_HTTPParam->tszHttpUri, tszSMSAddr, _X("app="), _X("&")); + _tcsxcat(tszSMSAddr, _X("/")); + BaseLib_String_GetStartEnd(pSt_HTTPParam->tszHttpUri, tszSMSAddr + _tcsxlen(tszSMSAddr), _X("stream="), NULL); + //查找流是否存在 + XCHAR tszPushAddr[128] = {}; + if (ModuleSession_PushStream_FindStream(tszSMSAddr, tszPushAddr)) + { + ModuleProtocol_Packet_Comm(tszRVBuffer, &nRVLen, NULL, 400, "stream is published"); + HttpProtocol_Server_SendMsgEx(xhHttpPacket, tszSDBuffer, &nSDLen, &st_HDRParam, tszRVBuffer, nRVLen); + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("WEBRTC:%s,请求推流的地址:%s 不正确,此流已经在推送"), lpszClientAddr, tszSMSAddr); + return false; + } + //解析SDP + if (!SDPProtocol_Parse_Create(&xhParse, lpszMsgBuffer, nMsgLen)) + { + ModuleProtocol_Packet_Comm(tszRVBuffer, &nRVLen, NULL, 400, "sdp is incorrent"); + HttpProtocol_Server_SendMsgEx(xhHttpPacket, tszSDBuffer, &nSDLen, &st_HDRParam, tszRVBuffer, nRVLen); + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("WEBRTC:%s,请求拉流的SDP不正确,错误:%lX"), lpszClientAddr, SDPProtocol_GetLastError()); + return false; + } + + int nIndex1 = -1; + int nIndex2 = -1; + int nListCount = 0; + XCHAR tszICEUser[XPATH_MAX] = {}; + XCHAR tszICEPass[XPATH_MAX] = {}; + XCHAR tszAlgType[XPATH_MAX] = {}; + XCHAR tszHMacStr[XPATH_MAX] = {}; + STREAMMEDIA_SDPPROTOCOL_ATTR** ppSt_ListAttr; + SDPProtocol_Parse_GetAttr(xhParse, &ppSt_ListAttr, &nListCount); + + SDPProtocol_Parse_AttrBundle(&ppSt_ListAttr, nListCount, &nIndex1, &nIndex2); + SDPProtocol_Parse_AttrICEUser(&ppSt_ListAttr, nListCount, tszICEUser, tszICEPass); + SDPProtocol_Parse_AttrFinger(&ppSt_ListAttr, nListCount, tszAlgType, tszHMacStr); + //查找合适的视频和音频流索引信息 + STREAMMEDIA_SDPPROTOCOL_MEDIAINFO st_SDPAudioInfo = {}; + STREAMMEDIA_SDPPROTOCOL_MEDIAINFO st_SDPVideoInfo = {}; + + int nVideoIndex = 0; + int nAudioIndex = 0; + int nAVCount = 0; + STREAMMEDIA_SDPPROTOCOL_AVMEDIA** ppSt_AVMedia; + SDPProtocol_Parse_GetAVMedia(xhParse, &ppSt_AVMedia, &nAVCount); + for (int i = 0; i < nAVCount; i++) + { + LPCXSTR lpszAudioStr = _X("audio"); + LPCXSTR lpszVideoStr = _X("video"); + if (0 == _tcsxnicmp(lpszAudioStr, ppSt_AVMedia[i]->tszAVType, _tcsxlen(lpszAudioStr))) + { + //查找列表 + for (int j = 0; j < ppSt_AVMedia[i]->nListCount; j++) + { + STREAMMEDIA_SDPPROTOCOL_MEDIAINFO st_SDPMeida = {}; + SDPProtocol_Parse_RTPMapAudio(&ppSt_ListAttr, nListCount, _ttxoi(ppSt_AVMedia[i]->pptszAVList[j]), &st_SDPMeida); + //推流一般只有一个 + if ((2 == st_SDPMeida.st_RTPMap.nChannel) && (0 == _tcsxnicmp(st_SDPMeida.st_RTPMap.tszCodecName, "opus", 4))) + { + nAudioIndex = _ttxoi(ppSt_AVMedia[i]->pptszAVList[j]); + st_SDPAudioInfo = st_SDPMeida; + + st_AVInfo.st_AudioInfo.bEnable = true; + st_AVInfo.st_AudioInfo.nChannel = st_SDPMeida.st_RTPMap.nChannel; + st_AVInfo.st_AudioInfo.nSampleRate = st_SDPMeida.st_RTPMap.nSampleRate; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("WEBRTC:%s,找到了合适的音频信息索引:%s"), lpszClientAddr, ppSt_AVMedia[i]->pptszAVList[j]); + break; + } + } + } + else if (0 == _tcsxnicmp(lpszVideoStr, ppSt_AVMedia[i]->tszAVType, _tcsxlen(lpszVideoStr))) + { + //查找列表 + for (int j = 0; j < ppSt_AVMedia[i]->nListCount; j++) + { + STREAMMEDIA_SDPPROTOCOL_MEDIAINFO st_SDPMeida = {}; + SDPProtocol_Parse_RTPMapVideo(&ppSt_ListAttr, nListCount, _ttxoi(ppSt_AVMedia[i]->pptszAVList[j]), &st_SDPMeida); + + if ((1 == st_SDPMeida.st_FmtpVideo.nPacketMode) && (0x42 == st_SDPMeida.st_FmtpVideo.tszLeaveId[0]) && (0xe0 == st_SDPMeida.st_FmtpVideo.tszLeaveId[1]) && (0x1f == st_SDPMeida.st_FmtpVideo.tszLeaveId[2]) && (0 == _tcsxnicmp(st_SDPMeida.st_RTPMap.tszCodecName, "H264", 4))) + { + nVideoIndex = _ttxoi(ppSt_AVMedia[i]->pptszAVList[j]); + st_SDPVideoInfo = st_SDPMeida; + + st_AVInfo.st_VideoInfo.bEnable = true; + st_AVInfo.st_VideoInfo.nFrameNumber = st_SDPMeida.st_FmtpVideo.nFrameRate; + st_AVInfo.st_VideoInfo.nBitRate = st_SDPMeida.st_RTPMap.nSampleRate; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("WEBRTC:%s,找到了合适的视频信息索引:%s,帧率:%d"), lpszClientAddr, ppSt_AVMedia[i]->pptszAVList[j], st_AVInfo.st_VideoInfo.nFrameRate); + } + } + } + } + + SDPProtocol_Parse_Destory(xhParse); + BaseLib_Memory_Free((XPPPMEM)&ppSt_ListAttr, nListCount); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("WEBRTC:%s,请求的SDP信息属性解析完毕,总共解析了:%d 个属性"), lpszClientAddr, nListCount); + + SDPProtocol_Packet_Create(&xhPacket); + SDPProtocol_Packet_Owner(xhPacket, _X("rtc"), xhPacket, _X("0.0.0.0")); + SDPProtocol_Packet_Session(xhPacket, _X("XEngine_Session")); + SDPProtocol_Packet_KeepTime(xhPacket); + if (nIndex1 >= 0 && nIndex2 >= 0) + { + SDPProtocol_Packet_Bundle(xhPacket); + } + else + { + SDPProtocol_Packet_Bundle(xhPacket, 0, -1); + } + SDPProtocol_Packet_OptionalAddAttr(xhPacket, _X("ice-lite")); + SDPProtocol_Packet_OptionalAddAttr(xhPacket, _X("msid-semantic"), _X("WMS *")); + + XCHAR tszTokenStr[XPATH_MAX] = {}; + XCHAR tszHDRStr[XPATH_MAX] = {}; + XCHAR tszUserStr[XPATH_MAX] = {}; + + BaseLib_Handle_CreateStr(tszTokenStr, 10); + _xstprintf(tszUserStr, _X("%s:%s"), st_ServiceConfig.st_XPull.st_PullWebRtc.tszICEUser, tszICEUser); + _xstprintf(tszHDRStr, _X("Location: /rtc/v1/whip/?action=delete&token=%s&app=live&stream=livestream.flv&session=%s\r\n"), tszTokenStr, tszUserStr); + + if (nIndex1 >= 0 && nIndex2 >= 0) + { + PushStream_ClientWebRtc_SDKPacket(xhPacket, tszUserStr, false, nAudioIndex, &st_SDPAudioInfo); + PushStream_ClientWebRtc_SDKPacket(xhPacket, tszUserStr, true, nVideoIndex, &st_SDPVideoInfo); + } + else + { + PushStream_ClientWebRtc_SDKPacket(xhPacket, tszUserStr, true, nVideoIndex, &st_SDPVideoInfo); + } + + SDPProtocol_Packet_GetPacket(xhPacket, tszRVBuffer, &nRVLen); + SDPProtocol_Packet_Destory(xhPacket); + + ModuleSession_PushStream_Create(tszUserStr, tszSMSAddr, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PULL_RTC); + ModuleSession_PushStream_RTCIndexSet(tszUserStr, nVideoIndex, nAudioIndex); + ModuleSession_PushStream_SetAVInfo(tszUserStr, &st_AVInfo); + SocketOpt_HeartBeat_InsertAddrEx(xhRTCWhipHeart, tszUserStr); //需要加入心跳,不然没法知道超时 + + st_HDRParam.nHttpCode = 201; + _xstprintf(st_HDRParam.tszMimeType, _X("application/sdp")); + HttpProtocol_Server_SendMsgEx(xhHttpPacket, tszSDBuffer, &nSDLen, &st_HDRParam, tszRVBuffer, nRVLen, tszHDRStr); + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("WEBRTC:%s,Whip协议推流请求成功"), lpszClientAddr); + return true; +} \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_ClientWebRtc.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_ClientWebRtc.h new file mode 100644 index 0000000..eb746d2 --- /dev/null +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_ClientWebRtc.h @@ -0,0 +1,16 @@ +#pragma once +/******************************************************************** +// Created: 2025/07/25 10:24:09 +// File Name: D:\XEngine_StreamMedia\XEngine_Source\XEngine_ServiceApp\XEngine_StreamMediaApp\StreamMedia_PushStream\PushStream_ClientWebRtc.h +// File Path: D:\XEngine_StreamMedia\XEngine_Source\XEngine_ServiceApp\XEngine_StreamMediaApp\StreamMedia_PushStream +// File Base: PushStream_ClientWebRtc +// File Ext: h +// Project: XEngine +// Author: qyt +// Purpose: WEBRTC推流服务 +// History: +*********************************************************************/ +bool PushStream_ClientProtocol_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszMsgBuffer, int nMsgLen); +bool PushStream_ClientProtocol_Thread(); +bool PushStream_ClientWebRtc_SDKPacket(XNETHANDLE xhPacket, LPCXSTR lpszClientID, bool bVideo, int nAVIndex, STREAMMEDIA_SDPPROTOCOL_MEDIAINFO* pSt_SDPMediaInfo); +bool PushStream_ClientWhip_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.cpp index a3baf89..53b693a 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.cpp @@ -10,7 +10,7 @@ // Purpose: JT1078流处理器 // History: *********************************************************************/ -XHTHREAD CALLBACK PushStream_JT1078Task_Thread(XPVOID lParam) +XHTHREAD XCALLBACK PushStream_JT1078Task_Thread(XPVOID lParam) { int nThreadPos = *(int*)lParam; nThreadPos++; @@ -31,8 +31,8 @@ XHTHREAD CALLBACK PushStream_JT1078Task_Thread(XPVOID lParam) int nMsgLen = 0; int nHDRLen = 0; XCHAR* ptszMsgBuffer; - XCHAR tszHdrBuffer[MAX_PATH]; - memset(tszHdrBuffer, '\0', MAX_PATH); + XCHAR tszHdrBuffer[XPATH_MAX]; + memset(tszHdrBuffer, '\0', XPATH_MAX); if (HelpComponents_PKTCustom_GetMemoryEx(xhJT1078Pkt, ppSt_PacketClient[i]->hSocket, &ptszMsgBuffer, &nMsgLen, tszHdrBuffer, &nHDRLen)) { @@ -75,7 +75,7 @@ bool PushStream_JT1078Task_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, { int nRVLen = 0; int nSDLen = 0; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; XCHAR tszDeviceNumber[128]; XCHAR* ptszRVBuffer = (XCHAR*)ManagePool_Memory_Alloc(xhMemoryPool, XENGINE_MEMORY_SIZE_MAX); XCHAR* ptszSDBuffer = (XCHAR*)ManagePool_Memory_Alloc(xhMemoryPool, XENGINE_MEMORY_SIZE_MAX); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.h index 99e896c..646f2be 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_JT1078Task.h @@ -10,6 +10,6 @@ // Purpose: JT1078流处理器 // History: *********************************************************************/ -XHTHREAD CALLBACK PushStream_JT1078Task_Thread(XPVOID lParam); +XHTHREAD XCALLBACK PushStream_JT1078Task_Thread(XPVOID lParam); bool PushStream_JT1078Task_Handle(XSOCKET hSocket, LPCXSTR lpszMsgBuffer, int nMsgLen, LPCXSTR lpszHDRBuffer, int nHDRLen); bool PushStream_JT1078Task_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_RTPPACKETHDR* pSt_RTPHdr, XENGINE_RTPPACKETTAIL* pSt_RTPTail); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.cpp index 43e6e90..4645055 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.cpp @@ -10,7 +10,7 @@ // Purpose: RTMP流处理协议 // History: *********************************************************************/ -XHTHREAD CALLBACK PushStream_RTMPTask_Thread(XPVOID lParam) +XHTHREAD XCALLBACK PushStream_RTMPTask_Thread(XPVOID lParam) { //任务池是编号1开始的. int nThreadPos = *(int*)lParam; @@ -40,7 +40,7 @@ XHTHREAD CALLBACK PushStream_RTMPTask_Thread(XPVOID lParam) //在另外一个函数里面处理数据 PushStream_RTMPTask_Handle(&st_RTMPHdr, ppSst_ListAddr[i]->tszClientAddr, ptszMsgBuffer, nMsgLen); //释放内存 - BaseLib_Memory_FreeCStyle((VOID**)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); } } } @@ -217,10 +217,10 @@ bool PushStream_RTMPTask_Handle(XENGINE_RTMPHDR* pSt_RTMPHdr, LPCXSTR lpszClient } else if (XENGINE_STREAMMEDIA_RTMP_MSGTYPE_COMMAND == pSt_RTMPHdr->byTypeID) { - XCHAR tszCMDBuffer[MAX_PATH]; + XCHAR tszCMDBuffer[XPATH_MAX]; XENGINE_RTMPCOMMAND st_RTMPCommand; - memset(tszCMDBuffer, '\0', MAX_PATH); + memset(tszCMDBuffer, '\0', XPATH_MAX); memset(&st_RTMPCommand, '\0', sizeof(XENGINE_RTMPCOMMAND)); RTMPProtocol_Help_ParseCommand(&st_RTMPCommand, lpszMsgBuffer, nMsgLen); @@ -360,8 +360,8 @@ bool PushStream_RTMPTask_Handle(XENGINE_RTMPHDR* pSt_RTMPHdr, LPCXSTR lpszClient { bool bSMSFound = false; XCHAR tszSMSAddr[2048]; - XCHAR tszLiveName[MAX_PATH]; - XCHAR tszPushAddr[MAX_PATH]; + XCHAR tszLiveName[XPATH_MAX]; + XCHAR tszPushAddr[XPATH_MAX]; memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); memset(tszLiveName, '\0', sizeof(tszLiveName)); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.h index ae39a32..b1b3163 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_RTMPTask.h @@ -11,7 +11,7 @@ // History: *********************************************************************/ //任务处理池,用来获取一个完整包 -XHTHREAD CALLBACK PushStream_RTMPTask_Thread(XPVOID lParam); +XHTHREAD XCALLBACK PushStream_RTMPTask_Thread(XPVOID lParam); //预处理封包 bool PushStream_RTMPTask_Play(LPCXSTR lpszClientAddr, LPCXSTR lpszPushAddr, XCHAR* ptszSDBuffer, XCHAR* ptszRVBuffer); //任务处理相关函数,处理包的内容 diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.cpp index 33c7a2c..cfac9ff 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.cpp @@ -13,7 +13,7 @@ bool PushStream_SrtTask_Connct(LPCXSTR lpszClientAddr, XSOCKET hSocket) { bool bPublish = false; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); if (!ModuleHelp_SrtCore_GetStreamID(hSocket, tszSMSAddr, &bPublish)) @@ -71,7 +71,7 @@ bool PushStream_SrtTask_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR return true; } -XHTHREAD CALLBACK PushStream_SRTTask_Thread(XPVOID lParam) +XHTHREAD XCALLBACK PushStream_SRTTask_Thread(XPVOID lParam) { //任务池是编号1开始的. int nThreadPos = *(int*)lParam; diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.h index f3c9051..7dd420a 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_SrtTask.h @@ -14,5 +14,5 @@ bool PushStream_SrtTask_Connct(LPCXSTR lpszClientAddr, XSOCKET hSocket); //任务处理相关函数,处理包的内容 bool PushStream_SrtTask_Handle(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszMsgBuffer, int nMsgLen); -XHTHREAD CALLBACK PushStream_SRTTask_Thread(XPVOID lParam); +XHTHREAD XCALLBACK PushStream_SRTTask_Thread(XPVOID lParam); bool PushStream_SrtTask_ThreadProcess(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, XBYTE byAVType); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.cpp index 3c66251..081781c 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.cpp @@ -10,7 +10,7 @@ // Purpose: X推流任务处理代码 // History: *********************************************************************/ -XHTHREAD CALLBACK PushStream_XStreamTask_Thread(XPVOID lParam) +XHTHREAD XCALLBACK PushStream_XStreamTask_Thread(XPVOID lParam) { //任务池是编号1开始的. int nThreadPos = *(int*)lParam; @@ -41,7 +41,7 @@ XHTHREAD CALLBACK PushStream_XStreamTask_Thread(XPVOID lParam) //在另外一个函数里面处理数据 PushStream_XStreamTask_Handle(&st_ProtocolHdr, ppSst_ListAddr[i]->tszClientAddr, ptszMsgBuffer, nMsgLen); //释放内存 - BaseLib_Memory_FreeCStyle((VOID**)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); } } } @@ -89,7 +89,7 @@ bool PushStream_XStreamTask_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR } else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_SMS_REQDESTROY == pSt_ProtocolHdr->unOperatorCode) { - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); XEngine_AVPacket_AVDelete(lpszClientAddr); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.h index 1c14cf1..07d9457 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/StreamMedia_PushStream/PushStream_XStreamTask.h @@ -11,6 +11,6 @@ // History: *********************************************************************/ //任务处理池,用来获取一个完整包 -XHTHREAD CALLBACK PushStream_XStreamTask_Thread(XPVOID lParam); +XHTHREAD XCALLBACK PushStream_XStreamTask_Thread(XPVOID lParam); //任务处理相关函数,处理包的内容 bool PushStream_XStreamTask_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_AVPacket.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_AVPacket.cpp index c3b5e30..bb9da3b 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_AVPacket.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_AVPacket.cpp @@ -26,12 +26,12 @@ bool XEngine_AVPacket_AVCreate(LPCXSTR lpszClientAddr) if (st_ServiceConfig.st_XPull.st_PullHls.bEnable) { - XCHAR tszSMSAddr[MAX_PATH] = {}; + XCHAR tszSMSAddr[XPATH_MAX] = {}; if (ModuleSession_PushStream_GetAddrForAddr(lpszClientAddr, tszSMSAddr)) { XNETHANDLE xhSub = 0; - XCHAR tszHLSFile[MAX_PATH] = {}; - XCHAR tszTSFile[MAX_PATH] = {}; + XCHAR tszHLSFile[XPATH_MAX] = {}; + XCHAR tszTSFile[XPATH_MAX] = {}; _xstprintf(tszHLSFile, _X("%s/%s.m3u8"), st_ServiceConfig.st_XPull.st_PullHls.tszHLSPath, tszSMSAddr); #ifdef _MSC_BUILD @@ -82,7 +82,7 @@ bool XEngine_AVPacket_AVSetTime(LPCXSTR lpszClientAddr, int nVideoParament, int } bool XEngine_AVPacket_AVPrePlay(LPCXSTR lpszClientAddr, XCHAR* ptszSDBuffer, XCHAR* ptszRVBuffer, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE enPushType) { - XCHAR tszSMSAddr[MAX_PATH] = {}; + XCHAR tszSMSAddr[XPATH_MAX] = {}; ModuleSession_PushStream_GetAddrForAddr(lpszClientAddr, tszSMSAddr); //获得所有预拉流客户端 int nListCount = 0; @@ -471,8 +471,8 @@ bool XEngine_AVPacket_AVFrame(XCHAR* ptszSDBuffer, int* pInt_SDLen, XCHAR* ptszR int nPATLen = 0; int nPMTLen = 0; - XBYTE tszPATBuffer[MAX_PATH] = {}; - XBYTE tszPMTBuffer[MAX_PATH] = {}; + XBYTE tszPATBuffer[XPATH_MAX] = {}; + XBYTE tszPMTBuffer[XPATH_MAX] = {}; //如果是关键帧 if (1 == byFrameType) { @@ -490,10 +490,10 @@ bool XEngine_AVPacket_AVFrame(XCHAR* ptszSDBuffer, int* pInt_SDLen, XCHAR* ptszR if (nCalValue >= XUINT(st_ServiceConfig.st_XPull.st_PullHls.nTime)) { XNETHANDLE xhSubFile = 0; - XCHAR tszTSFile[MAX_PATH] = {}; - XCHAR tszHLSFile[MAX_PATH] = {}; - XCHAR tszFile[MAX_PATH] = {}; - XCHAR tszSMSAddr[MAX_PATH] = {}; + XCHAR tszTSFile[XPATH_MAX] = {}; + XCHAR tszHLSFile[XPATH_MAX] = {}; + XCHAR tszFile[XPATH_MAX] = {}; + XCHAR tszSMSAddr[XPATH_MAX] = {}; ModuleSession_PushStream_GetAddrForAddr(lpszClientAddr, tszSMSAddr); ModuleSession_PushStream_HLSTimeSet(lpszClientAddr, __int64u(nTimeEnd)); @@ -562,14 +562,14 @@ bool XEngine_AVPacket_AVFrame(XCHAR* ptszSDBuffer, int* pInt_SDLen, XCHAR* ptszR { int nPacketCount = 0; STREAMMEDIA_RTPPROTOCOL_PACKET** ppSt_RTPPacket; - XCHAR tszSSCRStr[MAX_PATH] = {}; + XCHAR tszSSCRStr[XPATH_MAX] = {}; XCHAR tszADDRStr[128] = {}; if (0 == byAVType) { ModuleHelp_Rtsp_GetSsrc(stl_ListIteratorClient->tszClientID, tszSSCRStr, true); ModuleHelp_Rtsp_GetRTPAddr(stl_ListIteratorClient->tszClientID, tszADDRStr, true); - RTPProtocol_Packet_Packet(tszSSCRStr, lpszMsgBuffer + nStartCode, nMsgLen - nStartCode, &ppSt_RTPPacket, &nPacketCount); + RTPProtocol_Packet_Packet(tszSSCRStr, nRTPVIndex, lpszMsgBuffer + nStartCode, nMsgLen - nStartCode, &ppSt_RTPPacket, &nPacketCount); //发送数据,RTSP使用UDP发送 for (int i = 0; i < nPacketCount; i++) { @@ -580,7 +580,7 @@ bool XEngine_AVPacket_AVFrame(XCHAR* ptszSDBuffer, int* pInt_SDLen, XCHAR* ptszR { ModuleHelp_Rtsp_GetSsrc(stl_ListIteratorClient->tszClientID, tszSSCRStr, false); ModuleHelp_Rtsp_GetRTPAddr(stl_ListIteratorClient->tszClientID, tszADDRStr, false); - RTPProtocol_Packet_Packet(tszSSCRStr, lpszMsgBuffer, nMsgLen, &ppSt_RTPPacket, &nPacketCount); + RTPProtocol_Packet_Packet(tszSSCRStr, nRTPAIndex, lpszMsgBuffer, nMsgLen, &ppSt_RTPPacket, &nPacketCount); //发送数据,RTSP使用UDP发送 for (int i = 0; i < nPacketCount; i++) { @@ -602,12 +602,12 @@ bool XEngine_AVPacket_AVFrame(XCHAR* ptszSDBuffer, int* pInt_SDLen, XCHAR* ptszR { int nPacketCount = 0; STREAMMEDIA_RTPPROTOCOL_PACKET** ppSt_RTPPacket; - XCHAR tszSSCRStr[MAX_PATH] = {}; + XCHAR tszSSCRStr[XPATH_MAX] = {}; if (0 == byAVType) { ModuleSession_PullStream_RTCSSrcGet(stl_ListIteratorClient->tszClientID, tszSSCRStr, true); - RTPProtocol_Packet_Packet(tszSSCRStr, lpszMsgBuffer + nStartCode, nMsgLen - nStartCode, &ppSt_RTPPacket, &nPacketCount); + RTPProtocol_Packet_Packet(tszSSCRStr, 0, lpszMsgBuffer + nStartCode, nMsgLen - nStartCode, &ppSt_RTPPacket, &nPacketCount); //发送数据,RTSP使用UDP发送 for (int i = 0; i < nPacketCount; i++) { diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Configure.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Configure.cpp index e084308..280b0a0 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Configure.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Configure.cpp @@ -14,7 +14,6 @@ bool XEngine_Configure_Parament(int argc, char** argv) { LPCXSTR lpszServiceCfg = _X("./XEngine_Config/XEngine_Config.json"); LPCXSTR lpszServiceVersion = _X("./XEngine_Config/XEngine_Version.json"); - if (!ModuleConfigure_Json_File(lpszServiceCfg, &st_ServiceConfig)) { printf("解析配置文件失败,ModuleConfigure_Json_File:%lX", ModuleConfigure_GetLastError()); @@ -29,23 +28,39 @@ bool XEngine_Configure_Parament(int argc, char** argv) for (int i = 0; i < argc; i++) { - if ((0 == _tcsxcmp("-h", argv[i])) || (0 == _tcsxcmp("-H", argv[i]))) + if ((0 == _tcsxicmp("-h", argv[i])) || (0 == _tcsxicmp("-H", argv[i]))) { XEngine_Configure_Help(); return false; } - else if (0 == _tcsxcmp("-d", argv[i])) + else if (0 == _tcsxicmp("-d", argv[i])) { st_ServiceConfig.bDeamon = _ttxoi(argv[i + 1]); } - else if (0 == _tcsxcmp("-b", argv[i])) + else if (0 == _tcsxicmp("-b", argv[i])) { st_ServiceConfig.bDebug = true; } - else if (0 == _tcsxcmp("-t", argv[i])) + else if (0 == _tcsxicmp("-t", argv[i])) { bIsTest = true; } + else if (0 == _tcsxicmp("-l", argv[i])) + { + LPCXSTR lpszLogLevel = argv[++i]; + if (0 == _tcsxicmp("debug", lpszLogLevel)) + { + st_ServiceConfig.st_XLog.nLogLeave = XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DETAIL; + } + else if (0 == _tcsxicmp("detail", lpszLogLevel)) + { + st_ServiceConfig.st_XLog.nLogLeave = XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DETAIL; + } + else if (0 == _tcsxicmp("info", lpszLogLevel)) + { + st_ServiceConfig.st_XLog.nLogLeave = XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO; + } + } } return true; diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Hdr.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Hdr.h index f34bfbf..24d460c 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Hdr.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Hdr.h @@ -79,8 +79,8 @@ using namespace std; #include "../../XEngine_ModuleHelp/ModuleHelp_Error.h" #include "../../XEngine_ModuleQueue/ModuleQueue_Define.h" #include "../../XEngine_ModuleQueue/ModuleQueue_Error.h" -#include "../../XEngine_Depend/XEngine_Module/XEngine_InfoReport/InfoReport_Define.h" -#include "../../XEngine_Depend/XEngine_Module/XEngine_InfoReport/InfoReport_Error.h" +#include "../../XEngine_DependLibrary/XEngine_Module/XEngine_InfoReport/InfoReport_Define.h" +#include "../../XEngine_DependLibrary/XEngine_Module/XEngine_InfoReport/InfoReport_Error.h" //加载自己的头文件 #include "XEngine_Configure.h" #include "XEngine_Network.h" @@ -91,6 +91,7 @@ using namespace std; #include "./StreamMedia_PushStream/PushStream_JT1078Task.h" #include "./StreamMedia_PushStream/PushStream_RTMPTask.h" #include "./StreamMedia_PushStream/PushStream_SrtTask.h" +#include "./StreamMedia_PushStream/PushStream_ClientWebRtc.h" #include "./StreamMedia_PullStream/PullStream_ClientGet.h" #include "./StreamMedia_PullStream/PullStream_ClientRtsp.h" #include "./StreamMedia_PullStream/PullStream_ClientWebRtc.h" @@ -135,9 +136,13 @@ extern XHANDLE xhVRTCPSocket; extern XHANDLE xhARTPSocket; extern XHANDLE xhARTCPSocket; //WEBRTC网络 -extern XHANDLE xhRTCSocket; -extern XHANDLE xhRTCHeart; -extern XHANDLE xhRTCSsl; +extern XHANDLE xhRTCWhepSocket; +extern XHANDLE xhRTCWhepHeart; +extern XHANDLE xhRTCWhepSsl; +extern XHANDLE xhRTCWhipSocket; +extern XHANDLE xhRTCWhipHeart; +extern XHANDLE xhRTCWhipSsl; +extern std::unique_ptr pSTD_RTCThread; //HLS流 extern XNETHANDLE xhHLSFile; //配置文件 @@ -145,6 +150,11 @@ extern XENGINE_SERVICECONFIG st_ServiceConfig; //调试 extern FILE* pSt_VFile; extern FILE* pSt_AFile; + +//固定值 +static int nRTPVIndex = 96; +static int nRTPAIndex = 98; + //连接库 #ifdef _MSC_BUILD #pragma comment(lib,"Ws2_32.lib") diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.cpp index 936b328..1eb9819 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.cpp @@ -10,7 +10,7 @@ // Purpose: HTTP任务处理代码 // History: *********************************************************************/ -XHTHREAD CALLBACK XEngine_HTTPTask_Thread(XPVOID lParam) +XHTHREAD XCALLBACK XEngine_HTTPTask_Thread(XPVOID lParam) { //任务池是编号1开始的. int nThreadPos = *(int*)lParam; @@ -46,7 +46,7 @@ XHTHREAD CALLBACK XEngine_HTTPTask_Thread(XPVOID lParam) //在另外一个函数里面处理数据 XEngine_HTTPTask_Handle(&st_HTTPReqparam, ppSst_ListAddr[i]->tszClientAddr, ptszMsgBuffer, nMsgLen, &pptszListHdr, nHCount); //释放内存 - BaseLib_Memory_FreeCStyle((VOID**)&ptszMsgBuffer); + BaseLib_Memory_FreeCStyle((XPPMEM)&ptszMsgBuffer); BaseLib_Memory_Free((XPPPMEM)&pptszListHdr, nHCount); } } @@ -77,8 +77,10 @@ bool XEngine_HTTPTask_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR st_HDRParam.nHttpCode = 200; //HTTP CODE码 st_HDRParam.bIsClose = true; //收到回复后就关闭 - XCHAR tszAPIType[MAX_PATH] = {}; - HttpProtocol_ServerHelp_GetUrlApi(pSt_HTTPParam->tszHttpUri, tszAPIType); + XCHAR tszAPIType[128] = {}; + XCHAR tszAPIVer[128] = {}; + XCHAR tszAPIName[128] = {}; + HttpProtocol_ServerHelp_GetUrlApi(pSt_HTTPParam->tszHttpUri, tszAPIType, tszAPIVer, tszAPIName); //得到URL参数个数 HttpProtocol_ServerHelp_GetParament(pSt_HTTPParam->tszHttpUri, &pptszList, &nListCount, tszUrlName); if (nListCount < 1) @@ -114,7 +116,14 @@ bool XEngine_HTTPTask_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR { if (0 == _tcsxnicmp(lpszFunRtc, tszAPIType, _tcsxlen(lpszFunRtc))) { - PullStream_ClientWebRtc_Handle(pSt_HTTPParam, lpszClientAddr, lpszMsgBuffer, nMsgLen); + if (0 == _tcsxnicmp(tszAPIName, "whip", 4)) + { + PushStream_ClientWhip_Handle(pSt_HTTPParam, lpszClientAddr, lpszMsgBuffer, nMsgLen); + } + else + { + PullStream_ClientWhep_Handle(pSt_HTTPParam, lpszClientAddr, lpszMsgBuffer, nMsgLen); + } } } else if (0 == _tcsxnicmp(lpszMethodGet, pSt_HTTPParam->tszHttpMethod, _tcsxlen(lpszMethodGet))) diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.h index df0c7df..a3e175b 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_HttpTask.h @@ -11,6 +11,6 @@ // History: *********************************************************************/ //任务处理池,用来获取一个完整包 -XHTHREAD CALLBACK XEngine_HTTPTask_Thread(XPVOID lParam); +XHTHREAD XCALLBACK XEngine_HTTPTask_Thread(XPVOID lParam); //任务处理相关函数,处理包的内容 bool XEngine_HTTPTask_Handle(RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR*** ppptszHDRList, int nHDRCount); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.cpp index 5321ec9..8a54ebb 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.cpp @@ -11,14 +11,14 @@ // History: *********************************************************************/ //////////////////////////////////////////////////////////////////////////HTTP -bool CALLBACK Network_Callback_HttpLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +bool XCALLBACK Network_Callback_HttpLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { SocketOpt_HeartBeat_InsertAddrEx(xhHttpHeart, lpszClientAddr); HttpProtocol_Server_CreateClientEx(xhHttpPacket, lpszClientAddr, 0); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,连接到服务器"), lpszClientAddr); return true; } -void CALLBACK Network_Callback_HttpRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_HttpRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { if (!HttpProtocol_Server_InserQueueEx(xhHttpPacket, lpszClientAddr, lpszRecvMsg, nMsgLen)) { @@ -28,16 +28,16 @@ void CALLBACK Network_Callback_HttpRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, SocketOpt_HeartBeat_ActiveAddrEx(xhHttpHeart, lpszClientAddr); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("HTTP客户端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_HttpLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +void XCALLBACK Network_Callback_HttpLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, false, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_HTTP); } -void CALLBACK Network_Callback_HttpHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) +void XCALLBACK Network_Callback_HttpHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, true, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_HTTP); } //////////////////////////////////////////////////////////////////////////下面是X推流网络IO相关代码处理函数 -bool CALLBACK Network_Callback_XStreamLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +bool XCALLBACK Network_Callback_XStreamLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { //客户端连接后要把客户端插入心跳管理器中才有效 SocketOpt_HeartBeat_InsertAddrEx(xhXStreamHeart, lpszClientAddr); @@ -46,7 +46,7 @@ bool CALLBACK Network_Callback_XStreamLogin(LPCXSTR lpszClientAddr, XSOCKET hSoc XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("XStream推流端:%s,连接到服务器"), lpszClientAddr); return true; } -void CALLBACK Network_Callback_XStreamRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_XStreamRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { //接受到数据后直接投递给TCP包管理器,因为可能不是一个完整的包,所以我们的期望是通过此得到一个完整的包 if (!HelpComponents_Datas_PostEx(xhXStreamPacket, lpszClientAddr, lpszRecvMsg, nMsgLen)) @@ -58,25 +58,25 @@ void CALLBACK Network_Callback_XStreamRecv(LPCXSTR lpszClientAddr, XSOCKET hSock SocketOpt_HeartBeat_ActiveAddrEx(xhXStreamHeart, lpszClientAddr); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("XStream推流端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_XStreamLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +void XCALLBACK Network_Callback_XStreamLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { //交给指定函数来处理客户端离开消息 XEngine_Network_Close(lpszClientAddr, hSocket, false, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_XSTREAM); } -void CALLBACK Network_Callback_XStreamHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) +void XCALLBACK Network_Callback_XStreamHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { //同上 XEngine_Network_Close(lpszClientAddr, hSocket, true, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_XSTREAM); } //////////////////////////////////////////////////////////////////////////RTMP推流相关 -bool CALLBACK Network_Callback_RTMPLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +bool XCALLBACK Network_Callback_RTMPLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { RTMPProtocol_Parse_Insert(lpszClientAddr); SocketOpt_HeartBeat_InsertSocketEx(xhRTMPHeart, hSocket); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTMP推流端:%s,进入了服务器"), lpszClientAddr); return true; } -void CALLBACK Network_Callback_RTMPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_RTMPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { if (!RTMPProtocol_Parse_Send(lpszClientAddr, lpszRecvMsg, nMsgLen)) { @@ -87,23 +87,23 @@ void CALLBACK Network_Callback_RTMPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, SocketOpt_HeartBeat_ActiveAddrEx(xhJT1078Heart, lpszClientAddr); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("RTMP推流端:%s,投递包成功,大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_RTMPLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +void XCALLBACK Network_Callback_RTMPLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, false, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_RTMP); } -void CALLBACK Network_Callback_RTMPHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) +void XCALLBACK Network_Callback_RTMPHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, true, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_RTMP); } //////////////////////////////////////////////////////////////////////////JT1078协议流 -bool CALLBACK Network_Callback_JT1078Login(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +bool XCALLBACK Network_Callback_JT1078Login(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { SocketOpt_HeartBeat_InsertSocketEx(xhJT1078Heart, hSocket); HelpComponents_PKTCustom_CreateEx(xhJT1078Pkt, hSocket, 0); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("JT1078推流端:%s,进入了服务器"), lpszClientAddr); return true; } -void CALLBACK Network_Callback_JT1078Recv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_JT1078Recv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { if (!HelpComponents_PKTCustom_PostEx(xhJT1078Pkt, hSocket, lpszRecvMsg, nMsgLen)) { @@ -114,57 +114,67 @@ void CALLBACK Network_Callback_JT1078Recv(LPCXSTR lpszClientAddr, XSOCKET hSocke SocketOpt_HeartBeat_ActiveAddrEx(xhJT1078Heart, lpszClientAddr); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("JT1078推流端:%s,投递包成功,大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_JT1078Leave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +void XCALLBACK Network_Callback_JT1078Leave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, false, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_JT1078); } -void CALLBACK Network_Callback_JT1078HBLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) +void XCALLBACK Network_Callback_JT1078HBLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, true, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_JT1078); } //////////////////////////////////////////////////////////////////////////SRT -bool CALLBACK Network_Callback_SRTLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +bool XCALLBACK Network_Callback_SRTLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { PushStream_SrtTask_Connct(lpszClientAddr, hSocket); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SRT客户端:%s,进入了服务器"), lpszClientAddr); return true; } -void CALLBACK Network_Callback_SRTRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_SRTRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { PushStream_SrtTask_Handle(lpszClientAddr, hSocket, lpszRecvMsg, nMsgLen); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("SRT客户端:%s,接受到数据,数据大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_SRTLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) +void XCALLBACK Network_Callback_SRTLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, false, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PUSH_SRT); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SRT客户端:%s,离开了服务器"), lpszClientAddr); } //RTSP -void CALLBACK Network_Callback_VideoRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_VideoRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("RTP视频客户端:%s,发送数据大小:%d 给服务器"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_VideoRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_VideoRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { PullStream_ClientRtsp_RTCPProcess(lpszClientAddr, hSocket, lpszRecvMsg, nMsgLen); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("RTCP视频客户端:%s,发送数据大小:%d 给服务器"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_AudioRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_AudioRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("RTP音频客户端:%s,发送数据大小:%d 给服务器"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_AudioRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_AudioRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { PullStream_ClientRtsp_RTCPProcess(lpszClientAddr, hSocket, lpszRecvMsg, nMsgLen); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("RTCP音频客户端:%s,发送数据大小:%d 给服务器"), lpszClientAddr, nMsgLen); } //WEBRTC -void CALLBACK Network_Callback_RTCRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +void XCALLBACK Network_Callback_RTCWhepRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { PullStream_ClientProtocol_Handle(lpszClientAddr, hSocket, lpszRecvMsg, nMsgLen); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("STUN客户端:%s,发送数据大小:%d 给服务器"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_RTCHBLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) +void XCALLBACK Network_Callback_RTCWhipRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) +{ + PushStream_ClientProtocol_Handle(lpszClientAddr, hSocket, lpszRecvMsg, nMsgLen); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("STUN客户端:%s,发送数据大小:%d 给服务器"), lpszClientAddr, nMsgLen); +} +void XCALLBACK Network_Callback_RTCWhepLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) +{ + XEngine_Network_Close(lpszClientAddr, hSocket, true, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PULL_RTC); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,离开了服务器"), lpszClientAddr); +} +void XCALLBACK Network_Callback_RTCWhipLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, hSocket, true, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PULL_RTC); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("RTC客户端:%s,离开了服务器"), lpszClientAddr); @@ -242,8 +252,8 @@ void XEngine_Network_Close(LPCXSTR lpszClientAddr, XSOCKET hSocket, bool bHeart, XEngine_AVPacket_AVDelete(lpszClientAddr); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SRT客户端:%s,离开服务器,心跳标志:%d"), lpszClientAddr, bHeart); } - XCHAR tszSMSAddr[MAX_PATH]; - XCHAR tszPushAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; + XCHAR tszPushAddr[XPATH_MAX]; memset(tszSMSAddr, '\0', sizeof(tszSMSAddr)); memset(tszPushAddr, '\0', sizeof(tszPushAddr)); @@ -334,7 +344,19 @@ bool XEngine_Network_Send(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMs XCHAR tszIPPort[128] = {}; _tcsxcpy(tszIPPort, lpszClientAddr); APIAddr_IPAddr_SegAddr(tszIPPort, &nPort); - if (!NetCore_UDPSelect_Send(xhRTCSocket, lpszMsgBuffer, nMsgLen, tszIPPort, nPort)) + if (!NetCore_UDPSelect_Send(xhRTCWhipSocket, lpszMsgBuffer, nMsgLen, tszIPPort, nPort)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC服务端:%s,发送数据失败,大小:%d,错误:%lX"), lpszClientAddr, nMsgLen, NetCore_GetLastError()); + return false; + } + } + else if (ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE_PULL_RTC == enClientType) + { + int nPort = 0; + XCHAR tszIPPort[128] = {}; + _tcsxcpy(tszIPPort, lpszClientAddr); + APIAddr_IPAddr_SegAddr(tszIPPort, &nPort); + if (!NetCore_UDPSelect_Send(xhRTCWhepSocket, lpszMsgBuffer, nMsgLen, tszIPPort, nPort)) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("RTC服务端:%s,发送数据失败,大小:%d,错误:%lX"), lpszClientAddr, nMsgLen, NetCore_GetLastError()); return false; diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.h b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.h index 5c6800b..034f863 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_Network.h @@ -11,37 +11,39 @@ // History: *********************************************************************/ //HTTP相关 -bool CALLBACK Network_Callback_HttpLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户连接 -void CALLBACK Network_Callback_HttpRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); //接受到数据 -void CALLBACK Network_Callback_HttpLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户离开 -void CALLBACK Network_Callback_HttpHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //心跳超时 +bool XCALLBACK Network_Callback_HttpLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户连接 +void XCALLBACK Network_Callback_HttpRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); //接受到数据 +void XCALLBACK Network_Callback_HttpLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户离开 +void XCALLBACK Network_Callback_HttpHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //心跳超时 //X推流相关 -bool CALLBACK Network_Callback_XStreamLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户连接 -void CALLBACK Network_Callback_XStreamRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); //接受到数据 -void CALLBACK Network_Callback_XStreamLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户离开 -void CALLBACK Network_Callback_XStreamHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //心跳超时 +bool XCALLBACK Network_Callback_XStreamLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户连接 +void XCALLBACK Network_Callback_XStreamRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); //接受到数据 +void XCALLBACK Network_Callback_XStreamLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户离开 +void XCALLBACK Network_Callback_XStreamHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //心跳超时 //RTMP推流相关 -bool CALLBACK Network_Callback_RTMPLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); -void CALLBACK Network_Callback_RTMPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); -void CALLBACK Network_Callback_RTMPLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); -void CALLBACK Network_Callback_RTMPHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); +bool XCALLBACK Network_Callback_RTMPLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void XCALLBACK Network_Callback_RTMPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_RTMPLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void XCALLBACK Network_Callback_RTMPHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //JT1078 -bool CALLBACK Network_Callback_JT1078Login(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); -void CALLBACK Network_Callback_JT1078Recv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); -void CALLBACK Network_Callback_JT1078Leave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); -void CALLBACK Network_Callback_JT1078HBLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); +bool XCALLBACK Network_Callback_JT1078Login(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void XCALLBACK Network_Callback_JT1078Recv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_JT1078Leave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void XCALLBACK Network_Callback_JT1078HBLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //SRT -bool CALLBACK Network_Callback_SRTLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); -void CALLBACK Network_Callback_SRTRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); -void CALLBACK Network_Callback_SRTLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +bool XCALLBACK Network_Callback_SRTLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void XCALLBACK Network_Callback_SRTRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_SRTLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //UDP -void CALLBACK Network_Callback_VideoRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); -void CALLBACK Network_Callback_VideoRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); -void CALLBACK Network_Callback_AudioRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); -void CALLBACK Network_Callback_AudioRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_VideoRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_VideoRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_AudioRTPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_AudioRTCPRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); //WEBRTC -void CALLBACK Network_Callback_RTCRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); -void CALLBACK Network_Callback_RTCHBLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); +void XCALLBACK Network_Callback_RTCWhepRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_RTCWhipRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void XCALLBACK Network_Callback_RTCWhepLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); +void XCALLBACK Network_Callback_RTCWhipLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //关闭与发送 void XEngine_Network_Close(LPCXSTR lpszClientAddr, XSOCKET hSocket, bool bHeart, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE enClientType); bool XEngine_Network_Send(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, ENUM_XENGINE_STREAMMEDIA_CLIENT_TYPE enClientType); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.cpp index 3ec29c0..7516980 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.cpp @@ -40,9 +40,13 @@ XHANDLE xhVRTCPSocket = NULL; XHANDLE xhARTPSocket = NULL; XHANDLE xhARTCPSocket = NULL; //WEBRTC网络 -XHANDLE xhRTCSocket = NULL; -XHANDLE xhRTCHeart = NULL; -XHANDLE xhRTCSsl = NULL; +XHANDLE xhRTCWhepSocket = NULL; +XHANDLE xhRTCWhepHeart = NULL; +XHANDLE xhRTCWhepSsl = NULL; +XHANDLE xhRTCWhipSocket = NULL; +XHANDLE xhRTCWhipHeart = NULL; +XHANDLE xhRTCWhipSsl = NULL; +std::unique_ptr pSTD_RTCThread = NULL; //HLS流 XNETHANDLE xhHLSFile = 0; //配置文件 @@ -71,15 +75,18 @@ void ServiceApp_Stop(int signo) } if (st_ServiceConfig.st_XPull.st_PullWebRtc.bEnable) { - NetCore_UDPSelect_Stop(xhRTCSocket); - Cryption_Server_StopEx(xhRTCSsl); + NetCore_UDPSelect_Stop(xhRTCWhipSocket); + NetCore_UDPSelect_Stop(xhRTCWhepSocket); + Cryption_Server_StopEx(xhRTCWhipSsl); + Cryption_Server_StopEx(xhRTCWhepSsl); } //销毁心跳 SocketOpt_HeartBeat_DestoryEx(xhHttpHeart); SocketOpt_HeartBeat_DestoryEx(xhXStreamHeart); SocketOpt_HeartBeat_DestoryEx(xhRTMPHeart); SocketOpt_HeartBeat_DestoryEx(xhJT1078Heart); - SocketOpt_HeartBeat_DestoryEx(xhRTCHeart); + SocketOpt_HeartBeat_DestoryEx(xhRTCWhipHeart); + SocketOpt_HeartBeat_DestoryEx(xhRTCWhepHeart); //销毁包管理器 HttpProtocol_Server_DestroyEx(xhHttpPacket); HelpComponents_Datas_Destory(xhXStreamPacket); @@ -87,6 +94,7 @@ void ServiceApp_Stop(int signo) RTMPProtocol_Parse_Destory(); FLVProtocol_Parse_Destory(); HLSProtocol_TSParse_Destory(); + RTPProtocol_Parse_Destory(); //销毁线程池 ManagePool_Thread_NQDestroy(xhHttpPool); ManagePool_Thread_NQDestroy(xhXStreamPool); @@ -99,6 +107,14 @@ void ServiceApp_Stop(int signo) ManagePool_Memory_Destory(xhMemoryPool); HelpComponents_XLog_Destroy(xhLog); + + if (NULL != pSTD_RTCThread) + { + if (pSTD_RTCThread->joinable()) + { + pSTD_RTCThread->join(); + } + } if (NULL != pSt_AFile) { fclose(pSt_AFile); @@ -147,7 +163,7 @@ static int ServiceApp_Deamon() LONG WINAPI Coredump_ExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) { static int i = 0; - XCHAR tszFileStr[MAX_PATH] = {}; + XCHAR tszFileStr[XPATH_MAX] = {}; XCHAR tszTimeStr[128] = {}; BaseLib_Time_TimeToStr(tszTimeStr); _xstprintf(tszFileStr, _X("./XEngine_Coredump/dumpfile_%s_%d.dmp"), tszTimeStr, i++); @@ -201,7 +217,7 @@ int main(int argc, char** argv) memset(&st_ServiceConfig, '\0', sizeof(XENGINE_SERVICECONFIG)); //pSt_VFile = _xtfopen("./1.h264", "wb"); - //pSt_AFile = _xtfopen("./1.aac", "wb"); + //pSt_AFile = _xtfopen("./1.opus", "wb"); //初始化参数 if (!XEngine_Configure_Parament(argc, argv)) { @@ -238,6 +254,13 @@ int main(int argc, char** argv) goto XENGINE_SERVICEAPP_EXIT; } XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化内存池成功")); + + if (!RTPProtocol_Parse_Init(1)) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化RTP包解析器失败,错误:%lX"), RTPProtocol_GetLastError()); + goto XENGINE_SERVICEAPP_EXIT; + } + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化RTP包解析器成功")); //启动HTTP服务相关代码 if (st_ServiceConfig.nHttpPort > 0) { @@ -570,42 +593,79 @@ int main(int argc, char** argv) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,RTSP拉流服务被禁用")); } - - if (st_ServiceConfig.st_XPull.st_PullWebRtc.bEnable) + //webrtc 拉流服务 + if (st_ServiceConfig.st_XPull.st_PullWebRtc.bEnable && (st_ServiceConfig.nRTCWhepPort > 0)) { - xhRTCSsl = Cryption_Server_InitEx(st_ServiceConfig.st_XPull.st_PullWebRtc.tszCertStr, NULL, st_ServiceConfig.st_XPull.st_PullWebRtc.tszKeyStr, false, false, XENGINE_CRYPTION_PROTOCOL_DTL); - if (NULL == xhRTCSsl) + xhRTCWhepSsl = Cryption_Server_InitEx(st_ServiceConfig.st_XPull.st_PullWebRtc.tszCertStr, NULL, st_ServiceConfig.st_XPull.st_PullWebRtc.tszKeyStr, false, false, XENGINE_CRYPTION_PROTOCOL_DTL); + if (NULL == xhRTCWhepSsl) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动WEBRTC-DTLS安全网络,错误:%lX"), Cryption_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动拉流WEBRTC-DTLS安全网络,错误:%lX"), Cryption_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - Cryption_Server_ConfigEx(xhRTCSsl); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,加载RTC证书成功:%s,%s"), st_ServiceConfig.st_XPull.st_PullWebRtc.tszCertStr, st_ServiceConfig.st_XPull.st_PullWebRtc.tszKeyStr); + Cryption_Server_ConfigEx(xhRTCWhepSsl); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,加载拉流RTC证书成功:%s,%s"), st_ServiceConfig.st_XPull.st_PullWebRtc.tszCertStr, st_ServiceConfig.st_XPull.st_PullWebRtc.tszKeyStr); - xhRTCSocket = NetCore_UDPSelect_Start(st_ServiceConfig.nRTCPort); - if (NULL == xhRTCSocket) + xhRTCWhepSocket = NetCore_UDPSelect_Start(st_ServiceConfig.nRTCWhepPort); + if (NULL == xhRTCWhepSocket) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动WEBRTC网络端口:%d 失败,错误:%d"), st_ServiceConfig.nRTCPort, errno); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动拉流WEBRTC网络端口:%d 失败,错误:%d"), st_ServiceConfig.nRTCWhepPort, errno); goto XENGINE_SERVICEAPP_EXIT; } - NetCore_UDPSelect_RegisterCallBack(xhRTCSocket, Network_Callback_RTCRecv); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动WEBRTC端口:%d 成功"), st_ServiceConfig.nRTCPort); + NetCore_UDPSelect_RegisterCallBack(xhRTCWhepSocket, Network_Callback_RTCWhepRecv); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动拉流WEBRTC端口:%d 成功"), st_ServiceConfig.nRTCWhepPort); if (st_ServiceConfig.st_XTime.nRTCTimeout > 0) { - xhRTCHeart = SocketOpt_HeartBeat_InitEx(st_ServiceConfig.st_XTime.nRTCTimeout, st_ServiceConfig.st_XTime.nTimeCheck, Network_Callback_RTCHBLeave); - if (NULL == xhRTCHeart) + xhRTCWhepHeart = SocketOpt_HeartBeat_InitEx(st_ServiceConfig.st_XTime.nRTCTimeout, st_ServiceConfig.st_XTime.nTimeCheck, Network_Callback_RTCWhepLeave); + if (NULL == xhRTCWhepHeart) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化RTC心跳管理服务失败,错误:%lX"), NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化拉流RTC心跳管理服务失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化RTC心跳管理服务成功,检测时间:%d"), st_ServiceConfig.st_XTime.nRTCTimeout); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化拉流RTC心跳管理服务成功,检测时间:%d"), st_ServiceConfig.st_XTime.nRTCTimeout); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,RTC心跳管理服务没有启用!")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,拉流RTC心跳管理服务没有启用!")); } } + //webrtc 推流 + if (st_ServiceConfig.st_XPull.st_PullWebRtc.bEnable && (st_ServiceConfig.nRTCWhipPort > 0)) + { + xhRTCWhipSsl = Cryption_Server_InitEx(st_ServiceConfig.st_XPull.st_PullWebRtc.tszCertStr, NULL, st_ServiceConfig.st_XPull.st_PullWebRtc.tszKeyStr, false, false, XENGINE_CRYPTION_PROTOCOL_DTL); + if (NULL == xhRTCWhipSsl) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动推流WEBRTC-DTLS安全网络,错误:%lX"), Cryption_GetLastError()); + goto XENGINE_SERVICEAPP_EXIT; + } + Cryption_Server_ConfigEx(xhRTCWhipSsl); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,加载推流RTC证书成功:%s,%s"), st_ServiceConfig.st_XPull.st_PullWebRtc.tszCertStr, st_ServiceConfig.st_XPull.st_PullWebRtc.tszKeyStr); + + xhRTCWhipSocket = NetCore_UDPSelect_Start(st_ServiceConfig.nRTCWhipPort); + if (NULL == xhRTCWhipSocket) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动推流WEBRTC网络端口:%d 失败,错误:%d"), st_ServiceConfig.nRTCWhipPort, errno); + goto XENGINE_SERVICEAPP_EXIT; + } + NetCore_UDPSelect_RegisterCallBack(xhRTCWhipSocket, Network_Callback_RTCWhipRecv); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动推流WEBRTC端口:%d 成功"), st_ServiceConfig.nRTCWhipPort); + + if (st_ServiceConfig.st_XTime.nRTCTimeout > 0) + { + xhRTCWhipHeart = SocketOpt_HeartBeat_InitEx(st_ServiceConfig.st_XTime.nRTCTimeout, st_ServiceConfig.st_XTime.nTimeCheck, Network_Callback_RTCWhipLeave); + if (NULL == xhRTCWhipHeart) + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化推流RTC心跳管理服务失败,错误:%lX"), NetCore_GetLastError()); + goto XENGINE_SERVICEAPP_EXIT; + } + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化推流RTC心跳管理服务成功,检测时间:%d"), st_ServiceConfig.st_XTime.nRTCTimeout); + } + else + { + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,推流RTC心跳管理服务没有启用!")); + } + pSTD_RTCThread = std::make_unique(PushStream_ClientProtocol_Thread); + } if (st_ServiceConfig.st_XPull.st_PullHls.bEnable) { @@ -625,7 +685,7 @@ int main(int argc, char** argv) if (st_ServiceConfig.st_XReport.bEnable && !bIsTest) { __int64x nTimeCount = 0; - if (InfoReport_APIMachine_Send(st_ServiceConfig.st_XReport.tszAPIUrl, st_ServiceConfig.st_XReport.tszServiceName)) + if (InfoReport_APIMachine_Send(st_ServiceConfig.st_XReport.tszAPIUrl, st_ServiceConfig.st_XReport.tszServiceName, &nTimeCount)) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动信息报告给API服务器:%s 成功,报告次数:%lld"), st_ServiceConfig.st_XReport.tszAPIUrl, nTimeCount); } @@ -679,15 +739,18 @@ int main(int argc, char** argv) } if (st_ServiceConfig.st_XPull.st_PullWebRtc.bEnable) { - NetCore_UDPSelect_Stop(xhRTCSocket); - Cryption_Server_StopEx(xhRTCSsl); + NetCore_UDPSelect_Stop(xhRTCWhepSocket); + NetCore_UDPSelect_Stop(xhRTCWhipSocket); + Cryption_Server_StopEx(xhRTCWhepSsl); + Cryption_Server_StopEx(xhRTCWhipSsl); + SocketOpt_HeartBeat_DestoryEx(xhRTCWhepHeart); + SocketOpt_HeartBeat_DestoryEx(xhRTCWhipHeart); } //销毁心跳 SocketOpt_HeartBeat_DestoryEx(xhHttpHeart); SocketOpt_HeartBeat_DestoryEx(xhXStreamHeart); SocketOpt_HeartBeat_DestoryEx(xhRTMPHeart); SocketOpt_HeartBeat_DestoryEx(xhJT1078Heart); - SocketOpt_HeartBeat_DestoryEx(xhRTCHeart); //销毁包管理器 HttpProtocol_Server_DestroyEx(xhHttpPacket); HelpComponents_Datas_Destory(xhXStreamPacket); @@ -695,6 +758,7 @@ int main(int argc, char** argv) RTMPProtocol_Parse_Destory(); FLVProtocol_Parse_Destory(); HLSProtocol_TSParse_Destory(); + RTPProtocol_Parse_Destory(); //销毁线程池 ManagePool_Thread_NQDestroy(xhHttpPool); ManagePool_Thread_NQDestroy(xhXStreamPool); @@ -707,6 +771,14 @@ int main(int argc, char** argv) ManagePool_Memory_Destory(xhMemoryPool); HelpComponents_XLog_Destroy(xhLog); + + if (NULL != pSTD_RTCThread) + { + if (pSTD_RTCThread->joinable()) + { + pSTD_RTCThread->join(); + } + } if (NULL != pSt_AFile) { fclose(pSt_AFile); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj index 5f627b0..fe87fb3 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj @@ -228,6 +228,7 @@ + @@ -243,6 +244,7 @@ + diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj.filters b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj.filters index 4353424..e6abed3 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj.filters +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_StreamMediaApp/XEngine_StreamMediaApp.vcxproj.filters @@ -72,6 +72,9 @@ 源文件\StreamMedia_PullStream + + 源文件\StreamMedia_PushStream + @@ -113,5 +116,8 @@ 头文件\StreamMedia_PullStream + + 头文件\StreamMedia_PushStream + \ No newline at end of file diff --git a/XEngine_Source/XEngine_UserProtocol.h b/XEngine_Source/XEngine_UserProtocol.h index 97568f9..beb0800 100644 --- a/XEngine_Source/XEngine_UserProtocol.h +++ b/XEngine_Source/XEngine_UserProtocol.h @@ -70,7 +70,7 @@ typedef enum typedef struct { XENGINE_PROTOCOL_AVINFO st_AVInfo; - XCHAR tszSMSAddr[MAX_PATH]; + XCHAR tszSMSAddr[XPATH_MAX]; }XENGINE_PROTOCOLSTREAM; //////////////////////////////////////////////////////////////////////////设备协议RTP typedef struct