Help us shape the future of Go! Take the 2026 Go Developer Survey

rtsp2rtmp

package module
v0.0.0-...-2958aee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2017 License: MIT Imports: 14 Imported by: 0

README

rtsp2rtmp

rtsp stream to rtmp

How to use:

cd demo go build demo.go ./demo -rtspUrl "rtsp://admin:123456@10.1.51.13/H264?ch=1&subtype=0" -rtmpUrl "rtmp://10.1.51.20:1935/myapp/cv"

Documentation

Index

Constants

View Source
const (
	AUDIO_TAG       = byte(0x08)
	VIDEO_TAG       = byte(0x09)
	SCRIPT_DATA_TAG = byte(0x12)
	DURATION_OFFSET = 53
	HEADER_LEN      = 13
)

Variables

View Source
var (
	VideoWidth  int
	VideoHeight int
)

Functions

func GetMD5Hash

func GetMD5Hash(text string) string

func InitRtmpHandler

func InitRtmpHandler(handler *RtmpOutboundConnHandler, streamName string, rtmpUrl string, inFlvChan chan FlvChunk)

func ParseDirective

func ParseDirective(header, name string) string

func ParseMedia

func ParseMedia(header string) []string

func ParseSession

func ParseSession(header string) string

func StartPublish

func StartPublish(handler *RtmpOutboundConnHandler)

Types

type FlvChunk

type FlvChunk struct {
	TagType   byte
	DataSize  uint32
	Timestamp uint32

	NaluData []byte
}

type RtmpOutboundConnHandler

type RtmpOutboundConnHandler struct {
	RtmpPublisherCtx RtmpPublisherContext
	// contains filtered or unexported fields
}

func (*RtmpOutboundConnHandler) OnClosed

func (handler *RtmpOutboundConnHandler) OnClosed(conn rtmp.Conn)

func (*RtmpOutboundConnHandler) OnPlayStart

func (handler *RtmpOutboundConnHandler) OnPlayStart(stream rtmp.OutboundStream)

func (*RtmpOutboundConnHandler) OnPublishStart

func (handler *RtmpOutboundConnHandler) OnPublishStart(stream rtmp.OutboundStream)

func (*RtmpOutboundConnHandler) OnReceived

func (handler *RtmpOutboundConnHandler) OnReceived(conn rtmp.Conn, message *rtmp.Message)

func (*RtmpOutboundConnHandler) OnReceivedRtmpCommand

func (handler *RtmpOutboundConnHandler) OnReceivedRtmpCommand(conn rtmp.Conn, command *rtmp.Command)

func (*RtmpOutboundConnHandler) OnStatus

func (handler *RtmpOutboundConnHandler) OnStatus(conn rtmp.OutboundConn)

func (*RtmpOutboundConnHandler) OnStreamCreated

func (handler *RtmpOutboundConnHandler) OnStreamCreated(conn rtmp.OutboundConn, stream rtmp.OutboundStream)

type RtmpPublisherContext

type RtmpPublisherContext struct {
	// contains filtered or unexported fields
}

type RtspClient

type RtspClient struct {
	OutGoing chan []byte //out chanel
	Signals  chan bool   //Signals quit
	// contains filtered or unexported fields
}

func RtspClientNew

func RtspClientNew() *RtspClient

вернет пустой инициализированный обьект

func (*RtspClient) AuthBasic

func (this *RtspClient) AuthBasic(phase string, message string) bool

func (*RtspClient) AuthDigest

func (this *RtspClient) AuthDigest(phase string, message string) bool

func (*RtspClient) AuthDigest_Only

func (this *RtspClient) AuthDigest_Only(phase string, message string) string

func (*RtspClient) Client

func (this *RtspClient) Client(rtsp_url string) (bool, string)

основная функция работы с rtsp

func (*RtspClient) Close

func (this *RtspClient) Close()

func (*RtspClient) Connect

func (this *RtspClient) Connect() bool

func (*RtspClient) ParseMedia

func (this *RtspClient) ParseMedia(header string) []string

func (*RtspClient) ParseUrl

func (this *RtspClient) ParseUrl(rtsp_url string) bool

func (*RtspClient) Read

func (this *RtspClient) Read() (bool, string)

func (*RtspClient) RtspRtpLoop

func (this *RtspClient) RtspRtpLoop()
	The RTP header has the following format:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |V=2|P|X|  CC   |M|     PT      |       sequence number         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           timestamp                           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |           synchronization source (SSRC) identifier            |
   +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
   |            contributing source (CSRC) identifiers             |
   |                             ....                              |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   version (V): 2 bits
      This field identifies the version of RTP.  The version defined by
      this specification is two (2).  (The value 1 is used by the first
      draft version of RTP and the value 0 is used by the protocol
      initially implemented in the "vat" audio tool.)

   padding (P): 1 bit
      If the padding bit is set, the packet contains one or more
      additional padding octets at the end which are not part of the
      payload.  The last octet of the padding contains a count of how
      many padding octets should be ignored, including itself.  Padding
      may be needed by some encryption algorithms with fixed block sizes
      or for carrying several RTP packets in a lower-layer protocol data
      unit.

   extension (X): 1 bit
      If the extension bit is set, the fixed header MUST be followed by
      exactly one header extension, with a format defined in Section
      5.3.1.

func (*RtspClient) SendBufer

func (this *RtspClient) SendBufer(bufer []byte)

unsafe!

func (*RtspClient) Write

func (this *RtspClient) Write(message string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL