apps/streamer/rtsp.c File Reference

#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "event.h"
#include "str.h"
#include "rtp.h"
#include "rtsp.h"

Include dependency graph for rtsp.c:

Go to the source code of this file.

Data Structures

struct  session
struct  conn
struct  listener

Defines

#define CONN_STATE_START   0
#define CONN_STATE_RTSP   1
#define CONN_STATE_RTSP_REQ   2
#define CONN_STATE_INTERLEAVED   3
#define CONN_STATE_HTTP   10

Functions

static void do_read (struct event *e, void *d)
static void del_session (struct session *sess)
static struct sessionnew_session (void)
static struct sessionget_session (char *id)
static void close_session (struct session *s)
static void drop_conn (struct conn *c)
static void conn_write (struct event *e, void *d)
static int avail_send_buf (struct conn *c)
static int send_data (struct conn *c, unsigned char *d, int len)
static char * get_header (struct conn *c, char *name)
static int handle_OPTIONS (struct conn *c)
static int handle_DESCRIBE (struct conn *c)
static int rtsp_udp_setup (struct conn *c, char *t)
static int handle_SETUP (struct conn *c)
static int handle_PLAY (struct conn *c)
static int handle_PAUSE (struct conn *c)
static int handle_TEARDOWN (struct conn *c)
static int handle_unknown (struct conn *c)
static int handle_request (struct conn *c)
static int parse_client_data (struct conn *c)
static void do_accept (struct event *e, void *d)
int rtsp_listen (struct param *p)

Variables

param_param
connconn_list = NULL
sessionsess_list = NULL


Define Documentation

#define CONN_STATE_HTTP   10

Definition at line 64 of file rtsp.c.

#define CONN_STATE_INTERLEAVED   3

Definition at line 63 of file rtsp.c.

#define CONN_STATE_RTSP   1

Definition at line 61 of file rtsp.c.

Referenced by parse_client_data().

#define CONN_STATE_RTSP_REQ   2

Definition at line 62 of file rtsp.c.

Referenced by parse_client_data().

#define CONN_STATE_START   0

Definition at line 60 of file rtsp.c.

Referenced by do_accept(), and parse_client_data().


Function Documentation

static int avail_send_buf ( struct conn c  )  [inline, static]

Definition at line 177 of file rtsp.c.

References conn::send_buf, conn::send_buf_r, and conn::send_buf_w.

Referenced by send_data().

static void close_session ( struct session s  )  [static]

Definition at line 129 of file rtsp.c.

References del_session(), and s.

Referenced by drop_conn(), and handle_TEARDOWN().

static void conn_write ( struct event e,
void *  d 
) [static]

Definition at line 151 of file rtsp.c.

References conn::drop_after, drop_conn(), conn::fd, conn::send_buf, conn::send_buf_r, conn::send_buf_w, set_event_enabled(), write, and conn::write_event.

Referenced by do_accept().

static void del_session ( struct session sess  )  [static]

Definition at line 94 of file rtsp.c.

References free(), session::next, session::prev, and sess_list.

Referenced by close_session().

static void do_accept ( struct event e,
void *  d 
) [static]

Definition at line 558 of file rtsp.c.

References add_fd_event(), conn::attached_session, conn::client_addr, conn::close_flag, conn_list, CONN_STATE_START, conn_write(), do_read(), conn::drop_after, exit, conn::fd, listener::fd, fd, malloc(), conn::next, conn::prev, conn::read_event, conn::req_len, conn::send_buf_r, conn::send_buf_w, set_event_enabled(), conn::state, stderr, and conn::write_event.

Referenced by rtsp_listen().

static void do_read ( struct event e,
void *  d 
) [static]

Definition at line 506 of file rtsp.c.

References _param, conn::close_flag, drop_conn(), conn::fd, read, conn::req_buf, conn::req_len, param::rtsp_qt_compat, stderr, str_count, and str_teardown.

Referenced by do_accept().

static void drop_conn ( struct conn c  )  [static]

Definition at line 134 of file rtsp.c.

References conn::attached_session, close_session(), conn_list, conn::fd, free(), conn::next, conn::prev, conn::read_event, remove_event(), and conn::write_event.

Referenced by conn_write(), and do_read().

static char* get_header ( struct conn c,
char *  name 
) [static]

Definition at line 201 of file rtsp.c.

References conn::name, conn::req_hdr, and conn::value.

Referenced by handle_DESCRIBE(), handle_OPTIONS(), handle_PAUSE(), handle_PLAY(), handle_SETUP(), handle_TEARDOWN(), handle_unknown(), and rtsp_udp_setup().

static struct session* get_session ( char *  id  )  [static]

Definition at line 120 of file rtsp.c.

References s, and sess_list.

Referenced by handle_PAUSE(), handle_PLAY(), and handle_TEARDOWN().

static int handle_DESCRIBE ( struct conn c  )  [static]

Definition at line 220 of file rtsp.c.

References _param, conn::close_flag, get_header(), ismulticast(), param::rtsp_use_cmd_addr, send_data(), stderr, str_count, and write_sdp().

Referenced by handle_request().

static int handle_OPTIONS ( struct conn c  )  [static]

Definition at line 212 of file rtsp.c.

References get_header(), and send_data().

Referenced by handle_request().

static int handle_PAUSE ( struct conn c  )  [static]

Definition at line 348 of file rtsp.c.

References _param, get_header(), get_session(), memset(), param::rtsp_qt_compat, s, send_data(), stderr, str_count, and str_play.

Referenced by handle_request().

static int handle_PLAY ( struct conn c  )  [static]

Definition at line 322 of file rtsp.c.

References get_header(), get_session(), memset(), s, send_data(), stderr, and str_play.

Referenced by handle_request().

static int handle_request ( struct conn c  )  [static]

Definition at line 411 of file rtsp.c.

References handle_DESCRIBE(), handle_OPTIONS(), handle_PAUSE(), handle_PLAY(), handle_SETUP(), handle_TEARDOWN(), handle_unknown(), conn::name, conn::req_buf, conn::req_hdr, stderr, t, and conn::value.

Referenced by parse_client_data().

static int handle_SETUP ( struct conn c  )  [static]

Definition at line 302 of file rtsp.c.

References get_header(), memset(), rtsp_udp_setup(), send_data(), and t.

Referenced by handle_request().

static int handle_TEARDOWN ( struct conn c  )  [static]

Definition at line 379 of file rtsp.c.

References _param, conn::attached_session, conn::close_flag, close_session(), get_header(), get_session(), param::rtsp_qt_compat, s, send_data(), str_count, and str_teardown.

Referenced by handle_request().

static int handle_unknown ( struct conn c  )  [static]

Definition at line 403 of file rtsp.c.

References get_header(), and send_data().

Referenced by handle_request().

static struct session* new_session ( void   )  [static]

Definition at line 102 of file rtsp.c.

References session::id, malloc(), session::next, session::prev, and sess_list.

Referenced by rtsp_udp_setup().

static int parse_client_data ( struct conn c  )  [static]

Definition at line 475 of file rtsp.c.

References CONN_STATE_RTSP, CONN_STATE_RTSP_REQ, CONN_STATE_START, handle_request(), conn::req_buf, conn::req_len, conn::state, and t.

int rtsp_listen ( struct param p  ) 

Definition at line 598 of file rtsp.c.

References _param, add_fd_event(), do_accept(), fd, malloc(), param::rtsp_port, and stderr.

Referenced by rtsp_loop().

static int rtsp_udp_setup ( struct conn c,
char *  t 
) [static]

Definition at line 246 of file rtsp.c.

References _param, conn::attached_session, conn::client_addr, param::dport, param::dst, get_header(), memset(), mode, new_session(), param::rtsp_use_cmd_addr, param::rtsp_use_cmd_port, s, send_data(), stderr, str_count, and str_setup.

Referenced by handle_SETUP().

static int send_data ( struct conn c,
unsigned char *  d,
int  len 
) [static]

Definition at line 184 of file rtsp.c.

References avail_send_buf(), conn::send_buf, conn::send_buf_w, set_event_enabled(), and conn::write_event.

Referenced by handle_DESCRIBE(), handle_OPTIONS(), handle_PAUSE(), handle_PLAY(), handle_SETUP(), handle_TEARDOWN(), handle_unknown(), and rtsp_udp_setup().


Variable Documentation

struct param* _param

Definition at line 43 of file rtsp.c.

Referenced by do_read(), handle_DESCRIBE(), handle_PAUSE(), handle_TEARDOWN(), rtsp_listen(), and rtsp_udp_setup().

struct conn* conn_list = NULL

Definition at line 89 of file rtsp.c.

Referenced by do_accept(), and drop_conn().

struct session* sess_list = NULL

Definition at line 90 of file rtsp.c.

Referenced by del_session(), get_session(), and new_session().


Generated on Fri Nov 28 00:07:28 2008 for elphel by  doxygen 1.5.1