mirror of https://bitbucket.org/ausocean/av.git
container/mts: changed consts H264, H265 and Audio to EncodeH264, EncodeH265 and EncodeAudio
This commit is contained in:
parent
eeaf806c6e
commit
d29141cf05
|
@ -87,9 +87,9 @@ const (
|
|||
// Video and Audio constants are used to communicate which media type will be encoded when creating a
|
||||
// new encoder with NewEncoder.
|
||||
const (
|
||||
H264 = iota
|
||||
H265
|
||||
Audio
|
||||
EncodeH264 = iota
|
||||
EncodeH265
|
||||
EncodeAudio
|
||||
)
|
||||
|
||||
// Time-related constants.
|
||||
|
@ -133,13 +133,13 @@ func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
|||
var mPid int
|
||||
var sid byte
|
||||
switch mediaType {
|
||||
case Audio:
|
||||
case EncodeAudio:
|
||||
mPid = audioPid
|
||||
sid = audioStreamID
|
||||
case H265:
|
||||
case EncodeH265:
|
||||
mPid = videoPid
|
||||
sid = H265ID
|
||||
case H264:
|
||||
case EncodeH264:
|
||||
mPid = videoPid
|
||||
sid = H264ID
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ func TestEncodeVideo(t *testing.T) {
|
|||
|
||||
// Create the dst and write the test data to encoder.
|
||||
dst := &destination{}
|
||||
_, err := NewEncoder(nopCloser{dst}, 25, H264).Write(data)
|
||||
_, err := NewEncoder(nopCloser{dst}, 25, EncodeH264).Write(data)
|
||||
if err != nil {
|
||||
t.Fatalf("could not write data to encoder, failed with err: %v\n", err)
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func TestEncodePcm(t *testing.T) {
|
|||
sampleSize := 2
|
||||
blockSize := 16000
|
||||
writeFreq := float64(sampleRate*sampleSize) / float64(blockSize)
|
||||
e := NewEncoder(nopCloser{&buf}, writeFreq, Audio)
|
||||
e := NewEncoder(nopCloser{&buf}, writeFreq, EncodeAudio)
|
||||
|
||||
inPath := "../../../test/test-data/av/input/sweep_400Hz_20000Hz_-3dBFS_5s_48khz.pcm"
|
||||
inPcm, err := ioutil.ReadFile(inPath)
|
||||
|
|
|
@ -48,7 +48,7 @@ const fps = 25
|
|||
func TestMetaEncode1(t *testing.T) {
|
||||
Meta = meta.New()
|
||||
var buf bytes.Buffer
|
||||
e := NewEncoder(nopCloser{&buf}, fps, H264)
|
||||
e := NewEncoder(nopCloser{&buf}, fps, EncodeH264)
|
||||
Meta.Add("ts", "12345678")
|
||||
if err := e.writePSI(); err != nil {
|
||||
t.Errorf(errUnexpectedErr, err.Error())
|
||||
|
@ -76,7 +76,7 @@ func TestMetaEncode1(t *testing.T) {
|
|||
func TestMetaEncode2(t *testing.T) {
|
||||
Meta = meta.New()
|
||||
var buf bytes.Buffer
|
||||
e := NewEncoder(nopCloser{&buf}, fps, H264)
|
||||
e := NewEncoder(nopCloser{&buf}, fps, EncodeH264)
|
||||
Meta.Add("ts", "12345678")
|
||||
Meta.Add("loc", "1234,4321,1234")
|
||||
if err := e.writePSI(); err != nil {
|
||||
|
|
|
@ -177,9 +177,9 @@ func (r *Revid) reset(config Config) error {
|
|||
var st int
|
||||
switch r.config.Input {
|
||||
case Raspivid, File, V4L:
|
||||
st = mts.H264
|
||||
st = mts.EncodeH264
|
||||
case RTSP:
|
||||
st = mts.H265
|
||||
st = mts.EncodeH265
|
||||
}
|
||||
e := mts.NewEncoder(dst, float64(fps), st)
|
||||
return e, nil
|
||||
|
|
|
@ -134,7 +134,7 @@ func TestMtsSenderSegment(t *testing.T) {
|
|||
const numberOfClips = 11
|
||||
dst := &destination{t: t, done: make(chan struct{}), doneAt: numberOfClips}
|
||||
sender := newMtsSender(dst, (*dummyLogger)(t).log, rbSize, rbElementSize, 0)
|
||||
encoder := mts.NewEncoder(sender, 25, mts.H264)
|
||||
encoder := mts.NewEncoder(sender, 25, mts.EncodeH264)
|
||||
|
||||
// Turn time based PSI writing off for encoder.
|
||||
const psiSendCount = 10
|
||||
|
@ -212,7 +212,7 @@ func TestMtsSenderFailedSend(t *testing.T) {
|
|||
const clipToFailAt = 3
|
||||
dst := &destination{t: t, testFails: true, failAt: clipToFailAt, done: make(chan struct{})}
|
||||
sender := newMtsSender(dst, (*dummyLogger)(t).log, rbSize, rbElementSize, 0)
|
||||
encoder := mts.NewEncoder(sender, 25, mts.H264)
|
||||
encoder := mts.NewEncoder(sender, 25, mts.EncodeH264)
|
||||
|
||||
// Turn time based PSI writing off for encoder and send PSI every 10 packets.
|
||||
const psiSendCount = 10
|
||||
|
@ -292,7 +292,7 @@ func TestMtsSenderDiscontinuity(t *testing.T) {
|
|||
const clipToDelay = 3
|
||||
dst := &destination{t: t, sendDelay: 10 * time.Millisecond, delayAt: clipToDelay, done: make(chan struct{})}
|
||||
sender := newMtsSender(dst, (*dummyLogger)(t).log, 1, rbElementSize, 0)
|
||||
encoder := mts.NewEncoder(sender, 25, mts.H264)
|
||||
encoder := mts.NewEncoder(sender, 25, mts.EncodeH264)
|
||||
|
||||
// Turn time based PSI writing off for encoder.
|
||||
const psiSendCount = 10
|
||||
|
|
Loading…
Reference in New Issue