|
SmolRTSP 0.1.3
A small, portable, extensible RTSP 1.0 implementation in C99
|
A request context. More...
#include <smolrtsp/droppable.h>#include <smolrtsp/priv/compiler_attrs.h>#include <smolrtsp/types/message_body.h>#include <smolrtsp/types/status_code.h>#include <smolrtsp/writer.h>#include <stdarg.h>#include <stdint.h>#include <interface99.h>#include <slice99.h>

Go to the source code of this file.
Typedefs | |
| typedef struct SmolRTSP_Context | SmolRTSP_Context |
| An opaque type used to conveniently respond to RTSP clients. | |
Functions | |
| SmolRTSP_Context * | SmolRTSP_Context_new (SmolRTSP_Writer w, uint32_t cseq) SMOLRTSP_PRIV_MUST_USE |
| Creates a new SmolRTSP context. | |
| SmolRTSP_Writer | SmolRTSP_Context_get_writer (const SmolRTSP_Context *ctx) SMOLRTSP_PRIV_MUST_USE |
| Retrieves the writer specified in SmolRTSP_Context_new. | |
| uint32_t | SmolRTSP_Context_get_cseq (const SmolRTSP_Context *ctx) SMOLRTSP_PRIV_MUST_USE |
Retrieves cseq specified in SmolRTSP_Context_new. | |
| ssize_t | SmolRTSP_Context_get_ret (const SmolRTSP_Context *ctx) SMOLRTSP_PRIV_MUST_USE |
| Retrieves the RTSP respond return value. | |
| void | smolrtsp_vheader (SmolRTSP_Context *ctx, CharSlice99 key, const char *restrict fmt, va_list list) SMOLRTSP_PRIV_GCC_ATTR(format(printf |
| Appends an RTSP header to the request context. | |
| void void | smolrtsp_header (SmolRTSP_Context *ctx, CharSlice99 key, const char *restrict fmt,...) SMOLRTSP_PRIV_GCC_ATTR(format(printf |
| The smolrtsp_vheader twin. | |
| void void void | smolrtsp_body (SmolRTSP_Context *ctx, SmolRTSP_MessageBody body) |
| Sets an RTSP body in the request context. | |
| ssize_t | smolrtsp_respond (SmolRTSP_Context *ctx, SmolRTSP_StatusCode code, const char *reason) |
| Writes an RTSP response to the underlying writer. | |
| ssize_t | smolrtsp_respond_ok (SmolRTSP_Context *ctx) |
A shortcut for smolrtsp_respond(ctx, SMOLRTSP_STATUS_OK, "OK"). | |
| ssize_t | smolrtsp_respond_internal_error (SmolRTSP_Context *ctx) |
A shortcut for smolrtsp_respond(ctx, SMOLRTSP_STATUS_INTERNAL_SERVER_ERROR, "Internal error"). | |
| declImplExtern99 (SmolRTSP_Droppable, SmolRTSP_Context) | |
| Implements SmolRTSP_Droppable_IFACE for SmolRTSP_Context. | |
A request context.
| declImplExtern99 | ( | SmolRTSP_Droppable | , |
| SmolRTSP_Context | |||
| ) |
Implements SmolRTSP_Droppable_IFACE for SmolRTSP_Context.
See Interface99 for the macro usage.
| void void void smolrtsp_body | ( | SmolRTSP_Context * | ctx, |
| SmolRTSP_MessageBody | body | ||
| ) |
Sets an RTSP body in the request context.
| [out] | ctx | The request context to modify. |
| [in] | body | The RTSP body. |
ctx != NULL | uint32_t SmolRTSP_Context_get_cseq | ( | const SmolRTSP_Context * | ctx | ) |
Retrieves cseq specified in SmolRTSP_Context_new.
ctx != NULL | ssize_t SmolRTSP_Context_get_ret | ( | const SmolRTSP_Context * | ctx | ) |
Retrieves the RTSP respond return value.
If you have not responded yet, the result is 0.
ctx != NULL | SmolRTSP_Writer SmolRTSP_Context_get_writer | ( | const SmolRTSP_Context * | ctx | ) |
Retrieves the writer specified in SmolRTSP_Context_new.
ctx != NULL | SmolRTSP_Context * SmolRTSP_Context_new | ( | SmolRTSP_Writer | w, |
| uint32_t | cseq | ||
| ) |
Creates a new SmolRTSP context.
| [in] | w | The writer to be provided with the response. |
| [in] | cseq | The sequence number for an RTSP request/response pair. |
w.self && w.vptr | ssize_t smolrtsp_respond | ( | SmolRTSP_Context * | ctx, |
| SmolRTSP_StatusCode | code, | ||
| const char * | reason | ||
| ) |
Writes an RTSP response to the underlying writer.
The CSeq and Content-Length headers will be written automatically as first headers.
| [out] | ctx | The request context to write the response to. |
| [in] | code | The RTSP status code. |
| [in] | reason | The RTSP reason phrase. |
ctx != NULL reason is a null-terminated string.| void smolrtsp_vheader | ( | SmolRTSP_Context * | ctx, |
| CharSlice99 | key, | ||
| const char *restrict | fmt, | ||
| va_list | list | ||
| ) |
Appends an RTSP header to the request context.
| [out] | ctx | The request context to modify. |
| [in] | key | The header key. |
| [in] | fmt | The printf-like format string (header value). |
| [in] | list | The variadic function arguments. |
ctx != NULL ctx must contain strictly less than SMOLRTSP_HEADER_MAP_CAPACITY headers. fmt != NULL