Skip to content

Commit

Permalink
extract stream definition
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Jul 14, 2024
1 parent fc7843c commit eb31fe8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/streamdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use tokio::sync::broadcast;
use std::sync::Arc;
use log::debug;
use webrtc::track::track_local::track_local_static_sample::TrackLocalStaticSample;
use webrtc::api::media_engine::MIME_TYPE_H264;
use webrtc::rtp_transceiver::rtp_codec::RTCRtpCodecCapability;
Expand All @@ -34,7 +35,7 @@ impl Clone for StreamsDef {

impl StreamsDef {
pub fn new(name: String) -> Self {
let (tx, rx) = broadcast::channel::<Vec<u8>>(100);
let (tx, rx) = broadcast::channel::<Vec<u8>>(1024*1024);

let track = Arc::new(TrackLocalStaticSample::new(
RTCRtpCodecCapability {
Expand All @@ -51,7 +52,9 @@ impl StreamsDef {
pub fn start(&self) {
let self_clone = self.clone();
tokio::spawn(async move {
while let Ok(data) = self_clone.rx.resubscribe().recv().await {
let mut rx = self_clone.rx.resubscribe();
while let Ok(data) = rx.recv().await {
debug!("Received data:{}\n", data.len());
let sample = Sample {
data: data.into(),
..Default::default()};
Expand Down

0 comments on commit eb31fe8

Please sign in to comment.