[dvblast-devel] patch SAP announcements generated from sdt
Georgi Chorbadzhiyski
gf at unixsol.org
Sun Oct 21 20:03:33 CEST 2012
On 10/19/12 5:22 PM, markus at selfnet.de wrote:
> we want to get rid of the minisapserver so we wrote an patch for dvblast which adds sap announcements. The announcements are generated from the Service Description Table (sdt). just add '--sap' to your startup parameters and your streams will be announced.
> we are looking forward to your feedback/comments. we know that it is just a very limited version, but the basic functionality is working fine for us (ipv4 + rtp + dvb-s).
> in general do you like the idea of integrated announce protocols?
As long as it is small, do not introduce external dependencies and makes sense
I see no problem with adding them.
> +\fB--sap\fR
> +announce streams via sdp/sap
Use proper sentences, please. Start with capital letter, put dot at the end.
> + msg_Raw( NULL, " --sap announce streams via sdp/sap");
We have finally run out of short options (good! sort options are evil!)
> msg_Raw( NULL, " -V --version only display the version" );
> msg_Raw( NULL, " -Z --mrtg-file <file> Log input packets and errors into mrtg-file" );
> exit(1);
> @@ -610,10 +614,12 @@ int main( int i_argc, char **pp_argv )
> { "mrtg-file", required_argument, NULL, 'Z' },
> { "ca-number", required_argument, NULL, 'y' },
> { "pidmap", required_argument, NULL, '0' },
> + { "sap", no_argument, &b_enable_sap, 1 },
Is this working? /I have not used getopt in such way/.
> +#include "dvblast.h"
> +#include "sap.h"
> +
> +// Reporting timer
> +#if defined( WIN32 )
> +static LARGE_INTEGER sap_time;
> +static LARGE_INTEGER sap_inc;
Do we even support dvblast on win32?
> +void sap_Init(void)
> +{
> +// socklen_t i_sockaddr_len = (p_config->i_family == AF_INET) ?
> +// sizeof(struct sockaddr_in) :
> +// sizeof(struct sockaddr_in6);
> +
> +// No IPv6 Support, yet TODO
Must be added before we commit this.
> + // Parsing SDT
> + uint8_t *sdt = pp_outputs[i_next_output]->p_sdt_section;
> + if(!sdt) return;
> +
> + uint16_t sid = sdt[11]<<8 | sdt[12]; // SID at byte [11,12]
Use bitstream functions.
> + int j,k;
> + k=0; // provider begins at 20
> + for(j=0; j<sdt[19] && j<499; j++) // end is stored in sdt[19]
> + if(sdt[j+20] >= 0x20)
> + service_provider[k++] = sdt[j+20];
> + service_provider[k] = 0;
> +
> + k=0; // service begins 1 byte after provider
> + for(j=0; j<sdt[20+sdt[19]] && j<499; j++)
> + if(sdt[21+sdt[19]+j] >= 0x20)
> + service_name[k++] = sdt[21+sdt[19]+j];
> + service_name[k] = 0;
Use bitstream functions.
> + char buffer[1500];
Why 1500?
> + char *worker = buffer;
> + char *worker_end = buffer+1500;
> +
> + // create the sap header
> + worker[0] = 0x20;
> + worker[1] = 0x00;
> + worker[2] = (sid>>8) & 0xff;
> + worker[3] = sid & 0xff;
> + worker+=4;
> +
> + worker += snprintf(worker, worker_end-worker, "\x01\x02\x03\x05");
> + worker += snprintf(worker, worker_end-worker, "application/sdp");
> + worker[0] = 0;
> + worker++;
> +
The code looks easily potable to IPv6. See:
http://long.ccaba.upc.es/long/045Guidelines/eva/ipv6.html
> +#ifndef SAP_H
> +#define SAP_H
> +
> +// Define the dump period in seconds
> +#define SAP_INTERVAL 1
> +#define SAP_IPv4_DEST "239.195.255.255"
> +#define SAP_IPv4_DPORT 9875
> +#define SAP_IPv4_TTL 255
Does these settings work for everyone?
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
More information about the dvblast-devel
mailing list