Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void
- add_item (GUPnPContext *context,
- GUPnPDIDLLiteWriter *didl_writer,
- GUPnPDIDLLiteObject *object,
- const char *id,
- const char *parent_id,
- const char *mime,
- const char *title,
- const char *path)
- {
- GUPnPDIDLLiteResource *res;
- res = gupnp_didl_lite_object_add_resource(object);
- gupnp_didl_lite_resource_set_uri(res, g_strdup_printf ("http://%s:%d%s",
- gupnp_context_get_host_ip (context),
- gupnp_context_get_port (context),
- path));
- gupnp_didl_lite_resource_set_protocol_info(res, gupnp_protocol_info_new_from_string(g_strdup_printf("http-get:*:%s:*", mime), NULL));
- gupnp_didl_lite_object_set_id(object, id);
- gupnp_didl_lite_object_set_parent_id(object, parent_id);
- gupnp_didl_lite_object_set_title(object, title);
- }
- static char *
- browse_direct_children ()
- {
- GUPnPContext *context;
- const char *didl;
- char *result;
- GUPnPDIDLLiteWriter *didlw = gupnp_didl_lite_writer_new (NULL);
- GUPnPDIDLLiteObject *object = GUPNP_DIDL_LITE_OBJECT
- (gupnp_didl_lite_writer_add_item (didlw));
- context = gupnp_device_info_get_context (GUPNP_DEVICE_INFO (device));
- add_item (context,
- didlw,
- object,
- "4000",
- "0",
- "audio/mp3",
- "Song1",
- "/home/phantom/Music/2.mp3");
- didl = gupnp_didl_lite_writer_get_string (didlw);
- result = g_strdup(didl);
- qDebug() << result;
- return result;
- }
- static void browse_cb (GUPnPService *service,
- GUPnPServiceAction *action,
- gpointer user_data)
- {
- qDebug()<< "Browse";
- char *object_id, *browse_flag;
- char *result;
- guint num_returned = 1;
- /* Handle incoming arguments */
- gupnp_service_action_get (action,
- "ObjectID",
- G_TYPE_STRING,
- &object_id,
- "BrowseFlag",
- G_TYPE_STRING,
- &browse_flag,
- NULL);
- result = browse_direct_children();
- /* Set action return arguments */
- gupnp_service_action_set (action,
- "Result",
- G_TYPE_STRING,
- result,
- "NumberReturned",
- G_TYPE_UINT,
- num_returned,
- "TotalMatches",
- G_TYPE_UINT,
- num_returned,
- "UpdateID",
- G_TYPE_UINT,
- 32,
- NULL);
- gupnp_service_action_return (action);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement