http_app.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 169 行
H
169 行
/*****************************************************************
** **
** Copyright (C) 2004 Amlogic,Inc. **
** All rights reserved **
** Filename : http_app.h /Project:AVOS **
** Revision : 1.0 **
** Author: lichao **
** **
*****************************************************************/
#ifndef __HTTP_APP_H_
#define __HTTP_APP_H_
/**
* @file http_app.h
* @author LiChao, chao_li@amlogic.com.cn
*
* This is the HTTP downlaod application program. It have resume download function.
*
*/
/** @defgroup http_app HTTP application.
* @ingroup Application
*/
extern char gHttpSysDir[];
extern char gDownLoadDir[];
#define DOWNLOAD_BLOCK_NUM_MODE 1
#define DOWNLOAD_BLOCK_SIZE_MODE 2
#define DOWNLOAD_NONE_BLOCK_MODE 3
#define HTTP_INFO_SYNC 0x7319dc25
#define HTTP_DOWNLOAD_READY 0x01
#define HTTP_DOWNLOAD_RUNNING 0x02
#define HTTP_DOWNLOAD_PAUSE 0x03
#define HTTP_DOWNLOAD_FAIL 0x10
#define HTTP_DOWNLOAD_DONE 0x20
#define HTTP_DOWNLOAD_FREE 0x30
#define HTTP_DOWNLOAD_CANCEL 0x40
#define HTTP_DOWNLOAD_ENTRY_FREE 0xf0
#define DOWNLOAD_FILE_NAME_LENGTH 224
#define DOWNLOAD_URL_LENGTH 256
/**
* @brief Following struct is basic information to store the download information. It'll saved
* to HD or other place to keep these information to do resume download.
*/
typedef struct{
///Store a special magic data to identify this is a HTTP download resume information.
INT32U http_info_async ;
///the position in resume configure file
INT32U offset ;
///the HTTP server port of this download connection
INT16U host_port;
///save the download mode of this connection.
INT8U download_mode;
///to save the connection's status, like HTTP_DOWNLOAD_READY, HTTP_DOWNLOAD_RUNNING, ect.
INT8U download_flag;
///save the download parameter, see HTTPSetDownloadMode
INT32U download_parameter;
///the file size of this download file.
INT32U file_size ;
///the size already downloaded.
INT32U download_size ;
///define the start offset of this download connection.
INT32U download_block_start_pos;
///define the end offset of this download connection.
INT32U download_block_end_pos ;
///save the download server address and download file.
///the format must like: 10.18.1.75/index.html or www.sina.com/index.html
char download_url[DOWNLOAD_URL_LENGTH];
/// Host name part of the URL
char download_host[DOWNLOAD_URL_LENGTH];
///save the download file local save path.
char download_file[DOWNLOAD_FILE_NAME_LENGTH] ;
} HTTP_DOWNLOAD_INFO;
/**
* Allow user set the download configure file dir
* @param [in] sys_dir define the dir of configure file, default dir is "/mnt/C".
*
* @returns -1 if cannot access or create the dir, otherwise 0.
*/
INT32S HTTPSetSysDir(const char *sys_dir) ;
/**
* Allow user set the dir for all download file
* @param [in] download_dir define the dir of downlaod file, default dir is "/mnt/C".
*
* @returns -1 if cannot access or create the dir, otherwise 0.
*/
INT32S HTTPSetDownloadDir(const char *download_dir);
/**
* Allow user define the download mode and parameters for HTTP
* @param [in] auto_download configured if later HTTP Download should be auto start if system restart
* @param [in] download_mode set later HTTP download mode, default is DOWNLOAD_BLOCK_NUM_MODE.
* @param [in] download_parameter if set download_mode to DOWNLOAD_BLOCK_NUM_MODE, this parameter
* define the block num which download file should be devided. If set download_mode to
* DOWNLOAD_BLOCK_SIZE_MODE, this parameter define the size of every block.
*
* @returns -1 if any error, otherwise 0.
*/
INT32S HTTPSetDownloadMode(INT8U auto_download, INT8U download_mode, INT32U download_parameter) ;
/**
* Allow user to get current first download file's download porcess information.
*
* @returns return NULL if there are not any download file running. Otherwise return
* the first download file information.
*/
HTTP_DOWNLOAD_INFO* HTTPGetFirstDownloadInfo(void);
/**
* Allow user to get current next download file's download porcess information.
*
* @returns return NULL if there are not any download file running. Otherwise return
* the next download file information. You can call HTTPGetFirstDownloadInfo first, then
* loop call this function until return NULL to get all download information.
*/
HTTP_DOWNLOAD_INFO* HTTPGetNextDownloadInfo(void);
/**
* Allow user to set the HTTP server listen port to a special port.
* @param [in] port the port will be used later. Default port is 80.
*/
void HTTPSetServerPort(INT16U port);
/**
* @brief Set the notification frequence of downloading.
* When we download a block data(normally the size is 0x8000), we'll send a notification message --
* NM_HTTP_DOWNLOAD_INFO to customer code to update the download process bar. But if we send this
* message to frequently, that will waste too much time. So we can set this frequence to control it.
* @param [in] notify_rate the rate of send notification message. If it's 0, that means we never
* send notification message during download. Default rate is 1.
*/
void HTTPSetNotifyRate(INT8U notify_rate);
/**
* @brief The main function of HTTP application, receive and execute command from customize code.
*
* Following is the commnads HTTP application support:
* CM_PLAY This command is prepare to download a file from server. It need a parameter -- downlad url
* string, the string format must like: "10.18.1.75/index.html" or "www.sina.com/index.html"
*
* CM_STOP This command will cancel a download file which added by CM_PLAY command. This command need
* a parameter too, the cancel url string, the string format same as CM_PLAY command parameter.
*
* CM_PAUSE This command will pause a download file which added by CM_PLAY command. This command need
* a parameter too, the pause url string, the string format same as CM_PLAY command parameter. When you
* want to resume a paused download file, just send CM_PLAY command again.
*
* CM_QUIT This command means the HTTP application will quit when we power off the IP-Box or in other case.
* This command will close all http connection and save their information. No parameter.
*
* During the HTTP application running, it'll send some notification message back, like
* NM_END_OF_PLAY This notification message told customer that one download file have done. No parameter.
*
* NM_HTTP_DOWNLOAD_FAIL This notification message told customer that one download failed because some
* error. No parameter.
*/
void HTTPTaskProcess(void *opt) ;
void HTTPAppGetInfo(void* pInfo) ;
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?