fix comment

This commit is contained in:
nareix 2016-07-30 14:36:47 +08:00
parent cb534aa104
commit e90ce45293
4 changed files with 25 additions and 3 deletions

View File

@ -1,5 +1,5 @@
// Package av defines import interfaces and data structures includes container demux/mux and audio encode/decode.
// Package av defines basic interfaces and data structures of container demux/mux and audio encode/decode.
package av
import (

View File

@ -1,4 +1,5 @@
// Package pktque provides packet Filter interface and structures used by other components.
package pktque
import (
@ -7,9 +8,11 @@ import (
)
type Filter interface {
// Change packet time or drop packet
ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoidx int, audioidx int) (drop bool, err error)
}
// Combine multiple Filters into one, ModifyPacket will be called in order.
type Filters []Filter
func (self Filters) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoidx int, audioidx int) (drop bool, err error) {
@ -24,6 +27,7 @@ func (self Filters) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoid
return
}
// Wrap origin Demuxer and Filter into a new Demuxer, when read this Demuxer filters will be called.
type FilterDemuxer struct {
av.Demuxer
Filter Filter
@ -62,6 +66,7 @@ func (self FilterDemuxer) ReadPacket() (pkt av.Packet, err error) {
return
}
// Drop packets until first video key frame arrived.
type WaitKeyFrame struct {
ok bool
}
@ -74,12 +79,13 @@ func (self *WaitKeyFrame) ModifyPacket(pkt *av.Packet, streams []av.CodecData, v
return
}
// Fix incorrect packet timestamps.
type FixTime struct {
zerobase time.Duration
incrbase time.Duration
lasttime time.Duration
StartFromZero bool
MakeIncrement bool
StartFromZero bool // make timestamp start from zero
MakeIncrement bool // force timestamp increment
}
func (self *FixTime) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoidx int, audioidx int) (drop bool, err error) {
@ -105,6 +111,7 @@ func (self *FixTime) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoi
return
}
// Drop incorrect packets to make A/V sync.
type AVSync struct {
MaxTimeDiff time.Duration
time []time.Duration
@ -163,6 +170,7 @@ func (self *AVSync) check(i int) (start time.Duration, end time.Duration, correc
return
}
// Make packets reading speed as same as walltime, effect like ffmpeg -re option.
type Walltime struct {
firsttime time.Time
}

View File

@ -1,3 +1,5 @@
// Packege pubsub implements publisher-subscribers model used in multi-channel streaming.
package pubsub
import (
@ -17,6 +19,7 @@ import (
// oldest latest
//
// One publisher and multiple subscribers thread-safe packet queue buffer.
type Queue struct {
pkts []av.Packet
head, tail int
@ -43,6 +46,7 @@ func NewQueue(streams []av.CodecData) *Queue {
return q
}
// Set max buffered total packets duration.
func (self *Queue) SetMaxDuration(dur time.Duration) {
self.lock.Lock()
defer self.lock.Unlock()
@ -55,6 +59,7 @@ func (self *Queue) SetMaxDuration(dur time.Duration) {
return
}
// Currently buffered packets total duration.
func (self *Queue) Duration() (dur time.Duration) {
self.lock.RLock()
defer self.lock.RUnlock()
@ -65,6 +70,7 @@ func (self *Queue) Duration() (dur time.Duration) {
return
}
// After Close() called, all QueueCursor's ReadPacket will return io.EOF.
func (self *Queue) Close() (err error) {
self.lock.Lock()
defer self.lock.Unlock()
@ -74,6 +80,7 @@ func (self *Queue) Close() (err error) {
return
}
// Put packet into buffer, old packets will be discared.
func (self *Queue) WritePacket(pkt av.Packet) (err error) {
self.lock.Lock()
defer self.lock.Unlock()
@ -101,6 +108,7 @@ func (self *Queue) newCursor() *QueueCursor {
}
}
// Create cursor position at latest packet.
func (self *Queue) Latest() *QueueCursor {
cursor := self.newCursor()
cursor.init = func(pkts []av.Packet, videoidx int) int {
@ -109,6 +117,7 @@ func (self *Queue) Latest() *QueueCursor {
return cursor
}
// Create cursor position at oldest buffered packet.
func (self *Queue) Oldest() *QueueCursor {
cursor := self.newCursor()
cursor.init = func(pkts []av.Packet, videoidx int) int {
@ -117,6 +126,7 @@ func (self *Queue) Oldest() *QueueCursor {
return cursor
}
// Create cursor position at specific time in buffered packets.
func (self *Queue) DelayedTime(dur time.Duration) *QueueCursor {
cursor := self.newCursor()
cursor.init = func(pkts []av.Packet, videoidx int) int {
@ -134,6 +144,7 @@ func (self *Queue) DelayedTime(dur time.Duration) *QueueCursor {
return cursor
}
// Create cursor position at specific delayed GOP count in buffered packets.
func (self *Queue) DelayedGopCount(n int) *QueueCursor {
cursor := self.newCursor()
cursor.init = func(pkts []av.Packet, videoidx int) int {
@ -159,6 +170,7 @@ func (self *QueueCursor) Streams() (streams []av.CodecData, err error) {
return
}
// ReadPacket will not consume packets in Queue, it's just a cursor.
func (self *QueueCursor) ReadPacket() (pkt av.Packet, err error) {
self.que.cond.L.Lock()
if self.pos == -1 {

View File

@ -1,3 +1,5 @@
// Package transcoder implements Transcoder based on Muxer/Demuxer and AudioEncoder/AudioDecoder interface.
package transcode
import (