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

This commit is contained in:
Saxon Nelson-Milton 2021-01-18 15:29:21 +10:30
parent 13ea99b63b
commit af519d61fa
14 changed files with 27 additions and 24 deletions

View File

@ -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
}

View File

@ -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"

View File

@ -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) {

View File

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

View File

@ -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"

View File

@ -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"

View File

@ -27,7 +27,7 @@ LICENSE
// lex_test.go provides testing for the lexer in lex.go.
package mjpeg
package jpeg
import (
"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 (
EncodeH264 = iota
EncodeH265
EncodeJPEG
EncodeMJPEG
EncodePCM
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
// 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
}

View File

@ -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:

View File

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

View File

@ -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")