~ubuntu-branches/debian/experimental/gpac/experimental

1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
1
/*
2
 *			GPAC - Multimedia Framework C SDK
3
 *
1.2.1 by Alessio Treglia
Import upstream version 0.5.0+svn4288~dfsg1
4
 *			Authors: Jean Le Feuvre 
5
 *			Copyright (c) Telecom ParisTech 2000-2012
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
6
 *					All rights reserved
7
 *
8
 *  This file is part of GPAC / common tools sub-project
9
 *
10
 *  GPAC is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU Lesser General Public License as published by
12
 *  the Free Software Foundation; either version 2, or (at your option)
13
 *  any later version.
14
 *
15
 *  GPAC is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU Lesser General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU Lesser General Public
21
 *  License along with this library; see the file COPYING.  If not, write to
22
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
 *
24
 */
25
26
#ifndef _GF_DOWNLOAD_H_
27
#define _GF_DOWNLOAD_H_
28
29
/*!
30
 *	\file <gpac/download.h>
31
 *	\brief Downloader functions.
32
 */
33
34
/*!
35
 *	\addtogroup dld_grp downloader
36
 *	\ingroup utils_grp
37
 *	\brief File Downloader objects
38
 *
39
 *	This section documents the file downloading tools the GPAC framework. Currently HTTP is supported, HTTPS is under testing but may not be supported
40
 *depending on GPAC compilation options (HTTPS in GPAC needs OpenSSL installed on the system).
41
 *
42
 *	@{
43
 */
44
45
46
#ifdef __cplusplus
47
extern "C" {
48
#endif
49
50
#include <gpac/tools.h>
1.2.1 by Alessio Treglia
Import upstream version 0.5.0+svn4288~dfsg1
51
#include <gpac/config_file.h>
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
52
#include <gpac/cache.h>
53
54
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
55
	/*!the download manager object. This is usually not used by GPAC modules*/
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
56
    typedef struct __gf_download_manager GF_DownloadManager;
57
    /*!the download manager session.*/
58
    typedef struct __gf_download_session GF_DownloadSession;
59
60
    typedef struct GF_URL_Info_Struct {
61
        const char * protocol;
62
        char * server_name;
63
        char * remotePath;
64
        char * canonicalRepresentation;
65
        char * userName;
66
        char * password;
67
        u16 port;
68
    } GF_URL_Info;
69
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
70
	/*!
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
71
     * Extracts the information from an URL. A call to gf_dm_url_info_init() must have been issue before calling this method.
72
     * \param url The URL to fill
73
     * \param info This structure will be initialized properly and filled with the data
74
     * \param baseURL The baseURL to use if any (can be null)
75
     * \return GF_OK if URL is well formed and supported by GPAC
76
     */
77
    GF_Err gf_dm_get_url_info(const char * url, GF_URL_Info * info, const char * baseURL);
78
79
    /**
80
     * Init the GF_URL_Info structure before it can be used
81
     * \param info The structure to initialize
82
     */
83
    void gf_dm_url_info_init(GF_URL_Info * info);
84
85
    /*!
86
     * Frees the inner structures of a GF_URL_Info_Struct
87
     * \param info The info to free
88
     */
89
    void gf_dm_url_info_del(GF_URL_Info * info);
90
91
    /*!
92
     *\brief download manager constructor
93
     *
94
     *Creates a new download manager object.
95
     *\param cfg optional configuration file. Currently the download manager needs a configuration file for cache location and
96
     *other options. The cache directory must be indicated in the section "General", key "CacheDirectory" of the configuration
97
     *file. If the cache directory is not found, the cache will be disabled but the downloader will still work.
98
     *\return the download manager object
99
    */
100
    GF_DownloadManager *gf_dm_new(GF_Config *cfg);
101
    /*
102
     *\brief download manager destructor
103
     *
104
     *Deletes the download manager. All running sessions are aborted
105
     *\param dm the download manager object
106
     */
107
    void gf_dm_del(GF_DownloadManager *dm);
108
109
    /*!
110
     *\brief callback function for authentication
111
     *
112
     * The gf_dm_get_usr_pass type is the type for the callback of the \ref gf_dm_set_auth_callback function used for password retrieval
113
     *\param usr_cbk opaque user data
114
     *\param site_url url of the site the user and password are requested for
115
     *\param usr_name the user name for this site. The allocated space for this buffer is 50 bytes. \note this varaibale may already be formatted.
116
     *\param password the password for this site and user. The allocated space for this buffer is 50 bytes.
117
     *\return 0 if user didn't fill in the information which will result in an authentication failure, 1 otherwise.
118
    */
119
    typedef Bool (*gf_dm_get_usr_pass)(void *usr_cbk, const char *site_url, char *usr_name, char *password);
120
121
    /*!
122
     *\brief password retrieval assignment
123
     *
124
     *Assigns the callback function used for user password retrieval. If no such function is assigned to the download manager,
125
     *all downloads requiring authentication will fail.
126
     *\param dm the download manager object
127
     *\param get_pass \ref gf_dm_get_usr_pass callback function for user and password retrieval.
128
     *\param usr_cbk opaque user data passed to callback function
129
     */
130
    void gf_dm_set_auth_callback(GF_DownloadManager *dm, gf_dm_get_usr_pass get_pass, void *usr_cbk);
131
132
    /*!downloader session message types*/
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
133
    typedef enum
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
134
    {
135
        /*!signal that session is setup and waiting for connection request*/
136
        GF_NETIO_SETUP = 0,
137
        /*!signal that session connection is done*/
138
        GF_NETIO_CONNECTED,
139
        /*!request a protocol method from the user. Default value is "GET" for HTTP*/
140
        GF_NETIO_GET_METHOD,
141
        /*!request a header from the user. */
142
        GF_NETIO_GET_HEADER,
143
        /*!requesting content from the user, if any. Content is appended to the request*/
144
        GF_NETIO_GET_CONTENT,
145
        /*!signal that request is sent and waiting for server reply*/
146
        GF_NETIO_WAIT_FOR_REPLY,
147
        /*!signal a header to user. */
148
        GF_NETIO_PARSE_HEADER,
149
        /*!signal request reply to user. The reply is always sent after the headers*/
150
        GF_NETIO_PARSE_REPLY,
151
        /*!send data to the user*/
152
        GF_NETIO_DATA_EXCHANGE,
153
        /*!all data has been transfered*/
154
        GF_NETIO_DATA_TRANSFERED,
155
        /*!signal that the session has been deconnected*/
156
        GF_NETIO_DISCONNECTED,
157
        /*!downloader session failed (error code set) or done/destroyed (no error code)*/
158
        GF_NETIO_STATE_ERROR
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
159
    } GF_NetIOStatus;
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
160
161
    /*!session download flags*/
162
    enum
163
    {
1.1.2 by Alessio Treglia
Import upstream version 0.4.5+svn3912~dfsg1
164
        /*!session is not threaded, the user must explicitely fetch the data , either with the function gf_dm_sess_fetch_data 
165
		or the function gf_dm_sess_process- if the session is threaded, the user must call gf_dm_sess_process to start the session*/
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
166
        GF_NETIO_SESSION_NOT_THREADED	=	1,
167
        /*! session data is live, e.g. data will be sent to the user if threaded mode (live streams like radios & co)
168
				Whether the data is cached or not to disk cannot be controlled by the user at the current time.
169
		*/
170
        GF_NETIO_SESSION_NOT_CACHED	=	1<<1,
171
		/*indicates that the connection to the server should be kept once the download is successfully completed*/
172
        GF_NETIO_SESSION_PERSISTENT =	1<<2,
1.2.1 by Alessio Treglia
Import upstream version 0.5.0+svn4288~dfsg1
173
		/*file is stored in memory, and the cache name is set to gpac://%u@%p, where %d is the size in bytes and %d is the the pointer to the memory.
174
		Memory cached files are destroyed upon downloader destruction*/
175
        GF_NETIO_SESSION_MEMORY_CACHE	=	1<<3,
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
176
    };
177
178
179
    /*!protocol I/O parameter*/
180
    typedef struct
181
    {
182
        /*!parameter message type*/
183
        u32 msg_type;
184
        /*error code if any. Valid for all message types.*/
185
        GF_Err error;
186
        /*!data received or data to send. Only valid for GF_NETIO_GET_CONTENT and GF_NETIO_DATA_EXCHANGE (when no cache is setup) messages*/
187
        const char *data;
188
        /*!size of associated data. Only valid for GF_NETIO_GET_CONTENT and GF_NETIO_DATA_EXCHANGE messages*/
189
        u32 size;
190
        /*protocol header. Only valid for GF_NETIO_GET_HEADER, GF_NETIO_PARSE_HEADER and GF_NETIO_GET_METHOD*/
191
        const char *name;
192
        /*protocol header value or server response. Only alid for GF_NETIO_GET_HEADER, GF_NETIO_PARSE_HEADER and GF_NETIO_PARSE_REPLY*/
193
        char *value;
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
194
        /*message-dependend
195
			for GF_NETIO_PARSE_REPLY, response code
196
			for GF_NETIO_DATA_EXCHANGE 
197
				Set to 1 in to indicate end of chunk transfer
198
				Set to 2 in GF_NETIO_DATA_EXCHANGE to indicate complete file is already received (replay of events from cache)
199
			for all other, usage is reserved
200
		*/
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
201
        u32 reply;
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
202
        /*download session for which the message is being sent*/
203
		GF_DownloadSession *sess;
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
204
    } GF_NETIO_Parameter;
205
206
    /*!
207
     *\brief callback function for data reception and state signaling
208
     *
209
     * The gf_dm_user_io type is the type for the data callback function of a download session
210
     *\param usr_cbk opaque user data
211
     *\param parameter the input/output parameter structure
212
    */
213
    typedef void (*gf_dm_user_io)(void *usr_cbk, GF_NETIO_Parameter *parameter);
214
215
216
217
    /*!
218
     *\brief download session constructor
219
     *
220
     *Creates a new download session
221
     *\param dm the download manager object
222
     *\param url file to retrieve (no PUT/POST yet, only downloading is supported)
223
     *\param dl_flags combination of session download flags
224
     *\param user_io \ref gf_dm_user_io callback function for data reception and service messages
225
     *\param usr_cbk opaque user data passed to callback function
226
     *\param error error for failure cases
227
     *\return the session object or NULL if error. If no error is indicated and a NULL session is returned, this means the file is local
228
     */
229
    GF_DownloadSession * gf_dm_sess_new(GF_DownloadManager *dm, const char *url, u32 dl_flags,
230
                                        gf_dm_user_io user_io,
231
                                        void *usr_cbk,
232
                                        GF_Err *error);
233
234
    /*!
235
     *\brief download session simple constructor
236
     *
237
     *Creates a new download session
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
238
     *\param dm The download manager used to create the download session
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
239
     *\param url file to retrieve (no PUT/POST yet, only downloading is supported)
240
     *\param dl_flags combination of session download flags
241
     *\param user_io \ref gf_dm_user_io callback function for data reception and service messages
242
     *\param usr_cbk opaque user data passed to callback function
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
243
     *\param e error for failure cases
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
244
     *\return the session object or NULL if error. If no error is indicated and a NULL session is returned, this means the file is local
245
     */
246
    GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *url, u32 dl_flags,
247
            gf_dm_user_io user_io,
248
            void *usr_cbk,
249
            GF_Err *e);
250
251
    /*!
252
     *brief downloader session destructor
253
     *
254
     *Deletes the download session, cleaning the cache if indicated in the configuration file of the download manager (section "Downloader", key "CleanCache")
255
     *\param sess the download session
256
    */
257
    void gf_dm_sess_del(GF_DownloadSession * sess);
1.1.2 by Alessio Treglia
Import upstream version 0.4.5+svn3912~dfsg1
258
259
	/*!
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
260
     *\brief aborts downloading
261
     *
262
     *Aborts all operations in the session, regardless of its state. The session cannot be reused once this is called.
263
     *\param sess the download session
264
     */
265
    void gf_dm_sess_abort(GF_DownloadSession * sess);
1.1.2 by Alessio Treglia
Import upstream version 0.4.5+svn3912~dfsg1
266
267
	/*!
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
268
     *\brief sets private data
269
     *
270
     *associate private data with the session.
271
     *\param sess the download session
272
     *\param private_data the private data
273
     *\warning the private_data parameter is reserved for bandwidth statistics per service when used in the GPAC terminal.
274
     */
275
    void gf_dm_sess_set_private(GF_DownloadSession * sess, void *private_data);
276
277
    /*!
278
     *\brief gets private data
279
     *
280
     *Gets private data associated with the session.
281
     *\param sess the download session
282
     *\return the private data
283
     *\warning the private_data parameter is reserved for bandwidth statistics per service when used in the GPAC terminal.
284
     */
285
    void *gf_dm_sess_get_private(GF_DownloadSession * sess);
286
287
	/*!
288
     *\brief gets last session error
289
     *
290
     *Gets the last error that occured in the session
291
     *\param sess the download session
292
     *\return the last error
293
     */
294
    GF_Err gf_dm_sess_last_error(GF_DownloadSession *sess);
295
296
    /*!
297
     *\brief is download manager thread dead?
298
     *
299
     *Indicates whether the thread has ended
300
	 *\param sess the download session
301
     */
302
	Bool gf_dm_is_thread_dead(GF_DownloadSession *sess);
303
304
    /*!
305
     *\brief fetches data on session
306
     *
307
     *Fetches data from the server. This will also performs connections and all needed exchange with server.
308
     *\param sess the download session
309
     *\param buffer destination buffer
310
     *\param buffer_size destination buffer allocated size
311
     *\param read_size amount of data actually fetched
312
     *\note this can only be used when the session is not threaded
313
     */
314
    GF_Err gf_dm_sess_fetch_data(GF_DownloadSession * sess, char *buffer, u32 buffer_size, u32 *read_size);
315
316
    /*!
1.1.2 by Alessio Treglia
Import upstream version 0.4.5+svn3912~dfsg1
317
     *\brief get mime type as lower case
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
318
     *
1.1.2 by Alessio Treglia
Import upstream version 0.4.5+svn3912~dfsg1
319
     *Fetches the mime type of the URL this session is fetching, value will be returned lower case, so application/x-mpegURL will be returned as application/x-mpegurl
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
320
     *\param sess the download session
321
     *\return the mime type of the URL, or NULL if error. You should get the error with \ref gf_dm_sess_last_error
322
     */
323
    const char *gf_dm_sess_mime_type(GF_DownloadSession * sess);
324
325
    /*!
326
     *\brief sets session range
327
     *
328
     *Sets the session byte range. This shll be called before processing the session.
329
     *\param sess the download session
330
     *\param start_range HTTP download start range in byte 
331
     *\param end_range HTTP download end range in byte 
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
332
     *\param discontinue_cache If set, forces a new cache entry if byte range are not continuous. Otherwise a single cache entry is used to reconstruct the file
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
333
     *\note this can only be used when the session is not threaded
334
     */
1.2.1 by Alessio Treglia
Import upstream version 0.5.0+svn4288~dfsg1
335
	GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_range, Bool discontinue_cache);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
336
    /*!
337
     *\brief get cache file name
338
     *
339
     * Gets the cache file name for the session.
340
     *\param sess the download session
341
     *\return the absolute path of the cache file, or NULL if the session is not cached*/
342
    const char *gf_dm_sess_get_cache_name(GF_DownloadSession * sess);
343
344
    /*!
345
     * \brief Marks the cache file to be deleted once the file is not used anymore by any session
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
346
     * \param dm the download manager
347
     * \param url The URL associate to the cache entry to be deleted
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
348
     */
349
    void gf_dm_delete_cached_file_entry(const GF_DownloadManager * dm, const char * url);
350
351
    /*!
352
     * Convenience function
353
     * \see gf_dm_delete_cached_file_entry
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
354
     *\param sess the download session
355
     * \param url The URL associate to the cache entry to be deleted
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
356
     */
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
357
    void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * sess, const char * url);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
358
359
    /*!
360
     * Get a range of a cache entry file
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
361
     * \param sess The session
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
362
     * \param startOffset The first byte of the request to get
363
     * \param endOffset The last byte of request to get
364
     * \return The temporary name for the file created to have a range of the file
365
     */
366
    const char * gf_cache_get_cache_filename_range( const GF_DownloadSession * sess, u64 startOffset, u64 endOffset );
367
368
    /*!
369
     *\brief get statistics
370
     *
371
     *Gets download statistics for the session. All output parameters are optional and may be set to NULL.
372
     *\param sess the download session
373
     *\param server the remote server address
374
     *\param path the path on the remote server
375
     *\param total_size the total size in bytes the file fetched, 0 if unknown.
376
     *\param bytes_done the amount of bytes received from the server
377
     *\param bytes_per_sec the average data rate in bytes per seconds
378
     *\param net_status the session status
379
     */
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
380
    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, GF_NetIOStatus *net_status);
381
382
    /*!
383
     *\brief get start time
384
     *
385
     *Gets session start time in UTC. If chunk-transfer is used, the start time is reset at each chunk start
386
     *\param sess the download session
387
     *\return UTC start time
388
     */
389
    u64 gf_dm_sess_get_utc_start(GF_DownloadSession *sess);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
390
391
392
    /*!
393
     *\brief fetch session object
394
     *
395
     *Fetch the session object (process all headers and data transfer). This is only usable if the session is not threaded
396
     *\param sess the download session
397
     *\return the last error in the session or 0 if none*/
398
    GF_Err gf_dm_sess_process(GF_DownloadSession * sess);
399
400
    /*!
401
     *\brief fetch session object headers
402
     *
403
     *Fetch the session object headers and stops after that. This is only usable if the session is not threaded
404
     *\param sess the download session
405
     *\return the last error in the session or 0 if none*/
406
    GF_Err gf_dm_sess_process_headers(GF_DownloadSession * sess);
407
408
    /*!
409
     *\brief fetch session status
410
     *
411
     *Fetch the session current status
412
     *\param sess the download session
413
     *\return the session status*/
414
	u32 gf_dm_sess_get_status(GF_DownloadSession * sess);
415
	/*!
416
     *\brief Get session resource url
417
     *
418
     *Returns the original resource URL associated with the session
419
     *\param sess the download session
420
     *\return the associated URL
421
     */
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
422
    const char *gf_dm_sess_get_resource_name(GF_DownloadSession *sess);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
423
    /*!
424
     *\brief Get session original resource url
425
     *
426
     *Returns the original resource URL before any redirection associated with the session
427
     *\param sess the download session
428
     *\return the associated URL
429
     */
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
430
    const char *gf_dm_sess_get_original_resource_name(GF_DownloadSession *sess);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
431
	
432
433
    /*!
434
     * \brief Download a file over the network using a download manager
435
     * \param dm The downlaod manager to use, function will use all associated cache ressources
436
     * \param url The url to download
437
     * \param filename The filename to download
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
438
     * \param start_range start position of a byte range
439
     * \param end_range end position of a byte range
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
440
     * \return GF_OK if everything went fine, an error otherwise
441
     */
442
    GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm,
1.2.1 by Alessio Treglia
Import upstream version 0.5.0+svn4288~dfsg1
443
                                const char *url, const char *filename, u64 start_range, u64 end_range);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
444
445
    /*!
446
     * \brief Same as gf_dm_wget_with_cache, but initializes the GF_DownloadManager by itself.
447
     * This function is deprecated, please use gf_dm_wget_with_cache instead
448
     * \param url The url to download
449
     * \param filename The filename to download
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
450
     * \param start_range start position of a byte range
451
     * \param end_range end position of a byte range
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
452
     * \return GF_OK if everything went fine, an error otherwise
453
     */
1.2.1 by Alessio Treglia
Import upstream version 0.5.0+svn4288~dfsg1
454
    GF_Err gf_dm_wget(const char *url, const char *filename, u64 start_range, u64 end_range);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
455
456
    /*!
457
     *\brief Reset session
458
     *
459
     *Resets the session for new processing of the same url
460
     *\param sess the download session
461
     *\return error code if any
462
     */
463
    GF_Err gf_dm_sess_reset(GF_DownloadSession *sess);
464
465
    /*!
466
     * \brief forces the refresh of a cache entry
467
     * The entry is still allocated in the session.
468
     * \param sess The session
469
     * \return a pointer to the entry of session refreshed
470
     */
471
    DownloadedCacheEntry gf_dm_refresh_cache_entry(GF_DownloadSession *sess);
472
    
473
    /*!
474
     * Tells whether session can be cached on disk.
475
     * Typically, when request has no content length, it deserves being streamed an cannot be cached
476
     * (ICY or MPEG-streamed content
477
     * \param sess The session
478
     * \return True if a cache can be created
479
     */
480
    Bool gf_dm_sess_can_be_cached_on_disk(const GF_DownloadSession *sess);
481
482
483
    /*!
484
     * Reassigns session flags and callbacks. This is only possible if the session is not threaded.
485
	 * \param sess The session
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
486
	 * \param flags The new flags for the session - if flags is 0xFFFFFFFF, existing flags are not modified
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
487
	 * \param user_io The new callback function
488
	 * \param cbk The new user data to ba used in the callback function
489
     * \return GF_OK or error
490
     */
491
	GF_Err gf_dm_sess_reassign(GF_DownloadSession *sess, u32 flags, gf_dm_user_io user_io, void *cbk);
492
493
    /*!
494
     * Re-setup an existing, completed session to download a new URL. If same server/port/protocol is used, the same socket will be reused if the session
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
495
	 * has the GF_NETIO_SESSION_PERSISTENT flag set. This is only possible if the session is not threaded.
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
496
	 * \param sess The session
497
	 * \param url The new url for the session 
498
     * \return GF_OK or error
499
     */
500
	GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url);
501
502
    /*
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
503
     *\retrieves the HTTP header value for the given name
504
     *
505
     *Retrieves the HTTP header value for the given header name.
506
     *\param sess the current session
507
     *\param name the target header name
508
     * \return header value or NULL if not found
509
	 */
510
	const char *gf_dm_sess_get_header(GF_DownloadSession *sess, const char *name);
511
512
    /*
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
513
     *\brief sets download manager max rate per session
514
     *
515
     *Sets the maximum rate (per session only at the current time). 
516
     *\param dm the download manager object
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
517
     *\param rate_in_bits_per_sec the new rate in bits per sec. If 0, HTTP rate will not be limited
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
518
     */
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
519
    void gf_dm_set_data_rate(GF_DownloadManager *dm, u32 rate_in_bits_per_sec);
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
520
521
    /*
522
     *\brief gets download manager max rate per session
523
     *
524
     *Sets the maximum rate (per session only at the current time). 
525
     *\param dm the download manager object
1.2.2 by Reinhard Tartler
Import upstream version 0.5.0+svn5104~dfsg1
526
     *\return the rate in bits per sec. If 0, HTTP rate is not limited
1 by Andres Mejia
Import upstream version 0.4.5+svn3450~dfsg3
527
     */
528
    u32 gf_dm_get_data_rate(GF_DownloadManager *dm);
529
530
531
    /*
532
     *\brief fetches remote file in memory
533
     *
534
     *Fetches remote file in memory . 
535
     *\param url the data to fetch 
536
     *\param out_data output data (allocated by function)
537
     *\param out_size output data size
538
     *\param out_mime if not NULL, pointer will contain the mime type (allocated by function)
539
     *\return error code if any
540
     */
541
	GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, char **out_mime);
542
	/*! @} */
543
544
#ifdef __cplusplus
545
}
546
#endif
547
548
549
#endif		/*_GF_DOWNLOAD_H_*/
550