-
Notifications
You must be signed in to change notification settings - Fork 86
/
response_preset.go
54 lines (46 loc) · 1.91 KB
/
response_preset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// Copyright (c) 2018- yutopp ([email protected])
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
package rtmp
import (
"github.com/yutopp/go-rtmp/message"
)
// ResponsePreset is an interface to provider server info.
// Users of go-rtmp can obfuscate this information by modifying RPreset field of ConnConfig.
type ResponsePreset interface {
GetServerConnectResultProperties() message.NetConnectionConnectResultProperties
GetServerConnectResultData() map[string]interface{}
}
// DefaultResponsePreset gives a default ServerInfo.
type DefaultResponsePreset struct {
ServerConnectResultProperties message.NetConnectionConnectResultProperties
ServerConnectResultData map[string]interface{}
}
// NewDefaultResponsePreset gives an instance of DefaultResponsePreset
func NewDefaultResponsePreset() *DefaultResponsePreset {
return &DefaultResponsePreset{
// Sent to clients as result when Connect message is received
ServerConnectResultProperties: message.NetConnectionConnectResultProperties{
FMSVer: "GO-RTMP/0,0,0,0", // TODO: fix
Capabilities: 31, // TODO: fix
Mode: 1, // TODO: fix
},
// Sent to clients as result when Connect message is received
ServerConnectResultData: map[string]interface{}{
"type": "go-rtmp",
"version": "master", // TODO: fix
},
}
}
// GetServerConnectResultProperties returns ServerConnectResultProperties.
func (r *DefaultResponsePreset) GetServerConnectResultProperties() message.NetConnectionConnectResultProperties {
return r.ServerConnectResultProperties
}
// GetServerConnectResultData returns ServerConnectResultData.
func (r *DefaultResponsePreset) GetServerConnectResultData() map[string]interface{} {
return r.ServerConnectResultData
}
var defaultResponsePreset ResponsePreset = NewDefaultResponsePreset()