Skip to content

Commit 8b21754

Browse files
Auto merge of #241 - troy/remove-bytesio, r=lennartkloock
create scuffle-bytes-util Rename `bytesio` to `scuffle-bytes-util`. We also remove the wrapper types we had and optimize the `Cursor<Bytes>` usage. A lot of what we did with the wrapper types was essentially what `BytesMut` does and what `Vec<u8>` does, which is why most of the usage has been replaced with that. These changes allow for the code to have fewer copies in the rtmp implementation (I will look to further clean up the tests and code there in a future PR). The old rtmp flow was such: - copy bytes from wire into a temporary buffer - copy that buffer into the chunk decoder (or handshake buffer) buffer - parse chunks/handshake - create a temporary buffer to write back result - copy result from tmp buffer onto wire. The new flow looks like: - copy bytes from wire into a buffer - parse chunks/handshake - write result into a buffer - copy result onto the wire The newer example reuses existing buffers; so each connection will store additional memory (roughly 10kb/connection). As apposed to creating a buffer each time we want to read or write we just reuse an existing one. We also remove the additional copy to the handshake or chunk decode buffers by having them all share the same buffer (the read buffer). CLOUD-23 Requested-by: lennartkloock <[email protected]> Reviewed-by: lennartkloock <[email protected]>
2 parents 7726105 + b1a9a32 commit 8b21754

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+748
-1007
lines changed

Cargo.lock

Lines changed: 22 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ members = [
2525
"crates/aac",
2626
"crates/amf0",
2727
"crates/av1",
28-
"crates/bytesio",
2928
"crates/exp_golomb",
3029
"crates/flv",
3130
"crates/h264",
@@ -35,7 +34,7 @@ members = [
3534
"crates/transmuxer",
3635
"dev-tools/xtask",
3736
"crates/future-ext",
38-
"crates/bitio",
37+
"crates/bytes-util",
3938
]
4039

4140
resolver = "2"
@@ -60,7 +59,7 @@ scuffle-h3-webtransport = { path = "crates/h3-webtransport", version = "0.0.2" }
6059
scuffle-metrics-derive = { path = "crates/metrics/derive", version = "0.0.2" }
6160
scuffle-ffmpeg-sys = { path = "crates/ffmpeg-sys", version = "7.1.0" }
6261
scuffle-future-ext = { path = "crates/future-ext", version = "0.0.1" }
63-
scuffle-bitio = { path = "crates/bitio", version = "0.0.1" }
62+
scuffle-bytes-util = { path = "crates/bytes-util", version = "0.0.1" }
6463

6564
[profile.release-debug]
6665
inherits = "release"

crates/aac/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ byteorder = "1.5"
1313
num-traits = "0.2"
1414
num-derive = "0.4"
1515
scuffle-workspace-hack.workspace = true
16-
scuffle-bitio = { workspace = true }
16+
scuffle-bytes-util.workspace = true

crates/aac/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io;
44

55
use num_derive::FromPrimitive;
66
use num_traits::FromPrimitive;
7-
use scuffle_bitio::BitReader;
7+
use scuffle_bytes_util::BitReader;
88

99
/// A Partial Audio Specific Config
1010
/// ISO/IEC 14496-3:2019(E) - 1.6

crates/amf0/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ bytes = "1.5"
99
byteorder = "1.5"
1010
num-traits = "0.2"
1111
num-derive = "0.4"
12-
bytesio = { path = "../bytesio" }
12+
scuffle-bytes-util.workspace = true
1313
scuffle-workspace-hack.workspace = true
14-
scuffle-bitio = { workspace = true }

crates/av1/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ license = "MIT OR Apache-2.0"
77
[dependencies]
88
bytes = "1.5"
99
byteorder = "1.5"
10-
bytesio = { path = "../bytesio" }
11-
scuffle-bitio = { workspace = true }
10+
scuffle-bytes-util.workspace = true
1211
scuffle-workspace-hack.workspace = true

crates/av1/src/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::io;
22

33
use bytes::Bytes;
4-
use bytesio::bytes_reader::BytesCursor;
5-
use scuffle_bitio::{BitReader, BitWriter};
4+
use scuffle_bytes_util::{BitReader, BitWriter, BytesCursorExt};
65

76
#[derive(Debug, Clone, PartialEq)]
87
/// AV1 Codec Configuration Record

crates/av1/src/obu/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::io::{
33
};
44

55
use bytes::Bytes;
6-
use scuffle_bitio::BitReader;
6+
use scuffle_bytes_util::BitReader;
77

88
pub mod seq;
99

crates/av1/src/obu/seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io;
22

33
use byteorder::{BigEndian, ReadBytesExt};
44
use bytes::Bytes;
5-
use scuffle_bitio::BitReader;
5+
use scuffle_bytes_util::BitReader;
66

77
use super::ObuHeader;
88
use crate::obu::read_uvlc;

crates/av1/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::io;
22

3-
use scuffle_bitio::BitReader;
3+
use scuffle_bytes_util::BitReader;
44

55
use crate::config::AV1CodecConfigurationRecord;
66
use crate::seq::{ColorConfig, OperatingPoint, SequenceHeaderObu};

crates/bitio/src/lib.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "scuffle-bitio"
2+
name = "scuffle-bytes-util"
33
version = "0.0.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
@@ -8,4 +8,5 @@ license = "MIT OR Apache-2.0"
88
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }
99

1010
[dependencies]
11+
bytes = "1.5"
1112
scuffle-workspace-hack.workspace = true
File renamed without changes.

crates/bitio/README.md renamed to crates/bytes-util/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# scuffle-bitio
1+
# scuffle-bytes-util
22

33
> [!WARNING]
44
> This crate is under active development and may not be stable.
55
6-
[![crates.io](https://img.shields.io/crates/v/scuffle-bitio.svg)](https://crates.io/crates/scuffle-bitio) [![docs.rs](https://img.shields.io/docsrs/scuffle-bitio)](https://docs.rs/scuffle-bitio)
6+
[![crates.io](https://img.shields.io/crates/v/scuffle-bytes-util.svg)](https://crates.io/crates/scuffle-bytes-util) [![docs.rs](https://img.shields.io/docsrs/scuffle-bytes-util)](https://docs.rs/scuffle-bytes-util)
77

88
---
99

10-
Adds a simple interface for writing and reading bits to and from a stream.
10+
Adds some helpful utilities for working with bits and bytes.
1111

1212
## License
1313

0 commit comments

Comments
 (0)