Created
October 19, 2011 01:12
-
-
Save j0sh/1297236 to your computer and use it in GitHub Desktop.
Make FFmpeg RTMP work with RTMPD.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c | |
index 093d21a..cee696b 100644 | |
--- a/libavformat/rtmpproto.c | |
+++ b/libavformat/rtmpproto.c | |
@@ -74,6 +74,7 @@ typedef struct RTMPContext { | |
int skip_bytes; ///< number of bytes to skip from the input FLV stream in the next write call | |
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 | |
} RTMPContext; | |
#define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing | |
@@ -166,7 +167,7 @@ static void gen_release_stream(URLContext *s, RTMPContext *rt) | |
av_log(s, AV_LOG_DEBUG, "Releasing stream...\n"); | |
p = pkt.data; | |
ff_amf_write_string(&p, "releaseStream"); | |
- ff_amf_write_number(&p, 2.0); | |
+ ff_amf_write_number(&p, ++rt->nb_invokes); | |
ff_amf_write_null(&p); | |
ff_amf_write_string(&p, rt->playpath); | |
@@ -189,7 +190,7 @@ static void gen_fcpublish_stream(URLContext *s, RTMPContext *rt) | |
av_log(s, AV_LOG_DEBUG, "FCPublish stream...\n"); | |
p = pkt.data; | |
ff_amf_write_string(&p, "FCPublish"); | |
- ff_amf_write_number(&p, 3.0); | |
+ ff_amf_write_number(&p, ++rt->nb_invokes); | |
ff_amf_write_null(&p); | |
ff_amf_write_string(&p, rt->playpath); | |
@@ -212,7 +213,7 @@ static void gen_fcunpublish_stream(URLContext *s, RTMPContext *rt) | |
av_log(s, AV_LOG_DEBUG, "UnPublishing stream...\n"); | |
p = pkt.data; | |
ff_amf_write_string(&p, "FCUnpublish"); | |
- ff_amf_write_number(&p, 5.0); | |
+ ff_amf_write_number(&p, ++rt->nb_invokes); | |
ff_amf_write_null(&p); | |
ff_amf_write_string(&p, rt->playpath); | |
@@ -234,7 +235,7 @@ static void gen_create_stream(URLContext *s, RTMPContext *rt) | |
p = pkt.data; | |
ff_amf_write_string(&p, "createStream"); | |
- ff_amf_write_number(&p, rt->is_input ? 3.0 : 4.0); | |
+ ff_amf_write_number(&p, ++rt->nb_invokes); | |
ff_amf_write_null(&p); | |
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]); | |
@@ -595,13 +596,14 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) | |
} else if (!memcmp(pkt->data, "\002\000\007_result", 10)) { | |
switch (rt->state) { | |
case STATE_HANDSHAKED: | |
- if (!rt->is_input) { | |
+ /*if (!rt->is_input) { | |
gen_release_stream(s, rt); | |
gen_fcpublish_stream(s, rt); | |
rt->state = STATE_RELEASING; | |
} else { | |
rt->state = STATE_CONNECTING; | |
- } | |
+ }*/ | |
+ rt->state = STATE_CONNECTING; | |
gen_create_stream(s, rt); | |
break; | |
case STATE_FCPUBLISH: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment