static int rtsp_plugin_open (input_plugin_t *this_gen) { rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; rtsp_session_t *rtsp; lprintf ("trying to open '%s'\n", this->mrl); rtsp = rtsp_session_start(this->stream, this->mrl); if (!rtsp) { lprintf ("returning null.\n"); return 0; } this->rtsp = rtsp; return 1; }
static int rtsp_streaming_start (stream_t *stream) { int fd; rtsp_session_t *rtsp; char *mrl; char *file; int port; int redirected, temp; if (!stream) return -1; /* counter so we don't get caught in infinite redirections */ temp = 5; do { redirected = 0; fd = connect2Server (stream->streaming_ctrl->url->hostname, port = (stream->streaming_ctrl->url->port ? stream->streaming_ctrl->url->port : RTSP_DEFAULT_PORT), 1); if (fd < 0 && !stream->streaming_ctrl->url->port) fd = connect2Server (stream->streaming_ctrl->url->hostname, port = 7070, 1); if (fd < 0) return -1; file = stream->streaming_ctrl->url->file; if (file[0] == '/') file++; mrl = malloc (strlen (stream->streaming_ctrl->url->hostname) + strlen (file) + 16); sprintf (mrl, "rtsp://%s:%i/%s", stream->streaming_ctrl->url->hostname, port, file); rtsp = rtsp_session_start (fd, &mrl, file, stream->streaming_ctrl->url->hostname, port, &redirected, stream->streaming_ctrl->bandwidth, stream->streaming_ctrl->url->username, stream->streaming_ctrl->url->password); if (redirected == 1) { url_free (stream->streaming_ctrl->url); stream->streaming_ctrl->url = url_new (mrl); closesocket (fd); } free (mrl); temp--; } while ((redirected != 0) && (temp > 0)); if (!rtsp) return -1; stream->fd = fd; stream->streaming_ctrl->data = rtsp; stream->streaming_ctrl->streaming_read = rtsp_streaming_read; stream->streaming_ctrl->streaming_seek = NULL; stream->streaming_ctrl->prebuffer_size = 128*1024; // 640 KBytes stream->streaming_ctrl->buffering = 1; stream->streaming_ctrl->status = streaming_playing_e; return 0; }