mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-18 17:16:04 +00:00
* Introduce Makefile and go vendor directory for faster build * WIP: Refactor cloud-game codebase with spliting overlord and worker binary * Fix all issues and have a running build * Complete first version of refactor
43 lines
653 B
Go
43 lines
653 B
Go
// credit to https://github.com/poi5305/go-yuv2webRTC/blob/master/webrtc/webrtc.go
|
|
package webrtc
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func zip(in []byte) []byte {
|
|
var b bytes.Buffer
|
|
gz := gzip.NewWriter(&b)
|
|
_, err := gz.Write(in)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
err = gz.Flush()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
err = gz.Close()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return b.Bytes()
|
|
}
|
|
|
|
func unzip(in []byte) []byte {
|
|
var b bytes.Buffer
|
|
_, err := b.Write(in)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
r, err := gzip.NewReader(&b)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
res, err := ioutil.ReadAll(r)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return res
|
|
}
|