summaryrefslogtreecommitdiffstats
path: root/gst/rtp/gstrtptheorapay.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/gstrtptheorapay.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/gstrtptheorapay.c')
-rw-r--r--gst/rtp/gstrtptheorapay.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/gst/rtp/gstrtptheorapay.c b/gst/rtp/gstrtptheorapay.c
index db8a5872..418b9f0c 100644
--- a/gst/rtp/gstrtptheorapay.c
+++ b/gst/rtp/gstrtptheorapay.c
@@ -25,6 +25,7 @@
#include <gst/rtp/gstrtpbuffer.h>
+#include "fnv1hash.h"
#include "gstrtptheorapay.h"
#define THEORA_ID_LEN 42
@@ -230,8 +231,11 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
goto no_headers;
/* we need exactly 2 header packets */
- if (g_list_length (rtptheorapay->headers) != 2)
+ if (g_list_length (rtptheorapay->headers) != 2) {
+ GST_DEBUG_OBJECT (rtptheorapay, "We need 2 headers but have %d",
+ g_list_length (rtptheorapay->headers));
goto no_headers;
+ }
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Number of packed headers |
@@ -266,9 +270,13 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
/* count the size of the headers first */
length = 0;
+ ident = fnv1_hash_32_new ();
for (walk = rtptheorapay->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);
}
@@ -283,8 +291,8 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
data[2] = 0;
data[3] = 1;
- /* we generate a random ident for this configuration */
- ident = rtptheorapay->payload_ident = g_random_int ();
+ ident = fnv1_hash_32_to_24 (ident);
+ rtptheorapay->payload_ident = ident;
/* take lower 3 bytes */
data[4] = (ident >> 16) & 0xff;
@@ -427,7 +435,8 @@ gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload,
if (data[0] & 0x80) {
/* header */
if (data[0] == 0x80) {
- /* identification, we need to parse this in order to get the clock rate. */
+ /* identification, we need to parse this in order to get the clock rate.
+ */
if (G_UNLIKELY (!gst_rtp_theora_pay_parse_id (basepayload, data, size)))
goto parse_id_failed;
TDT = 1;
@@ -451,7 +460,7 @@ gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload,
ret = GST_FLOW_OK;
goto done;
} else if (TDT != 0) {
- GST_DEBUG_OBJECT (rtptheorapay, "collecting header");
+ GST_DEBUG_OBJECT (rtptheorapay, "collecting header, buffer %p", buffer);
/* append header to the list of headers */
rtptheorapay->headers = g_list_append (rtptheorapay->headers, buffer);
ret = GST_FLOW_OK;