Skip to content

Commit e652bdf

Browse files
committed
refactor
1 parent 6bd86a0 commit e652bdf

File tree

5 files changed

+186
-201
lines changed

5 files changed

+186
-201
lines changed

compositor_api/src/types/from_register_output.rs

+27-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ use compositor_pipeline::{
99
ffmpeg_h264::{self},
1010
ffmpeg_vp8, AudioEncoderOptions,
1111
},
12-
output::{self, mp4::Mp4OutputOptions, rtmp::RtmpSenderOptions},
12+
output::{
13+
self,
14+
mp4::Mp4OutputOptions,
15+
rtmp::RtmpSenderOptions,
16+
whip::{AudioWhipOptions, VideoWhipOptions},
17+
},
1318
},
1419
};
1520
use tracing::warn;
@@ -166,11 +171,11 @@ impl TryFrom<WhipOutput> for pipeline::RegisterOutputOptions<output::OutputOptio
166171
}
167172

168173
if video.as_ref().filter(|v| v.encoder.is_some()).is_some() {
169-
warn!("Field 'video' is deprecated. The codec will now be set automatically based on WHIP negotiation; manual specification is no longer needed.")
174+
warn!("Field 'encoder' is deprecated. The codec will now be set automatically based on WHIP negotiation; manual specification is no longer needed.")
170175
}
171176

172177
if audio.as_ref().filter(|a| a.encoder.is_some()).is_some() {
173-
warn!("Field 'audio' is deprecated. The codec will now be set automatically based on WHIP negotiation; manual specification is no longer needed.")
178+
warn!("Field 'encoder' is deprecated. The codec will now be set automatically based on WHIP negotiation; manual specification is no longer needed.")
174179
}
175180

176181
if let Some(token) = &bearer_token {
@@ -179,8 +184,8 @@ impl TryFrom<WhipOutput> for pipeline::RegisterOutputOptions<output::OutputOptio
179184
};
180185
}
181186

182-
let output_video_options = maybe_whip_video_options(video)?;
183-
let output_audio_options = match audio {
187+
let (output_video_options, video_whip_options) = maybe_whip_video_options(video)?;
188+
let (output_audio_options, audio_whip_options) = match audio {
184189
Some(OutputWhipAudioOptions {
185190
mixing_strategy,
186191
send_eos_when,
@@ -193,17 +198,17 @@ impl TryFrom<WhipOutput> for pipeline::RegisterOutputOptions<output::OutputOptio
193198
mixing_strategy: mixing_strategy.unwrap_or(MixingStrategy::SumClip).into(),
194199
channels: AudioChannels::Stereo, // hardcoded just temporarly, TODO when adding preferences
195200
};
196-
197-
Some(output_audio_options)
201+
let audio_whip_options = AudioWhipOptions; //TODO when adding preferences
202+
(Some(output_audio_options), Some(audio_whip_options))
198203
}
199-
None => None,
204+
None => (None, None),
200205
};
201206

202207
let output_options = output::OutputOptions::Whip(output::whip::WhipSenderOptions {
203208
endpoint_url,
204209
bearer_token,
205-
video: None,
206-
audio: None,
210+
video: video_whip_options,
211+
audio: audio_whip_options,
207212
});
208213

209214
Ok(Self {
@@ -301,17 +306,25 @@ fn maybe_video_options(
301306

302307
fn maybe_whip_video_options(
303308
options: Option<OutputWhipVideoOptions>,
304-
) -> Result<Option<pipeline::OutputVideoOptions>, TypeError> {
309+
) -> Result<
310+
(
311+
Option<pipeline::OutputVideoOptions>,
312+
Option<VideoWhipOptions>,
313+
),
314+
TypeError,
315+
> {
305316
let Some(options) = options else {
306-
return Ok(None);
317+
return Ok((None, None));
307318
};
308-
309319
let output_options = pipeline::OutputVideoOptions {
310320
initial: options.initial.try_into()?,
311321
end_condition: options.send_eos_when.unwrap_or_default().try_into()?,
312322
};
323+
let video_whip_options = VideoWhipOptions {
324+
resolution: options.resolution.into(),
325+
};
313326

314-
Ok(Some(output_options))
327+
Ok((Some(output_options), Some(video_whip_options)))
315328
}
316329

317330
impl From<Mp4AudioEncoderOptions> for pipeline::encoder::AudioEncoderOptions {

0 commit comments

Comments
 (0)