diff options
author | David Schleef <ds@schleef.org> | 2014-09-01 18:46:17 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2014-09-01 18:46:17 -0700 |
commit | 571f497f7d96da43797f58cfdab82fd37cc98193 (patch) | |
tree | eba623a69b37a432a27d3572f0ceb38406fdc7f4 | |
parent | 8e5dc328d6d59769b0f3ffeafbf97453dd2936f9 (diff) |
stream_id -> chunk_stream_id
-rw-r--r-- | plugins/gstrtmp2sink.c | 6 | ||||
-rw-r--r-- | plugins/gstrtmp2src.c | 8 | ||||
-rw-r--r-- | rtmp/rtmpchunk.c | 47 | ||||
-rw-r--r-- | rtmp/rtmpchunk.h | 10 | ||||
-rw-r--r-- | rtmp/rtmpconnection.c | 43 | ||||
-rw-r--r-- | rtmp/rtmpconnection.h | 2 | ||||
-rw-r--r-- | tools/client-test.c | 4 | ||||
-rw-r--r-- | tools/proxy-server.c | 4 |
8 files changed, 65 insertions, 59 deletions
diff --git a/plugins/gstrtmp2sink.c b/plugins/gstrtmp2sink.c index d0277b5..1c4dd58 100644 --- a/plugins/gstrtmp2sink.c +++ b/plugins/gstrtmp2sink.c @@ -470,7 +470,7 @@ gst_rtmp2_sink_render (GstBaseSink * sink, GstBuffer * buffer) chunk = gst_rtmp_chunk_new (); chunk->message_type_id = data[0]; - chunk->stream_id = 4; + chunk->chunk_stream_id = 4; if (chunk->message_type_id == 18 || chunk->message_type_id == 9) { } else { GST_ERROR ("unknown message_type_id %d", chunk->message_type_id); @@ -846,9 +846,9 @@ dump_command (GstRtmpChunk * chunk) static void dump_chunk (GstRtmpChunk * chunk, gboolean dir) { - g_print ("%s stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT + g_print ("%s chunk_stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT " type_id:%-4d info:%08x\n", dir ? ">>>" : "<<<", - chunk->stream_id, + chunk->chunk_stream_id, chunk->timestamp, chunk->message_length, chunk->message_type_id, chunk->info); if (chunk->message_type_id == 20) { diff --git a/plugins/gstrtmp2src.c b/plugins/gstrtmp2src.c index 2811733..a84a247 100644 --- a/plugins/gstrtmp2src.c +++ b/plugins/gstrtmp2src.c @@ -430,9 +430,9 @@ dump_command (GstRtmpChunk * chunk) static void dump_chunk (GstRtmpChunk * chunk, gboolean dir) { - g_print ("%s stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT + g_print ("%s chunk_stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT " type_id:%-4d info:%08x\n", dir ? ">>>" : "<<<", - chunk->stream_id, + chunk->chunk_stream_id, chunk->timestamp, chunk->message_length, chunk->message_type_id, chunk->info); if (chunk->message_type_id == 20) { @@ -454,8 +454,8 @@ got_chunk (GstRtmpConnection * connection, GstRtmpChunk * chunk, dump_chunk (chunk, FALSE); } - if ((chunk->stream_id == 7 && chunk->message_type_id == 9) || - (chunk->stream_id == 5 && chunk->message_type_id == 18 + if ((chunk->chunk_stream_id == 7 && chunk->message_type_id == 9) || + (chunk->chunk_stream_id == 5 && chunk->message_type_id == 18 && chunk->message_length > 100)) { g_object_ref (chunk); g_mutex_lock (&rtmp2src->lock); diff --git a/rtmp/rtmpchunk.c b/rtmp/rtmpchunk.c index 6a22c9e..197d66d 100644 --- a/rtmp/rtmpchunk.c +++ b/rtmp/rtmpchunk.c @@ -133,24 +133,24 @@ gst_rtmp_chunk_parse_header1 (GstRtmpChunkHeader * header, GBytes * bytes) { const guint8 *data; const gsize sizes[4] = { 12, 8, 4, 1 }; - int stream_id; + int chunk_stream_id; gsize size; data = g_bytes_get_data (bytes, &size); header->format = data[0] >> 6; header->header_size = sizes[header->format]; - stream_id = data[0] & 0x3f; - if (stream_id == 0) { + chunk_stream_id = data[0] & 0x3f; + if (chunk_stream_id == 0) { if (size >= 2) - header->stream_id = 64 + data[1]; + header->chunk_stream_id = 64 + data[1]; header->header_size += 1; - } else if (stream_id == 1) { + } else if (chunk_stream_id == 1) { if (size >= 3) - header->stream_id = 64 + data[1] + (data[2] << 8); + header->chunk_stream_id = 64 + data[1] + (data[2] << 8); header->header_size += 2; } else { - header->stream_id = stream_id; + header->chunk_stream_id = chunk_stream_id; } return (header->header_size <= size); @@ -167,13 +167,13 @@ gst_rtmp_chunk_parse_header2 (GstRtmpChunkHeader * header, GBytes * bytes, data = g_bytes_get_data (bytes, &size); header->format = data[0] >> 6; - header->stream_id = data[0] & 0x3f; + header->chunk_stream_id = data[0] & 0x3f; offset = 1; - if (header->stream_id == 0) { - header->stream_id = 64 + data[1]; + if (header->chunk_stream_id == 0) { + header->chunk_stream_id = 64 + data[1]; offset = 2; - } else if (header->stream_id == 1) { - header->stream_id = 64 + data[1] + (data[2] << 8); + } else if (header->chunk_stream_id == 1) { + header->chunk_stream_id = 64 + data[1] + (data[2] << 8); offset = 3; } if (header->format == 0) { @@ -240,7 +240,7 @@ gst_rtmp_chunk_serialize (GstRtmpChunk * chunk, /* FIXME this is incomplete and inefficient */ chunkdata = g_bytes_get_data (chunk->payload, &chunksize); g_assert (chunk->message_length == chunksize); - g_assert (chunk->stream_id < 64); + g_assert (chunk->chunk_stream_id < 64); data = g_malloc (chunksize + 12 + (chunksize / max_chunk_size)); header_fmt = 0; @@ -251,8 +251,8 @@ gst_rtmp_chunk_serialize (GstRtmpChunk * chunk, } #endif - g_assert (chunk->stream_id < 64); - data[0] = (header_fmt << 6) | (chunk->stream_id); + g_assert (chunk->chunk_stream_id < 64); + data[0] = (header_fmt << 6) | (chunk->chunk_stream_id); if (header_fmt == 0) { g_assert (chunk->timestamp < 0xffffff); data[1] = (chunk->timestamp >> 16) & 0xff; @@ -281,7 +281,7 @@ gst_rtmp_chunk_serialize (GstRtmpChunk * chunk, chunk->message_type_id == 0x14) { for (i = 0; i < chunksize; i += max_chunk_size) { if (i != 0) { - data[offset] = 0xc0 | chunk->stream_id; + data[offset] = 0xc0 | chunk->chunk_stream_id; offset++; } memcpy (data + offset, chunkdata + i, MIN (chunksize - i, @@ -299,9 +299,10 @@ gst_rtmp_chunk_serialize (GstRtmpChunk * chunk, } void -gst_rtmp_chunk_set_stream_id (GstRtmpChunk * chunk, guint32 stream_id) +gst_rtmp_chunk_set_chunk_stream_id (GstRtmpChunk * chunk, + guint32 chunk_stream_id) { - chunk->stream_id = stream_id; + chunk->chunk_stream_id = chunk_stream_id; } void @@ -320,9 +321,9 @@ gst_rtmp_chunk_set_payload (GstRtmpChunk * chunk, GBytes * payload) } guint32 -gst_rtmp_chunk_get_stream_id (GstRtmpChunk * chunk) +gst_rtmp_chunk_get_chunk_stream_id (GstRtmpChunk * chunk) { - return chunk->stream_id; + return chunk->chunk_stream_id; } guint32 @@ -353,18 +354,18 @@ gst_rtmp_chunk_cache_free (GstRtmpChunkCache * cache) } GstRtmpChunkCacheEntry * -gst_rtmp_chunk_cache_get (GstRtmpChunkCache * cache, int stream_id) +gst_rtmp_chunk_cache_get (GstRtmpChunkCache * cache, int chunk_stream_id) { int i; GstRtmpChunkCacheEntry *entry; for (i = 0; i < cache->len; i++) { entry = &g_array_index (cache, GstRtmpChunkCacheEntry, i); - if (entry->previous_header.stream_id == stream_id) + if (entry->previous_header.chunk_stream_id == chunk_stream_id) return entry; } g_array_set_size (cache, cache->len + 1); entry = &g_array_index (cache, GstRtmpChunkCacheEntry, cache->len - 1); - entry->previous_header.stream_id = stream_id; + entry->previous_header.chunk_stream_id = chunk_stream_id; return entry; } diff --git a/rtmp/rtmpchunk.h b/rtmp/rtmpchunk.h index 8b2b707..6588f3f 100644 --- a/rtmp/rtmpchunk.h +++ b/rtmp/rtmpchunk.h @@ -40,7 +40,7 @@ typedef struct _GstRtmpChunkHeader GstRtmpChunkHeader; struct _GstRtmpChunkHeader { int format; gsize header_size; - guint32 stream_id; + guint32 chunk_stream_id; guint32 timestamp; gsize message_length; int message_type_id; @@ -58,7 +58,7 @@ struct _GstRtmpChunk { GObject object; - guint32 stream_id; + guint32 chunk_stream_id; guint32 timestamp; gsize message_length; int message_type_id; @@ -89,11 +89,11 @@ GstRtmpChunk * gst_rtmp_chunk_new_parse (GBytes *bytes, gsize *chunk_size, GBytes * gst_rtmp_chunk_serialize (GstRtmpChunk *chunk, GstRtmpChunkHeader *previous_header, gsize max_chunk_size); -void gst_rtmp_chunk_set_stream_id (GstRtmpChunk *chunk, guint32 stream_id); +void gst_rtmp_chunk_set_chunk_stream_id (GstRtmpChunk *chunk, guint32 chunk_stream_id); void gst_rtmp_chunk_set_timestamp (GstRtmpChunk *chunk, guint32 timestamp); void gst_rtmp_chunk_set_payload (GstRtmpChunk *chunk, GBytes *payload); -guint32 gst_rtmp_chunk_get_stream_id (GstRtmpChunk *chunk); +guint32 gst_rtmp_chunk_get_chunk_stream_id (GstRtmpChunk *chunk); guint32 gst_rtmp_chunk_get_timestamp (GstRtmpChunk *chunk); GBytes * gst_rtmp_chunk_get_payload (GstRtmpChunk *chunk); @@ -111,7 +111,7 @@ gboolean gst_rtmp_chunk_parse_message (GstRtmpChunk *chunk, GstRtmpChunkCache *gst_rtmp_chunk_cache_new (void); void gst_rtmp_chunk_cache_free (GstRtmpChunkCache *cache); GstRtmpChunkCacheEntry * gst_rtmp_chunk_cache_get ( - GstRtmpChunkCache *cache, int stream_id); + GstRtmpChunkCache *cache, int chunk_stream_id); void gst_rtmp_chunk_cache_update (GstRtmpChunkCacheEntry * entry, GstRtmpChunk * chunk); diff --git a/rtmp/rtmpconnection.c b/rtmp/rtmpconnection.c index 1529ed4..a027552 100644 --- a/rtmp/rtmpconnection.c +++ b/rtmp/rtmpconnection.c @@ -88,7 +88,7 @@ static void gst_rtmp_connection_send_window_size_request (GstRtmpConnection * typedef struct _CommandCallback CommandCallback; struct _CommandCallback { - int stream_id; + int chunk_stream_id; int transaction_id; GstRtmpCommandCallback func; gpointer user_data; @@ -324,9 +324,12 @@ gst_rtmp_connection_output_ready (GOutputStream * os, gpointer user_data) } sc->output_chunk = chunk; - entry = gst_rtmp_chunk_cache_get (sc->output_chunk_cache, chunk->stream_id); - sc->output_bytes = gst_rtmp_chunk_serialize (chunk, - &entry->previous_header, sc->out_chunk_size); + entry = + gst_rtmp_chunk_cache_get (sc->output_chunk_cache, + chunk->chunk_stream_id); + sc->output_bytes = + gst_rtmp_chunk_serialize (chunk, &entry->previous_header, + sc->out_chunk_size); g_bytes_ref (sc->output_bytes); gst_rtmp_chunk_cache_update (entry, chunk); } @@ -528,7 +531,9 @@ gst_rtmp_connection_chunk_callback (GstRtmpConnection * sc) break; } - entry = gst_rtmp_chunk_cache_get (sc->input_chunk_cache, header.stream_id); + entry = + gst_rtmp_chunk_cache_get (sc->input_chunk_cache, + header.chunk_stream_id); if (entry->chunk && header.format != 3) { GST_ERROR ("expected message continuation, but got new message"); @@ -557,7 +562,7 @@ gst_rtmp_connection_chunk_callback (GstRtmpConnection * sc) if (entry->chunk == NULL) { entry->chunk = gst_rtmp_chunk_new (); - entry->chunk->stream_id = header.stream_id; + entry->chunk->chunk_stream_id = header.chunk_stream_id; entry->chunk->timestamp = header.timestamp; entry->chunk->message_length = header.message_length; entry->chunk->message_type_id = header.message_type_id; @@ -595,7 +600,7 @@ gst_rtmp_connection_chunk_callback (GstRtmpConnection * sc) static void gst_rtmp_connection_handle_chunk (GstRtmpConnection * sc, GstRtmpChunk * chunk) { - if (chunk->stream_id == 0x02) { + if (chunk->chunk_stream_id == 0x02) { GST_DEBUG ("got protocol control message, type: %d", chunk->message_type_id); gst_rtmp_connection_handle_pcm (sc, chunk); @@ -613,7 +618,7 @@ gst_rtmp_connection_handle_chunk (GstRtmpConnection * sc, GstRtmpChunk * chunk) &command_object, &optional_args); for (g = sc->command_callbacks; g; g = g_list_next (g)) { cb = g->data; - if (cb->stream_id == chunk->stream_id && + if (cb->chunk_stream_id == chunk->chunk_stream_id && cb->transaction_id == transaction_id) { break; } @@ -893,15 +898,15 @@ gst_rtmp_connection_dump (GstRtmpConnection * connection) } int -gst_rtmp_connection_send_command (GstRtmpConnection * connection, int stream_id, - const char *command_name, int transaction_id, GstAmfNode * command_object, - GstAmfNode * optional_args, GstRtmpCommandCallback response_command, - gpointer user_data) +gst_rtmp_connection_send_command (GstRtmpConnection * connection, + int chunk_stream_id, const char *command_name, int transaction_id, + GstAmfNode * command_object, GstAmfNode * optional_args, + GstRtmpCommandCallback response_command, gpointer user_data) { GstRtmpChunk *chunk; chunk = gst_rtmp_chunk_new (); - chunk->stream_id = stream_id; + chunk->chunk_stream_id = chunk_stream_id; chunk->timestamp = 0; /* FIXME */ chunk->message_type_id = 0x14; chunk->info = 0; /* FIXME */ @@ -916,7 +921,7 @@ gst_rtmp_connection_send_command (GstRtmpConnection * connection, int stream_id, CommandCallback *callback; callback = g_malloc0 (sizeof (CommandCallback)); - callback->stream_id = stream_id; + callback->chunk_stream_id = chunk_stream_id; callback->transaction_id = transaction_id; callback->func = response_command; callback->user_data = user_data; @@ -938,7 +943,7 @@ gst_rtmp_connection_send_command2 (GstRtmpConnection * connection, GstRtmpChunk *chunk; chunk = gst_rtmp_chunk_new (); - chunk->stream_id = chunk_stream_id; + chunk->chunk_stream_id = chunk_stream_id; chunk->timestamp = 0; /* FIXME */ chunk->message_type_id = 0x14; chunk->info = stream_id; @@ -953,7 +958,7 @@ gst_rtmp_connection_send_command2 (GstRtmpConnection * connection, CommandCallback *callback; callback = g_malloc0 (sizeof (CommandCallback)); - callback->stream_id = stream_id; + callback->chunk_stream_id = chunk_stream_id; callback->transaction_id = transaction_id; callback->func = response_command; callback->user_data = user_data; @@ -972,7 +977,7 @@ gst_rtmp_connection_send_ack (GstRtmpConnection * connection) guint8 *data; chunk = gst_rtmp_chunk_new (); - chunk->stream_id = 2; + chunk->chunk_stream_id = 2; chunk->timestamp = 0; chunk->message_type_id = 5; chunk->info = 0; @@ -995,7 +1000,7 @@ gst_rtmp_connection_send_ping_response (GstRtmpConnection * connection, guint8 *data; chunk = gst_rtmp_chunk_new (); - chunk->stream_id = 2; + chunk->chunk_stream_id = 2; chunk->timestamp = 0; chunk->message_type_id = 4; chunk->info = 0; @@ -1016,7 +1021,7 @@ gst_rtmp_connection_send_window_size_request (GstRtmpConnection * connection) guint8 *data; chunk = gst_rtmp_chunk_new (); - chunk->stream_id = 2; + chunk->chunk_stream_id = 2; chunk->timestamp = 0; chunk->message_type_id = 5; chunk->info = 0; diff --git a/rtmp/rtmpconnection.h b/rtmp/rtmpconnection.h index 6f2a6a2..d3d5ac0 100644 --- a/rtmp/rtmpconnection.h +++ b/rtmp/rtmpconnection.h @@ -104,7 +104,7 @@ void gst_rtmp_connection_queue_chunk (GstRtmpConnection *connection, void gst_rtmp_connection_dump (GstRtmpConnection *connection); int gst_rtmp_connection_send_command (GstRtmpConnection *connection, - int stream_id, const char *command_name, int transaction_id, + int chunk_stream_id, const char *command_name, int transaction_id, GstAmfNode *command_object, GstAmfNode *optional_args, GstRtmpCommandCallback response_command, gpointer user_data); int gst_rtmp_connection_send_command2 (GstRtmpConnection *connection, diff --git a/tools/client-test.c b/tools/client-test.c index 1f8eb60..6887620 100644 --- a/tools/client-test.c +++ b/tools/client-test.c @@ -139,9 +139,9 @@ dump_chunk (GstRtmpChunk * chunk, gboolean dir) if (!dump) return; - g_print ("%s stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT + g_print ("%s chunk_stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT " type_id:%-4d info:%08x\n", dir ? ">>>" : "<<<", - chunk->stream_id, + chunk->chunk_stream_id, chunk->timestamp, chunk->message_length, chunk->message_type_id, chunk->info); if (chunk->message_type_id == 20) { diff --git a/tools/proxy-server.c b/tools/proxy-server.c index e9ea6a5..178dd57 100644 --- a/tools/proxy-server.c +++ b/tools/proxy-server.c @@ -214,9 +214,9 @@ dump_chunk (GstRtmpChunk * chunk, gboolean dir) if (!dump) return; - g_print ("%s stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT + g_print ("%s chunk_stream_id:%-4d ts:%-8d len:%-6" G_GSIZE_FORMAT " type_id:%-4d info:%08x\n", dir ? ">>>" : "<<<", - chunk->stream_id, + chunk->chunk_stream_id, chunk->timestamp, chunk->message_length, chunk->message_type_id, chunk->info); if (chunk->message_type_id == 0x14 || chunk->message_type_id == 0x12) { |