Discover channel streams when opening the Streams stage
This commit is contained in:
1 parent
59a2878447
commit
b685597092
11 files changed
+469
-45
No files matched your search
@@ -900,9 +900,9 @@ impl StreamMetadata<'_> {
|
||||
}
|
||||
|
||||
fn verify_list(&self, observer: &mut Peer, tones: &[Tone; HZ.len()], publisher: u64,
|
||||
stream_id: &str, phase: &str) -> Result<()> {
|
||||
stream_id: &str, phase: &str, args: Value) -> Result<()> {
|
||||
let audio = if self.audio { "1" } else { "0" };
|
||||
request_stream_event(observer, tones, "stream_list", json!({"client_id": publisher}),
|
||||
request_stream_event(observer, tones, "stream_list", args,
|
||||
Some(publisher), "notifystreaminfo", |row| {
|
||||
if row["id"].as_str() != Some(stream_id) || stream_owner(row) != Some(publisher) {
|
||||
return None;
|
||||
@@ -939,6 +939,13 @@ fn stream_lifecycle(qa: &mut Duplex, name: &str) -> Result<()> {
|
||||
}
|
||||
}
|
||||
let publisher = Duplex::connect(&mut qa.a, &qa.tones)?;
|
||||
qa.wait_until("publisher alone in beta14 lobby", CONTROL, |qa| {
|
||||
is_beta14_default(&qa.a.snapshot) && qa.a.snapshot["clients"].as_array().is_some_and(|rows|
|
||||
matches!(rows.as_slice(), [own] if own["is_self"] == true && own["id"] == publisher))
|
||||
})?;
|
||||
let alone = qa.a.request(&qa.tones, "stream_list", json!({}), CONTROL)?;
|
||||
if !alone["results"].as_array().is_some_and(Vec::is_empty) { return Err("untargeted discovery included the only client itself".into()); }
|
||||
println!("stream_list without target: no results for a solitary publisher");
|
||||
let observer = Duplex::connect(&mut qa.b, &qa.tones)?;
|
||||
if publisher == 0 || observer == 0 {
|
||||
return Err("connect returned a zero client ID".into());
|
||||
@@ -967,7 +974,7 @@ fn stream_lifecycle(qa: &mut Duplex, name: &str) -> Result<()> {
|
||||
println!("publisher: fresh own notifystreamstarted supplied the registered stream ID");
|
||||
|
||||
let checked = (|| {
|
||||
initial.verify_list(&mut qa.b, &qa.tones, publisher, &stream_id, "initial")?;
|
||||
initial.verify_list(&mut qa.b, &qa.tones, publisher, &stream_id, "channel-wide", json!({}))?;
|
||||
|
||||
let since = Instant::now();
|
||||
let reply = qa.b.request_reply(&qa.tones, "stream_join", json!({
|
||||
@@ -988,7 +995,7 @@ fn stream_lifecycle(qa: &mut Duplex, name: &str) -> Result<()> {
|
||||
&& row["msg"] == "QA declined" && row["offer"].as_str().unwrap_or("").is_empty()).then_some(())
|
||||
})?;
|
||||
println!("observer: received the publisher's denial for its join request; no offer");
|
||||
initial.verify_list(&mut qa.b, &qa.tones, publisher, &stream_id, "after refusal")?;
|
||||
initial.verify_list(&mut qa.b, &qa.tones, publisher, &stream_id, "after refusal", json!({"client_id":publisher}))?;
|
||||
|
||||
let updated_name = format!("{name} updated");
|
||||
let updated = StreamMetadata { name: &updated_name, bitrate: 2500, viewer_limit: 3, audio: true };
|
||||
@@ -998,7 +1005,7 @@ fn stream_lifecycle(qa: &mut Duplex, name: &str) -> Result<()> {
|
||||
require_stream_ack(&qa.a, "stream_update", &reply, None)?;
|
||||
|
||||
// Query only after the update ACK; an unsolicited update notification is not discovery.
|
||||
updated.verify_list(&mut qa.b, &qa.tones, publisher, &stream_id, "updated")
|
||||
updated.verify_list(&mut qa.b, &qa.tones, publisher, &stream_id, "updated", json!({"client_id":publisher}))
|
||||
})();
|
||||
|
||||
// If discovery or update failed, still unregister the exact ID before disconnecting.
|
||||
|
||||
Reference in new issue
Block a user