diff options
author | Benjamin Otte <otte@gnome.org> | 2008-12-08 15:49:22 +0100 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2008-12-16 15:16:37 +0100 |
commit | 67ef5217b2fd682734526576ae0ceada7161723f (patch) | |
tree | 6d3f2770e0386b976d7890ea35c9c3fcfdacd338 | |
parent | f4fed1e8c62da3a03c04131b607699e520a7fcea (diff) |
make NetStream RPC actually work
-rw-r--r-- | swfdec/swfdec_net_stream.c | 6 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_channel.c | 2 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_rpc_channel.c | 26 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_rpc_channel.h | 4 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_socket.c | 4 |
5 files changed, 33 insertions, 9 deletions
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c index b0b37cd7..163a9e89 100644 --- a/swfdec/swfdec_net_stream.c +++ b/swfdec/swfdec_net_stream.c @@ -158,6 +158,8 @@ swfdec_net_stream_construct (SwfdecAsContext *cx, SwfdecAsObject *object, stream->conn = conn; swfdec_as_object_set_relay (o, SWFDEC_AS_RELAY (stream)); stream->rpc_channel = swfdec_rtmp_rpc_channel_new (conn); + swfdec_rtmp_rpc_channel_set_target (SWFDEC_RTMP_RPC_CHANNEL (stream->rpc_channel), + swfdec_as_relay_get_as_object (SWFDEC_AS_RELAY (stream))); stream->video_channel = swfdec_rtmp_video_channel_new (conn); /* FIXME: new class for audio plz */ stream->audio_channel = swfdec_rtmp_rpc_channel_new (conn); @@ -181,8 +183,8 @@ swfdec_net_stream_onCreate (SwfdecAsContext *cx, SwfdecAsObject *object, stream->stream_id = stream_id; channel_id = 4 + ((stream_id - 1) * 5); swfdec_rtmp_channel_register (stream->rpc_channel, channel_id, stream_id); - swfdec_rtmp_channel_register (stream->video_channel, channel_id, stream_id + 1); - swfdec_rtmp_channel_register (stream->audio_channel, channel_id, stream_id + 2); + swfdec_rtmp_channel_register (stream->video_channel, channel_id + 1, stream_id); + swfdec_rtmp_channel_register (stream->audio_channel, channel_id + 2, stream_id); } SWFDEC_AS_NATIVE (2101, 202, swfdec_net_stream_send_connection) diff --git a/swfdec/swfdec_rtmp_channel.c b/swfdec/swfdec_rtmp_channel.c index 7adbf26d..c8158096 100644 --- a/swfdec/swfdec_rtmp_channel.c +++ b/swfdec/swfdec_rtmp_channel.c @@ -180,6 +180,8 @@ swfdec_rtmp_channel_register (SwfdecRtmpChannel *channel, SWFDEC_FIXME ("figure out how huge ids (like %u) are handled. Channel registration failed", channel_id); return; } + SWFDEC_DEBUG ("registering %s as channel %u for stream %u", G_OBJECT_TYPE_NAME (channel), + channel_id, stream_id); conn = channel->conn; conn->channels = g_list_insert_sorted (conn->channels, channel, diff --git a/swfdec/swfdec_rtmp_rpc_channel.c b/swfdec/swfdec_rtmp_rpc_channel.c index 2a29842e..d056eb58 100644 --- a/swfdec/swfdec_rtmp_rpc_channel.c +++ b/swfdec/swfdec_rtmp_rpc_channel.c @@ -132,6 +132,7 @@ swfdec_rtmp_rpc_channel_receive_call (SwfdecRtmpChannel *channel, SwfdecAmfContext *cx, SwfdecAsValue val, SwfdecBits *bits) { SwfdecAsContext *context = swfdec_gc_object_get_context (channel->conn); + SwfdecRtmpRpcChannel *rpc = SWFDEC_RTMP_RPC_CHANNEL (channel); const char *name; guint id, i; SwfdecAsValue *args; @@ -153,13 +154,12 @@ swfdec_rtmp_rpc_channel_receive_call (SwfdecRtmpChannel *channel, return; } } - swfdec_as_relay_call (SWFDEC_AS_RELAY (channel->conn), name, - i, args, &val); + swfdec_as_object_call (rpc->target, name, i, args, &val); g_free (args); /* send reply */ if (id) { - swfdec_rtmp_rpc_channel_do_send (SWFDEC_RTMP_RPC_CHANNEL (channel), + swfdec_rtmp_rpc_channel_do_send (rpc, SWFDEC_AS_VALUE_FROM_STRING (SWFDEC_AS_STR__result), id, val, 0, NULL); } } @@ -173,9 +173,6 @@ swfdec_rtmp_rpc_channel_receive (SwfdecRtmpChannel *channel, SwfdecAsValue val; SwfdecBits bits; - if (header->stream != 0) { - SWFDEC_FIXME ("not stream 0, but stream %u here?!", header->stream); - } context = swfdec_gc_object_get_context (channel->conn); cx = swfdec_amf_context_new (context); swfdec_sandbox_use (channel->conn->sandbox); @@ -218,6 +215,8 @@ swfdec_rtmp_rpc_channel_mark (SwfdecRtmpChannel *channel) g_hash_table_iter_next (&iter, NULL, &value);) { swfdec_as_object_mark (value); } + + swfdec_as_object_mark (rpc->target); } static void @@ -289,8 +288,21 @@ swfdec_rtmp_rpc_channel_send (SwfdecRtmpRpcChannel *rpc, SwfdecRtmpChannel * swfdec_rtmp_rpc_channel_new (SwfdecRtmpConnection *conn) { + SwfdecRtmpRpcChannel *rpc; g_return_val_if_fail (SWFDEC_IS_RTMP_CONNECTION (conn), NULL); - return g_object_new (SWFDEC_TYPE_RTMP_RPC_CHANNEL, "connection", conn, NULL); + rpc = g_object_new (SWFDEC_TYPE_RTMP_RPC_CHANNEL, "connection", conn, NULL); + rpc->target = swfdec_as_relay_get_as_object (SWFDEC_AS_RELAY (conn)); + + return SWFDEC_RTMP_CHANNEL (rpc); +} + +void +swfdec_rtmp_rpc_channel_set_target (SwfdecRtmpRpcChannel *rpc, SwfdecAsObject *object) +{ + g_return_if_fail (SWFDEC_IS_RTMP_RPC_CHANNEL (rpc)); + g_return_if_fail (object != NULL); + + rpc->target = object; } diff --git a/swfdec/swfdec_rtmp_rpc_channel.h b/swfdec/swfdec_rtmp_rpc_channel.h index 316b9a75..b4b69b1e 100644 --- a/swfdec/swfdec_rtmp_rpc_channel.h +++ b/swfdec/swfdec_rtmp_rpc_channel.h @@ -39,6 +39,7 @@ typedef struct _SwfdecRtmpRpcChannelClass SwfdecRtmpRpcChannelClass; struct _SwfdecRtmpRpcChannel { SwfdecRtmpChannel channel; + SwfdecAsObject * target; /* object to call received calls on */ guint id; /* last id used for RPC call */ GHashTable * pending; /* int => SwfdecAsObject mapping of calls having pending replies */ GQueue * packets; /* outstanding packets */ @@ -61,6 +62,9 @@ void swfdec_rtmp_rpc_channel_send (SwfdecRtmpRpcChannel * rpc, guint argc, const SwfdecAsValue * argv); +void swfdec_rtmp_rpc_channel_set_target (SwfdecRtmpRpcChannel * rpc, + SwfdecAsObject * object); + G_END_DECLS #endif diff --git a/swfdec/swfdec_rtmp_socket.c b/swfdec/swfdec_rtmp_socket.c index 6ba90285..29acf92d 100644 --- a/swfdec/swfdec_rtmp_socket.c +++ b/swfdec/swfdec_rtmp_socket.c @@ -212,6 +212,10 @@ swfdec_rtmp_socket_receive (SwfdecRtmpSocket *sock, SwfdecBufferQueue *queue) SwfdecRtmpChannelClass *klass = SWFDEC_RTMP_CHANNEL_GET_CLASS (channel); g_assert (swfdec_buffer_queue_get_depth (channel->recv_queue) == 0); + if (header.stream != channel->stream_id) { + SWFDEC_FIXME ("channel has stream id %u, but message has stream id %u, is this bad?", + channel->stream_id, header.stream); + } klass->receive (channel, &header, buffer); swfdec_buffer_unref (buffer); } |