1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-29 22:41:06 +02:00

Start telnet connection to send ASCII Art stream

This commit is contained in:
Yohann D'ANELLO
2020-10-12 23:39:26 +02:00
parent b675023804
commit e640450d98
2 changed files with 70 additions and 26 deletions

View File

@ -3,7 +3,7 @@ package webrtc
import (
"bufio"
"fmt"
"gitlab.crans.org/nounous/ghostream/stream/telnet"
"io"
"log"
"net"
@ -106,7 +106,7 @@ func ingestFrom(inputChannel chan srt.Packet) {
}()
// Receive ascii
go asciiArt(output, videoTracks[srtPacket.StreamName])
go telnet.ServeAsciiArt(output)
// Receive audio
go func() {
@ -165,27 +165,3 @@ func ingestFrom(inputChannel chan srt.Packet) {
}
}
}
func asciiChar(pixel byte) string {
asciiChars := []string{"@", "#", "$", "%", "?", "*", "+", ";", ":", ",", "."}
return asciiChars[pixel/25]
}
func asciiArt(reader io.Reader, videoTracks []*webrtc.Track) {
buff := make([]byte, 2048)
for {
n, _ := reader.Read(buff)
if n == 0 {
break
}
for j := 0; j < 18; j++ {
for i := 0; i < 32; i++ {
pixel := buff[32*j+i]
fmt.Print(asciiChar(pixel))
}
fmt.Println()
}
fmt.Println()
}
}