Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nareix committed Jul 30, 2016
1 parent cb534aa commit e90ce45
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion av/av.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
12 changes: 10 additions & 2 deletions av/pktque/filters.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

// Package pktque provides packet Filter interface and structures used by other components.
package pktque

import (
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 12 additions & 0 deletions av/pubsub/queue.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

// Packege pubsub implements publisher-subscribers model used in multi-channel streaming.
package pubsub

import (
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions av/transcode/transcode.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

// Package transcoder implements Transcoder based on Muxer/Demuxer and AudioEncoder/AudioDecoder interface.
package transcode

import (
Expand Down

0 comments on commit e90ce45

Please sign in to comment.