Skip to content
Draft
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
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ members = [
"crates/future-ext",
"crates/h264",
"crates/h265",
"crates/hls",
"crates/http",
"crates/metrics",
"crates/metrics/derive",
Expand Down
1 change: 1 addition & 0 deletions cargo_targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ _packages = [
"//crates/future-ext",
"//crates/h264",
"//crates/h265",
"//crates/hls",
"//crates/http",
"//crates/metrics",
"//crates/metrics/derive",
Expand Down
14 changes: 14 additions & 0 deletions crates/hls/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("//misc/utils/rust:manifest.bzl", "cargo_toml")
load("//misc/utils/rust:package.bzl", "scuffle_package")

cargo_toml()

scuffle_package(
compile_data = [
":CHANGELOG.md",
":Cargo.toml",
],
crate_name = "scuffle-hls",
proc_macro_deps = ["//crates/changelog"],
deps = [],
)
44 changes: 44 additions & 0 deletions crates/hls/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Changelog

<!--
This file is automatically generated by our release process.
DO NOT edit it directly.
If you want to add a change log entry for this package,
please create a new file in /changes.d/<pr-number>.toml
Refer to the [README.md](/changes.d/README.md) for more information.
-->

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.4](https://github.com/ScuffleCloud/scuffle/releases/tag/scuffle-aac-v0.1.4) - 2025-05-17

[View diff on diff.rs](https://diff.rs/scuffle-aac/0.1.3/scuffle-aac/0.1.4/Cargo.toml)

### 🛠️ Non-breaking changes

- chore: fix changelog entry & release process ([#465](https://github.com/scufflecloud/scuffle/pull/465)) (@troykomodo, @SimaoMoreira5228, @philipch07)

## [0.1.3](https://github.com/ScuffleCloud/scuffle/releases/tag/scuffle-aac-v0.1.3) - 2025-05-14

[View diff on diff.rs](https://diff.rs/scuffle-aac/0.1.2/scuffle-aac/0.1.3/Cargo.toml)

### 🛠️ Non-breaking changes

- chore: cleanup readme and crate docs ([#458](https://github.com/scufflecloud/scuffle/pull/458)) (@troykomodo)

## [0.1.2](https://github.com/ScuffleCloud/scuffle/releases/tag/scuffle-aac-v0.1.2) - 2025-04-27

### 🛠️ Non-breaking changes

- docs: improved documentation ([#372](https://github.com/scufflecloud/scuffle/pull/372)) (@lennartkloock)

## [0.1.1](https://github.com/ScuffleCloud/scuffle/releases/tag/scuffle-aac-v0.1.1) - 2025-02-21

### 🛠️ Non-breaking changes

- chore: update to rust edition 2024 ([#373](https://github.com/scufflecloud/scuffle/pull/373)) (@TroyKomodo)
43 changes: 43 additions & 0 deletions crates/hls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "scuffle-hls"
version = "0.1.0"
authors = ["Scuffle <opensource@scuffle.cloud>"]
documentation = "https://docs.rs/scuffle-hls"
edition = "2024"
keywords = ["hls"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/scufflecloud/scuffle"
description = "Generating HLS playlists"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }

[features]
## Enables changelog and documentation of feature flags
docs = ["dep:scuffle-changelog", "dep:document-features"]

[dependencies]
chrono = "0.4"
document-features = { optional = true, version = "0.2" }
scuffle-changelog = { optional = true, path = "../changelog", version = "0.1" }
thiserror = "2"
url = "2"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs",
"--sort-modules-by-appearance",
"--generate-link-to-definition",
]

[package.metadata.sync-readme.rustdoc-mappings]
changelog = "./CHANGELOG.md"

[package.metadata.sync-readme.badges]
docs-rs = true
crates-io = true
license = true
codecov = true
13 changes: 13 additions & 0 deletions crates/hls/LICENSE.Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2025 Scuffle LLC.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
7 changes: 7 additions & 0 deletions crates/hls/LICENSE.MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2025 Scuffle LLC.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 changes: 35 additions & 0 deletions crates/hls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- dprint-ignore-file -->
<!-- sync-readme title [[ -->
# scuffle-aac
<!-- sync-readme ]] -->

> [!WARNING]
> This crate is under active development and may not be stable.

<!-- sync-readme badge [[ -->
[![docs.rs](https://img.shields.io/docsrs/scuffle-aac/0.1.4.svg?logo=docs.rs&label=docs.rs&style=flat-square)](https://docs.rs/scuffle-aac/0.1.4)
[![crates.io](https://img.shields.io/badge/crates.io-v0.1.4-orange?style=flat-square&logo=rust&logoColor=white)](https://crates.io/crates/scuffle-aac/0.1.4)
![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-purple.svg?style=flat-square)
![Crates.io Size](https://img.shields.io/crates/size/scuffle-aac/0.1.4.svg?style=flat-square)
![Crates.io Downloads](https://img.shields.io/crates/dv/scuffle-aac/0.1.4.svg?&label=downloads&style=flat-square)
[![Codecov](https://img.shields.io/codecov/c/github/scufflecloud/scuffle.svg?label=codecov&logo=codecov&style=flat-square)](https://app.codecov.io/gh/scufflecloud/scuffle)
<!-- sync-readme ]] -->

---

<!-- sync-readme rustdoc [[ -->
A crate for decoding AAC audio headers.

See the [changelog](./CHANGELOG.md) for a full release history.

### Feature flags

* **`docs`** — Enables changelog and documentation of feature flags

### License

This project is licensed under the MIT or Apache-2.0 license.
You can choose between one of them if you use this work.

`SPDX-License-Identifier: MIT OR Apache-2.0`
<!-- sync-readme ]] -->
5 changes: 5 additions & 0 deletions crates/hls/src/any_playlist.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod independent_segments;
mod start;

pub use independent_segments::*;
pub use start::*;
7 changes: 7 additions & 0 deletions crates/hls/src/any_playlist/independent_segments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::Tag;

pub struct IndependentSegments;

impl Tag for IndependentSegments {
const NAME: &'static str = "EXT-X-INDEPENDENT-SEGMENTS";
}
37 changes: 37 additions & 0 deletions crates/hls/src/any_playlist/start.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::fmt::Display;
use std::io;

use crate::Tag;

pub enum StartPrecise {
Yes,
No,
}

impl Display for StartPrecise {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StartPrecise::Yes => write!(f, "YES"),
StartPrecise::No => write!(f, "NO"),
}
}
}

pub struct Start {
pub time_offset: f64,
pub precise: Option<StartPrecise>,
}

impl Tag for Start {
const NAME: &'static str = "EXT-X-START";

fn write_value(&self, mut writer: impl io::Write) -> Result<(), io::Error> {
write!(writer, ":TIME-OFFSET={}", self.time_offset)?;

if let Some(precise) = self.precise.as_ref() {
write!(writer, ",PRECISE={}", precise)?;
}

Ok(())
}
}
38 changes: 38 additions & 0 deletions crates/hls/src/attribute_name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use std::fmt::Display;
use std::str::FromStr;

#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AttributeName(String);

#[derive(thiserror::Error, Debug)]
#[error("invalid attribute name")]
pub struct InvalidAttributeNameError;

impl TryFrom<String> for AttributeName {
type Error = InvalidAttributeNameError;

fn try_from(value: String) -> Result<Self, Self::Error> {
if !value
.chars()
.all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == '-')
{
return Err(InvalidAttributeNameError);
}

Ok(Self(value))
}
}

impl FromStr for AttributeName {
type Err = InvalidAttributeNameError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::try_from(s.to_string())
}
}

impl Display for AttributeName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
26 changes: 26 additions & 0 deletions crates/hls/src/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use std::io;

use crate::Tag;

pub struct ExtM3u;

impl Tag for ExtM3u {
const NAME: &'static str = "EXTM3U";
}

#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct Version(pub u64);

impl Default for Version {
fn default() -> Self {
Self(1)
}
}

impl Tag for Version {
const NAME: &'static str = "EXT-X-VERSION";

fn write_value(&self, mut writer: impl io::Write) -> Result<(), io::Error> {
write!(writer, ":{}", self.0)
}
}
50 changes: 50 additions & 0 deletions crates/hls/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//! Generating HLS playlists.
#![cfg_attr(feature = "docs", doc = "\n\nSee the [changelog][changelog] for a full release history.")]
#![cfg_attr(feature = "docs", doc = "## Feature flags")]
#![cfg_attr(feature = "docs", doc = document_features::document_features!())]
//! ## License
//!
//! This project is licensed under the MIT or Apache-2.0 license.
//! You can choose between one of them if you use this work.
//!
//! `SPDX-License-Identifier: MIT OR Apache-2.0`
#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// #![deny(missing_docs)]
#![deny(unsafe_code)]
#![deny(unreachable_pub)]
#![deny(clippy::mod_module_files)]

use std::io;

use crate::basic::Version;

pub mod any_playlist;
pub mod attribute_name;
pub mod basic;
pub mod master_playlist;
pub mod media_playlist;
pub mod media_segment;

pub use attribute_name::AttributeName;

pub trait Tag {
const NAME: &'static str;

fn min_version(&self) -> Version {
Version::default()
}

fn write_value(&self, writer: impl io::Write) -> Result<(), io::Error> {
let _ = writer;
Ok(())
}

fn write(&self, mut writer: impl io::Write) -> Result<(), io::Error> {
writer.write_all(b"#")?;
writer.write_all(Self::NAME.as_bytes())?;
self.write_value(&mut writer)?;
writer.write_all(b"\n")?;
Ok(())
}
}
11 changes: 11 additions & 0 deletions crates/hls/src/master_playlist.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mod i_frame_stream_inf;
mod media;
mod session_data;
mod session_key;
mod stream_inf;

pub use i_frame_stream_inf::*;
pub use media::*;
pub use session_data::*;
pub use session_key::*;
pub use stream_inf::*;
Loading
Loading