[SCM] Mumudvb packaging branch, upstream, updated. 24c2efb080b56abb8e7be67bae30ba7fe457759e
Brice DUBOST
braice at braice.net
Sat Nov 1 13:31:04 UTC 2008
The following commit has been merged in the upstream branch:
commit 1654b5cab7a1b9dcb2b89d0ae43a503c9847a409
Merge: af8596ce9f74b323e4f793f92c40e95aa80e6bf8 cfb3767eefd1bcf4adbdda8b3a70d814a52e3df8
Author: Brice DUBOST <braice at braice.net>
Date: Tue Sep 23 22:04:00 2008 +0200
Merge branch 'sap'
diff --combined src/mumudvb.c
index 9616612,c83e649..f442e29
--- a/src/mumudvb.c
+++ b/src/mumudvb.c
@@@ -52,8 -52,7 +52,7 @@@
#include "ts.h"
#include "errors.h"
#include "autoconf.h"
-
- #define VERSION "1.5.0"
+ #include "sap.h"
extern uint32_t crc32_table[256];
@@@ -84,6 -83,11 +83,11 @@@ char nom_fich_chaines_non_diff[256]
char nom_fich_pid[256];
int write_streamed_channels=1;
+ //sap announces
+ mumudvb_sap_message_t sap_messages[MAX_CHANNELS]; //the sap message... //TODO : allocate dynamically
+ int sap=0; //do we send sap announces ?
+ int sap_interval=SAP_DEFAULT_INTERVAL;
+ char sap_sending_ip[20]="0.0.0.0";
//autoconfiguration
int autoconfiguration = 0; //Do we use autoconfiguration ?
@@@ -232,6 -236,8 +236,8 @@@ main (int argc, char **argv
};
int c, option_index = 0;
+ //paranoia
+ sap_organisation[0]=0;
// Initialise PID map
for (k = 0; k < 8192; k++)
@@@ -368,11 -374,56 +374,56 @@@
{
substring = strtok (NULL, delimiteurs);
autoconfiguration = atoi (substring);
- if(autoconfiguration)
+ if((autoconfiguration==1)||(autoconfiguration==2))
{
log_message( MSG_WARN,
"!!! You have enabled the support for autoconfiguration, this is a beta feature.Please report any bug/comment\n");
}
+ else
+ autoconfiguration=0;
+ if(autoconfiguration==2)
+ {
+ log_message( MSG_INFO,
+ "Full autoconfiguration, we activate SAP announces. if you want to desactivate them see the README.\n");
+ sap=1;
+ }
+ }
+ else if (!strcmp (substring, "sap"))
+ {
+ substring = strtok (NULL, delimiteurs);
+ sap = atoi (substring);
+ if(sap)
+ {
+ log_message( MSG_WARN,
+ "!!! You have enabled the support for sap announces, this is a beta feature.Please report any bug/comment\n");
+ }
+ }
+ else if (!strcmp (substring, "sap_interval"))
+ {
+ substring = strtok (NULL, delimiteurs);
+ sap_interval = atoi (substring);
+ }
+ else if (!strcmp (substring, "sap_organisation"))
+ {
+ // other substring extraction method in order to keep spaces
+ substring = strtok (NULL, "=");
+ if (!(strlen (substring) >= 255 - 1))
+ strcpy(sap_organisation,strtok(substring,"\n"));
+ else
+ {
+ log_message( MSG_INFO,"Sap Organisation name too long\n");
+ }
+ }
+ else if (!strcmp (substring, "sap_sending_ip"))
+ {
+ substring = strtok (NULL, delimiteurs);
+ if(strlen(substring)>19)
+ {
+ log_message( MSG_ERROR,
+ "The sap sending ip is too long\n");
+ exit(ERROR_CONF);
+ }
+ sscanf (substring, "%s\n", sap_sending_ip);
}
else if (!strcmp (substring, "freq"))
{
@@@ -418,15 -469,26 +469,32 @@@
else if (!strcmp (substring, "ip"))
{
substring = strtok (NULL, delimiteurs);
+ if(strlen(substring)>19)
+ {
+ log_message( MSG_ERROR,
+ "The Ip address %s is too long.\n", substring);
+ exit(ERROR_CONF);
+ }
sscanf (substring, "%s\n", channels[curr_channel].ipOut);
ip_ok = 1;
}
+ else if (!strcmp (substring, "sap_group"))
+ {
+ if (sap==0)
+ {
+ log_message( MSG_WARN,
+ "Warning : you have not activated sap, the sap group will not be taken in account\n");
+
+ }
+ substring = strtok (NULL, "=");
+ if(strlen(substring)>19)
+ {
+ log_message( MSG_ERROR,
+ "The sap group is too long\n");
+ exit(ERROR_CONF);
+ }
+ sscanf (substring, "%s\n", channels[curr_channel].sap_group);
+ }
else if (!strcmp (substring, "common_port"))
{
substring = strtok (NULL, delimiteurs);
@@@ -635,6 -697,7 +703,7 @@@
//end of config file reading
/******************************************************/
+
number_of_channels = curr_channel;
if (curr_channel > MAX_CHANNELS)
{
@@@ -906,6 -969,23 +975,23 @@@
channels[curr_channel].socketOut = makeclientsocket (channels[curr_channel].ipOut, channels[curr_channel].portOut, DEFAULT_TTL, &channels[curr_channel].sOut);
}
+
+ /*****************************************************/
+ // init sap
+ /*****************************************************/
+
+ if(sap)
+ {
+ //For sap announces, we open the socket
+ sap_socketOut = makeclientsocket (SAP_IP, SAP_PORT, SAP_TTL, &sap_sOut);
+ if(!strlen(sap_organisation))
+ sprintf(sap_organisation,"mumudvb");
+ sap_serial= 1 + (int) (424242.0 * (rand() / (RAND_MAX + 1.0)));
+ sap_last_time_sent = 0;
+ //todo : loop to create the version
+ }
+
+
/*****************************************************/
// Information about streamed channels
/*****************************************************/
@@@ -1305,6 -1385,23 +1391,23 @@@ SignalHandler (int signum
//end of autoconfiguration
else //we are not doing autoconfiguration we can do something else
{
+ //sap announces
+ if(!sap_last_time_sent)
+ {
+ // it's the first time we are here, we initialize all the channels
+ for (curr_channel = 0; curr_channel < number_of_channels; curr_channel++)
+ {
+ sap_update(channels[curr_channel], &sap_messages[curr_channel]);
+ }
+ sap_last_time_sent=now-sap_interval-1;
+ }
+ if((now-sap_last_time_sent)>=sap_interval)
+ {
+ sap_send(sap_messages, number_of_channels);
+ sap_last_time_sent=now;
+ }
+ //end of sap announces
+
for (curr_channel = 0; curr_channel < number_of_channels; curr_channel++)
if ((channels[curr_channel].streamed_channel >= 100) && (!channels[curr_channel].streamed_channel_old))
{
@@@ -1312,6 -1409,7 +1415,7 @@@
"Channel \"%s\" back.Card %d\n",
channels[curr_channel].name, card);
channels[curr_channel].streamed_channel_old = 1; // update
+ sap_update(channels[curr_channel], &sap_messages[curr_channel]);
}
else if ((channels[curr_channel].streamed_channel_old) && (channels[curr_channel].streamed_channel < 30))
{
@@@ -1319,6 -1417,7 +1423,7 @@@
"Channel \"%s\" down.Card %d\n",
channels[curr_channel].name, card);
channels[curr_channel].streamed_channel_old = 0; // update
+ sap_update(channels[curr_channel], &sap_messages[curr_channel]);
}
/*******************************************/
--
Mumudvb packaging
More information about the pkg-vdr-dvb-changes
mailing list