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

« back to all changes in this revision

Viewing changes to include/gpac/download.h

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2014-02-22 18:15:00 UTC
  • mfrom: (1.2.2) (3.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140222181500-b4phupo05gjpmopa
Tags: 0.5.0+svn5104~dfsg1-1
* New  upstream version 0.5.0+svn5104~dfsg1:
  - src/utils/sha1.c is relicensed under LGPLv2.1, Closes: #730759
* Don't install modules in multi-arch directories, Closes: #730497
* Add libusb-1.0.0-dev headers because libfreenect requires this
* Fix install rule
* Follow upstream soname bump
  - Drop the symbols file for now until it has been revised thourougly
* Let binaries produce the correct svn revision
* Refresh patches
* Patch and build against libav10, Closes: #739321
* Bump standards version, no changes necessary

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
#include <gpac/cache.h>
53
53
 
54
54
 
55
 
    /*!the download manager object. This is usually not used by GPAC modules*/
 
55
        /*!the download manager object. This is usually not used by GPAC modules*/
56
56
    typedef struct __gf_download_manager GF_DownloadManager;
57
57
    /*!the download manager session.*/
58
58
    typedef struct __gf_download_session GF_DownloadSession;
67
67
        u16 port;
68
68
    } GF_URL_Info;
69
69
 
70
 
    /*!
 
70
        /*!
71
71
     * Extracts the information from an URL. A call to gf_dm_url_info_init() must have been issue before calling this method.
72
72
     * \param url The URL to fill
73
73
     * \param info This structure will be initialized properly and filled with the data
130
130
    void gf_dm_set_auth_callback(GF_DownloadManager *dm, gf_dm_get_usr_pass get_pass, void *usr_cbk);
131
131
 
132
132
    /*!downloader session message types*/
133
 
    enum
 
133
    typedef enum
134
134
    {
135
135
        /*!signal that session is setup and waiting for connection request*/
136
136
        GF_NETIO_SETUP = 0,
156
156
        GF_NETIO_DISCONNECTED,
157
157
        /*!downloader session failed (error code set) or done/destroyed (no error code)*/
158
158
        GF_NETIO_STATE_ERROR
159
 
    };
 
159
    } GF_NetIOStatus;
160
160
 
161
161
    /*!session download flags*/
162
162
    enum
191
191
        const char *name;
192
192
        /*protocol header value or server response. Only alid for GF_NETIO_GET_HEADER, GF_NETIO_PARSE_HEADER and GF_NETIO_PARSE_REPLY*/
193
193
        char *value;
194
 
        /*response code - only valid for GF_NETIO_PARSE_REPLY*/
 
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
                */
195
201
        u32 reply;
 
202
        /*download session for which the message is being sent*/
 
203
                GF_DownloadSession *sess;
196
204
    } GF_NETIO_Parameter;
197
205
 
198
206
    /*!
227
235
     *\brief download session simple constructor
228
236
     *
229
237
     *Creates a new download session
 
238
     *\param dm The download manager used to create the download session
230
239
     *\param url file to retrieve (no PUT/POST yet, only downloading is supported)
231
240
     *\param dl_flags combination of session download flags
232
241
     *\param user_io \ref gf_dm_user_io callback function for data reception and service messages
233
242
     *\param usr_cbk opaque user data passed to callback function
234
 
     *\param cache_name cache name
235
 
     *\param error error for failure cases
 
243
     *\param e error for failure cases
236
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
237
245
     */
238
246
    GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *url, u32 dl_flags,
321
329
     *\param sess the download session
322
330
     *\param start_range HTTP download start range in byte 
323
331
     *\param end_range HTTP download end range in byte 
324
 
     *\param discontinue If set, forces a new cache entry if byte range are not continuous. Otherwise a single cache entry is used to reconstruct the file
 
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
325
333
     *\note this can only be used when the session is not threaded
326
334
     */
327
335
        GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_range, Bool discontinue_cache);
335
343
 
336
344
    /*!
337
345
     * \brief Marks the cache file to be deleted once the file is not used anymore by any session
338
 
     * \param entry The cache entry to delete
 
346
     * \param dm the download manager
 
347
     * \param url The URL associate to the cache entry to be deleted
339
348
     */
340
349
    void gf_dm_delete_cached_file_entry(const GF_DownloadManager * dm, const char * url);
341
350
 
342
351
    /*!
343
352
     * Convenience function
344
353
     * \see gf_dm_delete_cached_file_entry
 
354
     *\param sess the download session
 
355
     * \param url The URL associate to the cache entry to be deleted
345
356
     */
346
 
    void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * dm, const char * url);
 
357
    void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * sess, const char * url);
347
358
 
348
359
    /*!
349
360
     * Get a range of a cache entry file
350
 
     * \param entry The session
 
361
     * \param sess The session
351
362
     * \param startOffset The first byte of the request to get
352
363
     * \param endOffset The last byte of request to get
353
364
     * \return The temporary name for the file created to have a range of the file
366
377
     *\param bytes_per_sec the average data rate in bytes per seconds
367
378
     *\param net_status the session status
368
379
     */
369
 
    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);
 
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);
370
390
 
371
391
 
372
392
    /*!
399
419
     *\param sess the download session
400
420
     *\return the associated URL
401
421
     */
402
 
    const char *gf_dm_sess_get_resource_name(GF_DownloadSession *dnload);
 
422
    const char *gf_dm_sess_get_resource_name(GF_DownloadSession *sess);
403
423
    /*!
404
424
     *\brief Get session original resource url
405
425
     *
407
427
     *\param sess the download session
408
428
     *\return the associated URL
409
429
     */
410
 
    const char *gf_dm_sess_get_original_resource_name(GF_DownloadSession *dnload);
 
430
    const char *gf_dm_sess_get_original_resource_name(GF_DownloadSession *sess);
411
431
        
412
432
 
413
433
    /*!
415
435
     * \param dm The downlaod manager to use, function will use all associated cache ressources
416
436
     * \param url The url to download
417
437
     * \param filename The filename to download
 
438
     * \param start_range start position of a byte range
 
439
     * \param end_range end position of a byte range
418
440
     * \return GF_OK if everything went fine, an error otherwise
419
441
     */
420
442
    GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm,
425
447
     * This function is deprecated, please use gf_dm_wget_with_cache instead
426
448
     * \param url The url to download
427
449
     * \param filename The filename to download
 
450
     * \param start_range start position of a byte range
 
451
     * \param end_range end position of a byte range
428
452
     * \return GF_OK if everything went fine, an error otherwise
429
453
     */
430
454
    GF_Err gf_dm_wget(const char *url, const char *filename, u64 start_range, u64 end_range);
459
483
    /*!
460
484
     * Reassigns session flags and callbacks. This is only possible if the session is not threaded.
461
485
         * \param sess The session
462
 
         * \param flags The new flags for the session 
 
486
         * \param flags The new flags for the session - if flags is 0xFFFFFFFF, existing flags are not modified
463
487
         * \param user_io The new callback function
464
488
         * \param cbk The new user data to ba used in the callback function
465
489
     * \return GF_OK or error
468
492
 
469
493
    /*!
470
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
471
 
         has the @GF_NETIO_SESSION_PERSISTENT flag set. This is only possible if the session is not threaded.
 
495
         * has the GF_NETIO_SESSION_PERSISTENT flag set. This is only possible if the session is not threaded.
472
496
         * \param sess The session
473
497
         * \param url The new url for the session 
474
498
     * \return GF_OK or error
476
500
        GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url);
477
501
 
478
502
    /*
 
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
    /*
479
513
     *\brief sets download manager max rate per session
480
514
     *
481
515
     *Sets the maximum rate (per session only at the current time). 
482
516
     *\param dm the download manager object
483
 
     *\param rate_in_byte_per_sec the new rate in bytes per sec. If 0, HTTP rate will not be limited
 
517
     *\param rate_in_bits_per_sec the new rate in bits per sec. If 0, HTTP rate will not be limited
484
518
     */
485
 
    void gf_dm_set_data_rate(GF_DownloadManager *dm, u32 rate_in_byte_per_sec);
 
519
    void gf_dm_set_data_rate(GF_DownloadManager *dm, u32 rate_in_bits_per_sec);
486
520
 
487
521
    /*
488
522
     *\brief gets download manager max rate per session
489
523
     *
490
524
     *Sets the maximum rate (per session only at the current time). 
491
525
     *\param dm the download manager object
492
 
     *\return the rate in bytes per sec. If 0, HTTP rate is not limited
 
526
     *\return the rate in bits per sec. If 0, HTTP rate is not limited
493
527
     */
494
528
    u32 gf_dm_get_data_rate(GF_DownloadManager *dm);
495
529