Commit Graph

166 Commits

Author SHA1 Message Date
ejurgensen 10e4a138a3 Fix crash after special (malformed?) TunesRemote SE daap request
Request has comma before &query:
/databases/1/containers/1/items?session-id=100&meta=dmap.itemname,[...],daap.songcompilation,&query=('com.apple...
2013-12-02 20:55:16 +01:00
ejurgensen d85eb171cb Lower log level to spam for metadata message in httpd_daap.c 2013-11-16 22:52:53 +01:00
ejurgensen 7bb2fef25f Lower log level to spam for DMAP investigation and add dmap_add_raw_uint32() for later use 2013-11-14 23:08:20 +01:00
ejurgensen 28b485c595 Fix malformed DAAP packages 2013-11-10 12:35:24 +01:00
ejurgensen 9b190fe282 Fix group-type-type 2013-08-29 22:43:59 +02:00
ejurgensen 95fc525beb Add support for artist group request (experimental)
The purpose of this is mainly to support Hyperfine Remote for Android
2013-08-29 22:00:37 +02:00
Craig Markwardt c2e6eeda32 Fixes for Amarok and Banshee clients which don't send
revision-number in their update request.

Details: Banshee (v1.6.1) and Amarok client players send an
update request but do not send the revision-number parameter.
iTunes version 10 (and perhaps earlier) does send this parameter.
See: https://github.com/jasonmc/forked-daapd/issues/78

Fix: function daap_reply_update() now warns when revision-number
is not submitted by the client, but does not reply with an error.
In that case the server assumes a revision-number which insures
an update is sent back to the client.

Testing:
I verified that the following clients were able to connect succesfully
and retrieve a library listing:
  * iTunes 10.5.2
  * iTunes 10.4.2
  * iTunes 9.7.1
  * Rhythmbox 0.12.8
  * Banshee 1.6.1
I can't test with Amarok since I don't have this client.
2012-01-02 04:22:39 -05:00
Craig Markwardt bd10978d52 Fixes for iTunes v10.5 time-outs.
Details:

iTunes v10.5 clients changed how they responded to DAAP
protocol, and started disconnecting when the forked-daapd server
sent an empty "refresh" reply ("mupd" protocol).  This problem is
also coupled with session-timeout ("mstm" and "msal"); when these
server capabilities were enabled, iTunes 10.x clients did not poll
for updates and eventually disconnected.

I investigated DAAP network packets using Wireshark.  I found that
a true iTunes server sends a set of server capabilities in a specific
order, and order matters to the client.  When the correct order is used,
the client correctly polls for updates and does not disconnect.

This change:
  1. Send server capabilities in different order (daap_reply_server_info).
  2. Disables 5-minute update refresh.
  3. Disables 30-minute inactivity time-out.

Testing:
This server version successfully stayed connected to the
following clients:
  * iTunes 10.5.2
  * iTunes 10.4.2
  * iTunes 9.7.1
  * Rhythmbox 0.12.8
The clients stayed connected for at least several hours,
sometimes days, with activity or no activity.
2012-01-02 02:15:18 -05:00
Julien BLACHE 4be0d86aa0 Revert "Disable session expiration"
This reverts commit c70caad87e.
2011-09-10 18:44:37 +02:00
Julien BLACHE 9f06848d43 Reply to update requests periodically to avoid 30-minute iTunes timeout
Craig Markwardt <craig.markwardt@gmail.com> found out that the 30-minute
timeout in iTunes was caused by the lack of reply to update requests.

We now send out replies every 5 minutes, avoiding the timeout and
disconnection.

Thanks to Craig for digging into this, producing code to demonstrate the fix
and trying out a few more ideas for update support beyond this fix.
2011-09-10 18:37:16 +02:00
Julien BLACHE a70a45d925 Fix DAAP songlist generation after code move to dmap_common
Handling of the sort tags was left into httpd_daap.c where the code runs
after the song is added to the songlist - effectively adding the sort tags
to the *next* song, leading to incorrect sort tags on the current song.
2011-04-28 18:25:14 +02:00
Julien BLACHE 718d1e9487 Migrate file metadata encoding to DMAP common code 2011-04-09 10:11:35 +02:00
Julien BLACHE 07df6bb4aa Move dmap_add_field() to DMAP common code 2011-04-09 10:11:35 +02:00
Julien BLACHE 39542aee27 Move DMAP fields list and hash table to DMAP common code 2011-04-09 10:11:34 +02:00
Julien BLACHE 52691d6c4d Rename dmap_helpers.[ch] to dmap_common.[ch] 2011-04-09 10:11:34 +02:00
Julien BLACHE e23f02c7c0 Replace AVL tree in DAAP by a static hash using gperf 2011-04-02 09:52:19 +02:00
Julien BLACHE 303a3329eb Replace AVL tree in DAAP query by a static hash using gperf 2011-04-02 09:52:19 +02:00
Julien BLACHE 204c9681ca Enable and handle JPEG artwork in DAAP 2011-04-01 22:02:51 +02:00
Julien BLACHE c7209ab699 Add support for JPEG as a valid artwork output format
Reduce CPU usage by avoiding unneeded JPEG -> PNG conversions; it appears
all the clients we care about support JPEG as well as PNG.
2011-03-30 21:50:29 +02:00
Julien BLACHE f5b167080b Use title_sort for DAAP sort headers 2011-03-21 18:48:00 +01:00
Kai Elwert 4dce6390ea Switch to using db_query_fetch_string_sort() in daap_reply_browse() 2011-03-21 18:48:00 +01:00
Kai Elwert bf86cf45bd Always include sort tags in songlist 2011-03-21 18:47:59 +01:00
Julien BLACHE c70caad87e Disable session expiration
Auto-logout currently doesn't work as expected and breaks streaming etc once
the timeout occurs. Disable it until we can make it work as expected.

Maybe we'll need to upgrade the DAAP version.
2010-11-11 10:44:57 +01:00
Kai Elwert e5af78fe9f Implement sort=artist for DAAP queries 2010-10-09 16:06:00 +02:00
Kai Elwert ee7b976eeb Advertise DAAP updates support in server-info
We don't send out DAAP updates, but Remote requires this to work.
2010-10-09 15:54:53 +02:00
Julien BLACHE f7c2bf756a Remove duplicate mstm tag in server-info reply 2010-09-18 22:50:26 +02:00
Julien BLACHE 535d691a4a Fix full_uri memory leak in error path 2010-09-10 18:47:42 +02:00
Kai Elwert de8884c8df Add sort-headers support to DAAP song lists 2010-09-04 10:58:25 +02:00
Kai Elwert ee294753e1 Add sort-headers support to DAAP groups query 2010-08-29 12:07:08 +02:00
Kai Elwert 8a2d76895c Add sort-headers support to DAAP browse query 2010-08-29 12:07:08 +02:00
Kai Elwert eaaaec91a1 Introduce DAAP sort-headers helpers 2010-08-29 12:07:07 +02:00
Kai Elwert d4f341aff0 Handle include-sort-headers parameter in DAAP queries 2010-08-29 12:07:07 +02:00
Julien BLACHE 471f750a8c Rework error handling where an oom variable was used
The oom-specific message was actually never used as it was hidden by
ret being < 0 and that condition was tested before oom.
2010-08-29 12:05:02 +02:00
Julien BLACHE 1d35afbe62 Fixup file modes 2010-08-06 17:27:56 +02:00
Kai Elwert ca72ee5926 Handle sort parameter in DAAP queries
This is used by Remote for the Title view.
2010-08-05 18:28:02 +02:00
Kai Elwert 4347731133 Add mpco to playlists, hardcode to 0 for now 2010-07-31 10:40:39 +02:00
Kai Elwert 931c0aac29 Map mper to playlist id for playlists 2010-07-31 10:39:41 +02:00
Julien BLACHE 25ee24d2be Properly deinit DAAP sessions
Call event_del() before freeing the session when clearing the AVL tree. Caused
an infinite loop in event_base_free() in httpd_deinit().
2010-07-30 21:52:04 +02:00
Julien BLACHE f6a9e1f7f4 Kill update request connections during deinit
Avoid leaving active requests on the HTTP server before shutting it down.
2010-07-30 21:42:53 +02:00
Julien BLACHE 81d09ed234 Account for new evhttp behaviour on failed incoming connections
The evcon associated with a request is freed by evhttp when the connection
fails. Protect against a NULL evcon when handling the connection failure.
2010-07-23 18:28:29 +02:00
Julien BLACHE 548cd2a150 Use httpd_send_reply() instead of evhttp_send_reply() where pertinent
gzip replies where useful; artwork should not be compressed, as PNGs are
already compressed and that would be a waste of time.
2010-05-03 19:11:55 +02:00
Julien BLACHE dc95a04562 Add optional sorting clause to Q_ITEMS 2010-05-02 11:44:43 +02:00
Julien BLACHE bccc6da87f Set closecb to NULL on update requests' connections at deinit
Otherwise the closecb is called when the connection is closed/freed during
deinit, and this happens in the HTTP cleanup after the DAAP and DACP cleanups
have run, leading to spurious "struct update_request not found" messages.
2010-05-02 11:21:07 +02:00
Julien BLACHE 17b1e1a7bf Fix size_t in snprintf() 2010-05-02 10:17:22 +02:00
Julien BLACHE 1df0258055 Demote "could not find requested meta field" message to E_WARN 2010-04-10 09:46:48 +02:00
Julien BLACHE 19b6780a3c Remove provisions for multi-library support
It is now clear that multi-library support will not happen, so remove whatever
provisions were in the code for that.

It comes with a small change to the configuration file, too.

With this, DB schema version went to 9.
2010-03-19 19:09:18 +01:00
Julien BLACHE ece7c0d071 Handle DAAP extra_data requests for groups/items artwork 2010-03-07 15:45:52 +01:00
Julien BLACHE 641e5462cc Rename pl_id member of struct query_params 2010-03-07 15:23:40 +01:00
Julien BLACHE 224ef48137 Make album groups persistent
Store groups (only album groups supported at the moment) in the DB,
so their ids are persistent for the duration of the forked-daapd session.

Those ids are used to, among other things, retrieve artwork, so we must
provide ourselves some persistence here.

This brings us to schema version 8.
2010-03-06 19:02:49 +01:00
Julien BLACHE 748cca63be Maintain songalbumid inside the files table
songalbumid is used a lot in queries from Remote; computing the hash for
each row is a major waste of time on big libraries and slow machines, so
let's store the hash in the table.

This brings us to schema version 7.
2010-03-06 17:29:37 +01:00
Julien BLACHE 20c57d5289 Implement DAAP auto-logout
And advertise it.
2010-03-06 10:30:59 +01:00
Julien BLACHE 8c2def5ef5 Move daap_session_kill() higher up
No functional changes.
2010-03-06 10:29:53 +01:00
Julien BLACHE 18abda3a97 Use evhttp_connection's closecb instead of our fail_cb extension
The closecb callback of evhttp_connection does what we need, so no need
to use that extension anymore.
2010-02-14 09:34:29 +01:00
Ace Jones a92dc076e8 Add a test facility for DMAP
Add a /dmap-test handler that sends back a list containing test values
for all standard DMAP types (string + all integer types).
2010-02-10 18:29:26 +01:00
Julien BLACHE 056f4b6997 Reindent dmap_add_field()
Fix indentation in dmap_add_field(), no functional changes.
2010-02-10 18:29:26 +01:00
Julien BLACHE 3280fd5cf9 Get rid of magic hash values for filtering query parameters
Some metadata were filtered out from the reply by directly checking
for their hash, including the hash value in the code. Remove the magic
values and compare dfm->field against the relevant dmap_* field as for
other special cases.
2010-02-10 18:29:26 +01:00
Julien BLACHE 2524eb0f8f Rework special cases in daap_reply_songlist_generic()
Use a pointer comparison instead of strcmp(), now that the fields
have been separated out from the field map.
2010-02-10 18:29:26 +01:00
Julien BLACHE 3df34fe9a8 Remove mper special case in daap_reply_groups()
mper was so far the only LONG we really cared about, but dmap_add_field()
now has proper support all DMAP types. This special case can go.
2010-02-10 18:29:26 +01:00
Ace Jones cfabc9a456 Update DMAP fields
Update field types, add new fields (commented out). This fixes a number
of mis-assigned types. Update generated from the result of a /content-codes
request.
2010-02-10 18:29:26 +01:00
Ace Jones b4b89dd937 Break out the dmap_field_map struct into two structs
Introduce struct dmap_field holding the field tag, description and
DMAP type and use it in struct dmap_field_map to replace the tag,
desc and type fields.

This enables semi-automated updates of the DMAP fields information
from the output of a /content-codes request.
2010-02-10 18:29:20 +01:00
Julien BLACHE d8bd8e5381 Rewrite dmap_add_field() to handle properly all DMAP types 2010-02-10 18:21:32 +01:00
Ace Jones 0607e82a42 Add missing DMAP types and correct existing types
Most of the unsigned DMAP types were missing and assignments were incorrect
between signed and unsigned types. Fix all of this, and add (preliminary)
support for the new types.
2010-02-10 18:21:32 +01:00
Julien BLACHE d4fb2091c8 Use an enum for DMAP types 2010-02-10 18:21:32 +01:00
Julien BLACHE 42dd7ddd00 Kill code redundant with dmap_add_field()
This code in daap_reply_songlist_generic() is redundant with code
in (new) dmap_add_field() and can be removed, with a tweak: we must
ensure the val integer is always 0 if not used to override a value in
the transcoding case.
2010-02-10 18:21:32 +01:00
Julien BLACHE 1a3620d0a4 Handle DMAP long type properly in dmap_add_field() 2010-02-02 21:09:56 +01:00
Julien BLACHE 58faeaceca Integer types cleanup
Try to be a bit more strict about integer types, use off_t or int64_t for
file size and file offsets.

Replace safe_ato*() by safe_atoi32() and safe_atoi64(), fix integer types
at call sites to match.
2010-02-02 21:09:56 +01:00
Julien BLACHE 168144c1e0 Make daap_session_find() non-static so DACP can use it 2010-01-30 17:30:22 +01:00
Julien BLACHE 44bf308701 Waive HTTP authentication on the library for Remote
DAAP queries from Remote won't need HTTP authentication as they all
require a valid session-id; Remote can only obtain a valid session-id
if its pairing-guid is known to us (it did pair successfully with us).
2010-01-30 17:30:22 +01:00
Julien BLACHE e016ced119 Authenticate Remote clients by their pairing-guid
Remote clients have a waiver for HTTP authentication; they are authenticated
by their pairing-guid given during the pairing process.
2010-01-30 17:30:22 +01:00
Julien BLACHE 07a71b4e94 Reorganize httpd_daap
Some code moved around for clarity, no functional changes.
2010-01-30 17:30:22 +01:00
Julien BLACHE 7ec27a30eb Use DMAP routines from dmap_helpers.c 2010-01-30 17:30:22 +01:00
Julien BLACHE 29fb23893d DAAP update request requires a session-id 2010-01-30 17:30:21 +01:00
Julien BLACHE b9a2e10272 Modify DAAP update request debug messages 2010-01-30 17:30:21 +01:00
Julien BLACHE 78275ae432 Remove useless include 2010-01-30 17:30:21 +01:00
Julien BLACHE 42f39938d5 Start implementing DAAP updates
Stall update requests if revision-number == current revision. This is a
first step that is necessary to get clients to work properly (eg Remote).
2010-01-28 19:20:00 +01:00
Julien BLACHE b5b9f92d97 Fix HTTP error return in daap_session_find() 2010-01-27 12:18:22 +01:00
Julien BLACHE 98cb978b9b Set capability atoms to true in server-info reply
Capability atoms like mslr, msbr and friends should be set to true; it
seems their presence in the reply is actually enough, though.
2010-01-25 18:33:25 +01:00
Julien BLACHE 022bebe1d9 Send back mslr in server-info reply, indicating login is required
At least FrontRow honours this atom of the server-info reply.
2010-01-24 10:53:49 +01:00
Julien BLACHE d3fe586d5b Remove a special case for playlist #1
Not needed anymore, now that playlist #1 has been turned into a smart
playlist.
2010-01-22 19:02:29 +01:00
Ace Jones 1af1cf51c7 Return special playlists in playlist list response 2010-01-21 17:56:44 +01:00
Julien BLACHE 87abc3f432 Avoid useless double attempt at converting string to integer
Fixup dmap_add_field() and one of its callers to avoid making two useless
attempts at converting a string to an integer in some cases.
2010-01-20 18:34:36 +01:00
Julien BLACHE ba251b16ae Start keeping track of DAAP sessions
This will soon be required as we'll need to keep some knowledge about
the session in some cases. This also makes us a bit more compliant.
2010-01-20 18:24:52 +01:00
Ace Jones d96cdd7400 Add DAAP request handler for databases/###/groups (albums)
As of now we only support album groups, but there may be more than
album groups.
2010-01-10 14:43:23 +01:00
Ace Jones e033d35195 Rework error handling in daap_reply_playlists()
Kill a bit of code duplication in the error handling.
2010-01-10 14:43:22 +01:00
Ace Jones ac82b176a0 Rework error handling in daap_reply_songlist_generic()
Kill a bit of code duplication in the error handling.
2010-01-10 14:43:22 +01:00
Ace Jones cac2c032f6 Add the daap.songalbumartist DMAP field 2010-01-10 12:11:00 +01:00
Julien BLACHE 974a74a833 Update copyright notices for 2010 2010-01-05 19:34:00 +01:00
Ace Jones d3350713d1 Return daap.songalbumid as a hash of the album_artist + album
iPhone remote will later want to query by album. Instead of doing a
fulltext query, it uses a 64-bit hash of the album + album_artist. It
is not necessary to use the same hash algorithm that iTunes uses. The
important thing is that we can later respond to a query=('daap.songalbumid:xxx')
with this value.
2010-01-04 18:00:05 +01:00
Ace Jones 117ee15e44 Add handler for DMAP extra_data requests
iPhone Remote uses the following requests to get cover art for
songs and albums:

/databases/#/items/#/extra_data/artwork
/databases/#/groups/#/extra_data/artwork

For now, we will return the valid and correct response that we
have "No content".  In the future, the real artwork could be
extracted and returned here.
2010-01-03 18:55:32 +01:00
Ace Jones abbba5cf47 Fix typo in DAAP error message 2009-12-30 18:47:41 +01:00
Ace Jones 76fc069f22 Fix missing argument to debug call 2009-12-30 18:46:41 +01:00
Julien BLACHE 403153f64b Reindent the dmap_fields table, no code changes 2009-12-26 09:28:28 +01:00
Ace Jones 000e13b7ee Return TV metadata in DMAP response 2009-12-26 09:23:13 +01:00
Ace Jones d231faff2d Handle DAAP activity request
Reply to the DAAP /activity request with 204 / No content. Used by iTunes to
ping the server while streaming.
2009-12-20 14:43:28 +01:00
Julien BLACHE b9e7df5be3 Return a proper Content-Type when streaming videos
Clients like Front Row expect video/<type> for video streaming, whereas iTunes
likes application/x-dmap-tagged when streaming audio.

Based on a patch by Ace Jones <ace.jones1@yahoo.com>.
2009-12-08 21:04:30 +01:00
Julien BLACHE 946758cec7 Rework iTunes 9 absolute request uri fix 2009-11-14 11:23:03 +01:00
Julien BLACHE f8f183f2f6 Fixup iTunes 9 Request-URI before processing
iTunes 9 sends requests with a Request-URI like
  daap://10.1.1.20:3689/server-info

The DAAP server expected the Request-URI to be just /server-info, and so
couldn't match the request to any handler.

In addition, evhttp would declare this request a proxy request which also
broke keep-alive handling resulting in the server closing the connection
after the reply. iTunes doesn't like that.
2009-11-13 21:53:47 +01:00
Julien BLACHE c36b3c360d Fix DAAP request regexps - IDs can (thankfully) be more than 1-digit long 2009-11-01 12:39:11 +01:00
Julien BLACHE e1c0b6d4b7 Move *_offsetof() macro definitions to db.h 2009-06-11 23:17:17 +02:00
Julien BLACHE c589d92b14 Use db_get_count() wherever applicable; simplify db_{pl,files}_get_count() prototypes 2009-06-11 18:41:50 +02:00