您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Android:以mjpeg格式传输相机

Android:以mjpeg格式传输相机

我知道了。好像我的http- / content-headers被弄乱了。正确的标题应该是:

stream.write(("HTTP/1.0 200 OK\r\n" +
                          "Server: iRecon\r\n" +
                          "Connection: close\r\n" +
                          "Max-Age: 0\r\n" +
                          "Expires: 0\r\n" +
                          "Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0\r\n" +
                          "Pragma: no-cache\r\n" + 
                          "Content-Type: multipart/x-mixed-replace; " +
                          "boundary=" + boundary + "\r\n" +
                          "\r\n" +
                          "--" + boundary + "\r\n").getBytes());

stream.write(("Content-type: image/jpeg\r\n" +
                      "Content-Length: " + buffer.size() + "\r\n" +
                      "X-Timestamp:" + timestamp + "\r\n" +
                      "\r\n").getBytes());

buffer.writeTo(stream);
stream.write(("\r\n--" + boundary + "\r\n").getBytes());

当然,将边界置于何处是您自己的选择。也可能有些字段是可选的(例如,大多数在Cache- Control中),但这是可行的,直到现在,我还是懒得剥夺它们。重要的是要记住换行符(\r\nthingies)…

其他 2022/1/1 18:25:04 有368人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶