summaryrefslogtreecommitdiffstats
path: root/gst/rtp/gstrtpvorbispay.c
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2007-04-12 11:41:11 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2007-04-12 11:41:11 +0000
commit2fc868841f152a80ac3dda9c0fe632e7ac0118ea (patch)
treeb96ddddc9b2efca498468a385c95bd768fa4c035 /gst/rtp/gstrtpvorbispay.c
parenta7efc5ceb7653a54c6ba29352c0f2c6df1d82555 (diff)
gst/rtp/Makefile.am: gst/rtp/fnv1hash.c (MASK_24, FNV1_HASH_32_INIT, FNV1_HASH_32_PRIME, fnv1_hash_32_new, fnv1_hash_...
Original commit message from CVS: * gst/rtp/Makefile.am: * gst/rtp/fnv1hash.c (MASK_24, FNV1_HASH_32_INIT, FNV1_HASH_32_PRIME, fnv1_hash_32_new, fnv1_hash_32_update, fnv1_hash_32_to_24): * gst/rtp/fnv1hash.h (__GST_FNV1_HASH_H__): Add a simple hashing implementation that we can use to generate a 24-bit ident value based on the codebooks for vorbis and theora. * gst/rtp/gstrtptheorapay.c (gst_rtp_theora_pay_finish_headers, gst_rtp_theora_pay_handle_buffer): * gst/rtp/gstrtpvorbisdepay.c (gst_rtp_vorbis_depay_parse_configuration, gst_rtp_vorbis_depay_switch_codebook, gst_rtp_vorbis_depay_process): * gst/rtp/gstrtpvorbispay.c (gst_rtp_vorbis_pay_reset_packet, gst_rtp_vorbis_pay_init_packet, gst_rtp_vorbis_pay_flush_packet, gst_rtp_vorbis_pay_finish_headers, gst_rtp_vorbis_pay_handle_buffer): Use the hashing function, ensuring that the same codebooks result in the same ident and thus the same SDP description. Various log fixes/changes.
Diffstat (limited to 'gst/rtp/gstrtpvorbispay.c')
-rw-r--r--gst/rtp/gstrtpvorbispay.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/gst/rtp/gstrtpvorbispay.c b/gst/rtp/gstrtpvorbispay.c
index 0482e0c5..35478a27 100644
--- a/gst/rtp/gstrtpvorbispay.c
+++ b/gst/rtp/gstrtpvorbispay.c
@@ -25,6 +25,7 @@
#include <gst/rtp/gstrtpbuffer.h>
+#include "fnv1hash.h"
#include "gstrtpvorbispay.h"
GST_DEBUG_CATEGORY_STATIC (rtpvorbispay_debug);
@@ -133,7 +134,7 @@ gst_rtp_vorbis_pay_reset_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT)
{
guint payload_len;
- GST_DEBUG_OBJECT (rtpvorbispay, "reset packet");
+ GST_LOG_OBJECT (rtpvorbispay, "reset packet");
rtpvorbispay->payload_pos = 4;
payload_len = gst_rtp_buffer_get_payload_len (rtpvorbispay->packet);
@@ -148,7 +149,7 @@ static void
gst_rtp_vorbis_pay_init_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT,
GstClockTime timestamp)
{
- GST_DEBUG_OBJECT (rtpvorbispay, "starting new packet, VDT: %d", VDT);
+ GST_LOG_OBJECT (rtpvorbispay, "starting new packet, VDT: %d", VDT);
if (rtpvorbispay->packet)
gst_buffer_unref (rtpvorbispay->packet);
@@ -172,7 +173,7 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay)
if (!rtpvorbispay->packet || rtpvorbispay->payload_pos <= 4)
return GST_FLOW_OK;
- GST_DEBUG_OBJECT (rtpvorbispay, "flushing packet");
+ GST_LOG_OBJECT (rtpvorbispay, "flushing packet");
/* fix header */
payload = gst_rtp_buffer_get_payload (rtpvorbispay->packet);
@@ -261,9 +262,13 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
/* count the size of the headers first */
length = 0;
+ ident = fnv1_hash_32_new ();
for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) {
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
+ ident =
+ fnv1_hash_32_update (ident, GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf));
length += GST_BUFFER_SIZE (buf);
}
@@ -278,8 +283,9 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
data[2] = 0;
data[3] = 1;
- /* we generate a random ident for this configuration */
- ident = rtpvorbispay->payload_ident = g_random_int ();
+ ident = fnv1_hash_32_to_24 (ident);
+ rtpvorbispay->payload_ident = ident;
+ GST_DEBUG_OBJECT (rtpvorbispay, "ident 0x%08x", ident);
/* take lower 3 bytes */
data[4] = (ident >> 16) & 0xff;
@@ -416,7 +422,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
duration = GST_BUFFER_DURATION (buffer);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
- GST_DEBUG_OBJECT (rtpvorbispay, "size %u, duration %" GST_TIME_FORMAT,
+ GST_LOG_OBJECT (rtpvorbispay, "size %u, duration %" GST_TIME_FORMAT,
size, GST_TIME_ARGS (duration));
if (G_UNLIKELY (size < 1 || size > 0xffff))
@@ -496,7 +502,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload,
while (size) {
plen = MIN (rtpvorbispay->payload_left - 2, size);
- GST_DEBUG_OBJECT (rtpvorbispay, "append %u bytes", plen);
+ GST_LOG_OBJECT (rtpvorbispay, "append %u bytes", plen);
/* data is copied in the payload with a 2 byte length header */
ppos[0] = (plen >> 8) & 0xff;