Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rtsp #177

Open
wants to merge 30 commits into
base: mumudvb2
Choose a base branch
from
Open

Rtsp #177

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
19f89fc
RTSP First step : we split unicast common and the HTTP
Jan 15, 2010
76b2e83
Unicast: Splitting ... for RTSP
Jan 15, 2010
627542e
Unicast : RTSP master socket
Jan 16, 2010
38af806
Unicast: other RTSP standard responses
Jan 17, 2010
f7c61bc
Unicast : merge of the RTSP code
braice Jan 20, 2010
0f29643
Unicast RTSP small bugs
Jan 22, 2010
1b69d04
Unicast: RTSP : Bug : the RSTP and HTTP clients were mixed
Jan 22, 2010
570196a
Unicast : some errors about the sockets (RTSP and logging)
Jan 22, 2010
91c5515
Unicast First working RTSP
Jan 23, 2010
66805f4
Not useful
Jan 24, 2010
d69bc13
Merge branch 'rtsp' of [email protected]:/home/mumudvb/git/m…
braice Jan 24, 2010
c823935
Unicast : possibility to choose the channel in RTSP (same path as HTTP)
Jan 26, 2010
377983a
RTSP playlist
Jan 27, 2010
68568d8
Merge branch 'rtsp' of [email protected]:/home/mumudvb/git/m…
braice Feb 27, 2010
3d7a2e3
Suffix to the version
braice Apr 10, 2011
1da18b7
RTSP example
braice Apr 10, 2011
e09a10a
Mistake in the example RTSP port
braice May 3, 2011
5118ebe
VB
braice May 3, 2011
310fa0b
Fix RTSP TEARDOWN reply
lboue May 24, 2011
9847391
VB
braice Jun 5, 2011
9298246
Use rtsp_portOut instead of http_portOut
lboue Jun 2, 2011
43c1328
Prepare new error types
lboue Jun 2, 2011
455ba34
Better methods names
lboue Jun 2, 2011
d2c3ebc
Translate to english
lboue Jun 4, 2011
f1767a2
Fix debugging with Wireshark
lboue Jun 4, 2011
9cea2c4
Time of day as Session ID and Session version value
lboue Jun 4, 2011
34f5634
Function for generate session id
lboue Jun 4, 2011
397d2b0
Error message for logging
lboue Jun 4, 2011
0534389
Monitor Unicast Clients number
lboue Jun 4, 2011
86aa64a
Debug : show all the clients sessions
lboue Jun 4, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.61])
AC_INIT([MuMuDVB], [1.6.1b_20100101], [[email protected]])
AC_INIT([MuMuDVB], [1.6.1b_20110605_rtsp], [[email protected]])
AC_CONFIG_SRCDIR([src/mumudvb.c])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([src/config.h])
Expand Down Expand Up @@ -30,7 +30,7 @@ AM_ICONV
AC_CHECK_LIB([dvbapi], [dvbdemux_set_section_filter])
AC_CHECK_LIB([ucsi], [atsc_text_segment_decode],[atsc_long_names="yes"], [atsc_long_names="no"])
#AC_CHECK_LIB([dvben50221], [en50221_stdcam_create],,,[ucsi,pthread])
AC_CHECK_LIB([pthread], [pthread_create], [pthread="yes"], [pthread="no"])
AC_CHECK_LIB([pthread], [pthread_create])


dnl
Expand All @@ -41,15 +41,16 @@ AC_ARG_ENABLE(cam_support,

if test "${enable_cam_support}" = "yes"
then
AC_CHECK_LIB([pthread], [pthread_create],[], [enable_cam_support="no"])
AC_CHECK_LIB([ucsi], [atsc_text_segment_decode],[], [enable_cam_support="no"])
AC_CHECK_LIB([dvben50221], [en50221_tl_create],[], [enable_cam_support="no"])
if test "${enable_cam_support}" != "no"
then
AC_DEFINE(ENABLE_CAM_SUPPORT, 1, Define if you want the CAM support)
else
AC_MSG_WARN([libpthread, libucsi and libdvben50221 are needed for CAM support])
AC_MSG_WARN([libucsi and libdvben50221 are needed for CAM support])
fi
else
enable_cam_support="no"
fi
AM_CONDITIONAL(BUILD_CAMSUPPORT, [test "${enable_cam_support}" != "no"])

Expand All @@ -61,7 +62,8 @@ AC_ARG_ENABLE(transcoding,

if test "${enable_transcoding}" = "yes"
then
AC_CHECK_LIB([pthread], [pthread_create],[], [enable_transcoding="no"])
AC_CHECK_LIB([avformat], [url_split],[AC_DEFINE(HAVE_URL_SPLIT, 1, Define if the function url_split exists)], [])
AC_CHECK_LIB([avformat], [ff_url_split],[AC_DEFINE(HAVE_FF_URL_SPLIT, 1, Define if the function ff_url_split exists)], [])
AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h])
AC_CHECK_HEADERS([libavformat/avformat.h ffmpeg/avformat.h])
AC_CHECK_HEADERS([libswscale/swscale.h ffmpeg/swscale.h])
Expand All @@ -72,8 +74,10 @@ then
then
AC_DEFINE(ENABLE_TRANSCODING, 1, Define if you want the transcoding support)
else
AC_MSG_WARN([libpthread, libavcodev, libavformat and libswscale are needed for transcoding support])
AC_MSG_WARN([libavcodev, libavformat and libswscale are needed for transcoding support])
fi
else
enable_transcoding="no"
fi
AM_CONDITIONAL(BUILD_TRANSCODING, [test "${enable_transcoding}" != "no"])

Expand Down Expand Up @@ -157,12 +161,6 @@ else
echo "Build with ATSC long names support: no"
fi

if test "${pthread}" = "yes" ; then
echo "Builded with threads support: yes"
else
echo "Builded with threads support: no"
fi

echo ""
echo "Debugging"
echo ""
Expand Down
9 changes: 9 additions & 0 deletions doc/configuration_examples/rtsp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
freq=12168
pol=v
srate=27500
autoconfiguration=full
unicast=1
unicast_rtsp=1
port_rtsp=554
multicast=0
port_http=8090
5 changes: 3 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ AM_LDFLAGS =

bin_PROGRAMS = mumudvb
mumudvb_SOURCES = autoconf.c crc32.c dvb.h log.c log.h multicast.c mumudvb.h network.h rewrite.h \
rtp.h sap.h ts.h tune.h unicast_http.h autoconf.h dvb.c errors.h \
rtp.h sap.h ts.h tune.h unicast_http.h autoconf.h dvb.c errors.h unicast_common.h \
mumudvb.c mumudvb_common.c network.c pat_rewrite.c rewrite.c sdt_rewrite.c \
rtp.c sap.c ts.c tune.c unicast_http.c unicast_queue.c autoconf_sdt.c autoconf_atsc.c \
autoconf_pmt.c autoconf_nit.c unicast_clients.c
autoconf_pmt.c autoconf_nit.c unicast_clients.c unicast_common.c unicast_common.h \
unicast_rtsp.c unicast_rtsp.h unicast.h

if BUILD_CAMSUPPORT
mumudvb_SOURCES += $(SOURCES_camsupport)
Expand Down
3 changes: 2 additions & 1 deletion src/autoconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "autoconf.h"
#include "rtp.h"
#include "log.h"
#include "unicast.h"

extern int Interrupted;
extern int server_id;
Expand Down Expand Up @@ -847,7 +848,7 @@ void autoconf_definite_end(int card, mumudvb_chan_and_pids_t *chan_and_pids, int
{
log_message(MSG_INFO,"Autoconfiguration done\n");

log_streamed_channels(chan_and_pids->number_of_channels, chan_and_pids->channels, multicast, unicast_vars->unicast, unicast_vars->portOut, unicast_vars->ipOut);
log_streamed_channels(chan_and_pids->number_of_channels, chan_and_pids->channels, multicast, unicast_vars->unicast, unicast_vars->http_portOut, unicast_vars->ipOut);

/**@todo : make an option to generate it or not ?*/
char filename_gen_conf[256];
Expand Down
2 changes: 1 addition & 1 deletion src/autoconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define _AUTOCONF_H

#include "mumudvb.h"
#include "unicast_http.h"
#include "unicast.h"
#include "ts.h"
#include "tune.h"

Expand Down
59 changes: 40 additions & 19 deletions src/mumudvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
#include "autoconf.h"
#include "sap.h"
#include "rewrite.h"
#include "unicast_http.h"
#include "unicast.h"
#include "rtp.h"
#include "log.h"
#ifdef ENABLE_TRANSCODING
Expand Down Expand Up @@ -294,8 +294,11 @@ rewrite_parameters_t rewrite_vars={
unicast_parameters_t unicast_vars={
.unicast=0,
.ipOut="0.0.0.0",
.portOut=4242,
.portOut_str=NULL,
.http_portOut=4242,
.http_portOut_str=NULL,
.unicast_rtsp_enable=0,
.rtsp_portOut=554,
.rtsp_portOut_str=NULL,
.consecutive_errors_timeout=UNICAST_CONSECUTIVE_ERROR_TIMEOUT,
.max_clients=-1,
.queue_max_size=UNICAST_DEFAULT_QUEUE_MAX,
Expand Down Expand Up @@ -768,17 +771,29 @@ int


//If we specified a string for the unicast port out, we parse it
if(unicast_vars.portOut_str!=NULL)
if(unicast_vars.http_portOut_str!=NULL)
{
int len;
len=strlen(unicast_vars.portOut_str)+1;
len=strlen(unicast_vars.http_portOut_str)+1;
char number[10];
sprintf(number,"%d",tuneparams.card);
unicast_vars.portOut_str=mumu_string_replace(unicast_vars.portOut_str,&len,1,"%card",number);
unicast_vars.http_portOut_str=mumu_string_replace(unicast_vars.http_portOut_str,&len,1,"%card",number);
sprintf(number,"%d",server_id);
unicast_vars.portOut_str=mumu_string_replace(unicast_vars.portOut_str,&len,1,"%server",number);
unicast_vars.portOut=string_comput(unicast_vars.portOut_str);
log_message( MSG_DEBUG, "Unicast: computed unicast master port : %d\n",unicast_vars.portOut);
unicast_vars.http_portOut_str=mumu_string_replace(unicast_vars.http_portOut_str,&len,1,"%server",number);
unicast_vars.http_portOut=string_comput(unicast_vars.http_portOut_str);
log_message( MSG_DEBUG, "Unicast: computed unicast master port : %d\n",unicast_vars.http_portOut);
}
if(unicast_vars.unicast_rtsp_enable && unicast_vars.rtsp_portOut_str!=NULL)
{
int len;
len=strlen(unicast_vars.rtsp_portOut_str)+1;
char number[10];
sprintf(number,"%d",tuneparams.card);
unicast_vars.rtsp_portOut_str=mumu_string_replace(unicast_vars.rtsp_portOut_str,&len,1,"%card",number);
sprintf(number,"%d",server_id);
unicast_vars.rtsp_portOut_str=mumu_string_replace(unicast_vars.rtsp_portOut_str,&len,1,"%server",number);
unicast_vars.rtsp_portOut=string_comput(unicast_vars.rtsp_portOut_str);
log_message( MSG_DEBUG, "Unicast: computed unicast RTSP port : %d\n",unicast_vars.rtsp_portOut);
}
/******************************************************/
//end of config file reading
Expand Down Expand Up @@ -843,10 +858,10 @@ int
}
}
#endif
if(multicast_vars.rtp_header)
if(multicast_vars.rtp_header && !unicast_vars.unicast_rtsp_enable)
{
multicast_vars.rtp_header=0;
log_message( MSG_INFO, "NO Multicast, RTP Header is desactivated.\n");
log_message( MSG_INFO, "NO Multicast, NO RTSP, RTP Header is desactivated.\n");
}
if(sap_vars.sap==OPTION_ON)
{
Expand Down Expand Up @@ -1069,7 +1084,7 @@ int
/*****************************************************/

//Initialisation of the channels for RTP
if(multicast_vars.rtp_header)
if(multicast_vars.rtp_header || unicast_vars.unicast_rtsp_enable)
for (curr_channel = 0; curr_channel < chan_and_pids.number_of_channels; curr_channel++)
init_rtp_header(&chan_and_pids.channels[curr_channel]);

Expand Down Expand Up @@ -1206,15 +1221,20 @@ int
//We open the socket for the http unicast if needed and we update the poll structure
if(unicast_vars.unicast)
{
log_message(MSG_INFO,"Unicast : We open the Master http socket for address %s:%d\n",unicast_vars.ipOut, unicast_vars.portOut);
unicast_create_listening_socket(UNICAST_MASTER, -1, unicast_vars.ipOut, unicast_vars.portOut, &unicast_vars.sIn, &unicast_vars.socketIn, &fds, &unicast_vars);
log_message(MSG_INFO,"Unicast : We open the Master HTTP socket for address %s:%d\n",unicast_vars.ipOut, unicast_vars.http_portOut);
unicast_create_listening_socket(UNICAST_MASTER_HTTP, -1, unicast_vars.ipOut, unicast_vars.http_portOut, &unicast_vars.http_sIn, &unicast_vars.http_socketIn, &fds, &unicast_vars);
/** open the unicast listening connections fo the channels */
for (curr_channel = 0; curr_channel < chan_and_pids.number_of_channels; curr_channel++)
if(chan_and_pids.channels[curr_channel].unicast_port)
{
log_message(MSG_INFO,"Unicast : We open the channel %d http socket address %s:%d\n",curr_channel, unicast_vars.ipOut, chan_and_pids.channels[curr_channel].unicast_port);
unicast_create_listening_socket(UNICAST_LISTEN_CHANNEL, curr_channel, unicast_vars.ipOut,chan_and_pids.channels[curr_channel].unicast_port , &chan_and_pids.channels[curr_channel].sIn, &chan_and_pids.channels[curr_channel].socketIn, &fds, &unicast_vars);
}
if(unicast_vars.unicast_rtsp_enable)
{
log_message(MSG_INFO,"Unicast : We open the Master RTSP socket for address %s:%d\n",unicast_vars.ipOut, unicast_vars.rtsp_portOut);
unicast_create_listening_socket(UNICAST_MASTER_RTSP, -1, unicast_vars.ipOut, unicast_vars.rtsp_portOut, &unicast_vars.rtsp_sIn, &unicast_vars.rtsp_socketIn, &fds, &unicast_vars);
}
}


Expand All @@ -1231,7 +1251,7 @@ int
/*****************************************************/

if(autoconf_vars.autoconfiguration!=AUTOCONF_MODE_FULL)
log_streamed_channels(chan_and_pids.number_of_channels, chan_and_pids.channels, multicast_vars.multicast, unicast_vars.unicast, unicast_vars.portOut, unicast_vars.ipOut);
log_streamed_channels(chan_and_pids.number_of_channels, chan_and_pids.channels, multicast_vars.multicast, unicast_vars.unicast, unicast_vars.http_portOut, unicast_vars.ipOut);

if(autoconf_vars.autoconfiguration)
log_message(MSG_INFO,"Autoconfiguration Start\n");
Expand Down Expand Up @@ -1513,8 +1533,8 @@ int

chan_and_pids.channels[curr_channel].nb_bytes += TS_PACKET_SIZE;
//The buffer is full, we send it
if ((!multicast_vars.rtp_header && ((chan_and_pids.channels[curr_channel].nb_bytes + TS_PACKET_SIZE) > MAX_UDP_SIZE))
||(multicast_vars.rtp_header && ((chan_and_pids.channels[curr_channel].nb_bytes + RTP_HEADER_LEN + TS_PACKET_SIZE) > MAX_UDP_SIZE)))
if ((!(multicast_vars.rtp_header ||unicast_vars.unicast_rtsp_enable) && ((chan_and_pids.channels[curr_channel].nb_bytes + TS_PACKET_SIZE) > MAX_UDP_SIZE))
||((multicast_vars.rtp_header ||unicast_vars.unicast_rtsp_enable) && ((chan_and_pids.channels[curr_channel].nb_bytes + RTP_HEADER_LEN + TS_PACKET_SIZE) > MAX_UDP_SIZE)))
{
//For bandwith measurement (traffic)
chan_and_pids.channels[curr_channel].sent_data+=chan_and_pids.channels[curr_channel].nb_bytes;
Expand Down Expand Up @@ -1546,14 +1566,15 @@ int
(NULL != chan_and_pids.channels[curr_channel].transcode_options.streaming_type &&
STREAMING_TYPE_MPEGTS != *chan_and_pids.channels[curr_channel].transcode_options.streaming_type))
#endif
if( multicast_vars.rtp_header || unicast_vars.unicast_rtsp_enable)
rtp_update_sequence_number(&chan_and_pids.channels[curr_channel]);
/********** MULTICAST *************/
//if the multicast TTL is set to 0 we don't send the multicast packets
//if the multicast TTL is set to 0 we don't send the multicast packets
if(multicast_vars.multicast)
{
if(multicast_vars.rtp_header)
{
/****** RTP *******/
rtp_update_sequence_number(&chan_and_pids.channels[curr_channel]);
sendudp (chan_and_pids.channels[curr_channel].socketOut,
&chan_and_pids.channels[curr_channel].sOut,
chan_and_pids.channels[curr_channel].buf_with_rtp_header,
Expand Down
49 changes: 49 additions & 0 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,55 @@ makesocket (char *szAddr, unsigned short port, int TTL,
return iSocket;
}


/** @brief create a sender socket.
*
* Create a socket for sending data, the socket is udp, with the option REUSE_ADDR set to 1
*/
int
makeUDPsocket (char *szAddr, unsigned short port,
struct sockaddr_in *sSockAddr)
{
int iRet, iLoop = 1;
struct sockaddr_in sin;

int iSocket = socket (AF_INET, SOCK_DGRAM, 0);

if (iSocket < 0)
{
log_message( MSG_WARN, "socket() failed : %s\n",strerror(errno));
Interrupted=ERROR_NETWORK<<8;
}

sSockAddr->sin_family = sin.sin_family = AF_INET;
sSockAddr->sin_port = sin.sin_port = htons (port);
iRet=inet_aton (szAddr,&sSockAddr->sin_addr);
if (iRet == 0)
{
log_message( MSG_ERROR,"inet_aton failed : %s\n", strerror(errno));
Interrupted=ERROR_NETWORK<<8;
}
//We connect the socket
connect(iSocket,(struct sockaddr *) sSockAddr, sizeof(struct sockaddr_in));
if (iRet == 0)
{
log_message( MSG_ERROR,"connect failed : %s\n", strerror(errno));
Interrupted=ERROR_NETWORK<<8;
}


/*
iRet = setsockopt (iSocket, SOL_SOCKET, SO_REUSEADDR, &iLoop, sizeof (int));
if (iRet < 0)
{
log_message( MSG_ERROR,"setsockopt SO_REUSEADDR failed : %s\n",strerror(errno));
Interrupted=ERROR_NETWORK<<8;
}
*/
return iSocket;
}


/** @brief create a receiver socket, i.e. join the multicast group.
*@todo document
*/
Expand Down
2 changes: 2 additions & 0 deletions src/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ int makeclientsocket (char *szAddr, unsigned short port, int TTL, struct sockadd
int sendudp (int fd, struct sockaddr_in *sSockAddr, unsigned char *data, int len);
int makesocket (char *szAddr, unsigned short port, int TTL, struct sockaddr_in *sSockAddr);
int makeTCPclientsocket (char *szAddr, unsigned short port, struct sockaddr_in *sSockAddr);
int makeUDPsocket (char *szAddr, unsigned short port, struct sockaddr_in *sSockAddr);


#endif

Expand Down
Loading