diff options
author | Benjamin Otte <otte@gnome.org> | 2008-12-10 11:07:45 +0100 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2008-12-16 21:38:14 +0100 |
commit | 282eea7488ef6b4e43b278438917218bb350e4e8 (patch) | |
tree | 01d059f9913b2bb8872c814615a1118fda27ad24 | |
parent | 09a4dee2e0ec10d198da7f810cab9d076b26954e (diff) |
stub out the ping messages
-rw-r--r-- | swfdec/swfdec_net_stream.c | 23 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_connection.c | 72 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_connection.h | 2 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_socket.c | 2 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_stream.c | 33 | ||||
-rw-r--r-- | swfdec/swfdec_rtmp_stream.h | 13 |
6 files changed, 142 insertions, 3 deletions
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c index 137b4ad8..0478d31a 100644 --- a/swfdec/swfdec_net_stream.c +++ b/swfdec/swfdec_net_stream.c @@ -73,14 +73,37 @@ static SwfdecRtmpPacket * swfdec_net_stream_rtmp_stream_sent (SwfdecRtmpStream *stream, const SwfdecRtmpPacket *packet) { + SWFDEC_FIXME ("implement"); + return NULL; } static void +swfdec_net_stream_rtmp_stream_sync (SwfdecRtmpStream *stream) +{ + SWFDEC_FIXME ("implement"); +} + +static void +swfdec_net_stream_rtmp_stream_flush (SwfdecRtmpStream *stream) +{ + SWFDEC_FIXME ("implement"); +} + +static void +swfdec_net_stream_rtmp_stream_clear (SwfdecRtmpStream *stream) +{ + SWFDEC_FIXME ("implement"); +} + +static void swfdec_net_stream_rtmp_stream_init (SwfdecRtmpStreamInterface *iface) { iface->receive = swfdec_net_stream_rtmp_stream_receive; iface->sent = swfdec_net_stream_rtmp_stream_sent; + iface->sync = swfdec_net_stream_rtmp_stream_sync; + iface->flush = swfdec_net_stream_rtmp_stream_flush; + iface->clear = swfdec_net_stream_rtmp_stream_clear; } /*** NET STREAM ***/ diff --git a/swfdec/swfdec_rtmp_connection.c b/swfdec/swfdec_rtmp_connection.c index c8414848..7af8bf7a 100644 --- a/swfdec/swfdec_rtmp_connection.c +++ b/swfdec/swfdec_rtmp_connection.c @@ -66,16 +66,57 @@ swfdec_rtmp_connection_handle_chunk_size (SwfdecRtmpConnection *conn, SwfdecBuff } } +enum { + SWFDEC_RTMP_PING_SYNC = 0, + SWFDEC_RTMP_PING_FLUSH = 1, + SWFDEC_RTMP_PING_BUFFERTIME = 3, + SWFDEC_RTMP_PING_CLEAR = 4, + SWFDEC_RTMP_PING_PING = 6, + SWFDEC_RTMP_PING_PONG = 7 +}; + static void swfdec_rtmp_connection_handle_ping (SwfdecRtmpConnection *conn, SwfdecBuffer *buffer) { SwfdecBits bits; guint type, target; + SwfdecRtmpStream *stream; swfdec_bits_init (&bits, buffer); type = swfdec_bits_get_bu16 (&bits); target = swfdec_bits_get_bu32 (&bits); - SWFDEC_FIXME ("handle ping type %u for target %u", type, target); + switch (type) { + case SWFDEC_RTMP_PING_SYNC: + stream = swfdec_rtmp_connection_get_stream (conn, target); + if (stream) { + swfdec_rtmp_stream_sync (stream); + } else { + SWFDEC_ERROR ("got sync ping for stream %u, but no such stream", target); + } + break; + case SWFDEC_RTMP_PING_FLUSH: + stream = swfdec_rtmp_connection_get_stream (conn, target); + if (stream) { + swfdec_rtmp_stream_flush (stream); + } else { + SWFDEC_ERROR ("got flush ping for stream %u, but no such stream", target); + } + break; + case SWFDEC_RTMP_PING_CLEAR: + stream = swfdec_rtmp_connection_get_stream (conn, target); + if (stream) { + swfdec_rtmp_stream_clear (stream); + } else { + SWFDEC_ERROR ("got clear ping for stream %u, but no such stream", target); + } + break; + case SWFDEC_RTMP_PING_BUFFERTIME: + case SWFDEC_RTMP_PING_PING: + case SWFDEC_RTMP_PING_PONG: + default: + SWFDEC_FIXME ("handle ping type %u for target %u", type, target); + break; + } } static void @@ -203,10 +244,31 @@ swfdec_rtmp_connection_rtmp_stream_sent (SwfdecRtmpStream *stream, } static void +swfdec_rtmp_connection_rtmp_stream_sync (SwfdecRtmpStream *stream) +{ + SWFDEC_FIXME ("implement"); +} + +static void +swfdec_rtmp_connection_rtmp_stream_flush (SwfdecRtmpStream *stream) +{ + SWFDEC_FIXME ("implement"); +} + +static void +swfdec_rtmp_connection_rtmp_stream_clear (SwfdecRtmpStream *stream) +{ + SWFDEC_FIXME ("implement"); +} + +static void swfdec_rtmp_connection_rtmp_stream_init (SwfdecRtmpStreamInterface *iface) { iface->receive = swfdec_rtmp_connection_rtmp_stream_receive; iface->sent = swfdec_rtmp_connection_rtmp_stream_sent; + iface->sync = swfdec_rtmp_connection_rtmp_stream_sync; + iface->flush = swfdec_rtmp_connection_rtmp_stream_flush; + iface->clear = swfdec_rtmp_connection_rtmp_stream_clear; } /*** SwfdecRtmpConnection ***/ @@ -403,6 +465,14 @@ swfdec_rtmp_connection_unregister_stream (SwfdecRtmpConnection *conn, guint id) } } +SwfdecRtmpStream * +swfdec_rtmp_connection_get_stream (SwfdecRtmpConnection *conn, guint id) +{ + g_return_val_if_fail (SWFDEC_IS_RTMP_CONNECTION (conn), NULL); + + return g_hash_table_lookup (conn->streams, GUINT_TO_POINTER (id)); +} + void swfdec_rtmp_connection_send (SwfdecRtmpConnection *conn, SwfdecRtmpPacket *packet) { diff --git a/swfdec/swfdec_rtmp_connection.h b/swfdec/swfdec_rtmp_connection.h index ed0f3234..4d86cbd5 100644 --- a/swfdec/swfdec_rtmp_connection.h +++ b/swfdec/swfdec_rtmp_connection.h @@ -100,6 +100,8 @@ void swfdec_rtmp_connection_register_stream (SwfdecRtmpConnection * conn, SwfdecRtmpStream * stream); void swfdec_rtmp_connection_unregister_stream(SwfdecRtmpConnection * conn, guint id); +SwfdecRtmpStream * swfdec_rtmp_connection_get_stream (SwfdecRtmpConnection * conn, + guint id); G_END_DECLS diff --git a/swfdec/swfdec_rtmp_socket.c b/swfdec/swfdec_rtmp_socket.c index 7bacb34b..32364d25 100644 --- a/swfdec/swfdec_rtmp_socket.c +++ b/swfdec/swfdec_rtmp_socket.c @@ -139,7 +139,7 @@ next_packet: SwfdecRtmpStream *stream; SwfdecRtmpPacket *next; - stream = g_hash_table_lookup (conn->streams, GUINT_TO_POINTER (packet->header.stream)); + stream = swfdec_rtmp_connection_get_stream (conn, packet->header.stream); if (stream == NULL) { swfdec_rtmp_packet_free (packet); goto next_packet; diff --git a/swfdec/swfdec_rtmp_stream.c b/swfdec/swfdec_rtmp_stream.c index 4cb4595d..590046b0 100644 --- a/swfdec/swfdec_rtmp_stream.c +++ b/swfdec/swfdec_rtmp_stream.c @@ -86,3 +86,36 @@ swfdec_rtmp_stream_sent (SwfdecRtmpStream *stream, const SwfdecRtmpPacket *packe iface = SWFDEC_RTMP_STREAM_GET_INTERFACE (stream); return iface->sent (stream, packet); } + +void +swfdec_rtmp_stream_sync (SwfdecRtmpStream *stream) +{ + SwfdecRtmpStreamInterface *iface; + + g_return_if_fail (SWFDEC_IS_RTMP_STREAM (stream)); + + iface = SWFDEC_RTMP_STREAM_GET_INTERFACE (stream); + iface->sync (stream); +} + +void +swfdec_rtmp_stream_flush (SwfdecRtmpStream *stream) +{ + SwfdecRtmpStreamInterface *iface; + + g_return_if_fail (SWFDEC_IS_RTMP_STREAM (stream)); + + iface = SWFDEC_RTMP_STREAM_GET_INTERFACE (stream); + iface->flush (stream); +} + +void +swfdec_rtmp_stream_clear (SwfdecRtmpStream *stream) +{ + SwfdecRtmpStreamInterface *iface; + + g_return_if_fail (SWFDEC_IS_RTMP_STREAM (stream)); + + iface = SWFDEC_RTMP_STREAM_GET_INTERFACE (stream); + iface->clear (stream); +} diff --git a/swfdec/swfdec_rtmp_stream.h b/swfdec/swfdec_rtmp_stream.h index a700952e..1aba25a9 100644 --- a/swfdec/swfdec_rtmp_stream.h +++ b/swfdec/swfdec_rtmp_stream.h @@ -36,12 +36,16 @@ typedef struct _SwfdecRtmpStreamInterface SwfdecRtmpStreamInterface; struct _SwfdecRtmpStreamInterface { GTypeInterface parent; - /* mandatory vfunc */ + /* mandatory vfuncs */ void (* receive) (SwfdecRtmpStream * stream, const SwfdecRtmpHeader * header, SwfdecBuffer * buffer); SwfdecRtmpPacket * (* sent) (SwfdecRtmpStream * stream, const SwfdecRtmpPacket * packet); + + void (* sync) (SwfdecRtmpStream * stream); + void (* flush) (SwfdecRtmpStream * stream); + void (* clear) (SwfdecRtmpStream * stream); }; GType swfdec_rtmp_stream_get_type (void) G_GNUC_CONST; @@ -51,6 +55,13 @@ void swfdec_rtmp_stream_receive (SwfdecRtmpStream * stream, SwfdecRtmpPacket * swfdec_rtmp_stream_sent (SwfdecRtmpStream * stream, const SwfdecRtmpPacket *packet); +/* Ping type 0 */ +void swfdec_rtmp_stream_sync (SwfdecRtmpStream * stream); +/* Ping type 1 */ +void swfdec_rtmp_stream_flush (SwfdecRtmpStream * stream); +/* Ping type 4 */ +void swfdec_rtmp_stream_clear (SwfdecRtmpStream * stream); + G_END_DECLS |