【发布时间】:2020-01-20 10:39:09
【问题描述】:
我有一个网络摄像头的流 url,它返回内容类型“multipart/x-mixed-replace;boundary=myboundary”,假设它可以通过http://mywebcam/livrestream.cgi 访问
我想在 ASP.NET CORE 中创建一个可以返回相同流的代理。
我创建了一条获取流的路线:
[Route("api/test")]
[HttpGet]
public async Task<HttpResponseMessage> Test()
{
var client = new HttpClient();
var inputStream = await client.GetStreamAsync("http://mywebcam/livrestream.cgi");
var response = new HttpResponseMessage();
response.Content = new PushStreamContent((stream, httpContent, transportContext) =>
{
// what to do ?
}, "video/mp4");
return response;
}
看来我必须使用 PushStreamContent。但我该怎么办? 一个无休止的 while 循环,定期查询流?还有什么?
【问题讨论】:
-
为什么使用
HttpResponseMessage?这不再在 asp.net-core 中使用。其次,还要考虑标题以允许部分/块(即:范围标题) -
为什么不呢,但我不知道我应该在 PushStreamContent 中做什么?还是有其他方法可以做到这一点?
标签: c# asp.net-core video-streaming