Forked from HybridGroup
- Adds support for streaming an MJPEG http response to Echo web server.
- Added new func
StreamToEcho. StreamToEchoimplements echo.Context to set header to image/jpeg content-type.- Writes mjpeg buffer to an Echo-type response and streams to http.
- Initialise standard Echo server as per.
- Define a Echo HTTP GET route.
- Pass new
StreamToEchofunc as the handler.
package main
import (
"github.com/GaryMcBay/mjpeg"
"github.com/labstack/echo"
)
func main() {
e := echo.New()
stream := mjpeg.NewStream()
e.GET("/capture", stream.StreamToEcho)
// Pass your jpegBuffer frames using stream.UpdateJPEG(<your-buffer>)
// Start server
e.Logger.Fatal(e.Start(":8080"))
}