-
Notifications
You must be signed in to change notification settings - Fork 2
/
video_proxy.go
134 lines (123 loc) · 4.12 KB
/
video_proxy.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Package main contains a generated proxy
// .
package main
import (
"bytes"
"context"
"fmt"
bus "github.com/lugu/qiloop/bus"
basic "github.com/lugu/qiloop/type/basic"
value "github.com/lugu/qiloop/type/value"
)
// ALVideoDeviceProxy represents a proxy object to the service
type ALVideoDeviceProxy interface {
SubscribeCamera(name string, cameraIndex int32, resolution int32, colorSpace int32, fps int32) (string, error)
GetImageRemote(name string) (value.Value, error)
Unsubscribe(nameId string) (bool, error)
// Generic methods shared by all objectsProxy
bus.ObjectProxy
// WithContext can be used cancellation and timeout
WithContext(ctx context.Context) ALVideoDeviceProxy
}
// proxyALVideoDevice implements ALVideoDeviceProxy
type proxyALVideoDevice struct {
bus.ObjectProxy
session bus.Session
}
// MakeALVideoDevice returns a specialized proxy.
func MakeALVideoDevice(sess bus.Session, proxy bus.Proxy) ALVideoDeviceProxy {
return &proxyALVideoDevice{bus.MakeObject(proxy), sess}
}
// ALVideoDevice returns a proxy to a remote service
func ALVideoDevice(session bus.Session) (ALVideoDeviceProxy, error) {
proxy, err := session.Proxy("ALVideoDevice", 1)
if err != nil {
return nil, fmt.Errorf("contact service: %s", err)
}
return MakeALVideoDevice(session, proxy), nil
}
// WithContext bound future calls to the context deadline and cancellation
func (p *proxyALVideoDevice) WithContext(ctx context.Context) ALVideoDeviceProxy {
return MakeALVideoDevice(p.session, p.Proxy().WithContext(ctx))
}
// SubscribeCamera calls the remote procedure
func (p *proxyALVideoDevice) SubscribeCamera(name string, cameraIndex int32, resolution int32, colorSpace int32, fps int32) (string, error) {
var err error
var ret string
var buf bytes.Buffer
if err = basic.WriteString(name, &buf); err != nil {
return ret, fmt.Errorf("serialize name: %s", err)
}
if err = basic.WriteInt32(cameraIndex, &buf); err != nil {
return ret, fmt.Errorf("serialize cameraIndex: %s", err)
}
if err = basic.WriteInt32(resolution, &buf); err != nil {
return ret, fmt.Errorf("serialize resolution: %s", err)
}
if err = basic.WriteInt32(colorSpace, &buf); err != nil {
return ret, fmt.Errorf("serialize colorSpace: %s", err)
}
if err = basic.WriteInt32(fps, &buf); err != nil {
return ret, fmt.Errorf("serialize fps: %s", err)
}
methodID, _, err := p.Proxy().MetaObject().MethodID("subscribeCamera", "(siiii)")
if err != nil {
return ret, err
}
response, err := p.Proxy().CallID(methodID, buf.Bytes())
if err != nil {
return ret, fmt.Errorf("call subscribeCamera failed: %s", err)
}
resp := bytes.NewBuffer(response)
ret, err = basic.ReadString(resp)
if err != nil {
return ret, fmt.Errorf("parse subscribeCamera response: %s", err)
}
return ret, nil
}
// GetImageRemote calls the remote procedure
func (p *proxyALVideoDevice) GetImageRemote(name string) (value.Value, error) {
var err error
var ret value.Value
var buf bytes.Buffer
if err = basic.WriteString(name, &buf); err != nil {
return ret, fmt.Errorf("serialize name: %s", err)
}
methodID, _, err := p.Proxy().MetaObject().MethodID("getImageRemote", "(s)")
if err != nil {
return ret, err
}
response, err := p.Proxy().CallID(methodID, buf.Bytes())
if err != nil {
return ret, fmt.Errorf("call getImageRemote failed: %s", err)
}
resp := bytes.NewBuffer(response)
ret, err = value.NewValue(resp)
if err != nil {
return ret, fmt.Errorf("parse getImageRemote response: %s", err)
}
return ret, nil
}
// Unsubscribe calls the remote procedure
func (p *proxyALVideoDevice) Unsubscribe(nameId string) (bool, error) {
var err error
var ret bool
var buf bytes.Buffer
if err = basic.WriteString(nameId, &buf); err != nil {
return ret, fmt.Errorf("serialize nameId: %s", err)
}
methodID, _, err := p.Proxy().MetaObject().MethodID("unsubscribe", "(s)")
if err != nil {
return ret, err
}
response, err := p.Proxy().CallID(methodID, buf.Bytes())
if err != nil {
return ret, fmt.Errorf("call unsubscribe failed: %s", err)
}
resp := bytes.NewBuffer(response)
ret, err = basic.ReadBool(resp)
if err != nil {
return ret, fmt.Errorf("parse unsubscribe response: %s", err)
}
return ret, nil
}