http_file.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 87 行
H
87 行
/*******************************************************************
*
* Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
*
* Description:
*
* Author: LiChao
* Created: Thu Aug 26 2005
*
*******************************************************************/
#ifndef _HTTP_FILE_H_
#define _HTTP_FILE_H_
/**
* @brief This is a call back function for WMC file read. Because WMC file is on server, it don't like
* local file, we can read any data in a constant time, we cannot know how long time to receive the request
* data from WMC server. So we design this call back function, when we call http_file_get_data to read
* data from WMC server, if request data in system buffer, return it at once; otherwise send request to
* WMC server and return failure at once. When the system receive the data from WMC server, system will
* call this call back function to wake up the user blocked read process.
* @param [in] buf_addr the data pointer which user requested by http_file_get_data.
* @param [in] len the return data length.
* @param [in] arg the callback argument.
*/
typedef void (*HTTP_FILE_CB)(void *buf_addr, int len, unsigned arg) ;
/**
* @brief Following struct is basic information to store the UPnP http download information.
* It'll saved read offset and current download buffer size and download offset for http_file_read.
*/
typedef struct http_file_s http_file_t ;
/**
* Open a media file which got by UPnP protocal and download by http protocal.
* @param [in] file_uri the URL of download media file.
* @param [in] buffer_size The amount of data to buffer.
* @param [in] callback User callback, check user operation during reading data.
*
* @returns handle of http connection when success, otherwise NULL.
*/
http_file_t* http_file_open(char *file_uri, unsigned buffer_size, unsigned callback) ;
/**
* Get the address of the \a pbuf buffer chain for \a http_file_t.
*/
extern int
http_file_get_chain(http_file_t* file_handle, struct pbuf **pbuf,
int len);
/**
* @brief Same as http_file_read, just don't copy to user buf, only return data point.
* @param [in] file_handle Define the handle of the media file we want to read.
* @param [out] buf_addr return the data point which user want to get.
* @param [in|out] len Read size(bytes) as input parameter, and reuturn actural read size as output parameter.
* if actural read size less than request size and biger than -1, that means end of file.
* if return size is -1, that means read file error.
* @param [in] async_cb If DATA_NOT_READY, we will send data request to http server, when we get the data, we'll
* call the call back function to notify user data is ready.
* @param [in] async_cb_arg argument for async_cb.
*
* @returns -2 if len > file_buffer_size;
* -1(DATA_NOT_READY) if not more data to read.
* 0 success(DATA_READY).
*/
int http_file_get_data(http_file_t* file_handle, char **buf_addr, int len);
/**
* Allow user set read offset of media file.
* @param [in] file_handle Define the handle of the media file we want to set read offset.
* @param [in] offset Define data of read offset.
* @param [in] fromwhere If fromwhere is 0, seek from current offset. if fromwhere is 2, from the
* begining of file.
*
* @returns -1 if failed, otherwise 0.
*/
int http_file_seek(http_file_t* file_handle, long offset, int fromwhere);
/**
* Close a download media file and free all relate resource.
* @param [in] file_handle Define the handle of the media file we want to close.
*
* @returns -1 if failed, otherwise 0.
*/
int http_file_close(http_file_t* file_handle) ;
#endif//_HTTP_FILE_H_
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?