diff --git a/codec/codecutil/list.go b/codec/codecutil/list.go index 58b80cad..071935d1 100644 --- a/codec/codecutil/list.go +++ b/codec/codecutil/list.go @@ -24,9 +24,6 @@ LICENSE package codecutil -// numCodecs is the number of entries in the list of codecs. -const numCodecs = 5 - // A global list containing all available codecs for reference in any application. // When adding or removing a codec from this list, the numCodecs const must be updated. const ( @@ -37,9 +34,10 @@ const ( H265 MJPEG JPEG + maxCodec ) // IsValid recieves an int representing a codec and checks if it is valid. func IsValid(codec uint8) bool { - return 0 < codec && codec <= numCodecs + return 0 < codec && codec < maxCodec } diff --git a/codec/mjpeg/extract.go b/codec/jpeg/extract.go similarity index 93% rename from codec/mjpeg/extract.go rename to codec/jpeg/extract.go index 3d7e9ca9..0223d3ab 100644 --- a/codec/mjpeg/extract.go +++ b/codec/jpeg/extract.go @@ -23,10 +23,7 @@ LICENSE along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. */ -// Package mjpeg provides functionality for extraction of MJPEG from an -// RTP-MJPEG stream and lexing of individual JPEGs from a bare bones -// MJPEG stream. -package mjpeg +package jpeg import ( "fmt" diff --git a/codec/mjpeg/extract_test.go b/codec/jpeg/extract_test.go similarity index 94% rename from codec/mjpeg/extract_test.go rename to codec/jpeg/extract_test.go index a9f0bd98..4faa0abc 100644 --- a/codec/mjpeg/extract_test.go +++ b/codec/jpeg/extract_test.go @@ -22,7 +22,7 @@ LICENSE along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. */ -package mjpeg +package jpeg import ( "bytes" @@ -53,7 +53,7 @@ func TestExtract(t *testing.T) { want, err := ioutil.ReadFile("testdata/expect.mjpeg") if err != nil { - t.Fatalf("could not read file for wanted MJPEG data: %v", err) + t.Fatalf("could not read file for wanted JPEG data: %v", err) } if !bytes.Equal(got.Bytes(), want) { diff --git a/codec/mjpeg/jpeg.go b/codec/jpeg/jpeg.go similarity index 99% rename from codec/mjpeg/jpeg.go rename to codec/jpeg/jpeg.go index 6506fc39..e2b9c9a1 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/jpeg/jpeg.go @@ -30,7 +30,7 @@ LICENSE Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package mjpeg +package jpeg import ( "encoding/binary" diff --git a/codec/mjpeg/jpeg_test.go b/codec/jpeg/jpeg_test.go similarity index 99% rename from codec/mjpeg/jpeg_test.go rename to codec/jpeg/jpeg_test.go index 26baaa20..c0c63f27 100644 --- a/codec/mjpeg/jpeg_test.go +++ b/codec/jpeg/jpeg_test.go @@ -22,7 +22,7 @@ LICENSE along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. */ -package mjpeg +package jpeg import ( "bytes" diff --git a/codec/mjpeg/lex.go b/codec/jpeg/lex.go similarity index 99% rename from codec/mjpeg/lex.go rename to codec/jpeg/lex.go index d7bb504d..e4c38073 100644 --- a/codec/mjpeg/lex.go +++ b/codec/jpeg/lex.go @@ -27,7 +27,7 @@ LICENSE along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. */ -package mjpeg +package jpeg import ( "bufio" diff --git a/codec/mjpeg/lex_test.go b/codec/jpeg/lex_test.go similarity index 99% rename from codec/mjpeg/lex_test.go rename to codec/jpeg/lex_test.go index 9e37c57a..4a1870c7 100644 --- a/codec/mjpeg/lex_test.go +++ b/codec/jpeg/lex_test.go @@ -27,7 +27,7 @@ LICENSE // lex_test.go provides testing for the lexer in lex.go. -package mjpeg +package jpeg import ( "bytes" diff --git a/codec/jpeg/testdata/expect.mjpeg b/codec/jpeg/testdata/expect.mjpeg new file mode 100644 index 00000000..c6a30988 Binary files /dev/null and b/codec/jpeg/testdata/expect.mjpeg differ diff --git a/codec/mjpeg/tests.go b/codec/jpeg/tests.go similarity index 99% rename from codec/mjpeg/tests.go rename to codec/jpeg/tests.go index fa39200c..dba83633 100644 --- a/codec/mjpeg/tests.go +++ b/codec/jpeg/tests.go @@ -25,7 +25,7 @@ LICENSE */ -package mjpeg +package jpeg var testPackets = [][]byte{ []byte{0x80, 0x1a, 0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0x84, 0x6d, 0x3, 0x51, 0x1e, 0x6a, 0xbd, 0x4f, 0x4c, 0xc0, 0xad, 0x8a, 0x31, 0x5a, 0x14, 0x1a, 0xd8, 0x46, 0x6d, 0x58, 0xa5, 0xa2, 0xa4, 0x64, 0xd5, 0x4c, 0xd4, 0xf5, 0x4a, 0xa0, 0x7, 0x66, 0x96, 0x9b, 0x8a, 0x8c, 0xd3, 0x2c, 0x33, 0x51, 0xd4, 0x35, 0x15, 0x49, 0x64, 0xf5, 0x63, 0x35, 0x5a, 0x9b, 0x54, 0x49, 0xa1, 0x53, 0x56, 0x7d, 0x4d, 0x41, 0x25, 0xca, 0x2a, 0xb5, 0x4f, 0x4c, 0x2, 0x9d, 0x50, 0xd3, 0xa8, 0x10, 0x55, 0x3a, 0x79, 0x34, 0xda, 0x63, 0x21, 0xa9, 0xb1, 0x52, 0xd2, 0x54, 0x8c, 0x82, 0x9f, 0x52, 0x53, 0xc5, 0x68, 0x3, 0x31, 0x4e, 0xa9, 0xaa, 0xad, 0x31, 0x5, 0x15, 0x2d, 0x36, 0x91, 0x44, 0x14, 0xb4, 0xfa, 0x29, 0x8c, 0x65, 0x3a, 0xa3, 0xa2, 0xa0, 0xa2, 0x7a, 0x8e, 0x99, 0x49, 0x52, 0x4, 0xb4, 0x95, 0x1d, 0x2d, 0x31, 0x8e, 0xa8, 0xe9, 0x28, 0xa4, 0x50, 0xfa, 0x29, 0x28, 0xaa, 0x1, 0xf4, 0xda, 0x29, 0xd4, 0xc9, 0x1b, 0x4f, 0xa4, 0xa7, 0x50, 0x4, 0x94, 0xca, 0x29, 0xb4, 0x89, 0x1f, 0x4f, 0xa6, 0xd3, 0xea, 0x89}, diff --git a/container/mts/encoder.go b/container/mts/encoder.go index 3eef00d0..8faccbe5 100644 --- a/container/mts/encoder.go +++ b/container/mts/encoder.go @@ -51,6 +51,7 @@ const ( const ( EncodeH264 = iota EncodeH265 + EncodeJPEG EncodeMJPEG EncodePCM EncodeADPCM diff --git a/container/mts/options.go b/container/mts/options.go index 599e324c..43ac8fef 100644 --- a/container/mts/options.go +++ b/container/mts/options.go @@ -67,8 +67,8 @@ func TimeBasedPSI(dur time.Duration) func(*Encoder) error { // MediaType is an option that can be passed to NewEncoder. It is used to // specifiy the media type/codec of the data we are packetising using the -// encoder. Currently supported options are EncodeH264, EncodeH265, EncodeMJPEG, EncodePCM -// and EncodeADPCM. +// encoder. Currently supported options are EncodeH264, EncodeH265, EncodeMJPEG, +// EncodeJPEG, EncodePCM and EncodeADPCM. func MediaType(mt int) func(*Encoder) error { return func(e *Encoder) error { switch mt { @@ -92,6 +92,10 @@ func MediaType(mt int) func(*Encoder) error { e.mediaPID = PIDVideo e.streamID = pes.MJPEGSID e.log.Debug("configured for MJPEG packetisation") + case EncodeJPEG: + e.mediaPID = PIDVideo + e.streamID = pes.JPEGSID + e.log.Debug("configure for JPEG packetisation") default: return ErrUnsupportedMedia } diff --git a/container/mts/pes/helpers.go b/container/mts/pes/helpers.go index 60cff2cd..23b8ee94 100644 --- a/container/mts/pes/helpers.go +++ b/container/mts/pes/helpers.go @@ -30,7 +30,8 @@ import "errors" const ( H264SID = 27 H265SID = 36 - MJPEGSID = 28 + MJPEGSID = 136 + JPEGSID = 137 PCMSID = 192 ADPCMSID = 193 ) @@ -44,6 +45,8 @@ func SIDToMIMEType(id int) (string, error) { return "video/h265", nil case MJPEGSID: return "video/x-motion-jpeg", nil + case JPEGSID: + return "image/jpeg", nil case PCMSID: return "audio/pcm", nil case ADPCMSID: diff --git a/revid/config/config.go b/revid/config/config.go index cefe81d4..673677ea 100644 --- a/revid/config/config.go +++ b/revid/config/config.go @@ -59,7 +59,7 @@ const ( // Codecs. H264 H265 - MJPEG + JPEG ) // Quality represents video quality. diff --git a/revid/pipeline.go b/revid/pipeline.go index f55ac02c..59340856 100644 --- a/revid/pipeline.go +++ b/revid/pipeline.go @@ -37,7 +37,7 @@ import ( "bitbucket.org/ausocean/av/codec/codecutil" "bitbucket.org/ausocean/av/codec/h264" "bitbucket.org/ausocean/av/codec/h265" - "bitbucket.org/ausocean/av/codec/mjpeg" + "bitbucket.org/ausocean/av/codec/jpeg" "bitbucket.org/ausocean/av/container/flv" "bitbucket.org/ausocean/av/container/mts" "bitbucket.org/ausocean/av/device" @@ -324,11 +324,11 @@ func (r *Revid) setLexer(c uint8, isRTSP bool) error { if !isRTSP { return errors.New("byte stream h.265 lexing not implemented") } - case codecutil.MJPEG: - r.cfg.Logger.Log(logger.Debug, "using MJPEG codec") - r.lexTo = mjpeg.Lex + case codecutil.MJPEG, codecutil.JPEG: + r.cfg.Logger.Log(logger.Debug, "using MJPEG/JPEG codec") + r.lexTo = jpeg.Lex if isRTSP { - r.lexTo = mjpeg.NewExtractor().Extract + r.lexTo = jpeg.NewExtractor().Extract } case codecutil.PCM, codecutil.ADPCM: return errors.New("invalid codec for this selected input")