Exemplo n.º 1
0
func (m *Muxer) routine() {
	vFrame := C.alloc_video_frame(m.videoStream.stream.codec)
	if vFrame == (*C.AVFrame)(null) {
		m.done <- true
		return
	}
	aFrame := C.alloc_audio_frame(m.audioStream.stream.codec)
	if aFrame == (*C.AVFrame)(null) {
		m.done <- true
		return
	}
	for m.loop {
		if C.av_compare_ts(C.int64_t(m.videoStream.ts), m.videoStream.stream.codec.time_base,
			C.int64_t(m.audioStream.ts), m.audioStream.stream.codec.time_base) <= 0 {
			m.writeVideoFrame(vFrame)
		} else {
			m.writeAudioFrame(aFrame)
		}
		time.Sleep(time.Millisecond * 30)
	}
	if vFrame != (*C.AVFrame)(null) {
		C.av_frame_free(&vFrame)
	}
	if aFrame != (*C.AVFrame)(null) {
		C.av_frame_free(&aFrame)
	}
	m.done <- true
}
func (time *Timestamp) Lower(ts Timestamp) bool {
	return C.av_compare_ts(_Ctypedef_int64_t(time.Time), *time.Timebase.GetAVRational(), _Ctypedef_int64_t(ts.Time), *ts.Timebase.GetAVRational()) == -1
}
Exemplo n.º 3
0
func CompareTimeStamp(aTimestamp int, aTimebase AVRational, bTimestamp int, bTimebase AVRational) int {
	return int(C.av_compare_ts(C.int64_t(aTimestamp), C.struct_AVRational(aTimebase),
		C.int64_t(bTimestamp), C.struct_AVRational(bTimebase)))
}
Exemplo n.º 4
0
func av_compare_ts(leftts int64, leftbase Rational, rightts int64, rightbase Rational) int {
	var a C.AVRational = C.AVRational{C.int(leftbase.Num), C.int(leftbase.Den)}
	var b C.AVRational = C.AVRational{C.int(rightbase.Num), C.int(rightbase.Den)}
	return int(C.av_compare_ts(C.int64_t(leftts), a, C.int64_t(rightts), b))
}