rtmp: Use nb_invokes for all invoke commands

Message ID 1323081577-22306-1-git-send-email-martin@martin.st
State Committed
Commit 1eef08f98cc2f216ecc44041ad727aaa7fa2c705
Headers show

Commit Message

Martin Storsjö Dec. 5, 2011, 10:39 a.m.
704af3e29c3ddbc22ac5c8f40e5a0f860d53ac4c broke publishing
of rtmp streams, at least publishing to Wowza servers.

This changes all invoke commands to use nb_invokes.
---
I don't have access to test publishing against Adobe FMS,
but this seems to work properly with wowza at least.

 libavformat/rtmpproto.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

Comments

Kostya Shishkov Dec. 5, 2011, 10:54 a.m. | #1
On Mon, Dec 05, 2011 at 12:39:37PM +0200, Martin Storsjö wrote:
> 704af3e29c3ddbc22ac5c8f40e5a0f860d53ac4c broke publishing
> of rtmp streams, at least publishing to Wowza servers.
> 
> This changes all invoke commands to use nb_invokes.
> ---
> I don't have access to test publishing against Adobe FMS,
> but this seems to work properly with wowza at least.
> 
>  libavformat/rtmpproto.c |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)

LGTM

Patch

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 54213b1..69acd86 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -75,6 +75,7 @@  typedef struct RTMPContext {
     uint8_t       flv_header[11];             ///< partial incoming flv packet header
     int           flv_header_bytes;           ///< number of initialized bytes in flv_header
     int           nb_invokes;                 ///< keeps track of invoke messages
+    int           create_stream_invoke;       ///< invoke id for the create stream command
 } RTMPContext;
 
 #define PLAYER_KEY_OPEN_PART_LEN 30   ///< length of partial key used for first client digest signing
@@ -115,7 +116,7 @@  static void gen_connect(URLContext *s, RTMPContext *rt, const char *proto,
 
     ff_url_join(tcurl, sizeof(tcurl), proto, NULL, host, port, "/%s", rt->app);
     ff_amf_write_string(&p, "connect");
-    ff_amf_write_number(&p, 1.0);
+    ff_amf_write_number(&p, ++rt->nb_invokes);
     ff_amf_write_object_start(&p);
     ff_amf_write_field_name(&p, "app");
     ff_amf_write_string(&p, rt->app);
@@ -237,6 +238,7 @@  static void gen_create_stream(URLContext *s, RTMPContext *rt)
     ff_amf_write_string(&p, "createStream");
     ff_amf_write_number(&p, ++rt->nb_invokes);
     ff_amf_write_null(&p);
+    rt->create_stream_invoke = rt->nb_invokes;
 
     ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
     ff_rtmp_packet_destroy(&pkt);
@@ -257,7 +259,7 @@  static void gen_delete_stream(URLContext *s, RTMPContext *rt)
 
     p = pkt.data;
     ff_amf_write_string(&p, "deleteStream");
-    ff_amf_write_number(&p, 0.0);
+    ff_amf_write_number(&p, ++rt->nb_invokes);
     ff_amf_write_null(&p);
     ff_amf_write_number(&p, rt->main_channel_id);
 
@@ -281,7 +283,7 @@  static void gen_play(URLContext *s, RTMPContext *rt)
 
     p = pkt.data;
     ff_amf_write_string(&p, "play");
-    ff_amf_write_number(&p, 0.0);
+    ff_amf_write_number(&p, ++rt->nb_invokes);
     ff_amf_write_null(&p);
     ff_amf_write_string(&p, rt->playpath);
 
@@ -315,7 +317,7 @@  static void gen_publish(URLContext *s, RTMPContext *rt)
 
     p = pkt.data;
     ff_amf_write_string(&p, "publish");
-    ff_amf_write_number(&p, 0.0);
+    ff_amf_write_number(&p, ++rt->nb_invokes);
     ff_amf_write_null(&p);
     ff_amf_write_string(&p, rt->playpath);
     ff_amf_write_string(&p, "live");
@@ -614,7 +616,7 @@  static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
                  * releaseStream and FCPublish calls */
                 if (!pkt->data[10]) {
                     int pkt_id = (int) av_int2dbl(AV_RB64(pkt->data + 11));
-                    if (pkt_id == 4)
+                    if (pkt_id == rt->create_stream_invoke)
                         rt->state = STATE_CONNECTING;
                 }
                 if (rt->state != STATE_CONNECTING)