6 changed files with 91 additions and 52 deletions
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
package rtmputils |
||||
|
||||
import ( |
||||
"time" |
||||
|
||||
"github.com/notedit/rtmp/av" |
||||
) |
||||
|
||||
// WriteAACConfig writes an AAC config.
|
||||
func (c *Conn) WriteAACConfig(config []byte) error { |
||||
return c.WritePacket(av.Packet{ |
||||
Type: av.AACDecoderConfig, |
||||
Data: config, |
||||
}) |
||||
} |
||||
|
||||
// WriteAAC writes an AAC AU.
|
||||
func (c *Conn) WriteAAC(au []byte, dts time.Duration) error { |
||||
return c.WritePacket(av.Packet{ |
||||
Type: av.AAC, |
||||
Data: au, |
||||
Time: dts, |
||||
}) |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package rtmputils |
||||
|
||||
import ( |
||||
"github.com/notedit/rtmp/format/rtmp" |
||||
) |
||||
|
||||
// Dial connects to a server in reading mode.
|
||||
func Dial(address string) (*Conn, error) { |
||||
rconn, nconn, err := rtmp.NewClient().Dial(address, rtmp.PrepareReading) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return NewConn(rconn, nconn), nil |
||||
} |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
package rtmputils |
||||
|
||||
import ( |
||||
"time" |
||||
|
||||
"github.com/notedit/rtmp/av" |
||||
rh264 "github.com/notedit/rtmp/codec/h264" |
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/h264" |
||||
) |
||||
|
||||
// WriteH264Config writes a H264 config.
|
||||
func (c *Conn) WriteH264Config(sps []byte, pps []byte) error { |
||||
codec := rh264.Codec{ |
||||
SPS: map[int][]byte{ |
||||
0: sps, |
||||
}, |
||||
PPS: map[int][]byte{ |
||||
0: pps, |
||||
}, |
||||
} |
||||
b := make([]byte, 128) |
||||
var n int |
||||
codec.ToConfig(b, &n) |
||||
b = b[:n] |
||||
|
||||
return c.WritePacket(av.Packet{ |
||||
Type: av.H264DecoderConfig, |
||||
Data: b, |
||||
}) |
||||
} |
||||
|
||||
// WriteH264 writes H264 NALUs.
|
||||
func (c *Conn) WriteH264(nalus [][]byte, dts time.Duration) error { |
||||
data, err := h264.EncodeAVCC(nalus) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
return c.WritePacket(av.Packet{ |
||||
Type: av.H264, |
||||
Data: data, |
||||
Time: dts, |
||||
}) |
||||
} |
Loading…
Reference in new issue