Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
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...")
}