modulepackage
0.0.0-20210310105412-531a1533a6cd
Repository: https://github.com/garymcbay/mjpeg.git
Documentation: pkg.go.dev
# README
Forked from HybridGroup
Changes
- Adds support for streaming an MJPEG http response to Echo web server.
- Added new func
StreamToEcho
. StreamToEcho
implements echo.Context to set header to image/jpeg content-type.- Writes mjpeg buffer to an Echo-type response and streams to http.
How to use
- Initialise standard Echo server as per.
- Define a Echo HTTP GET route.
- Pass new
StreamToEcho
func as the handler.
Code Example
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"))
}
# Functions
NewStream initializes and returns a new Stream.