Typedefs | |
typedef __gf_download_manager | GF_DownloadManager |
typedef __gf_download_session | GF_DownloadSession |
typedef Bool(*) | gf_dm_get_usr_pass (void *usr_cbk, const char *site_url, char *usr_name, char *password) |
callback function for authentication | |
typedef void(*) | gf_dm_on_data_rcv (void *usr_cbk, char *data, u32 data_size, u32 dnload_status, GF_Err dl_error) |
callback function for data reception and state signaling | |
Enumerations | |
enum | { GF_DOWNLOAD_STATE_SETUP = 0, GF_DOWNLOAD_STATE_CONNECTED, GF_DOWNLOAD_STATE_WAIT_FOR_REPLY, GF_DOWNLOAD_STATE_RUNNING, GF_DOWNLOAD_STATE_DISCONNECTED, GF_DOWNLOAD_STATE_UNAVAILABLE } |
enum | { GF_DOWNLOAD_SESSION_NOT_THREADED = 1, GF_DOWNLOAD_SESSION_NOT_CACHED = 1<<1 } |
Functions | |
GF_DownloadManager * | gf_dm_new (GF_Config *cfg) |
download manager constructor | |
void | gf_dm_del (GF_DownloadManager *dm) |
void | gf_dm_set_auth_callback (GF_DownloadManager *dm, gf_dm_get_usr_pass get_pass, void *usr_cbk) |
password retrieval assignment | |
GF_DownloadSession * | gf_dm_sess_new (GF_DownloadManager *dm, char *url, u32 dl_flags, gf_dm_on_data_rcv OnDataRcv, void *usr_cbk, void *private_data, GF_Err *error) |
download session constructor | |
void | gf_dm_sess_del (GF_DownloadSession *sess) |
void | gf_dm_sess_abort (GF_DownloadSession *sess) |
aborts downloading | |
void * | gf_dm_sess_get_private (GF_DownloadSession *sess) |
gets private data | |
GF_Err | gf_dm_sess_last_error (GF_DownloadSession *sess) |
gets last session error | |
GF_Err | gf_dm_sess_fetch_data (GF_DownloadSession *sess, char *buffer, u32 buffer_size, u32 *read_size) |
fetches data on session | |
const char * | gf_dm_sess_mime_type (GF_DownloadSession *sess) |
get mime type | |
const char * | gf_dm_sess_get_cache_name (GF_DownloadSession *sess) |
get cache file name | |
GF_Err | gf_dm_sess_get_stats (GF_DownloadSession *sess, const char **server, const char **path, u32 *total_size, u32 *bytes_done, u32 *bytes_per_sec, u32 *net_status) |
get statistics |
typedef struct __gf_download_manager GF_DownloadManager |
the download manager object. This is usually not used by GPAC modules
typedef struct __gf_download_session GF_DownloadSession |
the download manager session.
typedef Bool(*) gf_dm_get_usr_pass(void *usr_cbk, const char *site_url, char *usr_name, char *password) |
The gf_dm_get_usr_pass type is the type for the callback of the gf_dm_set_auth_callback function used for password retrieval
usr_cbk | opaque user data | |
site_url | url of the site the user and password are requested for | |
usr_name | the user name for this site. The allocated space for this buffer is 50 bytes. |
password | the password for this site and user. The allocated space for this buffer is 50 bytes. |
typedef void(*) gf_dm_on_data_rcv(void *usr_cbk, char *data, u32 data_size, u32 dnload_status, GF_Err dl_error) |
The gf_dm_on_data_rcv type is the type for the data callback function of a download session
usr_cbk | opaque user data | |
data |
| |
data_size |
| |
dnload_status | session state for message callback | |
dl_error | session error if any |
anonymous enum |
downloader session status
anonymous enum |
GF_DownloadManager* gf_dm_new | ( | GF_Config * | cfg | ) |
Creates a new download manager object.
cfg | optional configuration file. Currently the download manager needs a configuration file for cache location and other options. The cache directory must be indicated in the section "General", key "CacheDirectory" of the configuration file. If the cache directory is not found, the cache will be disabled but the downloader will still work. |
void gf_dm_set_auth_callback | ( | GF_DownloadManager * | dm, | |
gf_dm_get_usr_pass | get_pass, | |||
void * | usr_cbk | |||
) |
Assigns the callback function used for user password retrieval. If no such function is assigned to the download manager, all downloads requiring authentication will fail.
dm | the download manager object | |
get_pass | gf_dm_get_usr_pass callback function for user and password retrieval. | |
usr_cbk | opaque user data passed to callback function |
GF_DownloadSession* gf_dm_sess_new | ( | GF_DownloadManager * | dm, | |
char * | url, | |||
u32 | dl_flags, | |||
gf_dm_on_data_rcv | OnDataRcv, | |||
void * | usr_cbk, | |||
void * | private_data, | |||
GF_Err * | error | |||
) |
Creates a new download session
dm | the download manager object | |
url | file to retrieve (no PUT/POST yet, only downloading is supported) | |
dl_flags | combination of session download flags | |
OnDataRcv | gf_dm_on_data_rcv callback function for data reception and service messages | |
usr_cbk | opaque user data passed to callback function | |
private_data | private data associated with session. | |
error | error for failure cases |
void gf_dm_sess_del | ( | GF_DownloadSession * | sess | ) |
brief downloader session destructor
Deletes the download session, cleaning the cache if indicated in the configuration file of the download manager (section "Downloader", key "CleanCache")
sess | the download session |
void gf_dm_sess_abort | ( | GF_DownloadSession * | sess | ) |
Aborts all operations in the session, regardless of its state. The session cannot be reused once this is called.
sess | the download session |
void* gf_dm_sess_get_private | ( | GF_DownloadSession * | sess | ) |
Gets private data associated with the session.
sess | the download session |
GF_Err gf_dm_sess_last_error | ( | GF_DownloadSession * | sess | ) |
Gets the last error that occured in the session
sess | the download session |
GF_Err gf_dm_sess_fetch_data | ( | GF_DownloadSession * | sess, | |
char * | buffer, | |||
u32 | buffer_size, | |||
u32 * | read_size | |||
) |
Fetches data from the server. This will also performs connections and all needed exchange with server.
sess | the download session | |
buffer | destination buffer | |
buffer_size | destination buffer allocated size | |
read_size | amount of data actually fetched |
const char* gf_dm_sess_mime_type | ( | GF_DownloadSession * | sess | ) |
Fetches the mime type of the URL this session is fetching
sess | the download session |
const char* gf_dm_sess_get_cache_name | ( | GF_DownloadSession * | sess | ) |
Gets the cache file name for the session.
sess | the download session |
GF_Err gf_dm_sess_get_stats | ( | GF_DownloadSession * | sess, | |
const char ** | server, | |||
const char ** | path, | |||
u32 * | total_size, | |||
u32 * | bytes_done, | |||
u32 * | bytes_per_sec, | |||
u32 * | net_status | |||
) |
Gets download statistics for the session. All output parameters are optional and may be set to NULL.
sess | the download session | |
server | the remote server address | |
path | the path on the remote server | |
total_size | the total size in bytes the file fetched, 0 if unknown. | |
bytes_done | the amount of bytes received from the server | |
bytes_per_sec | the average data rate in bytes per seconds | |
net_status | the session status |