0

Code below read bytes from MJPEG video stream. It works perfectly on Windows 8.1 Store application, but the same code fail on Windows phone 8.1 application.

After reading 65536 bytes method "Read" not read more bytes from stream.

The same problem in On WP8.1 ONLY: cannot read more than 65536 bytes off an HTTP Stream

Someone tells about property DefaultMaximumErrorResponseLength but this property is only in WPF (not in windows store .net)

WebClient class on WP8.1 has the same problem.

(in On WP8.1 ONLY: cannot read more than 65536 bytes off an HTTP Stream says that WebClient don't have this problem, but it don't true)

Sample code:

        var request = (HttpWebRequest)WebRequest.CreateHttp("http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?resolution=352x288");
        request.AllowReadStreamBuffering = false;
        request.BeginGetResponse(OnGetResponse, request);


    private void OnGetResponse(IAsyncResult asyncResult)
    {
        HttpWebRequest req = (HttpWebRequest)asyncResult.AsyncState;
            HttpWebResponse resp = (HttpWebResponse)req.EndGetResponse(asyncResult);
            Stream s = resp.GetResponseStream();
        byte[] buff = new byte[ChunkSize];
        int readed;
        do
        {
            readed = s.Read(buff, 0, ChunkSize);
        }
        while (readed > 0);
    }
Community
  • 1
  • 1
denza
  • 66
  • 3
  • For large files you can look into using the BackgroundDownloader class https://msdn.microsoft.com/library/windows/apps/windows.networking.backgroundtransfer.backgrounddownloader.aspx – Barnstokkr Oct 12 '15 at 14:03
  • This sample is infinity stream with no end. I can't store this to file, and don't want that, because I need data from stream in real time. – denza Oct 12 '15 at 14:10

0 Answers0