Project

General

Profile

Htsp » History » Version 98

Jaroslav Kysela, 2014-10-19 21:03

1 75 Adam Sutton
h1. Home Tv Streaming Protocol (HTSP) - Version 10
2 1 Andreas Smas
3
h2. General
4 58 sbi -
5
HTSP is a TCP based protocol primarily intended for streaming of live TV and related meta data such as channels, group of channels (called tags in HTSP) and electronic program guide (EPG) information.
6
7 61 Adam Sutton
The transmission and reception of a channel over HTSP is referred to as a subscription. A single HTSP session can handle as many concurrent subscriptions as the bandwidth and CPU permits.
8 1 Andreas Smas
9 61 Adam Sutton
The HTSP server in tvheadend has a payload-aware scheduler for prioritizing more important packets (such as I-frames) before less important ones (such as B-frames). This makes HTSP suitable for long-distance transmissions and/or paths with non-perfect delivery.
10 1 Andreas Smas
(It has been tested with a server in Stockholm and the client in Berlin).
11
12 17 Andreas Smas
For information about the HTSP wire format please read [[htsmsgbinary|HTSMSG binary format]]
13 1 Andreas Smas
14 61 Adam Sutton
If you're looking to develop a new client, there are several existing client implementations from which you might be able to gain knowledge:
15
16
* "XBMC":https://github.com/opdenkamp/xbmc/tree/master/xbmc/pvrclients/tvheadend
17
* "Showtime":https://github.com/andoma/showtime/tree/master/src/backend/htsp
18 65 John Törnblom
* "TVHGuide":https://github.com/john-tornblom/TVHGuide
19 69 Adam Sutton
* "PyHTSP":https://github.com/adamsutton/tvheadend/tree/master/lib/py/tvh/htsp.py (This is a demo client and is WIP, it has limited functionality).
20 1 Andreas Smas
21 22 Andreas Smas
----
22 18 Andreas Smas
23 84 Jaroslav Kysela
h2. Protocol Changes
24 83 Jaroslav Kysela
25 85 Jaroslav Kysela
h3. v12..v13
26
27
* added addAutorecEntry method
28
* added deleteAutorecEntry method
29 92 Jaroslav Kysela
* added autorecEntryAdd, autorecEntryUpdate, autorecEntryDelete server-to-client methods
30 85 Jaroslav Kysela
* extended channelAdd server-to-client method
31 87 Jaroslav Kysela
** added channelNumberMinor (for {major}.{minor} channel numbers)
32
* extended dvrEntryAdd and dvrEntryUpdate server-to-client methods
33 88 Jaroslav Kysela
** added eventId, autorecId, startExtra, stopExtra, retention, priority, contentType fields
34 97 Jaroslav Kysela
* extended addDvrEntry method
35
** added retention
36
* extended updateDvrEntry method
37
** added retention, priority
38
* extended epgQuery method
39
** added minduration, maxduration
40 85 Jaroslav Kysela
* added subscriptionGrace server-to-client method
41 97 Jaroslav Kysela
42 85 Jaroslav Kysela
43 83 Jaroslav Kysela
h3. v11..v12
44
45
* added subscriptionFilterStream method
46
* added getDvrCutpoints method
47
48
49
h3. v10..v11
50
51 86 Jaroslav Kysela
* added audio_type in the subscriptionStart server-to-client method
52 83 Jaroslav Kysela
* added getCodecs method
53
54 58 sbi -
h2. Communication
55
56
57 69 Adam Sutton
This communication is currently implemented by using htsmsg's. All strings are encoded as UTF-8.
58 1 Andreas Smas
59
There are two distinct ways for communication within HTSP.
60
61 28 Andreas Smas
Apart from this there is a number of messages that needs to be exchanged during login, see the login section below.
62
63 1 Andreas Smas
64 58 sbi -
h3. RPC communication
65
66
67 1 Andreas Smas
There is a normal RPC way of doing things. I.e. the client sends a request and the server responds with a reply. All the RPC methods are listed below as the 'Client to Server' methods. Apart from all message fields listed within each message type the client can add an additional field:
68 18 Andreas Smas
69 17 Andreas Smas
RPC request extra fields:
70 58 sbi -
<pre>
71 28 Andreas Smas
seq              int  optional   Sequence number. This field will be echoed back by the server in the reply.
72 1 Andreas Smas
username         str  optional   Username, in combination with 'digest' this can be used to raise the privileges
73
                                 for the session in combination with invocation of a method. 
74 28 Andreas Smas
digest           bin  optional   Used to raise privileges.
75 58 sbi -
</pre>
76 18 Andreas Smas
77 1 Andreas Smas
The followings field should be used by the client to match the reply with the request.
78
All replies are guaranteed to arrive in the same order as the requests.
79
Even so, probably the best way to implement the request-reply client is by taking advantage of the 'seq' field.
80
81
RPC reply extra fields:
82 58 sbi -
<pre>
83 18 Andreas Smas
seq              int  optional   Sequence number. Same as in the request.
84 19 Andreas Smas
error            str  optional   If present an error has occurred and the text describes the error.
85
noaccess         int  optional   If present and set to '1' the user is prohibited from invoking the method due to 
86 1 Andreas Smas
                                 access restrictions. 
87 58 sbi -
</pre>
88 1 Andreas Smas
89 18 Andreas Smas
90 58 sbi -
h3. Streaming communication
91
92
93 19 Andreas Smas
For streaming of live TV and various related messages the server will continuously push data to the client.
94 1 Andreas Smas
These messages are referred to as asynchronous messages and always have the 'method' field set and never have the 'seq' field set.
95
Also, the client can enable an additional asyncMetadata mode and by doing so it will be notified by the server when meta data changes. (EPG updates, creation of channels and tags, etc). 
96
97 34 Andreas Smas
98 58 sbi -
h3. Authentication
99
100
101 29 Andreas Smas
In Tvheadend, each method has an associated access restriction. Currently there is only one restriction (Streaming). However, this may change in the future.
102 1 Andreas Smas
103
Privileges for these restrictions may be granted in two ways: Username + Password and/or Source IP address.
104
Therefore it is possible to gain permissions to the system without entering a username and password.
105
While this is really useful it also complicates the authentication schema a bit.
106
Upon connect the initial privileges will be raised based on the source address.
107
108
Before any username / password based authentication has taken place the client must have
109 34 Andreas Smas
obtained a challenge (which stays fixed for the session). This is done via the 'hello' method.
110 1 Andreas Smas
111
In principle it's possible to use two different authentication idioms with HTSP.
112
Depending on how your application works one or another may be more suitable.
113
While they do not really differ from a protocol point of view it's worth mentioning a bit about them here:
114
115
116 58 sbi -
h3. Initial login authentication
117
118
119 1 Andreas Smas
The client performs all of its authentication using the 'login' method.
120
121
It may choose to send:
122 58 sbi -
* Username and password: Privileges will be raised based on these credentials.
123
* Username only: Privileges will be based on just the source address. The username will be used for various logging purposes.
124
* Nothing: Privileges will be based on just the source address.
125 1 Andreas Smas
126
If no privileges are granted after the login message has been received by the server (i.e. both network and username + password based)
127
the server will reply with 'noaccess' set to 1. A client that only employs initial login should honor this flag and ask the
128
user for a username + password and retry by using the 'authenticate' method. I.e. it should not send the 'login' method again.
129
130
131 58 sbi -
h3. On-demand authentication
132
133
134 1 Andreas Smas
The client performs all of its authentication when it needs to.
135
136
When using this method, the client will check every RPC reply for the 'noaccess' field.
137
If it set to 1 it whould ask the user for username + password and retry the request but also
138 58 sbi -
add 'username' and 'digest' to the original message. (See _RPC request extra fields_ above)
139 1 Andreas Smas
140
Typically it would not send a username or digest during login.
141 29 Andreas Smas
142
----
143 34 Andreas Smas
144 66 Adam Sutton
h2. Client to Server (RPC) methods
145 34 Andreas Smas
146
h3. hello
147 58 sbi -
148
Used to identify the client toward the server and to get the session challenge used to
149 1 Andreas Smas
hash passwords into digests. The client can request a different version of the HTSP
150 66 Adam Sutton
protocol with this method. If no 'hello' message is sent the server assumes latest version
151 1 Andreas Smas
is to be used.
152 34 Andreas Smas
153 66 Adam Sutton
Client/Server should select lowest common version, if this is not possible connection should be terminated.
154 1 Andreas Smas
155
Request message fields:
156
<pre>
157 66 Adam Sutton
htspversion        u32   required   Client preferred HTSP version.
158
clientname         str   required   Client software name.
159
clientversion      str   required   Client software version.
160 58 sbi -
</pre>
161 1 Andreas Smas
162
Reply message fields:
163 34 Andreas Smas
<pre>
164 66 Adam Sutton
htspversion        u32   required   The server supports all versions of the protocol up to and including this number.
165
servername         str   required   Server software name.
166
serverversion      str   required   Server software version.
167
servercapability   str[] required   Server capabilities (Added in version 6)
168 1 Andreas Smas
challenge          bin   required   32 bytes randomized data used to generate authentication digests
169 73 Adam Sutton
webroot            str   optional   Server HTTP webroot (Added in version 8)
170
                                    Note: any access to TVH webserver should include this at start of URL path
171 1 Andreas Smas
</pre>
172
173 70 Adam Sutton
Note: possible values for servercapability[]:
174
<pre>
175
cwc                Descrambling available
176
v4l                Analogue TV available
177
linuxdvb           Linux DVB API available
178 1 Andreas Smas
imagecache         Image caching available
179 73 Adam Sutton
timeshift          Timeshifting available (Added in version 9).
180 70 Adam Sutton
</pre>
181
182 58 sbi -
h3. authenticate
183 1 Andreas Smas
184
This can be used to issue authentication without doing anything else.
185
If no privileges are gained it will return with 'noaccess' set to 1.
186
187 33 Andreas Smas
Request message fields:
188 1 Andreas Smas
<pre>
189 66 Adam Sutton
None   
190 33 Andreas Smas
</pre>
191 58 sbi -
192
Reply message fields:
193
<pre>
194 66 Adam Sutton
noaccess           u32   optional   If set to 1, no privileges were granted.
195 33 Andreas Smas
</pre>
196 1 Andreas Smas
197
----
198
199 66 Adam Sutton
h3. getDiskSpace (Added in version 3)
200 58 sbi -
201 66 Adam Sutton
Return diskspace status from Tvheadend's PVR storage
202 1 Andreas Smas
203 66 Adam Sutton
Request message fields:
204
<pre>
205
None
206
</pre>
207 1 Andreas Smas
208 66 Adam Sutton
Reply message fields:
209
<pre>
210
freediskspace      s64   required   Bytes available.
211
totaldiskspace     s64   required   Total capacity.
212
</pre>
213 1 Andreas Smas
214 66 Adam Sutton
h3. getSysTime (Added in version 3)
215 1 Andreas Smas
216 66 Adam Sutton
Return system time on the server.
217
218 1 Andreas Smas
Request message fields:
219
<pre>
220
None
221
</pre>
222
223
Reply message fields:
224 58 sbi -
<pre>
225 66 Adam Sutton
time               s64  required   UNIX time.
226
timezone           s32  required   Minutes west of GMT.
227 1 Andreas Smas
</pre>
228 23 Andreas Smas
229 1 Andreas Smas
----
230
231 66 Adam Sutton
h3. enableAsyncMetadata
232 1 Andreas Smas
233 66 Adam Sutton
When this is enabled the client will get continuous updates from the server about added, update or deleted channels, tags, dvr and epg entries.
234 1 Andreas Smas
235 66 Adam Sutton
An interactive application that presents the user with information about these things should probably enable this and the implement the various server to client methods.
236 1 Andreas Smas
237
Request message fields:
238
<pre>
239 66 Adam Sutton
epg                u32   optional   Set to 1, to include EPG data in async, implied by epgMaxTime (Added in version 6).
240
lastUpdate         s64   optional   Only provide metadata that has changed since this time (Added in version 6).
241
epgMaxTime         s64   optional   Maximum time to return EPG data up to (Added in version 6)
242
language           str   optional   RFC 2616 compatible language list (Added in version 6)
243 1 Andreas Smas
</pre>
244
245
Reply message fields:
246
<pre>
247 66 Adam Sutton
None
248 1 Andreas Smas
</pre>
249
250 66 Adam Sutton
Once the reply as been sent the initial data set will be provided, and then updates will arrive asynchronously after that. The initial data dump is sent using the following messages:
251 1 Andreas Smas
252 66 Adam Sutton
<pre>
253
tagAdd                   optional
254
channelAdd               optional
255
tagUpdate                optional
256
dvrEntryAdd              optional
257
eventAdd                 optional   (Added in version 6)
258
initialSyncComplete      required
259
</pre>
260 1 Andreas Smas
261 66 Adam Sutton
----
262 1 Andreas Smas
263 66 Adam Sutton
h3. getEvent
264 1 Andreas Smas
265 66 Adam Sutton
Request information about the given event. An event typically corresponds to a program on a channel.
266 1 Andreas Smas
267 66 Adam Sutton
The language field in the request allows preference for languages to be requested for the various string fields.
268
269 1 Andreas Smas
Request message fields:
270 45 mdd -
<pre>
271 66 Adam Sutton
eventId            u32   required   Event ID.
272
language           str   optional   RFC 2616 compatible language list (Added in version 6)
273 1 Andreas Smas
</pre>
274
275
Reply message fields:
276
<pre>
277 66 Adam Sutton
see eventAdd
278 1 Andreas Smas
</pre>
279
280 66 Adam Sutton
h3. getEvents (Added in version 4)
281 1 Andreas Smas
282 66 Adam Sutton
Request information about a set of events. If no options are specified the entire EPG database will be returned.
283 57 sbi -
284 58 sbi -
Request message fields:
285 1 Andreas Smas
<pre>
286 66 Adam Sutton
eventId            u32   optional   Event ID to begin from (Optional since version 6)
287
channelId          u32   optional   Channel ID to get data for (Added in version 6)
288
numFollowing       u32   optional   Number of events to add (Optional since version 6)
289
maxTime            u64   optional   Maximum time to return data up to (Added in version 6)
290
language           str   optional   RFC 2616 compatible language list (Added in version 6)
291 1 Andreas Smas
</pre>
292
293
Reply message fields:
294
<pre>
295 66 Adam Sutton
events             msg[] required   List of events, using response message fields from eventAdd
296 1 Andreas Smas
</pre>
297 45 mdd -
298 66 Adam Sutton
h3. epgQuery (Added in version 4)
299 1 Andreas Smas
300 66 Adam Sutton
Query the EPG (event titles) and optionally restrict to channel/tag/content type.
301 1 Andreas Smas
302 66 Adam Sutton
Request message fields:
303
<pre>
304
query              str   required  Title regular expression to search for
305
channelId          u32   optional  [[ChannelId]] to restrict search to
306
tagId              u32   optional  [[TagId]] to restrict search to
307
contentType        u32   optional  DVB content type to restrict search to
308 98 Jaroslav Kysela
minduration        u32   optional  Minimal duration in seconds (Added in version 13)
309
maxduration        u32   optional  Maximal duration in seconds (Added in version 13)
310 66 Adam Sutton
language           str   optional  RFC 2616 compatible language list for title (Added in version 6)
311
full               u32   optional  Output full event list rather than just IDs
312
</pre>
313 1 Andreas Smas
314 66 Adam Sutton
Reply message fields:
315 1 Andreas Smas
316 66 Adam Sutton
if full == 1
317
<pre>
318
events             msg[] optional   List of events, using response message fields from eventAdd
319
</pre>
320
else
321
<pre>
322
eventIds           u32[] optional  List of eventIds that match the query
323
</pre>
324 1 Andreas Smas
325 66 Adam Sutton
h3. getEpgObject
326
327
Get detailed EPG Object info.
328
329 58 sbi -
Request message fields:
330 1 Andreas Smas
<pre>
331 66 Adam Sutton
id                 u32   required  Object ID
332
type               u32   optional  Object type
333 1 Andreas Smas
</pre>
334 58 sbi -
335 1 Andreas Smas
Reply message fields:
336 66 Adam Sutton
337 1 Andreas Smas
<pre>
338 66 Adam Sutton
TODO
339 1 Andreas Smas
</pre>
340
341 58 sbi -
----
342 1 Andreas Smas
343 66 Adam Sutton
h3. addDvrEntry (Added in version 4)
344 1 Andreas Smas
345 66 Adam Sutton
Create a new DVR entry. Either eventId or channelId, start and stop must be specified.
346 1 Andreas Smas
347
Request message fields:
348
<pre>
349 66 Adam Sutton
eventId            u32   optional   Event ID (Optional since version 5).
350
channelId          u32   optional   Channel ID (Added in version 5)
351
start              s64   optional   Time to start recording (Added in version 5)
352
stop               s64   optional   Time to stop recording (Added in version 5)
353 96 Jaroslav Kysela
retention          u32   optional   Retention time in days (Added in version 13)
354 66 Adam Sutton
creator            str   optional   Name of the event creator (Added in version 5)
355
priority           u32   optional   Recording priority (Added in version 5)
356
startExtra         s64   optional   Pre-recording buffer in minutes (Added in version 5)
357
stopExtra          s64   optional   Post-recording buffer in minutes (Added in version 5)
358
title              str   optional   Recording title, if no eventId (Added in version 6)
359
description        str   optional   Recording description, if no eventId (Added in version 5)
360
configName         str   optional   DVR configuration name
361 40 Andreas Smas
</pre>
362 1 Andreas Smas
363
Reply message fields:
364
<pre>
365 66 Adam Sutton
success            u32   required   1 if entry was added, 0 otherwise
366
id                 u32   optional   ID of created DVR entry
367
error              str   optional   English clear text of error message
368 1 Andreas Smas
</pre>
369
370 66 Adam Sutton
h3. updateDvrEntry (Added in version 5)
371 1 Andreas Smas
372 66 Adam Sutton
Update an existing DVR entry.
373 1 Andreas Smas
374
Request message fields:
375
<pre>
376 66 Adam Sutton
id                 u32   required   DVR Entry ID
377
start              s64   optional   New start time
378
stop               s64   optional   New stop time
379
title              str   optional   New entry title
380
description        str   optional   New entry description (Added in version 6)
381
startExtra         s64   optional   New pre-record buffer (Added in version 6)
382
stopExtra          s64   optional   New post-record buffer (Added in version 6)
383
configName         str   optional   New DVR configuration name
384 1 Andreas Smas
</pre>
385
386
Reply message fields:
387
<pre>
388 66 Adam Sutton
success            u32   required   1 if update as successful, otherwise 0
389
error              str   optional   Error message if update failed
390 40 Andreas Smas
</pre>
391
392 66 Adam Sutton
h3. cancelDvrEntry (Added in version 5)
393 1 Andreas Smas
394 66 Adam Sutton
Cancel an existing recording, but don't remove the entry from the database.
395 1 Andreas Smas
396 66 Adam Sutton
Request message fields:
397
<pre>
398
id                 u32   required   dvrEnryId to delete
399
</pre>
400 1 Andreas Smas
401 66 Adam Sutton
Reply message fields:
402
<pre>
403
success            int   required   1 if entry was cancelled
404
error              str   optional   Error message if cancellation failed
405
</pre>
406 1 Andreas Smas
407 66 Adam Sutton
h3. deleteDvrEntry (Added in version 4)
408
409
Delete an existing DVR entry from the database.
410
411
Request message fields:
412 1 Andreas Smas
<pre>
413 66 Adam Sutton
id                 u32   required   DVR Entry ID
414 1 Andreas Smas
</pre>
415
416 11 Andreas Smas
Reply message fields:
417 1 Andreas Smas
<pre>
418 66 Adam Sutton
success            u32   required   1 if entry was removed
419
error              str   optional   Error message if the delete fails
420 1 Andreas Smas
</pre>
421
422 91 Jaroslav Kysela
h3. addAutorecEntry (Added in version 13)
423
424
Create a new Autorec DVR entry. Title must be specified.
425
426
Request message fields:
427
<pre>
428
title              str   required   Title for the recordings.
429
configName         str   optional   DVR Configuration Name / UUID.
430
channelId          u32   optional   Channel ID.
431
minDuration        u32   optional   Minimal duration in seconds (0 = Any).
432
maxDuration        u32   optional   Maximal duration in seconds (0 = Any).
433
daysOfWeek         u32   optional   Bitmask - Days of week (0x01 = Monday, 0x40 = Sunday, 0x7f = Whole Week, 0 = Not set).
434
priority           u32   optional   Priority (0 = Important, 1 = High, 2 = Normal, 3 = Low, 4 = Unimportant, 5 = Not set).
435
approxTime         u32   optional   Minutes from midnight (up to 24*60).
436
startExtra         s64   optional   Extra start minutes (pre-time).
437
stopExtra          s64   optional   Extra stop minutes (post-time).
438
comment            str   optional   User Comment.
439
</pre>
440
441
Reply message fields:
442
<pre>
443
success            u32   required   1 if entry was added, 0 otherwise
444 93 Jaroslav Kysela
id                 str   optional   ID (string!) of created autorec DVR entry
445 91 Jaroslav Kysela
error              str   optional   English clear text of error message
446
</pre>
447
448
h3. deleteAutorecEntry (Added in version 13)
449
450
Delete an existing autorec DVR entry from the database.
451
452
Request message fields:
453
<pre>
454 94 Jaroslav Kysela
id                 str   required   Autorec DVR Entry ID (string!)
455 91 Jaroslav Kysela
</pre>
456
457
Reply message fields:
458
<pre>
459
success            u32   required   1 if entry was removed
460
error              str   optional   Error message if the delete fails
461
</pre>
462
463 83 Jaroslav Kysela
h3. getDvrCutpoints (Added in version 12)
464
465
Get DVR cutpoints.
466
467
Request message fields:
468
<pre>
469
id                 u32   required   DVR Entry ID
470
</pre>
471
472
Reply message fields:
473
<pre>
474
cutpoints          msg[] optional   List of cutpoint entries, if a file is found and has some valid data.
475
</pre>
476
477
Cutpoint fields:
478
<pre>
479
start              u32   required   Cut start time in ms.
480
end                u32   required   Cut end time in ms.
481
type               u32   required   Action type: 
482
                                      0=Cut, 1=Mute, 2=Scene, 
483
                                      3=Commercial break.
484
</pre>
485
486 1 Andreas Smas
----
487
488 66 Adam Sutton
h3. getTicket (Added in version 5)
489 1 Andreas Smas
490 66 Adam Sutton
Get a ticket to allow access to a channel or recording via HTTP
491 1 Andreas Smas
492 66 Adam Sutton
Request message fields:
493 1 Andreas Smas
<pre>
494 66 Adam Sutton
channelId          u32  optional   Channel to gain access for
495
dvrId              u32  optional   DVR file to gain access for
496 1 Andreas Smas
</pre>
497
498
Reply message fields:
499
<pre>
500 66 Adam Sutton
path               str  required   The full path for access URL (no scheme, host or port)
501
ticket             str  required   The ticket to pass in the URL query string
502 1 Andreas Smas
</pre>
503
504 66 Adam Sutton
h3. subscribe
505 1 Andreas Smas
506 66 Adam Sutton
Request subscription to the given channel. 
507 1 Andreas Smas
508 66 Adam Sutton
Request message fields:
509
<pre>
510
channelId          u32   required   ID for channel. 
511
subscriptionId     u32   required   Subscription ID. Selected by client. This value is not interpreted by the server in any form. 
512
                                    The value is used from now on in all messages related to the subscription.
513 1 Andreas Smas
weight             u32   optional   Weighting of this subscription (same as recording priority).
514 73 Adam Sutton
90khz              u32   optional   Request PTS/DTS in default 90kHz timebase, default is 1MHz (Added in version 7)
515
normts             u32   optional   Request PTS/DTS normalisation (Added in version 7)
516
                                    Note: this will mean missing timestamps are added, first packet should be ~0 and will always be an i-frame.
517
                                    Note: this is implied if timeshiftPeriod is enabled
518
queueDepth         u32   optional   Change the default packet queue lengths, default 500000 bytes (Added in version 7)
519
                                    Note: I-frame depth is 3*queueDepth, P-frame is 2*queueDepth and B-frame is queueDepth
520
timeshiftPeriod    u32   optional   The number of seconds to keep in the timeshift buffer (Added in version 9)
521
                                    Note: this may be bounded by server configuration settings
522 11 Andreas Smas
</pre>
523 66 Adam Sutton
524 1 Andreas Smas
Reply message fields:
525
<pre>
526 73 Adam Sutton
90khz              u32   optional   Indicates 90khz timestamps will be used
527
normts             u32   optional   Indicates timestamps will be normalised (and fixed)
528
timeshiftPeriod    u32   optional   The actual timeshiftPeriod to be used
529 66 Adam Sutton
</pre>
530 1 Andreas Smas
531 66 Adam Sutton
h3. unsubscribe
532
533
Stop a subscription.
534
535
Request message fields:
536 1 Andreas Smas
<pre>
537 66 Adam Sutton
subscriptionId     u32   required   Subscription ID.
538 58 sbi -
</pre>
539
540 11 Andreas Smas
Reply message fields:
541 1 Andreas Smas
<pre>
542 66 Adam Sutton
None
543 58 sbi -
</pre>
544 11 Andreas Smas
545 66 Adam Sutton
h3. subscriptionChangeWeight (Added in version 5)
546 1 Andreas Smas
547 66 Adam Sutton
Change the weight of an existing subscription
548 1 Andreas Smas
549 66 Adam Sutton
Request message fields:
550
<pre>
551
subscriptionId     u32   required   Subscription ID.
552
weight             u32   optional   The new subscription weight.
553 1 Andreas Smas
</pre>
554
555
Reply message fields:
556
<pre>
557 69 Adam Sutton
None
558 1 Andreas Smas
</pre>
559
560 73 Adam Sutton
h3. subscriptionSkip (Added in version 9)
561
562
Skip a timeshift enabled subscription. The response will be asynchronous subscriptionSkip().
563
564
Request message fields:
565
<pre>
566
subscriptionId     u32   required   Subscription ID.
567
absolute           u32   optional   The skip request is absolute
568
time               u64   optional   Specify skip using time (units are as for PTS)
569
size               u64   optional   Specify skip using size (Not currently used)
570
</pre>
571
572
Reply message fields:
573
<pre>
574
None
575
</pre>
576
577
h3. subscriptionSeek (Added in version 9)
578
579
Synonym for subscriptionSkip
580
581
h3. subscriptionSpeed (Added in version 9)
582
583
Set the playback speed for the subscription. The response will be asynchronous subscriptionSpeed().
584
585
Request message fields:
586
<pre>
587
subscriptionId     u32   required   Subscription ID.
588
speed              u32   required   Specify speed (0=pause, 100=1x fwd, -100=1x backward)
589
</pre>
590
591
Reply message fields:
592
<pre>
593
None
594
</pre>
595
596
h3. subscriptionLive (Added in version 9)
597
598
Return a timeshifted session to live. Reply will be asynchronous subscriptionSkip().
599
600
Request message fields:
601
<pre>
602
subscriptionId     u32   required   Subscription ID.
603
</pre>
604
605
Reply message fields:
606
<pre>
607
None
608 82 Jaroslav Kysela
</pre>
609 1 Andreas Smas
610 83 Jaroslav Kysela
h3. subscriptionFilterStream (Added in version 12)
611 1 Andreas Smas
612 83 Jaroslav Kysela
Enable or disable specified streams by index.
613
614
Request message fields:
615
<pre>
616
subscriptionId     u32        required   Subscription ID.
617
enable             list[u32]  optional   Enable stream indexes
618
disable            list[u32]  optional   Disable (filter out) stream indexes
619
</pre>
620
621
Reply message fields:
622
<pre>
623
None
624
</pre>
625
626
h3. getCodecs (Added in version 11, Removed in version 16)
627
628 82 Jaroslav Kysela
Return a list of encoders (codecs).
629
630 1 Andreas Smas
Reply message fields:
631 82 Jaroslav Kysela
<pre>
632 83 Jaroslav Kysela
encoders           list[str]  optional   Supported encoders
633 82 Jaroslav Kysela
</pre>
634
635 70 Adam Sutton
h3. fileOpen (Added in version 8)
636 69 Adam Sutton
637
Open a file within the Tvheadend file system. This is now the preferred method (in place of HTTP) for accessing recordings.
638
639
Accessing recordings via HTSP will overcome the limitations of standard HTTP streaming which cannot handle both skipping and growing files (i.e. in-progress recordings) at the same time.
640
641 1 Andreas Smas
Request message fields:
642 69 Adam Sutton
<pre>
643 70 Adam Sutton
file               str   required   File path to open
644 1 Andreas Smas
</pre>
645
646 70 Adam Sutton
Valid file paths:
647
<pre>
648
/dvrfile/ID        will open the file associated with DVR entry ID
649 74 Adam Sutton
/imagecache/ID     will open the file associated with imagecache entry ID (Note: only works for HTSPv10+)
650 70 Adam Sutton
</pre>
651
652 69 Adam Sutton
Reply message fields:
653
<pre>
654
id                 u32   required   The file handle used for further file operations
655
size               u64   optional   The size of the file in bytes
656 1 Andreas Smas
mtime              u64   optional   The last time the file was modified
657 69 Adam Sutton
</pre>
658
659 70 Adam Sutton
h3. fileRead (Added in version 8)
660 69 Adam Sutton
661 1 Andreas Smas
Read data from a file.
662
663 69 Adam Sutton
Request message fields:
664
<pre>
665
id                 u32   required   The file handle used for further file operations
666 70 Adam Sutton
size               u64   required   The amount of data to read
667
offset             u64   optional   Offset into the file to read (default is current position)
668 69 Adam Sutton
</pre>
669 1 Andreas Smas
670 69 Adam Sutton
Reply message fields:
671
<pre>
672
data               bin   required   The data read from the file (size may be less than requested)
673
</pre>
674
675 70 Adam Sutton
h3. fileClose (Added in version 8)
676 69 Adam Sutton
677
Close an opened file.
678
679
Request message fields:
680
<pre>
681 1 Andreas Smas
id                 u32   required   The file handle to be closed
682 69 Adam Sutton
</pre>
683
684
Reply message fields:
685
<pre>
686
None
687
</pre>
688 70 Adam Sutton
689 69 Adam Sutton
h3. fileStat (Added in version 8)
690
691
Get status of a file.
692
693
Request message fields:
694
<pre>
695
id                 u32   required   The file handle to be stat'd
696 1 Andreas Smas
</pre>
697
698
Reply message fields:
699
<pre>
700
size               u64   optional   The size of the file in bytes
701
mtime              u64   optional   The last time the file was modified
702
</pre>
703 70 Adam Sutton
704
h3. fileSeek (Added in version 8)
705
706
Seek to position in a file.
707
708
Request message fields:
709
<pre>
710
id                 u32   required   The file handle to be stat'd
711
offset             u64   required   The position to seek in the file
712
whence             str   required   Where to seek relative to (default=SEEK_SET)
713
</pre>
714
715
Note: valid values for whence
716
<pre>
717
SEEK_SET           Seek relative to start of file
718
SEEK_CUR           Seek relative to current position in file
719 72 Adam Sutton
SEEK_END           Seek relative (backwards) to end of file
720 70 Adam Sutton
</pre>
721
722
Reply message fields:
723
<pre>
724
offset             u64   optional   The new absolute position within the file
725
</pre>
726 66 Adam Sutton
727 1 Andreas Smas
h1. Server to Client methods
728
729
----
730
731
h3. channelAdd
732
733
A new channel has been created on the server.
734
735
Message fields:
736
<pre>
737
channelId          u32   required   ID of channel.
738 66 Adam Sutton
channelNumber      u32   required   Channel number, 0 means unconfigured.
739 90 Jaroslav Kysela
channelNumberMinor u32   optional   Minor channel number (Added in version 13).
740 1 Andreas Smas
channelName        str   required   Name of channel.
741 70 Adam Sutton
channelIcon        str   optional   URL to an icon representative for the channel
742
                                    (For v8+ clients this could be a relative /imagecache/ID URL
743 73 Adam Sutton
                                     intended to be fed to fileOpen() or HTTP server)
744 66 Adam Sutton
eventId            u32   optional   ID of the current event on this channel.
745
nextEventId        u32   optional   ID of the next event on the channel.
746
tags               u32[] optional   Tags this channel is mapped to.
747
services           msg[] optional   List of available services (Added in version 5)
748 13 Andreas Smas
</pre>
749 1 Andreas Smas
750 66 Adam Sutton
Service fields:
751 1 Andreas Smas
<pre>
752 66 Adam Sutton
name               str   required   Service name
753
type               str   required   Service type
754
caid               u32   optional   Encryption CA ID
755
caname             str   optional   Encryption CA name
756 11 Andreas Smas
</pre>
757 1 Andreas Smas
758 66 Adam Sutton
h3. channelUpdate
759 11 Andreas Smas
760 66 Adam Sutton
Same as channelAdd, but all fields (except channelId) are optional.
761
762 58 sbi -
h3. channelDelete
763 1 Andreas Smas
764
A channel has been deleted on the server.
765 58 sbi -
766
Message fields:
767 1 Andreas Smas
<pre>
768 66 Adam Sutton
channelId          u32   required   ID of channel.
769 1 Andreas Smas
</pre>
770
771
----
772
773
h3. tagAdd
774 11 Andreas Smas
775 1 Andreas Smas
A new tag has been created on the server.
776
777
Message fields:
778
<pre>
779 66 Adam Sutton
tagId              u32   required   ID of tag.
780
tagName            str   required   Name of tag.
781
tagIcon            str   optional   URL to an icon representative for the channel.
782
tagTitledIcon      u32   optional   Icon includes a title
783
members            u32[] optional   Channel IDs of those that belong to the tag
784 1 Andreas Smas
</pre>
785 11 Andreas Smas
786 39 elupus -
h3. tagUpdate
787 58 sbi -
788 66 Adam Sutton
Same as tagAdd, but all fields (except tagId) are optional.
789 11 Andreas Smas
790
h3. tagDelete
791 1 Andreas Smas
792 58 sbi -
A tag has been deleted from the server.
793 1 Andreas Smas
794
Message fields:
795
<pre>
796 66 Adam Sutton
tagId              u32   required   ID of tag.
797 58 sbi -
</pre>
798
799 12 Andreas Smas
----
800 1 Andreas Smas
801 66 Adam Sutton
h3. dvrEntryAdd (Added in version 4)
802 58 sbi -
803 1 Andreas Smas
A new recording has been created on the server.
804 58 sbi -
805 1 Andreas Smas
Message fields:
806 2 Andreas Smas
<pre>
807 66 Adam Sutton
id                 u32   required   ID of dvrEntry.
808
channel            u32   required   Channel of dvrEntry.
809
start              s64   required   Time of when this entry was scheduled to start recording.
810
stop               s64   required   Time of when this entry was scheduled to stop recording.
811 89 Jaroslav Kysela
startExtra         s64   required   Extra start time (pre-time) in minutes (Added in version 13).
812
stopExtra          s64   required   Extra stop time (post-time) in minutes (Added in version 13).
813
retention          s64   required   DVR Entry retention time in days.
814
priority           u32   required   Priority (0 = Important, 1 = High, 2 = Normal, 3 = Low, 4 = Unimportant, 5 = Not set) (Added in version 13).
815
eventId            u32   optional   Associated EPG Event ID (Added in version 13).
816
autorecId          u32   optional   Associated Autorec ID (Added in version 13).
817
contentType        u32   optional   Content Type (like in the DVB standard) (Added in version 13).
818 66 Adam Sutton
title              str   optional   Title of recording
819
summary            str   optional   Short description of the recording (Added in version 6).
820
description        str   optional   Long description of the recording.
821
state              str   required   Recording state
822
error              str   optional   Plain english error description (e.g. "Aborted by user").
823 48 mdd -
</pre>
824 1 Andreas Smas
825 66 Adam Sutton
TODO: recording states
826 48 mdd -
827
h3. dvrEntryUpdate
828
829 66 Adam Sutton
Message fields:
830
<pre>
831
Same as dvrEntryAdd, but all fields (except id) are optional.
832
</pre>
833 51 elupus -
834 66 Adam Sutton
h3. dvrEntryDelete (Added in version 4)
835 58 sbi -
836 66 Adam Sutton
A recording has been deleted from the server.
837 58 sbi -
838 48 mdd -
Message fields:
839
<pre>
840 66 Adam Sutton
id                 u32   required   ID of recording to delete.
841 1 Andreas Smas
</pre>
842 48 mdd -
843 58 sbi -
----
844 48 mdd -
845 95 Jaroslav Kysela
h3. autorecEntryAdd (Added in version 13)
846
847
A new autorec recording has been created on the server.
848
849
Message fields:
850
<pre>
851
id                 str   required   ID (string!) of dvrAutorecEntry.
852
enabled            u32   required   If autorec entry is enabled (activated).
853
minDuration        u32   required   Minimal duration in seconds (0 = Any).
854
maxDuration        u32   required   Maximal duration in seconds (0 = Any).
855
retention          u32   required   Retention time (in days).
856
daysOfWeek         u32   required   Bitmask - Days of week (0x01 = Monday, 0x40 = Sunday, 0x7f = Whole Week, 0 = Not set).
857
priority           u32   required   Priority (0 = Important, 1 = High, 2 = Normal, 3 = Low, 4 = Unimportant, 5 = Not set).
858
approxTime         u32   required   Minutes from midnight (up to 24*60).
859
startExtra         s64   required   Extra start minutes (pre-time).
860
stopExtra          s64   required   Extra stop minutes (post-time).
861
title              str   optional   Title.
862
channel            u32   optional   Channel ID.
863
</pre>
864
865
h3. autorecEntryUpdate (Added in version 13)
866
867
Message fields:
868
<pre>
869
Same as autorecEntryUpdate but all fields (except id) are optional.
870
</pre>
871
872
h3. autorecEntryDelete (Added in version 13)
873
874
Message fields:
875
<pre>
876
id                 str   required   Autorec Entry ID (string!)
877
</pre>
878
879
----
880
881 66 Adam Sutton
h3. eventAdd (Added in version 6)
882 48 mdd -
883 66 Adam Sutton
Message fields:
884
<pre>
885
eventId            u32   required   Event ID
886
channelId          u32   required   The channel this event is related to.
887
start              u64   required   Start time of event, UNIX time.
888
stop               u64   required   Ending time of event, UNIX time.
889
title              str   optional   Title of event.
890
summary            str   optional   Short description of the event (Added in version 6).
891
description        str   optional   Long description of the event.
892
serieslinkId       u32   optional   Series Link ID (Added in version 6).
893
episodeId          u32   optional   Episode ID (Added in version 6).
894
seasonId           u32   optional   Season ID (Added in version 6).
895
brandId            u32   optional   Brand ID (Added in version 6).
896
contentType        u32   optional   DVB content code (Added in version 4, Modified in version 6*).
897
ageRating          u32   optional   Minimum age rating (Added in version 6).
898
starRating         u32   optional   Star rating (1-5) (Added in version 6).
899
firstAired         s64   optional   Original broadcast time, UNIX time (Added in version 6).
900
seasonNumber       u32   optional   Season number (Added in version 6).
901
seasonCount        u32   optional   Show season count (Added in version 6).
902
episodeNumber      u32   optional   Episode number (Added in version 6).
903
episodeCount       u32   optional   Season episode count (Added in version 6).
904
partNumber         u32   optional   Multi-part episode part number (Added in version 6).
905
partCount          u32   optional   Multi-part episode part count (Added in version 6).
906
episodeOnscreen    str   optional   Textual representation of episode number (Added in version 6).
907
image              str   optional   URL to a still capture from the episode (Added in version 6).
908
dvrId              u32   optional   ID of a recording (Added in version 5).
909
nextEventId        u32   optional   ID of next event on the same channel.
910
</pre>
911 48 mdd -
912 66 Adam Sutton
* *contentType previously had the major DVB category in the bottom 4 bits, 
913
  however in v6 this has been changed to properly match DVB, so top 4 bits
914
  as major category and bottom 4 bits has sub-category. Clients requesting
915
  v5 or lower will get the old output.
916 48 mdd -
917 66 Adam Sutton
h3. eventUpdate (Added in version 6)
918 35 Andreas Smas
919 58 sbi -
Message fields:
920
<pre>
921 66 Adam Sutton
Same as eventAdd but all fields (except eventId) are optional.
922 35 Andreas Smas
</pre>
923 58 sbi -
924 77 John Törnblom
h3. eventDelete (Added in version 6)
925 35 Andreas Smas
926 66 Adam Sutton
Message fields:
927
<pre>
928
eventId            u32   required   Event ID
929
</pre>
930 14 Andreas Smas
931 66 Adam Sutton
---
932 14 Andreas Smas
933 66 Adam Sutton
h3. initialSyncCompleted (Added in version 2)
934 14 Andreas Smas
935 66 Adam Sutton
Sent after all the initial metadata has been sent when session has been set to async mode.
936 38 Andreas Smas
937
Message fields:
938 14 Andreas Smas
<pre>
939
</pre>
940
941
----
942
943
h3. subscriptionStart
944 53 Andreas Smas
945 66 Adam Sutton
Asynchronous message output when a new subscription is successfully started.
946 14 Andreas Smas
947
Message fields:
948 1 Andreas Smas
<pre>
949 66 Adam Sutton
subscriptionId     u32   required   Subscription ID.
950
streams            msg[] required   Array of messages with stream information
951
sourceinfo         msg   optional   Source information.
952
</pre>
953 37 Andreas Smas
954 66 Adam Sutton
Stream message fields:
955
<pre>
956
index              u32   required   Index for this stream
957
type               str   required   Type of stream
958 80 Jaroslav Kysela
meta               bin   optional   Codec metadata (private data) (Added in version 17)
959 66 Adam Sutton
language           str   optional   Language for stream
960
Video components only:
961
width              u32   optional   Width of video in pixels
962
height             u32   optional   Height of video in pixels
963 68 Andreas Smas
aspect_num         u32   optional   Aspect ratio numerator (Added in version 5) *Can be incorrect and should not be relied upon*
964
aspect_den         u32   optional   Aspect ratio denonminator (Added in version 5) *Can be incorrect and should not be relied upon*
965 66 Adam Sutton
Audio components only:
966 76 Dave Chapman
audio_type         u32   optional   Audio type - 0=Normal; 1=Clean effects; 2=Hearing impaired; 3=Visually impaired commentary; 4-255=Reserved (Added in version 11)
967 66 Adam Sutton
channels           u32   optional   Number of audio channels (Added in version 5)
968
rate               u32   optional   Audio bitrate (Added in version 5)
969
Subtitle components only:
970
composition_id     u32   optional   ??? (Added in version 5)
971
ancillary_id       u32   optional   ??? (Added in version 5)
972
</pre>
973 2 Andreas Smas
974 66 Adam Sutton
Sourceinfo message fields:
975
<pre>
976
adapter            str   optional   Adapter name
977
mux                str   optional   Transponder name
978
network            str   optional   Network name
979
provider           str   optional   ???
980
service            str   optional   Service name
981
</pre>
982 15 Andreas Smas
983 66 Adam Sutton
Video Stream types:
984 1 Andreas Smas
<pre>
985 79 Jaroslav Kysela
MPEG2VIDEO                    MPEG2 video, meta field is present (configuration blocks)
986
H264                          H264 video, meta field is present (configuration blocks)
987
HEVC                          HEVC video, meta field is present (configuration blocks)
988 66 Adam Sutton
</pre>
989 15 Andreas Smas
990 1 Andreas Smas
Audio Stream types:
991
<pre>
992 66 Adam Sutton
MPEG2AUDIO                    MPEG2 audio (MP2)
993
AC3                           AC3 audio
994 79 Jaroslav Kysela
AAC                           ADTS framed AAC (one AAC packet per ADTS frame), meta field is present (MPEG4 config)
995 66 Adam Sutton
EAC3                          Enhanced AC3 audio
996 79 Jaroslav Kysela
VORBIS                        Vorbis audio, meta field is present with the main vorbis header
997 16 Andreas Smas
</pre>
998
999 66 Adam Sutton
Subtitle Stream types:
1000
<pre>
1001
TELETEXT                      ???
1002
DVBSUB                        ???
1003
</pre>
1004 55 Lars Op den Kamp -
1005
h3. subscriptionStop
1006
1007 66 Adam Sutton
A subscription has been stopped.
1008 55 Lars Op den Kamp -
1009
Message fields:
1010
<pre>
1011 66 Adam Sutton
subscriptionId     u32   required   Subscription ID.
1012 1 Andreas Smas
status             str   optional   Error message if subscription stopped unexpectedly.
1013
</pre>
1014
1015 73 Adam Sutton
h3. subscriptionSkip (Added version 9)
1016
1017
A subscription has been skipped.
1018
1019
Message fields:
1020
<pre>
1021
subscriptionId     u32   required   Subscription ID.
1022
error              u32   optional   The last skip command caused an error.
1023
absolute           u32   optional   Indicates the output is absolute (Note: should always be 1 at the moment)
1024
time               u64   optional   The time the subscription has skipped to.
1025
size               u64   optional   The position in the file we've skipped to (Note: not currently used).
1026
</pre>
1027
1028
h3. subscriptionSpeed (Added version 9)
1029
1030
A subscription's playback speed has changed.
1031
1032
This can happen even without a speed request, should playback reach either end of the buffer.
1033
1034
Message fields:
1035
<pre>
1036
subscriptionId     u32   required   Subscription ID.
1037
speed              u32   required   The new speed of the subscription
1038
</pre>
1039
1040 55 Lars Op den Kamp -
h3. subscriptionStatus
1041
1042 66 Adam Sutton
Subscription status update.
1043 58 sbi -
1044
Message fields:
1045
<pre>
1046 66 Adam Sutton
subscriptionId     u32   required   Subscription ID.
1047
status             str   optional   English clear text of error status. Absence of this field means that the status is OK. 
1048 16 Andreas Smas
</pre>
1049 58 sbi -
1050 16 Andreas Smas
h3. queueStatus
1051
1052 1 Andreas Smas
The queueStatus message is sent every second during normal data delivery.
1053 60 John Törnblom
1054
The transmit scheduler have different drop thresholds for different frame types.
1055 66 Adam Sutton
1056 1 Andreas Smas
If congestion occurs it will favor dropping B-frames before P-frames before I-frames.
1057
All audio is recognized as I-frames. 
1058 58 sbi -
1059 1 Andreas Smas
Message fields:
1060
<pre>
1061 66 Adam Sutton
subscriptionId     u32   required   Subscription ID.
1062
packets            u32   required   Number of data packets in queue.
1063
bytes              u32   required   Number of bytes in queue.
1064
delay              u32   optional   Estimated delay of queue (in µs).
1065 1 Andreas Smas
Bdrops             u32   required   Number of B-frames dropped
1066 66 Adam Sutton
Pdrops             u32   required   Number of P-frames dropped
1067
Idrops             u32   required   Number of I-frames dropped
1068 73 Adam Sutton
delay              s64   required   Delta between first and last DTS (Added in version 9)
1069 1 Andreas Smas
</pre>
1070
1071
h3. signalStatus
1072
1073
The signalStatus message is sent every second during normal data delivery.
1074
1075
The optional fields may not have been implemented or may not be supported by the active adapter.
1076
1077
Message fields:
1078
<pre>
1079 66 Adam Sutton
subscriptionId     u32   required   Subscription ID.
1080
feStatus           str   required   Frontend status.
1081
feSNR              u32   optional   Signal to noise ratio.
1082 1 Andreas Smas
feSignal           u32   optional   Signal status percentage.
1083
feBER              u32   optional   Bit error rate.
1084
feUNC              u32   optional   Uncorrected blocks.
1085 73 Adam Sutton
</pre>
1086
1087
h3. timeshiftStatus
1088
1089
Provide status every second about the timeshift buffer.
1090
1091
Message fields:
1092
<pre>
1093
subscriptionId     u32   required   Subscription ID.
1094
full               u32   required   Indicates whether the buffer is full
1095
shift              s64   required   Current position relative to live
1096
start              s64   optional   PTS of the first frame in the buffer
1097
end                s64   optional   PTS of the last frame in the buffer
1098 1 Andreas Smas
</pre>
1099
1100
h3. muxpkt
1101
1102
Streaming data.
1103
1104
Message fields:
1105
<pre>
1106 66 Adam Sutton
subscriptionId     u32   required   Subscription ID.
1107
frametype          u32   required   Type of frame as ASCII value: 'I', 'P', 'B'
1108
stream             u32   required   Stream index. Corresponds to the streams reported in the subscriptionStart message.
1109
dts                s64   optional   Decode Time Stamp in µs.
1110
pts                s64   optional   Presentation Time Stamp in µs.
1111
duration           u32   required   Duration of frame in µs.
1112
payload            bin   required   Actual frame data.
1113 1 Andreas Smas
</pre>
1114 81 Jaroslav Kysela
1115
Note: From protocol version 17, the H264 payload does not contain the H264 configuration blocks (they are only in the meta field - see start message).