From 7577cfa0c4ca86ff5c46e427f07b05b3330e46c4 Mon Sep 17 00:00:00 2001 From: Saxon Date: Fri, 15 Nov 2019 15:41:02 +1030 Subject: [PATCH] codec/mjpeg/jpeg.go: added putMarker function to write JPEG marker codes to an io.Writer --- codec/mjpeg/jpeg.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/codec/mjpeg/jpeg.go b/codec/mjpeg/jpeg.go index da878d83..c5c42c06 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/mjpeg/jpeg.go @@ -24,6 +24,8 @@ LICENSE package mjpeg +import "io" + // JPEG marker codes. const ( soi = 0xd8 // Start of image. @@ -34,3 +36,12 @@ const ( app0 = 0xe0 // TODO: find out what this is. sof0 = 0xc0 // Baseline ) + +// putMarker writes an JPEG marker with code to w. +func putMarker(w io.Writer, code byte) error { + _, err := w.Write([]byte{0xff, code}) + if err != nil { + return err + } + return nil +}