Libdmapsharing Server Internals
Libdmapsharing Server Internals — Description of libdmapsharing's internal server code
This description uses DmapAvShare to describe the libdmapsharing internals. DmapAvShare resembles each implmentation of the abstract class DMAPShare, including its cousin DmapImageShare. After creating a new DmapAvShare, an application should call the object's dmap_share_serve and dmap_share_publish methods. The former method starts a new web server by calling soup_server_new, and it adds callbacks to the SoupServer object to handle the various paths required by the DMAP specification (/server-info, /content-codes, /login, and so on). DmapAvShare implements these callbacks, and DmapShare wraps them in an adapter method to make them suitable for the SoupServer's requirements. (Note that some callbacks are common to all DMAP protocols and are implemented in DMAPShare; e.g., the login callback.) The latter method, dmap_share_publish, starts the mDNS subsystem. It does this by using the mDNS implmentation option choosen at compile-time (either Avahi, DNS-SD, or Howl).
The DmapStructure class represents the data which makes up a DMAP request or response. The _cc_defs array defines the allowed entries in a DmapStructure representation. Likewise, the numeric content code used by each node is defined by the enum DmapContentCode. Both the _cc_defs array and the DmapContentCode enum must be in the same order. That is, if you add an entry to _cc_defs, then you must add its corresponding content code to DmapContentCode at the same relative position.
Assuming DmapStructure defines all the entries you require, DmapAvShare builds the actual protocol-specific structures. Note the use of the function dmap_structure_add. Often, the data dmap_structure_add adds is provided by a DmapAvRecord object that exists in a DmapDb object (both interfaces are implemented by the application). Eventually, the DmapAvShare provides the DmapStructure to the SoupServer object using the dmap_share_message_set_from_dmap_structure function.