Browse Source

modify pkg management method

pull/48/head
aggresss 7 years ago
parent
commit
a036f46453
  1. 1
      .gitignore
  2. 53
      Gopkg.lock
  3. 42
      Gopkg.toml
  4. 3
      container/flv/demuxer.go
  5. 15
      container/flv/muxer.go
  6. 3
      container/flv/tag.go
  7. 5
      container/ts/muxer.go
  8. 4
      container/ts/muxer_test.go
  9. 11
      livego.go
  10. 3
      parser/aac/parser.go
  11. 1
      parser/h264/parser_test.go
  12. 9
      parser/parser.go
  13. 6
      protocol/hls/hls.go
  14. 15
      protocol/hls/source.go
  15. 9
      protocol/httpflv/server.go
  16. 11
      protocol/httpflv/writer.go
  17. 9
      protocol/httpopera/http_opera.go
  18. 3
      protocol/rtmp/cache/cache.go
  19. 3
      protocol/rtmp/cache/gop.go
  20. 4
      protocol/rtmp/cache/special.go
  21. 8
      protocol/rtmp/core/chunk_stream.go
  22. 3
      protocol/rtmp/core/chunk_stream_test.go
  23. 5
      protocol/rtmp/core/conn.go
  24. 6
      protocol/rtmp/core/conn_client.go
  25. 6
      protocol/rtmp/core/conn_server.go
  26. 4
      protocol/rtmp/core/conn_test.go
  27. 9
      protocol/rtmp/core/handshake.go
  28. 15
      protocol/rtmp/rtmp.go
  29. 5
      protocol/rtmp/rtmprelay/rtmprelay.go
  30. 7
      protocol/rtmp/rtmprelay/staticrelay.go
  31. 10
      protocol/rtmp/stream.go
  32. 3
      utils/queue/queue.go
  33. 3
      utils/uid/uuid.go

1
.gitignore vendored

@ -1,3 +1,4 @@
# Created by .ignore support plugin (hsz.mobi) # Created by .ignore support plugin (hsz.mobi)
.idea .idea
dist dist
vendor/

53
Gopkg.lock generated

@ -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

42
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

3
container/flv/demuxer.go

@ -2,7 +2,8 @@ package flv
import ( import (
"errors" "errors"
"github.com/gwuhaolin/livego/av"
"livego/av"
) )
var ( var (

15
container/flv/muxer.go

@ -1,15 +1,16 @@
package flv package flv
import ( import (
"strings"
"time"
"flag" "flag"
"os"
"log" "log"
"github.com/gwuhaolin/livego/utils/uid" "os"
"github.com/gwuhaolin/livego/protocol/amf" "strings"
"github.com/gwuhaolin/livego/av" "time"
"github.com/gwuhaolin/livego/utils/pio"
"livego/av"
"livego/protocol/amf"
"livego/utils/pio"
"livego/utils/uid"
) )
var ( var (

3
container/flv/tag.go

@ -2,7 +2,8 @@ package flv
import ( import (
"fmt" "fmt"
"github.com/gwuhaolin/livego/av"
"livego/av"
) )
type flvTag struct { type flvTag struct {

5
container/ts/muxer.go

@ -2,7 +2,8 @@ package ts
import ( import (
"io" "io"
"github.com/gwuhaolin/livego/av"
"livego/av"
) )
const ( const (
@ -236,7 +237,7 @@ func (muxer *Muxer) PMT(soundFormat byte, hasVideo bool) []byte {
copy(muxer.pmt[i:], progInfo[0:]) copy(muxer.pmt[i:], progInfo[0:])
i += len(progInfo) 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) muxer.pmt[i] = byte(crc32Value >> 24)
i++ i++
muxer.pmt[i] = byte(crc32Value >> 16) muxer.pmt[i] = byte(crc32Value >> 16)

4
container/ts/muxer_test.go

@ -2,7 +2,9 @@ package ts
import ( import (
"testing" "testing"
"github.com/gwuhaolin/livego/av"
"livego/av"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

11
livego.go

@ -2,14 +2,15 @@ package main
import ( import (
"flag" "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" "log"
"net" "net"
"time" "time"
"livego/configure"
"livego/protocol/hls"
"livego/protocol/httpflv"
"livego/protocol/httpopera"
"livego/protocol/rtmp"
) )
var ( var (

3
parser/aac/parser.go

@ -3,7 +3,8 @@ package aac
import ( import (
"errors" "errors"
"io" "io"
"github.com/gwuhaolin/livego/av"
"livego/av"
) )
type mpegExtension struct { type mpegExtension struct {

1
parser/h264/parser_test.go

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"errors" "errors"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

9
parser/parser.go

@ -3,10 +3,11 @@ package parser
import ( import (
"errors" "errors"
"io" "io"
"github.com/gwuhaolin/livego/parser/mp3"
"github.com/gwuhaolin/livego/parser/aac" "livego/av"
"github.com/gwuhaolin/livego/av" "livego/parser/aac"
"github.com/gwuhaolin/livego/parser/h264" "livego/parser/h264"
"livego/parser/mp3"
) )
var ( var (

6
protocol/hls/hls.go

@ -3,14 +3,16 @@ package hls
import ( import (
"errors" "errors"
"fmt" "fmt"
"log"
"net" "net"
"net/http" "net/http"
"path" "path"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"log"
"github.com/gwuhaolin/livego/av" "livego/av"
"github.com/orcaman/concurrent-map" "github.com/orcaman/concurrent-map"
) )

15
protocol/hls/source.go

@ -1,15 +1,16 @@
package hls package hls
import ( import (
"fmt"
"time"
"bytes" "bytes"
"log"
"errors" "errors"
"github.com/gwuhaolin/livego/parser" "fmt"
"github.com/gwuhaolin/livego/av" "log"
"github.com/gwuhaolin/livego/container/flv" "time"
"github.com/gwuhaolin/livego/container/ts"
"livego/av"
"livego/container/flv"
"livego/container/ts"
"livego/parser"
) )
const ( const (

9
protocol/httpflv/server.go

@ -2,12 +2,13 @@ package httpflv
import ( import (
"encoding/json" "encoding/json"
"strings" "log"
"net" "net"
"net/http" "net/http"
"log" "strings"
"github.com/gwuhaolin/livego/av"
"github.com/gwuhaolin/livego/protocol/rtmp" "livego/av"
"livego/protocol/rtmp"
) )
type Server struct { type Server struct {

11
protocol/httpflv/writer.go

@ -1,15 +1,16 @@
package httpflv package httpflv
import ( import (
"time"
"errors" "errors"
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
"github.com/gwuhaolin/livego/utils/uid" "time"
"github.com/gwuhaolin/livego/protocol/amf"
"github.com/gwuhaolin/livego/av" "livego/av"
"github.com/gwuhaolin/livego/utils/pio" "livego/protocol/amf"
"livego/utils/pio"
"livego/utils/uid"
) )
const ( const (

9
protocol/httpopera/http_opera.go

@ -3,13 +3,14 @@ package httpopera
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gwuhaolin/livego/protocol/rtmp/rtmprelay"
"io" "io"
"log"
"net" "net"
"net/http" "net/http"
"log"
"github.com/gwuhaolin/livego/av" "livego/av"
"github.com/gwuhaolin/livego/protocol/rtmp" "livego/protocol/rtmp"
"livego/protocol/rtmp/rtmprelay"
) )
type Response struct { type Response struct {

3
protocol/rtmp/cache/cache.go vendored

@ -2,7 +2,8 @@ package cache
import ( import (
"flag" "flag"
"github.com/gwuhaolin/livego/av"
"livego/av"
) )
var ( var (

3
protocol/rtmp/cache/gop.go vendored

@ -2,7 +2,8 @@ package cache
import ( import (
"errors" "errors"
"github.com/gwuhaolin/livego/av"
"livego/av"
) )
var ( var (

4
protocol/rtmp/cache/special.go vendored

@ -4,8 +4,8 @@ import (
"bytes" "bytes"
"log" "log"
"github.com/gwuhaolin/livego/protocol/amf" "livego/av"
"github.com/gwuhaolin/livego/av" "livego/protocol/amf"
) )
const ( const (

8
protocol/rtmp/core/chunk_stream.go

@ -4,8 +4,8 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"github.com/gwuhaolin/livego/av" "livego/av"
"github.com/gwuhaolin/livego/utils/pool" "livego/utils/pool"
) )
type ChunkStream struct { type ChunkStream struct {
@ -73,7 +73,7 @@ func (chunkStream *ChunkStream) writeHeader(w *ReadWriter) error {
} }
w.WriteUintLE(chunkStream.StreamID, 4) w.WriteUintLE(chunkStream.StreamID, 4)
END: END:
//Extended Timestamp //Extended Timestamp
if ts >= 0xffffff { if ts >= 0xffffff {
w.WriteUintBE(chunkStream.Timestamp, 4) w.WriteUintBE(chunkStream.Timestamp, 4)
} }
@ -211,7 +211,7 @@ func (chunkStream *ChunkStream) readChunk(r *ReadWriter, chunkSize uint32, pool
size = int(chunkSize) 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 { if _, err := r.Read(buf); err != nil {
return err return err
} }

3
protocol/rtmp/core/chunk_stream_test.go

@ -4,8 +4,9 @@ import (
"bytes" "bytes"
"testing" "testing"
"livego/utils/pool"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/gwuhaolin/livego/utils/pool"
) )
func TestChunkRead1(t *testing.T) { func TestChunkRead1(t *testing.T) {

5
protocol/rtmp/core/conn.go

@ -4,8 +4,9 @@ import (
"encoding/binary" "encoding/binary"
"net" "net"
"time" "time"
"github.com/gwuhaolin/livego/utils/pool"
"github.com/gwuhaolin/livego/utils/pio" "livego/utils/pio"
"livego/utils/pool"
) )
const ( const (

6
protocol/rtmp/core/conn_client.go

@ -5,14 +5,14 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"log"
"math/rand" "math/rand"
"net" "net"
neturl "net/url" neturl "net/url"
"strings" "strings"
"github.com/gwuhaolin/livego/protocol/amf" "livego/av"
"github.com/gwuhaolin/livego/av" "livego/protocol/amf"
"log"
) )
var ( var (

6
protocol/rtmp/core/conn_server.go

@ -4,10 +4,10 @@ import (
"bytes" "bytes"
"errors" "errors"
"io" "io"
"github.com/gwuhaolin/livego/protocol/amf"
"github.com/gwuhaolin/livego/av"
"log" "log"
"livego/av"
"livego/protocol/amf"
) )
var ( var (

4
protocol/rtmp/core/conn_test.go

@ -4,8 +4,10 @@ import (
"bytes" "bytes"
"io" "io"
"testing" "testing"
"livego/utils/pool"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/gwuhaolin/livego/utils/pool"
) )
func TestConnReadNormal(t *testing.T) { func TestConnReadNormal(t *testing.T) {

9
protocol/rtmp/core/handshake.go

@ -7,10 +7,9 @@ import (
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"io" "io"
"time" "time"
"github.com/gwuhaolin/livego/utils/pio" "livego/utils/pio"
) )
var ( var (
@ -124,7 +123,7 @@ func (conn *Conn) HandshakeClient() (err error) {
return return
} }
S1 := S0S1S2[1: 1536+1] S1 := S0S1S2[1 : 1536+1]
if ver := pio.U32BE(S1[4:8]); ver != 0 { if ver := pio.U32BE(S1[4:8]); ver != 0 {
C2 = S1 C2 = S1
} else { } else {
@ -145,13 +144,13 @@ func (conn *Conn) HandshakeServer() (err error) {
C0C1C2 := random[:1536*2+1] C0C1C2 := random[:1536*2+1]
C0 := C0C1C2[:1] C0 := C0C1C2[:1]
C1 := C0C1C2[1: 1536+1] C1 := C0C1C2[1 : 1536+1]
C0C1 := C0C1C2[:1536+1] C0C1 := C0C1C2[:1536+1]
C2 := C0C1C2[1536+1:] C2 := C0C1C2[1536+1:]
S0S1S2 := random[1536*2+1:] S0S1S2 := random[1536*2+1:]
S0 := S0S1S2[:1] S0 := S0S1S2[:1]
S1 := S0S1S2[1: 1536+1] S1 := S0S1S2[1 : 1536+1]
S0S1 := S0S1S2[:1536+1] S0S1 := S0S1S2[:1536+1]
S2 := S0S1S2[1536+1:] S2 := S0S1S2[1536+1:]

15
protocol/rtmp/rtmp.go

@ -4,17 +4,18 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "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" "log"
"net" "net"
"net/url" "net/url"
"reflect" "reflect"
"strings" "strings"
"time" "time"
"livego/av"
"livego/configure"
"livego/container/flv"
"livego/protocol/rtmp/core"
"livego/utils/uid"
) )
const ( const (
@ -284,7 +285,7 @@ func (v *VirWriter) Write(p *av.Packet) (err error) {
} }
func (v *VirWriter) SendPacket() error { func (v *VirWriter) SendPacket() error {
Flush := reflect.ValueOf(v.conn).MethodByName("Flush"); Flush := reflect.ValueOf(v.conn).MethodByName("Flush")
var cs core.ChunkStream var cs core.ChunkStream
for { for {
p, ok := <-v.packetQueue p, ok := <-v.packetQueue
@ -313,7 +314,7 @@ func (v *VirWriter) SendPacket() error {
v.closed = true v.closed = true
return err return err
} }
Flush.Call(nil); Flush.Call(nil)
} else { } else {
return errors.New("closed") return errors.New("closed")
} }

5
protocol/rtmp/rtmprelay/rtmprelay.go

@ -4,10 +4,11 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"github.com/gwuhaolin/livego/protocol/amf"
"github.com/gwuhaolin/livego/protocol/rtmp/core"
"io" "io"
"log" "log"
"livego/protocol/amf"
"livego/protocol/rtmp/core"
) )
var ( var (

7
protocol/rtmp/rtmprelay/staticrelay.go

@ -3,11 +3,12 @@ package rtmprelay
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/gwuhaolin/livego/av"
"github.com/gwuhaolin/livego/configure"
"github.com/gwuhaolin/livego/protocol/rtmp/core"
"log" "log"
"sync" "sync"
"livego/av"
"livego/configure"
"livego/protocol/rtmp/core"
) )
type StaticPush struct { type StaticPush struct {

10
protocol/rtmp/stream.go

@ -2,13 +2,15 @@ package rtmp
import ( import (
"errors" "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" "log"
"strings" "strings"
"time" "time"
"livego/av"
"livego/protocol/rtmp/cache"
"livego/protocol/rtmp/rtmprelay"
"github.com/orcaman/concurrent-map"
) )
var ( var (

3
utils/queue/queue.go

@ -2,7 +2,8 @@ package queue
import ( import (
"sync" "sync"
"github.com/gwuhaolin/livego/av"
"livego/av"
) )
// Queue is a basic FIFO queue for Messages. // Queue is a basic FIFO queue for Messages.

3
utils/uid/uuid.go

@ -2,11 +2,12 @@ package uid
import ( import (
"encoding/base64" "encoding/base64"
"github.com/satori/go.uuid" "github.com/satori/go.uuid"
) )
func NewId() string { func NewId() string {
id, _ := uuid.NewV4() id := uuid.NewV4()
b64 := base64.URLEncoding.EncodeToString(id.Bytes()[:12]) b64 := base64.URLEncoding.EncodeToString(id.Bytes()[:12])
return b64 return b64
} }

Loading…
Cancel
Save