Commit Graph

226 Commits

Author SHA1 Message Date
ejurgensen
3ee9204ff8 [xcode/daap/rsp] Default transcode to 320 kbps mp3 instead of wav
- Calculate size for both formats (+ move the return to transcode_encode_query)
- Let transcode_needed() decide what format to output
- Determine content-type from transcoding type
- Add transcode-dependent ability to override file metadata in rsp/daap
- Send file size matching format
2023-12-04 17:26:03 +01:00
ejurgensen
8528073003 [daap] Fix for use-after-free
Present in 28.7 and 28.8. Closes #1659.

Credit X-Ryl669.
2023-09-30 23:06:09 +02:00
ejurgensen
e94838925e [httpd] Change prototype for the close connection callback
Don't include hreq since it isn't fully valid, so caller shouldn't be invited
to dereference it.
2023-03-07 21:01:45 +01:00
ejurgensen
18a80f15dd [httpd] Multithread solution using worker threads instead of httpd threads
Using worker threads instead of httpd threads means that we, not libevent,
decide which requests get handled by which threads. This means that we can
make sure blocking requests (e.g. volume changes) don't get in the way of
realtime(ish) stuff like mp3 streaming.

Includes refactor of httpd_stream_file() since it was a bit of a monster.
2023-03-07 21:01:45 +01:00
ejurgensen
bd6f38282c [httpd] Main commit that adds multithreading to httpd
Also refactor streaming implementation to make it more like an output and to
let the design support multithreading.
2023-03-07 21:01:10 +01:00
ejurgensen
50a319df2b [httpd] Try doing request handling in worker thread 2023-03-07 21:01:10 +01:00
ejurgensen
74f1b93b42 [httpd] Make http modules agnostic to evhttp 2023-03-07 21:01:10 +01:00
ejurgensen
2778088c52 [httpd] Refactor to use modules for daap, dacp, json api etc.
Removes a lot of code duplication which hopefully will make it easier to add
support for evhtp as http engine.
2023-03-07 21:01:10 +01:00
ejurgensen
23979d223c [httpd] Refactor http handlers so they are initialized centrally
Means regex.h doesn't need to be in httpd.h making it easier to e.g. experiment
with evhtp.
2023-03-07 21:01:10 +01:00
ejurgensen
228c8e7920 [daap] Move daap_query_parse_sql() into dmap_common.c/h, drop daap_query.c/h 2022-01-29 17:46:40 +01:00
ejurgensen
53ee9a3c39 [daap] Coverity fixups 2022-01-20 20:17:38 +01:00
ejurgensen
d857116e41 [daap] Fix null dereference on missing group-type param 2022-01-14 23:12:49 +01:00
chme
8becdee8f1 [db] Refactor db_query_fetch_* functions to take the output parameter
first and the input parameter as last parameter
2021-12-28 07:23:56 +01:00
chme
a65ee4462e [db] Refactor fetching query result into generic function
Additionally changes the return value in case the end of the result set
is reached.
2021-12-28 06:55:35 +01:00
ejurgensen
5f1686695a [-] Name update forked-daapd -> owntone throughout the code 2021-04-24 23:54:20 +02:00
ejurgensen
7871d71a9c [misc] Add utility network functions, incl configurable addr binding
Also make misc.c/h a bit less messy.
2021-03-31 23:55:25 +02:00
ejurgensen
695927de2a [artwork] Remove old artwork_get_xxx in favor of new which has a format arg 2020-11-18 23:23:05 +01:00
ejurgensen
4fcd0ba781 [daap] Adjust user_agent_filter() so code matches intention 2020-04-04 21:25:14 +02:00
whatdoineed2do/Ray
10b10f8037 [daap] RSS support: podcasts visible on IOS Remote app
IOS appl generates request for itunes.extended-media-kind: 4,36,6,7 when
navigating "Podcasts" item on menu
2020-04-04 21:07:16 +02:00
ejurgensen
00de0a3f76 [db] Fixup commit #1edfadc 2020-02-23 20:25:22 +01:00
whatdoineed2do/Ray
de665fc6c8 [daap] honor requests to sort by 'releasedate' 2020-02-23 20:25:22 +01:00
ejurgensen
92dee0386d [daap/dacp] Workaround so that libevent cleans up when a long poll is disconnected
See https://github.com/ejurgensen/forked-daapd/issues/870
2020-01-12 01:06:34 +01:00
ejurgensen
4fa7eb98a0 [daap/dacp] Fix for memleak when client hangs up 2020-01-12 01:05:59 +01:00
ejurgensen
a69e79e5ec [daap] Make Apple Music on Catalina work - part 1 (fix for issue #834)
Like with iTunes, it has adverse effects to announce support for DAAP groups,
so with this change we also check if user-agent is "Music" before deciding what
to announce.
2019-11-01 15:43:56 -07:00
ejurgensen
7dfe4c2b65 [daap] Always use S_PLAYLIST ordering for Q_PL (ref issue #785) 2019-08-13 21:35:07 +02:00
ejurgensen
4f5966c9ff [db] Speed up Q_PL query used by e.g. '/databases/1/containers' request
The previous solution would use subqueries to count the number of items and
streams in each playlist, which means that response time gets pretty slow if
there are many playlists.

This commit also includes a number of lesser db code changes.
2019-05-30 21:19:40 +02:00
chme
46b37b2c80 [daapd] Fix scan-build issue "Dereference of null pointer" 2018-12-29 16:34:56 +01:00
ejurgensen
75dd9a5764 [daap] Fixup 2018-10-04 22:39:46 +02:00
ejurgensen
6109a5b6dd [daap] Don't send two errors on auth problems + use 401 instead of 403 (issue #594) 2018-10-04 22:33:30 +02:00
ejurgensen
75743bea80 [daap] Fix missing prompt for library password for non-remote DAAP clients (fixes #594) 2018-09-30 22:39:53 +02:00
ejurgensen
3ba92aa860 [httpd] Better logging of unauthorized requests 2018-09-07 17:01:32 +02:00
Rok Mandeljc
083f58abf7 daap_request: cache the query result only if user agent was provided
Avoid calling cache_daap_add() when hreq->user_agent is NULL
(user agent is not provided by the client), because it will
trigger a segfault when strdup() is called with that NULL pointer.

Fixes #571.
2018-08-24 17:05:11 +02:00
ejurgensen
e79beb6877 [httpd_daap] Workaround for Android "Remote for iTunes" requesting playlist 0
See issue #505
2018-03-11 22:40:07 +01:00
ejurgensen
ea6fd1476a [db] Improve speed of browse queries (issue #478)
Before, we returned either unordered (for RSP, meaning client had to
sort) or ordered by a client selected sort_clause[]. The latter are
multi-purpose and therefore not optimised for browse queries.

To speed up, we predefine the entire set of browse queries, including
order, with matching indices. The predefined queries are used except
if the client explicitly requests a non-default order or query.

As a special bonus, the commit also allows queries with I_SUB that
have an offset but no limit.
2018-03-02 21:11:31 +01:00
ejurgensen
a6fab4ac0d [httpd/mpd] Adjustments to commit #69ff42f 2017-11-15 23:13:20 +01:00
ejurgensen
3d5aeda7aa [httpd] Implement "trusted_networks" option
Some clients aren't really capable of authenticating + some users probably
don't want to enter a password for the web interface. This option allows
clients on for instance the local network to connect without authentication.
2017-11-12 21:29:57 +01:00
ejurgensen
473a29ef8a [httpd] More refactoring, reduce code duplication in the httpd_xxx modules 2017-11-11 22:20:09 +01:00
ejurgensen
9ed810d9df [httpd] Refactor httpd.c
- move stuff around and clean up
- put oauth out in own module like the other modules
2017-11-11 22:20:09 +01:00
ejurgensen
709d99d4c4 [httpd] Major refactor of the httpd request handling
Make it easier to add new parameters later, get rid of redundant code, clean
up, align between httpd_xxx modules and introduce new bugs. Yes, the refactor
got a bit out of hand.
2017-11-11 22:20:09 +01:00
ejurgensen
20937ea4c9 [httpd_daap] Try to use revision as it is supposed to be used 2017-11-11 22:20:09 +01:00
ejurgensen
fdc9054890 [httpd_daap] Improve code clarity a bit 2017-11-11 22:20:09 +01:00
ejurgensen
eff9e6ebeb [httpd] Add promiscuous mode option, i.e. no auth requirements
For people who want to avoid the web login, or want to get around pairing
problems. This is also added because commit #e59a1a1 means that all
Remotes are now subject to auth, not just those with a user-agent name that
starts with "Remote".
2017-11-11 22:20:09 +01:00
ejurgensen
8e7c47cce9 [httpd_daapd] Refactor daap 2017-11-11 22:20:09 +01:00
ejurgensen
66a46173fa [httpd_daap.c] Improve user_agent_filter() code
E.g. remove hardcoded values of DATA_KIND_x
2017-10-21 19:19:51 +02:00
ejurgensen
0c2773039b [-] Fix alsa.c null pointer deref + some minor bugs and do some housekeeping
Thanks to Denis Denisov and cppcheck for notifying about the below. The leaks
are edge cases, but the warning of dereference of avail in alsa.c points at
a bug that could probably cause actual crashes.

[src/evrtsp/rtsp.c:1352]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
[src/httpd_daap.c:228]: (error) Memory leak: s
[src/library.c:280]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'.
[src/library.c:284]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'.
[src/library/filescanner_playlist.c:251]: (error) Resource leak: fp
[src/library/filescanner_playlist.c:273]: (error) Resource leak: fp
[src/outputs/alsa.c:143]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
[src/outputs/alsa.c:657]: (warning) Possible null pointer dereference: avail
[src/outputs/dummy.c:75]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
[src/outputs/fifo.c:245]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
[src/outputs/raop.c:1806]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
[src/outputs/raop.c:1371]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'.
[src/outputs/raop.c:1471]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'.
[src/outputs/raop_verification.c:705] -> [src/outputs/raop_verification.c:667]: (warning) Either the condition 'if(len_M)' is redundant or there is possible null pointer dereference: len_M.
2017-10-05 22:13:01 +02:00
ejurgensen
1b8adc11ed [dmap] Use a wrapper for dmap_find_field()
Avoids the need to have definition of dmap_find_field in dmap_common.h that
must be kept in sync with the definition that gperf generates.

Also should fix compilation problems when gperf is not present, ref pr #390
2017-08-25 19:27:41 +02:00
ejurgensen
6c94cdd635 [httpd_daap] Honour sort param "artist" for album groups (fixes issue #358) 2017-03-05 09:45:34 +01:00
ejurgensen
c44f4310b7 [httpd] Replace evhttp_send_error with the httpd_send_error wrapper 2016-10-18 22:45:22 +02:00
ejurgensen
40c49f1fde [httpd] Use httpd_send_reply() wrapper in httpd_*, dmap_common and mpd 2016-10-17 22:25:31 +02:00
ejurgensen
7dc2a46261 [cache] Save daap replies gzipped - should improve performance 2016-10-17 19:40:25 +02:00