Skip to content

Commit

Permalink
Bring back RTP and RTCP notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Sep 28, 2024
1 parent 4e161f6 commit b247930
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

21 changes: 14 additions & 7 deletions rust/src/router/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,7 @@ enum Notification {
ProducerClose,
ProducerPause,
ProducerResume,
// TODO.
// Rtp,
Rtp(Vec<u8>),
Score(ConsumerScore),
LayersChange(Option<ConsumerLayers>),
Trace(ConsumerTraceEventData),
Expand All @@ -608,6 +607,17 @@ impl Notification {
notification::Event::ConsumerProducerClose => Ok(Notification::ProducerClose),
notification::Event::ConsumerProducerPause => Ok(Notification::ProducerPause),
notification::Event::ConsumerProducerResume => Ok(Notification::ProducerResume),
notification::Event::ConsumerRtp => {
let Ok(Some(notification::BodyRef::ConsumerRtpNotification(body))) =
notification.body()
else {
panic!("Wrong message from worker: {notification:?}");
};

let rtp_notification_fbs = consumer::RtpNotification::try_from(body).unwrap();

Ok(Notification::Rtp(rtp_notification_fbs.data))
}
notification::Event::ConsumerScore => {
let Ok(Some(notification::BodyRef::ConsumerScoreNotification(body))) =
notification.body()
Expand Down Expand Up @@ -841,14 +851,11 @@ impl Consumer {
handlers.resume.call_simple();
}
}
/*
* TODO.
Notification::Rtp => {
Notification::Rtp(data) => {
handlers.rtp.call(|callback| {
callback(notification);
callback(&data);
});
}
*/
Notification::Score(consumer_score) => {
*score.lock() = consumer_score.clone();
handlers.score.call_simple(&consumer_score);
Expand Down
28 changes: 13 additions & 15 deletions rust/src/router/direct_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ struct Handlers {
#[serde(tag = "event", rename_all = "lowercase", content = "data")]
enum Notification {
Trace(TransportTraceEventData),
// TODO.
// Rtcp,
Rtcp(Vec<u8>),
}

impl Notification {
Expand All @@ -252,17 +251,18 @@ impl Notification {

Ok(Notification::Trace(trace_notification))
}
/*
* TODO.
notification::Event::DirecttransportRtcp => {
let Ok(Some(notification::BodyRef::RtcpNotification(_body))) = notification.body()
let Ok(Some(notification::BodyRef::DirectTransportRtcpNotification(body))) =
notification.body()
else {
panic!("Wrong message from worker: {notification:?}");
};

Ok(Notification::Rtcp)
let rtcp_notification_fbs =
direct_transport::RtcpNotification::try_from(body).unwrap();

Ok(Notification::Rtcp(rtcp_notification_fbs.data))
}
*/
_ => Err(NotificationParseError::InvalidEvent),
}
}
Expand Down Expand Up @@ -574,14 +574,12 @@ impl DirectTransport {
Ok(notification) => match notification {
Notification::Trace(trace_event_data) => {
handlers.trace.call_simple(&trace_event_data);
} /*
* TODO.
Notification::Rtcp => {
handlers.rtcp.call(|callback| {
callback(notification);
});
}
*/
}
Notification::Rtcp(data) => {
handlers.rtcp.call(|callback| {
callback(&data);
});
}
},
Err(error) => {
error!("Failed to parse notification: {}", error);
Expand Down

0 comments on commit b247930

Please sign in to comment.