/*! \file
 * \brief StreamingDataFrame.
 *
 * \copyright
 * COPYRIGHT NOTICE: (c) 2017-2022 Neonode Technologies AB. All rights reserved.
 */

#ifndef DATAFRAME_STREAMINGDATAFRAME_H
#define DATAFRAME_STREAMINGDATAFRAME_H 1

#ifndef ZFORCECOMMON_H
    #error Please include "zForceCommon.h" before this file.
#endif // ZFORCECOMMON_H

/*!
 * \sa struct StreamingDataFrame
 */
typedef struct StreamingDataFrame StreamingDataFrame;
/*!
 * \brief Struct containing the StreamingDataFrame information.
 *
 * StreamingDataFrame contains the DataFrame base, a pointer to the data and its length.
 */
struct StreamingDataFrame
{
    /*!
    * \brief A string pointer to the type of DataFrame.
    *
    * A string pointer to the type of DataFrame.
    * For now the only type is Streaming. In the future we can have more types.
    * \n\n
	* Inherited from DataFrame base class.
    */
    char       * DataFrameType;
    /*!
     * \brief A Connection pointer that associates the DataFrame with the Connection.
     *
     * A Connection pointer that associates the DataFrame with the Connection.
     * \n\n
     * Inherited from DataFrame base class.
     */
    Connection * Connection;
    /*!
     * \brief Relative timeout in MilliSeconds.
     *
     * Relative timeout in MilliSeconds.
     * \n\n
     * Inherited from DataFrame base class.
     */
    uint64_t     RelativeTimeoutMilliSeconds;
    /*!
     * \brief Destructor for StreamingDataFrame.

     * Destructor for StreamingDataFrame. Frees up StreamingDataFrame's allocated memory.
     * Inherited from DataFrame base class.
     *
     * \param self Pointer to the struct itself.
     *
     * \return Returns nothing.
     */
    void (* Destructor) (DataFrame * self);

    uint8_t * Data;   //!< Pointer to the data.
    uint32_t  Length; //!< Length of the data.
};

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

/*!
 * \brief Create a new StreamingDataFrame.
 *
 * Creates a new streaming data frame and all the resources needed.
 * \n\n
 * On failure, errno is set.
 * - ::EOUTOFMEMORY - Memory allocation failed.
 *
 * \return Return a pointer to the allocated StreamingDataFrame upon success,
 *         otherwise a NULL pointer is returned and errno is set accordingly.
 */
DLLEXTERNAL StreamingDataFrame * StreamingDataFrame_New (uint64_t relativeTimeoutMilliSeconds, uint32_t length);

#ifdef __cplusplus
}
#endif // __cplusplus

/*!
 * \brief The streaming DataFrameType.
 */
#define STREAMINGDATAFRAMETYPE "Streaming"

#endif // DATAFRAME_STREAMINGDATAFRAME_H
