Commit Graph

1542 Commits

Author SHA1 Message Date
Julien BLACHE 6a144cd670 Add db_file_path_byid() 2010-03-07 11:13:38 +01:00
Julien BLACHE 1f5efe038b Register ffmpeg evbuffer URL handler 2010-03-07 11:13:38 +01:00
Julien BLACHE a1ef2ab243 FFmpeg "evbuffer:0x..." URLProtocol implementation
Implement a URL handler to output data to an evbuffer from ffmpeg.
2010-03-07 11:13:38 +01:00
Julien BLACHE 119525e612 Add a logger callback for FFmpeg log messages 2010-03-07 11:13:38 +01:00
Julien BLACHE 4c48dbad28 Add a logdomain for ffmpeg 2010-03-07 11:13:38 +01:00
Julien BLACHE 107ec85578 Constify the format string of logging functions 2010-03-07 11:13:38 +01:00
Julien BLACHE 07146e3261 Handle database upgrade v7 -> v8 2010-03-06 19:10:49 +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 88dde32fc7 Recompute all songalbumids at startup
Due to the two Murmur64 implementations for 64 and 32bit machines, the
hash is not compatible when moving the SQLite DB between 32/64 bit hosts.

So we'll recompute all the songalbumids at startup, just in case.
2010-03-06 18:59:58 +01:00
Julien BLACHE 0e9a8674d9 Handle database upgrade v6 -> v7 2010-03-06 17:29:48 +01:00
Julien BLACHE facb9957d8 Move daap_songalbumid() to its now-unique callsite 2010-03-06 17:29:48 +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 affbae1c47 Make evbase_httpd non-static
Make the httpd event base available to httpd protocol handlers.
2010-03-06 10:27:39 +01:00
Julien BLACHE c9e91532b3 Get rid of the intermediate buffer in itunes_pairing_hash()
No need to build the string to be hashed in advance, it can just
be written piece by piece to the md.
2010-02-22 17:49:24 +01:00
Julien BLACHE 2dde2f180d Revert "Add a fail_cb to evhttp_request for connection failures"
The fail_cb extension was actually never needed; we've migrated away from
it, so let's clean that up now.

This reverts commit 1ffcbdae27.
2010-02-14 09:36:55 +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 20d08d8a49 Add safe_atou32() and safe_atou64() 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 a5a46b8a53 Fix lseek() return value handling
lseek() returns an off_t and not an int, using an int to store and
test the return value means we'll error out when the position in the file
gets past INT_MAX.
2010-02-10 18:19:32 +01:00
Julien BLACHE 2b4f07195a Kill leftover includes 2010-02-06 07:25:44 +01:00
Julien BLACHE 71a40c5149 Simplify the iTunes pairing hash using standard MD5
The pairing hash actually uses standard MD5, so let's simplify the
code by using a standard MD5 implementation. Now that function is
readable and understandable by mere mortals.

Thanks to Jeff Sharkey for posting that simplified version.
2010-02-05 18:39:03 +01:00
Julien BLACHE 2f385bff2c Add libgcrypt, check for it and perform global initialization 2010-02-05 18:38:39 +01:00
Julien BLACHE cb4320791b Use eventfd instead of pipes if available
eventfd has less overhead than a pipe, works as a counter and uses a
single fd. Use it on Linux if available (that should be pretty much
always given the glibc and kernel requirements).
2010-02-04 18:52:13 +01:00
Julien BLACHE 274dccf66c Reduce STREAM_CHUNK_SIZE to a more manageable 64k
512k might be a bit too much, as it can take time to read 512k from the
filesystem (and we're using a blocking read) or from the decoder. Going
down to 64k will make this more manageable and improve the response time
when streaming to multiple clients at the same time.
2010-02-02 21:09:56 +01:00
Julien BLACHE 848dd41993 serve_file() is broken due to evbuffer_read()
If we ever need to serve files for a web interface or otherwise, serve_file()
will need to be fixed to not use evbuffer_read().
2010-02-02 21:09:56 +01:00
Julien BLACHE 6e5f49bdf9 Use transcode variable to check for transcoding status 2010-02-02 21:09:56 +01:00
Julien BLACHE 825569dc88 Rework failure path in httpd_stream_file()
Kill code duplication, make it all clearer.
2010-02-02 21:09:56 +01:00
Julien BLACHE f0239951e1 Replace evbuffer_read(); should not be applied to files
evbuffer_read() is really meant to read from sockets and not regular
files. It also looks like evbuffer_read() was causing issues with large
files, locking up a little below 2 GB for an unknown reason (couldn't
reproduce).
2010-02-02 21:09:56 +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 5d41d2d99c Move file_size to an int64_t, matching other types (off_t) 2010-02-02 21:09:55 +01:00
Julien BLACHE 516909545b Include config.h in all C files 2010-02-02 21:09:55 +01:00
Julien BLACHE 1df7ec1b7c Use posix_fadvise() to hint the OS when streaming raw file
Hinting the OS about our behaviour shouldn't make a big difference in
performance but it will help the OS manage its disk cache and can reduce
memory pressure on small systems.
2010-02-02 21:09:55 +01:00
Julien BLACHE 8ac5f48fe6 Wire up DACP support 2010-01-30 17:30:22 +01:00
Julien BLACHE a52ff42697 Introduce stub DACP protocol implementation 2010-01-30 17:30:22 +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 9f1c849241 Add logdomain for DACP 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 115d28e24a Parse pairing response and save pairing GUID
The pairing GUID will be used later on to authenticate the Remote
instance when it logs in.
2010-01-30 17:30:22 +01:00
Julien BLACHE b35c4749a2 Maintain a db connection in main.c for Remote pairing agent 2010-01-30 17:30:22 +01:00
Julien BLACHE dfa3db7732 Use struct pairing_info in struct remote_info 2010-01-30 17:30:22 +01:00
Julien BLACHE d384bc13a3 Handle database upgrade v5 -> v6 2010-01-30 17:30:22 +01:00
Julien BLACHE 762d80e0bb Add Remote pairing info storage facility
This brings schema_version to 6.
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 eca166feaa Move DMAP routines to a dedicated module 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 2924a98f1a Fix pairing_cb() - readd event after pairing 2010-01-30 17:30:21 +01:00
Julien BLACHE 2c6ceac486 Rework code flow in httpd_gen_cb() 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 7ddd135e2b Extend close detection to incoming connections
Stock evhttp has no means to detect when an incoming connection gets
closed by the client; it will notice the connection has gone down only
when sending back a reply.

For DAAP update requests working as a push mechanism with an HTTP request
stalled by the server until there actually is an update available, we need
to be notified when a connection goes down so we can perform proper cleanup
and not retain memory.

Do so by extending the close detection mechanism used for outgoing connections
and the connection failure callback we already have in place for streaming.
2010-01-28 19:19:31 +01:00
Julien BLACHE f425eddb62 Clean up remote list at deinit 2010-01-28 19:19:16 +01:00
Julien BLACHE 4321cffc87 Make queries on daap.songalbumid:0 a no-op
Remote makes queries with daap.songalbumid:0, which doesn't make sense. Make
that a no-op.
2010-01-27 18:31:13 +01:00
Julien BLACHE 21098d4c89 Fix query and path for playlist #1
The query was erroneously put into the path column; also change the query
for 1 = 1 instead of disabled = 0 which is redundant.
2010-01-27 18:29:59 +01:00
Julien BLACHE b5b9f92d97 Fix HTTP error return in daap_session_find() 2010-01-27 12:18:22 +01:00
Julien BLACHE eae5370c08 Log HTTP (non-DAAP, non-RSP) requests 2010-01-26 18:15:08 +01:00
Julien BLACHE 4701817333 Replace strlcpy() with evutil_snprintf() in evhttp
Get rid of strlcpy() and its implementation entirely, it doesn't buy anything
over snprintf(). Use evutil_snprintf() so as to match the rest of the code.
2010-01-26 17:54:45 +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 7e3b6957b2 Move the pairing agent to the main thread
The pairing agent doesn't need a thread of its own, the main thread can host
it. Move it there and save a thread.
2010-01-25 17:55:11 +01:00
Julien BLACHE 854abd8026 Specify field width for pairing hash
No field width was specified when the 128bit hash is converted to a string;
make sure we get 8 hex digits per 32bit hash component.
2010-01-25 17:51:17 +01:00
Julien BLACHE e6234c35ad Fix field width for 64bit library name hash
Was 8 hex digits, should have been 16 hex digits.
2010-01-25 17:47:37 +01:00
Julien BLACHE 672e4697ae Handle database schema upgrade from v4 to v5
Force a library rescan to fixup media_kind for regular videos.
2010-01-24 11:16:31 +01:00
Ace Jones 12e0c9268d Unspecified videos are "movies", media_kind=2
media_kind=2 (Movies) indicates a regular video, that is, a video that
isn't a TV Show (media_kind=64).

Also fix up the system playlist for Movies, and that brings us to DB
schema_version 5.
2010-01-24 11:11:08 +01:00
Julien BLACHE f85fa927c8 Dereference library directories before processing
The filescanner dereferences symlinks as it encounters them, but it did
not dereference the top-level library directories given in the config.

Also the playlist scanner always dereferences the filenames.

As a result, there was a mismatch between the paths in the files table and
the paths in the playlistitems table if the library directory given in the
config contain a symlink somewhere along the way.
2010-01-24 10:54:52 +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 4aa207533e Ignore empty lines in M3U playlists 2010-01-23 18:41:54 +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 67b3a8c2da Handle database schema upgrade from v3 to v4 2010-01-21 17:54:50 +01:00
Ace Jones 3fef4334bb Add support for smart playlists and some default ones
Add system playlists for Music, Movies, TV Shows, equivalent to iTunes.
2010-01-21 17:52:51 +01:00
Julien BLACHE fefdb23409 Simplify DB init routine 2010-01-21 17:51:44 +01:00
Julien BLACHE 944bf3f132 Check database version first, if that fails, try DB init
Doing it the other way around is a guaranteed way to run into issues when
a schema upgrade is needed.
2010-01-21 17:51:00 +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
Julien BLACHE f126b04521 Tell libavl to free() ITML <-> DB mappings
The mappings should be free()d with the standard free() when we are
done with the tree. This fixes a memory leak.
2010-01-20 18:19:51 +01:00
Julien BLACHE 2cb67743fc Add service type to the "ALL FOR NOW" message 2010-01-20 18:17:04 +01:00
Julien BLACHE d47c205452 Feed .remote files to the Remote pairing agent 2010-01-17 10:52:58 +01:00
Julien BLACHE 3c7456f545 Add Remote pairing services start/stop 2010-01-17 10:52:58 +01:00
Julien BLACHE c191aff5cd Add remote_pairing.[ch] to sources 2010-01-17 10:52:58 +01:00
Julien BLACHE 625b8e3177 Add a pairing agent for Remote
Remote is the iPod/iPhone application that can act as a remote control for
iTunes. Remote must be paired with an iTunes instance before it can control
it; this pairing process includes a challenge/response autentication.

This pairing agent makes it possible to pair Remote with a forked-daapd
instance. It is the very first step for Remote support.
2010-01-17 10:52:58 +01:00
Julien BLACHE 04f4622086 Add generic mDNS browsing + resolving facility 2010-01-17 10:52:58 +01:00
Julien BLACHE 2b2ec87e7e Add the "remote" logdomain for Remote pairing 2010-01-17 10:52:58 +01:00
Julien BLACHE 73fa690fd4 Advertise the _touch-able._tcp service
_touch-able._tcp is the service used by Remote.app to discover and identify
libraries it interacts with.
2010-01-17 10:52:58 +01:00
Julien BLACHE d228e0dcb8 Rename servername variable to a more appropriate libname 2010-01-17 10:52:58 +01:00
Julien BLACHE b918d14e38 Fix group_entries list traversal 2010-01-17 10:52:58 +01:00