From 60f60cc76e43197a0825ffac9aff0b7007a94175 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 20 Nov 2013 12:57:17 +0100 Subject: Framework API now complete in its first iteration. So far with support for raw, opus and amrwb. --- src/lrtp.h | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'src/lrtp.h') diff --git a/src/lrtp.h b/src/lrtp.h index 7428997..ce6b0e2 100644 --- a/src/lrtp.h +++ b/src/lrtp.h @@ -27,4 +27,108 @@ */ #ifndef __LRTP_LRTP_H__ #define __LRTP_LRTP_H__ + +#ifdef WIN32 +#ifdef BUILD_DLL +/* DLL export */ +#define EXPORT __declspec(dllexport) +#else +/* EXE import */ +#define EXPORT __declspec(dllimport) +#endif +#else +#define EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "lrtp_profiles.h" + +struct lrtp_t; + +EXPORT +struct lrtp_t *lrtp_init(const char *key, unsigned int ssrc); + +EXPORT +void lrtp_close(struct lrtp_t *lrtp); + +struct lrtp_profile_t; + +/** + * @param ... + */ +EXPORT +struct lrtp_profile_t *lrtp_create_profile(struct lrtp_t *lrtp, + lrtp_profile_id_t profile_id, + unsigned int csrc, ...); + +EXPORT +void lrtp_destroy_profile(struct lrtp_t *lrtp, unsigned int csrc); + +typedef enum { + // Errors: + PACK_ERROR = 1000, // Error... + PACK_BUFFER_TOO_SMALL = 1001, // Packet buffer needs to be bigger. + PACK_UNKNOWN_PROFILE = 1002, // Illegal profile id + PACK_MISSING_PROFILE = 1003, // Profile pointer NULL or not valid. +} lrtp_pack_status_t; + +/** + * Enqueue a media frame for the packetiser. + * @param profile A pointer to profile needed for processing the frame type. + * @param framedate The frame data that needs encapsulation. + * @param framesize The size in bytes of the frame data. + * @return 0 on success, or a negative error code on error. + * NOTE: The frame pointer cannot be freed or overwritten until all frame data + * has been handled by lrtp_pack(). Either call lrtp_pack() until it returns 0 + * after each call to lrtp_enqueue_frame or use the + * OPTION_SET_PROCESS_FINISHED_HANDLER option to set a process finished handler. + * See lrtp_profiles.h for further details. + */ +EXPORT +int lrtp_enqueue_frame(struct lrtp_profile_t *profile, + const char *framedate, size_t framesize); + +/** + * Handle frame data from the frame queue and create at most a single sRTP + * packet. + * @param lrtp The lrtp context handle. + * @param packet A char buffer which will contain the resulting RTP data. + * @param maxsize the maximum number of bytes that can be contained within + * packet. + * @return Returns the number of bytes written in packet, if any (can be zero + * if no packet is available) or a negative error code on error. + */ +EXPORT int lrtp_pack(struct lrtp_t *lrtp, char *packet, size_t maxsize); + +typedef enum { + // Errors: + UNPACK_ERROR = 1000, // Error... + UNPACK_BUFFER_TOO_SMALL = 1001, // Frame buffer needs to be bigger. + UNPACK_MISSING_HANDLE = 1002, // Handle pointer NULL or not valid. + UNPACK_MISSING_CSRC = 1003, // Exactly one csrc must be present. + UNPACK_TOO_MANY_CSRCS = 1004, // Exactly one csrc must be present. + UNPACK_MISSING_PROFILE = 1005, // CSrc from packet could not be connected with a preofile.. +} lrtp_unpack_status_t; + +/** + */ +EXPORT +int lrtp_dequeue_frame(struct lrtp_t *lrtp, + char *frame, size_t maxsize, + unsigned int *csrc, unsigned int *ts); + +/** + */ +EXPORT +int lrtp_unpack(struct lrtp_t *lrtp, const char *packet, size_t size); + +#ifdef __cplusplus +} +#endif + #endif/*__LRTP_LRTP_H__*/ -- cgit v1.2.3