mirror of
https://github.com/Monibuca/plugin-gb28181.git
synced 2025-12-24 13:27:57 +08:00
增加对GetMethod的判断
This commit is contained in:
4
main.go
4
main.go
@@ -22,8 +22,7 @@ var config = struct {
|
||||
ListenAddr string
|
||||
Expires int
|
||||
AutoInvite bool
|
||||
MediaPort uint16
|
||||
}{"34020000002000000001", "3402000000", "127.0.0.1:5060", 3600, true, 6000}
|
||||
}{"34020000002000000001", "3402000000", "127.0.0.1:5060", 3600, true}
|
||||
|
||||
func init() {
|
||||
InstallPlugin(&PluginConfig{
|
||||
@@ -48,7 +47,6 @@ func run() {
|
||||
Realm: config.Realm,
|
||||
AckTimeout: 10,
|
||||
MediaIP: ipAddr.IP.String(),
|
||||
MediaPort: config.MediaPort,
|
||||
RegisterValidity: config.Expires,
|
||||
RegisterInterval: 60,
|
||||
HeartbeatInterval: 60,
|
||||
|
||||
@@ -3,9 +3,10 @@ package sip
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Monibuca/plugin-gb28181/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Monibuca/plugin-gb28181/utils"
|
||||
)
|
||||
|
||||
//Content-Type: Application/MANSCDP+xml
|
||||
@@ -33,31 +34,33 @@ type Message struct {
|
||||
ContentType string //Content-Type
|
||||
Expires int //Expires
|
||||
ContentLength int //Content-Length
|
||||
Route *Contact
|
||||
Body string
|
||||
Addr string
|
||||
Route *Contact
|
||||
Body string
|
||||
Addr string
|
||||
}
|
||||
func (m *Message)BuildResponse(code int)*Message{
|
||||
response:=Message{
|
||||
Mode: SIP_MESSAGE_RESPONSE,
|
||||
From: m.From,
|
||||
To: m.To,
|
||||
CallID: m.CallID,
|
||||
CSeq: m.CSeq,
|
||||
Via:m.Via,
|
||||
|
||||
func (m *Message) BuildResponse(code int) *Message {
|
||||
response := Message{
|
||||
Mode: SIP_MESSAGE_RESPONSE,
|
||||
From: m.From,
|
||||
To: m.To,
|
||||
CallID: m.CallID,
|
||||
CSeq: m.CSeq,
|
||||
Via: m.Via,
|
||||
MaxForwards: m.MaxForwards,
|
||||
StartLine:&StartLine{
|
||||
Code:code,
|
||||
StartLine: &StartLine{
|
||||
Code: code,
|
||||
},
|
||||
}
|
||||
return &response
|
||||
}
|
||||
|
||||
//z9hG4bK + 10个随机数字
|
||||
func randBranch() string {
|
||||
return fmt.Sprintf("z9hG4bK%s", utils.RandNumString(8))
|
||||
}
|
||||
|
||||
func BuildMessageRequest(method Method, transport, sipSerial, sipRealm, username , srcIP string, srcPort uint16, expires, cseq int,body string) *Message {
|
||||
func BuildMessageRequest(method Method, transport, sipSerial, sipRealm, username, srcIP string, srcPort uint16, expires, cseq int, body string) *Message {
|
||||
server := fmt.Sprintf("%s@%s", sipSerial, sipRealm)
|
||||
client := fmt.Sprintf("%s@%s", username, sipRealm)
|
||||
|
||||
@@ -99,15 +102,13 @@ func BuildMessageRequest(method Method, transport, sipSerial, sipRealm, username
|
||||
msg.Contact = &Contact{
|
||||
Uri: NewURI(fmt.Sprintf("%s@%s:%d", username, srcIP, srcPort)),
|
||||
}
|
||||
if len(body)>0{
|
||||
if len(body) > 0 {
|
||||
msg.ContentLength = len(body)
|
||||
msg.Body = body
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (m *Message) GetMode() Mode {
|
||||
return m.Mode
|
||||
}
|
||||
@@ -121,6 +122,11 @@ func (m *Message) IsResponse() bool {
|
||||
}
|
||||
|
||||
func (m *Message) GetMethod() Method {
|
||||
if m.CSeq == nil {
|
||||
b, _ := Encode(m)
|
||||
println(string(b))
|
||||
return MESSAGE
|
||||
}
|
||||
return m.CSeq.Method
|
||||
}
|
||||
|
||||
@@ -243,7 +249,7 @@ func Decode(data []byte) (msg *Message, err error) {
|
||||
raw: firstline,
|
||||
Version: VERSION,
|
||||
Code: int(num),
|
||||
phrase: strings.Join(tmp[2:]," "),
|
||||
phrase: strings.Join(tmp[2:], " "),
|
||||
}
|
||||
} else {
|
||||
//request line
|
||||
@@ -255,7 +261,7 @@ func Decode(data []byte) (msg *Message, err error) {
|
||||
Method: Method(tmp[0]),
|
||||
Version: VERSION,
|
||||
}
|
||||
if len(tmp) > 1{
|
||||
if len(tmp) > 1 {
|
||||
msg.StartLine.Uri, err = parseURI(tmp[1])
|
||||
if err != nil {
|
||||
return
|
||||
@@ -445,5 +451,5 @@ func Encode(msg *Message) ([]byte, error) {
|
||||
sb.WriteString(msg.Body)
|
||||
}
|
||||
|
||||
return []byte( sb.String()), nil
|
||||
return []byte(sb.String()), nil
|
||||
}
|
||||
|
||||
6
ui/dist/plugin-gb28181.common.js
vendored
6
ui/dist/plugin-gb28181.common.js
vendored
@@ -136,7 +136,7 @@ if (typeof window !== 'undefined') {
|
||||
// Indicate to webpack that this file can be concatenated
|
||||
/* harmony default export */ var setPublicPath = (null);
|
||||
|
||||
// CONCATENATED MODULE: C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"2507526a-vue-loader-template"}!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js??ref--0-0!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=42a2ba94&
|
||||
// CONCATENATED MODULE: C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"2507526a-vue-loader-template"}!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js??ref--0-0!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=764a9e60&
|
||||
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('mu-data-table',{attrs:{"data":_vm.Devices,"columns":_vm.columns},scopedSlots:_vm._u([{key:"expand",fn:function(prop){return [_c('mu-data-table',{attrs:{"data":prop.row.Channels,"columns":_vm.columns2},scopedSlots:_vm._u([{key:"default",fn:function(ref){
|
||||
var item = ref.row;
|
||||
var $index = ref.$index;
|
||||
@@ -146,7 +146,7 @@ return [_c('td',[_vm._v(_vm._s(item.ID))]),_c('td',[_vm._v(_vm._s(item.Channels
|
||||
var staticRenderFns = []
|
||||
|
||||
|
||||
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=42a2ba94&
|
||||
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=764a9e60&
|
||||
|
||||
// CONCATENATED MODULE: C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"2507526a-vue-loader-template"}!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js??ref--0-0!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib??vue-loader-options!./src/components/Player.vue?vue&type=template&id=70987c50&scoped=true&
|
||||
var Playervue_type_template_id_70987c50_scoped_true_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Modal',_vm._g(_vm._b({attrs:{"draggable":"","title":_vm.streamPath},on:{"on-ok":_vm.onClosePreview,"on-cancel":_vm.onClosePreview}},'Modal',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"container"},[_c('video',{ref:"webrtc",attrs:{"width":"488","height":"275","autoplay":"","muted":"","controls":""},domProps:{"srcObject":_vm.stream,"muted":true}}),_c('div',{staticClass:"control"},_vm._l((4),function(n){return _c('svg',{class:'arrow'+n,attrs:{"viewBox":"0 0 1024 1024","version":"1.1","xmlns":"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","width":"64","height":"64"},on:{"click":function($event){return _vm.$emit('ptz',n)}}},[_c('defs'),_c('path',{attrs:{"d":"M682.666667 955.733333H341.333333a17.066667 17.066667 0 0 1-17.066666-17.066666V529.066667H85.333333a17.066667 17.066667 0 0 1-12.066133-29.1328l426.666667-426.666667a17.0496 17.0496 0 0 1 24.132266 0l426.666667 426.666667A17.066667 17.066667 0 0 1 938.666667 529.066667H699.733333v409.6a17.066667 17.066667 0 0 1-17.066666 17.066666z m-324.266667-34.133333h307.2V512a17.066667 17.066667 0 0 1 17.066667-17.066667h214.801066L512 109.4656 126.532267 494.933333H341.333333a17.066667 17.066667 0 0 1 17.066667 17.066667v409.6z","p-id":"6849"}})])}),0)]),_c('div',{attrs:{"slot":"footer"},slot:"footer"},[(_vm.remoteSDP)?_c('mu-badge',[_c('a',{attrs:{"slot":"content","href":_vm.remoteSDPURL,"download":"remoteSDP.txt"},slot:"content"},[_vm._v("remoteSDP")])]):_vm._e(),(_vm.localSDP)?_c('mu-badge',[_c('a',{attrs:{"slot":"content","href":_vm.localSDPURL,"download":"localSDP.txt"},slot:"content"},[_vm._v("localSDP")])]):_vm._e()],1)])}
|
||||
@@ -483,7 +483,7 @@ var component = normalizeComponent(
|
||||
channel:this.context.channel,
|
||||
ptzcmd: "A50F0100000000B5",
|
||||
});
|
||||
},1000)
|
||||
},500)
|
||||
});
|
||||
},
|
||||
invite(id, channel,item) {
|
||||
|
||||
2
ui/dist/plugin-gb28181.common.js.map
vendored
2
ui/dist/plugin-gb28181.common.js.map
vendored
File diff suppressed because one or more lines are too long
6
ui/dist/plugin-gb28181.umd.js
vendored
6
ui/dist/plugin-gb28181.umd.js
vendored
@@ -145,7 +145,7 @@ if (typeof window !== 'undefined') {
|
||||
// Indicate to webpack that this file can be concatenated
|
||||
/* harmony default export */ var setPublicPath = (null);
|
||||
|
||||
// CONCATENATED MODULE: C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"2507526a-vue-loader-template"}!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js??ref--0-0!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=42a2ba94&
|
||||
// CONCATENATED MODULE: C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"2507526a-vue-loader-template"}!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js??ref--0-0!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=template&id=764a9e60&
|
||||
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('mu-data-table',{attrs:{"data":_vm.Devices,"columns":_vm.columns},scopedSlots:_vm._u([{key:"expand",fn:function(prop){return [_c('mu-data-table',{attrs:{"data":prop.row.Channels,"columns":_vm.columns2},scopedSlots:_vm._u([{key:"default",fn:function(ref){
|
||||
var item = ref.row;
|
||||
var $index = ref.$index;
|
||||
@@ -155,7 +155,7 @@ return [_c('td',[_vm._v(_vm._s(item.ID))]),_c('td',[_vm._v(_vm._s(item.Channels
|
||||
var staticRenderFns = []
|
||||
|
||||
|
||||
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=42a2ba94&
|
||||
// CONCATENATED MODULE: ./src/App.vue?vue&type=template&id=764a9e60&
|
||||
|
||||
// CONCATENATED MODULE: C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"2507526a-vue-loader-template"}!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/cache-loader/dist/cjs.js??ref--0-0!C:/Users/dexte/go/src/github.com/Monibuca/plugin-webrtc/ui/node_modules/vue-loader/lib??vue-loader-options!./src/components/Player.vue?vue&type=template&id=70987c50&scoped=true&
|
||||
var Playervue_type_template_id_70987c50_scoped_true_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Modal',_vm._g(_vm._b({attrs:{"draggable":"","title":_vm.streamPath},on:{"on-ok":_vm.onClosePreview,"on-cancel":_vm.onClosePreview}},'Modal',_vm.$attrs,false),_vm.$listeners),[_c('div',{staticClass:"container"},[_c('video',{ref:"webrtc",attrs:{"width":"488","height":"275","autoplay":"","muted":"","controls":""},domProps:{"srcObject":_vm.stream,"muted":true}}),_c('div',{staticClass:"control"},_vm._l((4),function(n){return _c('svg',{class:'arrow'+n,attrs:{"viewBox":"0 0 1024 1024","version":"1.1","xmlns":"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","width":"64","height":"64"},on:{"click":function($event){return _vm.$emit('ptz',n)}}},[_c('defs'),_c('path',{attrs:{"d":"M682.666667 955.733333H341.333333a17.066667 17.066667 0 0 1-17.066666-17.066666V529.066667H85.333333a17.066667 17.066667 0 0 1-12.066133-29.1328l426.666667-426.666667a17.0496 17.0496 0 0 1 24.132266 0l426.666667 426.666667A17.066667 17.066667 0 0 1 938.666667 529.066667H699.733333v409.6a17.066667 17.066667 0 0 1-17.066666 17.066666z m-324.266667-34.133333h307.2V512a17.066667 17.066667 0 0 1 17.066667-17.066667h214.801066L512 109.4656 126.532267 494.933333H341.333333a17.066667 17.066667 0 0 1 17.066667 17.066667v409.6z","p-id":"6849"}})])}),0)]),_c('div',{attrs:{"slot":"footer"},slot:"footer"},[(_vm.remoteSDP)?_c('mu-badge',[_c('a',{attrs:{"slot":"content","href":_vm.remoteSDPURL,"download":"remoteSDP.txt"},slot:"content"},[_vm._v("remoteSDP")])]):_vm._e(),(_vm.localSDP)?_c('mu-badge',[_c('a',{attrs:{"slot":"content","href":_vm.localSDPURL,"download":"localSDP.txt"},slot:"content"},[_vm._v("localSDP")])]):_vm._e()],1)])}
|
||||
@@ -492,7 +492,7 @@ var component = normalizeComponent(
|
||||
channel:this.context.channel,
|
||||
ptzcmd: "A50F0100000000B5",
|
||||
});
|
||||
},1000)
|
||||
},500)
|
||||
});
|
||||
},
|
||||
invite(id, channel,item) {
|
||||
|
||||
2
ui/dist/plugin-gb28181.umd.js.map
vendored
2
ui/dist/plugin-gb28181.umd.js.map
vendored
File diff suppressed because one or more lines are too long
2
ui/dist/plugin-gb28181.umd.min.js
vendored
2
ui/dist/plugin-gb28181.umd.min.js
vendored
File diff suppressed because one or more lines are too long
2
ui/dist/plugin-gb28181.umd.min.js.map
vendored
2
ui/dist/plugin-gb28181.umd.min.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -107,7 +107,7 @@ export default {
|
||||
channel:this.context.channel,
|
||||
ptzcmd: "A50F0100000000B5",
|
||||
});
|
||||
},1000)
|
||||
},500)
|
||||
});
|
||||
},
|
||||
invite(id, channel,item) {
|
||||
|
||||
Reference in New Issue
Block a user