Skip to content

avformat/whip: fix H264 profile_iop bit map for SDP #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: workflows
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .augment-guidelines
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Augment Guidelines for FFmpeg Repository

project:
name: "FFmpeg"
description: |
A complete, cross-platform solution to record, convert and stream audio and video.
type: "media"

architecture:
overview: |
FFmpeg is organized into several core libraries that handle different aspects of
multimedia processing. The codebase follows a modular design where each library
can be used independently or together. FFmpeg also provides command-line tools
built on top of these libraries.

key_directories:
- path: "libavcodec"
description: |
Implements encoders and decoders for audio/video codecs and bitstream processing
- path: "libavdevice"
description: |
Provides abstraction for accessing capture and playback devices
- path: "libavfilter"
description: |
Implements media filtering framework for processing audio and video
- path: "libavformat"
description: |
Handles container formats, muxing/demuxing, and I/O protocols
- path: "libavutil"
description: |
Contains utility functions, data structures, and common components shared across
libraries
- path: "libswresample"
description: |
Implements audio mixing and resampling routines
- path: "tests"
description: |
Contains test suites and validation tools for FFmpeg functionality

components:
- name: "WHIP"
description: |
WebRTC-HTTP Ingestion Protocol implementation for low-latency streaming. Handles
SDP exchange, ICE connectivity, DTLS handshake, SRTP encryption, and RTP
packetization for WebRTC streaming.
related_files:
- path: "libavformat/whip.c"
description: |
Core implementation of the WHIP protocol, including SDP offer/answer exchange,
ICE connectivity, DTLS handshake setup, and SRTP encryption for RTP packets
- path: "libavformat/tls.h"
description: |
Header defining the DTLS interface used by WHIP for secure communication,
including functions for certificate handling and DTLS state management
- path: "libavformat/tls.c"
description: |
Common DTLS implementation shared across different SSL backends, providing
UDP socket setup for DTLS connections
- path: "libavformat/tls_openssl.c"
description: |
OpenSSL-specific implementation of DTLS functionality, including handshake
procedures and SRTP key material export
25 changes: 25 additions & 0 deletions .augmentignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Build artifacts
**/objs/**
**/build/**
**/*.o
**/*.a
**/*.so
**/*.dylib
**/*.d

# IDE files
**/.idea/**
**/.vscode/**
**/.run/**

# Generated files
**/.tmp/**
**/fate-suite/**
**/*.flv
**/*.mp4
**/*.ts

# Other files.
**/tools/**
**/tests/**
24 changes: 24 additions & 0 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# docker build -t ossrs/srs:ffmpeg-fate
# docker push ossrs/srs:ffmpeg-fate
FROM ubuntu:22.04

RUN apt-get update && \
apt-get install -y build-essential git rsync make nasm pkg-config libssl-dev &&\
rm -rf /var/lib/apt/lists/*

WORKDIR /opt
RUN git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg

WORKDIR /opt/ffmpeg
RUN ./configure --enable-openssl --enable-version3
RUN make -j$(nproc)

RUN make fate-rsync SAMPLES=/opt/ffmpeg/fate-suite
RUN du -sh /opt/ffmpeg/fate-suite

# Note that you should use the fate-suite.tar, then extract it out of
# docker, to avoid resync all files.
RUN tar cf fate-suite.tar fate-suite
RUN du -sh /opt/ffmpeg/fate-suite.tar

ENV FATE_SAMPLES=/opt/ffmpeg/fate-suite
189 changes: 189 additions & 0 deletions .github/scripts/format-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#!/bin/bash

LOGPREFIX=">>"

if [[ $(jq --version 1>/dev/null 2>&1 && echo yes) != "yes" ]]; then
echo "${LOGPREFIX} Tool jq is not installed. Please install it to parse JSON data. For example:"
echo "${LOGPREFIX} apt install jq"
echo "${LOGPREFIX} brew install jq"
echo "${LOGPREFIX} yum install jq"
echo "${LOGPREFIX} See https://github.com/jqlang/jq"
exit 1
fi

PR_NUMBER="$1"
PATCH_FILE="$2"
TMP_BRANCH="$3"
if [ -z "$PR_NUMBER" ]; then
echo "${LOGPREFIX} Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20"
exit 1
fi

if [[ "$1" =~ ^https://github.com/ossrs/ffmpeg-webrtc/pull/([0-9]+)$ ]]; then
PR_NUMBER="${BASH_REMATCH[1]}"
elif [[ "$1" =~ ^[0-9]+$ ]]; then
PR_NUMBER="$1"
else
echo "${LOGPREFIX} Invalid input format. Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20"
exit 1
fi

PR_URL="https://github.com/ossrs/ffmpeg-webrtc/pull/$PR_NUMBER"
echo "${LOGPREFIX} Fetching PR #$PR_NUMBER from $PR_URL"

PR_DATA=$(curl -s "https://api.github.com/repos/ossrs/ffmpeg-webrtc/pulls/$PR_NUMBER")
REPO_NAME=$(printf '%s' "$PR_DATA" | jq -r '.head.repo.full_name')
BRANCH_NAME=$(printf '%s' "$PR_DATA" | jq -r '.head.ref')
echo "${LOGPREFIX} Repository: $REPO_NAME, Branch: $BRANCH_NAME"
if [[ -z "$REPO_NAME" || -z "$BRANCH_NAME" ]]; then
echo "${LOGPREFIX} Error: REPO_NAME or BRANCH_NAME is empty!"
exit 1
fi

PR_TITLE=$(printf '%s' "$PR_DATA" | jq -r '.title')
PR_DESCRIPTION=$(printf '%s' "$PR_DATA" | jq -r '.body // ""')
echo "${LOGPREFIX} PR information:"
echo "${LOGPREFIX} ==================================================================="
echo "${LOGPREFIX} $PR_TITLE"
echo "${LOGPREFIX} $PR_DESCRIPTION"
echo "${LOGPREFIX} ==================================================================="
echo "${LOGPREFIX} "
if [[ -z "$PR_TITLE" ]]; then
echo "${LOGPREFIX} Error: PR title is empty!"
exit 1
fi

git checkout workflows &&
echo "${LOGPREFIX} Switched to workflows branch." &&
git pull &&
echo "${LOGPREFIX} Pulled latest changes from workflows branch."
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to switch to workflows branch or pull latest changes."
exit 1
fi

REMOTE_NAME=patch-tmp &&
if git remote | grep -q "^$REMOTE_NAME$"; then
git remote rm "$REMOTE_NAME"
fi &&
git remote add $REMOTE_NAME https://github.com/${REPO_NAME}.git &&
git fetch $REMOTE_NAME $BRANCH_NAME &&
echo "${LOGPREFIX} Fetch remote $REMOTE_NAME at $(git remote get-url $REMOTE_NAME)"
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to fetch remote branch $BRANCH_NAME from $REMOTE_NAME."
exit 1
fi

if [[ -z "$TMP_BRANCH" ]]; then
TMP_BRANCH="tmp-branch-for-patch-$PR_NUMBER"
fi &&
if git branch --list "$TMP_BRANCH" | grep -q "^..$TMP_BRANCH$"; then
git branch -D "$TMP_BRANCH"
fi &&
git checkout -b $TMP_BRANCH $REMOTE_NAME/$BRANCH_NAME &&
echo "${LOGPREFIX} Checkout branch $TMP_BRANCH from $REMOTE_NAME/$BRANCH_NAME"
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to checkout branch $TMP_BRANCH from $REMOTE_NAME/$BRANCH_NAME."
exit 1
fi

FIRST_AUTHOR_NAME=$(git log workflows..HEAD --reverse --format='%an' | head -n1)
FIRST_AUTHOR_EMAIL=$(git log workflows..HEAD --reverse --format='%ae' | head -n1)
echo "${LOGPREFIX} Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>"
if [[ -z "$FIRST_AUTHOR_NAME" || -z "$FIRST_AUTHOR_EMAIL" ]]; then
echo "${LOGPREFIX} Error: Unable to determine the first author of the PR."
exit 1
fi

COAUTHORS=$(git log workflows..HEAD --format='Co-authored-by: %an <%ae>' |grep -v "$FIRST_AUTHOR_NAME" | sort -u)
COAUTHOR_COUNT=$(echo "$COAUTHORS" | wc -l)
if [[ "$COAUTHOR_COUNT" -gt 0 ]]; then
echo "${LOGPREFIX} $COAUTHORS"
fi

COMMIT_MSG="$PR_TITLE"
if [[ -n "$PR_DESCRIPTION" ]]; then
COMMIT_MSG="$COMMIT_MSG\n\n$PR_DESCRIPTION"
fi

if [[ "$COAUTHOR_COUNT" -gt 0 ]]; then
COMMIT_MSG="$COMMIT_MSG\n"
COMMIT_MSG="$COMMIT_MSG\n$COAUTHORS"
fi

echo "${LOGPREFIX} Commit information:"
echo "${LOGPREFIX} Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>"
echo "${LOGPREFIX} ==================================================================="
echo -e "$COMMIT_MSG"
echo "${LOGPREFIX} ==================================================================="
echo "${LOGPREFIX} "

if [[ $(git config --list --local |grep 'user.name' >/dev/null 2>&1 && echo yes) != "yes" ]]; then
git config --local user.name "$FIRST_AUTHOR_NAME"
fi &&
if [[ $(git config --list --local |grep 'user.email' >/dev/null 2>&1 && echo yes) != "yes" ]]; then
git config --local user.email "$FIRST_AUTHOR_EMAIL"
fi &&
git config --list &&
echo "${LOGPREFIX} Set local git user configuration to: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>"
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to set local git user configuration."
exit 1
fi

git rebase workflows &&
git reset --soft workflows &&
echo "${LOGPREFIX} Rebased onto workflows branch and reset to soft."
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to rebase or reset changes."
exit 1
fi

git status &&
git restore --staged .github &&
git restore .github &&
git status &&
echo "${LOGPREFIX} Restored .github directory to the state of workflows branch."
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to restore .github directory."
exit 1
fi

if [[ $(git status | grep 'nothing to commit, working tree clean' >/dev/null 2>&1 && echo yes) == "yes" ]]; then
echo "${LOGPREFIX} No changes to commit. Exiting."
git checkout workflows
exit 0
fi

git commit --author "$FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -m "$(echo -e "$COMMIT_MSG")" &&
echo "${LOGPREFIX} Squashed commits into a single commit."
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to rebase or commit changes."
exit 1
fi

git branch -vv &&
git log -1 --pretty=format:"%an <%ae> %h %s"
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to display branch information or last commit."
exit 1
fi

if [[ -z "$PATCH_FILE" ]]; then
PATCH_FILE="whip-patch-$PR_NUMBER-$(date +%s).patch"
fi &&
rm -f $PATCH_FILE &&
git format-patch --add-header "X-Unsent: 1" --to [email protected] -1 --stdout > $PATCH_FILE &&
echo "${LOGPREFIX} Created patch file: $PATCH_FILE"
if [[ $? -ne 0 ]]; then
echo "${LOGPREFIX} Failed to create patch file."
exit 1
fi

git checkout workflows
#git br -D $TMP_BRANCH
#echo "${LOGPREFIX} Removed temporary branch $TMP_BRANCH."

echo "${LOGPREFIX} "
echo "${LOGPREFIX} Patch file created: $PATCH_FILE"
echo "${LOGPREFIX} "
27 changes: 27 additions & 0 deletions .github/workflows/fate-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "FFmpeg FATE Cache"

on:
workflow_dispatch:

permissions: read-all

jobs:
build:
name: "Build FFmpeg Fate Cache"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to docker hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Build FFmpeg Fate Cache
run: |
set -euxo pipefail
docker build -t ossrs/srs:ffmpeg-fate -f .github/docker/Dockerfile .
- name: Push FFmpeg Fate Cache
run: |
set -euxo pipefail
docker push ossrs/srs:ffmpeg-fate
runs-on: ubuntu-22.04
Loading
Loading