summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2008-12-09 19:06:34 +0100
committerBenjamin Otte <otte@gnome.org>2008-12-16 15:16:39 +0100
commite5e3f15d026b3774b44fccf5c9b5f2fc2f960275 (patch)
tree2a2696e05ea179a7117cb42e2cd520651429193c
parent31ee9ceb97360f10595678b76bad7d29700f9fcf (diff)
handle notify calls
-rw-r--r--swfdec/swfdec_net_stream.c5
-rw-r--r--swfdec/swfdec_rtmp_connection.c5
-rw-r--r--swfdec/swfdec_rtmp_rpc.c46
-rw-r--r--swfdec/swfdec_rtmp_rpc.h2
4 files changed, 58 insertions, 0 deletions
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
index 02c33cc2..b25bb38d 100644
--- a/swfdec/swfdec_net_stream.c
+++ b/swfdec/swfdec_net_stream.c
@@ -41,6 +41,11 @@ swfdec_net_stream_rtmp_stream_receive (SwfdecRtmpStream *rtmp_stream,
SwfdecNetStream *stream = SWFDEC_NET_STREAM (rtmp_stream);
switch ((guint) header->type) {
+ case SWFDEC_RTMP_PACKET_NOTIFY:
+ swfdec_sandbox_use (stream->conn->sandbox);
+ swfdec_rtmp_rpc_notify (stream->rpc, buffer);
+ swfdec_sandbox_unuse (stream->conn->sandbox);
+ break;
case SWFDEC_RTMP_PACKET_INVOKE:
swfdec_sandbox_use (stream->conn->sandbox);
if (swfdec_rtmp_rpc_receive (stream->rpc, buffer)) {
diff --git a/swfdec/swfdec_rtmp_connection.c b/swfdec/swfdec_rtmp_connection.c
index f11fdbf4..c8414848 100644
--- a/swfdec/swfdec_rtmp_connection.c
+++ b/swfdec/swfdec_rtmp_connection.c
@@ -142,6 +142,11 @@ swfdec_rtmp_connection_rtmp_stream_receive (SwfdecRtmpStream *stream,
case SWFDEC_RTMP_PACKET_CLIENT_BANDWIDTH:
swfdec_rtmp_connection_handle_client_bandwidth (conn, buffer);
break;
+ case SWFDEC_RTMP_PACKET_NOTIFY:
+ swfdec_sandbox_use (conn->sandbox);
+ swfdec_rtmp_rpc_notify (conn->rpc, buffer);
+ swfdec_sandbox_unuse (conn->sandbox);
+ break;
case SWFDEC_RTMP_PACKET_INVOKE:
swfdec_sandbox_use (conn->sandbox);
if (swfdec_rtmp_rpc_receive (conn->rpc, buffer)) {
diff --git a/swfdec/swfdec_rtmp_rpc.c b/swfdec/swfdec_rtmp_rpc.c
index e539bde1..bf8a2cd7 100644
--- a/swfdec/swfdec_rtmp_rpc.c
+++ b/swfdec/swfdec_rtmp_rpc.c
@@ -192,6 +192,9 @@ swfdec_rtmp_rpc_receive (SwfdecRtmpRpc *rpc, SwfdecBuffer *buffer)
SwfdecBits bits;
gboolean result;
+ g_return_val_if_fail (rpc != NULL, FALSE);
+ g_return_val_if_fail (buffer != NULL, FALSE);
+
context = swfdec_gc_object_get_context (rpc->conn);
cx = swfdec_amf_context_new (context);
g_assert (context->global);
@@ -217,6 +220,49 @@ swfdec_rtmp_rpc_receive (SwfdecRtmpRpc *rpc, SwfdecBuffer *buffer)
return result;
}
+void
+swfdec_rtmp_rpc_notify (SwfdecRtmpRpc *rpc, SwfdecBuffer *buffer)
+{
+ SwfdecAsContext *context;
+ SwfdecAmfContext *cx;
+ SwfdecAsValue *args;
+ SwfdecAsValue name;
+ SwfdecBits bits;
+ guint i;
+
+ g_return_if_fail (rpc != NULL);
+ g_return_if_fail (buffer != NULL);
+
+ context = swfdec_gc_object_get_context (rpc->conn);
+ cx = swfdec_amf_context_new (context);
+ g_assert (context->global);
+ swfdec_bits_init (&bits, buffer);
+
+ if (!swfdec_amf_decode (cx, &bits, &name)) {
+ SWFDEC_ERROR ("could not decode name");
+ return;
+ }
+
+ args = NULL;
+ for (i = 0; swfdec_bits_left (&bits); i++) {
+ if ((i % 4) == 0)
+ args = g_realloc (args, sizeof (SwfdecAsValue) * (i + 4));
+
+ if (!swfdec_amf_decode (cx, &bits, &args[i])) {
+ SWFDEC_ERROR ("could not decode argument %u", i);
+ return;
+ }
+ }
+ swfdec_as_relay_call (rpc->target, swfdec_as_value_to_string (context, name),
+ i, args, NULL);
+ g_free (args);
+
+ swfdec_amf_context_free (cx);
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_FIXME ("%u bytes left after invoke", swfdec_bits_left (&bits) / 8);
+ }
+}
+
SwfdecRtmpPacket *
swfdec_rtmp_rpc_pop (SwfdecRtmpRpc *rpc, gboolean pull_if_pending)
{
diff --git a/swfdec/swfdec_rtmp_rpc.h b/swfdec/swfdec_rtmp_rpc.h
index 3ca46e61..f7d1a790 100644
--- a/swfdec/swfdec_rtmp_rpc.h
+++ b/swfdec/swfdec_rtmp_rpc.h
@@ -57,6 +57,8 @@ void swfdec_rtmp_rpc_send (SwfdecRtmpRpc * rpc,
const SwfdecAsValue * argv);
gboolean swfdec_rtmp_rpc_receive (SwfdecRtmpRpc * rpc,
SwfdecBuffer * buffer);
+void swfdec_rtmp_rpc_notify (SwfdecRtmpRpc * rpc,
+ SwfdecBuffer * buffer);
G_END_DECLS