From: <ra...@fr...> - 2004-08-20 21:37:29
|
CVS Root: /cvs/gstreamer Module: gst-sandbox Changes by: ramon Date: Fri Aug 20 2004 14:37:28 PDT Log message: rtp_packet.c Implemented missing functions (warning: it does not compile) Modified files: rtpdec : gstrtpdec.c rtp_report.c todo Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-sandbox/rtpdec/gstrtpdec.c.diff?r1=1.11&r2=1.12 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-sandbox/rtpdec/rtp_report.c.diff?r1=1.14&r2=1.15 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-sandbox/rtpdec/todo.diff?r1=1.3&r2=1.4 ====Begin Diffs==== Index: gstrtpdec.c =================================================================== RCS file: /cvs/gstreamer/gst-sandbox/rtpdec/gstrtpdec.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- gstrtpdec.c 9 Apr 2004 14:00:33 -0000 1.11 +++ gstrtpdec.c 20 Aug 2004 21:37:15 -0000 1.12 @@ -1,7 +1,7 @@ /* Copyright (c) 2003 Ramon Garcia Fernandez - Sponsored by CSOA Laboratorio 3 http://laboratorio3.net Based on the template code copyright (C) 1999 Erik Walthinsen <om...@cs...> + With the support of the GStream developement team. */ #include <gst/gst.h> @@ -26,7 +26,6 @@ "Rtp decoder", "0.0", "Ramon Garcia Fernandez. " - "Sponsored by CSOA Laboratorio 3 http://laboratorio3.net", "(C) 2002, 2003" }; Index: rtp_report.c RCS file: /cvs/gstreamer/gst-sandbox/rtpdec/rtp_report.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- rtp_report.c 19 Aug 2004 23:09:50 -0000 1.14 +++ rtp_report.c 20 Aug 2004 21:37:15 -0000 1.15 @@ -17,7 +17,6 @@ #include "rtp_packet.h" /* Todo list in this file: - implement empty functions take care of races. The main thread removing a sender from the list, while we are building the RTCP message with the list of senders. */ @@ -68,9 +67,9 @@ static guint size_recv_report(guint num_recp_blocks); -static guint size_sdes_cname(GString* cname); +static guint size_sdes_cname(const GString* cname); -static void init_rtcp_cname(struct rtcp_sdes* sdes, guint32 myid, GString* cname); +static void init_rtcp_cname(const GstRtpdec* rtpdec, struct rtcp_sdes* sdes, guint32 myid, const GString* cname); static void fill_reception_block (struct reception_block *reception_block, const struct sender_info *sender_info); @@ -300,7 +299,7 @@ if (!buffer) { return; } - recv = (struct rtcp_recv_report *) recv; + recv = (struct rtcp_recv_report *) buffer; sdes_cname = (struct rtcp_sdes *) (recv + sizeof (struct rtcp_recv_report)); store_stats_in_rr (rtpdec, recv, num_recp_blocks); init_rtcp_cname (sdes_cname, rtpdec->myid, rtpdec->cname); @@ -397,11 +396,28 @@ } + +/* Evaluate how many reception records fit in a packet, taking into account the MTU */ static guint -decide_num_recp_blocks(const GstRtpdec * rtpdec) +decide_num_recp_blocks(const GstRtpdec * rtpdec, const GString* cname, gboolean do_bye) { - return 0; - /* FIXME: implement */ + guint base_size, factor, max_recp_blocks, num_recp_blocks; + guint factor31, num_31_blocks, num_reminder_recp; + base_size = sizeof(struct rtcp_recv_report) - sizeof(struct reception_block) + + size_sdes_cname(cname); + if (do_bye) { + base_size += sizeof(struct rtcp_bye); + } + factor = sizeof(struct reception_block); + factor31 = 31*factor + sizeof(rtcp_recv_report) - sizeof(struct reception_block); + num_31_blocks = (rtpdec->mtu - base_size)/factor31; + num_reminder_recp = (rtpdec->mtu - base_size - factor31*num31_blocks)/factor; + max_recp_blocks = num_reminder_recp + 31*num_31_blocks; + num_recp_blocks = g_hash_table_size(rtpdec->sender_list); + if (num_recp_blocks > max_recp_blocks) { + num_recp_blocks = max_recp_blocks; + return num_recp_blocks; /* Store statistics in a RTCP receiver record */ @@ -474,13 +490,14 @@ static void init_rtcp_bye(struct rtcp_bye* rtcp_bye, guint32 myid) + init_rtcp_common(rtcp_bye->common, BYE, sizeof(struct rtcp_bye), 1); + rtcp_bye->identifier[0] = myid; send_rtcp(const GstRtpdec* rtpdec, const char* buffer, guint32 bufsize) + gst_addr_try_send(rtpdec->control_socket, remote_address, remote_control_port, buffer, bufsize); @@ -488,21 +505,35 @@ size_recv_report(guint num_recp_block) - /* FIXME implement */ + guint size_block_31; + guint size_single_recp; + size_single_recp = sizeof(struct reception_block); + size_block_31 = sizeof(struct rtp_recv_report) + 30*sizeof(struct reception_block); + return (num_recp_block/31)*size_block_31 + (num_recp_block % 31)*size_single_recp; static guint -size_sdes_cname(GString* cname) +size_sdes_cname(const GString* cname) + gunit cname_item_size, chunk_size; + cname_item_size = sizeof(struct sdes_item) - 1 + cname->len; + chunk_size = sizeof(struct sdes_chunk) - sizeof(struct sdes_item) + cname_item_size; + chunk_size = ((chunk_size + 7)/8)*8; /* round up to next multiple of 8 */ + return sizeof(struct rtcp_sdes) - sizeof(struct sdes_chunk) + chunk_size; static void -init_rtcp_cname(struct rtcp_sdes* sdes, guint32 myid, GString* cname) +init_rtcp_cname(const GstRtpdec* rtpdec, struct rtcp_sdes* sdes, guint32 myid, const GString* cname) + struct sdes_chunk* chunk; + struct sdes_item* item; + init_rtcp_common(sdes->common, SDES, size_sdes_cname(cname), 1); + chunk = &sdes->chunks[0]; + chunk->identifier = myid; + item = &chunk->items[0]; + item->type = CNAME; + item->length = cname->len; + memcpy(item->text, cname->str, cname->len); Index: todo RCS file: /cvs/gstreamer/gst-sandbox/rtpdec/todo,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- todo 13 Aug 2004 10:30:53 -0000 1.3 +++ todo 20 Aug 2004 21:37:15 -0000 1.4 @@ -1,6 +1,5 @@ * Short term -Finish rtp_report.c: send_report. Update rtpdec.c, so that it sends a message when a new receiver is got or dropped. Remember, now we have new_num_members in GstRtpdec, that must be used for this purpose. Implement gclist.c and actually update GCLists. @@ -25,4 +24,4 @@ Warning: added identifier field to sender_info. Think about races. While the reporting thread is preparing the report, -the other thread removes an entry because of a BYE message. \ No newline at end of file +the other thread removes an entry because of a BYE message. |