Browse Source

初步连接成功

v4
langhuihui 5 years ago
parent
commit
c0662fb537
  1. 3
      go.mod
  2. 24
      go.sum
  3. 189
      main.go
  4. 64
      ui/dist/plugin-webrtc.common.js
  5. 2
      ui/dist/plugin-webrtc.common.js.map
  6. 1
      ui/dist/plugin-webrtc.css
  7. 64
      ui/dist/plugin-webrtc.umd.js
  8. 2
      ui/dist/plugin-webrtc.umd.js.map
  9. 2
      ui/dist/plugin-webrtc.umd.min.js
  10. 2
      ui/dist/plugin-webrtc.umd.min.js.map
  11. 6797
      ui/package-lock.json
  12. 52
      ui/src/App.vue

3
go.mod

@ -3,7 +3,8 @@ module github.com/Monibuca/plugin-webrtc
go 1.13
require (
github.com/Monibuca/engine/v2 v2.0.0
github.com/Monibuca/engine/v2 v2.0.1
github.com/Monibuca/plugin-rtsp v1.1.4
github.com/pion/rtcp v1.2.1
github.com/pion/webrtc/v2 v2.2.14
)

24
go.sum

@ -3,23 +3,38 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/Monibuca/engine v1.2.2 h1:hNjsrZpOmui8lYhgCJ5ltJU8g/k0Rrdysx2tHNGGnbI=
github.com/Monibuca/engine/v2 v2.0.0 h1:8FjaScrtN8QdbcxO9zZYABMC0Re3I1O1T4p94zAXYb0=
github.com/Monibuca/engine/v2 v2.0.0/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
github.com/Monibuca/engine/v2 v2.0.1 h1:z27YwXVSelYgGfbrx5RmJ+ROveIf5QWGnwZqfOdqhM0=
github.com/Monibuca/engine/v2 v2.0.1/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
github.com/Monibuca/plugin-rtsp v1.1.4 h1:n2ERclQdZE9KUf2HYPhyQYPYY8rQHT1BzE6oreDVcbg=
github.com/Monibuca/plugin-rtsp v1.1.4/go.mod h1:GkAUB7Xc/nUxX9Acm4EnfnbC3Hdtlv6WaFaDBXuIGa4=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/funny/slab v0.0.0-20180511031532-b1fad5e5d478 h1:Db9StoJ6RZN3YttC0Pm0I4Y5izITRYch3RMbT59BYN0=
github.com/funny/slab v0.0.0-20180511031532-b1fad5e5d478/go.mod h1:0j1+svBH8ABEIPdUP0AIg4qedsybnXGJBakCEw8cfoo=
github.com/funny/utest v0.0.0-20161029064919-43870a374500/go.mod h1:mUn39tBov9jKnTWV1RlOYoNzxdBFHiSzXWdY1FoNGGg=
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.3/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs=
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/lucas-clemente/quic-go v0.7.1-0.20190401152353-907071221cf9/go.mod h1:PpMmPfPKO9nKJ/psF49ESTAGQSdfXxlg1otPbEB2nOw=
@ -28,6 +43,7 @@ github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+v
github.com/mattn/go-colorable v0.1.6/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/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@ -63,10 +79,12 @@ github.com/pion/turn/v2 v2.0.3/go.mod h1:kl1hmT3NxcLynpXVnwJgObL8C9NaCyPTeqI2DcC
github.com/pion/webrtc v1.2.0 h1:3LGGPQEMacwG2hcDfhdvwQPz315gvjZXOfY4vaF4+I4=
github.com/pion/webrtc/v2 v2.2.14 h1:bRjnXTqMDJ3VERPF45z439Sv6QfDfjdYvdQk1QcIx8M=
github.com/pion/webrtc/v2 v2.2.14/go.mod h1:G+8lShCMbHhjpMF1ZJBkyuvrxXrvW4bxs3nOt+mJ2UI=
github.com/pixelbender/go-sdp v1.0.0/go.mod h1:6IBlz9+BrUHoFTea7gcp4S54khtOhjCW/nVDLhmZBAs=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/reactivex/rxgo v1.0.0/go.mod h1:/S1ygE20oE1BvZGIwd3fXx/m6s6pOX5G6zmXg9ninlQ=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
github.com/shirou/gopsutil v2.20.1+incompatible h1:oIq9Cq4i84Hk8uQAUOG3eNdI/29hBawGrD5YRl6JRDY=
github.com/shirou/gopsutil v2.20.1+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
@ -74,10 +92,15 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf h1:Z2X3Os7oRzpdJ75iPqWZc0HeJWFYNCvKsfpQwFpRNTA=
github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf/go.mod h1:M8agBzgqHIhgj7wEn9/0hJUZcrvt9VY+Ln+S1I5Mha0=
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@ -97,6 +120,7 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=

189
main.go

@ -4,11 +4,11 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/http"
"time"
. "github.com/Monibuca/engine/v2"
rtsp "github.com/Monibuca/plugin-rtsp"
"github.com/pion/rtcp"
. "github.com/pion/webrtc/v2"
)
@ -16,20 +16,15 @@ import (
var config = &struct {
ICEServers []string
}{[]string{
"stun.l.google.com:19302",
"stun1.l.google.com:19302",
"stun2.l.google.com:19302",
"stun3.l.google.com:19302",
"stun4.l.google.com:19302",
"stun.ekiga.net",
"stun.ideasip.com",
"stun.schlund.de",
"stun.stunprotocol.org:3478",
"stun.voiparound.com",
"stun.voipbuster.com",
"stun.voipstunt.com",
"stun.voxgratia.org",
"stun.services.mozilla.com",
"stun:stun.ekiga.net",
"stun:stun.ideasip.com",
"stun:stun.schlund.de",
"stun:stun.stunprotocol.org:3478",
"stun:stun.voiparound.com",
"stun:stun.voipbuster.com",
"stun:stun.voipstunt.com",
"stun:stun.voxgratia.org",
"stun:stun.services.mozilla.com",
"stun:stun.xten.com",
"stun:stun.softjoys.com",
"stun:stunserver.org",
@ -42,12 +37,18 @@ var config = &struct {
"stun:stun01.sipphone.com",
}}
type udpConn struct {
conn *net.UDPConn
port int
}
// type udpConn struct {
// conn *net.UDPConn
// port int
// }
var m = MediaEngine{}
var api *API
func init() {
m.RegisterCodec(NewRTPH264Codec(DefaultPayloadTypeH264, 90000))
//m.RegisterCodec(NewRTPPCMUCodec(DefaultPayloadTypePCMU, 8000))
api = NewAPI(WithMediaEngine(m))
InstallPlugin(&PluginConfig{
Config: config,
Name: "WebRTC",
@ -55,10 +56,13 @@ func init() {
Run: run,
})
}
func run() {
m := MediaEngine{}
m.RegisterCodec(NewRTPH264Codec(DefaultPayloadTypeH264, 90000))
api := NewAPI(WithMediaEngine(m))
type WebRTC struct {
rtsp.RTSP
*PeerConnection
}
func (rtc *WebRTC) Publish(streamPath string) bool {
peerConnection, err := api.NewPeerConnection(Configuration{
ICEServers: []ICEServer{
{
@ -66,134 +70,95 @@ func run() {
},
},
})
if _, err = peerConnection.AddTransceiverFromKind(RTPCodecTypeVideo); err != nil {
if err != nil {
Println(err)
return
return false
}
// Allow us to receive 1 audio track, and 1 video track
if _, err = peerConnection.AddTransceiverFromKind(RTPCodecTypeAudio); err != nil {
if err != nil {
Println(err)
return
}
} else if _, err = peerConnection.AddTransceiverFromKind(RTPCodecTypeVideo); err != nil {
if err != nil {
Println(err)
return
}
}
var laddr *net.UDPAddr
if laddr, err = net.ResolveUDPAddr("udp", "127.0.0.1:"); err != nil {
panic(err)
}
// Prepare udp conns
udpConns := map[string]*udpConn{
"audio": {port: 4000},
"video": {port: 4002},
}
for _, c := range udpConns {
// Create remote addr
var raddr *net.UDPAddr
if raddr, err = net.ResolveUDPAddr("udp", fmt.Sprintf("127.0.0.1:%d", c.port)); err != nil {
panic(err)
return false
}
peerConnection.OnICEConnectionStateChange(func(connectionState ICEConnectionState) {
fmt.Printf("Connection State has changed %s \n", connectionState.String())
// Dial udp
if c.conn, err = net.DialUDP("udp", laddr, raddr); err != nil {
panic(err)
}
defer func(conn net.PacketConn) {
if closeErr := conn.Close(); closeErr != nil {
panic(closeErr)
}
}(c.conn)
if connectionState == ICEConnectionStateConnected {
fmt.Println("Ctrl+C the remote client to stop the demo")
} else if connectionState == ICEConnectionStateFailed ||
connectionState == ICEConnectionStateDisconnected {
fmt.Println("Done forwarding")
//TODO
}
// Set a handler for when a new remote track starts, this handler will forward data to
// our UDP listeners.
// In your application this is where you would handle/process audio/video
})
rtc.PeerConnection = peerConnection
if rtc.RTSP.Publish(streamPath) {
rtc.Stream.Type = "WebRTC"
peerConnection.OnTrack(func(track *Track, receiver *RTPReceiver) {
// Retrieve udp connection
c, ok := udpConns[track.Kind().String()]
if !ok {
return
}
// Send a PLI on an interval so that the publisher is pushing a keyframe every rtcpPLIInterval
defer rtc.Close()
go func() {
ticker := time.NewTicker(time.Second * 2)
for range ticker.C {
select {
case <-ticker.C:
if rtcpErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: track.SSRC()}}); rtcpErr != nil {
fmt.Println(rtcpErr)
}
case <-rtc.Done():
return
}
}()
b := make([]byte, 1500)
for {
// Read
n, readErr := track.Read(b)
if readErr != nil {
panic(readErr)
pack := &rtsp.RTPPack{
Type: rtsp.RTPType(track.Kind() - 1),
}
// Write
if _, err = c.conn.Write(b[:n]); err != nil {
// For this particular example, third party applications usually timeout after a short
// amount of time during which the user doesn't have enough time to provide the answer
// to the browser.
// That's why, for this particular example, the user first needs to provide the answer
// to the browser then open the third party application. Therefore we must not kill
// the forward on "connection refused" errors
if opError, ok := err.(*net.OpError); ok && opError.Err.Error() == "write: connection refused" {
continue
for b := make([]byte, 1460); ; rtc.HandleRTP(pack) {
i, err := track.Read(b)
if err != nil {
return
}
panic(err)
if err = pack.Unmarshal(b[:i]); err != nil {
return
}
}
})
// Set the handler for ICE connection state
// This will notify you when the peer has connected/disconnected
peerConnection.OnICEConnectionStateChange(func(connectionState ICEConnectionState) {
fmt.Printf("Connection State has changed %s \n", connectionState.String())
if connectionState == ICEConnectionStateConnected {
fmt.Println("Ctrl+C the remote client to stop the demo")
} else if connectionState == ICEConnectionStateFailed ||
connectionState == ICEConnectionStateDisconnected {
fmt.Println("Done forwarding")
//TODO
} else {
return false
}
})
return true
}
func run() {
http.HandleFunc("/webrtc/answer", func(w http.ResponseWriter, r *http.Request) {
// Wait for the offer to be pasted
streamPath := r.URL.Query().Get("streamPath")
offer := SessionDescription{}
bytes, err := ioutil.ReadAll(r.Body)
err = json.Unmarshal(bytes, &offer)
if err != nil {
Println(err)
return
}
rtc := new(WebRTC)
if rtc.Publish(streamPath) {
// Set the remote SessionDescription
if err = peerConnection.SetRemoteDescription(offer); err != nil {
panic(err)
if err = rtc.SetRemoteDescription(offer); err != nil {
Println(err)
return
}
// Create answer
answer, err := peerConnection.CreateAnswer(nil)
answer, err := rtc.CreateAnswer(nil)
if err != nil {
panic(err)
Println(err)
return
}
// Sets the LocalDescription, and starts our UDP listeners
if err = peerConnection.SetLocalDescription(answer); err != nil {
panic(err)
if err = rtc.SetLocalDescription(answer); err != nil {
Println(err)
return
}
bytes, err = json.Marshal(answer)
if err != nil {
panic(err)
if bytes, err = json.Marshal(answer); err != nil {
Println(err)
return
}
w.Write(bytes)
}
})
}

64
ui/dist/plugin-webrtc.common.js

@ -87,6 +87,24 @@ module.exports =
/************************************************************************/
/******/ ({
/***/ "034f":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("85ec");
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__);
/* unused harmony reexport * */
/* unused harmony default export */ var _unused_webpack_default_export = (_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a);
/***/ }),
/***/ "85ec":
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ "8875":
/***/ (function(module, exports, __webpack_require__) {
@ -196,12 +214,12 @@ if (typeof window !== 'undefined') {
// Indicate to webpack that this file can be concatenated
/* harmony default export */ var setPublicPath = (null);
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"46d6b4f7-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=69b8f189&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_vm._v(" Browser base64 Session Description "),_c('br'),_c('textarea',{attrs:{"readonly":"true"},domProps:{"value":_vm.localDescription}}),_c('br'),_vm._v("Golang base64 Session Description "),_c('br'),_c('textarea',{domProps:{"value":_vm.remoteSessionDescription}}),_c('br'),_c('button',{on:{"click":_vm.startSession}},[_vm._v("Start Session")]),_c('br'),_c('br'),_vm._v("Video "),_c('br'),_c('video',{attrs:{"id":"video1","width":"160","height":"120","autoplay":"","muted":""},domProps:{"muted":true}}),_c('br'),_vm._v("Logs "),_c('br'),_c('div',{attrs:{"id":"logs"}})])}
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"7d106341-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=cb3c076e&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"root"},[_vm._v(" Browser SDP "),_c('br'),_c('textarea',{attrs:{"readonly":"true","rows":"10","cols":"100"}},[_vm._v(_vm._s(_vm.localSDP||"loading..."))]),_c('br'),_vm._v("Golang SDP "),_c('br'),_c('textarea',{attrs:{"rows":"10","cols":"100"}},[_vm._v(_vm._s(_vm.remoteSDP))]),_c('br'),_c('mu-text-field',{attrs:{"label":"streamPath"},model:{value:(_vm.streamPath),callback:function ($$v) {_vm.streamPath=$$v},expression:"streamPath"}}),(_vm.localSDP)?_c('m-button',{on:{"click":_vm.startSession}},[_vm._v("Start")]):_vm._e(),_c('br'),_c('br'),_vm._v("Video "),_c('br'),_c('video',{attrs:{"id":"video1","width":"160","height":"120","autoplay":"","muted":""},domProps:{"muted":true}}),_c('br'),_vm._v("Logs "),_c('br'),_c('div',{attrs:{"id":"logs"}})],1)}
var staticRenderFns = []
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=69b8f189&
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=cb3c076e&
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
//
@ -225,25 +243,47 @@ var staticRenderFns = []
//
//
//
//
let pc = new RTCPeerConnection({
iceServers: [
iceServers:[
{
urls: "stun:stun.l.google.com:19302"
urls:[
"stun:stun.ekiga.net",
"stun:stun.ideasip.com",
"stun:stun.schlund.de",
"stun:stun.stunprotocol.org:3478",
"stun:stun.voiparound.com",
"stun:stun.voipbuster.com",
"stun:stun.voipstunt.com",
"stun:stun.voxgratia.org",
"stun:stun.services.mozilla.com",
"stun:stun.xten.com",
"stun:stun.softjoys.com",
"stun:stunserver.org",
"stun:stun.schlund.de",
"stun:stun.rixtelecom.se",
"stun:stun.iptel.org",
"stun:stun.ideasip.com",
"stun:stun.fwdnet.net",
"stun:stun.ekiga.net",
"stun:stun01.sipphone.com",
]
}
]
});
/* harmony default export */ var Appvue_type_script_lang_js_ = ({
data() {
return {
localDescription: "",
remoteSessionDescription: ""
localSDP: "",
remoteSDP: "",
streamPath:"live/rtc"
};
},
methods: {
startSession() {
this.ajax.post("/webrtc/answer", this.localDescription).then(result => {
this.remoteSessionDescription = result;
this.ajax({type: 'POST',processData:false,data: JSON.stringify(pc.localDescription),url:"/webrtc/answer?streamPath="+this.streamPath,dataType:"json"}).then(result => {
this.remoteSDP = result.sdp;
pc.setRemoteDescription(new RTCSessionDescription(result));
});
}
@ -267,7 +307,7 @@ let pc = new RTCPeerConnection({
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState);
pc.onicecandidate = event => {
if (event.candidate === null) {
this.localDescription = JSON.stringify(pc.localDescription);
this.localSDP = pc.localDescription.sdp;
}
};
}
@ -275,6 +315,9 @@ let pc = new RTCPeerConnection({
// CONCATENATED MODULE: ./src/App.vue?vue&type=script&lang=js&
/* harmony default export */ var src_Appvue_type_script_lang_js_ = (Appvue_type_script_lang_js_);
// EXTERNAL MODULE: ./src/App.vue?vue&type=style&index=0&lang=css&
var Appvue_type_style_index_0_lang_css_ = __webpack_require__("034f");
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
/* globals __VUE_SSR_CONTEXT__ */
@ -381,6 +424,7 @@ function normalizeComponent (
/* normalize component */
var component = normalizeComponent(

2
ui/dist/plugin-webrtc.common.js.map

File diff suppressed because one or more lines are too long

1
ui/dist/plugin-webrtc.css

@ -0,0 +1 @@
.root textarea{background:transparent;color:#0ff}

64
ui/dist/plugin-webrtc.umd.js

@ -96,6 +96,24 @@ return /******/ (function(modules) { // webpackBootstrap
/************************************************************************/
/******/ ({
/***/ "034f":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("85ec");
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__);
/* unused harmony reexport * */
/* unused harmony default export */ var _unused_webpack_default_export = (_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_App_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a);
/***/ }),
/***/ "85ec":
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ "8875":
/***/ (function(module, exports, __webpack_require__) {
@ -205,12 +223,12 @@ if (typeof window !== 'undefined') {
// Indicate to webpack that this file can be concatenated
/* harmony default export */ var setPublicPath = (null);
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"46d6b4f7-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=69b8f189&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_vm._v(" Browser base64 Session Description "),_c('br'),_c('textarea',{attrs:{"readonly":"true"},domProps:{"value":_vm.localDescription}}),_c('br'),_vm._v("Golang base64 Session Description "),_c('br'),_c('textarea',{domProps:{"value":_vm.remoteSessionDescription}}),_c('br'),_c('button',{on:{"click":_vm.startSession}},[_vm._v("Start Session")]),_c('br'),_c('br'),_vm._v("Video "),_c('br'),_c('video',{attrs:{"id":"video1","width":"160","height":"120","autoplay":"","muted":""},domProps:{"muted":true}}),_c('br'),_vm._v("Logs "),_c('br'),_c('div',{attrs:{"id":"logs"}})])}
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"7d106341-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=cb3c076e&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"root"},[_vm._v(" Browser SDP "),_c('br'),_c('textarea',{attrs:{"readonly":"true","rows":"10","cols":"100"}},[_vm._v(_vm._s(_vm.localSDP||"loading..."))]),_c('br'),_vm._v("Golang SDP "),_c('br'),_c('textarea',{attrs:{"rows":"10","cols":"100"}},[_vm._v(_vm._s(_vm.remoteSDP))]),_c('br'),_c('mu-text-field',{attrs:{"label":"streamPath"},model:{value:(_vm.streamPath),callback:function ($$v) {_vm.streamPath=$$v},expression:"streamPath"}}),(_vm.localSDP)?_c('m-button',{on:{"click":_vm.startSession}},[_vm._v("Start")]):_vm._e(),_c('br'),_c('br'),_vm._v("Video "),_c('br'),_c('video',{attrs:{"id":"video1","width":"160","height":"120","autoplay":"","muted":""},domProps:{"muted":true}}),_c('br'),_vm._v("Logs "),_c('br'),_c('div',{attrs:{"id":"logs"}})],1)}
var staticRenderFns = []
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=69b8f189&
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=cb3c076e&
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
//
@ -234,25 +252,47 @@ var staticRenderFns = []
//
//
//
//
let pc = new RTCPeerConnection({
iceServers: [
iceServers:[
{
urls: "stun:stun.l.google.com:19302"
urls:[
"stun:stun.ekiga.net",
"stun:stun.ideasip.com",
"stun:stun.schlund.de",
"stun:stun.stunprotocol.org:3478",
"stun:stun.voiparound.com",
"stun:stun.voipbuster.com",
"stun:stun.voipstunt.com",
"stun:stun.voxgratia.org",
"stun:stun.services.mozilla.com",
"stun:stun.xten.com",
"stun:stun.softjoys.com",
"stun:stunserver.org",
"stun:stun.schlund.de",
"stun:stun.rixtelecom.se",
"stun:stun.iptel.org",
"stun:stun.ideasip.com",
"stun:stun.fwdnet.net",
"stun:stun.ekiga.net",
"stun:stun01.sipphone.com",
]
}
]
});
/* harmony default export */ var Appvue_type_script_lang_js_ = ({
data() {
return {
localDescription: "",
remoteSessionDescription: ""
localSDP: "",
remoteSDP: "",
streamPath:"live/rtc"
};
},
methods: {
startSession() {
this.ajax.post("/webrtc/answer", this.localDescription).then(result => {
this.remoteSessionDescription = result;
this.ajax({type: 'POST',processData:false,data: JSON.stringify(pc.localDescription),url:"/webrtc/answer?streamPath="+this.streamPath,dataType:"json"}).then(result => {
this.remoteSDP = result.sdp;
pc.setRemoteDescription(new RTCSessionDescription(result));
});
}
@ -276,7 +316,7 @@ let pc = new RTCPeerConnection({
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState);
pc.onicecandidate = event => {
if (event.candidate === null) {
this.localDescription = JSON.stringify(pc.localDescription);
this.localSDP = pc.localDescription.sdp;
}
};
}
@ -284,6 +324,9 @@ let pc = new RTCPeerConnection({
// CONCATENATED MODULE: ./src/App.vue?vue&type=script&lang=js&
/* harmony default export */ var src_Appvue_type_script_lang_js_ = (Appvue_type_script_lang_js_);
// EXTERNAL MODULE: ./src/App.vue?vue&type=style&index=0&lang=css&
var Appvue_type_style_index_0_lang_css_ = __webpack_require__("034f");
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
/* globals __VUE_SSR_CONTEXT__ */
@ -390,6 +433,7 @@ function normalizeComponent (
/* normalize component */
var component = normalizeComponent(

2
ui/dist/plugin-webrtc.umd.js.map

File diff suppressed because one or more lines are too long

2
ui/dist/plugin-webrtc.umd.min.js

File diff suppressed because one or more lines are too long

2
ui/dist/plugin-webrtc.umd.min.js.map

File diff suppressed because one or more lines are too long

6797
ui/package-lock.json

File diff suppressed because it is too large

52
ui/src/App.vue

@ -1,13 +1,14 @@
<template>
<div>
Browser base64 Session Description
<div class="root">
Browser SDP
<br />
<textarea readonly="true" :value="localDescription"></textarea>
<br />Golang base64 Session Description
<textarea readonly="true" rows="10" cols="100">{{localSDP||"loading..."}}</textarea>
<br />Golang SDP
<br />
<textarea :value="remoteSessionDescription"></textarea>
<textarea rows="10" cols="100">{{remoteSDP}}</textarea>
<br />
<button @click="startSession">Start Session</button>
<mu-text-field v-model="streamPath" label="streamPath"></mu-text-field>
<m-button @click="startSession" v-if="localSDP">Start</m-button>
<br />
<br />Video
@ -21,23 +22,44 @@
<script>
let pc = new RTCPeerConnection({
iceServers: [
iceServers:[
{
urls: "stun:stun.l.google.com:19302"
urls:[
"stun:stun.ekiga.net",
"stun:stun.ideasip.com",
"stun:stun.schlund.de",
"stun:stun.stunprotocol.org:3478",
"stun:stun.voiparound.com",
"stun:stun.voipbuster.com",
"stun:stun.voipstunt.com",
"stun:stun.voxgratia.org",
"stun:stun.services.mozilla.com",
"stun:stun.xten.com",
"stun:stun.softjoys.com",
"stun:stunserver.org",
"stun:stun.schlund.de",
"stun:stun.rixtelecom.se",
"stun:stun.iptel.org",
"stun:stun.ideasip.com",
"stun:stun.fwdnet.net",
"stun:stun.ekiga.net",
"stun:stun01.sipphone.com",
]
}
]
});
export default {
data() {
return {
localDescription: "",
remoteSessionDescription: ""
localSDP: "",
remoteSDP: "",
streamPath:"live/rtc"
};
},
methods: {
startSession() {
this.ajax.post("/webrtc/answer", this.localDescription).then(result => {
this.remoteSessionDescription = result;
this.ajax({type: 'POST',processData:false,data: JSON.stringify(pc.localDescription),url:"/webrtc/answer?streamPath="+this.streamPath,dataType:"json"}).then(result => {
this.remoteSDP = result.sdp;
pc.setRemoteDescription(new RTCSessionDescription(result));
});
}
@ -61,7 +83,7 @@ export default {
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState);
pc.onicecandidate = event => {
if (event.candidate === null) {
this.localDescription = JSON.stringify(pc.localDescription);
this.localSDP = pc.localDescription.sdp;
}
};
}
@ -69,4 +91,8 @@ export default {
</script>
<style>
.root textarea{
background: transparent;
color: cyan;
}
</style>
Loading…
Cancel
Save