add .gitreview
[src/app-framework-binder.git] / doc / afb-plugins-overview.md
1 Overview of plugins shipped with AFB-Daemon
2 ===========================================
3     Version: 1
4     Date:    09 juin 2016
5     Author:  Manuel Bachmann
6
7
8 List of plugins
9 ---------------
10
11 Here are the plugins shipped in the source tree:
12
13 * Hello World
14 * Authentication
15 * Tic Tac Toe
16 * Audio _(2 backends: ALSA/PulseAudio)_
17 * Radio _(1 backend: RTLSDR RTL2832U)_
18 * Media _(1 backend: Rygel UPnP)_
19
20 All plugins may not be built, depending on the development libraries present on the system at build time.
21
22
23 Detail of plugins
24 -----------------
25
26 ### Hello World
27
28 A sample Hello World plugin for demonstration and learning purposes.
29
30 This plugin provides a few unauthenticated requests, all beginning with "ping", to demonstrate basic binder capabilities.
31
32 **Verbs**:
33
34 * _ping:_ returns a success response
35 * _pingfail:_ returns a failure response
36 * _pingnull:_ returns a success response, with an empty JSON response field
37 * _pingbug:_ does a memory violation (intercepted by the binder)
38 * _pingJson:_ returns a success response, with a complex JSON response field
39 * _pingevent:_ broadcasts a global event
40
41 <br />
42
43
44 ### Authentication
45
46 An sample Authentication plugin for demonstration purposes.
47
48 This plugin provides a few requests to demonstrate the binder's token-based security mechanism.
49
50 Calling "_connect_" with a security token will initiate a session, calling "_refresh_" will issue a new token and invalidate the previous one, calling "_logout_" will invalidate all tokens and close the session.
51
52 **Verbs**:
53
54 * _ping:_ returns a success response
55 * _connect:_ creates a session and returns a new token
56 * _refresh:_ returns a new token
57 * _check:_ verifies the passed token is valid
58 * _logout:_ closes the session
59
60 <br />
61
62
63 ### Tic Tac Toe
64
65 A sample Tic Tac Toe game plugin.
66
67 This plugin provides an interactive Tic Tac Toe game where the binder returns the grid as a JSON response. 
68
69 **Verbs**:
70
71 * _new:_ starts a new game
72 * _play:_ asks the server to play
73 * _move:_ gives a client move
74 * _board:_ gets the current board state, as a JSON structure
75 * _level_: sets the server level
76 * _join_: joins an existing board
77 * _undo_: undo the last move
78 * _wait_: wait for a move
79
80 <br />
81
82
83 ### Audio
84
85 A sample Audio plugin with 2 backends:
86
87 * ALSA (mandatory)
88 * PulseAudio (optional)
89
90 This plugin is able to initialize a specific soundcard, define volume levels, channels (mono/stereo...), mute sound, and play a 22,050 Hz PCM stream.
91
92 **Verbs**:
93
94 * _ping:_ returns a success response
95 * _init:_ initializes backend, on the "default" sound card
96 * _volume:_ gets or sets volume, in % (0-100)
97 * _channels:_ gets or sets channels count (1-8)
98 * _mute:_ gets or sets the mute status (on-off)
99 * _play_: gets or sets the playing status (on-off)
100
101 _(if PulseAudio development libraries are not found at build time, only ALSA will be available)_
102
103 _(if a PulseAudio server is not found at runtime, the plugin will dynamically fall back to ALSA)_
104
105 _(a specifc backend can be forced by using this syntax before running afb-daemon : **$ export AFB_AUDIO_OUTPUT=Alsa**)_
106
107 <br />
108
109
110 ### Radio
111
112 A sample AM/FM Radio plugin with 1 backend:
113
114 * RTLSDR - Realtek RTL2832U dongles (mandatory)
115
116 This plugin is able to initialize specific RTL2832U dongles, switch between AM/FM modes, define frequency, mute sound, and play sound (if combining with the **audio** plugin).
117
118 **Verbs**:
119
120 * _ping:_ returns a success response
121 * _init:_ initializes backend, looking for plugged-in devices
122 * _power:_ sets device power status (on-off)
123 * _mode:_ sets device reception mode (AM-FM)
124 * _freq:_ sets device frequency (in Hz)
125 * _mute_: sets device mute status (on-off)
126 * _play_: sets device playing status (on-off)
127
128 _(if rtlsdr development libraries are not found at build time, this plugin will not be built)_
129
130 <br />
131
132
133 ### Media
134
135 A sample Media Server plugin with 1 backend:
136
137  * Rygel
138
139 This plugin is able to detect a local Rygel UPnP media server, list audio files, select an audio file for playback, play/pause/seek in this file, upload an audio file to the server.
140
141 **Verbs**:
142
143 * _ping:_ returns a success response
144 * _init:_ initializes backend, looking for an active local UPnP server
145 * _list:_ returns list of audio files, as a JSON structure
146 * _select:_ select an audio files, by index number (001-...)
147 * _play:_ plays the currently selected audio file
148 * _stop:_ stops the currently selected audio file
149 * _pause:_ pauses the currently selected audio file
150 * _seek:_ seeks in the currently selected audio file, in seconds
151 * _upload:_ uploads an audio file, with a POST request
152
153 _(if GUPnP/GSSDP development libraries are not fund at build time, this plugin will not be built)_
154
155 <br />
156
157
158 ---
159 <br />
160
161 Sample command-line applications: _afb-client-demo_ (built by default)
162
163 Sample HTML5 applications: 
164 **test/*.html**, 
165 **[afb-client](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/app-framework-demo.git;a=tree)**, 
166 **[afb-radio](https://github.com/iotbzh/afb-radio)**
167
168 Sample Qt/QML applications: *test/token-websock.qml*