123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- package av
- import (
- "fmt"
- "io"
- )
- const (
- TAG_AUDIO = 8
- TAG_VIDEO = 9
- TAG_SCRIPTDATAAMF0 = 18
- TAG_SCRIPTDATAAMF3 = 0xf
- )
- const (
- MetadatAMF0 = 0x12
- MetadataAMF3 = 0xf
- )
- const (
- SOUND_MP3 = 2
- SOUND_NELLYMOSER_16KHZ_MONO = 4
- SOUND_NELLYMOSER_8KHZ_MONO = 5
- SOUND_NELLYMOSER = 6
- SOUND_ALAW = 7
- SOUND_MULAW = 8
- SOUND_AAC = 10
- SOUND_SPEEX = 11
- SOUND_5_5Khz = 0
- SOUND_11Khz = 1
- SOUND_22Khz = 2
- SOUND_44Khz = 3
- SOUND_8BIT = 0
- SOUND_16BIT = 1
- SOUND_MONO = 0
- SOUND_STEREO = 1
- AAC_SEQHDR = 0
- AAC_RAW = 1
- )
- const (
- AVC_SEQHDR = 0
- AVC_NALU = 1
- AVC_EOS = 2
- FRAME_KEY = 1
- FRAME_INTER = 2
- VIDEO_H264 = 7
- )
- var (
- PUBLISH = "publish"
- PLAY = "play"
- )
- // Header can be converted to AudioHeaderInfo or VideoHeaderInfo
- type Packet struct {
- IsAudio bool
- IsVideo bool
- IsMetadata bool
- TimeStamp uint32 // dts
- StreamID uint32
- Header PacketHeader
- Data []byte
- }
- type PacketHeader interface {
- }
- type AudioPacketHeader interface {
- PacketHeader
- SoundFormat() uint8
- AACPacketType() uint8
- }
- type VideoPacketHeader interface {
- PacketHeader
- IsKeyFrame() bool
- IsSeq() bool
- CodecID() uint8
- CompositionTime() int32
- }
- type Demuxer interface {
- Demux(*Packet) (ret *Packet, err error)
- }
- type Muxer interface {
- Mux(*Packet, io.Writer) error
- }
- type SampleRater interface {
- SampleRate() (int, error)
- }
- type CodecParser interface {
- SampleRater
- Parse(*Packet, io.Writer) error
- }
- type GetWriter interface {
- GetWriter(Info) WriteCloser
- }
- type Handler interface {
- HandleReader(ReadCloser)
- HandleWriter(WriteCloser)
- }
- type Alive interface {
- Alive() bool
- }
- type Closer interface {
- Info() Info
- Close(error)
- }
- type CalcTime interface {
- CalcBaseTimestamp()
- }
- type Info struct {
- Key string
- URL string
- UID string
- Inter bool
- }
- func (info Info) IsInterval() bool {
- return info.Inter
- }
- func (info Info) String() string {
- return fmt.Sprintf("<key: %s, URL: %s, UID: %s, Inter: %v>",
- info.Key, info.URL, info.UID, info.Inter)
- }
- type ReadCloser interface {
- Closer
- Alive
- Read(*Packet) error
- }
- type WriteCloser interface {
- Closer
- Alive
- CalcTime
- Write(*Packet) error
- }
|