winlin

fix the http parse bug.

@@ -73,6 +73,19 @@ @@ -73,6 +73,19 @@
73 3C1232E91AAEA5D000CE8F6C /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232E71AAEA5D000CE8F6C /* libcrypto.a */; }; 73 3C1232E91AAEA5D000CE8F6C /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232E71AAEA5D000CE8F6C /* libcrypto.a */; };
74 3C1232EA1AAEA5D000CE8F6C /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232E81AAEA5D000CE8F6C /* libssl.a */; }; 74 3C1232EA1AAEA5D000CE8F6C /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232E81AAEA5D000CE8F6C /* libssl.a */; };
75 3C1232ED1AAEA70F00CE8F6C /* libhttp_parser.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232EC1AAEA70F00CE8F6C /* libhttp_parser.a */; }; 75 3C1232ED1AAEA70F00CE8F6C /* libhttp_parser.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232EC1AAEA70F00CE8F6C /* libhttp_parser.a */; };
  76 + 3C663F0E1AB0155100286D8B /* Makefile in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F011AB0155100286D8B /* Makefile */; };
  77 + 3C663F0F1AB0155100286D8B /* srs_aac_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */; };
  78 + 3C663F101AB0155100286D8B /* srs_audio_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */; };
  79 + 3C663F111AB0155100286D8B /* srs_bandwidth_check.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */; };
  80 + 3C663F121AB0155100286D8B /* srs_detect_rtmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F051AB0155100286D8B /* srs_detect_rtmp.c */; };
  81 + 3C663F131AB0155100286D8B /* srs_flv_injecter.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F061AB0155100286D8B /* srs_flv_injecter.c */; };
  82 + 3C663F141AB0155100286D8B /* srs_flv_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F071AB0155100286D8B /* srs_flv_parser.c */; };
  83 + 3C663F151AB0155100286D8B /* srs_h264_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F081AB0155100286D8B /* srs_h264_raw_publish.c */; };
  84 + 3C663F161AB0155100286D8B /* srs_ingest_flv.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F091AB0155100286D8B /* srs_ingest_flv.c */; };
  85 + 3C663F171AB0155100286D8B /* srs_ingest_rtmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F0A1AB0155100286D8B /* srs_ingest_rtmp.c */; };
  86 + 3C663F181AB0155100286D8B /* srs_play.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F0B1AB0155100286D8B /* srs_play.c */; };
  87 + 3C663F191AB0155100286D8B /* srs_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F0C1AB0155100286D8B /* srs_publish.c */; };
  88 + 3C663F1A1AB0155100286D8B /* srs_rtmp_dump.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F0D1AB0155100286D8B /* srs_rtmp_dump.c */; };
76 /* End PBXBuildFile section */ 89 /* End PBXBuildFile section */
77 90
78 /* Begin PBXCopyFilesBuildPhase section */ 91 /* Begin PBXCopyFilesBuildPhase section */
@@ -245,6 +258,19 @@ @@ -245,6 +258,19 @@
245 3C1232F21AAEAC7000CE8F6C /* srs-api */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-api"; path = "../../../etc/init.d/srs-api"; sourceTree = "<group>"; }; 258 3C1232F21AAEAC7000CE8F6C /* srs-api */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-api"; path = "../../../etc/init.d/srs-api"; sourceTree = "<group>"; };
246 3C1232F31AAEAC7000CE8F6C /* srs-demo */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-demo"; path = "../../../etc/init.d/srs-demo"; sourceTree = "<group>"; }; 259 3C1232F31AAEAC7000CE8F6C /* srs-demo */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-demo"; path = "../../../etc/init.d/srs-demo"; sourceTree = "<group>"; };
247 3C1232F41AAEAC7000CE8F6C /* srs-demo-19350 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-demo-19350"; path = "../../../etc/init.d/srs-demo-19350"; sourceTree = "<group>"; }; 260 3C1232F41AAEAC7000CE8F6C /* srs-demo-19350 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "srs-demo-19350"; path = "../../../etc/init.d/srs-demo-19350"; sourceTree = "<group>"; };
  261 + 3C663F011AB0155100286D8B /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = ../../../research/librtmp/Makefile; sourceTree = "<group>"; };
  262 + 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_aac_raw_publish.c; path = ../../../research/librtmp/srs_aac_raw_publish.c; sourceTree = "<group>"; };
  263 + 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_audio_raw_publish.c; path = ../../../research/librtmp/srs_audio_raw_publish.c; sourceTree = "<group>"; };
  264 + 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_bandwidth_check.c; path = ../../../research/librtmp/srs_bandwidth_check.c; sourceTree = "<group>"; };
  265 + 3C663F051AB0155100286D8B /* srs_detect_rtmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_detect_rtmp.c; path = ../../../research/librtmp/srs_detect_rtmp.c; sourceTree = "<group>"; };
  266 + 3C663F061AB0155100286D8B /* srs_flv_injecter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_flv_injecter.c; path = ../../../research/librtmp/srs_flv_injecter.c; sourceTree = "<group>"; };
  267 + 3C663F071AB0155100286D8B /* srs_flv_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_flv_parser.c; path = ../../../research/librtmp/srs_flv_parser.c; sourceTree = "<group>"; };
  268 + 3C663F081AB0155100286D8B /* srs_h264_raw_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_h264_raw_publish.c; path = ../../../research/librtmp/srs_h264_raw_publish.c; sourceTree = "<group>"; };
  269 + 3C663F091AB0155100286D8B /* srs_ingest_flv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_ingest_flv.c; path = ../../../research/librtmp/srs_ingest_flv.c; sourceTree = "<group>"; };
  270 + 3C663F0A1AB0155100286D8B /* srs_ingest_rtmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_ingest_rtmp.c; path = ../../../research/librtmp/srs_ingest_rtmp.c; sourceTree = "<group>"; };
  271 + 3C663F0B1AB0155100286D8B /* srs_play.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_play.c; path = ../../../research/librtmp/srs_play.c; sourceTree = "<group>"; };
  272 + 3C663F0C1AB0155100286D8B /* srs_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_publish.c; path = ../../../research/librtmp/srs_publish.c; sourceTree = "<group>"; };
  273 + 3C663F0D1AB0155100286D8B /* srs_rtmp_dump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_rtmp_dump.c; path = ../../../research/librtmp/srs_rtmp_dump.c; sourceTree = "<group>"; };
248 /* End PBXFileReference section */ 274 /* End PBXFileReference section */
249 275
250 /* Begin PBXFrameworksBuildPhase section */ 276 /* Begin PBXFrameworksBuildPhase section */
@@ -265,9 +291,10 @@ @@ -265,9 +291,10 @@
265 3C1231DC1AAE64A400CE8F6C = { 291 3C1231DC1AAE64A400CE8F6C = {
266 isa = PBXGroup; 292 isa = PBXGroup;
267 children = ( 293 children = (
  294 + 3C1231E61AAE64A400CE8F6C /* Products */,
268 3C1232EE1AAEA71C00CE8F6C /* links */, 295 3C1232EE1AAEA71C00CE8F6C /* links */,
269 3C1231E71AAE64A400CE8F6C /* srs_xcode */, 296 3C1231E71AAE64A400CE8F6C /* srs_xcode */,
270 - 3C1231E61AAE64A400CE8F6C /* Products */, 297 + 3C663F001AB014B500286D8B /* research */,
271 ); 298 );
272 sourceTree = "<group>"; 299 sourceTree = "<group>";
273 }; 300 };
@@ -529,6 +556,27 @@ @@ -529,6 +556,27 @@
529 name = init.d; 556 name = init.d;
530 sourceTree = "<group>"; 557 sourceTree = "<group>";
531 }; 558 };
  559 + 3C663F001AB014B500286D8B /* research */ = {
  560 + isa = PBXGroup;
  561 + children = (
  562 + 3C663F011AB0155100286D8B /* Makefile */,
  563 + 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */,
  564 + 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */,
  565 + 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */,
  566 + 3C663F051AB0155100286D8B /* srs_detect_rtmp.c */,
  567 + 3C663F061AB0155100286D8B /* srs_flv_injecter.c */,
  568 + 3C663F071AB0155100286D8B /* srs_flv_parser.c */,
  569 + 3C663F081AB0155100286D8B /* srs_h264_raw_publish.c */,
  570 + 3C663F091AB0155100286D8B /* srs_ingest_flv.c */,
  571 + 3C663F0A1AB0155100286D8B /* srs_ingest_rtmp.c */,
  572 + 3C663F0B1AB0155100286D8B /* srs_play.c */,
  573 + 3C663F0C1AB0155100286D8B /* srs_publish.c */,
  574 + 3C663F0D1AB0155100286D8B /* srs_rtmp_dump.c */,
  575 + );
  576 + name = research;
  577 + path = srs_xcode;
  578 + sourceTree = "<group>";
  579 + };
532 /* End PBXGroup section */ 580 /* End PBXGroup section */
533 581
534 /* Begin PBXNativeTarget section */ 582 /* Begin PBXNativeTarget section */
@@ -586,9 +634,12 @@ @@ -586,9 +634,12 @@
586 buildActionMask = 2147483647; 634 buildActionMask = 2147483647;
587 files = ( 635 files = (
588 3C1232951AAE81D900CE8F6C /* srs_app_config.cpp in Sources */, 636 3C1232951AAE81D900CE8F6C /* srs_app_config.cpp in Sources */,
  637 + 3C663F0F1AB0155100286D8B /* srs_aac_raw_publish.c in Sources */,
589 3C1232961AAE81D900CE8F6C /* srs_app_conn.cpp in Sources */, 638 3C1232961AAE81D900CE8F6C /* srs_app_conn.cpp in Sources */,
590 3C12322A1AAE814D00CE8F6C /* srs_kernel_ts.cpp in Sources */, 639 3C12322A1AAE814D00CE8F6C /* srs_kernel_ts.cpp in Sources */,
591 3C12329E1AAE81D900CE8F6C /* srs_app_hls.cpp in Sources */, 640 3C12329E1AAE81D900CE8F6C /* srs_app_hls.cpp in Sources */,
  641 + 3C663F171AB0155100286D8B /* srs_ingest_rtmp.c in Sources */,
  642 + 3C663F131AB0155100286D8B /* srs_flv_injecter.c in Sources */,
592 3C1232971AAE81D900CE8F6C /* srs_app_dvr.cpp in Sources */, 643 3C1232971AAE81D900CE8F6C /* srs_app_dvr.cpp in Sources */,
593 3C1232271AAE814D00CE8F6C /* srs_kernel_log.cpp in Sources */, 644 3C1232271AAE814D00CE8F6C /* srs_kernel_log.cpp in Sources */,
594 3C1232A81AAE81D900CE8F6C /* srs_app_log.cpp in Sources */, 645 3C1232A81AAE81D900CE8F6C /* srs_app_log.cpp in Sources */,
@@ -600,6 +651,8 @@ @@ -600,6 +651,8 @@
600 3C12324A1AAE81A400CE8F6C /* srs_rtsp_stack.cpp in Sources */, 651 3C12324A1AAE81A400CE8F6C /* srs_rtsp_stack.cpp in Sources */,
601 3C1232A51AAE81D900CE8F6C /* srs_app_json.cpp in Sources */, 652 3C1232A51AAE81D900CE8F6C /* srs_app_json.cpp in Sources */,
602 3C12329F1AAE81D900CE8F6C /* srs_app_http_api.cpp in Sources */, 653 3C12329F1AAE81D900CE8F6C /* srs_app_http_api.cpp in Sources */,
  654 + 3C663F101AB0155100286D8B /* srs_audio_raw_publish.c in Sources */,
  655 + 3C663F111AB0155100286D8B /* srs_bandwidth_check.c in Sources */,
603 3C1232A11AAE81D900CE8F6C /* srs_app_http_conn.cpp in Sources */, 656 3C1232A11AAE81D900CE8F6C /* srs_app_http_conn.cpp in Sources */,
604 3C1232AC1AAE81D900CE8F6C /* srs_app_refer.cpp in Sources */, 657 3C1232AC1AAE81D900CE8F6C /* srs_app_refer.cpp in Sources */,
605 3C1232991AAE81D900CE8F6C /* srs_app_empty.cpp in Sources */, 658 3C1232991AAE81D900CE8F6C /* srs_app_empty.cpp in Sources */,
@@ -608,9 +661,11 @@ @@ -608,9 +661,11 @@
608 3C1232221AAE814D00CE8F6C /* srs_kernel_codec.cpp in Sources */, 661 3C1232221AAE814D00CE8F6C /* srs_kernel_codec.cpp in Sources */,
609 3C1232B71AAE81D900CE8F6C /* srs_app_utility.cpp in Sources */, 662 3C1232B71AAE81D900CE8F6C /* srs_app_utility.cpp in Sources */,
610 3C1232AB1AAE81D900CE8F6C /* srs_app_recv_thread.cpp in Sources */, 663 3C1232AB1AAE81D900CE8F6C /* srs_app_recv_thread.cpp in Sources */,
  664 + 3C663F151AB0155100286D8B /* srs_h264_raw_publish.c in Sources */,
611 3C1231F61AAE652D00CE8F6C /* srs_core_autofree.cpp in Sources */, 665 3C1231F61AAE652D00CE8F6C /* srs_core_autofree.cpp in Sources */,
612 3C1232411AAE81A400CE8F6C /* srs_raw_avc.cpp in Sources */, 666 3C1232411AAE81A400CE8F6C /* srs_raw_avc.cpp in Sources */,
613 3C1232491AAE81A400CE8F6C /* srs_rtmp_utility.cpp in Sources */, 667 3C1232491AAE81A400CE8F6C /* srs_rtmp_utility.cpp in Sources */,
  668 + 3C663F191AB0155100286D8B /* srs_publish.c in Sources */,
614 3C1232A01AAE81D900CE8F6C /* srs_app_http_client.cpp in Sources */, 669 3C1232A01AAE81D900CE8F6C /* srs_app_http_client.cpp in Sources */,
615 3C12329B1AAE81D900CE8F6C /* srs_app_ffmpeg.cpp in Sources */, 670 3C12329B1AAE81D900CE8F6C /* srs_app_ffmpeg.cpp in Sources */,
616 3C1232421AAE81A400CE8F6C /* srs_rtmp_amf0.cpp in Sources */, 671 3C1232421AAE81A400CE8F6C /* srs_rtmp_amf0.cpp in Sources */,
@@ -620,6 +675,7 @@ @@ -620,6 +675,7 @@
620 3C1232AD1AAE81D900CE8F6C /* srs_app_reload.cpp in Sources */, 675 3C1232AD1AAE81D900CE8F6C /* srs_app_reload.cpp in Sources */,
621 3C1231F81AAE652D00CE8F6C /* srs_core.cpp in Sources */, 676 3C1231F81AAE652D00CE8F6C /* srs_core.cpp in Sources */,
622 3C1232A21AAE81D900CE8F6C /* srs_app_http_hooks.cpp in Sources */, 677 3C1232A21AAE81D900CE8F6C /* srs_app_http_hooks.cpp in Sources */,
  678 + 3C663F121AB0155100286D8B /* srs_detect_rtmp.c in Sources */,
623 3C1232B11AAE81D900CE8F6C /* srs_app_server.cpp in Sources */, 679 3C1232B11AAE81D900CE8F6C /* srs_app_server.cpp in Sources */,
624 3C1232B31AAE81D900CE8F6C /* srs_app_st_socket.cpp in Sources */, 680 3C1232B31AAE81D900CE8F6C /* srs_app_st_socket.cpp in Sources */,
625 3C1232061AAE812C00CE8F6C /* srs_main_server.cpp in Sources */, 681 3C1232061AAE812C00CE8F6C /* srs_main_server.cpp in Sources */,
@@ -630,15 +686,20 @@ @@ -630,15 +686,20 @@
630 3C1232461AAE81A400CE8F6C /* srs_rtmp_msg_array.cpp in Sources */, 686 3C1232461AAE81A400CE8F6C /* srs_rtmp_msg_array.cpp in Sources */,
631 3C1232A71AAE81D900CE8F6C /* srs_app_listener.cpp in Sources */, 687 3C1232A71AAE81D900CE8F6C /* srs_app_listener.cpp in Sources */,
632 3C1232261AAE814D00CE8F6C /* srs_kernel_flv.cpp in Sources */, 688 3C1232261AAE814D00CE8F6C /* srs_kernel_flv.cpp in Sources */,
  689 + 3C663F1A1AB0155100286D8B /* srs_rtmp_dump.c in Sources */,
633 3C1232241AAE814D00CE8F6C /* srs_kernel_error.cpp in Sources */, 690 3C1232241AAE814D00CE8F6C /* srs_kernel_error.cpp in Sources */,
634 3C1232441AAE81A400CE8F6C /* srs_rtmp_handshake.cpp in Sources */, 691 3C1232441AAE81A400CE8F6C /* srs_rtmp_handshake.cpp in Sources */,
635 3C1232291AAE814D00CE8F6C /* srs_kernel_stream.cpp in Sources */, 692 3C1232291AAE814D00CE8F6C /* srs_kernel_stream.cpp in Sources */,
  693 + 3C663F181AB0155100286D8B /* srs_play.c in Sources */,
636 3C1232B61AAE81D900CE8F6C /* srs_app_thread.cpp in Sources */, 694 3C1232B61AAE81D900CE8F6C /* srs_app_thread.cpp in Sources */,
637 3C1232A91AAE81D900CE8F6C /* srs_app_mpegts_udp.cpp in Sources */, 695 3C1232A91AAE81D900CE8F6C /* srs_app_mpegts_udp.cpp in Sources */,
638 3C1232AE1AAE81D900CE8F6C /* srs_app_rtmp_conn.cpp in Sources */, 696 3C1232AE1AAE81D900CE8F6C /* srs_app_rtmp_conn.cpp in Sources */,
639 3C1232B51AAE81D900CE8F6C /* srs_app_statistic.cpp in Sources */, 697 3C1232B51AAE81D900CE8F6C /* srs_app_statistic.cpp in Sources */,
  698 + 3C663F161AB0155100286D8B /* srs_ingest_flv.c in Sources */,
  699 + 3C663F141AB0155100286D8B /* srs_flv_parser.c in Sources */,
640 3C1232451AAE81A400CE8F6C /* srs_rtmp_io.cpp in Sources */, 700 3C1232451AAE81A400CE8F6C /* srs_rtmp_io.cpp in Sources */,
641 3C1232431AAE81A400CE8F6C /* srs_rtmp_buffer.cpp in Sources */, 701 3C1232431AAE81A400CE8F6C /* srs_rtmp_buffer.cpp in Sources */,
  702 + 3C663F0E1AB0155100286D8B /* Makefile in Sources */,
642 3C1232211AAE814D00CE8F6C /* srs_kernel_buffer.cpp in Sources */, 703 3C1232211AAE814D00CE8F6C /* srs_kernel_buffer.cpp in Sources */,
643 3C1232471AAE81A400CE8F6C /* srs_rtmp_sdk.cpp in Sources */, 704 3C1232471AAE81A400CE8F6C /* srs_rtmp_sdk.cpp in Sources */,
644 3C1232A61AAE81D900CE8F6C /* srs_app_kbps.cpp in Sources */, 705 3C1232A61AAE81D900CE8F6C /* srs_app_kbps.cpp in Sources */,
@@ -53,7 +53,8 @@ int main(int argc, char** argv) @@ -53,7 +53,8 @@ int main(int argc, char** argv)
53 // user option parse index. 53 // user option parse index.
54 int opt = 0; 54 int opt = 0;
55 // user options. 55 // user options.
56 - char* in_flv_file; char* out_rtmp_url; 56 + char* in_flv_file = NULL;
  57 + char* out_rtmp_url = NULL;
57 // rtmp handler 58 // rtmp handler
58 srs_rtmp_t ortmp; 59 srs_rtmp_t ortmp;
59 // flv handler 60 // flv handler
@@ -89,6 +90,15 @@ int main(int argc, char** argv) @@ -89,6 +90,15 @@ int main(int argc, char** argv)
89 } 90 }
90 } 91 }
91 92
  93 + if (!in_flv_file) {
  94 + srs_human_trace("input invalid, use -i <input>");
  95 + return -1;
  96 + }
  97 + if (!out_rtmp_url) {
  98 + srs_human_trace("output invalid, use -y <output>");
  99 + return -1;
  100 + }
  101 +
92 srs_human_trace("input: %s", in_flv_file); 102 srs_human_trace("input: %s", in_flv_file);
93 srs_human_trace("output: %s", out_rtmp_url); 103 srs_human_trace("output: %s", out_rtmp_url);
94 104
@@ -41,7 +41,8 @@ int main(int argc, char** argv) @@ -41,7 +41,8 @@ int main(int argc, char** argv)
41 // user option parse index. 41 // user option parse index.
42 int opt = 0; 42 int opt = 0;
43 // user options. 43 // user options.
44 - char* in_rtmp_url; char* out_rtmp_url; 44 + char* in_rtmp_url = NULL;
  45 + char* out_rtmp_url = NULL;
45 // rtmp handler 46 // rtmp handler
46 srs_rtmp_t irtmp, ortmp; 47 srs_rtmp_t irtmp, ortmp;
47 48
@@ -74,6 +75,15 @@ int main(int argc, char** argv) @@ -74,6 +75,15 @@ int main(int argc, char** argv)
74 } 75 }
75 } 76 }
76 77
  78 + if (!in_rtmp_url) {
  79 + srs_human_trace("input invalid, use -i <input>");
  80 + return -1;
  81 + }
  82 + if (!out_rtmp_url) {
  83 + srs_human_trace("output invalid, use -y <output>");
  84 + return -1;
  85 + }
  86 +
77 srs_human_trace("input: %s", in_rtmp_url); 87 srs_human_trace("input: %s", in_rtmp_url);
78 srs_human_trace("output: %s", out_rtmp_url); 88 srs_human_trace("output: %s", out_rtmp_url);
79 89
@@ -43,9 +43,6 @@ using namespace std; @@ -43,9 +43,6 @@ using namespace std;
43 43
44 #define SRS_DEFAULT_HTTP_PORT 80 44 #define SRS_DEFAULT_HTTP_PORT 80
45 45
46 -#define SRS_HTTP_HEADER_BUFFER 1024  
47 -#define SRS_HTTP_BODY_BUFFER 1024  
48 -  
49 // for http parser macros 46 // for http parser macros
50 #define SRS_CONSTS_HTTP_OPTIONS HTTP_OPTIONS 47 #define SRS_CONSTS_HTTP_OPTIONS HTTP_OPTIONS
51 #define SRS_CONSTS_HTTP_GET HTTP_GET 48 #define SRS_CONSTS_HTTP_GET HTTP_GET
@@ -1310,9 +1307,18 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt) @@ -1310,9 +1307,18 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt)
1310 int ret = ERROR_SUCCESS; 1307 int ret = ERROR_SUCCESS;
1311 1308
1312 while (true) { 1309 while (true) {
1313 - if (buffer->size() <= 0) {  
1314 - // when empty, only grow 1bytes, but the buffer will cache more.  
1315 - if ((ret = buffer->grow(skt, 1)) != ERROR_SUCCESS) { 1310 + ssize_t nparsed = 0;
  1311 +
  1312 + // when buffer not empty, parse it.
  1313 + if (buffer->size() > 0) {
  1314 + nparsed = http_parser_execute(&parser, &settings, buffer->bytes(), buffer->size());
  1315 + srs_info("buffer=%d, nparsed=%d, body=%d", buffer->size(), (int)nparsed, body_parsed);
  1316 + }
  1317 +
  1318 + // when nothing parsed, read more to parse.
  1319 + if (nparsed == 0) {
  1320 + // when requires more, only grow 1bytes, but the buffer will cache more.
  1321 + if ((ret = buffer->grow(skt, buffer->size() + 1)) != ERROR_SUCCESS) {
1316 if (!srs_is_client_gracefully_close(ret)) { 1322 if (!srs_is_client_gracefully_close(ret)) {
1317 srs_error("read body from server failed. ret=%d", ret); 1323 srs_error("read body from server failed. ret=%d", ret);
1318 } 1324 }
@@ -1320,10 +1326,8 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt) @@ -1320,10 +1326,8 @@ int SrsHttpParser::parse_message_imp(SrsStSocket* skt)
1320 } 1326 }
1321 } 1327 }
1322 1328
1323 - int nb_header = srs_min(SRS_HTTP_HEADER_BUFFER, buffer->size());  
1324 - ssize_t nparsed = http_parser_execute(&parser, &settings, buffer->bytes(), nb_header);  
1325 - srs_info("buffer=%d, nparsed=%d, body=%d", buffer->size(), (int)nparsed, body_parsed);  
1326 - if (nparsed - body_parsed > 0) { 1329 + // consume the parsed bytes.
  1330 + if (nparsed && nparsed - body_parsed > 0) {
1327 buffer->read_slice(nparsed - body_parsed); 1331 buffer->read_slice(nparsed - body_parsed);
1328 } 1332 }
1329 1333