Test API to operate the DLNA UPnP Content Directory Service

Overview

Definition of Test API for DLNA UPnP Content Directory Service features. More…

// typedefs

typedef enum tapi_upnp_cd_resource_type tapi_upnp_cd_resource_type;
typedef enum tapi_upnp_cd_object_type tapi_upnp_cd_object_type;
typedef struct tapi_upnp_cd_contributor tapi_upnp_cd_contributor;
typedef struct tapi_upnp_cd_contributor_node tapi_upnp_cd_contributor_node;
typedef struct tapi_upnp_cd_resource tapi_upnp_cd_resource;
typedef struct tapi_upnp_cd_resource_node tapi_upnp_cd_resource_node;
typedef struct tapi_upnp_cd_object tapi_upnp_cd_object;
typedef struct tapi_upnp_cd_container tapi_upnp_cd_container;
typedef struct tapi_upnp_cd_container_node tapi_upnp_cd_container_node;

typedef void (*cd_handler)(
    tapi_upnp_cd_container_node *,
    void *
    );

// enums

enum tapi_upnp_cd_object_type;
enum tapi_upnp_cd_resource_type;

// structs

struct tapi_upnp_cd_container;
struct tapi_upnp_cd_container_node;
struct tapi_upnp_cd_contributor;
struct tapi_upnp_cd_contributor_node;
struct tapi_upnp_cd_object;
struct tapi_upnp_cd_resource;
struct tapi_upnp_cd_resource_node;

// global functions

void tapi_upnp_cd_tree_dfs(tapi_upnp_cd_container_node* container, cd_handler presearch, cd_handler postsearch, void* user_data);
static tapi_upnp_cd_container_node* tapi_upnp_cd_get_parent(const tapi_upnp_cd_container_node* container);
te_errno tapi_upnp_cd_get_root(rcf_rpc_server* rpcs, const tapi_upnp_service_info* service, tapi_upnp_cd_container_node* container);
te_errno tapi_upnp_cd_get_children(rcf_rpc_server* rpcs, const tapi_upnp_service_info* service, tapi_upnp_cd_container_node* container);
te_errno tapi_upnp_cd_get_tree(rcf_rpc_server* rpcs, const tapi_upnp_service_info* service, const char* path_filter, tapi_upnp_cd_container_node* container);
void tapi_upnp_cd_remove_container(tapi_upnp_cd_container_node* container);
void tapi_upnp_cd_remove_tree(tapi_upnp_cd_container_node* root);
void tapi_upnp_print_content_directory(const tapi_upnp_cd_container_node* container);
size_t tapi_upnp_cd_get_objects_count(const tapi_upnp_cd_container_node* container, tapi_upnp_cd_object_type type);

Detailed Documentation

Definition of Test API for DLNA UPnP Content Directory Service features.

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef enum tapi_upnp_cd_resource_type tapi_upnp_cd_resource_type

Multimedia content types which can be returned as a resource.

typedef enum tapi_upnp_cd_object_type tapi_upnp_cd_object_type

Object type that is either container (i.e contains other objects) or item.

typedef struct tapi_upnp_cd_contributor tapi_upnp_cd_contributor

Parameters of a contributors resource in ContentDirectory service.

typedef struct tapi_upnp_cd_resource tapi_upnp_cd_resource

Parameters of a resource in ContentDirectory service.

typedef struct tapi_upnp_cd_resource_node tapi_upnp_cd_resource_node

Node of the tapi_upnp_cd_resource list.

typedef struct tapi_upnp_cd_object tapi_upnp_cd_object

Parameters of an object (common for items and containers) in ContentDirectory service.

typedef struct tapi_upnp_cd_container tapi_upnp_cd_container

A container context in ContentDirectory service.

typedef struct tapi_upnp_cd_container_node tapi_upnp_cd_container_node

Node of the tapi_upnp_cd_container list.

typedef void (*cd_handler)(
    tapi_upnp_cd_container_node *,
    void *
    )

Prototype of function of handler for using in

Parameters:

container

Container context

See also:

tapi_upnp_cd_tree_dfs.

Global Functions

void tapi_upnp_cd_tree_dfs(tapi_upnp_cd_container_node* container, cd_handler presearch, cd_handler postsearch, void* user_data)

Recursively call callbacks on each container in UPnP ContentDirectory tree using depth-first search on tree.

Parameters:

container

UPnP ContentDirectory subtree root element.

presearch

Pre search handler that is called on subtree node.

postsearch

Post search handler that is called on subtree node.

user_data

Additional data to post to presearch and postsearch handlers.

static tapi_upnp_cd_container_node* tapi_upnp_cd_get_parent(const tapi_upnp_cd_container_node* container)

Retrieve information about a container parent object. It does not invoke action on UPnP Control Point just gets parent from child context.

Parameters:

container

The container location which contains parent content.

Returns:

Parent container, or NULL if container has no parent, i.e. it is a root object.

te_errno tapi_upnp_cd_get_root(rcf_rpc_server* rpcs, const tapi_upnp_service_info* service, tapi_upnp_cd_container_node* container)

Retrieve information about a root container.

Parameters:

rpcs

RPC server handle.

service

ContentDirectory service context.

container

The container location where information will be saved.

Returns:

Status code. On success, 0.

te_errno tapi_upnp_cd_get_children(rcf_rpc_server* rpcs, const tapi_upnp_service_info* service, tapi_upnp_cd_container_node* container)

Retrieve information about a container child objects. Returned data about the children will be saved inside the children list of container.

Parameters:

rpcs

RPC server handle.

service

ContentDirectory service context.

container

The container location which contains parent content.

Returns:

Status code. On success, 0.

te_errno tapi_upnp_cd_get_tree(rcf_rpc_server* rpcs, const tapi_upnp_service_info* service, const char* path_filter, tapi_upnp_cd_container_node* container)

Retrieve tree structure and data of Content Directory which placement is matched to path_filter, for example, Video/Folders. This function releases container before retrieve a new data. Note, container should be released with either tapi_upnp_cd_remove_container or tapi_upnp_cd_remove_tree when it is no longer needed.

Parameters:

rpcs

RPC server handle.

service

ContentDirectory service context.

path_filter

Root path to retrieve data from. May be NULL or empty string to retrieve all content.

container

Container to put data to.

TE_ENODATA

There are no data which is satisfied to path_filter.

Returns:

Status code. On success, 0, on error container will be not changed.

void tapi_upnp_cd_remove_container(tapi_upnp_cd_container_node* container)

Remove the UPnP ContentDirectory container from the tree with all of it children, free content memory and update parent. User should care about freeing container if needed.

Parameters:

container

Container context.

void tapi_upnp_cd_remove_tree(tapi_upnp_cd_container_node* root)

Remove the all UPnP ContentDirectory containers: go through all parents to the root node and then remove all of it children. User should care about freeing root if needed.

Parameters:

root

Container context.

See also:

tapi_upnp_cd_remove_container

void tapi_upnp_print_content_directory(const tapi_upnp_cd_container_node* container)

Print UPnP Content Directory context using RING function. This function should be used for debugging purpose.

Parameters:

container

Container context.

size_t tapi_upnp_cd_get_objects_count(const tapi_upnp_cd_container_node* container, tapi_upnp_cd_object_type type)

Get a number of UPnP Content Directory objects.

Parameters:

container

Container context.

type

Content Directory object type.

Returns:

Number of UPnP Content Directory objects.