Skip to content
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

feat: Add C API header #19

Merged
merged 30 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
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
150 changes: 150 additions & 0 deletions .github/workflows/build-attach-artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Copyright 2023 Pluto TV

name: Build and attach release artifacts

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag of the release'
required: true
type: string

# By default, run all commands in a bash shell. On Windows, the default would
# otherwise be powershell.
defaults:
run:
shell: bash

jobs:
build_matrix_config:
name: Matrix configuration
runs-on: ubuntu-latest
outputs:
INCLUDE: ${{ steps.configure.outputs.INCLUDE }}
OS: ${{ steps.configure.outputs.OS }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}

- name: Configure Build Matrix
id: configure
shell: node {0}
run: |
const enableSelfHosted = false;

// Use enableSelfHosted to decide what the build matrix below should
// include.
const {hosted, selfHosted} = require("${{ github.workspace }}/.github/workflows/build-matrix.json");
const include = enableSelfHosted ? hosted.concat(selfHosted) : hosted;
const os = include.map((config) => config.os);

// Output JSON objects consumed by the build matrix below.
const fs = require('fs');
fs.writeFileSync(process.env.GITHUB_OUTPUT,
[
`INCLUDE=${ JSON.stringify(include) }`,
`OS=${ JSON.stringify(os) }`,
].join('\n'),
{flag: 'a'});

// Log the outputs, for the sake of debugging this script.
console.log({enableSelfHosted, include, os});

build:
needs: build_matrix_config
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.build_matrix_config.outputs.INCLUDE) }}
os: ${{ fromJSON(needs.build_matrix_config.outputs.OS) }}
build_type: ["Release"]
lib_type: ["shared"]

name: ${{ matrix.os_name }} ${{ matrix.target_arch }} ${{ matrix.build_type }} ${{ matrix.lib_type }}
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
submodules: recursive

- name: Generate build files
run: |
mkdir -p build/

cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DBUILD_SHARED_LIBS=1 \
-DUSE_WORKAROUND_FOR_TRUN_VERSION_0=1 \
-S . \
-B build/

- name: Build
run: cmake --build build/ --parallel $(getconf _NPROCESSORS_ONLN)

- name: Prepare artifacts
run: |
echo "::group::Prepare artifacts folder"
mkdir artifacts
ARTIFACTS="$GITHUB_WORKSPACE/artifacts"
if [[ "${{ runner.os }}" == "Windows" ]]; then
cd build/packager/Release
else
cd build/packager
fi
echo "::endgroup::"

SUFFIX="-${{ matrix.os_name }}-${{ matrix.target_arch }}"
EXE_SUFFIX="$SUFFIX${{ matrix.exe_ext}}"

echo "::group::Copy libpackager"
cp libpackager${{ matrix.exe_ext }} $ARTIFACTS/libpackager$EXE_SUFFIX
echo "::endgroup::"

- name: Upload release build artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.os_name }}-${{ matrix.target_arch }}
path: artifacts/*
if-no-files-found: error
retention-days: 5

update_release:
needs: [build]
name: Update release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
submodules: recursive

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true

# Debug
- name: Display structure of downloaded files
run: ls -la

- name: Attach artifact
id: attach_artifact
uses: ncipollo/[email protected]
with:
allowUpdates: true
replacesArtifacts: true
artifacts: |
artifacts/*
include/packager/live_packager_export.h
token: ${{ secrets.GITHUB_TOKEN }}
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
tag: ${{ inputs.tag }}
draft: false
32 changes: 11 additions & 21 deletions .github/workflows/build-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,27 @@
"comment1": "runners hosted by GitHub, always enabled",
"hosted": [
{
"os": "ubuntu-latest",
"os": "ubuntu-20.04",
"os_name": "linux",
"target_arch": "x64",
"exe_ext": "",
"exe_ext": ".so",
"generator": "Ninja"
},
{
"os": "macos-latest",
"comment": "Explicit macOS version 13 is required for explicit x64 CPU.",
"os": "macos-13",
"os_name": "osx",
"target_arch": "x64",
"exe_ext": "",
"exe_ext": ".dylib",
"generator": "Ninja"
},
{
"os": "windows-latest",
"os_name": "win",
"target_arch": "x64",
"exe_ext": ".exe",
"generator": ""
}
],

"comment2": "runners hosted by the owner, enabled by the 'self_hosted' environment being created on the repo",
"selfHosted": [
{
"os": "self-hosted-linux-arm64",
"os_name": "linux",
"comment": "Explicit macOS version 14 is required for explicit arm64 CPU.",
"os": "macos-14",
"os_name": "osx",
"target_arch": "arm64",
"exe_ext": "",
"generator": "Ninja",
"low_mem": "yes"
"exe_ext": ".dylib",
"generator": "Ninja"
}
]
}
}
85 changes: 0 additions & 85 deletions .github/workflows/github-dev-snap.yaml

This file was deleted.

18 changes: 16 additions & 2 deletions include/packager/live_packager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ class SegmentData final : public Segment {
const size_t size_ = 0;
};

class SegmentBuffer final : public Segment {
public:
SegmentBuffer() = default;
~SegmentBuffer() = default;

void AppendData(const uint8_t* data, size_t size);

virtual const uint8_t* Data() const override;
virtual size_t Size() const override;

private:
std::vector<uint8_t> buffer_;
};

class FullSegmentBuffer final : public Segment {
public:
FullSegmentBuffer() = default;
Expand Down Expand Up @@ -115,7 +129,7 @@ class LivePackager {
/// @param init_segment contains the init segment data.
/// @param output contains the packaged init segment data.
/// @return OK on success, an appropriate error code on failure.
Status PackageInit(const Segment& init_segment, FullSegmentBuffer& output);
Status PackageInit(const Segment& init_segment, SegmentBuffer& output);

/// Performs packaging of segment data.
/// @param init_segment contains the init segment data.
Expand All @@ -124,7 +138,7 @@ class LivePackager {
/// @return OK on success, an appropriate error code on failure.
Status Package(const Segment& init_segment,
const Segment& media_segment,
FullSegmentBuffer& output);
SegmentBuffer& output);

Status PackageTimedText(const Segment& media_segment,
FullSegmentBuffer& output);
Expand Down
Loading
Loading