[SCM] Mumudvb packaging branch, upstream, updated. 24c2efb080b56abb8e7be67bae30ba7fe457759e
Brice DUBOST
braice at braice.net
Sat Nov 1 13:31:03 UTC 2008
The following commit has been merged in the upstream branch:
commit 79887ded04b04f5f49f44bda9fdcedfd55d98fc5
Author: Brice DUBOST <braice at braice.net>
Date: Sat Sep 20 21:32:40 2008 +0200
Generation of sap messages, no sending for the moment
diff --git a/src/Makefile b/src/Makefile
index deee3c1..a6e4277 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,7 +3,7 @@ CFLAGS = -Wall -Wextra -O2
IFLAGS = -g root -o root
OUT = mumudvb
-OBJ_FILES = mumudvb.o tune.o udp.o dvb.o pat_rewrite.o cam.o cam_en50221.o log.o ts.o autoconf.o
+OBJ_FILES = mumudvb.o tune.o udp.o dvb.o pat_rewrite.o cam.o cam_en50221.o log.o ts.o autoconf.o sap.o
SRC_FILES = $(OBJ_FILES:.o=.c)
ifdef DESTDIR
diff --git a/src/mumudvb.c b/src/mumudvb.c
index a89b3e6..73b0734 100644
--- a/src/mumudvb.c
+++ b/src/mumudvb.c
@@ -51,8 +51,7 @@
#include "ts.h"
#include "errors.h"
#include "autoconf.h"
-
-#define VERSION "1.5.0"
+#include "sap.h"
/* Signal handling code shamelessly copied from VDR by Klaus Schmidinger
@@ -82,6 +81,9 @@ 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 ?
//autoconfiguration
int autoconfiguration = 0; //Do we use autoconfiguration ?
@@ -377,6 +379,16 @@ main (int argc, char **argv)
"!!! You have enabled the support for autoconfiguration, this is a beta feature.Please report any bug/comment\n");
}
}
+ else if (!strcmp (substring, "sap"))
+ {
+ substring = strtok (NULL, delimiteurs);
+ sap = atoi (substring);
+ if(autoconfiguration)
+ {
+ log_message( MSG_WARN,
+ "!!! You have enabled the support for autoconfiguration, this is a beta feature.Please report any bug/comment\n");
+ }
+ }
else if (!strcmp (substring, "freq"))
{
substring = strtok (NULL, delimiteurs);
@@ -1317,6 +1329,12 @@ SignalHandler (int signum)
//end of autoconfiguration
else //we are not doing autoconfiguration we can do something else
{
+ //sap announces
+ //TODO : update only when it's needed
+ if(sap)
+ sap_update(channels[0], &sap_messages[0]);
+ //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))
{
diff --git a/src/mumudvb.h b/src/mumudvb.h
index df98825..badea7b 100644
--- a/src/mumudvb.h
+++ b/src/mumudvb.h
@@ -28,6 +28,8 @@
#ifndef _MUMUDVB_H
#define _MUMUDVB_H
+#define VERSION "1.5.0"
+
//#include "ts.h"
#include "udp.h" //for the sockaddr
diff --git a/src/sap.c b/src/sap.c
new file mode 100644
index 0000000..843db1d
--- /dev/null
+++ b/src/sap.c
@@ -0,0 +1,178 @@
+/*
+ * mumudvb - UDP-ize a DVB transport stream.
+ * File for Session Announcement Protocol Announces
+ *
+ * (C) Brice DUBOST
+ *
+ * The latest version can be found at http://mumudvb.braice.net
+ *
+ * Parts of this code is from the VLC project, modified for mumudvb
+ * by Brice DUBOST
+ *
+ * Copyright notice:
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "sap.h"
+#include "udp.h"
+#include <string.h>
+
+
+//SAP_init : define the version (rand 1,4242), clear the message and open the socket
+int sap_init(mumudvb_sap_message_t *sap_messages, int num_messages)
+{
+
+ return 0;
+}
+
+//SAP_send : send the sap message
+void sap_send(mumudvb_sap_message_t *sap_messages, int num_messages)
+{
+
+ return;
+}
+
+
+//SAP_update : update the contents of the sap message
+int sap_update(mumudvb_channel_t channel, mumudvb_sap_message_t *sap_message)
+{
+ //TAILLE DU PAQUET < MTU
+ //TODO : add debug messages
+
+ //This function is called when the channel changes so it increases the version and update the packet
+ char temp_string[256];
+
+ sap_message->version++;
+ sap_message->buf[0]=SAP_HEADER;
+ sap_message->buf[1]=SAP_HEADER2;
+ sap_message->buf[2]=(sap_message->version&0xff00)>>8;
+ sap_message->buf[3]=sap_message->version&0xff;
+
+ //TODO TODO //sap_message->buf[4 5 6 7]= IP;
+ sap_message->buf[4]=0;
+ sap_message->buf[5]=0;
+ sap_message->buf[6]=0;
+ sap_message->buf[7]=0;
+
+
+ //the mime type
+ sprintf(temp_string,"application/sdp");
+ memcpy(sap_message->buf + 8, temp_string, sizeof(temp_string));
+ sap_message->len=8+sizeof(temp_string);
+
+ //boucle sur les chaines
+
+ // one program per message
+ if(!sap_add_program(channel, sap_message))
+ sap_message->to_be_sent=1;
+ else
+ sap_message->to_be_sent=0;
+
+ return 0;
+
+}
+
+int sap_add_program(mumudvb_channel_t channel, mumudvb_sap_message_t *sap_message)
+{
+
+ //See RFC 2327
+ int payload_len=0;
+
+ char temp_string[256];
+
+
+ if(!channel.streamed_channel)
+ return 1;
+
+ //Now we write the sdp part
+
+ //version
+ //v=0
+
+ sprintf(temp_string,"v=0\r\n");
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+ //owner/creator and session identifier
+ //o=username session_id version network_type address_type address
+ //ex : o=mumudvb 123134 1 IN IP4 235.255.215.1
+ //find a way ta create session id
+ //for version we'll use sap version
+ //o=....
+
+ sprintf(temp_string,"o=mumudvb %d %d IN IP4 %s\r\n", sap_message->version, sap_message->version, channel.ipOut);
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+ //session name (basically channel name)
+ //s=...
+ sprintf(temp_string,"s=%s\r\n", channel.name);
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+
+ //connection information
+ //Ex : c=IN IP4 235.214.225.1/2
+ // the / is the TTL
+ //c=...
+
+ sprintf(temp_string,"o=%s/%d\r\n", channel.ipOut, DEFAULT_TTL);
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+ //time session is active
+ //t=...
+ //permanent : t=0 0
+
+ sprintf(temp_string,"t=0 0\r\n");
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+ //attributes : group and co, we'll take the minisapserver ones
+ //a=...
+ //a=tool:mumudvb-VERSION
+ //a=type:broadcast
+ //a=x-plgroup: //channel's group
+
+ sprintf(temp_string,"a=tool:mumudvb-VERSION\r\n");
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+ sprintf(temp_string,"a=type:broadcast\r\n");
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+ //media name and transport address
+ //m=...
+ //m=video channel_port udp mpeg
+
+ sprintf(temp_string,"m=video %d udp mpeg\r\n", channel.portOut);
+ memcpy(sap_message->buf + sap_message->len + payload_len, temp_string, sizeof(temp_string));
+ payload_len+=sizeof(temp_string);
+
+ //TODO : display the message for debug
+
+ log_message(MSG_DEBUG,"DEBUG : SAP payload\n");
+ log_message(MSG_DEBUG,sap_message->buf + sap_message->len);
+ log_message(MSG_DEBUG,"DEBUG : end of SAP payload\n");
+
+ sap_message->len+=payload_len;
+
+ //TODO : check packet size
+
+ return 0;
+
+}
diff --git a/src/udp.h b/src/sap.h
similarity index 51%
copy from src/udp.h
copy to src/sap.h
index 09b18ab..8011141 100644
--- a/src/udp.h
+++ b/src/sap.h
@@ -1,11 +1,14 @@
/*
* mumudvb - UDP-ize a DVB transport stream.
- * Based on dvbstream by (C) Dave Chapman <dave at dchapman.com> 2001, 2002.
+ * File for Session Announcement Protocol Announces
*
* (C) Brice DUBOST
*
* The latest version can be found at http://mumudvb.braice.net
*
+ * Parts of this code is from the VLC project, modified for mumudvb
+ * by Brice DUBOST
+ *
* Copyright notice:
*
* This program is free software; you can redistribute it and/or modify
@@ -21,35 +24,35 @@
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
*/
-#ifndef _UDP_H
-#define _UDP_H
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <arpa/inet.h>
-#include <syslog.h>
-#include <stdio.h>
-#include <stdlib.h>
+#ifndef _SAP_H
+#define _SAP_H
#include "mumudvb.h"
-/* udp */
-/* Output: {uni,multi,broad}cast socket */
+//From RFC 2974
+#define SAP_IP "224.2.127.254"
+#define SAP_PORT 9875
+#define SAP_TTL 255
-//The default time to live
-#define DEFAULT_TTL 2
+//intervall between sap announces
+#define SAP_INTERVAL 5
-int makeclientsocket (char *szAddr, unsigned short port, int TTL, struct sockaddr_in *sSockAddr);
-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);
+#define SAP_HEADER 0x20 //00100000 : version 1 and nothing else
+#define SAP_HEADER2 0x00 //No auth header
+//sap_message
+typedef struct{
+ unsigned char buf[MAX_UDP_SIZE]; //the buffer
+ int len; //Lenght of the sap message
+ int version; //the version of the sap message, MUST be changed when sap changes
+ int to_be_sent;
+}mumudvb_sap_message_t;
-#endif
+int sap_update(mumudvb_channel_t channel, mumudvb_sap_message_t *sap_message);
+int sap_add_program(mumudvb_channel_t channel, mumudvb_sap_message_t *sap_message);
+#endif
--
Mumudvb packaging
More information about the pkg-vdr-dvb-changes
mailing list