/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file x_dlna_dmr_fm.h
*  $RCSfile: $
*  $Revision: #1 $
*  $Date: 2015/05/29 $
*  $Author: brianpc.huang $
*  
*  @par Description:
*         This header file contains DLNA DMR file manager exported API.
*/
/*----------------------------------------------------------------------------*/

/*!
* @addtogroup  groupMW_INET_DLNA
* @brief       Provide an external API about DLNA.
* %DLNA API would be used by user who wants to play media stream in local network  
* 
* @see 
*
* @{
* */


#ifndef X_DLNA_DMR_FM_H
#define X_DLNA_DMR_FM_H

#include "x_fm.h"
#include "u_dlna_dmr.h"

/**     
 * Transport layer API
 */
/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_open(CHAR * ps_uri, CHAR * ps_protocol, INT32 *pi4_fd)
*  @brief  Opens a URI looks like a local file
*          - Called while who wants to get a object in DMS
*  @param  [in]ps_uri            - The object URI
*  @param  [in]ps_protocol       - The object protocol info
*  @param  [out]pi4_fd           - The file handle 
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK          - The routine was successful. 
*  @retval FMR_FAIL        - Open object failed.
*  @retval FMR_DEVICE_ERROR       - The DMS error 
*  @retval FMR_NOT_ENOUGH_SPACE   - The memory not enough
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_open(CHAR * ps_uri, CHAR * ps_protocol, INT32 *pi4_fd);



/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_close(INT32 i4_fd)
*  @brief  Closes the object file handle
*          - Called while who wants to close the file handle
*  @param  [in]i4_fd           - The file handle 
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK          - The routine was successful. 
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_close(INT32 i4_fd);


/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_read(INT32 i4_fd, VOID *pv_data, UINT32 ui4_count, UINT32 *ui4_read)
*  @brief  Reads the object
*          - Called while who wants to get a object data in DMS
*  @param  [in]i4_fd           - The file handle 
*  @param  [in][out]pv_data    - The data buffer
*  @param  [in]ui4_count       - The buffer size 
*  @param  [out]i4_read        - The reading data size
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK                 - The routine was successful. 
*  @retval FMR_FAIL               - Open object failed.
*  @retval FMR_BUSY               - The DMS too busy to respond
*  @retval FMR_DEVICE_ERROR       - The DMS error 
*  @retval FMR_NOT_ENOUGH_SPACE   - The memory not enough
*  @retval FMR_EOF                - The file has already read to end
*  @retval FMR_NOT_INIT           - The handle may be closed
*  @retval FMR_CMD_TIMEOUT        - Read time out
*  @retval FMR_INVAL              - DRM failed  
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_read(INT32 i4_fd, VOID *pv_data, UINT32 ui4_count, UINT32 *ui4_read);



/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_read_async(INT32 i4_fd, VOID *pv_data, UINT32 ui4_count, UINT8 ui1_pri, x_fm_async_fct pf_nfy_fct, VOID *pv_tag, INT32 *pi4_req)
*  @brief  Reads the object asynchronism
*          - Called while who wants to get a object data in DMS
*  @param  [in]i4_fd           - The file handle 
*  @param  [in][out]pv_data    - The data buffer
*  @param  [in]ui4_count       - The buffer size 
*  @param  [in]ui1_pri         - The read priority 
*  @param  [in]pf_nfy_fct      - The callback function
*  @param  [in]pv_tag          - the callback tag 
*  @param  [out]pi4_req        - The request handle
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK                 - The routine was successful. 
*  @retval FMR_FAIL               - Open object failed.
*  @retval FMR_BUSY               - The DMS too busy to respond
*  @retval FMR_DEVICE_ERROR       - The DMS error 
*  @retval FMR_NOT_ENOUGH_SPACE   - The memory not enough
*  @retval FMR_EOF                - The file has already read to end
*  @retval FMR_NOT_INIT           - The handle may be closed
*  @retval FMR_CMD_TIMEOUT        - Read time out
*  @retval FMR_INVAL              - DRM failed  
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_read_async(INT32 i4_fd, VOID *pv_data, UINT32 ui4_count, UINT8 ui1_pri, x_fm_async_fct pf_nfy_fct, VOID *pv_tag, INT32 *pi4_req);



/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_abort_async(INT32 i4_fd)
*  @brief  Aborts the read action asynchronism
*          - Called while who wants to abort the read action
*  @param  [in]i4_fd           - The file request handle 
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK                 - The routine was successful. 
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_abort_async(INT32 i4_fd);

/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_seek(INT32 i4_fd, INT64 i8_offset, UINT8 ui1_whence, UINT64 *pui8_cur_pos)
*  @brief  Seeks file position
*          - Called while who wants to seek object file
*  @param  [in]i4_fd               - The file handle 
*  @param  [in]i8_offset           - The offset
*  @param  [in]ui1_whence          - The whence    
*  @param  [out]pui8_cur_pos       - The current position 
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK                 - The routine was successful.
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_seek(INT32 i4_fd, INT64 i8_offset, UINT8 ui1_whence, UINT64 *pui8_cur_pos);
extern INT32 x_dlna_http_client_time_seek(INT32 i4_fd, UINT64 i8_time_start, UINT64 i8_time_length);
/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_eof(INT32 i4_fd)
*  @brief  Checks the file is read to end.
*          - Called while who wants to check the file handle
*  @param  [in]i4_fd           - The file handle 
*  
*  @note   
*  @see      
*  @return Return the value                
*  @retval 0                 - The file is not EOF.
*  @retval 1                 - The file is EOF 
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_eof(INT32 i4_fd);


/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_file_size(INT32 i4_fd, UINT64 *pui8_size)
*  @brief  Gets the file size
*          - Called while who wants to get the file size
*  @param  [in]i4_fd               - The file handle    
*  @param  [out]pui8_size          - The file size 
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK                 - The routine was successful.
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_file_size(INT32 i4_fd, UINT64 *pui8_size);


/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_get_seek_type(INT32 i4_fd, DLNA_SEEK_TYPE_T * pe_type)
*  @brief  Gets the file seek type
*          - Called while who wants to get the file seek type
*  @param  [in]i4_fd               - The file handle    
*  @param  [out]pe_type            - The file seek type 
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK                 - The routine was successful.
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_get_seek_type(INT32 i4_fd, DLNA_SEEK_TYPE_T * pe_type);

/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_is_stalling_supported(INT32 i4_fd, BOOL *b_stalling)
*  @brief  Check if connection stalling is supported
*  @param  [in]i4_fd               - The file handle    
*  @param  [out]b_stalling         - Stalling flag
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval FMR_OK                 - The routine was successful.
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_is_stalling_supported(INT32 i4_fd, BOOL *pb_stalling);

/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_set_wmdrm_session_id(INT32 i4_fd, UINT8 * pui1_session_id, UINT32 ui4_length)
*  @brief  Sets the object WMDRM session id
*          - Called while who wants to set object WMDRM session id
*  @param  [in]i4_fd            - The file handle
*  @param  [in]pui1_session_id  - The WMDRM session id data
*  @param  [in]ui4_length       - the id data length
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval DLNAR_OK          - The routine was successful. 
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_set_wmdrm_session_id(INT32 i4_fd, UINT8 * pui1_session_id, UINT32 ui4_length);


/*----------------------------------------------------------------------------*/
/*! @fn    INT32 x_dlna_dmr_fm_get_drm_type(INT32 i4_fd, DLNA_DRM_TYPE_T * pe_type)
*  @brief  Gets the object DRM type
*          - Called while who wants to get the device DRM type
*  @param  [in]i4_fd            - The file handle
*  @param  [out]pe_type         - The device DRM type
*  
*  @note   
*  @see      
*  @return Return the error code                
*  @retval DLNAR_OK          - The routine was successful. 
*/
/*----------------------------------------------------------------------------*/
extern INT32 x_dlna_dmr_fm_get_drm_type(INT32 i4_fd, DLNA_DRM_TYPE_T *pe_type);

#endif

/*! @} */

