use ff_format::{AudioCodec, VideoCodec};
use ff_stream::{RtmpOutput, StreamError};
#[test]
fn rtmp_build_without_rtmp_scheme_should_return_invalid_config() {
let result = RtmpOutput::new("http://example.com/live")
.video(1280, 720, 30.0)
.build();
assert!(
matches!(result, Err(StreamError::InvalidConfig { .. })),
"expected InvalidConfig for non-rtmp URL"
);
}
#[test]
fn rtmp_build_without_video_should_return_invalid_config() {
let result = RtmpOutput::new("rtmp://127.0.0.1:1935/live").build();
assert!(
matches!(result, Err(StreamError::InvalidConfig { .. })),
"expected InvalidConfig when video() not called"
);
}
#[test]
fn rtmp_build_with_non_h264_video_codec_should_return_unsupported_codec() {
let result = RtmpOutput::new("rtmp://127.0.0.1:1935/live")
.video(1280, 720, 30.0)
.video_codec(VideoCodec::Vp9)
.build();
assert!(
matches!(result, Err(StreamError::UnsupportedCodec { .. })),
"expected UnsupportedCodec for VP9"
);
}
#[test]
fn rtmp_build_with_non_aac_audio_codec_should_return_unsupported_codec() {
let result = RtmpOutput::new("rtmp://127.0.0.1:1935/live")
.video(1280, 720, 30.0)
.audio_codec(AudioCodec::Mp3)
.build();
assert!(
matches!(result, Err(StreamError::UnsupportedCodec { .. })),
"expected UnsupportedCodec for MP3"
);
}
#[test]
fn rtmp_video_bitrate_default_should_be_four_megabits() {
let out = RtmpOutput::new("rtmp://127.0.0.1:1935/live");
let with_explicit = out.video_bitrate(4_000_000);
drop(with_explicit);
}