/* 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.
 *
 *****************************************************************************/

#ifndef _X_FM_DLNAFS_H_
#define _X_FM_DLNAFS_H_

#include "u_fm_dlnafs.h"


/*-----------------------------------------------------------------------------
                    include files
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
                    data declarations
 ----------------------------------------------------------------------------*/


/*-----------------------------------------------------------------------------
                    functions declarations
 ----------------------------------------------------------------------------*/
INT32 x_fm_dlna_dms_init(VOID*   pv_data);

INT32 x_dlna_dmp_fm_get_media_info(CHAR *ps_filename, DLNA_MEDIA_INFO_T *pt_info);

INT32 x_fm_dlna_orderby(CHAR * ps_filename, DLNA_ORDERBY_TYPE_T e_orderby, BOOL b_override);

INT32  x_fm_dlna_set_browse_recursive(CHAR* ps_filename, BOOL b_recursive);

INT32  x_fm_dlna_set_browse_file_ext(CHAR * ps_filename, CHAR * ps_ext_name);

INT32  x_fm_dlna_set_content_filter(CHAR * ps_filename, DLNA_FILE_CONTENT_TYPE_T e_browse_type);

BOOL x_fm_dlna_is_folder_sorting_supported(CHAR * ps_filename);

BOOL x_fm_dlna_is_folder_changed(CHAR * ps_dir_name);

CHAR * x_fm_dlna_dmr_get_file_path(CHAR* ps_uri, CHAR* ps_protocol);

extern BOOL x_fm_dlna_is_pause_supported(CHAR * ps_media_name);

BOOL x_fm_dlna_is_multiconnection_supported(CHAR * ps_media_name);


/**
 * Get DLNA file seek type
 * There are two seek method in DLNA: Byte-based and Time-based seek
 * Byte-based seek: Seek offset is measured by byte - x_fm_lseek
 * Time-based seek: Seek offset is measured by time (second) - x_fm_dlna_time_seek
 * DLNA file may support only one of them or both of them
 *
 * @param ps_filepath, file full path
 * @param pt_seek, seek ablity
 *
 * @return INT32
 * FMR_OK, ok
 * 
*/

INT32 x_fm_dlna_get_seek_type(const CHAR *ps_filepath, DLNAFS_SEEK_CAP_T * pt_seek);

/**
 * Seek current file access time position as user specified
 * 
 * @param i4_fd, file handle
 * @param i8_time_start, time seek start time, eg. 5s
 * @param i8_time_length, time seek length, eg. 60s, or 0 (to the end of file). It's time length, not end time.
 * 
 * @return INT32
 * FMR_OK, ok
 * FMR_HANDLE, Fail to get the handle object.
 * FMR_INVAL, error
 */

INT32 x_fm_dlna_time_seek(HANDLE_T h_file, UINT64 ui8_time_start, UINT64 ui8_time_length);

/**
 * Check if Connection-Stalling is supported for this file
 * if result is true, that is good, no need to do anything
 * if result is false, we need to close file handle during pause and slow forward operation, then open a new handle when resume
 *
 * @param ps_filepath, file full path
 * @param pb_stalling, result
 *
 * @return INT32
 * FMR_OK, ok
 * 
*/

INT32 x_fm_dlna_is_stalling_supported(const CHAR *ps_filepath, BOOL *pb_stalling);

#endif /* _X_FM_DLNAFS_H_ */
