ff-stream 0.14.2

HLS and DASH adaptive streaming output for the ff-* crate family
Documentation
//! Integration tests for `RtmpOutput`.
//!
//! Tests that validate builder configuration without requiring a live RTMP server.
//! All network-connection tests are skipped by design — they would require an
//! external RTMP ingest endpoint.

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");
    // Access via build validation — default is 4 Mbps, set explicitly and check
    // it does not override default when not called.
    let with_explicit = out.video_bitrate(4_000_000);
    // No assertion on internal field (not pub), but build should not fail due to
    // bitrate even when the network is unavailable — it will fail with Ffmpeg instead.
    drop(with_explicit);
}