From a036f46453fbff2a725d26e57fd6f07c7bca8f96 Mon Sep 17 00:00:00 2001 From: aggresss Date: Mon, 29 Oct 2018 19:43:46 +0800 Subject: [PATCH] modify pkg management method --- .gitignore | 1 + Gopkg.lock | 53 +++++++++++++++++++++++++ Gopkg.toml | 42 ++++++++++++++++++++ container/flv/demuxer.go | 3 +- container/flv/muxer.go | 17 ++++---- container/flv/tag.go | 3 +- container/ts/muxer.go | 7 ++-- container/ts/muxer_test.go | 34 ++++++++-------- livego.go | 11 ++--- parser/aac/parser.go | 3 +- parser/h264/parser_test.go | 9 +++-- parser/parser.go | 9 +++-- protocol/hls/hls.go | 6 ++- protocol/hls/source.go | 15 +++---- protocol/httpflv/server.go | 9 +++-- protocol/httpflv/writer.go | 11 ++--- protocol/httpopera/http_opera.go | 9 +++-- protocol/rtmp/cache/cache.go | 3 +- protocol/rtmp/cache/gop.go | 3 +- protocol/rtmp/cache/special.go | 4 +- protocol/rtmp/core/chunk_stream.go | 8 ++-- protocol/rtmp/core/chunk_stream_test.go | 3 +- protocol/rtmp/core/conn.go | 7 ++-- protocol/rtmp/core/conn_client.go | 6 +-- protocol/rtmp/core/conn_server.go | 6 +-- protocol/rtmp/core/conn_test.go | 6 ++- protocol/rtmp/core/handshake.go | 9 ++--- protocol/rtmp/rtmp.go | 15 +++---- protocol/rtmp/rtmprelay/rtmprelay.go | 5 ++- protocol/rtmp/rtmprelay/staticrelay.go | 7 ++-- protocol/rtmp/stream.go | 10 +++-- utils/queue/queue.go | 3 +- utils/uid/uuid.go | 3 +- 33 files changed, 232 insertions(+), 108 deletions(-) create mode 100644 Gopkg.lock create mode 100644 Gopkg.toml diff --git a/.gitignore b/.gitignore index 4e89af2..487dd0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # Created by .ignore support plugin (hsz.mobi) .idea dist +vendor/ diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000..f4792ff --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,53 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" + name = "github.com/davecgh/go-spew" + packages = ["spew"] + pruneopts = "UT" + revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" + version = "v1.1.1" + +[[projects]] + branch = "master" + digest = "1:f7aa53146bf79462509d4ce136826ebbd64907e4679e1b04e62758da6b68e589" + name = "github.com/orcaman/concurrent-map" + packages = ["."] + pruneopts = "UT" + revision = "b28018939af9022337862b94a463abb18abb3e0e" + +[[projects]] + digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" + name = "github.com/pmezard/go-difflib" + packages = ["difflib"] + pruneopts = "UT" + revision = "792786c7400a136282c1664665ae0a8db921c6c2" + version = "v1.0.0" + +[[projects]] + digest = "1:274f67cb6fed9588ea2521ecdac05a6d62a8c51c074c1fccc6a49a40ba80e925" + name = "github.com/satori/go.uuid" + packages = ["."] + pruneopts = "UT" + revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3" + version = "v1.2.0" + +[[projects]] + digest = "1:18752d0b95816a1b777505a97f71c7467a8445b8ffb55631a7bf779f6ba4fa83" + name = "github.com/stretchr/testify" + packages = ["assert"] + pruneopts = "UT" + revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" + version = "v1.2.2" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + input-imports = [ + "github.com/orcaman/concurrent-map", + "github.com/satori/go.uuid", + "github.com/stretchr/testify/assert", + ] + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..4e11037 --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,42 @@ +# Gopkg.toml example +# +# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" +# +# [prune] +# non-go = false +# go-tests = true +# unused-packages = true + + +[[constraint]] + branch = "master" + name = "github.com/orcaman/concurrent-map" + +[[constraint]] + name = "github.com/satori/go.uuid" + version = "1.2.0" + +[[constraint]] + name = "github.com/stretchr/testify" + version = "1.2.2" + +[prune] + go-tests = true + unused-packages = true diff --git a/container/flv/demuxer.go b/container/flv/demuxer.go index 9843978..bfcc784 100755 --- a/container/flv/demuxer.go +++ b/container/flv/demuxer.go @@ -2,7 +2,8 @@ package flv import ( "errors" - "github.com/gwuhaolin/livego/av" + + "livego/av" ) var ( diff --git a/container/flv/muxer.go b/container/flv/muxer.go index 452145c..2b8950d 100755 --- a/container/flv/muxer.go +++ b/container/flv/muxer.go @@ -1,15 +1,16 @@ package flv import ( - "strings" - "time" "flag" - "os" "log" - "github.com/gwuhaolin/livego/utils/uid" - "github.com/gwuhaolin/livego/protocol/amf" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/utils/pio" + "os" + "strings" + "time" + + "livego/av" + "livego/protocol/amf" + "livego/utils/pio" + "livego/utils/uid" ) var ( @@ -45,7 +46,7 @@ const ( ) type FLVWriter struct { - Uid string + Uid string av.RWBaser app, title, url string buf []byte diff --git a/container/flv/tag.go b/container/flv/tag.go index 550efaa..d2aec4f 100755 --- a/container/flv/tag.go +++ b/container/flv/tag.go @@ -2,7 +2,8 @@ package flv import ( "fmt" - "github.com/gwuhaolin/livego/av" + + "livego/av" ) type flvTag struct { diff --git a/container/ts/muxer.go b/container/ts/muxer.go index 1731a58..8f7ad3d 100755 --- a/container/ts/muxer.go +++ b/container/ts/muxer.go @@ -2,7 +2,8 @@ package ts import ( "io" - "github.com/gwuhaolin/livego/av" + + "livego/av" ) const ( @@ -207,7 +208,7 @@ func (muxer *Muxer) PMT(soundFormat byte, hasVideo bool) []byte { progInfo = []byte{0x0f, 0xe1, 0x01, 0xf0, 0x00} } else { progInfo = []byte{0x1b, 0xe1, 0x00, 0xf0, 0x00, //h264 or h265* - 0x0f, 0xe1, 0x01, 0xf0, 0x00, //mp3 or aac + 0x0f, 0xe1, 0x01, 0xf0, 0x00, //mp3 or aac } } pmtHeader[2] = byte(len(progInfo) + 9 + 4) @@ -236,7 +237,7 @@ func (muxer *Muxer) PMT(soundFormat byte, hasVideo bool) []byte { copy(muxer.pmt[i:], progInfo[0:]) i += len(progInfo) - crc32Value := GenCrc32(muxer.pmt[5: 5+len(pmtHeader)+len(progInfo)]) + crc32Value := GenCrc32(muxer.pmt[5 : 5+len(pmtHeader)+len(progInfo)]) muxer.pmt[i] = byte(crc32Value >> 24) i++ muxer.pmt[i] = byte(crc32Value >> 16) diff --git a/container/ts/muxer_test.go b/container/ts/muxer_test.go index 9d46f49..5ee3cf3 100755 --- a/container/ts/muxer_test.go +++ b/container/ts/muxer_test.go @@ -2,7 +2,9 @@ package ts import ( "testing" - "github.com/gwuhaolin/livego/av" + + "livego/av" + "github.com/stretchr/testify/assert" ) @@ -24,8 +26,8 @@ func TestTSEncoder(t *testing.T) { w := &TestWriter{} data := []byte{0xaf, 0x01, 0x21, 0x19, 0xd3, 0x40, 0x7d, 0x0b, 0x6d, 0x44, 0xae, 0x81, - 0x08, 0x00, 0x89, 0xa0, 0x3e, 0x85, 0xb6, 0x92, 0x57, 0x04, 0x80, 0x00, 0x5b, 0xb7, - 0x78, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x30, 0x00, 0x06, 0x00, 0x38, + 0x08, 0x00, 0x89, 0xa0, 0x3e, 0x85, 0xb6, 0x92, 0x57, 0x04, 0x80, 0x00, 0x5b, 0xb7, + 0x78, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x30, 0x00, 0x06, 0x00, 0x38, } p := av.Packet{ IsVideo: false, @@ -35,17 +37,17 @@ func TestTSEncoder(t *testing.T) { at.Equal(err, nil) at.Equal(w.count, 1) at.Equal(w.buf, []byte{0x47, 0x41, 0x01, 0x31, 0x81, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x30, - 0x80, 0x80, 0x05, 0x21, 0x00, 0x01, 0x00, 0x01, 0xaf, 0x01, 0x21, 0x19, 0xd3, 0x40, 0x7d, - 0x0b, 0x6d, 0x44, 0xae, 0x81, 0x08, 0x00, 0x89, 0xa0, 0x3e, 0x85, 0xb6, 0x92, 0x57, 0x04, - 0x80, 0x00, 0x5b, 0xb7, 0x78, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x30, 0x00, - 0x06, 0x00, 0x38}) + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x30, + 0x80, 0x80, 0x05, 0x21, 0x00, 0x01, 0x00, 0x01, 0xaf, 0x01, 0x21, 0x19, 0xd3, 0x40, 0x7d, + 0x0b, 0x6d, 0x44, 0xae, 0x81, 0x08, 0x00, 0x89, 0xa0, 0x3e, 0x85, 0xb6, 0x92, 0x57, 0x04, + 0x80, 0x00, 0x5b, 0xb7, 0x78, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x30, 0x00, + 0x06, 0x00, 0x38}) } diff --git a/livego.go b/livego.go index a6e2976..559aeaf 100755 --- a/livego.go +++ b/livego.go @@ -2,14 +2,15 @@ package main import ( "flag" - "github.com/gwuhaolin/livego/configure" - "github.com/gwuhaolin/livego/protocol/hls" - "github.com/gwuhaolin/livego/protocol/httpflv" - "github.com/gwuhaolin/livego/protocol/httpopera" - "github.com/gwuhaolin/livego/protocol/rtmp" "log" "net" "time" + + "livego/configure" + "livego/protocol/hls" + "livego/protocol/httpflv" + "livego/protocol/httpopera" + "livego/protocol/rtmp" ) var ( diff --git a/parser/aac/parser.go b/parser/aac/parser.go index 35ffe78..7ad9f05 100755 --- a/parser/aac/parser.go +++ b/parser/aac/parser.go @@ -3,7 +3,8 @@ package aac import ( "errors" "io" - "github.com/gwuhaolin/livego/av" + + "livego/av" ) type mpegExtension struct { diff --git a/parser/h264/parser_test.go b/parser/h264/parser_test.go index 4773168..40d43e4 100755 --- a/parser/h264/parser_test.go +++ b/parser/h264/parser_test.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "testing" + "github.com/stretchr/testify/assert" ) @@ -20,8 +21,8 @@ func TestH264SeqDemux(t *testing.T) { err := d.Parse(seq, true, w) at.Equal(err, nil) at.Equal(d.specificInfo, []byte{0x00, 0x00, 0x00, 0x01, 0x67, 0x4d, 0x00, - 0x1e, 0xab, 0x40, 0x5a, 0x12, 0x6c, 0x09, 0x28, 0x28, 0x28, 0x2f, - 0x80, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x61, 0xa8, 0x4a, 0x00, 0x00, 0x00, 0x01, 0x68, 0xde, 0x31, 0x12}) + 0x1e, 0xab, 0x40, 0x5a, 0x12, 0x6c, 0x09, 0x28, 0x28, 0x28, 0x2f, + 0x80, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x61, 0xa8, 0x4a, 0x00, 0x00, 0x00, 0x01, 0x68, 0xde, 0x31, 0x12}) } func TestH264AnnexbDemux(t *testing.T) { @@ -62,8 +63,8 @@ func TestH264Mp4Demux(t *testing.T) { at.Equal(err, nil) at.Equal(w.Len(), 47) at.Equal(w.Bytes(), []byte{0x00, 0x00, 0x00, 0x01, 0x09, 0xf0, 0x00, 0x00, 0x00, 0x01, 0x67, 0x4d, 0x00, 0x1e, 0xab, 0x40, 0x5a, 0x12, 0x6c, 0x09, 0x28, 0x28, - 0x28, 0x2f, 0x80, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x61, 0xa8, 0x4a, 0x00, 0x00, 0x00, 0x01, 0x68, - 0xde, 0x31, 0x12, 0x00, 0x00, 0x00, 0x01, 0x65, 0x23}) + 0x28, 0x2f, 0x80, 0x00, 0x01, 0xf4, 0x00, 0x00, 0x61, 0xa8, 0x4a, 0x00, 0x00, 0x00, 0x01, 0x68, + 0xde, 0x31, 0x12, 0x00, 0x00, 0x00, 0x01, 0x65, 0x23}) } func TestH264Mp4DemuxException1(t *testing.T) { diff --git a/parser/parser.go b/parser/parser.go index ba1b115..31bdd4f 100755 --- a/parser/parser.go +++ b/parser/parser.go @@ -3,10 +3,11 @@ package parser import ( "errors" "io" - "github.com/gwuhaolin/livego/parser/mp3" - "github.com/gwuhaolin/livego/parser/aac" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/parser/h264" + + "livego/av" + "livego/parser/aac" + "livego/parser/h264" + "livego/parser/mp3" ) var ( diff --git a/protocol/hls/hls.go b/protocol/hls/hls.go index f10eecb..f120e55 100755 --- a/protocol/hls/hls.go +++ b/protocol/hls/hls.go @@ -3,14 +3,16 @@ package hls import ( "errors" "fmt" + "log" "net" "net/http" "path" "strconv" "strings" "time" - "log" - "github.com/gwuhaolin/livego/av" + + "livego/av" + "github.com/orcaman/concurrent-map" ) diff --git a/protocol/hls/source.go b/protocol/hls/source.go index a1fb670..60f4f83 100644 --- a/protocol/hls/source.go +++ b/protocol/hls/source.go @@ -1,15 +1,16 @@ package hls import ( - "fmt" - "time" "bytes" - "log" "errors" - "github.com/gwuhaolin/livego/parser" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/container/flv" - "github.com/gwuhaolin/livego/container/ts" + "fmt" + "log" + "time" + + "livego/av" + "livego/container/flv" + "livego/container/ts" + "livego/parser" ) const ( diff --git a/protocol/httpflv/server.go b/protocol/httpflv/server.go index a4af13a..1694a67 100644 --- a/protocol/httpflv/server.go +++ b/protocol/httpflv/server.go @@ -2,12 +2,13 @@ package httpflv import ( "encoding/json" - "strings" + "log" "net" "net/http" - "log" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/protocol/rtmp" + "strings" + + "livego/av" + "livego/protocol/rtmp" ) type Server struct { diff --git a/protocol/httpflv/writer.go b/protocol/httpflv/writer.go index 353f964..e97e600 100755 --- a/protocol/httpflv/writer.go +++ b/protocol/httpflv/writer.go @@ -1,15 +1,16 @@ package httpflv import ( - "time" "errors" "fmt" "log" "net/http" - "github.com/gwuhaolin/livego/utils/uid" - "github.com/gwuhaolin/livego/protocol/amf" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/utils/pio" + "time" + + "livego/av" + "livego/protocol/amf" + "livego/utils/pio" + "livego/utils/uid" ) const ( diff --git a/protocol/httpopera/http_opera.go b/protocol/httpopera/http_opera.go index 294359e..378e7d0 100755 --- a/protocol/httpopera/http_opera.go +++ b/protocol/httpopera/http_opera.go @@ -3,13 +3,14 @@ package httpopera import ( "encoding/json" "fmt" - "github.com/gwuhaolin/livego/protocol/rtmp/rtmprelay" "io" + "log" "net" "net/http" - "log" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/protocol/rtmp" + + "livego/av" + "livego/protocol/rtmp" + "livego/protocol/rtmp/rtmprelay" ) type Response struct { diff --git a/protocol/rtmp/cache/cache.go b/protocol/rtmp/cache/cache.go index 1dd25cd..b644e94 100755 --- a/protocol/rtmp/cache/cache.go +++ b/protocol/rtmp/cache/cache.go @@ -2,7 +2,8 @@ package cache import ( "flag" - "github.com/gwuhaolin/livego/av" + + "livego/av" ) var ( diff --git a/protocol/rtmp/cache/gop.go b/protocol/rtmp/cache/gop.go index 1c1a1d0..401bab0 100755 --- a/protocol/rtmp/cache/gop.go +++ b/protocol/rtmp/cache/gop.go @@ -2,7 +2,8 @@ package cache import ( "errors" - "github.com/gwuhaolin/livego/av" + + "livego/av" ) var ( diff --git a/protocol/rtmp/cache/special.go b/protocol/rtmp/cache/special.go index b8aefbc..dce82a3 100755 --- a/protocol/rtmp/cache/special.go +++ b/protocol/rtmp/cache/special.go @@ -4,8 +4,8 @@ import ( "bytes" "log" - "github.com/gwuhaolin/livego/protocol/amf" - "github.com/gwuhaolin/livego/av" + "livego/av" + "livego/protocol/amf" ) const ( diff --git a/protocol/rtmp/core/chunk_stream.go b/protocol/rtmp/core/chunk_stream.go index fab2e6b..379646b 100755 --- a/protocol/rtmp/core/chunk_stream.go +++ b/protocol/rtmp/core/chunk_stream.go @@ -4,8 +4,8 @@ import ( "encoding/binary" "fmt" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/utils/pool" + "livego/av" + "livego/utils/pool" ) type ChunkStream struct { @@ -73,7 +73,7 @@ func (chunkStream *ChunkStream) writeHeader(w *ReadWriter) error { } w.WriteUintLE(chunkStream.StreamID, 4) END: -//Extended Timestamp + //Extended Timestamp if ts >= 0xffffff { w.WriteUintBE(chunkStream.Timestamp, 4) } @@ -211,7 +211,7 @@ func (chunkStream *ChunkStream) readChunk(r *ReadWriter, chunkSize uint32, pool size = int(chunkSize) } - buf := chunkStream.Data[chunkStream.index: chunkStream.index+uint32(size)] + buf := chunkStream.Data[chunkStream.index : chunkStream.index+uint32(size)] if _, err := r.Read(buf); err != nil { return err } diff --git a/protocol/rtmp/core/chunk_stream_test.go b/protocol/rtmp/core/chunk_stream_test.go index d351dac..94cd05a 100755 --- a/protocol/rtmp/core/chunk_stream_test.go +++ b/protocol/rtmp/core/chunk_stream_test.go @@ -4,8 +4,9 @@ import ( "bytes" "testing" + "livego/utils/pool" + "github.com/stretchr/testify/assert" - "github.com/gwuhaolin/livego/utils/pool" ) func TestChunkRead1(t *testing.T) { diff --git a/protocol/rtmp/core/conn.go b/protocol/rtmp/core/conn.go index 8d6d3cc..2e563a9 100755 --- a/protocol/rtmp/core/conn.go +++ b/protocol/rtmp/core/conn.go @@ -4,12 +4,13 @@ import ( "encoding/binary" "net" "time" - "github.com/gwuhaolin/livego/utils/pool" - "github.com/gwuhaolin/livego/utils/pio" + + "livego/utils/pio" + "livego/utils/pool" ) const ( - _ = iota + _ = iota idSetChunkSize idAbortMessage idAck diff --git a/protocol/rtmp/core/conn_client.go b/protocol/rtmp/core/conn_client.go index 987a72f..7806c56 100755 --- a/protocol/rtmp/core/conn_client.go +++ b/protocol/rtmp/core/conn_client.go @@ -5,14 +5,14 @@ import ( "errors" "fmt" "io" + "log" "math/rand" "net" neturl "net/url" "strings" - "github.com/gwuhaolin/livego/protocol/amf" - "github.com/gwuhaolin/livego/av" - "log" + "livego/av" + "livego/protocol/amf" ) var ( diff --git a/protocol/rtmp/core/conn_server.go b/protocol/rtmp/core/conn_server.go index e85b7d8..ca9de74 100755 --- a/protocol/rtmp/core/conn_server.go +++ b/protocol/rtmp/core/conn_server.go @@ -4,10 +4,10 @@ import ( "bytes" "errors" "io" - - "github.com/gwuhaolin/livego/protocol/amf" - "github.com/gwuhaolin/livego/av" "log" + + "livego/av" + "livego/protocol/amf" ) var ( diff --git a/protocol/rtmp/core/conn_test.go b/protocol/rtmp/core/conn_test.go index b3ff97b..1f4cb9b 100755 --- a/protocol/rtmp/core/conn_test.go +++ b/protocol/rtmp/core/conn_test.go @@ -4,8 +4,10 @@ import ( "bytes" "io" "testing" + + "livego/utils/pool" + "github.com/stretchr/testify/assert" - "github.com/gwuhaolin/livego/utils/pool" ) func TestConnReadNormal(t *testing.T) { @@ -176,7 +178,7 @@ func TestSetChunksize(t *testing.T) { //设置chunksize chunkBuf := []byte{0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x96} + 0x00, 0x00, 0x00, 0x96} conn.rw = NewReadWriter(bytes.NewBuffer(chunkBuf), 1024) err = conn.Read(&c) at.Equal(err, nil) diff --git a/protocol/rtmp/core/handshake.go b/protocol/rtmp/core/handshake.go index 4e22ea7..f563b9f 100755 --- a/protocol/rtmp/core/handshake.go +++ b/protocol/rtmp/core/handshake.go @@ -7,10 +7,9 @@ import ( "crypto/sha256" "fmt" "io" - "time" - "github.com/gwuhaolin/livego/utils/pio" + "livego/utils/pio" ) var ( @@ -124,7 +123,7 @@ func (conn *Conn) HandshakeClient() (err error) { return } - S1 := S0S1S2[1: 1536+1] + S1 := S0S1S2[1 : 1536+1] if ver := pio.U32BE(S1[4:8]); ver != 0 { C2 = S1 } else { @@ -145,13 +144,13 @@ func (conn *Conn) HandshakeServer() (err error) { C0C1C2 := random[:1536*2+1] C0 := C0C1C2[:1] - C1 := C0C1C2[1: 1536+1] + C1 := C0C1C2[1 : 1536+1] C0C1 := C0C1C2[:1536+1] C2 := C0C1C2[1536+1:] S0S1S2 := random[1536*2+1:] S0 := S0S1S2[:1] - S1 := S0S1S2[1: 1536+1] + S1 := S0S1S2[1 : 1536+1] S0S1 := S0S1S2[:1536+1] S2 := S0S1S2[1536+1:] diff --git a/protocol/rtmp/rtmp.go b/protocol/rtmp/rtmp.go index 1a76017..a5c7a66 100755 --- a/protocol/rtmp/rtmp.go +++ b/protocol/rtmp/rtmp.go @@ -4,17 +4,18 @@ import ( "errors" "flag" "fmt" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/configure" - "github.com/gwuhaolin/livego/container/flv" - "github.com/gwuhaolin/livego/protocol/rtmp/core" - "github.com/gwuhaolin/livego/utils/uid" "log" "net" "net/url" "reflect" "strings" "time" + + "livego/av" + "livego/configure" + "livego/container/flv" + "livego/protocol/rtmp/core" + "livego/utils/uid" ) const ( @@ -284,7 +285,7 @@ func (v *VirWriter) Write(p *av.Packet) (err error) { } func (v *VirWriter) SendPacket() error { - Flush := reflect.ValueOf(v.conn).MethodByName("Flush"); + Flush := reflect.ValueOf(v.conn).MethodByName("Flush") var cs core.ChunkStream for { p, ok := <-v.packetQueue @@ -313,7 +314,7 @@ func (v *VirWriter) SendPacket() error { v.closed = true return err } - Flush.Call(nil); + Flush.Call(nil) } else { return errors.New("closed") } diff --git a/protocol/rtmp/rtmprelay/rtmprelay.go b/protocol/rtmp/rtmprelay/rtmprelay.go index 1bcae28..5434b0e 100644 --- a/protocol/rtmp/rtmprelay/rtmprelay.go +++ b/protocol/rtmp/rtmprelay/rtmprelay.go @@ -4,10 +4,11 @@ import ( "bytes" "errors" "fmt" - "github.com/gwuhaolin/livego/protocol/amf" - "github.com/gwuhaolin/livego/protocol/rtmp/core" "io" "log" + + "livego/protocol/amf" + "livego/protocol/rtmp/core" ) var ( diff --git a/protocol/rtmp/rtmprelay/staticrelay.go b/protocol/rtmp/rtmprelay/staticrelay.go index ab90b43..d5ac017 100644 --- a/protocol/rtmp/rtmprelay/staticrelay.go +++ b/protocol/rtmp/rtmprelay/staticrelay.go @@ -3,11 +3,12 @@ package rtmprelay import ( "errors" "fmt" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/configure" - "github.com/gwuhaolin/livego/protocol/rtmp/core" "log" "sync" + + "livego/av" + "livego/configure" + "livego/protocol/rtmp/core" ) type StaticPush struct { diff --git a/protocol/rtmp/stream.go b/protocol/rtmp/stream.go index 5780536..c92c2da 100755 --- a/protocol/rtmp/stream.go +++ b/protocol/rtmp/stream.go @@ -2,13 +2,15 @@ package rtmp import ( "errors" - "github.com/gwuhaolin/livego/av" - "github.com/gwuhaolin/livego/protocol/rtmp/cache" - "github.com/gwuhaolin/livego/protocol/rtmp/rtmprelay" - "github.com/orcaman/concurrent-map" "log" "strings" "time" + + "livego/av" + "livego/protocol/rtmp/cache" + "livego/protocol/rtmp/rtmprelay" + + "github.com/orcaman/concurrent-map" ) var ( diff --git a/utils/queue/queue.go b/utils/queue/queue.go index e601133..03e4b6f 100755 --- a/utils/queue/queue.go +++ b/utils/queue/queue.go @@ -2,7 +2,8 @@ package queue import ( "sync" - "github.com/gwuhaolin/livego/av" + + "livego/av" ) // Queue is a basic FIFO queue for Messages. diff --git a/utils/uid/uuid.go b/utils/uid/uuid.go index 7593aba..e211ccb 100644 --- a/utils/uid/uuid.go +++ b/utils/uid/uuid.go @@ -2,11 +2,12 @@ package uid import ( "encoding/base64" + "github.com/satori/go.uuid" ) func NewId() string { - id, _ := uuid.NewV4() + id := uuid.NewV4() b64 := base64.URLEncoding.EncodeToString(id.Bytes()[:12]) return b64 }