67 lines
2.8 KiB
C#
67 lines
2.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using Paca.Mobile.Core;
|
|
using Paca.Tests.Infrastructure;
|
|
using Xunit;
|
|
|
|
namespace Paca.Tests.Mobile;
|
|
|
|
/// <summary>
|
|
/// Gate 157 ~ 159: 모바일 적응형 스트리밍 트랜스코딩 & 데이터 세이버 오디오 추출 기계적 검증
|
|
/// </summary>
|
|
public class MobileAdaptiveTranscodingGateTests
|
|
{
|
|
[Fact]
|
|
public void Gate157_AdaptiveStreamingProfile_Bandwidth_Estimation()
|
|
{
|
|
// 1시간 4K 영상 (약 15GB, ~33.3 Mbps)
|
|
long originalBytes = 15L * 1024 * 1024 * 1024;
|
|
var duration = TimeSpan.FromHours(1);
|
|
|
|
var originalProfile = AdaptiveStreamingProfile.OriginalDirect;
|
|
var cellularProfile = AdaptiveStreamingProfile.CellularDataSaver_720p;
|
|
var audioProfile = AdaptiveStreamingProfile.AudioPodcast_128k;
|
|
|
|
// 원본: 절감률 0%
|
|
Assert.Equal(0.0, originalProfile.CalculateDataSavingsPercent(originalBytes, duration));
|
|
|
|
// 720p 셀룰러: 약 675MB 소모 (1.5Mbps * 3600s / 8) -> 95%+ 절감
|
|
var cellularSavings = cellularProfile.CalculateDataSavingsPercent(originalBytes, duration);
|
|
Assert.InRange(cellularSavings, 90.0, 98.0);
|
|
|
|
// 오디오 전용: 약 57MB 소모 (128kbps * 3600s / 8) -> 99%+ 절감
|
|
var audioSavings = audioProfile.CalculateDataSavingsPercent(originalBytes, duration);
|
|
Assert.InRange(audioSavings, 98.0, 99.9);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate158_StreamingQualityManager_AutoSelection()
|
|
{
|
|
var manager = new StreamingQualityManager();
|
|
|
|
// 1. Wi-Fi 무제한 환경 -> 원본 직접 스트리밍
|
|
var wifiProfile = manager.SelectOptimalProfile(NetworkProfileType.WiFi, isDataSaverActive: false);
|
|
Assert.Equal(AdaptiveStreamingProfile.OriginalDirect, wifiProfile);
|
|
|
|
// 2. 3G/4G/5G 셀룰러 환경 -> 720p 데이터 세이버 자동 전환
|
|
var cellularProfile = manager.SelectOptimalProfile(NetworkProfileType.Cellular5G, isDataSaverActive: false);
|
|
Assert.Equal(AdaptiveStreamingProfile.CellularDataSaver_720p, cellularProfile);
|
|
|
|
// 3. 사용자 데이터 절약 모드 켬 -> 오디오 전용 모드 자동 추천
|
|
var saverProfile = manager.SelectOptimalProfile(NetworkProfileType.CellularLTE, isDataSaverActive: true);
|
|
Assert.Equal(AdaptiveStreamingProfile.AudioPodcast_128k, saverProfile);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate159_WebCompanion_AudioExtraction_Endpoint_Header_Audit()
|
|
{
|
|
var serverHostPath = Path.Combine(SourceTree.Root, "src", "Paca.Server", "ServerHost.cs");
|
|
Assert.True(File.Exists(serverHostPath), "ServerHost.cs must exist");
|
|
|
|
var code = File.ReadAllText(serverHostPath);
|
|
|
|
// 오디오 전용 스트리밍 엔드포인트 /api/audio/ 검증
|
|
Assert.Contains("/api/audio/{id}", code);
|
|
Assert.Contains("audio/mp4", code);
|
|
}
|
|
}
|