Merged in mjpeg-to-jpeg (pull request #446)

codec: renmaed mjpeg package to jpeg and alter terminology throughout av repo to use mjpeg and jpeg terms appropriately.

Approved-by: Trek Hopton
This commit is contained in:
Saxon Milton 2021-01-18 05:27:04 +00:00
commit 80746f9a03
14 changed files with 27 additions and 24 deletions

View File

@ -24,9 +24,6 @@ LICENSE
package codecutil 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. // 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. // When adding or removing a codec from this list, the numCodecs const must be updated.
const ( const (
@ -37,9 +34,10 @@ const (
H265 H265
MJPEG MJPEG
JPEG JPEG
maxCodec
) )
// IsValid recieves an int representing a codec and checks if it is valid. // IsValid recieves an int representing a codec and checks if it is valid.
func IsValid(codec uint8) bool { func IsValid(codec uint8) bool {
return 0 < codec && codec <= numCodecs return 0 < codec && codec < maxCodec
} }

View File

@ -23,10 +23,7 @@ LICENSE
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/ */
// Package mjpeg provides functionality for extraction of MJPEG from an package jpeg
// RTP-MJPEG stream and lexing of individual JPEGs from a bare bones
// MJPEG stream.
package mjpeg
import ( import (
"fmt" "fmt"

View File

@ -22,7 +22,7 @@ LICENSE
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/ */
package mjpeg package jpeg
import ( import (
"bytes" "bytes"
@ -53,7 +53,7 @@ func TestExtract(t *testing.T) {
want, err := ioutil.ReadFile("testdata/expect.mjpeg") want, err := ioutil.ReadFile("testdata/expect.mjpeg")
if err != nil { 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) { if !bytes.Equal(got.Bytes(), want) {

View File

@ -30,7 +30,7 @@ LICENSE
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package mjpeg package jpeg
import ( import (
"encoding/binary" "encoding/binary"

View File

@ -22,7 +22,7 @@ LICENSE
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/ */
package mjpeg package jpeg
import ( import (
"bytes" "bytes"

View File

@ -27,7 +27,7 @@ LICENSE
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/ */
package mjpeg package jpeg
import ( import (
"bufio" "bufio"

View File

@ -27,7 +27,7 @@ LICENSE
// lex_test.go provides testing for the lexer in lex.go. // lex_test.go provides testing for the lexer in lex.go.
package mjpeg package jpeg
import ( import (
"bytes" "bytes"

BIN
codec/jpeg/testdata/expect.mjpeg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 KiB

File diff suppressed because one or more lines are too long

View File

@ -51,6 +51,7 @@ const (
const ( const (
EncodeH264 = iota EncodeH264 = iota
EncodeH265 EncodeH265
EncodeJPEG
EncodeMJPEG EncodeMJPEG
EncodePCM EncodePCM
EncodeADPCM EncodeADPCM

View File

@ -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 // 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 // specifiy the media type/codec of the data we are packetising using the
// encoder. Currently supported options are EncodeH264, EncodeH265, EncodeMJPEG, EncodePCM // encoder. Currently supported options are EncodeH264, EncodeH265, EncodeMJPEG,
// and EncodeADPCM. // EncodeJPEG, EncodePCM and EncodeADPCM.
func MediaType(mt int) func(*Encoder) error { func MediaType(mt int) func(*Encoder) error {
return func(e *Encoder) error { return func(e *Encoder) error {
switch mt { switch mt {
@ -92,6 +92,10 @@ func MediaType(mt int) func(*Encoder) error {
e.mediaPID = PIDVideo e.mediaPID = PIDVideo
e.streamID = pes.MJPEGSID e.streamID = pes.MJPEGSID
e.log.Debug("configured for MJPEG packetisation") e.log.Debug("configured for MJPEG packetisation")
case EncodeJPEG:
e.mediaPID = PIDVideo
e.streamID = pes.JPEGSID
e.log.Debug("configure for JPEG packetisation")
default: default:
return ErrUnsupportedMedia return ErrUnsupportedMedia
} }

View File

@ -30,7 +30,8 @@ import "errors"
const ( const (
H264SID = 27 H264SID = 27
H265SID = 36 H265SID = 36
MJPEGSID = 28 MJPEGSID = 136
JPEGSID = 137
PCMSID = 192 PCMSID = 192
ADPCMSID = 193 ADPCMSID = 193
) )
@ -44,6 +45,8 @@ func SIDToMIMEType(id int) (string, error) {
return "video/h265", nil return "video/h265", nil
case MJPEGSID: case MJPEGSID:
return "video/x-motion-jpeg", nil return "video/x-motion-jpeg", nil
case JPEGSID:
return "image/jpeg", nil
case PCMSID: case PCMSID:
return "audio/pcm", nil return "audio/pcm", nil
case ADPCMSID: case ADPCMSID:

View File

@ -59,7 +59,7 @@ const (
// Codecs. // Codecs.
H264 H264
H265 H265
MJPEG JPEG
) )
// Quality represents video quality. // Quality represents video quality.

View File

@ -37,7 +37,7 @@ import (
"bitbucket.org/ausocean/av/codec/codecutil" "bitbucket.org/ausocean/av/codec/codecutil"
"bitbucket.org/ausocean/av/codec/h264" "bitbucket.org/ausocean/av/codec/h264"
"bitbucket.org/ausocean/av/codec/h265" "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/flv"
"bitbucket.org/ausocean/av/container/mts" "bitbucket.org/ausocean/av/container/mts"
"bitbucket.org/ausocean/av/device" "bitbucket.org/ausocean/av/device"
@ -324,11 +324,11 @@ func (r *Revid) setLexer(c uint8, isRTSP bool) error {
if !isRTSP { if !isRTSP {
return errors.New("byte stream h.265 lexing not implemented") return errors.New("byte stream h.265 lexing not implemented")
} }
case codecutil.MJPEG: case codecutil.MJPEG, codecutil.JPEG:
r.cfg.Logger.Log(logger.Debug, "using MJPEG codec") r.cfg.Logger.Log(logger.Debug, "using MJPEG/JPEG codec")
r.lexTo = mjpeg.Lex r.lexTo = jpeg.Lex
if isRTSP { if isRTSP {
r.lexTo = mjpeg.NewExtractor().Extract r.lexTo = jpeg.NewExtractor().Extract
} }
case codecutil.PCM, codecutil.ADPCM: case codecutil.PCM, codecutil.ADPCM:
return errors.New("invalid codec for this selected input") return errors.New("invalid codec for this selected input")