[dvblast-devel] patch SAP announcements generated from sdt

dirkmb at selfnet.de dirkmb at selfnet.de
Wed Nov 7 22:12:22 CET 2012


Hey,

thanks to you both for your comments.

We re-read the RFC and changed some stuff. There are some more options 
(it's now possible to set the IP to which SAP is sent)


On 2012-10-21 20:03, Georgi Chorbadzhiyski wrote:
> 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!)

yeah we noticed ;)



>>           { "pidmap",          required_argument, NULL, '0' },
>> +        { "sap",             no_argument,       &b_enable_sap,  1  
>> },
>
> Is this working? /I have not used getopt in such way/.
>

Yes it is. When the long option 'sap' is found the value '1' is set to 
b_enable_sap. It is a very easy way to set values to variables depending 
if an option is set or not.



>> +// Reporting timer
>> +#if defined( WIN32 )
>> +static LARGE_INTEGER sap_time;
>
> Do we even support dvblast on win32?

Do not know, but since we use now the internal time of dvblast this 
part was removed.



>> +// No IPv6 Support, yet TODO
>
> Must be added before we commit this.

We know, so we are working on it. It is working but we had not the time 
to test it properly.



>> +    // 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.

We now use these 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.

Same here


>
>> +    char buffer[1500];
>
> Why 1500?

1500 was replaced with the maximum packet size.
1500 is the MTU in our network.


>
>> +    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

Thanks, it was helpful ;)



>> +#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?

The port: yes.
The TTL of the stream is now used for the TTL of the announcement.
IPv4 and IPv6 address can be configured with an additional start-up 
parameter. There might be some circumstances where it is not possible to 
calculate the IP to which SAP is sent from the destination of the 
stream. So we decided to make it possible to set these IP Addresses 
manually.
The interval is also configurable. The RFC says how many SAP 
announcements should be sent per second all together, since we do not 
know how many programs are sending announcements it must be possible to 
be configured manually.


A new feature is that we now get the name of the current show (by 
parsing EIT). SAP has an 'information' field which could be used for 
displaying this information.
Most of our users use VLC for watching our streams; unfortunately, VLC 
does not display this field anywhere (XBMC does). For this reason we 
added the name of the show to the channel name (yes it is an ugly 
workaround which we hope to remove in the future once VLC adds this 
feature).



There are some details with the hash of the announcements which should 
be resolved (it is not being changed when the channel/show name is 
changed) and we want to test the IPv6 support properly before we publish 
a new patch, but it will come ;)

Greetings,
Dirk, Tillmann and Markus


More information about the dvblast-devel mailing list