Skip to content

Commit

Permalink
moq-clock-ietf: s/group/subgroup/g
Browse files Browse the repository at this point in the history
This may not be what we really want yet, but it seems to match what was
done on the moq-pub side and it builds, so that's a start...
  • Loading branch information
englishm committed Oct 29, 2024
1 parent 8cba2a6 commit c004f0c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions moq-clock-ietf/src/clock.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use anyhow::Context;

Check warning on line 1 in moq-clock-ietf/src/clock.rs

View workflow job for this annotation

GitHub Actions / build

Diff in /home/runner/work/moq-rs/moq-rs/moq-clock-ietf/src/clock.rs
use moq_transport::serve::{
DatagramsReader, Group, GroupWriter, GroupsReader, GroupsWriter, ObjectsReader, StreamReader, TrackReader,
DatagramsReader, Subgroup, SubgroupWriter, SubgroupsReader, SubgroupsWriter, ObjectsReader, StreamReader, TrackReader,
TrackReaderMode,
};

use chrono::prelude::*;

pub struct Publisher {
track: GroupsWriter,
track: SubgroupsWriter,
}

impl Publisher {
pub fn new(track: GroupsWriter) -> Self {
pub fn new(track: SubgroupsWriter) -> Self {
Self { track }
}

Expand All @@ -25,8 +25,9 @@ impl Publisher {
loop {
let segment = self
.track
.create(Group {
.create(Subgroup {
group_id: sequence as u64,
subgroup_id: 0,
priority: 0,
})
.context("failed to create minute segment")?;
Expand All @@ -49,7 +50,7 @@ impl Publisher {
}
}

async fn send_segment(mut segment: GroupWriter, mut now: DateTime<Utc>) -> anyhow::Result<()> {
async fn send_segment(mut segment: SubgroupWriter, mut now: DateTime<Utc>) -> anyhow::Result<()> {
// Everything but the second.
let base = now.format("%Y-%m-%d %H:%M:").to_string();

Expand Down Expand Up @@ -89,15 +90,15 @@ impl Subscriber {
pub async fn run(self) -> anyhow::Result<()> {
match self.track.mode().await.context("failed to get mode")? {
TrackReaderMode::Stream(stream) => Self::recv_stream(stream).await,
TrackReaderMode::Groups(groups) => Self::recv_groups(groups).await,
TrackReaderMode::Subgroups(subgroups) => Self::recv_subgroups(subgroups).await,
TrackReaderMode::Objects(objects) => Self::recv_objects(objects).await,
TrackReaderMode::Datagrams(datagrams) => Self::recv_datagrams(datagrams).await,
}
}

async fn recv_stream(mut track: StreamReader) -> anyhow::Result<()> {
while let Some(mut group) = track.next().await? {
while let Some(object) = group.read_next().await? {
while let Some(mut subgroup) = track.next().await? {
while let Some(object) = subgroup.read_next().await? {
let str = String::from_utf8_lossy(&object);
println!("{}", str);
}
Expand All @@ -106,17 +107,17 @@ impl Subscriber {
Ok(())
}

async fn recv_groups(mut groups: GroupsReader) -> anyhow::Result<()> {
while let Some(mut group) = groups.next().await? {
let base = group
async fn recv_subgroups(mut subgroups: SubgroupsReader) -> anyhow::Result<()> {
while let Some(mut subgroup) = subgroups.next().await? {
let base = subgroup
.read_next()
.await
.context("failed to get first object")?
.context("empty group")?;
.context("empty subgroup")?;

let base = String::from_utf8_lossy(&base);

while let Some(object) = group.read_next().await? {
while let Some(object) = subgroup.read_next().await? {
let str = String::from_utf8_lossy(&object);
println!("{}{}", base, str);
}
Expand Down

0 comments on commit c004f0c

Please sign in to comment.