Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kill.sh
build.sh
launch.sh
go/
www/
logs/
low-latency-preview
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.11.10
WORKDIR $GOPATH/src/app
COPY . .
RUN mkdir -p www logs
RUN go get -d -v ./...
RUN go install -v ./...
EXPOSE 8080
CMD ["app", "'./www'"]

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

17 changes: 0 additions & 17 deletions buildEncoderAndServerUbuntu.sh → build.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/bin/bash

# install go repo

sudo add-apt-repository -y ppa:longsleep/golang-backports

# update the OS

sudo apt-get -y update

sudo apt-get -y upgrade

sudo apt-get -y install git

rm -r -f *zip*
Expand All @@ -19,15 +11,6 @@ rm -r -f *tar*
wget -O- https://dl.google.com/go/go1.11.1.linux-amd64.tar.gz | tar xz

go/bin/go get -d -v .

go/bin/go build

go/bin/go get -d -v .

go/bin/go build

mkdir -p www logs

mkdir -p ffmpeg
wget -O- "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz" | tar xJ -C ffmpeg --strip-components 1

46 changes: 0 additions & 46 deletions buildEncoderAndServerMacOS.sh

This file was deleted.

12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module streamline

go 1.15

require (
github.com/gorilla/mux v1.8.0
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect
github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/rs/cors v1.7.0
)
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a h1:FaWFmfWdAUKbSCtOU2QjDaorUexogfaMgbipgYATUMU=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e h1:FdDd7bdI6cjq5vaoYlK1mfQYfF9sF2VZw8VEZMsl5t8=
github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U=
github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8 changes: 4 additions & 4 deletions handlers/dashplayhandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/url"
"path"

"github.com/streamlinevideo/low-latency-preview/utils"
"streamline/utils"
)

type DashPlayHandler struct {
Expand All @@ -25,10 +25,10 @@ func (l *DashPlayHandler) servePlayer(w http.ResponseWriter, req *http.Request)
if req.URL.EscapedPath() == "/" {
curFileURL = "/localhost/manifest.mpd"
} else {
curFileURL = req.URL.EscapedPath()[len("/ldashplay"):]
curFileURL = req.URL.EscapedPath()[len("/dashplay"):]
}

curFilePath := path.Join("ldash", curFileURL)
curFilePath := path.Join("dash", curFileURL)
base, _ := url.Parse("http://" + req.Host)
relativeUrl, _ := url.Parse(curFilePath)
manifestUrl := base.ResolveReference(relativeUrl).String()
Expand Down Expand Up @@ -613,7 +613,7 @@ func (l *DashPlayHandler) servePlayer(w http.ResponseWriter, req *http.Request)
<div>
<video id="player" controls style="width=640px;height:360px"></video>
<div>
<span id="wallclock" style="font-family: Arial, Helvetica, sans-serif; color:white;background:black;width:270px;font-size:xx-large;z-index: 10;position: absolute;top:125px;left:25px"></span>
<span id="wallclock" style="font-family: Arial, Helvetica, sans-serif; color:white;background:black;width:120px;font-size:small;z-index: 10;position: absolute;top:125px;left:25px"></span>

</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"path"
"time"

"github.com/streamlinevideo/low-latency-preview/utils"
"streamline/utils"
)

// UploadHandler handles for http delete
type FileDeleteHandler struct {
type FileDashDeleteHandler struct {
BaseDir string
}

func (d *FileDeleteHandler) isFileUploadingDone(file string) bool {
func (d *FileDashDeleteHandler) isFileUploadingDone(file string) bool {
symlink := file + ".symlink"
if _, err := os.Stat(symlink); err == nil {
// exist, then segment uploading is not finished yet
Expand All @@ -24,14 +24,14 @@ func (d *FileDeleteHandler) isFileUploadingDone(file string) bool {
return true
}

func (d *FileDeleteHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (d *FileDashDeleteHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
utils.GetUploadLogger().Infof("Received upload request\n")
curFileURL := req.URL.EscapedPath()[len("/ldash"):]
curFileURL := req.URL.EscapedPath()[len("/dash"):]
curFilePath := path.Join(d.BaseDir, curFileURL)
d.serveHTTPImpl(curFilePath, w, req)
}

func (d *FileDeleteHandler) serveHTTPImpl(curFilePath string, w http.ResponseWriter, req *http.Request) {
func (d *FileDashDeleteHandler) serveHTTPImpl(curFilePath string, w http.ResponseWriter, req *http.Request) {
// check file existing
if _, err := os.Stat(curFilePath); err != nil {
utils.GetDeleteLogger().Debugf("file %s not exists \n", curFilePath)
Expand Down
52 changes: 52 additions & 0 deletions handlers/filedeletehandlerhls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package handlers

import (
"net/http"
"os"
"path"
"time"

"streamline/utils"
)

// UploadHandler handles for http delete
type FileHLSDeleteHandler struct {
BaseDir string
}

func (d *FileHLSDeleteHandler) isFileUploadingDone(file string) bool {
symlink := file + ".symlink"
if _, err := os.Stat(symlink); err == nil {
// exist, then segment uploading is not finished yet
return false
}
// not exist
return true
}

func (d *FileHLSDeleteHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
utils.GetUploadLogger().Infof("Received upload request\n")
curFileURL := req.URL.EscapedPath()[len("/hls"):]
curFilePath := path.Join(d.BaseDir, curFileURL)
d.serveHTTPImpl(curFilePath, w, req)
}

func (d *FileHLSDeleteHandler) serveHTTPImpl(curFilePath string, w http.ResponseWriter, req *http.Request) {
// check file existing
if _, err := os.Stat(curFilePath); err != nil {
utils.GetDeleteLogger().Debugf("file %s not exists \n", curFilePath)
return
}

is_chunk_uploading_done := d.isFileUploadingDone(curFilePath)
if !is_chunk_uploading_done { // chunk uploading is not done yet
return
}

if err := os.Remove(curFilePath); err != nil {
utils.GetDeleteLogger().Errorf("Failed to delete file %s with %v \n", curFilePath, err)
return
}

utils.GetDeleteLogger().Debugf("file %s was deleted exists @ %v \n", curFilePath, time.Now().Format(time.RFC3339))
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import (
"strings"
"time"

"github.com/streamlinevideo/low-latency-preview/utils"
"streamline/utils"
)

type FileDownloadHandler struct {
type FileDashDownloadHandler struct {
StartTime time.Time
BaseDir string
}

func (l *FileDownloadHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (l *FileDashDownloadHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
utils.GetDownloadLogger().Infof("Received download request\n")
l.serveDownload(w, req)
}

func (l *FileDownloadHandler) getSourcePath(req *http.Request) string {
func (l *FileDashDownloadHandler) getSourcePath(req *http.Request) string {
return l.BaseDir
}

func (l *FileDownloadHandler) isFileUploadingDone(file string) bool {
func (l *FileDashDownloadHandler) isFileUploadingDone(file string) bool {
symlink := file + ".symlink"
if _, err := os.Stat(symlink); err == nil {
// exist, then segment uploading is not finished yet
Expand All @@ -35,8 +35,8 @@ func (l *FileDownloadHandler) isFileUploadingDone(file string) bool {
return true
}

func (l *FileDownloadHandler) serveDownload(w http.ResponseWriter, req *http.Request) {
curFileURL := req.URL.EscapedPath()[len("/ldash"):]
func (l *FileDashDownloadHandler) serveDownload(w http.ResponseWriter, req *http.Request) {
curFileURL := req.URL.EscapedPath()[len("/dash"):]
curFilePath := path.Join(l.getSourcePath(req), curFileURL)
file, err := os.Open(curFilePath) // For read access.
if err != nil {
Expand Down
Loading