I grabbed two parts from the internet. One part is webrequest to HDTV to pull a lower bitrate stream 3mbps using in url metadata. The second part is a simple http powershell to push content over port 8080. My VLC will connect to this 8080 service; as VLC transcode in url meta is not actually going to the HDtV so it's always full blast like 10mbps over wifi.

It kinda works, but closes the session upon first packet. So when I simply browse to it I get a 256 byte download, but it should continue to stream until I close the HDTV stream. VLC connects then drops connection after the first packet. I tried to not close the response or dispose the output stream, but both ways just ends my session after the first packet.

$webrequest = [System.Net.HttpWebRequest]::Create("http://192.168.0.213:5004/auto/v56.1?transcode=internet240")
$responseStream = $webrequest.GetResponse().GetResponseStream()
$streamReader = [System.IO.StreamReader]::new($responseStream)

$listener = New-Object System.Net.HttpListener ; $listener.Prefixes.Add("http://+:8080/"); $listener.Start(); 
while ($listener.IsListening) { 
#Above at top is the raw requests from HDHomeRun.  Listener for VLC is second. Below is logic to get and put.

[char[]]$Buffer = [char[]]::new(256)
while (($count = $streamReader.Read($buffer, 0, $buffer.Length)) -gt 0)
{    
  $Context = $listener.GetContext() ; $Request = $Context.Request; Write-Output (date); $Response = $Context.Response ; 

 $RespBytes = [System.Text.ASCIIEncoding]::utf8.GetBytes($buffer); 
  $Response.ContentLength64 = $RespBytes.Length ; $Response.OutputStream.Write($RespBytes, 0, $RespBytes.Length) ; 
  $Response.OutputStream.Dispose(); 
  $Response.Close() > $null ; 
# $Buffer
}

$responseStream.Close() > $null
}

I was expecting the port 80 read from HDTV IP would stream through my desktop's webserver and listen for VLC on port localhost:8080 and every byte I read from HDTV would flow to VLC over my port 8080 webserver.

I need to keep the write stream open on my webserver, but it keeps closing after the first 256 bytes packet.

0

There are 0 best solutions below