Я пишу приложение для Windows Phone в XNA ... и я хотел бы прочитать поток MJPEG, хранящийся в ресурсах приложения. Я нашел много примеров того, как получить MJPEG с веб-сайта с помощью WebHttpRequest так:Как прочитать локальный файл MJPEG
// get the response
HttpWebRequest request = (HttpWebRequest) asyncResult.AsyncState;
HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(asyncResult);
try {
// find boundary value
string contentType = response.Headers["Content-Type"];
if (!String.IsNullOrEmpty(contentType) && !contentType.Contains("=")) {
throw new FormatException("Invalid content-type header. The source is likely not returning a proper MJPEG stream.");
}
string boundary = response.Headers["Content-Type"].Split('=')[1].Replace("\"", "");
byte[] boundaryBytes = Encoding.UTF8.GetBytes(boundary.StartsWith("--") ? boundary : "--" + boundary);
using (Stream stream = response.GetResponseStream()) {
using (BinaryReader binaryReader = new BinaryReader(stream)) {
// code to parse the MJPEG stream
}
}
} finally {
response.Close();
}
... но это не совсем то, что я ищу. Здесь ниже мой код для чтения MJPEG в виде двоичного потока из ресурсов приложения:
private void ParseMjpeg(object uri)
{
// what the corresponding code for determining the boundary bytes in my local MJPEG?
byte[] boundaryBytes = ???
using (Stream stream = TitleContainer.OpenStream(uri.ToString())) {
using (BinaryReader binaryReader = new BinaryReader(stream)) {
// code to parse the MJPEG stream as before: OK
}
}
}
Как определить граничные байты в моем коде здесь выше? Любая помощь могла бы быть полезна.
Спасибо, J3D