Overview
libhdhomerun.changes
Changed
x
1
2
-------------------------------------------------------------------
3
+Tue Oct 29 11:39:22 UTC 2019 - <manfred.h@gmx.net>
4
+
5
+- Update patch: libhdhomerun-fix_makefile.patch
6
+- Version update to 20190621
7
+ https://www.silicondust.com/support/downloads/software-changelog/
8
+
9
+-------------------------------------------------------------------
10
Sat Oct 08 11:13:29 UTC 2016 - joerg.lorenzen@ki.tng.de
11
12
- Removed service file because build often fails with 'bad temdir'
13
libhdhomerun.spec
Changed
34
1
2
# package are under the same license as the package itself.
3
4
Name: libhdhomerun
5
-Version: 20150826
6
-%define soname %{version}
7
+Version: 20190621
8
+%define soname 2
9
Release: 1.pm
10
Summary: HD library for your pc
11
Group: System/Libraries
12
13
%setup -q -n libhdhomerun
14
%patch1
15
%__chmod 0644 *
16
-%__sed -i -e 's/\r$//' README
17
+%__sed -i -e 's/\r$//' README.md
18
19
%build
20
-%__make %{?_smp_flags} SONAME="%{version}" OPTFLAGS="%{optflags}"
21
+%__make %{?_smp_flags} SONAME="%{soname}" OPTFLAGS="%{optflags}"
22
23
%install
24
%__install -D -m0755 hdhomerun_config "%{buildroot}%{_bindir}/hdhomerun_config"
25
26
27
%files -n %{name}%{soname}
28
%defattr(-,root,root)
29
-%doc README
30
+%doc README.md
31
%{_libdir}/libhdhomerun.so.%{soname}
32
33
%files devel
34
libhdhomerun-fix_makefile.patch
Changed
37
1
2
---- Makefile.orig 2016-03-10 19:11:44.787338293 +0200
3
-+++ Makefile 2016-03-10 19:12:33.744628657 +0200
4
-@@ -12,11 +12,10 @@
5
+--- Makefile.orig 2019-05-03 19:45:43.000000000 +0200
6
++++ Makefile 2019-10-29 12:52:20.222262688 +0100
7
+@@ -12,11 +12,10 @@ LIBSRCS += hdhomerun_sock_posix.c
8
LIBSRCS += hdhomerun_video.c
9
10
CC := $(CROSS_COMPILE)gcc
11
-STRIP := $(CROSS_COMPILE)strip
12
13
--CFLAGS += -Wall -O2 -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
14
-+CFLAGS += -Wall -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith $(OPTFLAGS)
15
+-CFLAGS += -O2 -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wno-unused-parameter
16
++CFLAGS += $(OPTFLAGS) -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wno-unused-parameter
17
LDFLAGS += -lpthread
18
-SHARED = -shared -Wl,-soname,libhdhomerun$(LIBEXT)
19
+SHARED = -shared -Wl,-soname,libhdhomerun$(LIBEXT).$(SONAME)
20
21
ifeq ($(OS),Windows_NT)
22
BINEXT := .exe
23
-@@ -42,10 +41,10 @@
24
+@@ -42,10 +41,10 @@ all : hdhomerun_config$(BINEXT) libhdhom
25
26
hdhomerun_config$(BINEXT) : hdhomerun_config.c $(LIBSRCS)
27
$(CC) $(CFLAGS) $+ $(LDFLAGS) -o $@
28
29
libhdhomerun$(LIBEXT) : $(LIBSRCS)
30
- $(CC) $(CFLAGS) -fPIC -DDLL_EXPORT $(SHARED) $+ $(LDFLAGS) -o $@
31
+ $(CC) $(CFLAGS) -fPIC -DDLL_EXPORT $(SHARED) $+ $(LDFLAGS) -o $@.$(SONAME)
32
-+ ln -s $@.$(SONAME) $@
33
++ ln -sf $@.$(SONAME) $@
34
35
clean :
36
-rm -f hdhomerun_config$(BINEXT)
37
libhdhomerun_20150826.tgz/README
Deleted
31
1
2
-/*
3
- * README
4
- *
5
- * Copyright © 2005-2009 Silicondust USA Inc. <www.silicondust.com>.
6
- *
7
- * This library is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * This library is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with this library; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
- */
21
-
22
-Top level include file: hdhomerun.h
23
-
24
-Top level API: hdhomerun_device. See hdhomerun_device.h for documentation.
25
-
26
-The hdhomerun_device API should be used rather than the low level control and video APIs required with previous versions.
27
-
28
-Additional libraries required:
29
-- pthread
30
-- iphlpapi (windows only)
31
libhdhomerun_20150826.tgz/lgpl.txt
Deleted
504
1
2
- GNU LESSER GENERAL PUBLIC LICENSE
3
- Version 2.1, February 1999
4
-
5
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
6
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7
- Everyone is permitted to copy and distribute verbatim copies
8
- of this license document, but changing it is not allowed.
9
-
10
-[This is the first released version of the Lesser GPL. It also counts
11
- as the successor of the GNU Library Public License, version 2, hence
12
- the version number 2.1.]
13
-
14
- Preamble
15
-
16
- The licenses for most software are designed to take away your
17
-freedom to share and change it. By contrast, the GNU General Public
18
-Licenses are intended to guarantee your freedom to share and change
19
-free software--to make sure the software is free for all its users.
20
-
21
- This license, the Lesser General Public License, applies to some
22
-specially designated software packages--typically libraries--of the
23
-Free Software Foundation and other authors who decide to use it. You
24
-can use it too, but we suggest you first think carefully about whether
25
-this license or the ordinary General Public License is the better
26
-strategy to use in any particular case, based on the explanations below.
27
-
28
- When we speak of free software, we are referring to freedom of use,
29
-not price. Our General Public Licenses are designed to make sure that
30
-you have the freedom to distribute copies of free software (and charge
31
-for this service if you wish); that you receive source code or can get
32
-it if you want it; that you can change the software and use pieces of
33
-it in new free programs; and that you are informed that you can do
34
-these things.
35
-
36
- To protect your rights, we need to make restrictions that forbid
37
-distributors to deny you these rights or to ask you to surrender these
38
-rights. These restrictions translate to certain responsibilities for
39
-you if you distribute copies of the library or if you modify it.
40
-
41
- For example, if you distribute copies of the library, whether gratis
42
-or for a fee, you must give the recipients all the rights that we gave
43
-you. You must make sure that they, too, receive or can get the source
44
-code. If you link other code with the library, you must provide
45
-complete object files to the recipients, so that they can relink them
46
-with the library after making changes to the library and recompiling
47
-it. And you must show them these terms so they know their rights.
48
-
49
- We protect your rights with a two-step method: (1) we copyright the
50
-library, and (2) we offer you this license, which gives you legal
51
-permission to copy, distribute and/or modify the library.
52
-
53
- To protect each distributor, we want to make it very clear that
54
-there is no warranty for the free library. Also, if the library is
55
-modified by someone else and passed on, the recipients should know
56
-that what they have is not the original version, so that the original
57
-author's reputation will not be affected by problems that might be
58
-introduced by others.
59
-
60
- Finally, software patents pose a constant threat to the existence of
61
-any free program. We wish to make sure that a company cannot
62
-effectively restrict the users of a free program by obtaining a
63
-restrictive license from a patent holder. Therefore, we insist that
64
-any patent license obtained for a version of the library must be
65
-consistent with the full freedom of use specified in this license.
66
-
67
- Most GNU software, including some libraries, is covered by the
68
-ordinary GNU General Public License. This license, the GNU Lesser
69
-General Public License, applies to certain designated libraries, and
70
-is quite different from the ordinary General Public License. We use
71
-this license for certain libraries in order to permit linking those
72
-libraries into non-free programs.
73
-
74
- When a program is linked with a library, whether statically or using
75
-a shared library, the combination of the two is legally speaking a
76
-combined work, a derivative of the original library. The ordinary
77
-General Public License therefore permits such linking only if the
78
-entire combination fits its criteria of freedom. The Lesser General
79
-Public License permits more lax criteria for linking other code with
80
-the library.
81
-
82
- We call this license the "Lesser" General Public License because it
83
-does Less to protect the user's freedom than the ordinary General
84
-Public License. It also provides other free software developers Less
85
-of an advantage over competing non-free programs. These disadvantages
86
-are the reason we use the ordinary General Public License for many
87
-libraries. However, the Lesser license provides advantages in certain
88
-special circumstances.
89
-
90
- For example, on rare occasions, there may be a special need to
91
-encourage the widest possible use of a certain library, so that it becomes
92
-a de-facto standard. To achieve this, non-free programs must be
93
-allowed to use the library. A more frequent case is that a free
94
-library does the same job as widely used non-free libraries. In this
95
-case, there is little to gain by limiting the free library to free
96
-software only, so we use the Lesser General Public License.
97
-
98
- In other cases, permission to use a particular library in non-free
99
-programs enables a greater number of people to use a large body of
100
-free software. For example, permission to use the GNU C Library in
101
-non-free programs enables many more people to use the whole GNU
102
-operating system, as well as its variant, the GNU/Linux operating
103
-system.
104
-
105
- Although the Lesser General Public License is Less protective of the
106
-users' freedom, it does ensure that the user of a program that is
107
-linked with the Library has the freedom and the wherewithal to run
108
-that program using a modified version of the Library.
109
-
110
- The precise terms and conditions for copying, distribution and
111
-modification follow. Pay close attention to the difference between a
112
-"work based on the library" and a "work that uses the library". The
113
-former contains code derived from the library, whereas the latter must
114
-be combined with the library in order to run.
115
-
116
- GNU LESSER GENERAL PUBLIC LICENSE
117
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
118
-
119
- 0. This License Agreement applies to any software library or other
120
-program which contains a notice placed by the copyright holder or
121
-other authorized party saying it may be distributed under the terms of
122
-this Lesser General Public License (also called "this License").
123
-Each licensee is addressed as "you".
124
-
125
- A "library" means a collection of software functions and/or data
126
-prepared so as to be conveniently linked with application programs
127
-(which use some of those functions and data) to form executables.
128
-
129
- The "Library", below, refers to any such software library or work
130
-which has been distributed under these terms. A "work based on the
131
-Library" means either the Library or any derivative work under
132
-copyright law: that is to say, a work containing the Library or a
133
-portion of it, either verbatim or with modifications and/or translated
134
-straightforwardly into another language. (Hereinafter, translation is
135
-included without limitation in the term "modification".)
136
-
137
- "Source code" for a work means the preferred form of the work for
138
-making modifications to it. For a library, complete source code means
139
-all the source code for all modules it contains, plus any associated
140
-interface definition files, plus the scripts used to control compilation
141
-and installation of the library.
142
-
143
- Activities other than copying, distribution and modification are not
144
-covered by this License; they are outside its scope. The act of
145
-running a program using the Library is not restricted, and output from
146
-such a program is covered only if its contents constitute a work based
147
-on the Library (independent of the use of the Library in a tool for
148
-writing it). Whether that is true depends on what the Library does
149
-and what the program that uses the Library does.
150
-
151
- 1. You may copy and distribute verbatim copies of the Library's
152
-complete source code as you receive it, in any medium, provided that
153
-you conspicuously and appropriately publish on each copy an
154
-appropriate copyright notice and disclaimer of warranty; keep intact
155
-all the notices that refer to this License and to the absence of any
156
-warranty; and distribute a copy of this License along with the
157
-Library.
158
-
159
- You may charge a fee for the physical act of transferring a copy,
160
-and you may at your option offer warranty protection in exchange for a
161
-fee.
162
-
163
- 2. You may modify your copy or copies of the Library or any portion
164
-of it, thus forming a work based on the Library, and copy and
165
-distribute such modifications or work under the terms of Section 1
166
-above, provided that you also meet all of these conditions:
167
-
168
- a) The modified work must itself be a software library.
169
-
170
- b) You must cause the files modified to carry prominent notices
171
- stating that you changed the files and the date of any change.
172
-
173
- c) You must cause the whole of the work to be licensed at no
174
- charge to all third parties under the terms of this License.
175
-
176
- d) If a facility in the modified Library refers to a function or a
177
- table of data to be supplied by an application program that uses
178
- the facility, other than as an argument passed when the facility
179
- is invoked, then you must make a good faith effort to ensure that,
180
- in the event an application does not supply such function or
181
- table, the facility still operates, and performs whatever part of
182
- its purpose remains meaningful.
183
-
184
- (For example, a function in a library to compute square roots has
185
- a purpose that is entirely well-defined independent of the
186
- application. Therefore, Subsection 2d requires that any
187
- application-supplied function or table used by this function must
188
- be optional: if the application does not supply it, the square
189
- root function must still compute square roots.)
190
-
191
-These requirements apply to the modified work as a whole. If
192
-identifiable sections of that work are not derived from the Library,
193
-and can be reasonably considered independent and separate works in
194
-themselves, then this License, and its terms, do not apply to those
195
-sections when you distribute them as separate works. But when you
196
-distribute the same sections as part of a whole which is a work based
197
-on the Library, the distribution of the whole must be on the terms of
198
-this License, whose permissions for other licensees extend to the
199
-entire whole, and thus to each and every part regardless of who wrote
200
-it.
201
-
202
-Thus, it is not the intent of this section to claim rights or contest
203
-your rights to work written entirely by you; rather, the intent is to
204
-exercise the right to control the distribution of derivative or
205
-collective works based on the Library.
206
-
207
-In addition, mere aggregation of another work not based on the Library
208
-with the Library (or with a work based on the Library) on a volume of
209
-a storage or distribution medium does not bring the other work under
210
-the scope of this License.
211
-
212
- 3. You may opt to apply the terms of the ordinary GNU General Public
213
-License instead of this License to a given copy of the Library. To do
214
-this, you must alter all the notices that refer to this License, so
215
-that they refer to the ordinary GNU General Public License, version 2,
216
-instead of to this License. (If a newer version than version 2 of the
217
-ordinary GNU General Public License has appeared, then you can specify
218
-that version instead if you wish.) Do not make any other change in
219
-these notices.
220
-
221
- Once this change is made in a given copy, it is irreversible for
222
-that copy, so the ordinary GNU General Public License applies to all
223
-subsequent copies and derivative works made from that copy.
224
-
225
- This option is useful when you wish to copy part of the code of
226
-the Library into a program that is not a library.
227
-
228
- 4. You may copy and distribute the Library (or a portion or
229
-derivative of it, under Section 2) in object code or executable form
230
-under the terms of Sections 1 and 2 above provided that you accompany
231
-it with the complete corresponding machine-readable source code, which
232
-must be distributed under the terms of Sections 1 and 2 above on a
233
-medium customarily used for software interchange.
234
-
235
- If distribution of object code is made by offering access to copy
236
-from a designated place, then offering equivalent access to copy the
237
-source code from the same place satisfies the requirement to
238
-distribute the source code, even though third parties are not
239
-compelled to copy the source along with the object code.
240
-
241
- 5. A program that contains no derivative of any portion of the
242
-Library, but is designed to work with the Library by being compiled or
243
-linked with it, is called a "work that uses the Library". Such a
244
-work, in isolation, is not a derivative work of the Library, and
245
-therefore falls outside the scope of this License.
246
-
247
- However, linking a "work that uses the Library" with the Library
248
-creates an executable that is a derivative of the Library (because it
249
-contains portions of the Library), rather than a "work that uses the
250
-library". The executable is therefore covered by this License.
251
-Section 6 states terms for distribution of such executables.
252
-
253
- When a "work that uses the Library" uses material from a header file
254
-that is part of the Library, the object code for the work may be a
255
-derivative work of the Library even though the source code is not.
256
-Whether this is true is especially significant if the work can be
257
-linked without the Library, or if the work is itself a library. The
258
-threshold for this to be true is not precisely defined by law.
259
-
260
- If such an object file uses only numerical parameters, data
261
-structure layouts and accessors, and small macros and small inline
262
-functions (ten lines or less in length), then the use of the object
263
-file is unrestricted, regardless of whether it is legally a derivative
264
-work. (Executables containing this object code plus portions of the
265
-Library will still fall under Section 6.)
266
-
267
- Otherwise, if the work is a derivative of the Library, you may
268
-distribute the object code for the work under the terms of Section 6.
269
-Any executables containing that work also fall under Section 6,
270
-whether or not they are linked directly with the Library itself.
271
-
272
- 6. As an exception to the Sections above, you may also combine or
273
-link a "work that uses the Library" with the Library to produce a
274
-work containing portions of the Library, and distribute that work
275
-under terms of your choice, provided that the terms permit
276
-modification of the work for the customer's own use and reverse
277
-engineering for debugging such modifications.
278
-
279
- You must give prominent notice with each copy of the work that the
280
-Library is used in it and that the Library and its use are covered by
281
-this License. You must supply a copy of this License. If the work
282
-during execution displays copyright notices, you must include the
283
-copyright notice for the Library among them, as well as a reference
284
-directing the user to the copy of this License. Also, you must do one
285
-of these things:
286
-
287
- a) Accompany the work with the complete corresponding
288
- machine-readable source code for the Library including whatever
289
- changes were used in the work (which must be distributed under
290
- Sections 1 and 2 above); and, if the work is an executable linked
291
- with the Library, with the complete machine-readable "work that
292
- uses the Library", as object code and/or source code, so that the
293
- user can modify the Library and then relink to produce a modified
294
- executable containing the modified Library. (It is understood
295
- that the user who changes the contents of definitions files in the
296
- Library will not necessarily be able to recompile the application
297
- to use the modified definitions.)
298
-
299
- b) Use a suitable shared library mechanism for linking with the
300
- Library. A suitable mechanism is one that (1) uses at run time a
301
- copy of the library already present on the user's computer system,
302
- rather than copying library functions into the executable, and (2)
303
- will operate properly with a modified version of the library, if
304
- the user installs one, as long as the modified version is
305
- interface-compatible with the version that the work was made with.
306
-
307
- c) Accompany the work with a written offer, valid for at
308
- least three years, to give the same user the materials
309
- specified in Subsection 6a, above, for a charge no more
310
- than the cost of performing this distribution.
311
-
312
- d) If distribution of the work is made by offering access to copy
313
- from a designated place, offer equivalent access to copy the above
314
- specified materials from the same place.
315
-
316
- e) Verify that the user has already received a copy of these
317
- materials or that you have already sent this user a copy.
318
-
319
- For an executable, the required form of the "work that uses the
320
-Library" must include any data and utility programs needed for
321
-reproducing the executable from it. However, as a special exception,
322
-the materials to be distributed need not include anything that is
323
-normally distributed (in either source or binary form) with the major
324
-components (compiler, kernel, and so on) of the operating system on
325
-which the executable runs, unless that component itself accompanies
326
-the executable.
327
-
328
- It may happen that this requirement contradicts the license
329
-restrictions of other proprietary libraries that do not normally
330
-accompany the operating system. Such a contradiction means you cannot
331
-use both them and the Library together in an executable that you
332
-distribute.
333
-
334
- 7. You may place library facilities that are a work based on the
335
-Library side-by-side in a single library together with other library
336
-facilities not covered by this License, and distribute such a combined
337
-library, provided that the separate distribution of the work based on
338
-the Library and of the other library facilities is otherwise
339
-permitted, and provided that you do these two things:
340
-
341
- a) Accompany the combined library with a copy of the same work
342
- based on the Library, uncombined with any other library
343
- facilities. This must be distributed under the terms of the
344
- Sections above.
345
-
346
- b) Give prominent notice with the combined library of the fact
347
- that part of it is a work based on the Library, and explaining
348
- where to find the accompanying uncombined form of the same work.
349
-
350
- 8. You may not copy, modify, sublicense, link with, or distribute
351
-the Library except as expressly provided under this License. Any
352
-attempt otherwise to copy, modify, sublicense, link with, or
353
-distribute the Library is void, and will automatically terminate your
354
-rights under this License. However, parties who have received copies,
355
-or rights, from you under this License will not have their licenses
356
-terminated so long as such parties remain in full compliance.
357
-
358
- 9. You are not required to accept this License, since you have not
359
-signed it. However, nothing else grants you permission to modify or
360
-distribute the Library or its derivative works. These actions are
361
-prohibited by law if you do not accept this License. Therefore, by
362
-modifying or distributing the Library (or any work based on the
363
-Library), you indicate your acceptance of this License to do so, and
364
-all its terms and conditions for copying, distributing or modifying
365
-the Library or works based on it.
366
-
367
- 10. Each time you redistribute the Library (or any work based on the
368
-Library), the recipient automatically receives a license from the
369
-original licensor to copy, distribute, link with or modify the Library
370
-subject to these terms and conditions. You may not impose any further
371
-restrictions on the recipients' exercise of the rights granted herein.
372
-You are not responsible for enforcing compliance by third parties with
373
-this License.
374
-
375
- 11. If, as a consequence of a court judgment or allegation of patent
376
-infringement or for any other reason (not limited to patent issues),
377
-conditions are imposed on you (whether by court order, agreement or
378
-otherwise) that contradict the conditions of this License, they do not
379
-excuse you from the conditions of this License. If you cannot
380
-distribute so as to satisfy simultaneously your obligations under this
381
-License and any other pertinent obligations, then as a consequence you
382
-may not distribute the Library at all. For example, if a patent
383
-license would not permit royalty-free redistribution of the Library by
384
-all those who receive copies directly or indirectly through you, then
385
-the only way you could satisfy both it and this License would be to
386
-refrain entirely from distribution of the Library.
387
-
388
-If any portion of this section is held invalid or unenforceable under any
389
-particular circumstance, the balance of the section is intended to apply,
390
-and the section as a whole is intended to apply in other circumstances.
391
-
392
-It is not the purpose of this section to induce you to infringe any
393
-patents or other property right claims or to contest validity of any
394
-such claims; this section has the sole purpose of protecting the
395
-integrity of the free software distribution system which is
396
-implemented by public license practices. Many people have made
397
-generous contributions to the wide range of software distributed
398
-through that system in reliance on consistent application of that
399
-system; it is up to the author/donor to decide if he or she is willing
400
-to distribute software through any other system and a licensee cannot
401
-impose that choice.
402
-
403
-This section is intended to make thoroughly clear what is believed to
404
-be a consequence of the rest of this License.
405
-
406
- 12. If the distribution and/or use of the Library is restricted in
407
-certain countries either by patents or by copyrighted interfaces, the
408
-original copyright holder who places the Library under this License may add
409
-an explicit geographical distribution limitation excluding those countries,
410
-so that distribution is permitted only in or among countries not thus
411
-excluded. In such case, this License incorporates the limitation as if
412
-written in the body of this License.
413
-
414
- 13. The Free Software Foundation may publish revised and/or new
415
-versions of the Lesser General Public License from time to time.
416
-Such new versions will be similar in spirit to the present version,
417
-but may differ in detail to address new problems or concerns.
418
-
419
-Each version is given a distinguishing version number. If the Library
420
-specifies a version number of this License which applies to it and
421
-"any later version", you have the option of following the terms and
422
-conditions either of that version or of any later version published by
423
-the Free Software Foundation. If the Library does not specify a
424
-license version number, you may choose any version ever published by
425
-the Free Software Foundation.
426
-
427
- 14. If you wish to incorporate parts of the Library into other free
428
-programs whose distribution conditions are incompatible with these,
429
-write to the author to ask for permission. For software which is
430
-copyrighted by the Free Software Foundation, write to the Free
431
-Software Foundation; we sometimes make exceptions for this. Our
432
-decision will be guided by the two goals of preserving the free status
433
-of all derivatives of our free software and of promoting the sharing
434
-and reuse of software generally.
435
-
436
- NO WARRANTY
437
-
438
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
439
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
440
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
441
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
442
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
443
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
444
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
445
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
446
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
447
-
448
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
449
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
450
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
451
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
452
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
453
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
454
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
455
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
456
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
457
-DAMAGES.
458
-
459
- END OF TERMS AND CONDITIONS
460
-
461
- How to Apply These Terms to Your New Libraries
462
-
463
- If you develop a new library, and you want it to be of the greatest
464
-possible use to the public, we recommend making it free software that
465
-everyone can redistribute and change. You can do so by permitting
466
-redistribution under these terms (or, alternatively, under the terms of the
467
-ordinary General Public License).
468
-
469
- To apply these terms, attach the following notices to the library. It is
470
-safest to attach them to the start of each source file to most effectively
471
-convey the exclusion of warranty; and each file should have at least the
472
-"copyright" line and a pointer to where the full notice is found.
473
-
474
- <one line to give the library's name and a brief idea of what it does.>
475
- Copyright (C) <year> <name of author>
476
-
477
- This library is free software; you can redistribute it and/or
478
- modify it under the terms of the GNU Lesser General Public
479
- License as published by the Free Software Foundation; either
480
- version 2.1 of the License, or (at your option) any later version.
481
-
482
- This library is distributed in the hope that it will be useful,
483
- but WITHOUT ANY WARRANTY; without even the implied warranty of
484
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
485
- Lesser General Public License for more details.
486
-
487
- You should have received a copy of the GNU Lesser General Public
488
- License along with this library; if not, write to the Free Software
489
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
490
-
491
-Also add information on how to contact you by electronic and paper mail.
492
-
493
-You should also get your employer (if you work as a programmer) or your
494
-school, if any, to sign a "copyright disclaimer" for the library, if
495
-necessary. Here is a sample; alter the names:
496
-
497
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
498
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
499
-
500
- <signature of Ty Coon>, 1 April 1990
501
- Ty Coon, President of Vice
502
-
503
-That's all there is to it!
504
libhdhomerun_20190621.tgz/LICENSE
Added
506
1
2
+ GNU LESSER GENERAL PUBLIC LICENSE
3
+ Version 2.1, February 1999
4
+
5
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
6
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+(This is the first released version of the Lesser GPL. It also counts
11
+ as the successor of the GNU Library Public License, version 2, hence
12
+ the version number 2.1.)
13
+
14
+ Preamble
15
+
16
+ The licenses for most software are designed to take away your
17
+freedom to share and change it. By contrast, the GNU General Public
18
+Licenses are intended to guarantee your freedom to share and change
19
+free software--to make sure the software is free for all its users.
20
+
21
+ This license, the Lesser General Public License, applies to some
22
+specially designated software packages--typically libraries--of the
23
+Free Software Foundation and other authors who decide to use it. You
24
+can use it too, but we suggest you first think carefully about whether
25
+this license or the ordinary General Public License is the better
26
+strategy to use in any particular case, based on the explanations below.
27
+
28
+ When we speak of free software, we are referring to freedom of use,
29
+not price. Our General Public Licenses are designed to make sure that
30
+you have the freedom to distribute copies of free software (and charge
31
+for this service if you wish); that you receive source code or can get
32
+it if you want it; that you can change the software and use pieces of
33
+it in new free programs; and that you are informed that you can do
34
+these things.
35
+
36
+ To protect your rights, we need to make restrictions that forbid
37
+distributors to deny you these rights or to ask you to surrender these
38
+rights. These restrictions translate to certain responsibilities for
39
+you if you distribute copies of the library or if you modify it.
40
+
41
+ For example, if you distribute copies of the library, whether gratis
42
+or for a fee, you must give the recipients all the rights that we gave
43
+you. You must make sure that they, too, receive or can get the source
44
+code. If you link other code with the library, you must provide
45
+complete object files to the recipients, so that they can relink them
46
+with the library after making changes to the library and recompiling
47
+it. And you must show them these terms so they know their rights.
48
+
49
+ We protect your rights with a two-step method: (1) we copyright the
50
+library, and (2) we offer you this license, which gives you legal
51
+permission to copy, distribute and/or modify the library.
52
+
53
+ To protect each distributor, we want to make it very clear that
54
+there is no warranty for the free library. Also, if the library is
55
+modified by someone else and passed on, the recipients should know
56
+that what they have is not the original version, so that the original
57
+author's reputation will not be affected by problems that might be
58
+introduced by others.
59
+
60
+ Finally, software patents pose a constant threat to the existence of
61
+any free program. We wish to make sure that a company cannot
62
+effectively restrict the users of a free program by obtaining a
63
+restrictive license from a patent holder. Therefore, we insist that
64
+any patent license obtained for a version of the library must be
65
+consistent with the full freedom of use specified in this license.
66
+
67
+ Most GNU software, including some libraries, is covered by the
68
+ordinary GNU General Public License. This license, the GNU Lesser
69
+General Public License, applies to certain designated libraries, and
70
+is quite different from the ordinary General Public License. We use
71
+this license for certain libraries in order to permit linking those
72
+libraries into non-free programs.
73
+
74
+ When a program is linked with a library, whether statically or using
75
+a shared library, the combination of the two is legally speaking a
76
+combined work, a derivative of the original library. The ordinary
77
+General Public License therefore permits such linking only if the
78
+entire combination fits its criteria of freedom. The Lesser General
79
+Public License permits more lax criteria for linking other code with
80
+the library.
81
+
82
+ We call this license the "Lesser" General Public License because it
83
+does Less to protect the user's freedom than the ordinary General
84
+Public License. It also provides other free software developers Less
85
+of an advantage over competing non-free programs. These disadvantages
86
+are the reason we use the ordinary General Public License for many
87
+libraries. However, the Lesser license provides advantages in certain
88
+special circumstances.
89
+
90
+ For example, on rare occasions, there may be a special need to
91
+encourage the widest possible use of a certain library, so that it becomes
92
+a de-facto standard. To achieve this, non-free programs must be
93
+allowed to use the library. A more frequent case is that a free
94
+library does the same job as widely used non-free libraries. In this
95
+case, there is little to gain by limiting the free library to free
96
+software only, so we use the Lesser General Public License.
97
+
98
+ In other cases, permission to use a particular library in non-free
99
+programs enables a greater number of people to use a large body of
100
+free software. For example, permission to use the GNU C Library in
101
+non-free programs enables many more people to use the whole GNU
102
+operating system, as well as its variant, the GNU/Linux operating
103
+system.
104
+
105
+ Although the Lesser General Public License is Less protective of the
106
+users' freedom, it does ensure that the user of a program that is
107
+linked with the Library has the freedom and the wherewithal to run
108
+that program using a modified version of the Library.
109
+
110
+ The precise terms and conditions for copying, distribution and
111
+modification follow. Pay close attention to the difference between a
112
+"work based on the library" and a "work that uses the library". The
113
+former contains code derived from the library, whereas the latter must
114
+be combined with the library in order to run.
115
+
116
+ GNU LESSER GENERAL PUBLIC LICENSE
117
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
118
+
119
+ 0. This License Agreement applies to any software library or other
120
+program which contains a notice placed by the copyright holder or
121
+other authorized party saying it may be distributed under the terms of
122
+this Lesser General Public License (also called "this License").
123
+Each licensee is addressed as "you".
124
+
125
+ A "library" means a collection of software functions and/or data
126
+prepared so as to be conveniently linked with application programs
127
+(which use some of those functions and data) to form executables.
128
+
129
+ The "Library", below, refers to any such software library or work
130
+which has been distributed under these terms. A "work based on the
131
+Library" means either the Library or any derivative work under
132
+copyright law: that is to say, a work containing the Library or a
133
+portion of it, either verbatim or with modifications and/or translated
134
+straightforwardly into another language. (Hereinafter, translation is
135
+included without limitation in the term "modification".)
136
+
137
+ "Source code" for a work means the preferred form of the work for
138
+making modifications to it. For a library, complete source code means
139
+all the source code for all modules it contains, plus any associated
140
+interface definition files, plus the scripts used to control compilation
141
+and installation of the library.
142
+
143
+ Activities other than copying, distribution and modification are not
144
+covered by this License; they are outside its scope. The act of
145
+running a program using the Library is not restricted, and output from
146
+such a program is covered only if its contents constitute a work based
147
+on the Library (independent of the use of the Library in a tool for
148
+writing it). Whether that is true depends on what the Library does
149
+and what the program that uses the Library does.
150
+
151
+ 1. You may copy and distribute verbatim copies of the Library's
152
+complete source code as you receive it, in any medium, provided that
153
+you conspicuously and appropriately publish on each copy an
154
+appropriate copyright notice and disclaimer of warranty; keep intact
155
+all the notices that refer to this License and to the absence of any
156
+warranty; and distribute a copy of this License along with the
157
+Library.
158
+
159
+ You may charge a fee for the physical act of transferring a copy,
160
+and you may at your option offer warranty protection in exchange for a
161
+fee.
162
+
163
+ 2. You may modify your copy or copies of the Library or any portion
164
+of it, thus forming a work based on the Library, and copy and
165
+distribute such modifications or work under the terms of Section 1
166
+above, provided that you also meet all of these conditions:
167
+
168
+ a) The modified work must itself be a software library.
169
+
170
+ b) You must cause the files modified to carry prominent notices
171
+ stating that you changed the files and the date of any change.
172
+
173
+ c) You must cause the whole of the work to be licensed at no
174
+ charge to all third parties under the terms of this License.
175
+
176
+ d) If a facility in the modified Library refers to a function or a
177
+ table of data to be supplied by an application program that uses
178
+ the facility, other than as an argument passed when the facility
179
+ is invoked, then you must make a good faith effort to ensure that,
180
+ in the event an application does not supply such function or
181
+ table, the facility still operates, and performs whatever part of
182
+ its purpose remains meaningful.
183
+
184
+ (For example, a function in a library to compute square roots has
185
+ a purpose that is entirely well-defined independent of the
186
+ application. Therefore, Subsection 2d requires that any
187
+ application-supplied function or table used by this function must
188
+ be optional: if the application does not supply it, the square
189
+ root function must still compute square roots.)
190
+
191
+These requirements apply to the modified work as a whole. If
192
+identifiable sections of that work are not derived from the Library,
193
+and can be reasonably considered independent and separate works in
194
+themselves, then this License, and its terms, do not apply to those
195
+sections when you distribute them as separate works. But when you
196
+distribute the same sections as part of a whole which is a work based
197
+on the Library, the distribution of the whole must be on the terms of
198
+this License, whose permissions for other licensees extend to the
199
+entire whole, and thus to each and every part regardless of who wrote
200
+it.
201
+
202
+Thus, it is not the intent of this section to claim rights or contest
203
+your rights to work written entirely by you; rather, the intent is to
204
+exercise the right to control the distribution of derivative or
205
+collective works based on the Library.
206
+
207
+In addition, mere aggregation of another work not based on the Library
208
+with the Library (or with a work based on the Library) on a volume of
209
+a storage or distribution medium does not bring the other work under
210
+the scope of this License.
211
+
212
+ 3. You may opt to apply the terms of the ordinary GNU General Public
213
+License instead of this License to a given copy of the Library. To do
214
+this, you must alter all the notices that refer to this License, so
215
+that they refer to the ordinary GNU General Public License, version 2,
216
+instead of to this License. (If a newer version than version 2 of the
217
+ordinary GNU General Public License has appeared, then you can specify
218
+that version instead if you wish.) Do not make any other change in
219
+these notices.
220
+
221
+ Once this change is made in a given copy, it is irreversible for
222
+that copy, so the ordinary GNU General Public License applies to all
223
+subsequent copies and derivative works made from that copy.
224
+
225
+ This option is useful when you wish to copy part of the code of
226
+the Library into a program that is not a library.
227
+
228
+ 4. You may copy and distribute the Library (or a portion or
229
+derivative of it, under Section 2) in object code or executable form
230
+under the terms of Sections 1 and 2 above provided that you accompany
231
+it with the complete corresponding machine-readable source code, which
232
+must be distributed under the terms of Sections 1 and 2 above on a
233
+medium customarily used for software interchange.
234
+
235
+ If distribution of object code is made by offering access to copy
236
+from a designated place, then offering equivalent access to copy the
237
+source code from the same place satisfies the requirement to
238
+distribute the source code, even though third parties are not
239
+compelled to copy the source along with the object code.
240
+
241
+ 5. A program that contains no derivative of any portion of the
242
+Library, but is designed to work with the Library by being compiled or
243
+linked with it, is called a "work that uses the Library". Such a
244
+work, in isolation, is not a derivative work of the Library, and
245
+therefore falls outside the scope of this License.
246
+
247
+ However, linking a "work that uses the Library" with the Library
248
+creates an executable that is a derivative of the Library (because it
249
+contains portions of the Library), rather than a "work that uses the
250
+library". The executable is therefore covered by this License.
251
+Section 6 states terms for distribution of such executables.
252
+
253
+ When a "work that uses the Library" uses material from a header file
254
+that is part of the Library, the object code for the work may be a
255
+derivative work of the Library even though the source code is not.
256
+Whether this is true is especially significant if the work can be
257
+linked without the Library, or if the work is itself a library. The
258
+threshold for this to be true is not precisely defined by law.
259
+
260
+ If such an object file uses only numerical parameters, data
261
+structure layouts and accessors, and small macros and small inline
262
+functions (ten lines or less in length), then the use of the object
263
+file is unrestricted, regardless of whether it is legally a derivative
264
+work. (Executables containing this object code plus portions of the
265
+Library will still fall under Section 6.)
266
+
267
+ Otherwise, if the work is a derivative of the Library, you may
268
+distribute the object code for the work under the terms of Section 6.
269
+Any executables containing that work also fall under Section 6,
270
+whether or not they are linked directly with the Library itself.
271
+
272
+ 6. As an exception to the Sections above, you may also combine or
273
+link a "work that uses the Library" with the Library to produce a
274
+work containing portions of the Library, and distribute that work
275
+under terms of your choice, provided that the terms permit
276
+modification of the work for the customer's own use and reverse
277
+engineering for debugging such modifications.
278
+
279
+ You must give prominent notice with each copy of the work that the
280
+Library is used in it and that the Library and its use are covered by
281
+this License. You must supply a copy of this License. If the work
282
+during execution displays copyright notices, you must include the
283
+copyright notice for the Library among them, as well as a reference
284
+directing the user to the copy of this License. Also, you must do one
285
+of these things:
286
+
287
+ a) Accompany the work with the complete corresponding
288
+ machine-readable source code for the Library including whatever
289
+ changes were used in the work (which must be distributed under
290
+ Sections 1 and 2 above); and, if the work is an executable linked
291
+ with the Library, with the complete machine-readable "work that
292
+ uses the Library", as object code and/or source code, so that the
293
+ user can modify the Library and then relink to produce a modified
294
+ executable containing the modified Library. (It is understood
295
+ that the user who changes the contents of definitions files in the
296
+ Library will not necessarily be able to recompile the application
297
+ to use the modified definitions.)
298
+
299
+ b) Use a suitable shared library mechanism for linking with the
300
+ Library. A suitable mechanism is one that (1) uses at run time a
301
+ copy of the library already present on the user's computer system,
302
+ rather than copying library functions into the executable, and (2)
303
+ will operate properly with a modified version of the library, if
304
+ the user installs one, as long as the modified version is
305
+ interface-compatible with the version that the work was made with.
306
+
307
+ c) Accompany the work with a written offer, valid for at
308
+ least three years, to give the same user the materials
309
+ specified in Subsection 6a, above, for a charge no more
310
+ than the cost of performing this distribution.
311
+
312
+ d) If distribution of the work is made by offering access to copy
313
+ from a designated place, offer equivalent access to copy the above
314
+ specified materials from the same place.
315
+
316
+ e) Verify that the user has already received a copy of these
317
+ materials or that you have already sent this user a copy.
318
+
319
+ For an executable, the required form of the "work that uses the
320
+Library" must include any data and utility programs needed for
321
+reproducing the executable from it. However, as a special exception,
322
+the materials to be distributed need not include anything that is
323
+normally distributed (in either source or binary form) with the major
324
+components (compiler, kernel, and so on) of the operating system on
325
+which the executable runs, unless that component itself accompanies
326
+the executable.
327
+
328
+ It may happen that this requirement contradicts the license
329
+restrictions of other proprietary libraries that do not normally
330
+accompany the operating system. Such a contradiction means you cannot
331
+use both them and the Library together in an executable that you
332
+distribute.
333
+
334
+ 7. You may place library facilities that are a work based on the
335
+Library side-by-side in a single library together with other library
336
+facilities not covered by this License, and distribute such a combined
337
+library, provided that the separate distribution of the work based on
338
+the Library and of the other library facilities is otherwise
339
+permitted, and provided that you do these two things:
340
+
341
+ a) Accompany the combined library with a copy of the same work
342
+ based on the Library, uncombined with any other library
343
+ facilities. This must be distributed under the terms of the
344
+ Sections above.
345
+
346
+ b) Give prominent notice with the combined library of the fact
347
+ that part of it is a work based on the Library, and explaining
348
+ where to find the accompanying uncombined form of the same work.
349
+
350
+ 8. You may not copy, modify, sublicense, link with, or distribute
351
+the Library except as expressly provided under this License. Any
352
+attempt otherwise to copy, modify, sublicense, link with, or
353
+distribute the Library is void, and will automatically terminate your
354
+rights under this License. However, parties who have received copies,
355
+or rights, from you under this License will not have their licenses
356
+terminated so long as such parties remain in full compliance.
357
+
358
+ 9. You are not required to accept this License, since you have not
359
+signed it. However, nothing else grants you permission to modify or
360
+distribute the Library or its derivative works. These actions are
361
+prohibited by law if you do not accept this License. Therefore, by
362
+modifying or distributing the Library (or any work based on the
363
+Library), you indicate your acceptance of this License to do so, and
364
+all its terms and conditions for copying, distributing or modifying
365
+the Library or works based on it.
366
+
367
+ 10. Each time you redistribute the Library (or any work based on the
368
+Library), the recipient automatically receives a license from the
369
+original licensor to copy, distribute, link with or modify the Library
370
+subject to these terms and conditions. You may not impose any further
371
+restrictions on the recipients' exercise of the rights granted herein.
372
+You are not responsible for enforcing compliance by third parties with
373
+this License.
374
+
375
+ 11. If, as a consequence of a court judgment or allegation of patent
376
+infringement or for any other reason (not limited to patent issues),
377
+conditions are imposed on you (whether by court order, agreement or
378
+otherwise) that contradict the conditions of this License, they do not
379
+excuse you from the conditions of this License. If you cannot
380
+distribute so as to satisfy simultaneously your obligations under this
381
+License and any other pertinent obligations, then as a consequence you
382
+may not distribute the Library at all. For example, if a patent
383
+license would not permit royalty-free redistribution of the Library by
384
+all those who receive copies directly or indirectly through you, then
385
+the only way you could satisfy both it and this License would be to
386
+refrain entirely from distribution of the Library.
387
+
388
+If any portion of this section is held invalid or unenforceable under any
389
+particular circumstance, the balance of the section is intended to apply,
390
+and the section as a whole is intended to apply in other circumstances.
391
+
392
+It is not the purpose of this section to induce you to infringe any
393
+patents or other property right claims or to contest validity of any
394
+such claims; this section has the sole purpose of protecting the
395
+integrity of the free software distribution system which is
396
+implemented by public license practices. Many people have made
397
+generous contributions to the wide range of software distributed
398
+through that system in reliance on consistent application of that
399
+system; it is up to the author/donor to decide if he or she is willing
400
+to distribute software through any other system and a licensee cannot
401
+impose that choice.
402
+
403
+This section is intended to make thoroughly clear what is believed to
404
+be a consequence of the rest of this License.
405
+
406
+ 12. If the distribution and/or use of the Library is restricted in
407
+certain countries either by patents or by copyrighted interfaces, the
408
+original copyright holder who places the Library under this License may add
409
+an explicit geographical distribution limitation excluding those countries,
410
+so that distribution is permitted only in or among countries not thus
411
+excluded. In such case, this License incorporates the limitation as if
412
+written in the body of this License.
413
+
414
+ 13. The Free Software Foundation may publish revised and/or new
415
+versions of the Lesser General Public License from time to time.
416
+Such new versions will be similar in spirit to the present version,
417
+but may differ in detail to address new problems or concerns.
418
+
419
+Each version is given a distinguishing version number. If the Library
420
+specifies a version number of this License which applies to it and
421
+"any later version", you have the option of following the terms and
422
+conditions either of that version or of any later version published by
423
+the Free Software Foundation. If the Library does not specify a
424
+license version number, you may choose any version ever published by
425
+the Free Software Foundation.
426
+
427
+ 14. If you wish to incorporate parts of the Library into other free
428
+programs whose distribution conditions are incompatible with these,
429
+write to the author to ask for permission. For software which is
430
+copyrighted by the Free Software Foundation, write to the Free
431
+Software Foundation; we sometimes make exceptions for this. Our
432
+decision will be guided by the two goals of preserving the free status
433
+of all derivatives of our free software and of promoting the sharing
434
+and reuse of software generally.
435
+
436
+ NO WARRANTY
437
+
438
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
439
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
440
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
441
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
442
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
443
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
444
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
445
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
446
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
447
+
448
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
449
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
450
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
451
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
452
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
453
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
454
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
455
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
456
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
457
+DAMAGES.
458
+
459
+ END OF TERMS AND CONDITIONS
460
+
461
+ How to Apply These Terms to Your New Libraries
462
+
463
+ If you develop a new library, and you want it to be of the greatest
464
+possible use to the public, we recommend making it free software that
465
+everyone can redistribute and change. You can do so by permitting
466
+redistribution under these terms (or, alternatively, under the terms of the
467
+ordinary General Public License).
468
+
469
+ To apply these terms, attach the following notices to the library. It is
470
+safest to attach them to the start of each source file to most effectively
471
+convey the exclusion of warranty; and each file should have at least the
472
+"copyright" line and a pointer to where the full notice is found.
473
+
474
+ {description}
475
+ Copyright (C) {year} {fullname}
476
+
477
+ This library is free software; you can redistribute it and/or
478
+ modify it under the terms of the GNU Lesser General Public
479
+ License as published by the Free Software Foundation; either
480
+ version 2.1 of the License, or (at your option) any later version.
481
+
482
+ This library is distributed in the hope that it will be useful,
483
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
484
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
485
+ Lesser General Public License for more details.
486
+
487
+ You should have received a copy of the GNU Lesser General Public
488
+ License along with this library; if not, write to the Free Software
489
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
490
+ USA
491
+
492
+Also add information on how to contact you by electronic and paper mail.
493
+
494
+You should also get your employer (if you work as a programmer) or your
495
+school, if any, to sign a "copyright disclaimer" for the library, if
496
+necessary. Here is a sample; alter the names:
497
+
498
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
499
+ library `Frob' (a library for tweaking knobs) written by James Random
500
+ Hacker.
501
+
502
+ {signature of Ty Coon}, 1 April 1990
503
+ Ty Coon, President of Vice
504
+
505
+That's all there is to it!
506
libhdhomerun_20150826.tgz/Makefile -> libhdhomerun_20190621.tgz/Makefile
Changed
19
1
2
CC := $(CROSS_COMPILE)gcc
3
STRIP := $(CROSS_COMPILE)strip
4
5
-CFLAGS += -Wall -O2 -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
6
+CFLAGS += -O2 -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wno-unused-parameter
7
LDFLAGS += -lpthread
8
SHARED = -shared -Wl,-soname,libhdhomerun$(LIBEXT)
9
10
11
LDFLAGS += -lsocket
12
endif
13
ifeq ($(OS),Darwin)
14
- CFLAGS += -arch i386 -arch x86_64
15
+ CFLAGS += -arch x86_64
16
LIBEXT := .dylib
17
SHARED := -dynamiclib -install_name libhdhomerun$(LIBEXT)
18
endif
19
libhdhomerun_20190621.tgz/README.md
Added
14
1
2
+Copyright © 2005-2017 Silicondust USA Inc. <www.silicondust.com>.
3
+
4
+This library implements the libhdhomerun protocol for use with Silicondust HDHomeRun TV tuners.
5
+
6
+To compile simply "make" - this will compile both the library and the hdhomerun_config command line
7
+utility suitable for sending commands or scripting control of a HDHomeRun.
8
+
9
+The top level API is hdhomerun_device - see hdhomerun_device.h for documentation.
10
+
11
+Additional libraries required:
12
+- pthread (osx, linux, bsd)
13
+- iphlpapi (windows)
14
libhdhomerun_20150826.tgz/hdhomerun_channels.c -> libhdhomerun_20190621.tgz/hdhomerun_channels.c
Changed
33
1
2
/*
3
* hdhomerun_channels.c
4
*
5
- * Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2007-2014 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
{ 0, 0, 0, 0}
12
};
13
14
+/* TW antenna channels. */
15
+static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_tw_bcast[] = {
16
+ { 7, 13, 177000000, 6000000},
17
+ { 14, 69, 473000000, 6000000},
18
+ { 0, 0, 0, 0}
19
+};
20
+
21
/* US antenna channels. */
22
static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_bcast[] = {
23
{ 2, 4, 57000000, 6000000},
24
25
{"au-cable", hdhomerun_channelmap_range_eu_cable, "au-cable", "AU"},
26
{"eu-bcast", hdhomerun_channelmap_range_eu_bcast, "eu-bcast", NULL},
27
{"eu-cable", hdhomerun_channelmap_range_eu_cable, "eu-cable", NULL},
28
- {"tw-bcast", hdhomerun_channelmap_range_us_bcast, "tw-bcast", "TW"},
29
+ {"tw-bcast", hdhomerun_channelmap_range_tw_bcast, "tw-bcast", "TW"},
30
{"tw-cable", hdhomerun_channelmap_range_us_cable, "tw-cable", "TW"},
31
32
{"kr-bcast", hdhomerun_channelmap_range_us_bcast, "kr-bcast", "KR"},
33
libhdhomerun_20150826.tgz/hdhomerun_channels.h -> libhdhomerun_20190621.tgz/hdhomerun_channels.h
Changed
55
1
2
/*
3
* hdhomerun_channels.h
4
*
5
- * Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2007-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
struct hdhomerun_channel_entry_t;
12
struct hdhomerun_channel_list_t;
13
14
-extern LIBTYPE const char *hdhomerun_channelmap_get_channelmap_from_country_source(const char *countrycode, const char *source, const char *supported);
15
-extern LIBTYPE const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap);
16
+extern LIBHDHOMERUN_API const char *hdhomerun_channelmap_get_channelmap_from_country_source(const char *countrycode, const char *source, const char *supported);
17
+extern LIBHDHOMERUN_API const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap);
18
19
-extern LIBTYPE uint16_t hdhomerun_channel_entry_channel_number(struct hdhomerun_channel_entry_t *entry);
20
-extern LIBTYPE uint32_t hdhomerun_channel_entry_frequency(struct hdhomerun_channel_entry_t *entry);
21
-extern LIBTYPE const char *hdhomerun_channel_entry_name(struct hdhomerun_channel_entry_t *entry);
22
+extern LIBHDHOMERUN_API uint16_t hdhomerun_channel_entry_channel_number(struct hdhomerun_channel_entry_t *entry);
23
+extern LIBHDHOMERUN_API uint32_t hdhomerun_channel_entry_frequency(struct hdhomerun_channel_entry_t *entry);
24
+extern LIBHDHOMERUN_API const char *hdhomerun_channel_entry_name(struct hdhomerun_channel_entry_t *entry);
25
26
-extern LIBTYPE struct hdhomerun_channel_list_t *hdhomerun_channel_list_create(const char *channelmap);
27
-extern LIBTYPE void hdhomerun_channel_list_destroy(struct hdhomerun_channel_list_t *channel_list);
28
+extern LIBHDHOMERUN_API struct hdhomerun_channel_list_t *hdhomerun_channel_list_create(const char *channelmap);
29
+extern LIBHDHOMERUN_API void hdhomerun_channel_list_destroy(struct hdhomerun_channel_list_t *channel_list);
30
31
-extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_first(struct hdhomerun_channel_list_t *channel_list);
32
-extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_last(struct hdhomerun_channel_list_t *channel_list);
33
-extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_next(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry);
34
-extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_prev(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry);
35
-extern LIBTYPE uint32_t hdhomerun_channel_list_total_count(struct hdhomerun_channel_list_t *channel_list);
36
-extern LIBTYPE uint32_t hdhomerun_channel_list_frequency_count(struct hdhomerun_channel_list_t *channel_list);
37
+extern LIBHDHOMERUN_API struct hdhomerun_channel_entry_t *hdhomerun_channel_list_first(struct hdhomerun_channel_list_t *channel_list);
38
+extern LIBHDHOMERUN_API struct hdhomerun_channel_entry_t *hdhomerun_channel_list_last(struct hdhomerun_channel_list_t *channel_list);
39
+extern LIBHDHOMERUN_API struct hdhomerun_channel_entry_t *hdhomerun_channel_list_next(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry);
40
+extern LIBHDHOMERUN_API struct hdhomerun_channel_entry_t *hdhomerun_channel_list_prev(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry);
41
+extern LIBHDHOMERUN_API uint32_t hdhomerun_channel_list_total_count(struct hdhomerun_channel_list_t *channel_list);
42
+extern LIBHDHOMERUN_API uint32_t hdhomerun_channel_list_frequency_count(struct hdhomerun_channel_list_t *channel_list);
43
44
-extern LIBTYPE uint32_t hdhomerun_channel_frequency_round(uint32_t frequency, uint32_t resolution);
45
-extern LIBTYPE uint32_t hdhomerun_channel_frequency_round_normal(uint32_t frequency);
46
-extern LIBTYPE uint32_t hdhomerun_channel_number_to_frequency(struct hdhomerun_channel_list_t *channel_list, uint16_t channel_number);
47
-extern LIBTYPE uint16_t hdhomerun_channel_frequency_to_number(struct hdhomerun_channel_list_t *channel_list, uint32_t frequency);
48
+extern LIBHDHOMERUN_API uint32_t hdhomerun_channel_frequency_round(uint32_t frequency, uint32_t resolution);
49
+extern LIBHDHOMERUN_API uint32_t hdhomerun_channel_frequency_round_normal(uint32_t frequency);
50
+extern LIBHDHOMERUN_API uint32_t hdhomerun_channel_number_to_frequency(struct hdhomerun_channel_list_t *channel_list, uint16_t channel_number);
51
+extern LIBHDHOMERUN_API uint16_t hdhomerun_channel_frequency_to_number(struct hdhomerun_channel_list_t *channel_list, uint32_t frequency);
52
53
#ifdef __cplusplus
54
}
55
libhdhomerun_20150826.tgz/hdhomerun_channelscan.c -> libhdhomerun_20190621.tgz/hdhomerun_channelscan.c
Changed
107
1
2
/*
3
* hdhomerun_channelscan.c
4
*
5
- * Copyright © 2007-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2007-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
program->name[length] = 0;
12
}
13
14
-static int channelscan_detect_programs(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result, bool_t *pchanged, bool_t *pincomplete)
15
+static int channelscan_detect_programs(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result, bool *pchanged, bool *pincomplete)
16
{
17
- *pchanged = FALSE;
18
- *pincomplete = FALSE;
19
+ *pchanged = false;
20
+ *pincomplete = false;
21
22
char *streaminfo;
23
int ret = hdhomerun_device_get_tuner_streaminfo(scan->hd, &streaminfo);
24
25
26
unsigned int transport_stream_id;
27
if (sscanf(line, "tsid=0x%x", &transport_stream_id) == 1) {
28
- result->transport_stream_id = transport_stream_id;
29
- result->transport_stream_id_detected = TRUE;
30
+ result->transport_stream_id = (uint16_t)transport_stream_id;
31
+ result->transport_stream_id_detected = true;
32
continue;
33
}
34
35
unsigned int original_network_id;
36
if (sscanf(line, "onid=0x%x", &original_network_id) == 1) {
37
- result->original_network_id = original_network_id;
38
- result->original_network_id_detected = TRUE;
39
+ result->original_network_id = (uint16_t)original_network_id;
40
+ result->original_network_id_detected = true;
41
continue;
42
}
43
44
45
virtual_minor = 0;
46
}
47
48
- program.program_number = program_number;
49
- program.virtual_major = virtual_major;
50
- program.virtual_minor = virtual_minor;
51
+ program.program_number = (uint16_t)program_number;
52
+ program.virtual_major = (uint16_t)virtual_major;
53
+ program.virtual_minor = (uint16_t)virtual_minor;
54
55
channelscan_extract_name(&program, line);
56
57
58
program.type = HDHOMERUN_CHANNELSCAN_PROGRAM_ENCRYPTED;
59
} else if (strstr(line, "(no data)")) {
60
program.type = HDHOMERUN_CHANNELSCAN_PROGRAM_NODATA;
61
- *pincomplete = TRUE;
62
+ *pincomplete = true;
63
} else {
64
program.type = HDHOMERUN_CHANNELSCAN_PROGRAM_NORMAL;
65
if ((program.virtual_major == 0) || (program.name[0] == 0)) {
66
- *pincomplete = TRUE;
67
+ *pincomplete = true;
68
}
69
}
70
71
if (memcmp(&result->programs[program_count], &program, sizeof(program)) != 0) {
72
memcpy(&result->programs[program_count], &program, sizeof(program));
73
- *pchanged = TRUE;
74
+ *pchanged = true;
75
}
76
77
program_count++;
78
}
79
80
if (program_count == 0) {
81
- *pincomplete = TRUE;
82
+ *pincomplete = true;
83
}
84
if (result->program_count != program_count) {
85
result->program_count = program_count;
86
- *pchanged = TRUE;
87
+ *pchanged = true;
88
}
89
90
return 1;
91
92
uint64_t complete_time = getcurrenttime() + 1000;
93
94
while (1) {
95
- bool_t changed, incomplete;
96
+ bool changed, incomplete;
97
ret = channelscan_detect_programs(scan, result, &changed, &incomplete);
98
if (ret <= 0) {
99
return ret;
100
101
}
102
}
103
104
- return scan->scanned_channels * 100 / (scan->scanned_channels + channels_remaining);
105
+ return (uint8_t) (scan->scanned_channels * 100 / (scan->scanned_channels + channels_remaining));
106
}
107
libhdhomerun_20150826.tgz/hdhomerun_channelscan.h -> libhdhomerun_20190621.tgz/hdhomerun_channelscan.h
Changed
28
1
2
/*
3
* hdhomerun_channelscan.h
4
*
5
- * Copyright © 2007-2008 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2007-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
12
struct hdhomerun_channelscan_t;
13
14
-extern LIBTYPE struct hdhomerun_channelscan_t *channelscan_create(struct hdhomerun_device_t *hd, const char *channelmap);
15
-extern LIBTYPE void channelscan_destroy(struct hdhomerun_channelscan_t *scan);
16
+extern LIBHDHOMERUN_API struct hdhomerun_channelscan_t *channelscan_create(struct hdhomerun_device_t *hd, const char *channelmap);
17
+extern LIBHDHOMERUN_API void channelscan_destroy(struct hdhomerun_channelscan_t *scan);
18
19
-extern LIBTYPE int channelscan_advance(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result);
20
-extern LIBTYPE int channelscan_detect(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result);
21
-extern LIBTYPE uint8_t channelscan_get_progress(struct hdhomerun_channelscan_t *scan);
22
+extern LIBHDHOMERUN_API int channelscan_advance(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result);
23
+extern LIBHDHOMERUN_API int channelscan_detect(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result);
24
+extern LIBHDHOMERUN_API uint8_t channelscan_get_progress(struct hdhomerun_channelscan_t *scan);
25
26
#ifdef __cplusplus
27
}
28
libhdhomerun_20150826.tgz/hdhomerun_config.c -> libhdhomerun_20190621.tgz/hdhomerun_config.c
Changed
165
1
2
/*
3
* hdhomerun_config.c
4
*
5
- * Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2017 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
12
#include "hdhomerun.h"
13
14
-/*
15
- * The console output format should be set to UTF-8, however in XP and Vista this breaks batch file processing.
16
- * Attempting to restore on exit fails to restore if the program is terminated by the user.
17
- * Solution - set the output format each printf.
18
- */
19
-#if defined(__WINDOWS__)
20
-#define printf console_printf
21
-#define vprintf console_vprintf
22
-#endif
23
-
24
static const char *appname;
25
26
struct hdhomerun_device_t *hd;
27
28
appname = argv0;
29
}
30
31
-static bool_t contains(const char *arg, const char *cmpstr)
32
+static bool contains(const char *arg, const char *cmpstr)
33
{
34
if (strcmp(arg, cmpstr) == 0) {
35
- return TRUE;
36
+ return true;
37
}
38
39
if (*arg++ != '-') {
40
- return FALSE;
41
+ return false;
42
}
43
if (*arg++ != '-') {
44
- return FALSE;
45
+ return false;
46
}
47
if (strcmp(arg, cmpstr) == 0) {
48
- return TRUE;
49
+ return true;
50
}
51
52
- return FALSE;
53
+ return false;
54
}
55
56
static uint32_t parse_ip_addr(const char *str)
57
58
}
59
60
struct hdhomerun_discover_device_t result_list[64];
61
- int count = hdhomerun_discover_find_devices_custom_v2(target_ip, HDHOMERUN_DEVICE_TYPE_TUNER, HDHOMERUN_DEVICE_ID_WILDCARD, result_list, 64);
62
- if (count < 0) {
63
+ int result_count = hdhomerun_discover_find_devices_custom_v2(target_ip, HDHOMERUN_DEVICE_TYPE_WILDCARD, HDHOMERUN_DEVICE_ID_WILDCARD, result_list, 64);
64
+ if (result_count < 0) {
65
fprintf(stderr, "error sending discover request\n");
66
return -1;
67
}
68
- if (count == 0) {
69
- printf("no devices found\n");
70
- return 0;
71
- }
72
73
- int index;
74
- for (index = 0; index < count; index++) {
75
- struct hdhomerun_discover_device_t *result = &result_list[index];
76
+ struct hdhomerun_discover_device_t *result = result_list;
77
+ struct hdhomerun_discover_device_t *result_end = result_list + result_count;
78
+
79
+ int valid_count = 0;
80
+ while (result < result_end) {
81
+ if (result->device_id == 0) {
82
+ result++;
83
+ continue;
84
+ }
85
+
86
printf("hdhomerun device %08X found at %u.%u.%u.%u\n",
87
(unsigned int)result->device_id,
88
(unsigned int)(result->ip_addr >> 24) & 0x0FF, (unsigned int)(result->ip_addr >> 16) & 0x0FF,
89
(unsigned int)(result->ip_addr >> 8) & 0x0FF, (unsigned int)(result->ip_addr >> 0) & 0x0FF
90
);
91
+
92
+ valid_count++;
93
+ result++;
94
+ }
95
+
96
+ if (valid_count == 0) {
97
+ printf("no devices found\n");
98
}
99
100
- return count;
101
+ return valid_count;
102
}
103
104
static int cmd_get(const char *item)
105
106
return cmd_set_internal(item, value);
107
}
108
109
-static volatile sig_atomic_t sigabort_flag = FALSE;
110
-static volatile sig_atomic_t siginfo_flag = FALSE;
111
+static volatile sig_atomic_t sigabort_flag = false;
112
+static volatile sig_atomic_t siginfo_flag = false;
113
114
static void sigabort_handler(int arg)
115
{
116
- sigabort_flag = TRUE;
117
+ sigabort_flag = true;
118
}
119
120
static void siginfo_handler(int arg)
121
{
122
- siginfo_flag = TRUE;
123
+ siginfo_flag = true;
124
}
125
126
static void register_signal_handlers(sig_t sigpipe_handler, sig_t sigint_handler, sig_t siginfo_handler)
127
128
if (siginfo_flag) {
129
fprintf(stderr, "\n");
130
cmd_save_print_stats();
131
- siginfo_flag = FALSE;
132
+ siginfo_flag = false;
133
}
134
135
size_t actual_size;
136
137
}
138
139
/* Windows - indicate activity to suppress auto sleep mode. */
140
- #if defined(__WINDOWS__)
141
+ #if defined(_WIN32)
142
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
143
#endif
144
145
146
if (argc < 2) {
147
return help();
148
}
149
- uint32_t lockkey = strtoul(argv[0], NULL, 0);
150
+ uint32_t lockkey = (uint32_t)strtoul(argv[0], NULL, 0);
151
hdhomerun_device_tuner_lockkey_use_value(hd, lockkey);
152
153
cmd = argv[1];
154
155
156
static int main_internal(int argc, char *argv[])
157
{
158
-#if defined(__WINDOWS__)
159
+#if defined(_WIN32)
160
+ /* Configure console for UTF-8. */
161
+ SetConsoleOutputCP(CP_UTF8);
162
/* Initialize network socket support. */
163
WORD wVersionRequested = MAKEWORD(2, 0);
164
WSADATA wsaData;
165
libhdhomerun_20150826.tgz/hdhomerun_control.c -> libhdhomerun_20190621.tgz/hdhomerun_control.c
Changed
198
1
2
/*
3
* hdhomerun_control.c
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2016 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
uint32_t desired_device_ip;
12
uint32_t actual_device_id;
13
uint32_t actual_device_ip;
14
- hdhomerun_sock_t sock;
15
+ struct hdhomerun_sock_t *sock;
16
struct hdhomerun_debug_t *dbg;
17
struct hdhomerun_pkt_t tx_pkt;
18
struct hdhomerun_pkt_t rx_pkt;
19
20
21
static void hdhomerun_control_close_sock(struct hdhomerun_control_sock_t *cs)
22
{
23
- if (cs->sock == HDHOMERUN_SOCK_INVALID) {
24
+ if (!cs->sock) {
25
return;
26
}
27
28
hdhomerun_sock_destroy(cs->sock);
29
- cs->sock = HDHOMERUN_SOCK_INVALID;
30
+ cs->sock = NULL;
31
}
32
33
void hdhomerun_control_set_device(struct hdhomerun_control_sock_t *cs, uint32_t device_id, uint32_t device_ip)
34
35
}
36
37
cs->dbg = dbg;
38
- cs->sock = HDHOMERUN_SOCK_INVALID;
39
hdhomerun_control_set_device(cs, device_id, device_ip);
40
41
return cs;
42
43
free(cs);
44
}
45
46
-static bool_t hdhomerun_control_connect_sock(struct hdhomerun_control_sock_t *cs)
47
+static bool hdhomerun_control_connect_sock(struct hdhomerun_control_sock_t *cs)
48
{
49
- if (cs->sock != HDHOMERUN_SOCK_INVALID) {
50
- return TRUE;
51
+ if (cs->sock) {
52
+ return true;
53
}
54
55
if ((cs->desired_device_id == 0) && (cs->desired_device_ip == 0)) {
56
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_connect_sock: no device specified\n");
57
- return FALSE;
58
+ return false;
59
}
60
if (hdhomerun_discover_is_ip_multicast(cs->desired_device_ip)) {
61
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_connect_sock: cannot use multicast ip address for device operations\n");
62
- return FALSE;
63
+ return false;
64
}
65
66
/* Find device. */
67
struct hdhomerun_discover_device_t result;
68
if (hdhomerun_discover_find_devices_custom_v2(cs->desired_device_ip, HDHOMERUN_DEVICE_TYPE_WILDCARD, cs->desired_device_id, &result, 1) <= 0) {
69
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_connect_sock: device not found\n");
70
- return FALSE;
71
+ return false;
72
}
73
cs->actual_device_ip = result.ip_addr;
74
cs->actual_device_id = result.device_id;
75
76
/* Create socket. */
77
cs->sock = hdhomerun_sock_create_tcp();
78
- if (cs->sock == HDHOMERUN_SOCK_INVALID) {
79
+ if (!cs->sock) {
80
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_connect_sock: failed to create socket (%d)\n", hdhomerun_sock_getlasterror());
81
- return FALSE;
82
+ return false;
83
}
84
85
/* Initiate connection. */
86
if (!hdhomerun_sock_connect(cs->sock, cs->actual_device_ip, HDHOMERUN_CONTROL_TCP_PORT, HDHOMERUN_CONTROL_CONNECT_TIMEOUT)) {
87
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_connect_sock: failed to connect (%d)\n", hdhomerun_sock_getlasterror());
88
hdhomerun_control_close_sock(cs);
89
- return FALSE;
90
+ return false;
91
}
92
93
/* Success. */
94
- return TRUE;
95
+ return true;
96
}
97
98
uint32_t hdhomerun_control_get_device_id(struct hdhomerun_control_sock_t *cs)
99
100
return addr;
101
}
102
103
-static bool_t hdhomerun_control_send_sock(struct hdhomerun_control_sock_t *cs, struct hdhomerun_pkt_t *tx_pkt)
104
+static bool hdhomerun_control_send_sock(struct hdhomerun_control_sock_t *cs, struct hdhomerun_pkt_t *tx_pkt)
105
{
106
if (!hdhomerun_sock_send(cs->sock, tx_pkt->start, tx_pkt->end - tx_pkt->start, HDHOMERUN_CONTROL_SEND_TIMEOUT)) {
107
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_send_sock: send failed (%d)\n", hdhomerun_sock_getlasterror());
108
hdhomerun_control_close_sock(cs);
109
- return FALSE;
110
+ return false;
111
}
112
113
- return TRUE;
114
+ return true;
115
}
116
117
-static bool_t hdhomerun_control_recv_sock(struct hdhomerun_control_sock_t *cs, struct hdhomerun_pkt_t *rx_pkt, uint16_t *ptype, uint64_t recv_timeout)
118
+static bool hdhomerun_control_recv_sock(struct hdhomerun_control_sock_t *cs, struct hdhomerun_pkt_t *rx_pkt, uint16_t *ptype, uint64_t recv_timeout)
119
{
120
uint64_t stop_time = getcurrenttime() + recv_timeout;
121
hdhomerun_pkt_reset(rx_pkt);
122
123
if (current_time >= stop_time) {
124
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_recv_sock: timeout\n");
125
hdhomerun_control_close_sock(cs);
126
- return FALSE;
127
+ return false;
128
}
129
130
size_t length = rx_pkt->limit - rx_pkt->end;
131
if (!hdhomerun_sock_recv(cs->sock, rx_pkt->end, &length, stop_time - current_time)) {
132
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_recv_sock: recv failed (%d)\n", hdhomerun_sock_getlasterror());
133
hdhomerun_control_close_sock(cs);
134
- return FALSE;
135
+ return false;
136
}
137
138
rx_pkt->end += length;
139
140
if (ret < 0) {
141
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_recv_sock: frame error\n");
142
hdhomerun_control_close_sock(cs);
143
- return FALSE;
144
+ return false;
145
}
146
if (ret > 0) {
147
- return TRUE;
148
+ return true;
149
}
150
}
151
}
152
153
154
int i;
155
for (i = 0; i < 2; i++) {
156
- if (cs->sock == HDHOMERUN_SOCK_INVALID) {
157
+ if (!cs->sock) {
158
if (!hdhomerun_control_connect_sock(cs)) {
159
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_send_recv: connect failed\n");
160
return -1;
161
162
/* Request. */
163
hdhomerun_pkt_reset(tx_pkt);
164
165
- int name_len = (int)strlen(name) + 1;
166
+ size_t name_len = strlen(name) + 1;
167
if (tx_pkt->end + 3 + name_len > tx_pkt->limit) {
168
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_get_set: request too long\n");
169
return -1;
170
171
hdhomerun_pkt_write_mem(tx_pkt, (const void *)name, name_len);
172
173
if (value) {
174
- int value_len = (int)strlen(value) + 1;
175
+ size_t value_len = strlen(value) + 1;
176
if (tx_pkt->end + 3 + value_len > tx_pkt->limit) {
177
hdhomerun_debug_printf(cs->dbg, "hdhomerun_control_get_set: request too long\n");
178
return -1;
179
180
}
181
182
return 0;
183
+
184
+ default:
185
+ break;
186
}
187
188
rx_pkt->pos = next;
189
190
{
191
struct hdhomerun_pkt_t *tx_pkt = &cs->tx_pkt;
192
struct hdhomerun_pkt_t *rx_pkt = &cs->rx_pkt;
193
- bool_t upload_delay = FALSE;
194
+ bool upload_delay = false;
195
uint32_t sequence = 0;
196
197
/* Special case detection. */
198
libhdhomerun_20150826.tgz/hdhomerun_control.h -> libhdhomerun_20190621.tgz/hdhomerun_control.h
Changed
75
1
2
/*
3
* hdhomerun_control.h
4
*
5
- * Copyright © 2006 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
*
12
* When no longer needed, the socket should be destroyed by calling hdhomerun_control_destroy.
13
*/
14
-extern LIBTYPE struct hdhomerun_control_sock_t *hdhomerun_control_create(uint32_t device_id, uint32_t device_ip, struct hdhomerun_debug_t *dbg);
15
-extern LIBTYPE void hdhomerun_control_destroy(struct hdhomerun_control_sock_t *cs);
16
+extern LIBHDHOMERUN_API struct hdhomerun_control_sock_t *hdhomerun_control_create(uint32_t device_id, uint32_t device_ip, struct hdhomerun_debug_t *dbg);
17
+extern LIBHDHOMERUN_API void hdhomerun_control_destroy(struct hdhomerun_control_sock_t *cs);
18
19
/*
20
* Get the actual device id or ip of the device.
21
*
22
* Returns 0 if the device id cannot be determined.
23
*/
24
-extern LIBTYPE uint32_t hdhomerun_control_get_device_id(struct hdhomerun_control_sock_t *cs);
25
-extern LIBTYPE uint32_t hdhomerun_control_get_device_ip(struct hdhomerun_control_sock_t *cs);
26
-extern LIBTYPE uint32_t hdhomerun_control_get_device_id_requested(struct hdhomerun_control_sock_t *cs);
27
-extern LIBTYPE uint32_t hdhomerun_control_get_device_ip_requested(struct hdhomerun_control_sock_t *cs);
28
+extern LIBHDHOMERUN_API uint32_t hdhomerun_control_get_device_id(struct hdhomerun_control_sock_t *cs);
29
+extern LIBHDHOMERUN_API uint32_t hdhomerun_control_get_device_ip(struct hdhomerun_control_sock_t *cs);
30
+extern LIBHDHOMERUN_API uint32_t hdhomerun_control_get_device_id_requested(struct hdhomerun_control_sock_t *cs);
31
+extern LIBHDHOMERUN_API uint32_t hdhomerun_control_get_device_ip_requested(struct hdhomerun_control_sock_t *cs);
32
33
-extern LIBTYPE void hdhomerun_control_set_device(struct hdhomerun_control_sock_t *cs, uint32_t device_id, uint32_t device_ip);
34
+extern LIBHDHOMERUN_API void hdhomerun_control_set_device(struct hdhomerun_control_sock_t *cs, uint32_t device_id, uint32_t device_ip);
35
36
/*
37
* Get the local machine IP address used when communicating with the device.
38
39
*
40
* Returns 32-bit IP address with native endianness, or 0 on error.
41
*/
42
-extern LIBTYPE uint32_t hdhomerun_control_get_local_addr(struct hdhomerun_control_sock_t *cs);
43
+extern LIBHDHOMERUN_API uint32_t hdhomerun_control_get_local_addr(struct hdhomerun_control_sock_t *cs);
44
45
/*
46
* Low-level communication.
47
*/
48
-extern LIBTYPE int hdhomerun_control_send_recv(struct hdhomerun_control_sock_t *cs, struct hdhomerun_pkt_t *tx_pkt, struct hdhomerun_pkt_t *rx_pkt, uint16_t type);
49
+extern LIBHDHOMERUN_API int hdhomerun_control_send_recv(struct hdhomerun_control_sock_t *cs, struct hdhomerun_pkt_t *tx_pkt, struct hdhomerun_pkt_t *rx_pkt, uint16_t type);
50
51
/*
52
* Get/set a control variable on the device.
53
54
* Returns 0 if the operation was rejected (pvalue NULL, perror set).
55
* Returns -1 if a communication error occurs.
56
*/
57
-extern LIBTYPE int hdhomerun_control_get(struct hdhomerun_control_sock_t *cs, const char *name, char **pvalue, char **perror);
58
-extern LIBTYPE int hdhomerun_control_set(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, char **pvalue, char **perror);
59
-extern LIBTYPE int hdhomerun_control_set_with_lockkey(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, uint32_t lockkey, char **pvalue, char **perror);
60
+extern LIBHDHOMERUN_API int hdhomerun_control_get(struct hdhomerun_control_sock_t *cs, const char *name, char **pvalue, char **perror);
61
+extern LIBHDHOMERUN_API int hdhomerun_control_set(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, char **pvalue, char **perror);
62
+extern LIBHDHOMERUN_API int hdhomerun_control_set_with_lockkey(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, uint32_t lockkey, char **pvalue, char **perror);
63
64
/*
65
* Upload new firmware to the device.
66
67
* Returns 0 if the upload was rejected.
68
* Returns -1 if an error occurs.
69
*/
70
-extern LIBTYPE int hdhomerun_control_upgrade(struct hdhomerun_control_sock_t *cs, FILE *upgrade_file);
71
+extern LIBHDHOMERUN_API int hdhomerun_control_upgrade(struct hdhomerun_control_sock_t *cs, FILE *upgrade_file);
72
73
#ifdef __cplusplus
74
}
75
libhdhomerun_20150826.tgz/hdhomerun_debug.c -> libhdhomerun_20190621.tgz/hdhomerun_debug.c
Changed
442
1
2
/*
3
* hdhomerun_debug.c
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2007-2016 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
struct hdhomerun_debug_message_t
12
{
13
struct hdhomerun_debug_message_t *next;
14
- struct hdhomerun_debug_message_t *prev;
15
char buffer[2048];
16
};
17
18
struct hdhomerun_debug_t
19
{
20
- pthread_t thread;
21
- volatile bool_t enabled;
22
- volatile bool_t terminate;
23
+ thread_task_t thread;
24
+ volatile bool enabled;
25
+ volatile bool terminate;
26
char *prefix;
27
28
- pthread_mutex_t print_lock;
29
- pthread_mutex_t queue_lock;
30
- pthread_mutex_t send_lock;
31
+ thread_mutex_t print_lock;
32
+ thread_mutex_t queue_lock;
33
+ thread_mutex_t send_lock;
34
35
+ thread_cond_t queue_cond;
36
struct hdhomerun_debug_message_t *queue_head;
37
struct hdhomerun_debug_message_t *queue_tail;
38
uint32_t queue_depth;
39
40
41
char *file_name;
42
FILE *file_fp;
43
- hdhomerun_sock_t sock;
44
+ struct hdhomerun_sock_t *sock;
45
};
46
47
-static THREAD_FUNC_PREFIX hdhomerun_debug_thread_execute(void *arg);
48
+static void hdhomerun_debug_thread_execute(void *arg);
49
50
struct hdhomerun_debug_t *hdhomerun_debug_create(void)
51
{
52
53
return NULL;
54
}
55
56
- dbg->sock = HDHOMERUN_SOCK_INVALID;
57
+ thread_mutex_init(&dbg->print_lock);
58
+ thread_mutex_init(&dbg->queue_lock);
59
+ thread_mutex_init(&dbg->send_lock);
60
+ thread_cond_init(&dbg->queue_cond);
61
62
- pthread_mutex_init(&dbg->print_lock, NULL);
63
- pthread_mutex_init(&dbg->queue_lock, NULL);
64
- pthread_mutex_init(&dbg->send_lock, NULL);
65
-
66
- if (pthread_create(&dbg->thread, NULL, &hdhomerun_debug_thread_execute, dbg) != 0) {
67
+ if (!thread_task_create(&dbg->thread, &hdhomerun_debug_thread_execute, dbg)) {
68
free(dbg);
69
return NULL;
70
}
71
72
return;
73
}
74
75
- dbg->terminate = TRUE;
76
- pthread_join(dbg->thread, NULL);
77
+ dbg->terminate = true;
78
+ thread_cond_signal(&dbg->queue_cond);
79
+ thread_task_join(dbg->thread);
80
81
if (dbg->prefix) {
82
free(dbg->prefix);
83
84
if (dbg->file_fp) {
85
fclose(dbg->file_fp);
86
}
87
- if (dbg->sock != HDHOMERUN_SOCK_INVALID) {
88
+ if (dbg->sock) {
89
hdhomerun_sock_destroy(dbg->sock);
90
}
91
92
+ thread_cond_dispose(&dbg->queue_cond);
93
+ thread_mutex_dispose(&dbg->print_lock);
94
+ thread_mutex_dispose(&dbg->queue_lock);
95
+ thread_mutex_dispose(&dbg->send_lock);
96
free(dbg);
97
}
98
99
100
dbg->file_fp = NULL;
101
}
102
103
- if (dbg->sock != HDHOMERUN_SOCK_INVALID) {
104
+ if (dbg->sock) {
105
hdhomerun_sock_destroy(dbg->sock);
106
- dbg->sock = HDHOMERUN_SOCK_INVALID;
107
+ dbg->sock = NULL;
108
}
109
}
110
111
112
hdhomerun_debug_flush(dbg, timeout);
113
}
114
115
- pthread_mutex_lock(&dbg->send_lock);
116
+ thread_mutex_lock(&dbg->send_lock);
117
hdhomerun_debug_close_internal(dbg);
118
dbg->connect_delay = 0;
119
- pthread_mutex_unlock(&dbg->send_lock);
120
+ thread_mutex_unlock(&dbg->send_lock);
121
}
122
123
void hdhomerun_debug_set_filename(struct hdhomerun_debug_t *dbg, const char *filename)
124
125
return;
126
}
127
128
- pthread_mutex_lock(&dbg->send_lock);
129
+ thread_mutex_lock(&dbg->send_lock);
130
131
if (!filename && !dbg->file_name) {
132
- pthread_mutex_unlock(&dbg->send_lock);
133
+ thread_mutex_unlock(&dbg->send_lock);
134
return;
135
}
136
if (filename && dbg->file_name) {
137
if (strcmp(filename, dbg->file_name) == 0) {
138
- pthread_mutex_unlock(&dbg->send_lock);
139
+ thread_mutex_unlock(&dbg->send_lock);
140
return;
141
}
142
}
143
144
dbg->file_name = strdup(filename);
145
}
146
147
- pthread_mutex_unlock(&dbg->send_lock);
148
+ thread_mutex_unlock(&dbg->send_lock);
149
}
150
151
void hdhomerun_debug_set_prefix(struct hdhomerun_debug_t *dbg, const char *prefix)
152
153
return;
154
}
155
156
- pthread_mutex_lock(&dbg->print_lock);
157
+ thread_mutex_lock(&dbg->print_lock);
158
159
if (dbg->prefix) {
160
free(dbg->prefix);
161
162
dbg->prefix = strdup(prefix);
163
}
164
165
- pthread_mutex_unlock(&dbg->print_lock);
166
+ thread_mutex_unlock(&dbg->print_lock);
167
}
168
169
void hdhomerun_debug_enable(struct hdhomerun_debug_t *dbg)
170
171
if (!dbg) {
172
return;
173
}
174
+ if (dbg->enabled) {
175
+ return;
176
+ }
177
178
- dbg->enabled = TRUE;
179
+ dbg->enabled = true;
180
+ thread_cond_signal(&dbg->queue_cond);
181
}
182
183
void hdhomerun_debug_disable(struct hdhomerun_debug_t *dbg)
184
185
return;
186
}
187
188
- dbg->enabled = FALSE;
189
+ dbg->enabled = false;
190
}
191
192
-bool_t hdhomerun_debug_enabled(struct hdhomerun_debug_t *dbg)
193
+bool hdhomerun_debug_enabled(struct hdhomerun_debug_t *dbg)
194
{
195
if (!dbg) {
196
- return FALSE;
197
+ return false;
198
}
199
200
return dbg->enabled;
201
202
timeout = getcurrenttime() + timeout;
203
204
while (getcurrenttime() < timeout) {
205
- pthread_mutex_lock(&dbg->queue_lock);
206
- struct hdhomerun_debug_message_t *message = dbg->queue_tail;
207
- pthread_mutex_unlock(&dbg->queue_lock);
208
+ thread_mutex_lock(&dbg->queue_lock);
209
+ struct hdhomerun_debug_message_t *message = dbg->queue_head;
210
+ thread_mutex_unlock(&dbg->queue_lock);
211
212
if (!message) {
213
return;
214
}
215
216
- msleep_approx(10);
217
+ msleep_approx(16);
218
}
219
}
220
221
222
if (!dbg) {
223
return;
224
}
225
- if (!dbg->enabled) {
226
- return;
227
- }
228
229
struct hdhomerun_debug_message_t *message = (struct hdhomerun_debug_message_t *)malloc(sizeof(struct hdhomerun_debug_message_t));
230
if (!message) {
231
return;
232
}
233
234
+ message->next = NULL;
235
+
236
char *ptr = message->buffer;
237
char *end = message->buffer + sizeof(message->buffer) - 2;
238
*end = 0;
239
240
/*
241
* Debug prefix.
242
*/
243
- pthread_mutex_lock(&dbg->print_lock);
244
+ thread_mutex_lock(&dbg->print_lock);
245
246
if (dbg->prefix) {
247
hdhomerun_sprintf(ptr, end, "%s ", dbg->prefix);
248
ptr = strchr(ptr, 0);
249
}
250
251
- pthread_mutex_unlock(&dbg->print_lock);
252
+ thread_mutex_unlock(&dbg->print_lock);
253
254
/*
255
* Message text.
256
257
/*
258
* Enqueue.
259
*/
260
- pthread_mutex_lock(&dbg->queue_lock);
261
+ thread_mutex_lock(&dbg->queue_lock);
262
263
- message->prev = NULL;
264
- message->next = dbg->queue_head;
265
- dbg->queue_head = message;
266
- if (message->next) {
267
- message->next->prev = message;
268
+ if (dbg->queue_tail) {
269
+ dbg->queue_tail->next = message;
270
} else {
271
- dbg->queue_tail = message;
272
+ dbg->queue_head = message;
273
}
274
+ dbg->queue_tail = message;
275
dbg->queue_depth++;
276
277
- pthread_mutex_unlock(&dbg->queue_lock);
278
+ bool signal_thread = dbg->enabled || (dbg->queue_depth > 1024 + 100);
279
+
280
+ thread_mutex_unlock(&dbg->queue_lock);
281
+
282
+ if (signal_thread) {
283
+ thread_cond_signal(&dbg->queue_cond);
284
+ }
285
}
286
287
/* Send lock held by caller */
288
-static bool_t hdhomerun_debug_output_message_file(struct hdhomerun_debug_t *dbg, struct hdhomerun_debug_message_t *message)
289
+static bool hdhomerun_debug_output_message_file(struct hdhomerun_debug_t *dbg, struct hdhomerun_debug_message_t *message)
290
{
291
if (!dbg->file_fp) {
292
uint64_t current_time = getcurrenttime();
293
if (current_time < dbg->connect_delay) {
294
- return FALSE;
295
+ return false;
296
}
297
dbg->connect_delay = current_time + 30*1000;
298
299
dbg->file_fp = fopen(dbg->file_name, "a");
300
if (!dbg->file_fp) {
301
- return FALSE;
302
+ return false;
303
}
304
}
305
306
fprintf(dbg->file_fp, "%s", message->buffer);
307
fflush(dbg->file_fp);
308
309
- return TRUE;
310
+ return true;
311
}
312
313
/* Send lock held by caller */
314
-static bool_t hdhomerun_debug_output_message_sock(struct hdhomerun_debug_t *dbg, struct hdhomerun_debug_message_t *message)
315
+static bool hdhomerun_debug_output_message_sock(struct hdhomerun_debug_t *dbg, struct hdhomerun_debug_message_t *message)
316
{
317
- if (dbg->sock == HDHOMERUN_SOCK_INVALID) {
318
+ if (!dbg->sock) {
319
uint64_t current_time = getcurrenttime();
320
if (current_time < dbg->connect_delay) {
321
- return FALSE;
322
+ return false;
323
}
324
dbg->connect_delay = current_time + HDHOMERUN_DEBUG_CONNECT_RETRY_TIME;
325
326
dbg->sock = hdhomerun_sock_create_tcp();
327
- if (dbg->sock == HDHOMERUN_SOCK_INVALID) {
328
- return FALSE;
329
+ if (!dbg->sock) {
330
+ return false;
331
}
332
333
uint32_t remote_addr = hdhomerun_sock_getaddrinfo_addr(dbg->sock, HDHOMERUN_DEBUG_HOST);
334
if (remote_addr == 0) {
335
hdhomerun_debug_close_internal(dbg);
336
- return FALSE;
337
+ return false;
338
}
339
340
if (!hdhomerun_sock_connect(dbg->sock, remote_addr, HDHOMERUN_DEBUG_PORT, HDHOMERUN_DEBUG_CONNECT_TIMEOUT)) {
341
hdhomerun_debug_close_internal(dbg);
342
- return FALSE;
343
+ return false;
344
}
345
}
346
347
size_t length = strlen(message->buffer);
348
if (!hdhomerun_sock_send(dbg->sock, message->buffer, length, HDHOMERUN_DEBUG_SEND_TIMEOUT)) {
349
hdhomerun_debug_close_internal(dbg);
350
- return FALSE;
351
+ return false;
352
}
353
354
- return TRUE;
355
+ return true;
356
}
357
358
-static bool_t hdhomerun_debug_output_message(struct hdhomerun_debug_t *dbg, struct hdhomerun_debug_message_t *message)
359
+static bool hdhomerun_debug_output_message(struct hdhomerun_debug_t *dbg, struct hdhomerun_debug_message_t *message)
360
{
361
- pthread_mutex_lock(&dbg->send_lock);
362
+ thread_mutex_lock(&dbg->send_lock);
363
364
- bool_t ret;
365
+ bool ret;
366
if (dbg->file_name) {
367
ret = hdhomerun_debug_output_message_file(dbg, message);
368
} else {
369
ret = hdhomerun_debug_output_message_sock(dbg, message);
370
}
371
372
- pthread_mutex_unlock(&dbg->send_lock);
373
+ thread_mutex_unlock(&dbg->send_lock);
374
return ret;
375
}
376
377
static void hdhomerun_debug_pop_and_free_message(struct hdhomerun_debug_t *dbg)
378
{
379
- pthread_mutex_lock(&dbg->queue_lock);
380
+ thread_mutex_lock(&dbg->queue_lock);
381
382
- struct hdhomerun_debug_message_t *message = dbg->queue_tail;
383
- dbg->queue_tail = message->prev;
384
- if (message->prev) {
385
- message->prev->next = NULL;
386
- } else {
387
- dbg->queue_head = NULL;
388
+ struct hdhomerun_debug_message_t *message = dbg->queue_head;
389
+ dbg->queue_head = message->next;
390
+ if (!dbg->queue_head) {
391
+ dbg->queue_tail = NULL;
392
}
393
dbg->queue_depth--;
394
395
- pthread_mutex_unlock(&dbg->queue_lock);
396
+ thread_mutex_unlock(&dbg->queue_lock);
397
398
free(message);
399
}
400
401
-static THREAD_FUNC_PREFIX hdhomerun_debug_thread_execute(void *arg)
402
+static void hdhomerun_debug_thread_execute(void *arg)
403
{
404
struct hdhomerun_debug_t *dbg = (struct hdhomerun_debug_t *)arg;
405
406
while (!dbg->terminate) {
407
-
408
- pthread_mutex_lock(&dbg->queue_lock);
409
- struct hdhomerun_debug_message_t *message = dbg->queue_tail;
410
+ thread_mutex_lock(&dbg->queue_lock);
411
+ struct hdhomerun_debug_message_t *message = dbg->queue_head;
412
uint32_t queue_depth = dbg->queue_depth;
413
- pthread_mutex_unlock(&dbg->queue_lock);
414
+ thread_mutex_unlock(&dbg->queue_lock);
415
416
if (!message) {
417
- msleep_approx(250);
418
+ thread_cond_wait(&dbg->queue_cond);
419
continue;
420
}
421
422
423
continue;
424
}
425
426
+ if (!dbg->enabled) {
427
+ thread_cond_wait(&dbg->queue_cond);
428
+ continue;
429
+ }
430
+
431
if (!hdhomerun_debug_output_message(dbg, message)) {
432
- msleep_approx(250);
433
+ msleep_approx(1000);
434
continue;
435
}
436
437
hdhomerun_debug_pop_and_free_message(dbg);
438
}
439
-
440
- return 0;
441
}
442
libhdhomerun_20150826.tgz/hdhomerun_debug.h -> libhdhomerun_20190621.tgz/hdhomerun_debug.h
Changed
42
1
2
/*
3
* hdhomerun_debug.h
4
*
5
- * Copyright © 2006 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2007-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
12
struct hdhomerun_debug_t;
13
14
-extern LIBTYPE struct hdhomerun_debug_t *hdhomerun_debug_create(void);
15
-extern LIBTYPE void hdhomerun_debug_destroy(struct hdhomerun_debug_t *dbg);
16
+extern LIBHDHOMERUN_API struct hdhomerun_debug_t *hdhomerun_debug_create(void);
17
+extern LIBHDHOMERUN_API void hdhomerun_debug_destroy(struct hdhomerun_debug_t *dbg);
18
19
-extern LIBTYPE void hdhomerun_debug_set_prefix(struct hdhomerun_debug_t *dbg, const char *prefix);
20
-extern LIBTYPE void hdhomerun_debug_set_filename(struct hdhomerun_debug_t *dbg, const char *filename);
21
-extern LIBTYPE void hdhomerun_debug_enable(struct hdhomerun_debug_t *dbg);
22
-extern LIBTYPE void hdhomerun_debug_disable(struct hdhomerun_debug_t *dbg);
23
-extern LIBTYPE bool_t hdhomerun_debug_enabled(struct hdhomerun_debug_t *dbg);
24
+extern LIBHDHOMERUN_API void hdhomerun_debug_set_prefix(struct hdhomerun_debug_t *dbg, const char *prefix);
25
+extern LIBHDHOMERUN_API void hdhomerun_debug_set_filename(struct hdhomerun_debug_t *dbg, const char *filename);
26
+extern LIBHDHOMERUN_API void hdhomerun_debug_enable(struct hdhomerun_debug_t *dbg);
27
+extern LIBHDHOMERUN_API void hdhomerun_debug_disable(struct hdhomerun_debug_t *dbg);
28
+extern LIBHDHOMERUN_API bool hdhomerun_debug_enabled(struct hdhomerun_debug_t *dbg);
29
30
-extern LIBTYPE void hdhomerun_debug_flush(struct hdhomerun_debug_t *dbg, uint64_t timeout);
31
-extern LIBTYPE void hdhomerun_debug_close(struct hdhomerun_debug_t *dbg, uint64_t timeout);
32
+extern LIBHDHOMERUN_API void hdhomerun_debug_flush(struct hdhomerun_debug_t *dbg, uint64_t timeout);
33
+extern LIBHDHOMERUN_API void hdhomerun_debug_close(struct hdhomerun_debug_t *dbg, uint64_t timeout);
34
35
-extern LIBTYPE void hdhomerun_debug_printf(struct hdhomerun_debug_t *dbg, const char *fmt, ...);
36
-extern LIBTYPE void hdhomerun_debug_vprintf(struct hdhomerun_debug_t *dbg, const char *fmt, va_list args);
37
+extern LIBHDHOMERUN_API void hdhomerun_debug_printf(struct hdhomerun_debug_t *dbg, const char *fmt, ...);
38
+extern LIBHDHOMERUN_API void hdhomerun_debug_vprintf(struct hdhomerun_debug_t *dbg, const char *fmt, va_list args);
39
40
#ifdef __cplusplus
41
}
42
libhdhomerun_20150826.tgz/hdhomerun_device.c -> libhdhomerun_20190621.tgz/hdhomerun_device.c
Changed
124
1
2
/*
3
* hdhomerun_device.c
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
*/
12
unsigned int port;
13
if (sscanf(device_str, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &port) == 5) {
14
- return hdhomerun_device_create_multicast(ip_addr, port, dbg);
15
+ return hdhomerun_device_create_multicast(ip_addr, (uint16_t)port, dbg);
16
}
17
18
/*
19
20
return hd->vs;
21
}
22
23
- bool_t allow_port_reuse = (hd->multicast_port != 0);
24
+ bool allow_port_reuse = (hd->multicast_port != 0);
25
26
hd->vs = hdhomerun_video_create(hd->multicast_port, allow_port_reuse, VIDEO_DATA_BUFFER_SIZE_1S * 2, hd->dbg);
27
if (!hd->vs) {
28
29
return (uint32_t)value;
30
}
31
32
-static bool_t hdhomerun_device_get_tuner_status_lock_is_bcast(struct hdhomerun_tuner_status_t *status)
33
+static bool hdhomerun_device_get_tuner_status_lock_is_bcast(struct hdhomerun_tuner_status_t *status)
34
{
35
if (strcmp(status->lock_str, "8vsb") == 0) {
36
- return TRUE;
37
+ return true;
38
}
39
if (strncmp(status->lock_str, "t8", 2) == 0) {
40
- return TRUE;
41
+ return true;
42
}
43
if (strncmp(status->lock_str, "t7", 2) == 0) {
44
- return TRUE;
45
+ return true;
46
}
47
if (strncmp(status->lock_str, "t6", 2) == 0) {
48
- return TRUE;
49
+ return true;
50
}
51
52
- return FALSE;
53
+ return false;
54
}
55
56
uint32_t hdhomerun_device_get_tuner_status_ss_color(struct hdhomerun_tuner_status_t *status)
57
58
59
if (strcmp(status->lock_str, "none") != 0) {
60
if (status->lock_str[0] == '(') {
61
- status->lock_unsupported = TRUE;
62
+ status->lock_unsupported = true;
63
} else {
64
- status->lock_supported = TRUE;
65
+ status->lock_supported = true;
66
}
67
}
68
}
69
70
}
71
72
if (strncmp(vstatus->auth, "not-subscribed", 14) == 0) {
73
- vstatus->not_subscribed = TRUE;
74
+ vstatus->not_subscribed = true;
75
}
76
77
if (strncmp(vstatus->auth, "error", 5) == 0) {
78
- vstatus->not_available = TRUE;
79
+ vstatus->not_available = true;
80
}
81
if (strncmp(vstatus->auth, "dialog", 6) == 0) {
82
- vstatus->not_available = TRUE;
83
+ vstatus->not_available = true;
84
}
85
86
if (strncmp(vstatus->cci, "protected", 9) == 0) {
87
- vstatus->copy_protected = TRUE;
88
+ vstatus->copy_protected = true;
89
}
90
if (strncmp(vstatus->cgms, "protected", 9) == 0) {
91
- vstatus->copy_protected = TRUE;
92
+ vstatus->copy_protected = true;
93
}
94
}
95
96
97
return hdhomerun_control_set_with_lockkey(hd->cs, name, filter, hd->lockkey, NULL, NULL);
98
}
99
100
-static bool_t hdhomerun_device_set_tuner_filter_by_array_append(char *ptr, char *end, uint16_t range_begin, uint16_t range_end)
101
+static bool hdhomerun_device_set_tuner_filter_by_array_append(char *ptr, char *end, uint16_t range_begin, uint16_t range_end)
102
{
103
if (range_begin == range_end) {
104
return hdhomerun_sprintf(ptr, end, "0x%04x ", (unsigned int)range_begin);
105
106
return -1;
107
}
108
109
+ hdhomerun_video_set_keepalive(hd->vs, 0, 0, 0);
110
+
111
/* Set target. */
112
if (hd->multicast_ip != 0) {
113
int ret = hdhomerun_video_join_multicast_group(hd->vs, hd->multicast_ip, 0);
114
115
if (ret <= 0) {
116
return ret;
117
}
118
+
119
+ uint32_t remote_ip = hdhomerun_control_get_device_ip(hd->cs);
120
+ hdhomerun_video_set_keepalive(hd->vs, remote_ip, 5004, hd->lockkey);
121
}
122
123
/* Flush video buffer. */
124
libhdhomerun_20150826.tgz/hdhomerun_device.h -> libhdhomerun_20190621.tgz/hdhomerun_device.h
Changed
226
1
2
/*
3
* hdhomerun_device.h
4
*
5
- * Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
* <tuner index>
12
* /tuner<tuner index>
13
*/
14
-extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_create(uint32_t device_id, uint32_t device_ip, unsigned int tuner, struct hdhomerun_debug_t *dbg);
15
-extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_create_multicast(uint32_t multicast_ip, uint16_t multicast_port, struct hdhomerun_debug_t *dbg);
16
-extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_create_from_str(const char *device_str, struct hdhomerun_debug_t *dbg);
17
-extern LIBTYPE void hdhomerun_device_destroy(struct hdhomerun_device_t *hd);
18
+extern LIBHDHOMERUN_API struct hdhomerun_device_t *hdhomerun_device_create(uint32_t device_id, uint32_t device_ip, unsigned int tuner, struct hdhomerun_debug_t *dbg);
19
+extern LIBHDHOMERUN_API struct hdhomerun_device_t *hdhomerun_device_create_multicast(uint32_t multicast_ip, uint16_t multicast_port, struct hdhomerun_debug_t *dbg);
20
+extern LIBHDHOMERUN_API struct hdhomerun_device_t *hdhomerun_device_create_from_str(const char *device_str, struct hdhomerun_debug_t *dbg);
21
+extern LIBHDHOMERUN_API void hdhomerun_device_destroy(struct hdhomerun_device_t *hd);
22
23
/*
24
* Get the device id, ip, or tuner of the device instance.
25
*/
26
-extern LIBTYPE const char *hdhomerun_device_get_name(struct hdhomerun_device_t *hd);
27
-extern LIBTYPE uint32_t hdhomerun_device_get_device_id(struct hdhomerun_device_t *hd);
28
-extern LIBTYPE uint32_t hdhomerun_device_get_device_ip(struct hdhomerun_device_t *hd);
29
-extern LIBTYPE uint32_t hdhomerun_device_get_device_id_requested(struct hdhomerun_device_t *hd);
30
-extern LIBTYPE uint32_t hdhomerun_device_get_device_ip_requested(struct hdhomerun_device_t *hd);
31
-extern LIBTYPE unsigned int hdhomerun_device_get_tuner(struct hdhomerun_device_t *hd);
32
+extern LIBHDHOMERUN_API const char *hdhomerun_device_get_name(struct hdhomerun_device_t *hd);
33
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_device_id(struct hdhomerun_device_t *hd);
34
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_device_ip(struct hdhomerun_device_t *hd);
35
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_device_id_requested(struct hdhomerun_device_t *hd);
36
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_device_ip_requested(struct hdhomerun_device_t *hd);
37
+extern LIBHDHOMERUN_API unsigned int hdhomerun_device_get_tuner(struct hdhomerun_device_t *hd);
38
39
-extern LIBTYPE int hdhomerun_device_set_device(struct hdhomerun_device_t *hd, uint32_t device_id, uint32_t device_ip);
40
-extern LIBTYPE int hdhomerun_device_set_multicast(struct hdhomerun_device_t *hd, uint32_t multicast_ip, uint16_t multicast_port);
41
-extern LIBTYPE int hdhomerun_device_set_tuner(struct hdhomerun_device_t *hd, unsigned int tuner);
42
-extern LIBTYPE int hdhomerun_device_set_tuner_from_str(struct hdhomerun_device_t *hd, const char *tuner_str);
43
+extern LIBHDHOMERUN_API int hdhomerun_device_set_device(struct hdhomerun_device_t *hd, uint32_t device_id, uint32_t device_ip);
44
+extern LIBHDHOMERUN_API int hdhomerun_device_set_multicast(struct hdhomerun_device_t *hd, uint32_t multicast_ip, uint16_t multicast_port);
45
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner(struct hdhomerun_device_t *hd, unsigned int tuner);
46
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_from_str(struct hdhomerun_device_t *hd, const char *tuner_str);
47
48
/*
49
* Get the local machine IP address used when communicating with the device.
50
51
*
52
* Returns 32-bit IP address with native endianness, or 0 on error.
53
*/
54
-extern LIBTYPE uint32_t hdhomerun_device_get_local_machine_addr(struct hdhomerun_device_t *hd);
55
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_local_machine_addr(struct hdhomerun_device_t *hd);
56
57
/*
58
* Get operations.
59
60
* Returns 0 if the operation was rejected.
61
* Returns -1 if a communication error occurred.
62
*/
63
-extern LIBTYPE int hdhomerun_device_get_tuner_status(struct hdhomerun_device_t *hd, char **pstatus_str, struct hdhomerun_tuner_status_t *status);
64
-extern LIBTYPE int hdhomerun_device_get_tuner_vstatus(struct hdhomerun_device_t *hd, char **pvstatus_str, struct hdhomerun_tuner_vstatus_t *vstatus);
65
-extern LIBTYPE int hdhomerun_device_get_tuner_streaminfo(struct hdhomerun_device_t *hd, char **pstreaminfo);
66
-extern LIBTYPE int hdhomerun_device_get_tuner_channel(struct hdhomerun_device_t *hd, char **pchannel);
67
-extern LIBTYPE int hdhomerun_device_get_tuner_vchannel(struct hdhomerun_device_t *hd, char **pvchannel);
68
-extern LIBTYPE int hdhomerun_device_get_tuner_channelmap(struct hdhomerun_device_t *hd, char **pchannelmap);
69
-extern LIBTYPE int hdhomerun_device_get_tuner_filter(struct hdhomerun_device_t *hd, char **pfilter);
70
-extern LIBTYPE int hdhomerun_device_get_tuner_program(struct hdhomerun_device_t *hd, char **pprogram);
71
-extern LIBTYPE int hdhomerun_device_get_tuner_target(struct hdhomerun_device_t *hd, char **ptarget);
72
-extern LIBTYPE int hdhomerun_device_get_tuner_plotsample(struct hdhomerun_device_t *hd, struct hdhomerun_plotsample_t **psamples, size_t *pcount);
73
-extern LIBTYPE int hdhomerun_device_get_tuner_lockkey_owner(struct hdhomerun_device_t *hd, char **powner);
74
-extern LIBTYPE int hdhomerun_device_get_oob_status(struct hdhomerun_device_t *hd, char **pstatus_str, struct hdhomerun_tuner_status_t *status);
75
-extern LIBTYPE int hdhomerun_device_get_oob_plotsample(struct hdhomerun_device_t *hd, struct hdhomerun_plotsample_t **psamples, size_t *pcount);
76
-extern LIBTYPE int hdhomerun_device_get_ir_target(struct hdhomerun_device_t *hd, char **ptarget);
77
-extern LIBTYPE int hdhomerun_device_get_version(struct hdhomerun_device_t *hd, char **pversion_str, uint32_t *pversion_num);
78
-extern LIBTYPE int hdhomerun_device_get_supported(struct hdhomerun_device_t *hd, char *prefix, char **pstr);
79
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_status(struct hdhomerun_device_t *hd, char **pstatus_str, struct hdhomerun_tuner_status_t *status);
80
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_vstatus(struct hdhomerun_device_t *hd, char **pvstatus_str, struct hdhomerun_tuner_vstatus_t *vstatus);
81
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_streaminfo(struct hdhomerun_device_t *hd, char **pstreaminfo);
82
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_channel(struct hdhomerun_device_t *hd, char **pchannel);
83
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_vchannel(struct hdhomerun_device_t *hd, char **pvchannel);
84
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_channelmap(struct hdhomerun_device_t *hd, char **pchannelmap);
85
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_filter(struct hdhomerun_device_t *hd, char **pfilter);
86
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_program(struct hdhomerun_device_t *hd, char **pprogram);
87
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_target(struct hdhomerun_device_t *hd, char **ptarget);
88
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_plotsample(struct hdhomerun_device_t *hd, struct hdhomerun_plotsample_t **psamples, size_t *pcount);
89
+extern LIBHDHOMERUN_API int hdhomerun_device_get_tuner_lockkey_owner(struct hdhomerun_device_t *hd, char **powner);
90
+extern LIBHDHOMERUN_API int hdhomerun_device_get_oob_status(struct hdhomerun_device_t *hd, char **pstatus_str, struct hdhomerun_tuner_status_t *status);
91
+extern LIBHDHOMERUN_API int hdhomerun_device_get_oob_plotsample(struct hdhomerun_device_t *hd, struct hdhomerun_plotsample_t **psamples, size_t *pcount);
92
+extern LIBHDHOMERUN_API int hdhomerun_device_get_ir_target(struct hdhomerun_device_t *hd, char **ptarget);
93
+extern LIBHDHOMERUN_API int hdhomerun_device_get_version(struct hdhomerun_device_t *hd, char **pversion_str, uint32_t *pversion_num);
94
+extern LIBHDHOMERUN_API int hdhomerun_device_get_supported(struct hdhomerun_device_t *hd, char *prefix, char **pstr);
95
96
-extern LIBTYPE uint32_t hdhomerun_device_get_tuner_status_ss_color(struct hdhomerun_tuner_status_t *status);
97
-extern LIBTYPE uint32_t hdhomerun_device_get_tuner_status_snq_color(struct hdhomerun_tuner_status_t *status);
98
-extern LIBTYPE uint32_t hdhomerun_device_get_tuner_status_seq_color(struct hdhomerun_tuner_status_t *status);
99
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_tuner_status_ss_color(struct hdhomerun_tuner_status_t *status);
100
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_tuner_status_snq_color(struct hdhomerun_tuner_status_t *status);
101
+extern LIBHDHOMERUN_API uint32_t hdhomerun_device_get_tuner_status_seq_color(struct hdhomerun_tuner_status_t *status);
102
103
-extern LIBTYPE const char *hdhomerun_device_get_hw_model_str(struct hdhomerun_device_t *hd);
104
-extern LIBTYPE const char *hdhomerun_device_get_model_str(struct hdhomerun_device_t *hd);
105
+extern LIBHDHOMERUN_API const char *hdhomerun_device_get_hw_model_str(struct hdhomerun_device_t *hd);
106
+extern LIBHDHOMERUN_API const char *hdhomerun_device_get_model_str(struct hdhomerun_device_t *hd);
107
108
/*
109
* Set operations.
110
111
* Returns 0 if the operation was rejected.
112
* Returns -1 if a communication error occurred.
113
*/
114
-extern LIBTYPE int hdhomerun_device_set_tuner_channel(struct hdhomerun_device_t *hd, const char *channel);
115
-extern LIBTYPE int hdhomerun_device_set_tuner_vchannel(struct hdhomerun_device_t *hd, const char *vchannel);
116
-extern LIBTYPE int hdhomerun_device_set_tuner_channelmap(struct hdhomerun_device_t *hd, const char *channelmap);
117
-extern LIBTYPE int hdhomerun_device_set_tuner_filter(struct hdhomerun_device_t *hd, const char *filter);
118
-extern LIBTYPE int hdhomerun_device_set_tuner_filter_by_array(struct hdhomerun_device_t *hd, unsigned char filter_array[0x2000]);
119
-extern LIBTYPE int hdhomerun_device_set_tuner_program(struct hdhomerun_device_t *hd, const char *program);
120
-extern LIBTYPE int hdhomerun_device_set_tuner_target(struct hdhomerun_device_t *hd, const char *target);
121
-extern LIBTYPE int hdhomerun_device_set_ir_target(struct hdhomerun_device_t *hd, const char *target);
122
-extern LIBTYPE int hdhomerun_device_set_sys_dvbc_modulation(struct hdhomerun_device_t *hd, const char *modulation_list);
123
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_channel(struct hdhomerun_device_t *hd, const char *channel);
124
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_vchannel(struct hdhomerun_device_t *hd, const char *vchannel);
125
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_channelmap(struct hdhomerun_device_t *hd, const char *channelmap);
126
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_filter(struct hdhomerun_device_t *hd, const char *filter);
127
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_filter_by_array(struct hdhomerun_device_t *hd, unsigned char filter_array[0x2000]);
128
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_program(struct hdhomerun_device_t *hd, const char *program);
129
+extern LIBHDHOMERUN_API int hdhomerun_device_set_tuner_target(struct hdhomerun_device_t *hd, const char *target);
130
+extern LIBHDHOMERUN_API int hdhomerun_device_set_ir_target(struct hdhomerun_device_t *hd, const char *target);
131
+extern LIBHDHOMERUN_API int hdhomerun_device_set_sys_dvbc_modulation(struct hdhomerun_device_t *hd, const char *modulation_list);
132
133
/*
134
* Get/set a named control variable on the device.
135
136
* Returns 0 if the operation was rejected (pvalue NULL, perror set).
137
* Returns -1 if a communication error occurs.
138
*/
139
-extern LIBTYPE int hdhomerun_device_get_var(struct hdhomerun_device_t *hd, const char *name, char **pvalue, char **perror);
140
-extern LIBTYPE int hdhomerun_device_set_var(struct hdhomerun_device_t *hd, const char *name, const char *value, char **pvalue, char **perror);
141
+extern LIBHDHOMERUN_API int hdhomerun_device_get_var(struct hdhomerun_device_t *hd, const char *name, char **pvalue, char **perror);
142
+extern LIBHDHOMERUN_API int hdhomerun_device_set_var(struct hdhomerun_device_t *hd, const char *name, const char *value, char **pvalue, char **perror);
143
144
/*
145
* Tuner locking.
146
147
* previously held lock. If locking is used then this function must be called
148
* before destroying the hdhomerun_device object.
149
*/
150
-extern LIBTYPE int hdhomerun_device_tuner_lockkey_request(struct hdhomerun_device_t *hd, char **perror);
151
-extern LIBTYPE int hdhomerun_device_tuner_lockkey_release(struct hdhomerun_device_t *hd);
152
-extern LIBTYPE int hdhomerun_device_tuner_lockkey_force(struct hdhomerun_device_t *hd);
153
+extern LIBHDHOMERUN_API int hdhomerun_device_tuner_lockkey_request(struct hdhomerun_device_t *hd, char **perror);
154
+extern LIBHDHOMERUN_API int hdhomerun_device_tuner_lockkey_release(struct hdhomerun_device_t *hd);
155
+extern LIBHDHOMERUN_API int hdhomerun_device_tuner_lockkey_force(struct hdhomerun_device_t *hd);
156
157
/*
158
* Intended only for non persistent connections; eg, hdhomerun_config.
159
*/
160
-extern LIBTYPE void hdhomerun_device_tuner_lockkey_use_value(struct hdhomerun_device_t *hd, uint32_t lockkey);
161
+extern LIBHDHOMERUN_API void hdhomerun_device_tuner_lockkey_use_value(struct hdhomerun_device_t *hd, uint32_t lockkey);
162
163
/*
164
* Wait for tuner lock after channel change.
165
166
* It will return quickly if there is no signal detected.
167
* Worst case it will time out after 1.5 seconds - the case where there is signal but no lock.
168
*/
169
-extern LIBTYPE int hdhomerun_device_wait_for_lock(struct hdhomerun_device_t *hd, struct hdhomerun_tuner_status_t *status);
170
+extern LIBHDHOMERUN_API int hdhomerun_device_wait_for_lock(struct hdhomerun_device_t *hd, struct hdhomerun_tuner_status_t *status);
171
172
/*
173
* Stream a filtered program or the unfiltered stream.
174
175
*
176
* The hdhomerun_device_stream_stop function tells the device to stop streaming data.
177
*/
178
-extern LIBTYPE int hdhomerun_device_stream_start(struct hdhomerun_device_t *hd);
179
-extern LIBTYPE uint8_t *hdhomerun_device_stream_recv(struct hdhomerun_device_t *hd, size_t max_size, size_t *pactual_size);
180
-extern LIBTYPE void hdhomerun_device_stream_flush(struct hdhomerun_device_t *hd);
181
-extern LIBTYPE void hdhomerun_device_stream_stop(struct hdhomerun_device_t *hd);
182
+extern LIBHDHOMERUN_API int hdhomerun_device_stream_start(struct hdhomerun_device_t *hd);
183
+extern LIBHDHOMERUN_API uint8_t *hdhomerun_device_stream_recv(struct hdhomerun_device_t *hd, size_t max_size, size_t *pactual_size);
184
+extern LIBHDHOMERUN_API void hdhomerun_device_stream_flush(struct hdhomerun_device_t *hd);
185
+extern LIBHDHOMERUN_API void hdhomerun_device_stream_stop(struct hdhomerun_device_t *hd);
186
187
/*
188
* Channel scan API.
189
*/
190
-extern LIBTYPE int hdhomerun_device_channelscan_init(struct hdhomerun_device_t *hd, const char *channelmap);
191
-extern LIBTYPE int hdhomerun_device_channelscan_advance(struct hdhomerun_device_t *hd, struct hdhomerun_channelscan_result_t *result);
192
-extern LIBTYPE int hdhomerun_device_channelscan_detect(struct hdhomerun_device_t *hd, struct hdhomerun_channelscan_result_t *result);
193
-extern LIBTYPE uint8_t hdhomerun_device_channelscan_get_progress(struct hdhomerun_device_t *hd);
194
+extern LIBHDHOMERUN_API int hdhomerun_device_channelscan_init(struct hdhomerun_device_t *hd, const char *channelmap);
195
+extern LIBHDHOMERUN_API int hdhomerun_device_channelscan_advance(struct hdhomerun_device_t *hd, struct hdhomerun_channelscan_result_t *result);
196
+extern LIBHDHOMERUN_API int hdhomerun_device_channelscan_detect(struct hdhomerun_device_t *hd, struct hdhomerun_channelscan_result_t *result);
197
+extern LIBHDHOMERUN_API uint8_t hdhomerun_device_channelscan_get_progress(struct hdhomerun_device_t *hd);
198
199
/*
200
* Upload new firmware to the device.
201
202
* Returns 0 if the upload was rejected.
203
* Returns -1 if an error occurs.
204
*/
205
-extern LIBTYPE int hdhomerun_device_upgrade(struct hdhomerun_device_t *hd, FILE *upgrade_file);
206
+extern LIBHDHOMERUN_API int hdhomerun_device_upgrade(struct hdhomerun_device_t *hd, FILE *upgrade_file);
207
208
/*
209
* Low level accessor functions.
210
*/
211
-extern LIBTYPE struct hdhomerun_control_sock_t *hdhomerun_device_get_control_sock(struct hdhomerun_device_t *hd);
212
-extern LIBTYPE struct hdhomerun_video_sock_t *hdhomerun_device_get_video_sock(struct hdhomerun_device_t *hd);
213
+extern LIBHDHOMERUN_API struct hdhomerun_control_sock_t *hdhomerun_device_get_control_sock(struct hdhomerun_device_t *hd);
214
+extern LIBHDHOMERUN_API struct hdhomerun_video_sock_t *hdhomerun_device_get_video_sock(struct hdhomerun_device_t *hd);
215
216
/*
217
* Debug print internal stats.
218
*/
219
-extern LIBTYPE void hdhomerun_device_debug_print_video_stats(struct hdhomerun_device_t *hd);
220
-extern LIBTYPE void hdhomerun_device_get_video_stats(struct hdhomerun_device_t *hd, struct hdhomerun_video_stats_t *stats);
221
+extern LIBHDHOMERUN_API void hdhomerun_device_debug_print_video_stats(struct hdhomerun_device_t *hd);
222
+extern LIBHDHOMERUN_API void hdhomerun_device_get_video_stats(struct hdhomerun_device_t *hd, struct hdhomerun_video_stats_t *stats);
223
224
#ifdef __cplusplus
225
}
226
libhdhomerun_20150826.tgz/hdhomerun_device_selector.c -> libhdhomerun_20190621.tgz/hdhomerun_device_selector.c
Changed
224
1
2
/*
3
* hdhomerun_device_selector.c
4
*
5
- * Copyright © 2009-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2009-2016 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
return hds;
12
}
13
14
-void hdhomerun_device_selector_destroy(struct hdhomerun_device_selector_t *hds, bool_t destroy_devices)
15
+void hdhomerun_device_selector_destroy(struct hdhomerun_device_selector_t *hds, bool destroy_devices)
16
{
17
if (destroy_devices) {
18
size_t index;
19
20
free(hds);
21
}
22
23
-LIBTYPE int hdhomerun_device_selector_get_device_count(struct hdhomerun_device_selector_t *hds)
24
+int hdhomerun_device_selector_get_device_count(struct hdhomerun_device_selector_t *hds)
25
{
26
return (int)hds->hd_count;
27
}
28
29
}
30
}
31
32
- hds->hd_list = (struct hdhomerun_device_t **)realloc(hds->hd_list, (hds->hd_count + 1) * sizeof(struct hdhomerun_device_selector_t *));
33
- if (!hds->hd_list) {
34
+ struct hdhomerun_device_t **hd_list = (struct hdhomerun_device_t **)realloc(hds->hd_list, (hds->hd_count + 1) * sizeof(struct hdhomerun_device_t *));
35
+ if (!hd_list) {
36
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_add_device: failed to allocate device list\n");
37
return;
38
}
39
40
+ hds->hd_list = hd_list;
41
hds->hd_list[hds->hd_count++] = hd;
42
}
43
44
45
46
static int hdhomerun_device_selector_load_from_str_discover(struct hdhomerun_device_selector_t *hds, uint32_t target_ip, uint32_t device_id)
47
{
48
- struct hdhomerun_discover_device_t result_list[64];
49
- int discover_count = hdhomerun_discover_find_devices_custom_v2(target_ip, HDHOMERUN_DEVICE_TYPE_TUNER, device_id, result_list, 64);
50
+ struct hdhomerun_discover_device_t result;
51
+ int discover_count = hdhomerun_discover_find_devices_custom_v2(target_ip, HDHOMERUN_DEVICE_TYPE_TUNER, device_id, &result, 1);
52
+ if (discover_count != 1) {
53
+ return 0;
54
+ }
55
56
int count = 0;
57
- int result_index;
58
- struct hdhomerun_discover_device_t *result = result_list;
59
- for (result_index = 0; result_index < discover_count; result_index++) {
60
- unsigned int tuner_index;
61
- for (tuner_index = 0; tuner_index < result->tuner_count; tuner_index++) {
62
- struct hdhomerun_device_t *hd = hdhomerun_device_create(result->device_id, result->ip_addr, tuner_index, hds->dbg);
63
- if (!hd) {
64
- continue;
65
- }
66
-
67
- hdhomerun_device_selector_add_device(hds, hd);
68
- count++;
69
+ unsigned int tuner_index;
70
+ for (tuner_index = 0; tuner_index < result.tuner_count; tuner_index++) {
71
+ struct hdhomerun_device_t *hd = hdhomerun_device_create(result.device_id, result.ip_addr, tuner_index, hds->dbg);
72
+ if (!hd) {
73
+ continue;
74
}
75
76
- result++;
77
+ hdhomerun_device_selector_add_device(hds, hd);
78
+ count++;
79
}
80
81
return count;
82
83
*/
84
unsigned int port;
85
if (sscanf(device_str, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &port) == 5) {
86
- struct hdhomerun_device_t *hd = hdhomerun_device_create_multicast(ip_addr, port, hds->dbg);
87
+ struct hdhomerun_device_t *hd = hdhomerun_device_create_multicast(ip_addr, (uint16_t)port, hds->dbg);
88
if (!hd) {
89
return 0;
90
}
91
92
return count;
93
}
94
95
-#if defined(__WINDOWS__)
96
+#if defined(_WIN32) && !defined(_WINRT)
97
int hdhomerun_device_selector_load_from_windows_registry(struct hdhomerun_device_selector_t *hds, wchar_t *wsource)
98
{
99
HKEY tuners_key;
100
101
}
102
#endif
103
104
-static bool_t hdhomerun_device_selector_choose_test(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *test_hd)
105
+static bool hdhomerun_device_selector_choose_test(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *test_hd)
106
{
107
const char *name = hdhomerun_device_get_name(test_hd);
108
109
/*
110
* Attempt to aquire lock.
111
*/
112
- char *error;
113
+ char *error = NULL;
114
int ret = hdhomerun_device_tuner_lockkey_request(test_hd, &error);
115
if (ret > 0) {
116
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s chosen\n", name);
117
- return TRUE;
118
+ return true;
119
}
120
if (ret < 0) {
121
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s communication error\n", name);
122
- return FALSE;
123
+ return false;
124
}
125
126
/*
127
128
ret = hdhomerun_device_get_tuner_target(test_hd, &target);
129
if (ret < 0) {
130
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s communication error\n", name);
131
- return FALSE;
132
+ return false;
133
}
134
if (ret == 0) {
135
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use, failed to read target\n", name);
136
- return FALSE;
137
+ return false;
138
}
139
140
if (strcmp(target, "none") == 0) {
141
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use, no target set\n", name);
142
- return FALSE;
143
+ return false;
144
}
145
146
if ((strncmp(target, "udp://", 6) != 0) && (strncmp(target, "rtp://", 6) != 0)) {
147
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use by %s\n", name, target);
148
- return FALSE;
149
+ return false;
150
}
151
152
unsigned int a[4];
153
unsigned int target_port;
154
if (sscanf(target + 6, "%u.%u.%u.%u:%u", &a[0], &a[1], &a[2], &a[3], &target_port) != 5) {
155
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use, unexpected target set (%s)\n", name, target);
156
- return FALSE;
157
+ return false;
158
}
159
160
uint32_t target_ip = (uint32_t)((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | (a[3] << 0));
161
uint32_t local_ip = hdhomerun_device_get_local_machine_addr(test_hd);
162
if (target_ip != local_ip) {
163
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use by %s\n", name, target);
164
- return FALSE;
165
+ return false;
166
}
167
168
/*
169
* Test local port.
170
*/
171
- hdhomerun_sock_t test_sock = hdhomerun_sock_create_udp();
172
- if (test_sock == HDHOMERUN_SOCK_INVALID) {
173
+ struct hdhomerun_sock_t *test_sock = hdhomerun_sock_create_udp();
174
+ if (!test_sock) {
175
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use, failed to create test sock\n", name);
176
- return FALSE;
177
+ return false;
178
}
179
180
- bool_t inuse = (hdhomerun_sock_bind(test_sock, INADDR_ANY, (uint16_t)target_port, FALSE) == FALSE);
181
+ bool inuse = (hdhomerun_sock_bind(test_sock, INADDR_ANY, (uint16_t)target_port, false) == false);
182
hdhomerun_sock_destroy(test_sock);
183
184
if (inuse) {
185
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use by local machine\n", name);
186
- return FALSE;
187
+ return false;
188
}
189
190
/*
191
192
ret = hdhomerun_device_tuner_lockkey_force(test_hd);
193
if (ret < 0) {
194
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s communication error\n", name);
195
- return FALSE;
196
+ return false;
197
}
198
if (ret == 0) {
199
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use by local machine, dead target, failed to force release lockkey\n", name);
200
- return FALSE;
201
+ return false;
202
}
203
204
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s in use by local machine, dead target, lockkey force successful\n", name);
205
206
ret = hdhomerun_device_tuner_lockkey_request(test_hd, &error);
207
if (ret > 0) {
208
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s chosen\n", name);
209
- return TRUE;
210
+ return true;
211
}
212
if (ret < 0) {
213
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s communication error\n", name);
214
- return FALSE;
215
+ return false;
216
}
217
218
hdhomerun_debug_printf(hds->dbg, "hdhomerun_device_selector_choose_test: device %s still in use after lockkey force (%s)\n", name, error);
219
- return FALSE;
220
+ return false;
221
}
222
223
struct hdhomerun_device_t *hdhomerun_device_selector_choose_and_lock(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *prefered)
224
libhdhomerun_20150826.tgz/hdhomerun_device_selector.h -> libhdhomerun_20190621.tgz/hdhomerun_device_selector.h
Changed
65
1
2
/*
3
* hdhomerun_device_selector.h
4
*
5
- * Copyright © 2009 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2009-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
* All tuners registered with a specific device selector instance must have the same signal source.
12
* The dbg parameter may be null.
13
*/
14
-extern LIBTYPE struct hdhomerun_device_selector_t *hdhomerun_device_selector_create(struct hdhomerun_debug_t *dbg);
15
-extern LIBTYPE void hdhomerun_device_selector_destroy(struct hdhomerun_device_selector_t *hds, bool_t destroy_devices);
16
+extern LIBHDHOMERUN_API struct hdhomerun_device_selector_t *hdhomerun_device_selector_create(struct hdhomerun_debug_t *dbg);
17
+extern LIBHDHOMERUN_API void hdhomerun_device_selector_destroy(struct hdhomerun_device_selector_t *hds, bool destroy_devices);
18
19
/*
20
* Get the number of devices in the list.
21
*/
22
-extern LIBTYPE int hdhomerun_device_selector_get_device_count(struct hdhomerun_device_selector_t *hds);
23
+extern LIBHDHOMERUN_API int hdhomerun_device_selector_get_device_count(struct hdhomerun_device_selector_t *hds);
24
25
/*
26
* Populate device selector with devices from given source.
27
* Returns the number of devices populated.
28
*/
29
-extern LIBTYPE int hdhomerun_device_selector_load_from_str(struct hdhomerun_device_selector_t *hds, char *device_str);
30
-extern LIBTYPE int hdhomerun_device_selector_load_from_file(struct hdhomerun_device_selector_t *hds, char *filename);
31
-#if defined(__WINDOWS__)
32
-extern LIBTYPE int hdhomerun_device_selector_load_from_windows_registry(struct hdhomerun_device_selector_t *hds, wchar_t *wsource);
33
+extern LIBHDHOMERUN_API int hdhomerun_device_selector_load_from_str(struct hdhomerun_device_selector_t *hds, char *device_str);
34
+extern LIBHDHOMERUN_API int hdhomerun_device_selector_load_from_file(struct hdhomerun_device_selector_t *hds, char *filename);
35
+
36
+#if defined(_WIN32) && !defined(_WINRT)
37
+extern LIBHDHOMERUN_API int hdhomerun_device_selector_load_from_windows_registry(struct hdhomerun_device_selector_t *hds, wchar_t *wsource);
38
#endif
39
40
/*
41
* Add/remove a device from the selector list.
42
*/
43
-extern LIBTYPE void hdhomerun_device_selector_add_device(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *hd);
44
-extern LIBTYPE void hdhomerun_device_selector_remove_device(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *hd);
45
+extern LIBHDHOMERUN_API void hdhomerun_device_selector_add_device(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *hd);
46
+extern LIBHDHOMERUN_API void hdhomerun_device_selector_remove_device(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *hd);
47
48
/*
49
* Find a device in the selector list.
50
*/
51
-extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_selector_find_device(struct hdhomerun_device_selector_t *hds, uint32_t device_id, unsigned int tuner_index);
52
+extern LIBHDHOMERUN_API struct hdhomerun_device_t *hdhomerun_device_selector_find_device(struct hdhomerun_device_selector_t *hds, uint32_t device_id, unsigned int tuner_index);
53
54
/*
55
* Select and lock an available device.
56
57
* to refresh the lock. If this function succeeds then the same device can be used. If this fucntion fails
58
* then call hdhomerun_device_selector_choose_and_lock() to choose and lock an available tuner.
59
*/
60
-extern LIBTYPE struct hdhomerun_device_t *hdhomerun_device_selector_choose_and_lock(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *prefered);
61
+extern LIBHDHOMERUN_API struct hdhomerun_device_t *hdhomerun_device_selector_choose_and_lock(struct hdhomerun_device_selector_t *hds, struct hdhomerun_device_t *prefered);
62
63
#ifdef __cplusplus
64
}
65
libhdhomerun_20150826.tgz/hdhomerun_discover.c -> libhdhomerun_20190621.tgz/hdhomerun_discover.c
Changed
512
1
2
/*
3
* hdhomerun_discover.c
4
*
5
- * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2017 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
12
#include "hdhomerun.h"
13
14
-#define HDHOMERUN_DISOCVER_MAX_SOCK_COUNT 16
15
+#define HDHOMERUN_DISCOVER_MAX_SOCK_COUNT 16
16
17
struct hdhomerun_discover_sock_t {
18
- hdhomerun_sock_t sock;
19
- bool_t detected;
20
+ struct hdhomerun_sock_t *sock;
21
+ bool detected;
22
uint32_t local_ip;
23
uint32_t subnet_mask;
24
};
25
26
struct hdhomerun_discover_t {
27
- struct hdhomerun_discover_sock_t socks[HDHOMERUN_DISOCVER_MAX_SOCK_COUNT];
28
+ struct hdhomerun_discover_sock_t socks[HDHOMERUN_DISCOVER_MAX_SOCK_COUNT];
29
unsigned int sock_count;
30
struct hdhomerun_pkt_t tx_pkt;
31
struct hdhomerun_pkt_t rx_pkt;
32
struct hdhomerun_debug_t *dbg;
33
};
34
35
-static bool_t hdhomerun_discover_sock_add(struct hdhomerun_discover_t *ds, uint32_t local_ip, uint32_t subnet_mask)
36
+static bool hdhomerun_discover_sock_add(struct hdhomerun_discover_t *ds, uint32_t local_ip, uint32_t subnet_mask)
37
{
38
unsigned int i;
39
for (i = 1; i < ds->sock_count; i++) {
40
struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
41
42
if ((dss->local_ip == local_ip) && (dss->subnet_mask == subnet_mask)) {
43
- dss->detected = TRUE;
44
- return TRUE;
45
+ dss->detected = true;
46
+ return true;
47
}
48
}
49
50
- if (ds->sock_count >= HDHOMERUN_DISOCVER_MAX_SOCK_COUNT) {
51
- return FALSE;
52
+ if (ds->sock_count >= HDHOMERUN_DISCOVER_MAX_SOCK_COUNT) {
53
+ return false;
54
}
55
56
/* Create socket. */
57
- hdhomerun_sock_t sock = hdhomerun_sock_create_udp();
58
- if (sock == HDHOMERUN_SOCK_INVALID) {
59
- return FALSE;
60
+ struct hdhomerun_sock_t *sock = hdhomerun_sock_create_udp();
61
+ if (!sock) {
62
+ hdhomerun_debug_printf(ds->dbg, "discover: failed to allocate socket (%d)\n", hdhomerun_sock_getlasterror());
63
+ return false;
64
}
65
66
/* Bind socket. */
67
- if (!hdhomerun_sock_bind(sock, local_ip, 0, FALSE)) {
68
+ if (!hdhomerun_sock_bind(sock, local_ip, 0, false)) {
69
hdhomerun_debug_printf(ds->dbg, "discover: failed to bind to %u.%u.%u.%u:0\n", (unsigned int)(local_ip >> 24) & 0xFF, (unsigned int)(local_ip >> 16) & 0xFF, (unsigned int)(local_ip >> 8) & 0xFF, (unsigned int)(local_ip >> 0) & 0xFF);
70
hdhomerun_sock_destroy(sock);
71
- return FALSE;
72
+ return false;
73
}
74
75
/* Write sock entry. */
76
struct hdhomerun_discover_sock_t *dss = &ds->socks[ds->sock_count++];
77
dss->sock = sock;
78
- dss->detected = TRUE;
79
+ dss->detected = true;
80
dss->local_ip = local_ip;
81
dss->subnet_mask = subnet_mask;
82
83
- return TRUE;
84
+ return true;
85
}
86
87
struct hdhomerun_discover_t *hdhomerun_discover_create(struct hdhomerun_debug_t *dbg)
88
89
unsigned int i;
90
for (i = 1; i < ds->sock_count; i++) {
91
struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
92
- dss->detected = FALSE;
93
+ dss->detected = false;
94
}
95
96
- struct hdhomerun_local_ip_info_t ip_info_list[HDHOMERUN_DISOCVER_MAX_SOCK_COUNT];
97
- int count = hdhomerun_local_ip_info(ip_info_list, HDHOMERUN_DISOCVER_MAX_SOCK_COUNT);
98
+ struct hdhomerun_local_ip_info_t ip_info_list[HDHOMERUN_DISCOVER_MAX_SOCK_COUNT];
99
+ int count = hdhomerun_local_ip_info(ip_info_list, HDHOMERUN_DISCOVER_MAX_SOCK_COUNT);
100
if (count < 0) {
101
hdhomerun_debug_printf(ds->dbg, "discover: hdhomerun_local_ip_info returned error\n");
102
count = 0;
103
}
104
- if (count > HDHOMERUN_DISOCVER_MAX_SOCK_COUNT) {
105
+ if (count > HDHOMERUN_DISCOVER_MAX_SOCK_COUNT) {
106
hdhomerun_debug_printf(ds->dbg, "discover: too many local IP addresses\n");
107
- count = HDHOMERUN_DISOCVER_MAX_SOCK_COUNT;
108
+ count = HDHOMERUN_DISCOVER_MAX_SOCK_COUNT;
109
}
110
111
int index;
112
113
count++;
114
}
115
116
- ds->sock_count = count;
117
+ ds->sock_count = (unsigned int)count;
118
}
119
120
-static bool_t hdhomerun_discover_send_internal(struct hdhomerun_discover_t *ds, struct hdhomerun_discover_sock_t *dss, uint32_t target_ip, uint32_t device_type, uint32_t device_id)
121
+static bool hdhomerun_discover_send_internal(struct hdhomerun_discover_t *ds, struct hdhomerun_discover_sock_t *dss, uint32_t target_ip, uint32_t device_type, uint32_t device_id)
122
{
123
struct hdhomerun_pkt_t *tx_pkt = &ds->tx_pkt;
124
hdhomerun_pkt_reset(tx_pkt);
125
126
return hdhomerun_sock_sendto(dss->sock, target_ip, HDHOMERUN_DISCOVER_UDP_PORT, tx_pkt->start, tx_pkt->end - tx_pkt->start, 0);
127
}
128
129
-static bool_t hdhomerun_discover_send_wildcard_ip(struct hdhomerun_discover_t *ds, uint32_t device_type, uint32_t device_id)
130
+static bool hdhomerun_discover_send(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id)
131
{
132
- bool_t result = FALSE;
133
-
134
- /*
135
- * Send subnet broadcast using each local ip socket.
136
- * This will work with multiple separate 169.254.x.x interfaces.
137
- */
138
- unsigned int i;
139
- for (i = 1; i < ds->sock_count; i++) {
140
- struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
141
- uint32_t target_ip = dss->local_ip | ~dss->subnet_mask;
142
- result |= hdhomerun_discover_send_internal(ds, dss, target_ip, device_type, device_id);
143
- }
144
-
145
- /*
146
- * If no local ip sockets then fall back to sending a global broadcast letting the OS choose the interface.
147
- */
148
- if (!result) {
149
- struct hdhomerun_discover_sock_t *dss = &ds->socks[0];
150
- result = hdhomerun_discover_send_internal(ds, dss, 0xFFFFFFFF, device_type, device_id);
151
+ if (target_ip == 0x00000000) {
152
+ target_ip = 0xFFFFFFFF;
153
}
154
155
- return result;
156
-}
157
-
158
-static bool_t hdhomerun_discover_send_target_ip(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id)
159
-{
160
- bool_t result = FALSE;
161
+ bool result = false;
162
163
/*
164
* Send targeted packet from any local ip that is in the same subnet.
165
166
unsigned int i;
167
for (i = 1; i < ds->sock_count; i++) {
168
struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
169
- if ((target_ip & dss->subnet_mask) != (dss->local_ip & dss->subnet_mask)) {
170
- continue;
171
+
172
+ if (target_ip != 0xFFFFFFFF) {
173
+ if (dss->subnet_mask == 0) {
174
+ continue;
175
+ }
176
+ if ((target_ip & dss->subnet_mask) != (dss->local_ip & dss->subnet_mask)) {
177
+ continue;
178
+ }
179
}
180
181
result |= hdhomerun_discover_send_internal(ds, dss, target_ip, device_type, device_id);
182
183
return result;
184
}
185
186
-static bool_t hdhomerun_discover_send(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id)
187
-{
188
- if (target_ip == 0) {
189
- return hdhomerun_discover_send_wildcard_ip(ds, device_type, device_id);
190
- } else {
191
- return hdhomerun_discover_send_target_ip(ds, target_ip, device_type, device_id);
192
- }
193
-}
194
-
195
-static bool_t hdhomerun_discover_is_legacy(uint32_t device_id)
196
+static bool hdhomerun_discover_is_legacy(uint32_t device_id)
197
{
198
switch (device_id >> 20) {
199
case 0x100: /* TECH-US/TECH3-US */
200
201
case 0x111: /* HDHR3-DT */
202
case 0x121: /* HDHR-EU */
203
case 0x122: /* HDHR3-EU */
204
- return TRUE;
205
+ return true;
206
207
default:
208
- return FALSE;
209
+ return false;
210
}
211
}
212
213
-static bool_t hdhomerun_discover_recv_internal(struct hdhomerun_discover_t *ds, struct hdhomerun_discover_sock_t *dss, struct hdhomerun_discover_device_t *result)
214
+static bool hdhomerun_discover_recv_internal(struct hdhomerun_discover_t *ds, struct hdhomerun_discover_sock_t *dss, size_t result_struct_size, struct hdhomerun_discover_device_t *result)
215
{
216
static char hdhomerun_discover_recv_base64_encode_table[64 + 1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
217
struct hdhomerun_pkt_t *rx_pkt = &ds->rx_pkt;
218
219
uint16_t remote_port;
220
size_t length = rx_pkt->limit - rx_pkt->end;
221
if (!hdhomerun_sock_recvfrom(dss->sock, &remote_addr, &remote_port, rx_pkt->end, &length, 0)) {
222
- return FALSE;
223
+ return false;
224
}
225
226
rx_pkt->end += length;
227
228
uint16_t type;
229
if (hdhomerun_pkt_open_frame(rx_pkt, &type) <= 0) {
230
- return FALSE;
231
+ return false;
232
}
233
if (type != HDHOMERUN_TYPE_DISCOVER_RPY) {
234
- return FALSE;
235
+ return false;
236
}
237
238
- memset(result, 0, sizeof(struct hdhomerun_discover_device_t));
239
+ struct hdhomerun_discover_device_v3_t *result_v3 = (result_struct_size >= sizeof(struct hdhomerun_discover_device_v3_t)) ? (struct hdhomerun_discover_device_v3_t *)(void *)result : NULL;
240
+ memset(result, 0, result_struct_size);
241
result->ip_addr = remote_addr;
242
243
- hdhomerun_sprintf(result->base_url, result->base_url + sizeof(result->base_url), "http://%u.%u.%u.%u:80",
244
- (remote_addr >> 24) & 0xFF, (remote_addr >> 16) & 0xFF, (remote_addr >> 8) & 0xFF, (remote_addr >> 0) & 0xFF
245
- );
246
-
247
while (1) {
248
uint8_t tag;
249
size_t len;
250
251
result->device_auth[len] = 0;
252
break;
253
254
- case HDHOMERUN_TAG_DEVICE_AUTH_BIN:
255
+ case HDHOMERUN_TAG_DEVICE_AUTH_BIN_DEPRECATED:
256
if (len != 18) {
257
break;
258
}
259
for (i = 0; i < 24; i += 4) {
260
uint32_t raw24;
261
- raw24 = (uint32_t)hdhomerun_pkt_read_u8(rx_pkt) << 16;
262
+ raw24 = (uint32_t)hdhomerun_pkt_read_u8(rx_pkt) << 16;
263
raw24 |= (uint32_t)hdhomerun_pkt_read_u8(rx_pkt) << 8;
264
raw24 |= (uint32_t)hdhomerun_pkt_read_u8(rx_pkt) << 0;
265
result->device_auth[i + 0] = hdhomerun_discover_recv_base64_encode_table[(raw24 >> 18) & 0x3F];
266
267
result->base_url[len] = 0;
268
break;
269
270
+ case HDHOMERUN_TAG_STORAGE_ID:
271
+ if (!result_v3) {
272
+ break;
273
+ }
274
+ if (len >= sizeof(result_v3->storage_id)) {
275
+ break;
276
+ }
277
+ hdhomerun_pkt_read_mem(rx_pkt, result_v3->storage_id, len);
278
+ result_v3->storage_id[len] = 0;
279
+ break;
280
+
281
+ case HDHOMERUN_TAG_LINEUP_URL:
282
+ if (!result_v3) {
283
+ break;
284
+ }
285
+ if (len >= sizeof(result_v3->lineup_url)) {
286
+ break;
287
+ }
288
+ hdhomerun_pkt_read_mem(rx_pkt, result_v3->lineup_url, len);
289
+ result_v3->lineup_url[len] = 0;
290
+ break;
291
+
292
+ case HDHOMERUN_TAG_STORAGE_URL:
293
+ if (!result_v3) {
294
+ break;
295
+ }
296
+ if (len >= sizeof(result_v3->storage_url)) {
297
+ break;
298
+ }
299
+ hdhomerun_pkt_read_mem(rx_pkt, result_v3->storage_url, len);
300
+ result_v3->storage_url[len] = 0;
301
+ break;
302
+
303
default:
304
break;
305
}
306
307
rx_pkt->pos = next;
308
}
309
310
- /* Fixup for old firmware. */
311
- if (result->tuner_count == 0) {
312
- switch (result->device_id >> 20) {
313
- case 0x102:
314
- result->tuner_count = 1;
315
- break;
316
+ /*
317
+ * Fixup for old firmware.
318
+ */
319
+ if (result->device_type == HDHOMERUN_DEVICE_TYPE_TUNER) {
320
+ if (result->tuner_count == 0) {
321
+ switch (result->device_id >> 20) {
322
+ case 0x102:
323
+ result->tuner_count = 1;
324
+ break;
325
326
- case 0x100:
327
- case 0x101:
328
- case 0x121:
329
- result->tuner_count = 2;
330
- break;
331
+ case 0x100:
332
+ case 0x101:
333
+ case 0x121:
334
+ result->tuner_count = 2;
335
+ break;
336
337
- default:
338
- break;
339
+ default:
340
+ break;
341
+ }
342
+ }
343
+
344
+ if (!result->base_url[0]) {
345
+ hdhomerun_sprintf(result->base_url, result->base_url + sizeof(result->base_url), "http://%u.%u.%u.%u:80",
346
+ (remote_addr >> 24) & 0xFF, (remote_addr >> 16) & 0xFF, (remote_addr >> 8) & 0xFF, (remote_addr >> 0) & 0xFF
347
+ );
348
}
349
}
350
351
- return TRUE;
352
+ return true;
353
}
354
355
-static bool_t hdhomerun_discover_recv(struct hdhomerun_discover_t *ds, struct hdhomerun_discover_device_t *result)
356
+static bool hdhomerun_discover_recv(struct hdhomerun_discover_t *ds, size_t result_struct_size, struct hdhomerun_discover_device_t *result)
357
{
358
unsigned int i;
359
for (i = 0; i < ds->sock_count; i++) {
360
struct hdhomerun_discover_sock_t *dss = &ds->socks[i];
361
362
- if (hdhomerun_discover_recv_internal(ds, dss, result)) {
363
- return TRUE;
364
+ if (hdhomerun_discover_recv_internal(ds, dss, result_struct_size, result)) {
365
+ return true;
366
}
367
}
368
369
- return FALSE;
370
+ return false;
371
+}
372
+
373
+static struct hdhomerun_discover_device_t *hdhomerun_discover_result_by_index(size_t result_struct_size, struct hdhomerun_discover_device_t result_list[], int index)
374
+{
375
+ uint8_t *ptr = (uint8_t *)(void *)result_list;
376
+ ptr += result_struct_size * index;
377
+ return (struct hdhomerun_discover_device_t *)(void *)ptr;
378
}
379
380
-static struct hdhomerun_discover_device_t *hdhomerun_discover_find_in_list(struct hdhomerun_discover_device_t result_list[], int count, struct hdhomerun_discover_device_t *lookup)
381
+static struct hdhomerun_discover_device_t *hdhomerun_discover_find_in_list(size_t result_struct_size, struct hdhomerun_discover_device_t result_list[], int count, struct hdhomerun_discover_device_t *lookup)
382
{
383
int index;
384
for (index = 0; index < count; index++) {
385
- struct hdhomerun_discover_device_t *entry = &result_list[index];
386
- if (memcmp(lookup, entry, sizeof(struct hdhomerun_discover_device_t)) == 0) {
387
- return entry;
388
+ struct hdhomerun_discover_device_t *entry = hdhomerun_discover_result_by_index(result_struct_size, result_list, index);
389
+ if (lookup->ip_addr != entry->ip_addr) {
390
+ continue;
391
+ }
392
+
393
+ if (strcmp(lookup->base_url, entry->base_url) != 0) {
394
+ continue;
395
}
396
+
397
+ return entry;
398
}
399
400
return NULL;
401
}
402
403
-int hdhomerun_discover_find_devices_v2(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id, struct hdhomerun_discover_device_t result_list[], int max_count)
404
+static int hdhomerun_discover_find_devices(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, size_t result_struct_size, struct hdhomerun_discover_device_t result_list[], int max_count)
405
{
406
hdhomerun_discover_sock_detect(ds);
407
408
int count = 0;
409
int attempt;
410
for (attempt = 0; attempt < 2; attempt++) {
411
- if (!hdhomerun_discover_send(ds, target_ip, device_type, device_id)) {
412
+ if (!hdhomerun_discover_send(ds, target_ip, device_type_match, device_id_match)) {
413
return -1;
414
}
415
416
uint64_t timeout = getcurrenttime() + 200;
417
while (1) {
418
- struct hdhomerun_discover_device_t *result = &result_list[count];
419
- memset(result, 0, sizeof(struct hdhomerun_discover_device_t));
420
+ struct hdhomerun_discover_device_t *result = hdhomerun_discover_result_by_index(result_struct_size, result_list, count);
421
422
- if (!hdhomerun_discover_recv(ds, result)) {
423
+ if (!hdhomerun_discover_recv(ds, result_struct_size, result)) {
424
if (getcurrenttime() >= timeout) {
425
break;
426
}
427
- msleep_approx(10);
428
+ msleep_approx(16);
429
continue;
430
}
431
432
- /* Filter. */
433
- if (device_type != HDHOMERUN_DEVICE_TYPE_WILDCARD) {
434
- if (device_type != result->device_type) {
435
- continue;
436
- }
437
+ /* Filter */
438
+ if ((device_type_match != HDHOMERUN_DEVICE_TYPE_WILDCARD) && (result->device_type != device_type_match)) {
439
+ continue;
440
}
441
- if (device_id != HDHOMERUN_DEVICE_ID_WILDCARD) {
442
- if (device_id != result->device_id) {
443
- continue;
444
- }
445
+ if ((device_id_match != HDHOMERUN_DEVICE_ID_WILDCARD) && (result->device_id != device_id_match)) {
446
+ continue;
447
}
448
449
/* Ensure not already in list. */
450
- if (hdhomerun_discover_find_in_list(result_list, count, result)) {
451
+ if (hdhomerun_discover_find_in_list(result_struct_size, result_list, count, result)) {
452
continue;
453
}
454
455
456
return count;
457
}
458
459
-int hdhomerun_discover_find_devices_custom_v2(uint32_t target_ip, uint32_t device_type, uint32_t device_id, struct hdhomerun_discover_device_t result_list[], int max_count)
460
+int hdhomerun_discover_find_devices_v3(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_v3_t result_list[], int max_count)
461
{
462
- if (hdhomerun_discover_is_ip_multicast(target_ip)) {
463
- return 0;
464
- }
465
+ return hdhomerun_discover_find_devices(ds, target_ip, device_type_match, device_id_match, sizeof(struct hdhomerun_discover_device_v3_t), (struct hdhomerun_discover_device_t *)(void *)result_list, max_count);
466
+}
467
+
468
+int hdhomerun_discover_find_devices_v2(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_t result_list[], int max_count)
469
+{
470
+ return hdhomerun_discover_find_devices(ds, target_ip, device_type_match, device_id_match, sizeof(struct hdhomerun_discover_device_t), (struct hdhomerun_discover_device_t *)(void *)result_list, max_count);
471
+}
472
473
+int hdhomerun_discover_find_devices_custom_v3(uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_v3_t result_list[], int max_count)
474
+{
475
struct hdhomerun_discover_t *ds = hdhomerun_discover_create(NULL);
476
if (!ds) {
477
return -1;
478
}
479
480
- int ret = hdhomerun_discover_find_devices_v2(ds, target_ip, device_type, device_id, result_list, max_count);
481
+ int ret = hdhomerun_discover_find_devices(ds, target_ip, device_type_match, device_id_match, sizeof(struct hdhomerun_discover_device_v3_t), (struct hdhomerun_discover_device_t *)(void *)result_list, max_count);
482
+ hdhomerun_discover_destroy(ds);
483
+ return ret;
484
+}
485
+
486
+int hdhomerun_discover_find_devices_custom_v2(uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_t result_list[], int max_count)
487
+{
488
+ struct hdhomerun_discover_t *ds = hdhomerun_discover_create(NULL);
489
+ if (!ds) {
490
+ return -1;
491
+ }
492
493
+ int ret = hdhomerun_discover_find_devices(ds, target_ip, device_type_match, device_id_match, sizeof(struct hdhomerun_discover_device_t), (struct hdhomerun_discover_device_t *)(void *)result_list, max_count);
494
hdhomerun_discover_destroy(ds);
495
return ret;
496
}
497
498
-bool_t hdhomerun_discover_validate_device_id(uint32_t device_id)
499
+bool hdhomerun_discover_validate_device_id(uint32_t device_id)
500
{
501
static uint8_t lookup_table[16] = {0xA, 0x5, 0xF, 0x6, 0x7, 0xC, 0x1, 0xB, 0x9, 0x2, 0x8, 0xD, 0x4, 0x3, 0xE, 0x0};
502
503
504
return (checksum == 0);
505
}
506
507
-bool_t hdhomerun_discover_is_ip_multicast(uint32_t ip_addr)
508
+bool hdhomerun_discover_is_ip_multicast(uint32_t ip_addr)
509
{
510
return (ip_addr >= 0xE0000000) && (ip_addr < 0xF0000000);
511
}
512
libhdhomerun_20150826.tgz/hdhomerun_discover.h -> libhdhomerun_20190621.tgz/hdhomerun_discover.h
Changed
90
1
2
/*
3
* hdhomerun_discover.h
4
*
5
- * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2019 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
uint32_t device_type;
12
uint32_t device_id;
13
uint8_t tuner_count;
14
- bool_t is_legacy;
15
+ bool is_legacy;
16
char device_auth[25];
17
char base_url[29];
18
};
19
20
+struct hdhomerun_discover_device_v3_t {
21
+ uint32_t ip_addr;
22
+ uint32_t device_type;
23
+ uint32_t device_id;
24
+ uint8_t tuner_count;
25
+ bool is_legacy;
26
+ char device_auth[25];
27
+ char base_url[29];
28
+
29
+ char storage_id[37];
30
+ char lineup_url[128];
31
+ char storage_url[128];
32
+};
33
+
34
/*
35
* Find devices.
36
*
37
* The device information is stored in caller-supplied array of hdhomerun_discover_device_t vars.
38
* Multiple attempts are made to find devices.
39
- * Execution time is typically 400ms if max_count is not reached.
40
+ * Execution time is typically 400ms unless max_count is reached.
41
*
42
* Set target_ip to zero to auto-detect the IP address.
43
* Set device_type to HDHOMERUN_DEVICE_TYPE_TUNER to detect HDHomeRun tuner devices.
44
45
* Returns the number of devices found.
46
* Retruns -1 on error.
47
*/
48
-extern LIBTYPE int hdhomerun_discover_find_devices_custom_v2(uint32_t target_ip, uint32_t device_type, uint32_t device_id, struct hdhomerun_discover_device_t result_list[], int max_count);
49
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_custom_v2(uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_t result_list[], int max_count);
50
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_custom_v3(uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_v3_t result_list[], int max_count);
51
52
/*
53
* Optional: persistent discover instance available for discover polling use.
54
*/
55
-extern LIBTYPE struct hdhomerun_discover_t *hdhomerun_discover_create(struct hdhomerun_debug_t *dbg);
56
-extern LIBTYPE void hdhomerun_discover_destroy(struct hdhomerun_discover_t *ds);
57
-extern LIBTYPE int hdhomerun_discover_find_devices_v2(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id, struct hdhomerun_discover_device_t result_list[], int max_count);
58
+extern LIBHDHOMERUN_API struct hdhomerun_discover_t *hdhomerun_discover_create(struct hdhomerun_debug_t *dbg);
59
+extern LIBHDHOMERUN_API void hdhomerun_discover_destroy(struct hdhomerun_discover_t *ds);
60
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_v2(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_t result_list[], int max_count);
61
+extern LIBHDHOMERUN_API int hdhomerun_discover_find_devices_v3(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type_match, uint32_t device_id_match, struct hdhomerun_discover_device_v3_t result_list[], int max_count);
62
63
/*
64
* Verify that the device ID given is valid.
65
66
* The device ID contains a self-check sequence that detects common user input errors including
67
* single-digit errors and two digit transposition errors.
68
*
69
- * Returns TRUE if valid.
70
- * Returns FALSE if not valid.
71
+ * Returns true if valid.
72
+ * Returns false if not valid.
73
*/
74
-extern LIBTYPE bool_t hdhomerun_discover_validate_device_id(uint32_t device_id);
75
+extern LIBHDHOMERUN_API bool hdhomerun_discover_validate_device_id(uint32_t device_id);
76
77
/*
78
* Detect if an IP address is multicast.
79
*
80
- * Returns TRUE if multicast.
81
- * Returns FALSE if zero, unicast, expermental, or broadcast.
82
+ * Returns true if multicast.
83
+ * Returns false if zero, unicast, expermental, or broadcast.
84
*/
85
-extern LIBTYPE bool_t hdhomerun_discover_is_ip_multicast(uint32_t ip_addr);
86
+extern LIBHDHOMERUN_API bool hdhomerun_discover_is_ip_multicast(uint32_t ip_addr);
87
88
#ifdef __cplusplus
89
}
90
libhdhomerun_20150826.tgz/hdhomerun_os.h -> libhdhomerun_20190621.tgz/hdhomerun_os.h
Changed
32
1
2
/*
3
* hdhomerun_os.h
4
*
5
- * Copyright © 2006-2008 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
12
*/
13
14
-#if defined(_WIN32) || defined(_WIN64)
15
-#define __WINDOWS__
16
-#endif
17
-
18
-#if defined(__WINDOWS__)
19
+#if defined(_WIN32)
20
#include "hdhomerun_os_windows.h"
21
#else
22
#include "hdhomerun_os_posix.h"
23
#endif
24
-
25
-#if !defined(TRUE)
26
-#define TRUE 1
27
-#endif
28
-
29
-#if !defined(FALSE)
30
-#define FALSE 0
31
-#endif
32
libhdhomerun_20150826.tgz/hdhomerun_os_posix.c -> libhdhomerun_20190621.tgz/hdhomerun_os_posix.c
Changed
249
1
2
/*
3
* hdhomerun_os_posix.c
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2017 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
#include "hdhomerun_os.h"
12
13
#if defined(__APPLE__)
14
+
15
#include <mach/clock.h>
16
#include <mach/mach.h>
17
+
18
+static pthread_once_t clock_monotonic_once = PTHREAD_ONCE_INIT;
19
+static clock_serv_t clock_monotonic_clock_serv;
20
+
21
+static void clock_monotonic_init(void)
22
+{
23
+ host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock_monotonic_clock_serv);
24
+}
25
+
26
+static inline void clock_monotonic_timespec(struct timespec *ts)
27
+{
28
+ pthread_once(&clock_monotonic_once, clock_monotonic_init);
29
+
30
+ struct mach_timespec mt;
31
+ clock_get_time(clock_monotonic_clock_serv, &mt);
32
+ ts->tv_nsec = mt.tv_nsec;
33
+ ts->tv_sec = mt.tv_sec;
34
+}
35
+
36
+static inline void clock_realtime_timespec(struct timespec *ts)
37
+{
38
+ struct timeval tv;
39
+ gettimeofday(&tv, NULL);
40
+ ts->tv_nsec = tv.tv_usec * 1000;
41
+ ts->tv_sec = tv.tv_sec;
42
+}
43
+
44
+#else
45
+
46
+static inline void clock_monotonic_timespec(struct timespec *ts)
47
+{
48
+ clock_gettime(CLOCK_MONOTONIC, ts);
49
+}
50
+
51
+static inline void clock_realtime_timespec(struct timespec *ts)
52
+{
53
+ clock_gettime(CLOCK_REALTIME, ts);
54
+}
55
+
56
#endif
57
58
static pthread_once_t random_get32_once = PTHREAD_ONCE_INIT;
59
60
61
uint64_t getcurrenttime(void)
62
{
63
-#if defined(CLOCK_MONOTONIC)
64
- struct timespec t;
65
- clock_gettime(CLOCK_MONOTONIC, &t);
66
- return ((uint64_t)t.tv_sec * 1000) + (t.tv_nsec / 1000000);
67
-#elif defined(__APPLE__)
68
- clock_serv_t clock_serv;
69
- host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock_serv);
70
-
71
- struct mach_timespec t;
72
- clock_get_time(clock_serv, &t);
73
-
74
- mach_port_deallocate(mach_task_self(), clock_serv);
75
- return ((uint64_t)t.tv_sec * 1000) + (t.tv_nsec / 1000000);
76
-#else
77
-#error no clock source for getcurrenttime()
78
-#endif
79
+ struct timespec ts;
80
+ clock_monotonic_timespec(&ts);
81
+ return ((uint64_t)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
82
}
83
84
void msleep_approx(uint64_t ms)
85
{
86
- unsigned int delay_s = ms / 1000;
87
+ uint64_t delay_s = ms / 1000;
88
if (delay_s > 0) {
89
- sleep(delay_s);
90
+ sleep((unsigned int)delay_s);
91
ms -= delay_s * 1000;
92
}
93
94
- unsigned int delay_us = ms * 1000;
95
+ uint64_t delay_us = ms * 1000;
96
if (delay_us > 0) {
97
- usleep(delay_us);
98
+ usleep((useconds_t)delay_us);
99
}
100
}
101
102
103
}
104
}
105
106
-bool_t hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap)
107
+struct thread_task_execute_args_t {
108
+ thread_task_func_t func;
109
+ void *arg;
110
+};
111
+
112
+static void *thread_task_execute(void *arg)
113
+{
114
+ struct thread_task_execute_args_t *execute_args = (struct thread_task_execute_args_t *)arg;
115
+ execute_args->func(execute_args->arg);
116
+ free(execute_args);
117
+ return NULL;
118
+}
119
+
120
+bool thread_task_create(thread_task_t *tid, thread_task_func_t func, void *arg)
121
+{
122
+ struct thread_task_execute_args_t *execute_args = (struct thread_task_execute_args_t *)malloc(sizeof(struct thread_task_execute_args_t));
123
+ if (!execute_args) {
124
+ return false;
125
+ }
126
+
127
+ execute_args->func = func;
128
+ execute_args->arg = arg;
129
+
130
+ if (pthread_create(tid, NULL, thread_task_execute, execute_args) != 0) {
131
+ free(execute_args);
132
+ return false;
133
+ }
134
+
135
+ return true;
136
+}
137
+
138
+void thread_task_join(thread_task_t tid)
139
+{
140
+ pthread_join(tid, NULL);
141
+}
142
+
143
+void thread_mutex_init(thread_mutex_t *mutex)
144
+{
145
+ pthread_mutex_init(mutex, NULL);
146
+}
147
+
148
+void thread_mutex_dispose(pthread_mutex_t *mutex)
149
+{
150
+}
151
+
152
+void thread_mutex_lock(thread_mutex_t *mutex)
153
+{
154
+ pthread_mutex_lock(mutex);
155
+}
156
+
157
+void thread_mutex_unlock(thread_mutex_t *mutex)
158
+{
159
+ pthread_mutex_unlock(mutex);
160
+}
161
+
162
+void thread_cond_init(thread_cond_t *cond)
163
+{
164
+ cond->signaled = false;
165
+ pthread_mutex_init(&cond->lock, NULL);
166
+ pthread_cond_init(&cond->cond, NULL);
167
+}
168
+
169
+void thread_cond_dispose(thread_cond_t *cond)
170
+{
171
+}
172
+
173
+void thread_cond_signal(thread_cond_t *cond)
174
+{
175
+ pthread_mutex_lock(&cond->lock);
176
+
177
+ cond->signaled = true;
178
+ pthread_cond_signal(&cond->cond);
179
+
180
+ pthread_mutex_unlock(&cond->lock);
181
+}
182
+
183
+void thread_cond_wait(thread_cond_t *cond)
184
+{
185
+ pthread_mutex_lock(&cond->lock);
186
+
187
+ if (!cond->signaled) {
188
+ pthread_cond_wait(&cond->cond, &cond->lock);
189
+ }
190
+
191
+ cond->signaled = false;
192
+ pthread_mutex_unlock(&cond->lock);
193
+}
194
+
195
+void thread_cond_wait_with_timeout(thread_cond_t *cond, uint64_t max_wait_time)
196
+{
197
+ pthread_mutex_lock(&cond->lock);
198
+
199
+ if (!cond->signaled) {
200
+ struct timespec ts;
201
+ clock_realtime_timespec(&ts);
202
+
203
+ uint64_t tv_nsec = (uint64_t)ts.tv_nsec + (max_wait_time * 1000000);
204
+ ts.tv_nsec = (long)(tv_nsec % 1000000000);
205
+ ts.tv_sec += (time_t)(tv_nsec / 1000000000);
206
+
207
+ pthread_cond_timedwait(&cond->cond, &cond->lock, &ts);
208
+ }
209
+
210
+ cond->signaled = false;
211
+ pthread_mutex_unlock(&cond->lock);
212
+}
213
+
214
+bool hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap)
215
{
216
if (buffer >= end) {
217
- return FALSE;
218
+ return false;
219
}
220
221
int length = vsnprintf(buffer, end - buffer - 1, fmt, ap);
222
if (length < 0) {
223
*buffer = 0;
224
- return FALSE;
225
+ return false;
226
}
227
228
if (buffer + length + 1 > end) {
229
*(end - 1) = 0;
230
- return FALSE;
231
+ return false;
232
233
}
234
235
- return TRUE;
236
+ return true;
237
}
238
239
-bool_t hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...)
240
+bool hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...)
241
{
242
va_list ap;
243
va_start(ap, fmt);
244
- bool_t result = hdhomerun_vsprintf(buffer, end, fmt, ap);
245
+ bool result = hdhomerun_vsprintf(buffer, end, fmt, ap);
246
va_end(ap);
247
return result;
248
}
249
libhdhomerun_20150826.tgz/hdhomerun_os_posix.h -> libhdhomerun_20190621.tgz/hdhomerun_os_posix.h
Changed
89
1
2
/*
3
* hdhomerun_os_posix.h
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2017 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
#include <stdlib.h>
12
#include <stdio.h>
13
#include <stdarg.h>
14
+#include <stdint.h>
15
+#include <stdbool.h>
16
#include <string.h>
17
#include <unistd.h>
18
#include <errno.h>
19
20
#include <signal.h>
21
#include <sys/types.h>
22
#include <sys/socket.h>
23
+#include <sys/stat.h>
24
#include <sys/time.h>
25
-#include <sys/timeb.h>
26
#include <sys/wait.h>
27
#include <netinet/in.h>
28
#include <arpa/inet.h>
29
30
#include <netdb.h>
31
#include <pthread.h>
32
33
-typedef int bool_t;
34
typedef void (*sig_t)(int);
35
+typedef void (*thread_task_func_t)(void *arg);
36
+typedef pthread_t thread_task_t;
37
+typedef pthread_mutex_t thread_mutex_t;
38
39
-#define LIBTYPE
40
-#define console_vprintf vprintf
41
-#define console_printf printf
42
-#define THREAD_FUNC_PREFIX void *
43
+typedef struct {
44
+ volatile bool signaled;
45
+ pthread_mutex_t lock;
46
+ pthread_cond_t cond;
47
+} thread_cond_t;
48
+
49
+#define LIBHDHOMERUN_API
50
+
51
+#if !defined(alignas) && !defined(__cplusplus)
52
+#define alignas(n) __attribute__((aligned(n)))
53
+#endif
54
55
#ifdef __cplusplus
56
extern "C" {
57
#endif
58
59
-extern LIBTYPE uint32_t random_get32(void);
60
-extern LIBTYPE uint64_t getcurrenttime(void);
61
-extern LIBTYPE void msleep_approx(uint64_t ms);
62
-extern LIBTYPE void msleep_minimum(uint64_t ms);
63
+extern LIBHDHOMERUN_API uint32_t random_get32(void);
64
+extern LIBHDHOMERUN_API uint64_t getcurrenttime(void);
65
+extern LIBHDHOMERUN_API void msleep_approx(uint64_t ms);
66
+extern LIBHDHOMERUN_API void msleep_minimum(uint64_t ms);
67
+
68
+extern LIBHDHOMERUN_API bool thread_task_create(thread_task_t *tid, thread_task_func_t func, void *arg);
69
+extern LIBHDHOMERUN_API void thread_task_join(thread_task_t tid);
70
+
71
+extern LIBHDHOMERUN_API void thread_mutex_init(thread_mutex_t *mutex);
72
+extern LIBHDHOMERUN_API void thread_mutex_dispose(thread_mutex_t *mutex);
73
+extern LIBHDHOMERUN_API void thread_mutex_lock(thread_mutex_t *mutex);
74
+extern LIBHDHOMERUN_API void thread_mutex_unlock(thread_mutex_t *mutex);
75
+
76
+extern LIBHDHOMERUN_API void thread_cond_init(thread_cond_t *cond);
77
+extern LIBHDHOMERUN_API void thread_cond_dispose(thread_cond_t *cond);
78
+extern LIBHDHOMERUN_API void thread_cond_signal(thread_cond_t *cond);
79
+extern LIBHDHOMERUN_API void thread_cond_wait(thread_cond_t *cond);
80
+extern LIBHDHOMERUN_API void thread_cond_wait_with_timeout(thread_cond_t *cond, uint64_t max_wait_time);
81
82
-extern LIBTYPE bool_t hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap);
83
-extern LIBTYPE bool_t hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...);
84
+extern LIBHDHOMERUN_API bool hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap);
85
+extern LIBHDHOMERUN_API bool hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...);
86
87
#ifdef __cplusplus
88
}
89
libhdhomerun_20150826.tgz/hdhomerun_os_windows.c -> libhdhomerun_20190621.tgz/hdhomerun_os_windows.c
Changed
205
1
2
/*
3
* hdhomerun_os_windows.c
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2017 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
12
*/
13
14
-#include "hdhomerun_os.h"
15
-
16
-static DWORD random_get32_context_tls = TlsAlloc();
17
+#include "hdhomerun.h"
18
19
+#if defined(_WINRT)
20
+uint32_t random_get32(void)
21
+{
22
+ return (uint32_t)getcurrenttime();
23
+}
24
+#else
25
uint32_t random_get32(void)
26
{
27
+ static DWORD random_get32_context_tls = 0xFFFFFFFF;
28
+ if (random_get32_context_tls == 0xFFFFFFFF) {
29
+ random_get32_context_tls = TlsAlloc();
30
+ }
31
+
32
HCRYPTPROV *phProv = (HCRYPTPROV *)TlsGetValue(random_get32_context_tls);
33
if (!phProv) {
34
phProv = (HCRYPTPROV *)calloc(1, sizeof(HCRYPTPROV));
35
36
37
return Result;
38
}
39
+#endif
40
41
uint64_t getcurrenttime(void)
42
{
43
44
}
45
}
46
47
-int pthread_create(pthread_t *tid, void *attr, LPTHREAD_START_ROUTINE start, void *arg)
48
+struct thread_task_execute_args_t {
49
+ thread_task_func_t func;
50
+ void *arg;
51
+};
52
+
53
+static DWORD WINAPI thread_task_execute(void *arg)
54
+{
55
+ struct thread_task_execute_args_t *execute_args = (struct thread_task_execute_args_t *)arg;
56
+ execute_args->func(execute_args->arg);
57
+ free(execute_args);
58
+ return 0;
59
+}
60
+
61
+bool thread_task_create(thread_task_t *tid, thread_task_func_t func, void *arg)
62
{
63
- *tid = CreateThread(NULL, 0, start, arg, 0, NULL);
64
+ struct thread_task_execute_args_t *execute_args = (struct thread_task_execute_args_t *)malloc(sizeof(struct thread_task_execute_args_t));
65
+ if (!execute_args) {
66
+ return false;
67
+ }
68
+
69
+ execute_args->func = func;
70
+ execute_args->arg = arg;
71
+
72
+ *tid = CreateThread(NULL, 0, thread_task_execute, execute_args, 0, NULL);
73
if (!*tid) {
74
- return (int)GetLastError();
75
+ free(execute_args);
76
+ return false;
77
}
78
- return 0;
79
+
80
+ return true;
81
}
82
83
-int pthread_join(pthread_t tid, void **value_ptr)
84
+void thread_task_join(thread_task_t tid)
85
{
86
while (1) {
87
DWORD ExitCode = 0;
88
if (!GetExitCodeThread(tid, &ExitCode)) {
89
- return (int)GetLastError();
90
+ return;
91
}
92
if (ExitCode != STILL_ACTIVE) {
93
- return 0;
94
+ return;
95
}
96
}
97
}
98
99
-void pthread_mutex_init(pthread_mutex_t *mutex, void *attr)
100
+void thread_mutex_init(thread_mutex_t *mutex)
101
{
102
- *mutex = CreateMutex(NULL, FALSE, NULL);
103
+ *mutex = CreateMutex(NULL, false, NULL);
104
}
105
106
-void pthread_mutex_lock(pthread_mutex_t *mutex)
107
+void thread_mutex_dispose(thread_mutex_t *mutex)
108
+{
109
+ CloseHandle(*mutex);
110
+}
111
+
112
+void thread_mutex_lock(thread_mutex_t *mutex)
113
{
114
WaitForSingleObject(*mutex, INFINITE);
115
}
116
117
-void pthread_mutex_unlock(pthread_mutex_t *mutex)
118
+void thread_mutex_unlock(thread_mutex_t *mutex)
119
{
120
ReleaseMutex(*mutex);
121
}
122
123
-bool_t hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap)
124
+void thread_cond_init(thread_cond_t *cond)
125
+{
126
+ *cond = CreateEvent(NULL, false, false, NULL);
127
+}
128
+
129
+void thread_cond_dispose(thread_cond_t *cond)
130
+{
131
+ CloseHandle(*cond);
132
+}
133
+
134
+void thread_cond_signal(thread_cond_t *cond)
135
+{
136
+ SetEvent(*cond);
137
+}
138
+
139
+void thread_cond_wait(thread_cond_t *cond)
140
+{
141
+ WaitForSingleObject(*cond, INFINITE);
142
+}
143
+
144
+void thread_cond_wait_with_timeout(thread_cond_t *cond, uint64_t max_wait_time)
145
+{
146
+ WaitForSingleObject(*cond, (DWORD)max_wait_time);
147
+}
148
+
149
+bool hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap)
150
{
151
if (buffer >= end) {
152
- return FALSE;
153
+ return false;
154
}
155
156
int length = _vsnprintf(buffer, end - buffer - 1, fmt, ap);
157
if (length < 0) {
158
*buffer = 0;
159
- return FALSE;
160
+ return false;
161
}
162
163
if (buffer + length + 1 > end) {
164
*(end - 1) = 0;
165
- return FALSE;
166
+ return false;
167
168
}
169
170
- return TRUE;
171
+ return true;
172
}
173
174
-bool_t hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...)
175
+bool hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...)
176
{
177
va_list ap;
178
va_start(ap, fmt);
179
- bool_t result = hdhomerun_vsprintf(buffer, end, fmt, ap);
180
+ bool result = hdhomerun_vsprintf(buffer, end, fmt, ap);
181
va_end(ap);
182
return result;
183
}
184
-
185
-/*
186
- * The console output format should be set to UTF-8, however in XP and Vista this breaks batch file processing.
187
- * Attempting to restore on exit fails to restore if the program is terminated by the user.
188
- * Solution - set the output format each printf.
189
- */
190
-void console_vprintf(const char *fmt, va_list ap)
191
-{
192
- UINT cp = GetConsoleOutputCP();
193
- SetConsoleOutputCP(CP_UTF8);
194
- vprintf(fmt, ap);
195
- SetConsoleOutputCP(cp);
196
-}
197
-
198
-void console_printf(const char *fmt, ...)
199
-{
200
- va_list ap;
201
- va_start(ap, fmt);
202
- console_vprintf(fmt, ap);
203
- va_end(ap);
204
-}
205
libhdhomerun_20150826.tgz/hdhomerun_os_windows.h -> libhdhomerun_20190621.tgz/hdhomerun_os_windows.h
Changed
144
1
2
/*
3
* hdhomerun_os_windows.h
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2017 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
12
*/
13
14
-#define _WINSOCKAPI_
15
-#include <windows.h>
16
+#ifdef _WINRT
17
+#include <SDKDDKVer.h>
18
+#endif
19
+
20
+#ifndef _WIN32_WINNT
21
+#define _WIN32_WINNT _WIN32_WINNT_VISTA
22
+#endif
23
+#ifndef _CRT_SECURE_NO_WARNINGS
24
+#define _CRT_SECURE_NO_WARNINGS
25
+#endif
26
+#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
27
+#define _WINSOCK_DEPRECATED_NO_WARNINGS
28
+#endif
29
+
30
#include <winsock2.h>
31
+#include <windows.h>
32
#include <ws2tcpip.h>
33
#include <wspiapi.h>
34
#include <stdlib.h>
35
#include <stdio.h>
36
#include <stdarg.h>
37
+#include <stdint.h>
38
+#include <stdbool.h>
39
#include <string.h>
40
#include <signal.h>
41
#include <time.h>
42
#include <sys/types.h>
43
-#include <sys/timeb.h>
44
-
45
-#if defined(DLL_IMPORT)
46
-#define LIBTYPE __declspec( dllexport )
47
-#elif defined(DLL_EXPORT)
48
-#define LIBTYPE __declspec( dllimport )
49
-#else
50
-#define LIBTYPE
51
+
52
+#ifdef LIBHDHOMERUN_DLLEXPORT
53
+#define LIBHDHOMERUN_API __declspec(dllexport)
54
+#endif
55
+#ifdef LIBHDHOMERUN_DLLIMPORT
56
+#define LIBHDHOMERUN_API __declspec(dllimport)
57
+#endif
58
+#ifndef LIBHDHOMERUN_API
59
+#define LIBHDHOMERUN_API
60
+#endif
61
+
62
+#if !defined(__unused)
63
+#define __unused __pragma(warning(suppress: 4100 4101))
64
+#endif
65
+
66
+#if !defined(alignas) && !defined(__cplusplus)
67
+#define alignas(n) __declspec(align(n))
68
#endif
69
70
-typedef int bool_t;
71
-typedef signed __int8 int8_t;
72
-typedef signed __int16 int16_t;
73
-typedef signed __int32 int32_t;
74
-typedef signed __int64 int64_t;
75
-typedef unsigned __int8 uint8_t;
76
-typedef unsigned __int16 uint16_t;
77
-typedef unsigned __int32 uint32_t;
78
-typedef unsigned __int64 uint64_t;
79
typedef void (*sig_t)(int);
80
-typedef HANDLE pthread_t;
81
-typedef HANDLE pthread_mutex_t;
82
+typedef void (*thread_task_func_t)(void *arg);
83
+typedef HANDLE thread_task_t;
84
+typedef HANDLE thread_mutex_t;
85
+typedef HANDLE thread_cond_t;
86
87
#if !defined(va_copy)
88
#define va_copy(x, y) x = y
89
90
#define atoll _atoi64
91
#define strdup _strdup
92
#define strcasecmp _stricmp
93
+#define strncasecmp _strnicmp
94
#define fseeko _fseeki64
95
#define ftello _ftelli64
96
-#define THREAD_FUNC_PREFIX DWORD WINAPI
97
98
#ifdef __cplusplus
99
extern "C" {
100
#endif
101
102
-extern LIBTYPE uint32_t random_get32(void);
103
-extern LIBTYPE uint64_t getcurrenttime(void);
104
-extern LIBTYPE void msleep_approx(uint64_t ms);
105
-extern LIBTYPE void msleep_minimum(uint64_t ms);
106
+extern LIBHDHOMERUN_API uint32_t random_get32(void);
107
+extern LIBHDHOMERUN_API uint64_t getcurrenttime(void);
108
+extern LIBHDHOMERUN_API void msleep_approx(uint64_t ms);
109
+extern LIBHDHOMERUN_API void msleep_minimum(uint64_t ms);
110
111
-extern LIBTYPE int pthread_create(pthread_t *tid, void *attr, LPTHREAD_START_ROUTINE start, void *arg);
112
-extern LIBTYPE int pthread_join(pthread_t tid, void **value_ptr);
113
-extern LIBTYPE void pthread_mutex_init(pthread_mutex_t *mutex, void *attr);
114
-extern LIBTYPE void pthread_mutex_lock(pthread_mutex_t *mutex);
115
-extern LIBTYPE void pthread_mutex_unlock(pthread_mutex_t *mutex);
116
+extern LIBHDHOMERUN_API bool thread_task_create(thread_task_t *tid, thread_task_func_t func, void *arg);
117
+extern LIBHDHOMERUN_API void thread_task_join(thread_task_t tid);
118
119
-extern LIBTYPE bool_t hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap);
120
-extern LIBTYPE bool_t hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...);
121
+extern LIBHDHOMERUN_API void thread_mutex_init(thread_mutex_t *mutex);
122
+extern LIBHDHOMERUN_API void thread_mutex_dispose(thread_mutex_t *mutex);
123
+extern LIBHDHOMERUN_API void thread_mutex_lock(thread_mutex_t *mutex);
124
+extern LIBHDHOMERUN_API void thread_mutex_unlock(thread_mutex_t *mutex);
125
126
-/*
127
- * The console output format should be set to UTF-8, however in XP and Vista this breaks batch file processing.
128
- * Attempting to restore on exit fails to restore if the program is terminated by the user.
129
- * Solution - set the output format each printf.
130
- */
131
-extern LIBTYPE void console_vprintf(const char *fmt, va_list ap);
132
-extern LIBTYPE void console_printf(const char *fmt, ...);
133
+extern LIBHDHOMERUN_API void thread_cond_init(thread_cond_t *cond);
134
+extern LIBHDHOMERUN_API void thread_cond_dispose(thread_cond_t *cond);
135
+extern LIBHDHOMERUN_API void thread_cond_signal(thread_cond_t *cond);
136
+extern LIBHDHOMERUN_API void thread_cond_wait(thread_cond_t *cond);
137
+extern LIBHDHOMERUN_API void thread_cond_wait_with_timeout(thread_cond_t *cond, uint64_t max_wait_time);
138
+
139
+extern LIBHDHOMERUN_API bool hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap);
140
+extern LIBHDHOMERUN_API bool hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...);
141
142
#ifdef __cplusplus
143
}
144
libhdhomerun_20150826.tgz/hdhomerun_pkt.c -> libhdhomerun_20190621.tgz/hdhomerun_pkt.c
Changed
10
1
2
/*
3
* hdhomerun_pkt.c
4
*
5
- * Copyright © 2005-2006 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2014 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
libhdhomerun_20150826.tgz/hdhomerun_pkt.h -> libhdhomerun_20190621.tgz/hdhomerun_pkt.h
Changed
70
1
2
/*
3
* hdhomerun_pkt.h
4
*
5
- * Copyright © 2005-2006 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
#define HDHOMERUN_TAG_GETSET_LOCKKEY 0x15
12
#define HDHOMERUN_TAG_ERROR_MESSAGE 0x05
13
#define HDHOMERUN_TAG_TUNER_COUNT 0x10
14
-#define HDHOMERUN_TAG_DEVICE_AUTH_BIN 0x29
15
+#define HDHOMERUN_TAG_LINEUP_URL 0x27
16
+#define HDHOMERUN_TAG_STORAGE_URL 0x28
17
+#define HDHOMERUN_TAG_DEVICE_AUTH_BIN_DEPRECATED 0x29
18
#define HDHOMERUN_TAG_BASE_URL 0x2A
19
#define HDHOMERUN_TAG_DEVICE_AUTH_STR 0x2B
20
+#define HDHOMERUN_TAG_STORAGE_ID 0x2C
21
22
#define HDHOMERUN_DEVICE_TYPE_WILDCARD 0xFFFFFFFF
23
#define HDHOMERUN_DEVICE_TYPE_TUNER 0x00000001
24
+#define HDHOMERUN_DEVICE_TYPE_STORAGE 0x00000005
25
#define HDHOMERUN_DEVICE_ID_WILDCARD 0xFFFFFFFF
26
27
#define HDHOMERUN_MIN_PEEK_LENGTH 4
28
29
uint8_t buffer[3074];
30
};
31
32
-extern LIBTYPE struct hdhomerun_pkt_t *hdhomerun_pkt_create(void);
33
-extern LIBTYPE void hdhomerun_pkt_destroy(struct hdhomerun_pkt_t *pkt);
34
-extern LIBTYPE void hdhomerun_pkt_reset(struct hdhomerun_pkt_t *pkt);
35
+extern LIBHDHOMERUN_API struct hdhomerun_pkt_t *hdhomerun_pkt_create(void);
36
+extern LIBHDHOMERUN_API void hdhomerun_pkt_destroy(struct hdhomerun_pkt_t *pkt);
37
+extern LIBHDHOMERUN_API void hdhomerun_pkt_reset(struct hdhomerun_pkt_t *pkt);
38
39
-extern LIBTYPE uint8_t hdhomerun_pkt_read_u8(struct hdhomerun_pkt_t *pkt);
40
-extern LIBTYPE uint16_t hdhomerun_pkt_read_u16(struct hdhomerun_pkt_t *pkt);
41
-extern LIBTYPE uint32_t hdhomerun_pkt_read_u32(struct hdhomerun_pkt_t *pkt);
42
-extern LIBTYPE size_t hdhomerun_pkt_read_var_length(struct hdhomerun_pkt_t *pkt);
43
-extern LIBTYPE uint8_t *hdhomerun_pkt_read_tlv(struct hdhomerun_pkt_t *pkt, uint8_t *ptag, size_t *plength);
44
-extern LIBTYPE void hdhomerun_pkt_read_mem(struct hdhomerun_pkt_t *pkt, void *mem, size_t length);
45
+extern LIBHDHOMERUN_API uint8_t hdhomerun_pkt_read_u8(struct hdhomerun_pkt_t *pkt);
46
+extern LIBHDHOMERUN_API uint16_t hdhomerun_pkt_read_u16(struct hdhomerun_pkt_t *pkt);
47
+extern LIBHDHOMERUN_API uint32_t hdhomerun_pkt_read_u32(struct hdhomerun_pkt_t *pkt);
48
+extern LIBHDHOMERUN_API size_t hdhomerun_pkt_read_var_length(struct hdhomerun_pkt_t *pkt);
49
+extern LIBHDHOMERUN_API uint8_t *hdhomerun_pkt_read_tlv(struct hdhomerun_pkt_t *pkt, uint8_t *ptag, size_t *plength);
50
+extern LIBHDHOMERUN_API void hdhomerun_pkt_read_mem(struct hdhomerun_pkt_t *pkt, void *mem, size_t length);
51
52
-extern LIBTYPE void hdhomerun_pkt_write_u8(struct hdhomerun_pkt_t *pkt, uint8_t v);
53
-extern LIBTYPE void hdhomerun_pkt_write_u16(struct hdhomerun_pkt_t *pkt, uint16_t v);
54
-extern LIBTYPE void hdhomerun_pkt_write_u32(struct hdhomerun_pkt_t *pkt, uint32_t v);
55
-extern LIBTYPE void hdhomerun_pkt_write_var_length(struct hdhomerun_pkt_t *pkt, size_t v);
56
-extern LIBTYPE void hdhomerun_pkt_write_mem(struct hdhomerun_pkt_t *pkt, const void *mem, size_t length);
57
+extern LIBHDHOMERUN_API void hdhomerun_pkt_write_u8(struct hdhomerun_pkt_t *pkt, uint8_t v);
58
+extern LIBHDHOMERUN_API void hdhomerun_pkt_write_u16(struct hdhomerun_pkt_t *pkt, uint16_t v);
59
+extern LIBHDHOMERUN_API void hdhomerun_pkt_write_u32(struct hdhomerun_pkt_t *pkt, uint32_t v);
60
+extern LIBHDHOMERUN_API void hdhomerun_pkt_write_var_length(struct hdhomerun_pkt_t *pkt, size_t v);
61
+extern LIBHDHOMERUN_API void hdhomerun_pkt_write_mem(struct hdhomerun_pkt_t *pkt, const void *mem, size_t length);
62
63
-extern LIBTYPE bool_t hdhomerun_pkt_open_frame(struct hdhomerun_pkt_t *pkt, uint16_t *ptype);
64
-extern LIBTYPE void hdhomerun_pkt_seal_frame(struct hdhomerun_pkt_t *pkt, uint16_t frame_type);
65
+extern LIBHDHOMERUN_API int hdhomerun_pkt_open_frame(struct hdhomerun_pkt_t *pkt, uint16_t *ptype);
66
+extern LIBHDHOMERUN_API void hdhomerun_pkt_seal_frame(struct hdhomerun_pkt_t *pkt, uint16_t frame_type);
67
68
#ifdef __cplusplus
69
}
70
libhdhomerun_20150826.tgz/hdhomerun_sock.h -> libhdhomerun_20190621.tgz/hdhomerun_sock.h
Changed
67
1
2
/*
3
* hdhomerun_sock.h
4
*
5
- * Copyright © 2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2010-2016 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
uint32_t subnet_mask;
12
};
13
14
-extern LIBTYPE int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], int max_count);
15
+extern LIBHDHOMERUN_API int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], int max_count);
16
+extern LIBHDHOMERUN_API void hdhomerun_local_ip_info_set_str(const char *ip_info_str); /* WinRT only */
17
18
-#define HDHOMERUN_SOCK_INVALID -1
19
+struct hdhomerun_sock_t;
20
21
-typedef int hdhomerun_sock_t;
22
+extern LIBHDHOMERUN_API struct hdhomerun_sock_t *hdhomerun_sock_create_udp(void);
23
+extern LIBHDHOMERUN_API struct hdhomerun_sock_t *hdhomerun_sock_create_tcp(void);
24
+extern LIBHDHOMERUN_API void hdhomerun_sock_stop(struct hdhomerun_sock_t *sock);
25
+extern LIBHDHOMERUN_API void hdhomerun_sock_destroy(struct hdhomerun_sock_t *sock);
26
27
-extern LIBTYPE hdhomerun_sock_t hdhomerun_sock_create_udp(void);
28
-extern LIBTYPE hdhomerun_sock_t hdhomerun_sock_create_tcp(void);
29
-extern LIBTYPE void hdhomerun_sock_destroy(hdhomerun_sock_t sock);
30
+extern LIBHDHOMERUN_API void hdhomerun_sock_set_send_buffer_size(struct hdhomerun_sock_t *sock, size_t size);
31
+extern LIBHDHOMERUN_API void hdhomerun_sock_set_recv_buffer_size(struct hdhomerun_sock_t *sock, size_t size);
32
+extern LIBHDHOMERUN_API void hdhomerun_sock_set_allow_reuse(struct hdhomerun_sock_t *sock);
33
34
-extern LIBTYPE int hdhomerun_sock_getlasterror(void);
35
-extern LIBTYPE uint32_t hdhomerun_sock_getsockname_addr(hdhomerun_sock_t sock);
36
-extern LIBTYPE uint16_t hdhomerun_sock_getsockname_port(hdhomerun_sock_t sock);
37
-extern LIBTYPE uint32_t hdhomerun_sock_getpeername_addr(hdhomerun_sock_t sock);
38
-extern LIBTYPE uint32_t hdhomerun_sock_getaddrinfo_addr(hdhomerun_sock_t sock, const char *name);
39
+extern LIBHDHOMERUN_API int hdhomerun_sock_getlasterror(void);
40
+extern LIBHDHOMERUN_API uint32_t hdhomerun_sock_getsockname_addr(struct hdhomerun_sock_t *sock);
41
+extern LIBHDHOMERUN_API uint16_t hdhomerun_sock_getsockname_port(struct hdhomerun_sock_t *sock);
42
+extern LIBHDHOMERUN_API uint32_t hdhomerun_sock_getpeername_addr(struct hdhomerun_sock_t *sock);
43
+extern LIBHDHOMERUN_API uint32_t hdhomerun_sock_getaddrinfo_addr(struct hdhomerun_sock_t *sock, const char *name);
44
45
-extern LIBTYPE bool_t hdhomerun_sock_join_multicast_group(hdhomerun_sock_t sock, uint32_t multicast_ip, uint32_t local_ip);
46
-extern LIBTYPE bool_t hdhomerun_sock_leave_multicast_group(hdhomerun_sock_t sock, uint32_t multicast_ip, uint32_t local_ip);
47
+extern LIBHDHOMERUN_API bool hdhomerun_sock_join_multicast_group(struct hdhomerun_sock_t *sock, uint32_t multicast_ip, uint32_t local_ip);
48
+extern LIBHDHOMERUN_API bool hdhomerun_sock_leave_multicast_group(struct hdhomerun_sock_t *sock, uint32_t multicast_ip, uint32_t local_ip);
49
50
-extern LIBTYPE bool_t hdhomerun_sock_bind(hdhomerun_sock_t sock, uint32_t local_addr, uint16_t local_port, bool_t allow_reuse);
51
-extern LIBTYPE bool_t hdhomerun_sock_connect(hdhomerun_sock_t sock, uint32_t remote_addr, uint16_t remote_port, uint64_t timeout);
52
+extern LIBHDHOMERUN_API bool hdhomerun_sock_bind(struct hdhomerun_sock_t *sock, uint32_t local_addr, uint16_t local_port, bool allow_reuse);
53
+extern LIBHDHOMERUN_API bool hdhomerun_sock_connect(struct hdhomerun_sock_t *sock, uint32_t remote_addr, uint16_t remote_port, uint64_t timeout);
54
55
-extern LIBTYPE bool_t hdhomerun_sock_send(hdhomerun_sock_t sock, const void *data, size_t length, uint64_t timeout);
56
-extern LIBTYPE bool_t hdhomerun_sock_sendto(hdhomerun_sock_t sock, uint32_t remote_addr, uint16_t remote_port, const void *data, size_t length, uint64_t timeout);
57
+extern LIBHDHOMERUN_API bool hdhomerun_sock_send(struct hdhomerun_sock_t *sock, const void *data, size_t length, uint64_t timeout);
58
+extern LIBHDHOMERUN_API bool hdhomerun_sock_sendto(struct hdhomerun_sock_t *sock, uint32_t remote_addr, uint16_t remote_port, const void *data, size_t length, uint64_t timeout);
59
60
-extern LIBTYPE bool_t hdhomerun_sock_recv(hdhomerun_sock_t sock, void *data, size_t *length, uint64_t timeout);
61
-extern LIBTYPE bool_t hdhomerun_sock_recvfrom(hdhomerun_sock_t sock, uint32_t *remote_addr, uint16_t *remote_port, void *data, size_t *length, uint64_t timeout);
62
+extern LIBHDHOMERUN_API bool hdhomerun_sock_recv(struct hdhomerun_sock_t *sock, void *data, size_t *length, uint64_t timeout);
63
+extern LIBHDHOMERUN_API bool hdhomerun_sock_recvfrom(struct hdhomerun_sock_t *sock, uint32_t *remote_addr, uint16_t *remote_port, void *data, size_t *length, uint64_t timeout);
64
65
#ifdef __cplusplus
66
}
67
libhdhomerun_20150826.tgz/hdhomerun_sock_posix.c -> libhdhomerun_20190621.tgz/hdhomerun_sock_posix.c
Changed
771
1
2
/*
3
* hdhomerun_sock_posix.c
4
*
5
- * Copyright © 2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2010-2019 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
12
*/
13
14
-/*
15
- * Implementation notes:
16
- *
17
- * API specifies timeout for each operation (or zero for non-blocking).
18
- *
19
- * It is not possible to rely on the OS socket timeout as this will fail to
20
- * detect the command-response situation where data is sent successfully and
21
- * the other end chooses not to send a response (other than the TCP ack).
22
- *
23
- * The select() cannot be used with high socket numbers (typically max 1024)
24
- * so the code works as follows:
25
- * - Use non-blocking sockets to allow operation without select.
26
- * - Use select where safe (low socket numbers).
27
- * - Poll with short sleep when select cannot be used safely.
28
- */
29
-
30
#include "hdhomerun.h"
31
32
-#include <net/if.h>
33
+#if defined(LIBHDHOMERUN_USE_SIOCGIFCONF)
34
#include <sys/ioctl.h>
35
-
36
-#ifndef SIOCGIFCONF
37
-#include <sys/sockio.h>
38
+#else
39
+#include <ifaddrs.h>
40
#endif
41
42
-#ifndef _SIZEOF_ADDR_IFREQ
43
-#define _SIZEOF_ADDR_IFREQ(x) sizeof(x)
44
-#endif
45
+#include <net/if.h>
46
47
#ifndef MSG_NOSIGNAL
48
#define MSG_NOSIGNAL 0
49
#endif
50
51
+struct hdhomerun_sock_t {
52
+ int sock;
53
+};
54
+
55
+#if defined(LIBHDHOMERUN_USE_SIOCGIFCONF)
56
int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], int max_count)
57
{
58
- int sock = socket(AF_INET, SOCK_DGRAM, 0);
59
- if (sock == HDHOMERUN_SOCK_INVALID) {
60
+ int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
61
+ if (sock == -1) {
62
+ return -1;
63
+ }
64
+
65
+ int ifreq_buffer_size = 128 * sizeof(struct ifreq);
66
+ char *ifreq_buffer = (char *)calloc(ifreq_buffer_size, 1);
67
+ if (!ifreq_buffer) {
68
+ close(sock);
69
return -1;
70
}
71
72
struct ifconf ifc;
73
- size_t ifreq_buffer_size = 1024;
74
+ ifc.ifc_len = ifreq_buffer_size;
75
+ ifc.ifc_buf = ifreq_buffer;
76
77
- while (1) {
78
+ if (ioctl(sock, SIOCGIFCONF, &ifc) != 0) {
79
+ free(ifreq_buffer);
80
+ close(sock);
81
+ return -1;
82
+ }
83
+
84
+ if (ifc.ifc_len > ifreq_buffer_size) {
85
ifc.ifc_len = ifreq_buffer_size;
86
- ifc.ifc_buf = (char *)malloc(ifreq_buffer_size);
87
- if (!ifc.ifc_buf) {
88
- close(sock);
89
- return -1;
90
- }
91
-
92
- memset(ifc.ifc_buf, 0, ifreq_buffer_size);
93
-
94
- if (ioctl(sock, SIOCGIFCONF, &ifc) != 0) {
95
- free(ifc.ifc_buf);
96
- close(sock);
97
- return -1;
98
- }
99
-
100
- if (ifc.ifc_len < ifreq_buffer_size) {
101
- break;
102
- }
103
-
104
- free(ifc.ifc_buf);
105
- ifreq_buffer_size += 1024;
106
}
107
108
+ struct hdhomerun_local_ip_info_t *ip_info = ip_info_list;
109
+ int count = 0;
110
+
111
char *ptr = ifc.ifc_buf;
112
char *end = ifc.ifc_buf + ifc.ifc_len;
113
114
- int count = 0;
115
- while (ptr < end) {
116
+ while (ptr + sizeof(struct ifreq) <= end) {
117
struct ifreq *ifr = (struct ifreq *)ptr;
118
- ptr += _SIZEOF_ADDR_IFREQ(*ifr);
119
+ ptr += sizeof(struct ifreq);
120
+
121
+ /* Local IP address. */
122
+ struct sockaddr_in *ip_addr_in = (struct sockaddr_in *)&ifr->ifr_addr;
123
+ uint32_t ip_addr = ntohl(ip_addr_in->sin_addr.s_addr);
124
+ if (ip_addr == 0) {
125
+ continue;
126
+ }
127
128
/* Flags. */
129
if (ioctl(sock, SIOCGIFFLAGS, ifr) != 0) {
130
continue;
131
}
132
133
- if ((ifr->ifr_flags & IFF_UP) == 0) {
134
+ unsigned int flags = ifr->ifr_flags & (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_UP | IFF_RUNNING);
135
+ if (flags != (IFF_UP | IFF_RUNNING)) {
136
continue;
137
}
138
- if ((ifr->ifr_flags & IFF_RUNNING) == 0) {
139
+
140
+ /* Subnet mask. */
141
+ if (ioctl(sock, SIOCGIFNETMASK, ifr) != 0) {
142
continue;
143
}
144
145
- /* Local IP address. */
146
- if (ioctl(sock, SIOCGIFADDR, ifr) != 0) {
147
+ struct sockaddr_in *subnet_mask_in = (struct sockaddr_in *)&ifr->ifr_addr;
148
+ uint32_t subnet_mask = ntohl(subnet_mask_in->sin_addr.s_addr);
149
+
150
+ /* Result. */
151
+ if (count < max_count) {
152
+ ip_info->ip_addr = ip_addr;
153
+ ip_info->subnet_mask = subnet_mask;
154
+ ip_info++;
155
+ }
156
+
157
+ count++;
158
+ }
159
+
160
+ free(ifreq_buffer);
161
+ close(sock);
162
+ return count;
163
+}
164
+#else
165
+int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], int max_count)
166
+{
167
+ struct ifaddrs *ifaddrs;
168
+ if (getifaddrs(&ifaddrs) != 0) {
169
+ return -1;
170
+ }
171
+
172
+ struct hdhomerun_local_ip_info_t *ip_info = ip_info_list;
173
+ struct ifaddrs *ifa = ifaddrs;
174
+ int count = 0;
175
+
176
+ while (ifa) {
177
+ if (ifa->ifa_addr == NULL) {
178
+ ifa = ifa->ifa_next;
179
continue;
180
}
181
182
- struct sockaddr_in *ip_addr_in = (struct sockaddr_in *)&(ifr->ifr_addr);
183
- uint32_t ip_addr = ntohl(ip_addr_in->sin_addr.s_addr);
184
- if (ip_addr == 0) {
185
+ if (ifa->ifa_addr->sa_family != AF_INET) {
186
+ ifa = ifa->ifa_next;
187
continue;
188
}
189
190
- /* Subnet mask. */
191
- if (ioctl(sock, SIOCGIFNETMASK, ifr) != 0) {
192
+ unsigned int flags = ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_UP | IFF_RUNNING);
193
+ if (flags != (IFF_UP | IFF_RUNNING)) {
194
+ ifa = ifa->ifa_next;
195
continue;
196
}
197
198
- struct sockaddr_in *subnet_mask_in = (struct sockaddr_in *)&(ifr->ifr_addr);
199
- uint32_t subnet_mask = ntohl(subnet_mask_in->sin_addr.s_addr);
200
+ struct sockaddr_in *addr_in = (struct sockaddr_in *)ifa->ifa_addr;
201
+ uint32_t ip_addr = ntohl(addr_in->sin_addr.s_addr);
202
+
203
+ struct sockaddr_in *netmask_in = (struct sockaddr_in *)ifa->ifa_netmask;
204
+ uint32_t subnet_mask = ntohl(netmask_in->sin_addr.s_addr);
205
+
206
+ ifa = ifa->ifa_next;
207
208
- /* Report. */
209
if (count < max_count) {
210
- struct hdhomerun_local_ip_info_t *ip_info = &ip_info_list[count];
211
ip_info->ip_addr = ip_addr;
212
ip_info->subnet_mask = subnet_mask;
213
+ ip_info++;
214
}
215
216
count++;
217
}
218
219
- free(ifc.ifc_buf);
220
- close(sock);
221
+ freeifaddrs(ifaddrs);
222
return count;
223
}
224
+#endif
225
226
-hdhomerun_sock_t hdhomerun_sock_create_udp(void)
227
+static struct hdhomerun_sock_t *hdhomerun_sock_create_internal(int protocol)
228
{
229
+ struct hdhomerun_sock_t *sock = (struct hdhomerun_sock_t *)calloc(1, sizeof(struct hdhomerun_sock_t));
230
+ if (!sock) {
231
+ return NULL;
232
+ }
233
+
234
/* Create socket. */
235
- hdhomerun_sock_t sock = (hdhomerun_sock_t)socket(AF_INET, SOCK_DGRAM, 0);
236
- if (sock == -1) {
237
- return HDHOMERUN_SOCK_INVALID;
238
+ sock->sock = socket(AF_INET, protocol, 0);
239
+ if (sock->sock == -1) {
240
+ free(sock);
241
+ return NULL;
242
}
243
244
/* Set non-blocking */
245
- if (fcntl(sock, F_SETFL, O_NONBLOCK) != 0) {
246
- close(sock);
247
- return HDHOMERUN_SOCK_INVALID;
248
+ if (fcntl(sock->sock, F_SETFL, O_NONBLOCK) != 0) {
249
+ hdhomerun_sock_destroy(sock);
250
+ return NULL;
251
}
252
253
- /* Allow broadcast. */
254
- int sock_opt = 1;
255
- setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&sock_opt, sizeof(sock_opt));
256
+ /* Configure socket not to generate pipe-error signal (BSD/OSX). */
257
+#if defined(SO_NOSIGPIPE)
258
+ int set = 1;
259
+ setsockopt(sock->sock, SOL_SOCKET, SO_NOSIGPIPE, (char *)&set, sizeof(set));
260
+#endif
261
262
/* Success. */
263
return sock;
264
}
265
266
-hdhomerun_sock_t hdhomerun_sock_create_tcp(void)
267
+struct hdhomerun_sock_t *hdhomerun_sock_create_udp(void)
268
{
269
- /* Create socket. */
270
- hdhomerun_sock_t sock = (hdhomerun_sock_t)socket(AF_INET, SOCK_STREAM, 0);
271
- if (sock == -1) {
272
- return HDHOMERUN_SOCK_INVALID;
273
+ struct hdhomerun_sock_t *sock = hdhomerun_sock_create_internal(SOCK_DGRAM);
274
+ if (!sock) {
275
+ return NULL;
276
}
277
278
- /* Set non-blocking */
279
- if (fcntl(sock, F_SETFL, O_NONBLOCK) != 0) {
280
- close(sock);
281
- return HDHOMERUN_SOCK_INVALID;
282
- }
283
+ /* Allow broadcast. */
284
+ int sock_opt = 1;
285
+ setsockopt(sock->sock, SOL_SOCKET, SO_BROADCAST, (char *)&sock_opt, sizeof(sock_opt));
286
287
/* Success. */
288
return sock;
289
}
290
291
-void hdhomerun_sock_destroy(hdhomerun_sock_t sock)
292
+struct hdhomerun_sock_t *hdhomerun_sock_create_tcp(void)
293
{
294
- close(sock);
295
+ return hdhomerun_sock_create_internal(SOCK_STREAM);
296
+}
297
+
298
+void hdhomerun_sock_destroy(struct hdhomerun_sock_t *sock)
299
+{
300
+ close(sock->sock);
301
+ free(sock);
302
+}
303
+
304
+void hdhomerun_sock_stop(struct hdhomerun_sock_t *sock)
305
+{
306
+ shutdown(sock->sock, SHUT_RDWR);
307
+}
308
+
309
+void hdhomerun_sock_set_send_buffer_size(struct hdhomerun_sock_t *sock, size_t size)
310
+{
311
+ int size_opt = (int)size;
312
+ setsockopt(sock->sock, SOL_SOCKET, SO_SNDBUF, (char *)&size_opt, sizeof(size_opt));
313
+}
314
+
315
+void hdhomerun_sock_set_recv_buffer_size(struct hdhomerun_sock_t *sock, size_t size)
316
+{
317
+ int size_opt = (int)size;
318
+ setsockopt(sock->sock, SOL_SOCKET, SO_RCVBUF, (char *)&size_opt, sizeof(size_opt));
319
+}
320
+
321
+void hdhomerun_sock_set_allow_reuse(struct hdhomerun_sock_t *sock)
322
+{
323
+ int sock_opt = 1;
324
+ setsockopt(sock->sock, SOL_SOCKET, SO_REUSEADDR, (char *)&sock_opt, sizeof(sock_opt));
325
}
326
327
int hdhomerun_sock_getlasterror(void)
328
329
return errno;
330
}
331
332
-uint32_t hdhomerun_sock_getsockname_addr(hdhomerun_sock_t sock)
333
+uint32_t hdhomerun_sock_getsockname_addr(struct hdhomerun_sock_t *sock)
334
{
335
struct sockaddr_in sock_addr;
336
socklen_t sockaddr_size = sizeof(sock_addr);
337
338
- if (getsockname(sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
339
+ if (getsockname(sock->sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
340
return 0;
341
}
342
343
return ntohl(sock_addr.sin_addr.s_addr);
344
}
345
346
-uint16_t hdhomerun_sock_getsockname_port(hdhomerun_sock_t sock)
347
+uint16_t hdhomerun_sock_getsockname_port(struct hdhomerun_sock_t *sock)
348
{
349
struct sockaddr_in sock_addr;
350
socklen_t sockaddr_size = sizeof(sock_addr);
351
352
- if (getsockname(sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
353
+ if (getsockname(sock->sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
354
return 0;
355
}
356
357
return ntohs(sock_addr.sin_port);
358
}
359
360
-uint32_t hdhomerun_sock_getpeername_addr(hdhomerun_sock_t sock)
361
+uint32_t hdhomerun_sock_getpeername_addr(struct hdhomerun_sock_t *sock)
362
{
363
struct sockaddr_in sock_addr;
364
socklen_t sockaddr_size = sizeof(sock_addr);
365
366
- if (getpeername(sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
367
+ if (getpeername(sock->sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
368
return 0;
369
}
370
371
return ntohl(sock_addr.sin_addr.s_addr);
372
}
373
374
-uint32_t hdhomerun_sock_getaddrinfo_addr(hdhomerun_sock_t sock, const char *name)
375
+uint32_t hdhomerun_sock_getaddrinfo_addr(struct hdhomerun_sock_t *sock, const char *name)
376
{
377
struct addrinfo hints;
378
memset(&hints, 0, sizeof(hints));
379
380
return addr;
381
}
382
383
-bool_t hdhomerun_sock_join_multicast_group(hdhomerun_sock_t sock, uint32_t multicast_ip, uint32_t local_ip)
384
+bool hdhomerun_sock_join_multicast_group(struct hdhomerun_sock_t *sock, uint32_t multicast_ip, uint32_t local_ip)
385
{
386
struct ip_mreq imr;
387
memset(&imr, 0, sizeof(imr));
388
imr.imr_multiaddr.s_addr = htonl(multicast_ip);
389
imr.imr_interface.s_addr = htonl(local_ip);
390
391
- if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
392
- return FALSE;
393
+ if (setsockopt(sock->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
394
+ return false;
395
}
396
397
- return TRUE;
398
+ return true;
399
}
400
401
-bool_t hdhomerun_sock_leave_multicast_group(hdhomerun_sock_t sock, uint32_t multicast_ip, uint32_t local_ip)
402
+bool hdhomerun_sock_leave_multicast_group(struct hdhomerun_sock_t *sock, uint32_t multicast_ip, uint32_t local_ip)
403
{
404
struct ip_mreq imr;
405
memset(&imr, 0, sizeof(imr));
406
imr.imr_multiaddr.s_addr = htonl(multicast_ip);
407
imr.imr_interface.s_addr = htonl(local_ip);
408
409
- if (setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
410
- return FALSE;
411
+ if (setsockopt(sock->sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
412
+ return false;
413
}
414
415
- return TRUE;
416
+ return true;
417
}
418
419
-bool_t hdhomerun_sock_bind(hdhomerun_sock_t sock, uint32_t local_addr, uint16_t local_port, bool_t allow_reuse)
420
+bool hdhomerun_sock_bind(struct hdhomerun_sock_t *sock, uint32_t local_addr, uint16_t local_port, bool allow_reuse)
421
{
422
int sock_opt = allow_reuse;
423
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&sock_opt, sizeof(sock_opt));
424
+ setsockopt(sock->sock, SOL_SOCKET, SO_REUSEADDR, (char *)&sock_opt, sizeof(sock_opt));
425
426
struct sockaddr_in sock_addr;
427
memset(&sock_addr, 0, sizeof(sock_addr));
428
429
sock_addr.sin_addr.s_addr = htonl(local_addr);
430
sock_addr.sin_port = htons(local_port);
431
432
- if (bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
433
- return FALSE;
434
+ if (bind(sock->sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
435
+ return false;
436
}
437
438
- return TRUE;
439
+ return true;
440
}
441
442
-static bool_t hdhomerun_sock_wait_for_event(hdhomerun_sock_t sock, short event_type, uint64_t stop_time)
443
+bool hdhomerun_sock_connect(struct hdhomerun_sock_t *sock, uint32_t remote_addr, uint16_t remote_port, uint64_t timeout)
444
{
445
- uint64_t current_time = getcurrenttime();
446
- if (current_time >= stop_time) {
447
- return FALSE;
448
+ struct sockaddr_in sock_addr;
449
+ memset(&sock_addr, 0, sizeof(sock_addr));
450
+ sock_addr.sin_family = AF_INET;
451
+ sock_addr.sin_addr.s_addr = htonl(remote_addr);
452
+ sock_addr.sin_port = htons(remote_port);
453
+
454
+ if (connect(sock->sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
455
+ if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
456
+ return false;
457
+ }
458
}
459
460
struct pollfd poll_event;
461
- poll_event.fd = sock;
462
- poll_event.events = event_type;
463
+ poll_event.fd = sock->sock;
464
+ poll_event.events = POLLOUT;
465
poll_event.revents = 0;
466
467
- uint64_t timeout = stop_time - current_time;
468
-
469
if (poll(&poll_event, 1, (int)timeout) <= 0) {
470
- return FALSE;
471
+ return false;
472
}
473
474
- if ((poll_event.revents & event_type) == 0) {
475
- return FALSE;
476
+ if ((poll_event.revents & POLLOUT) == 0) {
477
+ return false;
478
}
479
480
- return TRUE;
481
+ return true;
482
}
483
484
-bool_t hdhomerun_sock_connect(hdhomerun_sock_t sock, uint32_t remote_addr, uint16_t remote_port, uint64_t timeout)
485
+bool hdhomerun_sock_send(struct hdhomerun_sock_t *sock, const void *data, size_t length, uint64_t timeout)
486
{
487
- struct sockaddr_in sock_addr;
488
- memset(&sock_addr, 0, sizeof(sock_addr));
489
- sock_addr.sin_family = AF_INET;
490
- sock_addr.sin_addr.s_addr = htonl(remote_addr);
491
- sock_addr.sin_port = htons(remote_port);
492
+ const uint8_t *ptr = (const uint8_t *)data;
493
+ ssize_t ret = send(sock->sock, ptr, length, MSG_NOSIGNAL);
494
+ if (ret >= (ssize_t)length) {
495
+ return true;
496
+ }
497
498
- if (connect(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
499
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
500
- return FALSE;
501
- }
502
+ if ((ret < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
503
+ return false;
504
}
505
506
- uint64_t stop_time = getcurrenttime() + timeout;
507
- return hdhomerun_sock_wait_for_event(sock, POLLOUT, stop_time);
508
-}
509
+ if (ret > 0) {
510
+ ptr += ret;
511
+ length -= ret;
512
+ }
513
514
-bool_t hdhomerun_sock_send(hdhomerun_sock_t sock, const void *data, size_t length, uint64_t timeout)
515
-{
516
uint64_t stop_time = getcurrenttime() + timeout;
517
- const uint8_t *ptr = (const uint8_t *)data;
518
519
while (1) {
520
- int ret = send(sock, ptr, length, MSG_NOSIGNAL);
521
- if (ret <= 0) {
522
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
523
- return FALSE;
524
- }
525
- if (!hdhomerun_sock_wait_for_event(sock, POLLOUT, stop_time)) {
526
- return FALSE;
527
- }
528
- continue;
529
+ struct pollfd poll_event;
530
+ poll_event.fd = sock->sock;
531
+ poll_event.events = POLLOUT;
532
+ poll_event.revents = 0;
533
+
534
+ if (poll(&poll_event, 1, (int)timeout) <= 0) {
535
+ return false;
536
+ }
537
+
538
+ if ((poll_event.revents & POLLOUT) == 0) {
539
+ return false;
540
+ }
541
+
542
+ ret = send(sock->sock, ptr, length, MSG_NOSIGNAL);
543
+ if (ret >= (ssize_t)length) {
544
+ return true;
545
+ }
546
+
547
+ if ((ret < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
548
+ return false;
549
}
550
551
- if (ret < (int)length) {
552
+ if (ret > 0) {
553
ptr += ret;
554
length -= ret;
555
- continue;
556
}
557
558
- return TRUE;
559
+ uint64_t current_time = getcurrenttime();
560
+ if (current_time >= stop_time) {
561
+ return false;
562
+ }
563
+
564
+ timeout = stop_time - current_time;
565
}
566
}
567
568
-bool_t hdhomerun_sock_sendto(hdhomerun_sock_t sock, uint32_t remote_addr, uint16_t remote_port, const void *data, size_t length, uint64_t timeout)
569
+bool hdhomerun_sock_sendto(struct hdhomerun_sock_t *sock, uint32_t remote_addr, uint16_t remote_port, const void *data, size_t length, uint64_t timeout)
570
{
571
- uint64_t stop_time = getcurrenttime() + timeout;
572
+ struct sockaddr_in sock_addr;
573
+ memset(&sock_addr, 0, sizeof(sock_addr));
574
+ sock_addr.sin_family = AF_INET;
575
+ sock_addr.sin_addr.s_addr = htonl(remote_addr);
576
+ sock_addr.sin_port = htons(remote_port);
577
+
578
const uint8_t *ptr = (const uint8_t *)data;
579
+ ssize_t ret = sendto(sock->sock, ptr, length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
580
+ if (ret >= (ssize_t)length) {
581
+ return true;
582
+ }
583
+
584
+ if ((ret < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
585
+ return false;
586
+ }
587
+
588
+ if (ret > 0) {
589
+ ptr += ret;
590
+ length -= ret;
591
+ }
592
+
593
+ uint64_t stop_time = getcurrenttime() + timeout;
594
595
while (1) {
596
- struct sockaddr_in sock_addr;
597
- memset(&sock_addr, 0, sizeof(sock_addr));
598
- sock_addr.sin_family = AF_INET;
599
- sock_addr.sin_addr.s_addr = htonl(remote_addr);
600
- sock_addr.sin_port = htons(remote_port);
601
-
602
- int ret = sendto(sock, ptr, length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
603
- if (ret <= 0) {
604
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
605
- return FALSE;
606
- }
607
- if (!hdhomerun_sock_wait_for_event(sock, POLLOUT, stop_time)) {
608
- return FALSE;
609
- }
610
- continue;
611
+ struct pollfd poll_event;
612
+ poll_event.fd = sock->sock;
613
+ poll_event.events = POLLOUT;
614
+ poll_event.revents = 0;
615
+
616
+ if (poll(&poll_event, 1, (int)timeout) <= 0) {
617
+ return false;
618
+ }
619
+
620
+ if ((poll_event.revents & POLLOUT) == 0) {
621
+ return false;
622
}
623
624
- if (ret < (int)length) {
625
+ ret = sendto(sock->sock, ptr, length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
626
+ if (ret >= (ssize_t)length) {
627
+ return true;
628
+ }
629
+
630
+ if ((ret < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
631
+ return false;
632
+ }
633
+
634
+ if (ret > 0) {
635
ptr += ret;
636
length -= ret;
637
- continue;
638
}
639
640
- return TRUE;
641
+ uint64_t current_time = getcurrenttime();
642
+ if (current_time >= stop_time) {
643
+ return false;
644
+ }
645
+
646
+ timeout = stop_time - current_time;
647
}
648
}
649
650
-bool_t hdhomerun_sock_recv(hdhomerun_sock_t sock, void *data, size_t *length, uint64_t timeout)
651
+bool hdhomerun_sock_recv(struct hdhomerun_sock_t *sock, void *data, size_t *length, uint64_t timeout)
652
{
653
- uint64_t stop_time = getcurrenttime() + timeout;
654
+ ssize_t ret = recv(sock->sock, data, *length, 0);
655
+ if (ret > 0) {
656
+ *length = (size_t)ret;
657
+ return true;
658
+ }
659
660
- while (1) {
661
- int ret = recv(sock, data, *length, 0);
662
- if (ret < 0) {
663
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
664
- return FALSE;
665
- }
666
- if (!hdhomerun_sock_wait_for_event(sock, POLLIN, stop_time)) {
667
- return FALSE;
668
- }
669
- continue;
670
- }
671
+ if (ret == 0) {
672
+ return false;
673
+ }
674
+ if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
675
+ return false;
676
+ }
677
678
- if (ret == 0) {
679
- return FALSE;
680
- }
681
+ struct pollfd poll_event;
682
+ poll_event.fd = sock->sock;
683
+ poll_event.events = POLLIN;
684
+ poll_event.revents = 0;
685
+
686
+ if (poll(&poll_event, 1, (int)timeout) <= 0) {
687
+ return false;
688
+ }
689
690
- *length = ret;
691
- return TRUE;
692
+ if ((poll_event.revents & POLLIN) == 0) {
693
+ return false;
694
}
695
+
696
+ ret = recv(sock->sock, data, *length, 0);
697
+ if (ret > 0) {
698
+ *length = (size_t)ret;
699
+ return true;
700
+ }
701
+
702
+ return false;
703
}
704
705
-bool_t hdhomerun_sock_recvfrom(hdhomerun_sock_t sock, uint32_t *remote_addr, uint16_t *remote_port, void *data, size_t *length, uint64_t timeout)
706
+bool hdhomerun_sock_recvfrom(struct hdhomerun_sock_t *sock, uint32_t *remote_addr, uint16_t *remote_port, void *data, size_t *length, uint64_t timeout)
707
{
708
- uint64_t stop_time = getcurrenttime() + timeout;
709
+ struct sockaddr_in sock_addr;
710
+ memset(&sock_addr, 0, sizeof(sock_addr));
711
+ socklen_t sockaddr_size = sizeof(sock_addr);
712
713
- while (1) {
714
- struct sockaddr_in sock_addr;
715
- memset(&sock_addr, 0, sizeof(sock_addr));
716
- socklen_t sockaddr_size = sizeof(sock_addr);
717
-
718
- int ret = recvfrom(sock, data, *length, 0, (struct sockaddr *)&sock_addr, &sockaddr_size);
719
- if (ret < 0) {
720
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
721
- return FALSE;
722
- }
723
- if (!hdhomerun_sock_wait_for_event(sock, POLLIN, stop_time)) {
724
- return FALSE;
725
- }
726
- continue;
727
- }
728
+ ssize_t ret = recvfrom(sock->sock, data, *length, 0, (struct sockaddr *)&sock_addr, &sockaddr_size);
729
+ if (ret > 0) {
730
+ *remote_addr = ntohl(sock_addr.sin_addr.s_addr);
731
+ *remote_port = ntohs(sock_addr.sin_port);
732
+ *length = (size_t)ret;
733
+ return true;
734
+ }
735
736
- if (ret == 0) {
737
- return FALSE;
738
- }
739
+ if (ret == 0) {
740
+ return false;
741
+ }
742
+ if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINPROGRESS)) {
743
+ return false;
744
+ }
745
+
746
+ struct pollfd poll_event;
747
+ poll_event.fd = sock->sock;
748
+ poll_event.events = POLLIN;
749
+ poll_event.revents = 0;
750
751
+ if (poll(&poll_event, 1, (int)timeout) <= 0) {
752
+ return false;
753
+ }
754
+
755
+ if ((poll_event.revents & POLLIN) == 0) {
756
+ return false;
757
+ }
758
+
759
+ ret = recvfrom(sock->sock, data, *length, 0, (struct sockaddr *)&sock_addr, &sockaddr_size);
760
+ if (ret > 0) {
761
*remote_addr = ntohl(sock_addr.sin_addr.s_addr);
762
*remote_port = ntohs(sock_addr.sin_port);
763
- *length = ret;
764
- return TRUE;
765
+ *length = (size_t)ret;
766
+ return true;
767
}
768
+
769
+ return false;
770
}
771
libhdhomerun_20150826.tgz/hdhomerun_sock_windows.c -> libhdhomerun_20190621.tgz/hdhomerun_sock_windows.c
Changed
649
1
2
/*
3
* hdhomerun_sock_windows.c
4
*
5
- * Copyright © 2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2010-2016 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
12
*/
13
14
+#include "hdhomerun.h"
15
+#include <iphlpapi.h>
16
+
17
+struct hdhomerun_sock_t {
18
+ SOCKET sock;
19
+ HANDLE event;
20
+ long events_selected;
21
+};
22
+
23
+#if defined(_WINRT)
24
+static char *hdhomerun_local_ip_info_str = NULL;
25
+
26
/*
27
- * Implementation notes:
28
- *
29
- * API specifies timeout for each operation (or zero for non-blocking).
30
- *
31
- * It is not possible to rely on the OS socket timeout as this will fail to
32
- * detect the command-response situation where data is sent successfully and
33
- * the other end chooses not to send a response (other than the TCP ack).
34
- *
35
- * Windows supports select() however native WSA events are used to:
36
- * - avoid problems with socket numbers above 1024.
37
- * - wait without allowing other events handlers to run (important for use
38
- * with win7 WMC).
39
+ * String format: ip address '/' subnet mask bits <space> ...
40
+ * Example: "192.168.0.100/24 169.254.0.100/16"
41
*/
42
+void hdhomerun_local_ip_info_set_str(const char *ip_info_str)
43
+{
44
+ if (hdhomerun_local_ip_info_str) {
45
+ free(hdhomerun_local_ip_info_str);
46
+ }
47
48
-#include "hdhomerun.h"
49
-#include <windows.h>
50
-#include <iphlpapi.h>
51
+ hdhomerun_local_ip_info_str = strdup(ip_info_str);
52
+}
53
+
54
+int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], int max_count)
55
+{
56
+ const char *ptr = hdhomerun_local_ip_info_str;
57
+ if (!ptr) {
58
+ return 0;
59
+ }
60
+
61
+ struct hdhomerun_local_ip_info_t *ip_info = ip_info_list;
62
+ int count = 0;
63
+
64
+ while (count < max_count) {
65
+ unsigned int a[4];
66
+ unsigned int mask_bitcount;
67
+ if (sscanf(ptr, "%u.%u.%u.%u/%u", &a[0], &a[1], &a[2], &a[3], &mask_bitcount) != 5) {
68
+ break;
69
+ }
70
+
71
+ ip_info->ip_addr = (uint32_t)((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | (a[3] << 0));
72
+ ip_info->subnet_mask = 0xFFFFFFFF << (32 - mask_bitcount);
73
+ ip_info++;
74
75
+ count++;
76
+
77
+ ptr = strchr(ptr, ' ');
78
+ if (!ptr) {
79
+ break;
80
+ }
81
+
82
+ ptr++;
83
+ }
84
+
85
+ return count;
86
+}
87
+#endif
88
+
89
+#if !defined(_WINRT)
90
int hdhomerun_local_ip_info(struct hdhomerun_local_ip_info_t ip_info_list[], int max_count)
91
{
92
PIP_ADAPTER_INFO AdapterInfo;
93
94
free(AdapterInfo);
95
return count;
96
}
97
+#endif
98
99
-hdhomerun_sock_t hdhomerun_sock_create_udp(void)
100
+static struct hdhomerun_sock_t *hdhomerun_sock_create_internal(int protocol)
101
{
102
+ struct hdhomerun_sock_t *sock = (struct hdhomerun_sock_t *)calloc(1, sizeof(struct hdhomerun_sock_t));
103
+ if (!sock) {
104
+ return NULL;
105
+ }
106
+
107
/* Create socket. */
108
- hdhomerun_sock_t sock = (hdhomerun_sock_t)socket(AF_INET, SOCK_DGRAM, 0);
109
- if (sock == -1) {
110
- return HDHOMERUN_SOCK_INVALID;
111
+ sock->sock = socket(AF_INET, protocol, 0);
112
+ if (sock->sock == INVALID_SOCKET) {
113
+ free(sock);
114
+ return NULL;
115
}
116
117
/* Set non-blocking */
118
unsigned long mode = 1;
119
- if (ioctlsocket(sock, FIONBIO, &mode) != 0) {
120
- closesocket(sock);
121
- return HDHOMERUN_SOCK_INVALID;
122
+ if (ioctlsocket(sock->sock, FIONBIO, &mode) != 0) {
123
+ hdhomerun_sock_destroy(sock);
124
+ return NULL;
125
}
126
127
- /* Allow broadcast. */
128
- int sock_opt = 1;
129
- setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&sock_opt, sizeof(sock_opt));
130
+ /* Event */
131
+ sock->event = CreateEvent(NULL, false, false, NULL);
132
+ if (!sock->event) {
133
+ hdhomerun_sock_destroy(sock);
134
+ return NULL;
135
+ }
136
137
/* Success. */
138
return sock;
139
}
140
141
-hdhomerun_sock_t hdhomerun_sock_create_tcp(void)
142
+struct hdhomerun_sock_t *hdhomerun_sock_create_udp(void)
143
{
144
- /* Create socket. */
145
- hdhomerun_sock_t sock = (hdhomerun_sock_t)socket(AF_INET, SOCK_STREAM, 0);
146
- if (sock == -1) {
147
- return HDHOMERUN_SOCK_INVALID;
148
+ struct hdhomerun_sock_t *sock = hdhomerun_sock_create_internal(SOCK_DGRAM);
149
+ if (!sock) {
150
+ return NULL;
151
}
152
153
- /* Set non-blocking */
154
- unsigned long mode = 1;
155
- if (ioctlsocket(sock, FIONBIO, &mode) != 0) {
156
- closesocket(sock);
157
- return HDHOMERUN_SOCK_INVALID;
158
- }
159
+ /* Allow broadcast. */
160
+ int sock_opt = 1;
161
+ setsockopt(sock->sock, SOL_SOCKET, SO_BROADCAST, (char *)&sock_opt, sizeof(sock_opt));
162
163
/* Success. */
164
return sock;
165
}
166
167
-void hdhomerun_sock_destroy(hdhomerun_sock_t sock)
168
+struct hdhomerun_sock_t *hdhomerun_sock_create_tcp(void)
169
{
170
- closesocket(sock);
171
+ return hdhomerun_sock_create_internal(SOCK_STREAM);
172
+}
173
+
174
+void hdhomerun_sock_destroy(struct hdhomerun_sock_t *sock)
175
+{
176
+ if (sock->event) {
177
+ CloseHandle(sock->event);
178
+ }
179
+
180
+ closesocket(sock->sock);
181
+ free(sock);
182
+}
183
+
184
+void hdhomerun_sock_stop(struct hdhomerun_sock_t *sock)
185
+{
186
+ shutdown(sock->sock, SD_BOTH);
187
+}
188
+
189
+void hdhomerun_sock_set_send_buffer_size(struct hdhomerun_sock_t *sock, size_t size)
190
+{
191
+ int size_opt = (int)size;
192
+ setsockopt(sock->sock, SOL_SOCKET, SO_SNDBUF, (char *)&size_opt, sizeof(size_opt));
193
+}
194
+
195
+void hdhomerun_sock_set_recv_buffer_size(struct hdhomerun_sock_t *sock, size_t size)
196
+{
197
+ int size_opt = (int)size;
198
+ setsockopt(sock->sock, SOL_SOCKET, SO_RCVBUF, (char *)&size_opt, sizeof(size_opt));
199
+}
200
+
201
+void hdhomerun_sock_set_allow_reuse(struct hdhomerun_sock_t *sock)
202
+{
203
+ int sock_opt = 1;
204
+ setsockopt(sock->sock, SOL_SOCKET, SO_REUSEADDR, (char *)&sock_opt, sizeof(sock_opt));
205
}
206
207
int hdhomerun_sock_getlasterror(void)
208
209
return WSAGetLastError();
210
}
211
212
-uint32_t hdhomerun_sock_getsockname_addr(hdhomerun_sock_t sock)
213
+uint32_t hdhomerun_sock_getsockname_addr(struct hdhomerun_sock_t *sock)
214
{
215
struct sockaddr_in sock_addr;
216
int sockaddr_size = sizeof(sock_addr);
217
218
- if (getsockname(sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
219
+ if (getsockname(sock->sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
220
return 0;
221
}
222
223
return ntohl(sock_addr.sin_addr.s_addr);
224
}
225
226
-uint16_t hdhomerun_sock_getsockname_port(hdhomerun_sock_t sock)
227
+uint16_t hdhomerun_sock_getsockname_port(struct hdhomerun_sock_t *sock)
228
{
229
struct sockaddr_in sock_addr;
230
int sockaddr_size = sizeof(sock_addr);
231
232
- if (getsockname(sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
233
+ if (getsockname(sock->sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
234
return 0;
235
}
236
237
return ntohs(sock_addr.sin_port);
238
}
239
240
-uint32_t hdhomerun_sock_getpeername_addr(hdhomerun_sock_t sock)
241
+uint32_t hdhomerun_sock_getpeername_addr(struct hdhomerun_sock_t *sock)
242
{
243
struct sockaddr_in sock_addr;
244
int sockaddr_size = sizeof(sock_addr);
245
246
- if (getpeername(sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
247
+ if (getpeername(sock->sock, (struct sockaddr *)&sock_addr, &sockaddr_size) != 0) {
248
return 0;
249
}
250
251
return ntohl(sock_addr.sin_addr.s_addr);
252
}
253
254
-uint32_t hdhomerun_sock_getaddrinfo_addr(hdhomerun_sock_t sock, const char *name)
255
+uint32_t hdhomerun_sock_getaddrinfo_addr(struct hdhomerun_sock_t *sock, const char *name)
256
{
257
struct addrinfo hints;
258
memset(&hints, 0, sizeof(hints));
259
260
return addr;
261
}
262
263
-bool_t hdhomerun_sock_join_multicast_group(hdhomerun_sock_t sock, uint32_t multicast_ip, uint32_t local_ip)
264
+bool hdhomerun_sock_join_multicast_group(struct hdhomerun_sock_t *sock, uint32_t multicast_ip, uint32_t local_ip)
265
{
266
struct ip_mreq imr;
267
memset(&imr, 0, sizeof(imr));
268
imr.imr_multiaddr.s_addr = htonl(multicast_ip);
269
imr.imr_interface.s_addr = htonl(local_ip);
270
271
- if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
272
- return FALSE;
273
+ if (setsockopt(sock->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
274
+ return false;
275
}
276
277
- return TRUE;
278
+ return true;
279
}
280
281
-bool_t hdhomerun_sock_leave_multicast_group(hdhomerun_sock_t sock, uint32_t multicast_ip, uint32_t local_ip)
282
+bool hdhomerun_sock_leave_multicast_group(struct hdhomerun_sock_t *sock, uint32_t multicast_ip, uint32_t local_ip)
283
{
284
struct ip_mreq imr;
285
memset(&imr, 0, sizeof(imr));
286
imr.imr_multiaddr.s_addr = htonl(multicast_ip);
287
imr.imr_interface.s_addr = htonl(local_ip);
288
289
- if (setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
290
- return FALSE;
291
+ if (setsockopt(sock->sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const char *)&imr, sizeof(imr)) != 0) {
292
+ return false;
293
}
294
295
- return TRUE;
296
+ return true;
297
}
298
299
-bool_t hdhomerun_sock_bind(hdhomerun_sock_t sock, uint32_t local_addr, uint16_t local_port, bool_t allow_reuse)
300
+bool hdhomerun_sock_bind(struct hdhomerun_sock_t *sock, uint32_t local_addr, uint16_t local_port, bool allow_reuse)
301
{
302
int sock_opt = allow_reuse;
303
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&sock_opt, sizeof(sock_opt));
304
+ setsockopt(sock->sock, SOL_SOCKET, SO_REUSEADDR, (char *)&sock_opt, sizeof(sock_opt));
305
306
struct sockaddr_in sock_addr;
307
memset(&sock_addr, 0, sizeof(sock_addr));
308
309
sock_addr.sin_addr.s_addr = htonl(local_addr);
310
sock_addr.sin_port = htons(local_port);
311
312
- if (bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
313
- return FALSE;
314
+ if (bind(sock->sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
315
+ return false;
316
+ }
317
+
318
+ return true;
319
+}
320
+
321
+static bool hdhomerun_sock_event_select(struct hdhomerun_sock_t *sock, long events)
322
+{
323
+ if (sock->events_selected != events) {
324
+ if (WSAEventSelect(sock->sock, sock->event, events) == SOCKET_ERROR) {
325
+ return false;
326
+ }
327
+ sock->events_selected = events;
328
}
329
330
- return TRUE;
331
+ ResetEvent(sock->event);
332
+ return true;
333
}
334
335
-bool_t hdhomerun_sock_connect(hdhomerun_sock_t sock, uint32_t remote_addr, uint16_t remote_port, uint64_t timeout)
336
+bool hdhomerun_sock_connect(struct hdhomerun_sock_t *sock, uint32_t remote_addr, uint16_t remote_port, uint64_t timeout)
337
{
338
- /* Connect (non-blocking). */
339
+ if (!hdhomerun_sock_event_select(sock, FD_WRITE | FD_CLOSE)) {
340
+ return false;
341
+ }
342
+
343
struct sockaddr_in sock_addr;
344
memset(&sock_addr, 0, sizeof(sock_addr));
345
sock_addr.sin_family = AF_INET;
346
sock_addr.sin_addr.s_addr = htonl(remote_addr);
347
sock_addr.sin_port = htons(remote_port);
348
349
- if (connect(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
350
+ if (connect(sock->sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) {
351
if (WSAGetLastError() != WSAEWOULDBLOCK) {
352
- return FALSE;
353
+ return false;
354
}
355
}
356
357
- /* Wait for connect to complete (both success and failure will signal). */
358
- WSAEVENT wsa_event = WSACreateEvent();
359
- if (wsa_event == WSA_INVALID_EVENT) {
360
- return FALSE;
361
+ DWORD wait_ret = WaitForSingleObjectEx(sock->event, (DWORD)timeout, false);
362
+ if (wait_ret != WAIT_OBJECT_0) {
363
+ return false;
364
}
365
366
- if (WSAEventSelect(sock, wsa_event, FD_WRITE | FD_CLOSE) == SOCKET_ERROR) {
367
- WSACloseEvent(wsa_event);
368
- return FALSE;
369
+ WSANETWORKEVENTS network_events;
370
+ if (WSAEnumNetworkEvents(sock->sock, sock->event, &network_events) == SOCKET_ERROR) {
371
+ return false;
372
}
373
-
374
- DWORD ret = WaitForSingleObjectEx(wsa_event, (DWORD)timeout, FALSE);
375
- WSACloseEvent(wsa_event);
376
- if (ret != WAIT_OBJECT_0) {
377
- return FALSE;
378
+ if ((network_events.lNetworkEvents & FD_WRITE) == 0) {
379
+ return false;
380
}
381
-
382
- /* Detect success/failure. */
383
- wsa_event = WSACreateEvent();
384
- if (wsa_event == WSA_INVALID_EVENT) {
385
- return FALSE;
386
- }
387
-
388
- if (WSAEventSelect(sock, wsa_event, FD_CLOSE) == SOCKET_ERROR) {
389
- WSACloseEvent(wsa_event);
390
- return FALSE;
391
+ if (network_events.lNetworkEvents & FD_CLOSE) {
392
+ return false;
393
}
394
395
- ret = WaitForSingleObjectEx(wsa_event, 0, FALSE);
396
- WSACloseEvent(wsa_event);
397
- if (ret == WAIT_OBJECT_0) {
398
- return FALSE;
399
- }
400
-
401
- return TRUE;
402
+ return true;
403
}
404
405
-static bool_t hdhomerun_sock_wait_for_event(hdhomerun_sock_t sock, long event_type, uint64_t stop_time)
406
+bool hdhomerun_sock_send(struct hdhomerun_sock_t *sock, const void *data, size_t length, uint64_t timeout)
407
{
408
- uint64_t current_time = getcurrenttime();
409
- if (current_time >= stop_time) {
410
- return FALSE;
411
- }
412
-
413
- WSAEVENT wsa_event = WSACreateEvent();
414
- if (wsa_event == WSA_INVALID_EVENT) {
415
- return FALSE;
416
- }
417
-
418
- if (WSAEventSelect(sock, wsa_event, event_type) == SOCKET_ERROR) {
419
- WSACloseEvent(wsa_event);
420
- return FALSE;
421
+ if (!hdhomerun_sock_event_select(sock, FD_WRITE | FD_CLOSE)) {
422
+ return false;
423
}
424
425
- DWORD ret = WaitForSingleObjectEx(wsa_event, (DWORD)(stop_time - current_time), FALSE);
426
- WSACloseEvent(wsa_event);
427
-
428
- if (ret != WAIT_OBJECT_0) {
429
- return FALSE;
430
- }
431
-
432
- return TRUE;
433
-}
434
-
435
-bool_t hdhomerun_sock_send(hdhomerun_sock_t sock, const void *data, size_t length, uint64_t timeout)
436
-{
437
uint64_t stop_time = getcurrenttime() + timeout;
438
const uint8_t *ptr = (uint8_t *)data;
439
440
while (1) {
441
- int ret = send(sock, (char *)ptr, (int)length, 0);
442
- if (ret <= 0) {
443
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
444
- return FALSE;
445
- }
446
- if (!hdhomerun_sock_wait_for_event(sock, FD_WRITE | FD_CLOSE, stop_time)) {
447
- return FALSE;
448
- }
449
- continue;
450
+ int ret = send(sock->sock, (char *)ptr, (int)length, 0);
451
+ if (ret >= (int)length) {
452
+ return true;
453
+ }
454
+
455
+ if ((ret == SOCKET_ERROR) && (WSAGetLastError() != WSAEWOULDBLOCK)) {
456
+ return false;
457
}
458
459
- if (ret < (int)length) {
460
+ if (ret > 0) {
461
ptr += ret;
462
length -= ret;
463
- continue;
464
}
465
466
- return TRUE;
467
+ uint64_t current_time = getcurrenttime();
468
+ if (current_time >= stop_time) {
469
+ return false;
470
+ }
471
+
472
+ if (WaitForSingleObjectEx(sock->event, (DWORD)(stop_time - current_time), false) != WAIT_OBJECT_0) {
473
+ return false;
474
+ }
475
}
476
}
477
478
-bool_t hdhomerun_sock_sendto(hdhomerun_sock_t sock, uint32_t remote_addr, uint16_t remote_port, const void *data, size_t length, uint64_t timeout)
479
+bool hdhomerun_sock_sendto(struct hdhomerun_sock_t *sock, uint32_t remote_addr, uint16_t remote_port, const void *data, size_t length, uint64_t timeout)
480
{
481
- uint64_t stop_time = getcurrenttime() + timeout;
482
- const uint8_t *ptr = (uint8_t *)data;
483
+ if (!hdhomerun_sock_event_select(sock, FD_WRITE | FD_CLOSE)) {
484
+ return false;
485
+ }
486
487
- while (1) {
488
- struct sockaddr_in sock_addr;
489
- memset(&sock_addr, 0, sizeof(sock_addr));
490
- sock_addr.sin_family = AF_INET;
491
- sock_addr.sin_addr.s_addr = htonl(remote_addr);
492
- sock_addr.sin_port = htons(remote_port);
493
-
494
- int ret = sendto(sock, (char *)ptr, (int)length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
495
- if (ret <= 0) {
496
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
497
- return FALSE;
498
- }
499
- if (!hdhomerun_sock_wait_for_event(sock, FD_WRITE | FD_CLOSE, stop_time)) {
500
- return FALSE;
501
- }
502
- continue;
503
- }
504
+ struct sockaddr_in sock_addr;
505
+ memset(&sock_addr, 0, sizeof(sock_addr));
506
+ sock_addr.sin_family = AF_INET;
507
+ sock_addr.sin_addr.s_addr = htonl(remote_addr);
508
+ sock_addr.sin_port = htons(remote_port);
509
510
- if (ret < (int)length) {
511
- ptr += ret;
512
- length -= ret;
513
- continue;
514
- }
515
+ int ret = sendto(sock->sock, (char *)data, (int)length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
516
+ if (ret >= (int)length) {
517
+ return true;
518
+ }
519
+
520
+ if (ret >= 0) {
521
+ return false;
522
+ }
523
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
524
+ return false;
525
+ }
526
527
- return TRUE;
528
+ if (WaitForSingleObjectEx(sock->event, (DWORD)timeout, false) != WAIT_OBJECT_0) {
529
+ return false;
530
}
531
+
532
+ ret = sendto(sock->sock, (char *)data, (int)length, 0, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
533
+ if (ret >= (int)length) {
534
+ return true;
535
+ }
536
+
537
+ return false;
538
}
539
540
-bool_t hdhomerun_sock_recv(hdhomerun_sock_t sock, void *data, size_t *length, uint64_t timeout)
541
+bool hdhomerun_sock_recv(struct hdhomerun_sock_t *sock, void *data, size_t *length, uint64_t timeout)
542
{
543
- uint64_t stop_time = getcurrenttime() + timeout;
544
+ if (!hdhomerun_sock_event_select(sock, FD_READ | FD_CLOSE)) {
545
+ return false;
546
+ }
547
548
- while (1) {
549
- int ret = recv(sock, (char *)data, (int)(*length), 0);
550
- if (ret < 0) {
551
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
552
- return FALSE;
553
- }
554
- if (!hdhomerun_sock_wait_for_event(sock, FD_READ | FD_CLOSE, stop_time)) {
555
- return FALSE;
556
- }
557
- continue;
558
- }
559
+ int ret = recv(sock->sock, (char *)data, (int)(*length), 0);
560
+ if (ret > 0) {
561
+ *length = ret;
562
+ return true;
563
+ }
564
565
- if (ret == 0) {
566
- return FALSE;
567
- }
568
+ if (ret == 0) {
569
+ return false;
570
+ }
571
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
572
+ return false;
573
+ }
574
575
+ if (WaitForSingleObjectEx(sock->event, (DWORD)timeout, false) != WAIT_OBJECT_0) {
576
+ return false;
577
+ }
578
+
579
+ ret = recv(sock->sock, (char *)data, (int)(*length), 0);
580
+ if (ret > 0) {
581
*length = ret;
582
- return TRUE;
583
+ return true;
584
}
585
+
586
+ return false;
587
}
588
589
-bool_t hdhomerun_sock_recvfrom(hdhomerun_sock_t sock, uint32_t *remote_addr, uint16_t *remote_port, void *data, size_t *length, uint64_t timeout)
590
+bool hdhomerun_sock_recvfrom(struct hdhomerun_sock_t *sock, uint32_t *remote_addr, uint16_t *remote_port, void *data, size_t *length, uint64_t timeout)
591
{
592
- uint64_t stop_time = getcurrenttime() + timeout;
593
+ if (!hdhomerun_sock_event_select(sock, FD_READ | FD_CLOSE)) {
594
+ return false;
595
+ }
596
597
- while (1) {
598
- struct sockaddr_in sock_addr;
599
- memset(&sock_addr, 0, sizeof(sock_addr));
600
- int sockaddr_size = sizeof(sock_addr);
601
-
602
- int ret = recvfrom(sock, (char *)data, (int)(*length), 0, (struct sockaddr *)&sock_addr, &sockaddr_size);
603
- if (ret < 0) {
604
- if (WSAGetLastError() != WSAEWOULDBLOCK) {
605
- return FALSE;
606
- }
607
- if (!hdhomerun_sock_wait_for_event(sock, FD_READ | FD_CLOSE, stop_time)) {
608
- return FALSE;
609
- }
610
- continue;
611
- }
612
+ struct sockaddr_in sock_addr;
613
+ memset(&sock_addr, 0, sizeof(sock_addr));
614
+ int sockaddr_size = sizeof(sock_addr);
615
616
- if (ret == 0) {
617
- return FALSE;
618
- }
619
+ int ret = recvfrom(sock->sock, (char *)data, (int)(*length), 0, (struct sockaddr *)&sock_addr, &sockaddr_size);
620
+ if (ret > 0) {
621
+ *remote_addr = ntohl(sock_addr.sin_addr.s_addr);
622
+ *remote_port = ntohs(sock_addr.sin_port);
623
+ *length = ret;
624
+ return true;
625
+ }
626
627
+ if (ret == 0) {
628
+ return false;
629
+ }
630
+ if (WSAGetLastError() != WSAEWOULDBLOCK) {
631
+ return false;
632
+ }
633
+
634
+ if (WaitForSingleObjectEx(sock->event, (DWORD)timeout, false) != WAIT_OBJECT_0) {
635
+ return false;
636
+ }
637
+
638
+ ret = recvfrom(sock->sock, (char *)data, (int)(*length), 0, (struct sockaddr *)&sock_addr, &sockaddr_size);
639
+ if (ret > 0) {
640
*remote_addr = ntohl(sock_addr.sin_addr.s_addr);
641
*remote_port = ntohs(sock_addr.sin_port);
642
*length = ret;
643
- return TRUE;
644
+ return true;
645
}
646
+
647
+ return false;
648
}
649
libhdhomerun_20150826.tgz/hdhomerun_types.h -> libhdhomerun_20190621.tgz/hdhomerun_types.h
Changed
47
1
2
/*
3
* hdhomerun_types.h
4
*
5
- * Copyright © 2008-2009 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2008-2015 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
struct hdhomerun_tuner_status_t {
12
char channel[32];
13
char lock_str[32];
14
- bool_t signal_present;
15
- bool_t lock_supported;
16
- bool_t lock_unsupported;
17
+ bool signal_present;
18
+ bool lock_supported;
19
+ bool lock_unsupported;
20
unsigned int signal_strength;
21
unsigned int signal_to_noise_quality;
22
unsigned int symbol_error_quality;
23
24
char auth[32];
25
char cci[32];
26
char cgms[32];
27
- bool_t not_subscribed;
28
- bool_t not_available;
29
- bool_t copy_protected;
30
+ bool not_subscribed;
31
+ bool not_available;
32
+ bool copy_protected;
33
};
34
35
struct hdhomerun_channelscan_program_t {
36
37
struct hdhomerun_tuner_status_t status;
38
int program_count;
39
struct hdhomerun_channelscan_program_t programs[HDHOMERUN_CHANNELSCAN_MAX_PROGRAM_COUNT];
40
- bool_t transport_stream_id_detected;
41
- bool_t original_network_id_detected;
42
+ bool transport_stream_id_detected;
43
+ bool original_network_id_detected;
44
uint16_t transport_stream_id;
45
uint16_t original_network_id;
46
};
47
libhdhomerun_20150826.tgz/hdhomerun_video.c -> libhdhomerun_20190621.tgz/hdhomerun_video.c
Changed
340
1
2
/*
3
* hdhomerun_video.c
4
*
5
- * Copyright © 2006-2010 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2016 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
#include "hdhomerun.h"
12
13
struct hdhomerun_video_sock_t {
14
- pthread_mutex_t lock;
15
+ thread_mutex_t lock;
16
struct hdhomerun_debug_t *dbg;
17
- hdhomerun_sock_t sock;
18
+ struct hdhomerun_sock_t *sock;
19
+
20
+ uint32_t keepalive_lockkey;
21
+ uint32_t keepalive_addr;
22
+ uint16_t keepalive_port;
23
+ volatile bool keepalive_start;
24
25
volatile size_t head;
26
volatile size_t tail;
27
28
size_t buffer_size;
29
size_t advance;
30
31
- pthread_t thread;
32
- volatile bool_t terminate;
33
+ thread_task_t thread;
34
+ volatile bool terminate;
35
36
volatile uint32_t packet_count;
37
volatile uint32_t transport_error_count;
38
39
volatile uint8_t sequence[0x2000];
40
};
41
42
-static THREAD_FUNC_PREFIX hdhomerun_video_thread_execute(void *arg);
43
+static void hdhomerun_video_thread_execute(void *arg);
44
45
-struct hdhomerun_video_sock_t *hdhomerun_video_create(uint16_t listen_port, bool_t allow_port_reuse, size_t buffer_size, struct hdhomerun_debug_t *dbg)
46
+struct hdhomerun_video_sock_t *hdhomerun_video_create(uint16_t listen_port, bool allow_port_reuse, size_t buffer_size, struct hdhomerun_debug_t *dbg)
47
{
48
/* Create object. */
49
struct hdhomerun_video_sock_t *vs = (struct hdhomerun_video_sock_t *)calloc(1, sizeof(struct hdhomerun_video_sock_t));
50
51
}
52
53
vs->dbg = dbg;
54
- vs->sock = HDHOMERUN_SOCK_INVALID;
55
- pthread_mutex_init(&vs->lock, NULL);
56
+ thread_mutex_init(&vs->lock);
57
58
/* Reset sequence tracking. */
59
hdhomerun_video_flush(vs);
60
61
62
/* Create socket. */
63
vs->sock = hdhomerun_sock_create_udp();
64
- if (vs->sock == HDHOMERUN_SOCK_INVALID) {
65
+ if (!vs->sock) {
66
hdhomerun_debug_printf(dbg, "hdhomerun_video_create: failed to allocate socket\n");
67
goto error;
68
}
69
70
/* Expand socket buffer size. */
71
- int rx_size = 1024 * 1024;
72
- setsockopt(vs->sock, SOL_SOCKET, SO_RCVBUF, (char *)&rx_size, sizeof(rx_size));
73
+ hdhomerun_sock_set_recv_buffer_size(vs->sock, 1024 * 1024);
74
75
/* Bind socket. */
76
if (!hdhomerun_sock_bind(vs->sock, INADDR_ANY, listen_port, allow_port_reuse)) {
77
78
}
79
80
/* Start thread. */
81
- if (pthread_create(&vs->thread, NULL, &hdhomerun_video_thread_execute, vs) != 0) {
82
+ if (!thread_task_create(&vs->thread, &hdhomerun_video_thread_execute, vs)) {
83
hdhomerun_debug_printf(dbg, "hdhomerun_video_create: failed to start thread\n");
84
goto error;
85
}
86
87
return vs;
88
89
error:
90
- if (vs->sock != HDHOMERUN_SOCK_INVALID) {
91
+ if (vs->sock) {
92
hdhomerun_sock_destroy(vs->sock);
93
}
94
+
95
if (vs->buffer) {
96
free(vs->buffer);
97
}
98
+
99
+ thread_mutex_dispose(&vs->lock);
100
+
101
free(vs);
102
return NULL;
103
}
104
105
void hdhomerun_video_destroy(struct hdhomerun_video_sock_t *vs)
106
{
107
- vs->terminate = TRUE;
108
- pthread_join(vs->thread, NULL);
109
+ vs->terminate = true;
110
+ thread_task_join(vs->thread);
111
112
hdhomerun_sock_destroy(vs->sock);
113
+ thread_mutex_dispose(&vs->lock);
114
free(vs->buffer);
115
116
free(vs);
117
}
118
119
-hdhomerun_sock_t hdhomerun_video_get_sock(struct hdhomerun_video_sock_t *vs)
120
+void hdhomerun_video_set_keepalive(struct hdhomerun_video_sock_t *vs, uint32_t remote_addr, uint16_t remote_port, uint32_t lockkey)
121
+{
122
+ thread_mutex_lock(&vs->lock);
123
+
124
+ vs->keepalive_addr = remote_addr;
125
+ vs->keepalive_port = remote_port;
126
+ vs->keepalive_lockkey = lockkey;
127
+
128
+ if ((remote_addr != 0) && (remote_port != 0)) {
129
+ vs->keepalive_start = true;
130
+ }
131
+
132
+ thread_mutex_unlock(&vs->lock);
133
+}
134
+
135
+struct hdhomerun_sock_t *hdhomerun_video_get_sock(struct hdhomerun_video_sock_t *vs)
136
{
137
return vs->sock;
138
}
139
140
141
static void hdhomerun_video_stats_ts_pkt(struct hdhomerun_video_sock_t *vs, uint8_t *ptr)
142
{
143
- uint16_t packet_identifier = ((uint16_t)(ptr[1] & 0x1F) << 8) | (uint16_t)ptr[2];
144
- if (packet_identifier == 0x1FFF) {
145
- return;
146
- }
147
+ uint16_t packet_identifier;
148
+ packet_identifier = (uint16_t)(ptr[1] & 0x1F) << 8;
149
+ packet_identifier |= (uint16_t)ptr[2] << 0;
150
151
- bool_t transport_error = ptr[1] >> 7;
152
+ bool transport_error = (ptr[1] & 0x80) != 0;
153
if (transport_error) {
154
vs->transport_error_count++;
155
vs->sequence[packet_identifier] = 0xFF;
156
return;
157
}
158
159
+ if (packet_identifier == 0x1FFF) {
160
+ return;
161
+ }
162
+
163
+ bool payload_present = (ptr[3] & 0x10) != 0;
164
+ if (!payload_present) {
165
+ return;
166
+ }
167
+
168
uint8_t sequence = ptr[3] & 0x0F;
169
170
uint8_t previous_sequence = vs->sequence[packet_identifier];
171
172
if (sequence == ((previous_sequence + 1) & 0x0F)) {
173
return;
174
}
175
- if (sequence == previous_sequence) {
176
- return;
177
- }
178
179
vs->sequence_error_count++;
180
}
181
182
}
183
}
184
185
-static THREAD_FUNC_PREFIX hdhomerun_video_thread_execute(void *arg)
186
+static void hdhomerun_video_thread_send_keepalive(struct hdhomerun_video_sock_t *vs)
187
+{
188
+ thread_mutex_lock(&vs->lock);
189
+ uint32_t keepalive_lockkey = vs->keepalive_lockkey;
190
+ uint32_t keepalive_addr = vs->keepalive_addr;
191
+ uint16_t keepalive_port = vs->keepalive_port;
192
+ vs->keepalive_start = false;
193
+ thread_mutex_unlock(&vs->lock);
194
+
195
+ if ((keepalive_addr == 0) || (keepalive_port == 0)) {
196
+ return;
197
+ }
198
+
199
+ struct hdhomerun_pkt_t pkt;
200
+ hdhomerun_pkt_reset(&pkt);
201
+ hdhomerun_pkt_write_u32(&pkt, keepalive_lockkey);
202
+ hdhomerun_sock_sendto(vs->sock, keepalive_addr, keepalive_port, pkt.start, pkt.end - pkt.start, 25);
203
+}
204
+
205
+static void hdhomerun_video_thread_execute(void *arg)
206
{
207
struct hdhomerun_video_sock_t *vs = (struct hdhomerun_video_sock_t *)arg;
208
- struct hdhomerun_pkt_t pkt_inst;
209
+ uint64_t send_time = getcurrenttime();
210
211
while (!vs->terminate) {
212
- struct hdhomerun_pkt_t *pkt = &pkt_inst;
213
- hdhomerun_pkt_reset(pkt);
214
+ uint64_t current_time = getcurrenttime();
215
+ if (vs->keepalive_start || (current_time >= send_time)) {
216
+ hdhomerun_video_thread_send_keepalive(vs);
217
+ send_time = current_time + 1000;
218
+ }
219
220
/* Receive. */
221
+ struct hdhomerun_pkt_t pkt;
222
+ hdhomerun_pkt_reset(&pkt);
223
+
224
size_t length = VIDEO_RTP_DATA_PACKET_SIZE;
225
- if (!hdhomerun_sock_recv(vs->sock, pkt->end, &length, 25)) {
226
+ if (!hdhomerun_sock_recv(vs->sock, pkt.end, &length, 25)) {
227
continue;
228
}
229
230
- pkt->end += length;
231
+ pkt.end += length;
232
233
if (length == VIDEO_RTP_DATA_PACKET_SIZE) {
234
- hdhomerun_video_parse_rtp(vs, pkt);
235
- length = (int)(pkt->end - pkt->pos);
236
+ hdhomerun_video_parse_rtp(vs, &pkt);
237
+ length = pkt.end - pkt.pos;
238
}
239
240
if (length != VIDEO_DATA_PACKET_SIZE) {
241
242
continue;
243
}
244
245
- pthread_mutex_lock(&vs->lock);
246
+ thread_mutex_lock(&vs->lock);
247
248
/* Store in ring buffer. */
249
size_t head = vs->head;
250
uint8_t *ptr = vs->buffer + head;
251
- memcpy(ptr, pkt->pos, length);
252
+ memcpy(ptr, pkt.pos, length);
253
254
/* Stats. */
255
vs->packet_count++;
256
257
/* Check for buffer overflow. */
258
if (head == vs->tail) {
259
vs->overflow_error_count++;
260
- pthread_mutex_unlock(&vs->lock);
261
+ thread_mutex_unlock(&vs->lock);
262
continue;
263
}
264
265
vs->head = head;
266
267
- pthread_mutex_unlock(&vs->lock);
268
+ thread_mutex_unlock(&vs->lock);
269
}
270
-
271
- return NULL;
272
}
273
274
uint8_t *hdhomerun_video_recv(struct hdhomerun_video_sock_t *vs, size_t max_size, size_t *pactual_size)
275
{
276
- pthread_mutex_lock(&vs->lock);
277
+ thread_mutex_lock(&vs->lock);
278
279
size_t head = vs->head;
280
size_t tail = vs->tail;
281
282
if (head == tail) {
283
vs->advance = 0;
284
*pactual_size = 0;
285
- pthread_mutex_unlock(&vs->lock);
286
+ thread_mutex_unlock(&vs->lock);
287
return NULL;
288
}
289
290
291
if (size == 0) {
292
vs->advance = 0;
293
*pactual_size = 0;
294
- pthread_mutex_unlock(&vs->lock);
295
+ thread_mutex_unlock(&vs->lock);
296
return NULL;
297
}
298
299
300
*pactual_size = size;
301
uint8_t *result = vs->buffer + tail;
302
303
- pthread_mutex_unlock(&vs->lock);
304
+ thread_mutex_unlock(&vs->lock);
305
return result;
306
}
307
308
void hdhomerun_video_flush(struct hdhomerun_video_sock_t *vs)
309
{
310
- pthread_mutex_lock(&vs->lock);
311
+ thread_mutex_lock(&vs->lock);
312
313
vs->tail = vs->head;
314
vs->advance = 0;
315
316
vs->sequence_error_count = 0;
317
vs->overflow_error_count = 0;
318
319
- pthread_mutex_unlock(&vs->lock);
320
+ thread_mutex_unlock(&vs->lock);
321
}
322
323
void hdhomerun_video_debug_print_stats(struct hdhomerun_video_sock_t *vs)
324
325
{
326
memset(stats, 0, sizeof(struct hdhomerun_video_stats_t));
327
328
- pthread_mutex_lock(&vs->lock);
329
+ thread_mutex_lock(&vs->lock);
330
331
stats->packet_count = vs->packet_count;
332
stats->network_error_count = vs->network_error_count;
333
334
stats->sequence_error_count = vs->sequence_error_count;
335
stats->overflow_error_count = vs->overflow_error_count;
336
337
- pthread_mutex_unlock(&vs->lock);
338
+ thread_mutex_unlock(&vs->lock);
339
}
340
libhdhomerun_20150826.tgz/hdhomerun_video.h -> libhdhomerun_20190621.tgz/hdhomerun_video.h
Changed
71
1
2
/*
3
* hdhomerun_video.h
4
*
5
- * Copyright © 2006 Silicondust USA Inc. <www.silicondust.com>.
6
+ * Copyright © 2006-2016 Silicondust USA Inc. <www.silicondust.com>.
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
11
*
12
* When no longer needed, the socket should be destroyed by calling hdhomerun_control_destroy.
13
*/
14
-extern LIBTYPE struct hdhomerun_video_sock_t *hdhomerun_video_create(uint16_t listen_port, bool_t allow_port_reuse, size_t buffer_size, struct hdhomerun_debug_t *dbg);
15
-extern LIBTYPE void hdhomerun_video_destroy(struct hdhomerun_video_sock_t *vs);
16
+extern LIBHDHOMERUN_API struct hdhomerun_video_sock_t *hdhomerun_video_create(uint16_t listen_port, bool allow_port_reuse, size_t buffer_size, struct hdhomerun_debug_t *dbg);
17
+extern LIBHDHOMERUN_API void hdhomerun_video_destroy(struct hdhomerun_video_sock_t *vs);
18
+
19
+/*
20
+ * Configure to send a keepalive packet every second.
21
+ */
22
+extern LIBHDHOMERUN_API void hdhomerun_video_set_keepalive(struct hdhomerun_video_sock_t *vs, uint32_t remote_addr, uint16_t remote_port, uint32_t lockkey);
23
24
/*
25
* Get the port the socket is listening on.
26
*
27
* Returns 16-bit port with native endianness, or 0 on error.
28
*/
29
-extern LIBTYPE uint16_t hdhomerun_video_get_local_port(struct hdhomerun_video_sock_t *vs);
30
+extern LIBHDHOMERUN_API uint16_t hdhomerun_video_get_local_port(struct hdhomerun_video_sock_t *vs);
31
32
/*
33
* Join/leave multicast group.
34
*/
35
-extern LIBTYPE int hdhomerun_video_join_multicast_group(struct hdhomerun_video_sock_t *vs, uint32_t multicast_ip, uint32_t local_ip);
36
-extern LIBTYPE void hdhomerun_video_leave_multicast_group(struct hdhomerun_video_sock_t *vs, uint32_t multicast_ip, uint32_t local_ip);
37
+extern LIBHDHOMERUN_API int hdhomerun_video_join_multicast_group(struct hdhomerun_video_sock_t *vs, uint32_t multicast_ip, uint32_t local_ip);
38
+extern LIBHDHOMERUN_API void hdhomerun_video_leave_multicast_group(struct hdhomerun_video_sock_t *vs, uint32_t multicast_ip, uint32_t local_ip);
39
40
/*
41
* Read data from buffer.
42
43
* The buffer is implemented as a ring buffer. It is possible for this function to return a small
44
* amount of data when more is available due to the wrap-around case.
45
*/
46
-extern LIBTYPE uint8_t *hdhomerun_video_recv(struct hdhomerun_video_sock_t *vs, size_t max_size, size_t *pactual_size);
47
+extern LIBHDHOMERUN_API uint8_t *hdhomerun_video_recv(struct hdhomerun_video_sock_t *vs, size_t max_size, size_t *pactual_size);
48
49
/*
50
* Flush the buffer.
51
*/
52
-extern LIBTYPE void hdhomerun_video_flush(struct hdhomerun_video_sock_t *vs);
53
+extern LIBHDHOMERUN_API void hdhomerun_video_flush(struct hdhomerun_video_sock_t *vs);
54
55
/*
56
* Debug print internal stats.
57
*/
58
-extern LIBTYPE void hdhomerun_video_debug_print_stats(struct hdhomerun_video_sock_t *vs);
59
-extern LIBTYPE void hdhomerun_video_get_stats(struct hdhomerun_video_sock_t *vs, struct hdhomerun_video_stats_t *stats);
60
+extern LIBHDHOMERUN_API void hdhomerun_video_debug_print_stats(struct hdhomerun_video_sock_t *vs);
61
+extern LIBHDHOMERUN_API void hdhomerun_video_get_stats(struct hdhomerun_video_sock_t *vs, struct hdhomerun_video_stats_t *stats);
62
63
/*
64
* Internal use only.
65
*/
66
-extern LIBTYPE hdhomerun_sock_t hdhomerun_video_get_sock(struct hdhomerun_video_sock_t *vs);
67
+extern LIBHDHOMERUN_API struct hdhomerun_sock_t *hdhomerun_video_get_sock(struct hdhomerun_video_sock_t *vs);
68
69
#ifdef __cplusplus
70
}
71
Refresh
No build results available
Refresh
No rpmlint results available
Login required, please
login
or
signup
in order to comment
Request History
manfred.h created request over 5 years ago
Version upgrade to 20190621, needed to build current kodi.pvr-addons
hillwood accepted request over 5 years ago