增加rdp协议声音输出功能
This commit is contained in:
@ -111,7 +111,7 @@ func CloseSessionById(sessionId string, code int, reason string) {
|
||||
defer mutex.Unlock()
|
||||
observable, _ := global.Store.Get(sessionId)
|
||||
if observable != nil {
|
||||
logrus.Debugf("会话%v创建者退出", sessionId)
|
||||
logrus.Debugf("会话%v创建者退出,原因:%v", sessionId, reason)
|
||||
observable.Subject.Close(code, reason)
|
||||
|
||||
for i := 0; i < len(observable.Observers); i++ {
|
||||
|
@ -201,6 +201,9 @@ func TunEndpoint(c echo.Context) error {
|
||||
}
|
||||
break
|
||||
}
|
||||
if len(instruction) == 0 {
|
||||
continue
|
||||
}
|
||||
err = ws.WriteMessage(websocket.TextMessage, instruction)
|
||||
if err != nil {
|
||||
if connectionId == "" {
|
||||
|
@ -153,13 +153,13 @@ func NewTunnel(address string, config Configuration) (ret *Tunnel, err error) {
|
||||
if err := ret.WriteInstructionAndFlush(NewInstruction("size", width, height, dpi)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := ret.WriteInstructionAndFlush(NewInstruction("audio")); err != nil {
|
||||
if err := ret.WriteInstructionAndFlush(NewInstruction("audio", "audio/L8", "audio/L16")); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := ret.WriteInstructionAndFlush(NewInstruction("video")); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := ret.WriteInstructionAndFlush(NewInstruction("image")); err != nil {
|
||||
if err := ret.WriteInstructionAndFlush(NewInstruction("image", "image/jpeg", "image/png", "image/webp")); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := ret.WriteInstructionAndFlush(NewInstruction("timezone", "Asia/Shanghai")); err != nil {
|
||||
@ -209,7 +209,7 @@ func (opt *Tunnel) WriteInstruction(instruction Instruction) error {
|
||||
}
|
||||
|
||||
func (opt *Tunnel) WriteAndFlush(p []byte) (int, error) {
|
||||
//fmt.Printf("-> %v \n", string(p))
|
||||
//fmt.Printf("-> %v\n", string(p))
|
||||
nn, err := opt.rw.Write(p)
|
||||
if err != nil {
|
||||
return nn, err
|
||||
@ -246,7 +246,14 @@ func (opt *Tunnel) ReadInstruction() (instruction Instruction, err error) {
|
||||
func (opt *Tunnel) Read() (p []byte, err error) {
|
||||
p, err = opt.rw.ReadBytes(Delimiter)
|
||||
//fmt.Printf("<- %v \n", string(p))
|
||||
return
|
||||
s := string(p)
|
||||
if s == "rate=44100,channels=2;" {
|
||||
return make([]byte, 0), nil
|
||||
}
|
||||
if s == "5.audio,1.1,31.audio/L16;" {
|
||||
s += "rate=44100,channels=2;"
|
||||
}
|
||||
return []byte(s), err
|
||||
}
|
||||
|
||||
func (opt *Tunnel) expect(opcode string) (instruction Instruction, err error) {
|
||||
|
Reference in New Issue
Block a user