1

XNA で Windows Phone 用のアプリを作成しています...アプリのリソースに保存されている MJPEG ストリームを読みたいと思います。次のように WebHttpRequest を介して Web サイトから 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

4

1 に答える 1

1

これはあなたの人生をずっと楽にするはずです。私が理解している限り、DLL は必要なもののほとんどを提供するはずです。

http://channel9.msdn.com/coding4fun/articles/MJPEG-Decoder

于 2012-06-27T21:54:52.943 に答える