I'm running server (ASP NET Core project .NET 8) and subscriber (VLC Media player) on localhost. The video source is on Raspberry Pi.
VLC Media player (FLV subscription) is subscribing successfully and I can see the stream.
var outputDir = Path.Combine(Directory.GetCurrentDirectory(), "output");
if (!Directory.Exists(outputDir))
new DirectoryInfo(outputDir).Create();
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddJsonFile("appsettings.Local.json", true, true);
using var liveStreamingServer = LiveStreamingServerBuilder.Create()
.ConfigureRtmpServer(options =>
{
options
.AddAuthorizationHandler<StreamAuthorizationHandler>()
.AddConnectionEventHandler<ConnectionEventListener>()
.AddStreamEventHandler<StreamEventListener>()
.AddStandaloneServices()
.AddFlv();
options
.AddStreamProcessor(options => options.AddStreamProcessorEventHandler<HlsTransmuxerEventListener>())
.AddHlsTransmuxer(options => options.OutputPathResolver = new HlsTransmuxerOutputPathResolver(outputDir));
})
.ConfigureLogging(options =>
{
options.AddConsole();
options.AddApplicationInsights(config => config.ConnectionString = builder.Configuration.GetValue<string>("APPLICATIONINSIGHTS_CONNECTION_STRING"), loggerOpts => { });
})
.Build();
// Add services to the container.
builder.Services.AddBackgroundServer(liveStreamingServer, new ServerEndPoint(new IPEndPoint(IPAddress.Any, 1935), false));
builder.Services.AddApplicationInsightsTelemetry();
builder.Services.AddCors(options =>
options.AddDefaultPolicy(policy =>
policy
.AllowAnyHeader()
.AllowAnyOrigin()
.AllowAnyMethod()));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseWebSockets();
app.UseWebSocketFlv(liveStreamingServer);
app.UseHttpFlv(liveStreamingServer);
app.MapStandaloneServerApiEndPoints(liveStreamingServer);
app.UseAdminPanelUI(new AdminPanelUIOptions { BasePath = "/ui", HasHttpFlvPreview = true });
app.UseCors();
app.UseStaticFiles(new StaticFileOptions
{
RequestPath = "/hls",
FileProvider = new PhysicalFileProvider(outputDir),
ContentTypeProvider = new FileExtensionContentTypeProvider
{
Mappings = { [".m3u8"] = "application/x-mpegURL" }
}
});
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();