Commit 775fa8a1 authored by Gildas Bazin's avatar Gildas Bazin

* modules/access/rtsp: real rtsp access module.

parent 369ccbef
...@@ -2402,6 +2402,15 @@ if test "${enable_real}" = "yes"; then ...@@ -2402,6 +2402,15 @@ if test "${enable_real}" = "yes"; then
VLC_ADD_PLUGINS([realaudio]) VLC_ADD_PLUGINS([realaudio])
fi fi
dnl
dnl Real RTSP plugin
dnl
AC_ARG_ENABLE(realrtsp,
[ --enable-realrtsp Real RTSP module (default disabled)])
if test "${enable_realrtsp}" = "yes"; then
VLC_ADD_PLUGINS([access_realrtsp])
fi
dnl dnl
dnl MP4 module dnl MP4 module
dnl dnl
...@@ -4653,6 +4662,7 @@ AC_CONFIG_FILES([ ...@@ -4653,6 +4662,7 @@ AC_CONFIG_FILES([
modules/access/pvr/Makefile modules/access/pvr/Makefile
modules/access/v4l/Makefile modules/access/v4l/Makefile
modules/access/cdda/Makefile modules/access/cdda/Makefile
modules/access/rtsp/Makefile
modules/access/vcd/Makefile modules/access/vcd/Makefile
modules/access/vcdx/Makefile modules/access/vcdx/Makefile
modules/access/screen/Makefile modules/access/screen/Makefile
......
SOURCES_access_realrtsp = \
access.c \
rtsp.c \
rtsp.h \
real.c \
real.h \
real_rmff.c \
real_rmff.h \
real_sdpplin.c \
real_sdpplin.h \
real_asmrp.c \
real_asmrp.h \
$(NULL)
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
* real.c: rtsp input
*****************************************************************************
* Copyright (C) 2002-2004 the xine project
* Copyright (C) 2005 VideoLAN
* $Id: file.c 10310 2005-03-11 22:36:40Z anil $
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Adapted from xine which itself adapted it from joschkas real tools.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef HAVE_REAL_H
#define HAVE_REAL_H
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <vlc/vlc.h>
#include "rtsp.h"
#include "real_rmff.h"
#include "real_sdpplin.h"
#ifdef REALDEBUG
# define lprintf printf
#else
static inline void lprintf( char *dummy, ... ){}
#endif
int real_get_rdt_chunk(rtsp_client_t *, unsigned char **buffer);
rmff_header_t *real_setup_and_get_header(rtsp_client_t *, int bandwidth);
int asmrp_match(const char *rules, int bandwidth, int *matches) ;
#endif
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2002-2003 the xine project
*
* This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* $Id: rmff.h,v 1.5 2004/04/06 19:20:16 valtri Exp $
*
* some functions for real media file headers
* adopted from joschkas real tools
*/
#ifndef HAVE_RMFF_H
#define HAVE_RMFF_H
#define RMFF_HEADER_SIZE 0x12
#define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
(((long)(unsigned char)(ch3) ) | \
( (long)(unsigned char)(ch2) << 8 ) | \
( (long)(unsigned char)(ch1) << 16 ) | \
( (long)(unsigned char)(ch0) << 24 ) )
#define RMF_TAG FOURCC_TAG('.', 'R', 'M', 'F')
#define PROP_TAG FOURCC_TAG('P', 'R', 'O', 'P')
#define MDPR_TAG FOURCC_TAG('M', 'D', 'P', 'R')
#define CONT_TAG FOURCC_TAG('C', 'O', 'N', 'T')
#define DATA_TAG FOURCC_TAG('D', 'A', 'T', 'A')
#define INDX_TAG FOURCC_TAG('I', 'N', 'D', 'X')
#define PNA_TAG FOURCC_TAG('P', 'N', 'A', 0 )
#define MLTI_TAG FOURCC_TAG('M', 'L', 'T', 'I')
/* prop flags */
#define PN_SAVE_ENABLED 0x01
#define PN_PERFECT_PLAY_ENABLED 0x02
#define PN_LIVE_BROADCAST 0x04
/*
* rm header data structs
*/
typedef struct {
uint32_t object_id;
uint32_t size;
uint16_t object_version;
uint32_t file_version;
uint32_t num_headers;
} rmff_fileheader_t;
typedef struct {
uint32_t object_id;
uint32_t size;
uint16_t object_version;
uint32_t max_bit_rate;
uint32_t avg_bit_rate;
uint32_t max_packet_size;
uint32_t avg_packet_size;
uint32_t num_packets;
uint32_t duration;
uint32_t preroll;
uint32_t index_offset;
uint32_t data_offset;
uint16_t num_streams;
uint16_t flags;
} rmff_prop_t;
typedef struct {
uint32_t object_id;
uint32_t size;
uint16_t object_version;
uint16_t stream_number;
uint32_t max_bit_rate;
uint32_t avg_bit_rate;
uint32_t max_packet_size;
uint32_t avg_packet_size;
uint32_t start_time;
uint32_t preroll;
uint32_t duration;
uint8_t stream_name_size;
char *stream_name;
uint8_t mime_type_size;
char *mime_type;
uint32_t type_specific_len;
char *type_specific_data;
int mlti_data_size;
char *mlti_data;
} rmff_mdpr_t;
typedef struct {
uint32_t object_id;
uint32_t size;
uint16_t object_version;
uint16_t title_len;
char *title;
uint16_t author_len;
char *author;
uint16_t copyright_len;
char *copyright;
uint16_t comment_len;
char *comment;
} rmff_cont_t;
typedef struct {
uint32_t object_id;
uint32_t size;
uint16_t object_version;
uint32_t num_packets;
uint32_t next_data_header; /* rarely used */
} rmff_data_t;
typedef struct {
rmff_fileheader_t *fileheader;
rmff_prop_t *prop;
rmff_mdpr_t **streams;
rmff_cont_t *cont;
rmff_data_t *data;
} rmff_header_t;
typedef struct {
uint16_t object_version;
uint16_t length;
uint16_t stream_number;
uint32_t timestamp;
uint8_t reserved;
uint8_t flags;
} rmff_pheader_t;
/*
* constructors for header structs
*/
rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers);
rmff_prop_t *rmff_new_prop (
uint32_t max_bit_rate,
uint32_t avg_bit_rate,
uint32_t max_packet_size,
uint32_t avg_packet_size,
uint32_t num_packets,
uint32_t duration,
uint32_t preroll,
uint32_t index_offset,
uint32_t data_offset,
uint16_t num_streams,
uint16_t flags );
rmff_mdpr_t *rmff_new_mdpr(
uint16_t stream_number,
uint32_t max_bit_rate,
uint32_t avg_bit_rate,
uint32_t max_packet_size,
uint32_t avg_packet_size,
uint32_t start_time,
uint32_t preroll,
uint32_t duration,
const char *stream_name,
const char *mime_type,
uint32_t type_specific_len,
const char *type_specific_data );
rmff_cont_t *rmff_new_cont(
const char *title,
const char *author,
const char *copyright,
const char *comment);
rmff_data_t *rmff_new_dataheader(
uint32_t num_packets, uint32_t next_data_header);
/*
* reads header infos from data and returns a newly allocated header struct
*/
rmff_header_t *rmff_scan_header(const char *data);
/*
* scans a data packet header. Notice, that this function does not allocate
* the header struct itself.
*/
void rmff_scan_pheader(rmff_pheader_t *h, char *data);
/*
* reads header infos from stream and returns a newly allocated header struct
*/
rmff_header_t *rmff_scan_header_stream(int fd);
/*
* prints header information in human readible form to stdout
*/
void rmff_print_header(rmff_header_t *h);
/*
* does some checks and fixes header if possible
*/
void rmff_fix_header(rmff_header_t *h);
/*
* returns the size of the header (incl. first data-header)
*/
int rmff_get_header_size(rmff_header_t *h);
/*
* dumps the header <h> to <buffer>. <max> is the size of <buffer>
*/
int rmff_dump_header(rmff_header_t *h, char *buffer, int max);
/*
* dumps a packet header
*/
void rmff_dump_pheader(rmff_pheader_t *h, char *data);
/*
* frees a header struct
*/
void rmff_free_header(rmff_header_t *h);
#endif
/*
* Copyright (C) 2002-2003 the xine project
*
* This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* $Id: sdpplin.c,v 1.5 2004/04/23 21:59:04 miguelfreitas Exp $
*
* sdp/sdpplin parser.
*
*/
#include "real.h"
/*
* Decodes base64 strings (based upon b64 package)
*/
static char *b64_decode(const char *in, char *out, int *size)
{
char dtable[256]; /* Encode / decode table */
int i,j,k;
for (i = 0; i < 255; i++) {
dtable[i] = 0x80;
}
for (i = 'A'; i <= 'Z'; i++) {
dtable[i] = 0 + (i - 'A');
}
for (i = 'a'; i <= 'z'; i++) {
dtable[i] = 26 + (i - 'a');
}
for (i = '0'; i <= '9'; i++) {
dtable[i] = 52 + (i - '0');
}
dtable['+'] = 62;
dtable['/'] = 63;
dtable['='] = 0;
k=0;
/*CONSTANTCONDITION*/
for (j=0; j<strlen(in); j+=4)
{
char a[4], b[4];
for (i = 0; i < 4; i++) {
int c = in[i+j];
if (dtable[c] & 0x80) {
printf("Illegal character '%c' in input.\n", c);
exit(1);
}
a[i] = (char) c;
b[i] = (char) dtable[c];
}
//xine_buffer_ensure_size(out, k+3);
out[k++] = (b[0] << 2) | (b[1] >> 4);
out[k++] = (b[1] << 4) | (b[2] >> 2);
out[k++] = (b[2] << 6) | b[3];
i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3);
if (i < 3) {
out[k]=0;
*size=k;
return out;
}
}
out[k]=0;
*size=k;
return out;
}
static char *nl(char *data) {
char *nlptr = (data) ? strchr(data,'\n') : NULL;
return (nlptr) ? nlptr + 1 : NULL;
}
static int filter(const char *in, const char *filter, char **out) {
int flen=strlen(filter);
int len;
if (!in)
return 0;
len = (strchr(in,'\n')) ? strchr(in,'\n')-in : strlen(in);
if (!strncmp(in,filter,flen))
{
if(in[flen]=='"') flen++;
if(in[len-1]==13) len--;
if(in[len-1]=='"') len--;
memcpy(*out, in+flen, len-flen+1);
(*out)[len-flen]=0;
return len-flen;
}
return 0;
}
static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
sdpplin_stream_t *desc = malloc(sizeof(sdpplin_stream_t));
char *buf=malloc(32000);
char *decoded=malloc(32000);
int handled;
memset(desc, 0, sizeof(sdpplin_stream_t));
if (filter(*data, "m=", &buf)) {
desc->id = strdup(buf);
} else
{
lprintf("sdpplin: no m= found.\n");
free(desc);
free(buf);
return NULL;
}
*data=nl(*data);
while (*data && **data && *data[0]!='m') {
handled=0;
if(filter(*data,"a=control:streamid=",&buf)) {
desc->stream_id=atoi(buf);
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=MaxBitRate:integer;",&buf)) {
desc->max_bit_rate=atoi(buf);
if (!desc->avg_bit_rate)
desc->avg_bit_rate=desc->max_bit_rate;
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=MaxPacketSize:integer;",&buf)) {
desc->max_packet_size=atoi(buf);
if (!desc->avg_packet_size)
desc->avg_packet_size=desc->max_packet_size;
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=StartTime:integer;",&buf)) {
desc->start_time=atoi(buf);
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=Preroll:integer;",&buf)) {
desc->preroll=atoi(buf);
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=length:npt=",&buf)) {
desc->duration=(uint32_t)(atof(buf)*1000);
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=StreamName:string;",&buf)) {
desc->stream_name=strdup(buf);
desc->stream_name_size=strlen(desc->stream_name);
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=mimetype:string;",&buf)) {
desc->mime_type=strdup(buf);
desc->mime_type_size=strlen(desc->mime_type);
handled=1;
*data=nl(*data);
}
if(filter(*data,"a=OpaqueData:buffer;",&buf)) {
decoded = b64_decode(buf, decoded, &(desc->mlti_data_size));
desc->mlti_data = malloc(sizeof(char)*desc->mlti_data_size);
memcpy(desc->mlti_data, decoded, desc->mlti_data_size);
handled=1;
*data=nl(*data);
lprintf("mlti_data_size: %i\n", desc->mlti_data_size);
}
if(filter(*data,"a=ASMRuleBook:string;",&buf)) {
desc->asm_rule_book=strdup(buf);
handled=1;
*data=nl(*data);
}
if(!handled) {
#ifdef LOG
int len=strchr(*data,'\n')-(*data);
memcpy(buf, *data, len+1);
buf[len]=0;
printf("libreal: sdpplin: not handled: '%s'\n", buf);
#endif
*data=nl(*data);
}
}
free(buf);
free(decoded);
return desc;
}
sdpplin_t *sdpplin_parse(char *data) {
sdpplin_t *desc = malloc(sizeof(sdpplin_t));
sdpplin_stream_t *stream;
char *buf=malloc(3200);
char *decoded=malloc(3200);
int handled;
int len;
memset(desc, 0, sizeof(sdpplin_t));
while (data && *data) {
handled=0;
if (filter(data, "m=", &buf)) {
stream=sdpplin_parse_stream(&data);
lprintf("got data for stream id %u\n", stream->stream_id);
desc->stream[stream->stream_id]=stream;
continue;
}
if(filter(data,"a=Title:buffer;",&buf)) {
decoded=b64_decode(buf, decoded, &len);
desc->title=strdup(decoded);
handled=1;
data=nl(data);
}
if(filter(data,"a=Author:buffer;",&buf)) {
decoded=b64_decode(buf, decoded, &len);
desc->author=strdup(decoded);
handled=1;
data=nl(data);
}
if(filter(data,"a=Copyright:buffer;",&buf)) {
decoded=b64_decode(buf, decoded, &len);
desc->copyright=strdup(decoded);
handled=1;
data=nl(data);
}
if(filter(data,"a=Abstract:buffer;",&buf)) {
decoded=b64_decode(buf, decoded, &len);
desc->abstract=strdup(decoded);
handled=1;
data=nl(data);
}
if(filter(data,"a=StreamCount:integer;",&buf)) {
desc->stream_count=atoi(buf);
desc->stream = malloc(sizeof(sdpplin_stream_t*)*desc->stream_count);
handled=1;
data=nl(data);
}
if(filter(data,"a=Flags:integer;",&buf)) {
desc->flags=atoi(buf);
handled=1;
data=nl(data);
}
if(!handled) {
#ifdef LOG
int len=strchr(data,'\n')-data;
memcpy(buf, data, len+1);
buf[len]=0;
printf("libreal: sdpplin: not handled: '%s'\n", buf);
#endif
data=nl(data);
}
}
free(buf);
free(decoded);
return desc;
}
void sdpplin_free(sdpplin_t *description) {
/* TODO: free strings */
free(description);
}
/*
* Copyright (C) 2002-2003 the xine project
*
* This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* $Id: sdpplin.h,v 1.2 2003/12/09 00:02:30 f1rmb Exp $
*
* sdp/sdpplin parser.
*
*/
#ifndef HAVE_SDPPLIN_H
#define HAVE_SDPPLIN_H
typedef struct {
char *id;
char *bandwidth;
int stream_id;
char *range;
char *length;
char *rtpmap;
char *mimetype;
int min_switch_overlap;
int start_time;
int end_one_rule_end_all;
int avg_bit_rate;
int max_bit_rate;
int avg_packet_size;
int max_packet_size;
int end_time;
int seek_greater_on_switch;
int preroll;
int duration;
char *stream_name;
int stream_name_size;
char *mime_type;
int mime_type_size;
char *mlti_data;
int mlti_data_size;
int rmff_flags_length;
char *rmff_flags;
int asm_rule_book_length;
char *asm_rule_book;
} sdpplin_stream_t;
typedef struct {
int sdp_version, sdpplin_version;
char *owner;
char *session_name;
char *session_info;
char *uri;
char *email;
char *phone;
char *connection;
char *bandwidth;
int flags;
int is_real_data_type;
int stream_count;
char *title;
char *author;
char *copyright;
char *keywords;
int asm_rule_book_length;
char *asm_rule_book;
char *abstract;
char *range;
int avg_bit_rate;
int max_bit_rate;
int avg_packet_size;
int max_packet_size;
int preroll;
int duration;
sdpplin_stream_t **stream;
} sdpplin_t;
sdpplin_t *sdpplin_parse(char *data);
void sdpplin_free(sdpplin_t *description);
#endif
This diff is collapsed.
/*
* Copyright (C) 2002-2003 the xine project
*
* This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* $Id: rtsp.h,v 1.4 2003/12/09 00:02:31 f1rmb Exp $
*
* a minimalistic implementation of rtsp protocol,
* *not* RFC 2326 compilant yet.
*/
#ifndef HAVE_RTSP_H
#define HAVE_RTSP_H
/* some codes returned by rtsp_request_* functions */
#define RTSP_STATUS_SET_PARAMETER 10
#define RTSP_STATUS_OK 200
typedef struct rtsp_s rtsp_t;
typedef struct
{
void *p_userdata;
int (*pf_connect)( void *p_userdata, char *p_server, int i_port );
int (*pf_disconnect)( void *p_userdata );
int (*pf_read)( void *p_userdata, uint8_t *p_buffer, int i_buffer );
int (*pf_read_line)( void *p_userdata, uint8_t *p_buffer, int i_buffer );
int (*pf_write)( void *p_userdata, uint8_t *p_buffer, int i_buffer );
rtsp_t *p_private;
} rtsp_client_t;
int rtsp_connect( rtsp_client_t *, const char *mrl, const char *user_agent );
int rtsp_request_options( rtsp_client_t *, const char *what );
int rtsp_request_describe( rtsp_client_t *, const char *what );
int rtsp_request_setup( rtsp_client_t *, const char *what );
int rtsp_request_setparameter( rtsp_client_t *, const char *what );
int rtsp_request_play( rtsp_client_t *, const char *what );
int rtsp_request_tearoff( rtsp_client_t *, const char *what );
int rtsp_send_ok( rtsp_client_t * );
int rtsp_read_data( rtsp_client_t *, char *buffer, unsigned int size );
char* rtsp_search_answers( rtsp_client_t *, const char *tag );
void rtsp_free_answers( rtsp_client_t * );
void rtsp_add_to_payload( char **payload, const char *string );
int rtsp_read( rtsp_client_t *, char *data, int len );
void rtsp_close( rtsp_client_t * );
void rtsp_set_session( rtsp_client_t *, const char *id );
char *rtsp_get_session( rtsp_client_t * );
char *rtsp_get_mrl( rtsp_client_t * );
/* int rtsp_peek_header( rtsp_client_t *, char *data ); */
void rtsp_schedule_field( rtsp_client_t *, const char *string );
void rtsp_unschedule_field( rtsp_client_t *, const char *string );
void rtsp_unschedule_all( rtsp_client_t * );
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment