X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/488cd0f950a1754f8c5a34dc2617c927e466cc3b..18349069c27a0b4fb2e39669fb535600805ad160:/m17codec2/src/lib.rs diff --git a/m17codec2/src/lib.rs b/m17codec2/src/lib.rs index 5146bca..5eb54a4 100755 --- a/m17codec2/src/lib.rs +++ b/m17codec2/src/lib.rs @@ -6,6 +6,8 @@ use cpal::{Sample, SampleFormat, SampleRate}; use log::debug; use m17app::adapter::StreamAdapter; use m17app::app::TxHandle; +use m17app::link_setup::LinkSetup; +use m17app::link_setup::M17Address; use m17core::address::Address; use m17core::address::Callsign; use m17core::protocol::LsfFrame; @@ -160,7 +162,13 @@ fn stream_thread(end: Receiver<()>, state: Arc>, output_card pub struct WavePlayer; impl WavePlayer { - pub fn play(path: PathBuf, tx: TxHandle) { + pub fn play( + path: PathBuf, + tx: TxHandle, + source: &M17Address, + destination: &M17Address, + channel_access_number: u8, + ) { let mut reader = hound::WavReader::open(path).unwrap(); let mut samples = reader.samples::(); @@ -172,14 +180,9 @@ impl WavePlayer { let mut next_tick = Instant::now() + TICK; let mut frame_number = 0; - // TODO: need a better way to create addresses from std strings - - let lsf = LsfFrame::new_voice( - &Address::Callsign(Callsign(b"VK7XT ".clone())), - &Address::Broadcast, - ); - - tx.transmit_stream_start(lsf.clone()); + let mut setup = LinkSetup::new_voice(source, destination); + setup.set_channel_access_number(channel_access_number); + tx.transmit_stream_start(&setup); loop { let mut last_one = false; @@ -196,11 +199,9 @@ impl WavePlayer { } codec.encode(&mut out, &in_buf); } - tx.transmit_stream_next(StreamFrame { + tx.transmit_stream_next(&StreamFrame { lich_idx: lsf_chunk as u8, - lich_part: lsf.0[lsf_chunk * 5..(lsf_chunk + 1) * 5] - .try_into() - .unwrap(), + lich_part: setup.lich_part(lsf_chunk as u8), frame_number, end_of_stream: last_one, stream_data: out_buf.clone(),