예제 #1
0
파일: processor.go 프로젝트: izacus/gortmpd
func dispatchPacket(channel chan<- webm.DispatchPacket, id uint64, length uint64, data []byte) {
	var packet webm.DispatchPacket
	packet.Id = id
	packet.Length = length
	packet.Data = data
	channel <- packet
}
예제 #2
0
파일: web.go 프로젝트: izacus/gortmpd
func clientHandler(w http.ResponseWriter, req *http.Request) {
	var packet webm.DispatchPacket

	// Return WebM header
	w.Header().Add("Content-Type", "video/webm")
	w.WriteHeader(http.StatusOK)

	// Write EBML intro
	ebmlHeader := *context.InputStream.GetEBMLHeader()
	packet.Id = 0xA45DFA3
	packet.Length = uint64(len(ebmlHeader))
	packet.Data = ebmlHeader
	w.Write(packet.GetByteRepresentation())

	// Prepare segment header
	packet.Id = 0x8538067
	packet.Length = 0xFFFFFFFFFFFFFFFF
	packet.Data = nil
	w.Write(packet.GetByteRepresentation())

	// Send stream info
	segmentInfo := *context.InputStream.GetStreamInfo()
	packet.Id = 0x549A966
	packet.Length = uint64(len(segmentInfo))
	packet.Data = segmentInfo
	w.Write(packet.GetByteRepresentation())

	// Send track info
	trackInfo := *context.InputStream.GetTrackInfo()
	packet.Id = 0x654AE6B
	packet.Length = uint64(len(trackInfo))
	packet.Data = trackInfo
	w.Write(packet.GetByteRepresentation())

	fmt.Println("Client connected, header written...")
}