c# - HttpWebResponse with MJPEG and multipart/x-mixed-replace; boundary=--myboundary response content type from security camera not working -
i have asp.net application need show video feed security camera. video feed has content type of 'multipart/x-mixed-replace; boundary=--myboundary' image data between boundaries. need assistance passing stream of data through page client side plugin have can consume stream if browsed camera's web interface directly. following code not work:
//get response data byte[] data = htmlparser.getbytearrayfromstream(response.getresponsestream()); if (data != null) { httpcontext.current.response.outputstream.write(data, 0, data.length); } return;
well, if want client see mjpeg stream, need send whole http response. http client browser or media player vlc need mjpeg stream looks :
http/1.1 200 ok content-type: multipart/x-mixed-replace; boundary=myboundary --myboundary content-type: image/jpeg content-length: 12345 [image 1 encoded jpeg data] --myboundary content-type: image/jpeg content-length: 45678 [image 2 encoded jpeg data] ...
note: ergousha said in answer, must have empty line after content-length field.
by way, why not redirect client directly mjpeg stream ?
you can use http://ipcam/mjpg/video.mjpg axis ip cameras example.
if need image through http, have set correct header , mime content-type image/jpeg. decode image, have byte data , jpeg encoding. have decode jpeg image in specific format (something yuv420p think). i've check on ip camera, , stream not base64 encoded think.
precise needs, try more.
my2c
edit:
well, suppose :
client : connect proxy, example.com/camera1.mjpg, while not end recv yourproxy : wait connection connect camera, 10.0.0.123/camera1.mjpg while not end recv buffer copy buffer send buffer client
that must send correct header client. sure use tool wireshark spy on packet , sure after client has issued http send him correct mjpeg stream (like 1 describe @ beginning of post ...)
m2c
Comments
Post a Comment