winlin

support gmd. change work_dir. hourglass. add utilies.

@@ -195,6 +195,11 @@ if [ $SRS_GPERF_MC = YES ]; then @@ -195,6 +195,11 @@ if [ $SRS_GPERF_MC = YES ]; then
195 else 195 else
196 srs_undefine_macro "SRS_AUTO_GPERF_MC" $SRS_AUTO_HEADERS_H 196 srs_undefine_macro "SRS_AUTO_GPERF_MC" $SRS_AUTO_HEADERS_H
197 fi 197 fi
  198 +if [ $SRS_GPERF_MD = YES ]; then
  199 + srs_define_macro "SRS_AUTO_GPERF_MD" $SRS_AUTO_HEADERS_H
  200 +else
  201 + srs_undefine_macro "SRS_AUTO_GPERF_MD" $SRS_AUTO_HEADERS_H
  202 +fi
198 if [ $SRS_GPERF_MP = YES ]; then 203 if [ $SRS_GPERF_MP = YES ]; then
199 srs_define_macro "SRS_AUTO_GPERF_MP" $SRS_AUTO_HEADERS_H 204 srs_define_macro "SRS_AUTO_GPERF_MP" $SRS_AUTO_HEADERS_H
200 else 205 else
@@ -36,6 +36,8 @@ SRS_UTEST=RESERVED @@ -36,6 +36,8 @@ SRS_UTEST=RESERVED
36 SRS_GPERF=RESERVED 36 SRS_GPERF=RESERVED
37 # gperf memory check 37 # gperf memory check
38 SRS_GPERF_MC=RESERVED 38 SRS_GPERF_MC=RESERVED
  39 +# gperf memory defence
  40 +SRS_GPERF_MD=RESERVED
39 # gperf memory profile 41 # gperf memory profile
40 SRS_GPERF_MP=RESERVED 42 SRS_GPERF_MP=RESERVED
41 # gperf cpu profile 43 # gperf cpu profile
@@ -130,8 +132,9 @@ Options: @@ -130,8 +132,9 @@ Options:
130 --with-librtmp enable srs-librtmp, library for client. 132 --with-librtmp enable srs-librtmp, library for client.
131 --with-research build the research tools. 133 --with-research build the research tools.
132 --with-utest build the utest for SRS. 134 --with-utest build the utest for SRS.
133 - --with-gperf build SRS with gperf tools(no gmc/gmp/gcp, with tcmalloc only). 135 + --with-gperf build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only).
134 --with-gmc build memory check for SRS with gperf tools. 136 --with-gmc build memory check for SRS with gperf tools.
  137 + --with-gmd build memory defense(corrupt memory) for SRS with gperf tools.
135 --with-gmp build memory profile for SRS with gperf tools. 138 --with-gmp build memory profile for SRS with gperf tools.
136 --with-gcp build cpu profile for SRS with gperf tools. 139 --with-gcp build cpu profile for SRS with gperf tools.
137 --with-gprof build SRS with gprof(GNU profile tool). 140 --with-gprof build SRS with gprof(GNU profile tool).
@@ -155,8 +158,9 @@ Options: @@ -155,8 +158,9 @@ Options:
155 --without-librtmp disable srs-librtmp, library for client. 158 --without-librtmp disable srs-librtmp, library for client.
156 --without-research do not build the research tools. 159 --without-research do not build the research tools.
157 --without-utest do not build the utest for SRS. 160 --without-utest do not build the utest for SRS.
158 - --without-gperf do not build SRS with gperf tools(without tcmalloc and gmc/gmp/gcp). 161 + --without-gperf do not build SRS with gperf tools(without tcmalloc and gmd/gmc/gmp/gcp).
159 --without-gmc do not build memory check for SRS with gperf tools. 162 --without-gmc do not build memory check for SRS with gperf tools.
  163 + --without-gmd do not build memory defense for SRS with gperf tools.
160 --without-gmp do not build memory profile for SRS with gperf tools. 164 --without-gmp do not build memory profile for SRS with gperf tools.
161 --without-gcp do not build cpu profile for SRS with gperf tools. 165 --without-gcp do not build cpu profile for SRS with gperf tools.
162 --without-gprof do not build srs with gprof(GNU profile tool). 166 --without-gprof do not build srs with gprof(GNU profile tool).
@@ -241,6 +245,7 @@ function parse_user_option() { @@ -241,6 +245,7 @@ function parse_user_option() {
241 --with-utest) SRS_UTEST=YES ;; 245 --with-utest) SRS_UTEST=YES ;;
242 --with-gperf) SRS_GPERF=YES ;; 246 --with-gperf) SRS_GPERF=YES ;;
243 --with-gmc) SRS_GPERF_MC=YES ;; 247 --with-gmc) SRS_GPERF_MC=YES ;;
  248 + --with-gmd) SRS_GPERF_MD=YES ;;
244 --with-gmp) SRS_GPERF_MP=YES ;; 249 --with-gmp) SRS_GPERF_MP=YES ;;
245 --with-gcp) SRS_GPERF_CP=YES ;; 250 --with-gcp) SRS_GPERF_CP=YES ;;
246 --with-gprof) SRS_GPROF=YES ;; 251 --with-gprof) SRS_GPROF=YES ;;
@@ -266,6 +271,7 @@ function parse_user_option() { @@ -266,6 +271,7 @@ function parse_user_option() {
266 --without-utest) SRS_UTEST=NO ;; 271 --without-utest) SRS_UTEST=NO ;;
267 --without-gperf) SRS_GPERF=NO ;; 272 --without-gperf) SRS_GPERF=NO ;;
268 --without-gmc) SRS_GPERF_MC=NO ;; 273 --without-gmc) SRS_GPERF_MC=NO ;;
  274 + --without-gmd) SRS_GPERF_MD=NO ;;
269 --without-gmp) SRS_GPERF_MP=NO ;; 275 --without-gmp) SRS_GPERF_MP=NO ;;
270 --without-gcp) SRS_GPERF_CP=NO ;; 276 --without-gcp) SRS_GPERF_CP=NO ;;
271 --without-gprof) SRS_GPROF=NO ;; 277 --without-gprof) SRS_GPROF=NO ;;
@@ -401,6 +407,7 @@ function apply_user_presets() { @@ -401,6 +407,7 @@ function apply_user_presets() {
401 SRS_UTEST=NO 407 SRS_UTEST=NO
402 SRS_GPERF=NO 408 SRS_GPERF=NO
403 SRS_GPERF_MC=NO 409 SRS_GPERF_MC=NO
  410 + SRS_GPERF_MD=NO
404 SRS_GPERF_MP=NO 411 SRS_GPERF_MP=NO
405 SRS_GPERF_CP=NO 412 SRS_GPERF_CP=NO
406 SRS_GPROF=NO 413 SRS_GPROF=NO
@@ -429,6 +436,7 @@ function apply_user_presets() { @@ -429,6 +436,7 @@ function apply_user_presets() {
429 SRS_UTEST=YES 436 SRS_UTEST=YES
430 SRS_GPERF=NO 437 SRS_GPERF=NO
431 SRS_GPERF_MC=NO 438 SRS_GPERF_MC=NO
  439 + SRS_GPERF_MD=NO
432 SRS_GPERF_MP=NO 440 SRS_GPERF_MP=NO
433 SRS_GPERF_CP=NO 441 SRS_GPERF_CP=NO
434 SRS_GPROF=NO 442 SRS_GPROF=NO
@@ -457,6 +465,7 @@ function apply_user_presets() { @@ -457,6 +465,7 @@ function apply_user_presets() {
457 SRS_UTEST=NO 465 SRS_UTEST=NO
458 SRS_GPERF=NO 466 SRS_GPERF=NO
459 SRS_GPERF_MC=NO 467 SRS_GPERF_MC=NO
  468 + SRS_GPERF_MD=NO
460 SRS_GPERF_MP=NO 469 SRS_GPERF_MP=NO
461 SRS_GPERF_CP=NO 470 SRS_GPERF_CP=NO
462 SRS_GPROF=NO 471 SRS_GPROF=NO
@@ -485,6 +494,7 @@ function apply_user_presets() { @@ -485,6 +494,7 @@ function apply_user_presets() {
485 SRS_UTEST=NO 494 SRS_UTEST=NO
486 SRS_GPERF=NO 495 SRS_GPERF=NO
487 SRS_GPERF_MC=NO 496 SRS_GPERF_MC=NO
  497 + SRS_GPERF_MD=NO
488 SRS_GPERF_MP=NO 498 SRS_GPERF_MP=NO
489 SRS_GPERF_CP=NO 499 SRS_GPERF_CP=NO
490 SRS_GPROF=NO 500 SRS_GPROF=NO
@@ -513,6 +523,7 @@ function apply_user_presets() { @@ -513,6 +523,7 @@ function apply_user_presets() {
513 SRS_UTEST=NO 523 SRS_UTEST=NO
514 SRS_GPERF=NO 524 SRS_GPERF=NO
515 SRS_GPERF_MC=NO 525 SRS_GPERF_MC=NO
  526 + SRS_GPERF_MD=NO
516 SRS_GPERF_MP=NO 527 SRS_GPERF_MP=NO
517 SRS_GPERF_CP=NO 528 SRS_GPERF_CP=NO
518 SRS_GPROF=NO 529 SRS_GPROF=NO
@@ -533,7 +544,7 @@ function apply_user_presets() { @@ -533,7 +544,7 @@ function apply_user_presets() {
533 SRS_HTTP_CORE=YES 544 SRS_HTTP_CORE=YES
534 SRS_HTTP_CALLBACK=YES 545 SRS_HTTP_CALLBACK=YES
535 SRS_HTTP_SERVER=YES 546 SRS_HTTP_SERVER=YES
536 - SRS_STREAM_CASTER=NO 547 + SRS_STREAM_CASTER=YES
537 SRS_KAFKA=YES 548 SRS_KAFKA=YES
538 SRS_HTTP_API=YES 549 SRS_HTTP_API=YES
539 SRS_LIBRTMP=YES 550 SRS_LIBRTMP=YES
@@ -541,6 +552,7 @@ function apply_user_presets() { @@ -541,6 +552,7 @@ function apply_user_presets() {
541 SRS_UTEST=NO 552 SRS_UTEST=NO
542 SRS_GPERF=NO 553 SRS_GPERF=NO
543 SRS_GPERF_MC=NO 554 SRS_GPERF_MC=NO
  555 + SRS_GPERF_MD=NO
544 SRS_GPERF_MP=NO 556 SRS_GPERF_MP=NO
545 SRS_GPERF_CP=NO 557 SRS_GPERF_CP=NO
546 SRS_GPROF=NO 558 SRS_GPROF=NO
@@ -562,7 +574,7 @@ function apply_user_presets() { @@ -562,7 +574,7 @@ function apply_user_presets() {
562 SRS_HTTP_CORE=YES 574 SRS_HTTP_CORE=YES
563 SRS_HTTP_CALLBACK=YES 575 SRS_HTTP_CALLBACK=YES
564 SRS_HTTP_SERVER=YES 576 SRS_HTTP_SERVER=YES
565 - SRS_STREAM_CASTER=NO 577 + SRS_STREAM_CASTER=YES
566 SRS_KAFKA=YES 578 SRS_KAFKA=YES
567 SRS_HTTP_API=YES 579 SRS_HTTP_API=YES
568 SRS_LIBRTMP=YES 580 SRS_LIBRTMP=YES
@@ -570,6 +582,7 @@ function apply_user_presets() { @@ -570,6 +582,7 @@ function apply_user_presets() {
570 SRS_UTEST=NO 582 SRS_UTEST=NO
571 SRS_GPERF=NO 583 SRS_GPERF=NO
572 SRS_GPERF_MC=NO 584 SRS_GPERF_MC=NO
  585 + SRS_GPERF_MD=NO
573 SRS_GPERF_MP=NO 586 SRS_GPERF_MP=NO
574 SRS_GPERF_CP=NO 587 SRS_GPERF_CP=NO
575 SRS_GPROF=NO 588 SRS_GPROF=NO
@@ -590,7 +603,7 @@ function apply_user_presets() { @@ -590,7 +603,7 @@ function apply_user_presets() {
590 SRS_HTTP_CORE=YES 603 SRS_HTTP_CORE=YES
591 SRS_HTTP_CALLBACK=YES 604 SRS_HTTP_CALLBACK=YES
592 SRS_HTTP_SERVER=YES 605 SRS_HTTP_SERVER=YES
593 - SRS_STREAM_CASTER=NO 606 + SRS_STREAM_CASTER=YES
594 SRS_KAFKA=YES 607 SRS_KAFKA=YES
595 SRS_HTTP_API=YES 608 SRS_HTTP_API=YES
596 SRS_LIBRTMP=YES 609 SRS_LIBRTMP=YES
@@ -598,6 +611,7 @@ function apply_user_presets() { @@ -598,6 +611,7 @@ function apply_user_presets() {
598 SRS_UTEST=YES 611 SRS_UTEST=YES
599 SRS_GPERF=NO 612 SRS_GPERF=NO
600 SRS_GPERF_MC=NO 613 SRS_GPERF_MC=NO
  614 + SRS_GPERF_MD=NO
601 SRS_GPERF_MP=NO 615 SRS_GPERF_MP=NO
602 SRS_GPERF_CP=NO 616 SRS_GPERF_CP=NO
603 SRS_GPROF=NO 617 SRS_GPROF=NO
@@ -618,7 +632,7 @@ function apply_user_presets() { @@ -618,7 +632,7 @@ function apply_user_presets() {
618 SRS_HTTP_CORE=YES 632 SRS_HTTP_CORE=YES
619 SRS_HTTP_CALLBACK=YES 633 SRS_HTTP_CALLBACK=YES
620 SRS_HTTP_SERVER=YES 634 SRS_HTTP_SERVER=YES
621 - SRS_STREAM_CASTER=NO 635 + SRS_STREAM_CASTER=YES
622 SRS_KAFKA=YES 636 SRS_KAFKA=YES
623 SRS_HTTP_API=YES 637 SRS_HTTP_API=YES
624 SRS_LIBRTMP=YES 638 SRS_LIBRTMP=YES
@@ -626,6 +640,7 @@ function apply_user_presets() { @@ -626,6 +640,7 @@ function apply_user_presets() {
626 SRS_UTEST=YES 640 SRS_UTEST=YES
627 SRS_GPERF=NO 641 SRS_GPERF=NO
628 SRS_GPERF_MC=NO 642 SRS_GPERF_MC=NO
  643 + SRS_GPERF_MD=NO
629 SRS_GPERF_MP=NO 644 SRS_GPERF_MP=NO
630 SRS_GPERF_CP=NO 645 SRS_GPERF_CP=NO
631 SRS_GPROF=NO 646 SRS_GPROF=NO
@@ -646,7 +661,7 @@ function apply_user_presets() { @@ -646,7 +661,7 @@ function apply_user_presets() {
646 SRS_HTTP_CORE=YES 661 SRS_HTTP_CORE=YES
647 SRS_HTTP_CALLBACK=YES 662 SRS_HTTP_CALLBACK=YES
648 SRS_HTTP_SERVER=YES 663 SRS_HTTP_SERVER=YES
649 - SRS_STREAM_CASTER=NO 664 + SRS_STREAM_CASTER=YES
650 SRS_KAFKA=YES 665 SRS_KAFKA=YES
651 SRS_HTTP_API=YES 666 SRS_HTTP_API=YES
652 SRS_LIBRTMP=YES 667 SRS_LIBRTMP=YES
@@ -654,6 +669,7 @@ function apply_user_presets() { @@ -654,6 +669,7 @@ function apply_user_presets() {
654 SRS_UTEST=YES 669 SRS_UTEST=YES
655 SRS_GPERF=NO 670 SRS_GPERF=NO
656 SRS_GPERF_MC=NO 671 SRS_GPERF_MC=NO
  672 + SRS_GPERF_MD=NO
657 SRS_GPERF_MP=NO 673 SRS_GPERF_MP=NO
658 SRS_GPERF_CP=NO 674 SRS_GPERF_CP=NO
659 SRS_GPROF=NO 675 SRS_GPROF=NO
@@ -674,7 +690,7 @@ function apply_user_presets() { @@ -674,7 +690,7 @@ function apply_user_presets() {
674 SRS_HTTP_CORE=YES 690 SRS_HTTP_CORE=YES
675 SRS_HTTP_CALLBACK=YES 691 SRS_HTTP_CALLBACK=YES
676 SRS_HTTP_SERVER=YES 692 SRS_HTTP_SERVER=YES
677 - SRS_STREAM_CASTER=NO 693 + SRS_STREAM_CASTER=YES
678 SRS_KAFKA=YES 694 SRS_KAFKA=YES
679 SRS_HTTP_API=YES 695 SRS_HTTP_API=YES
680 SRS_LIBRTMP=NO 696 SRS_LIBRTMP=NO
@@ -682,6 +698,7 @@ function apply_user_presets() { @@ -682,6 +698,7 @@ function apply_user_presets() {
682 SRS_UTEST=NO 698 SRS_UTEST=NO
683 SRS_GPERF=NO 699 SRS_GPERF=NO
684 SRS_GPERF_MC=NO 700 SRS_GPERF_MC=NO
  701 + SRS_GPERF_MD=NO
685 SRS_GPERF_MP=NO 702 SRS_GPERF_MP=NO
686 SRS_GPERF_CP=NO 703 SRS_GPERF_CP=NO
687 SRS_GPROF=NO 704 SRS_GPROF=NO
@@ -702,7 +719,7 @@ function apply_user_presets() { @@ -702,7 +719,7 @@ function apply_user_presets() {
702 SRS_HTTP_CORE=YES 719 SRS_HTTP_CORE=YES
703 SRS_HTTP_CALLBACK=YES 720 SRS_HTTP_CALLBACK=YES
704 SRS_HTTP_SERVER=YES 721 SRS_HTTP_SERVER=YES
705 - SRS_STREAM_CASTER=NO 722 + SRS_STREAM_CASTER=YES
706 SRS_KAFKA=YES 723 SRS_KAFKA=YES
707 SRS_HTTP_API=YES 724 SRS_HTTP_API=YES
708 SRS_LIBRTMP=YES 725 SRS_LIBRTMP=YES
@@ -710,6 +727,7 @@ function apply_user_presets() { @@ -710,6 +727,7 @@ function apply_user_presets() {
710 SRS_UTEST=YES 727 SRS_UTEST=YES
711 SRS_GPERF=NO 728 SRS_GPERF=NO
712 SRS_GPERF_MC=NO 729 SRS_GPERF_MC=NO
  730 + SRS_GPERF_MD=NO
713 SRS_GPERF_MP=NO 731 SRS_GPERF_MP=NO
714 SRS_GPERF_CP=NO 732 SRS_GPERF_CP=NO
715 SRS_GPROF=NO 733 SRS_GPROF=NO
@@ -730,7 +748,7 @@ function apply_user_presets() { @@ -730,7 +748,7 @@ function apply_user_presets() {
730 SRS_HTTP_CORE=YES 748 SRS_HTTP_CORE=YES
731 SRS_HTTP_CALLBACK=YES 749 SRS_HTTP_CALLBACK=YES
732 SRS_HTTP_SERVER=YES 750 SRS_HTTP_SERVER=YES
733 - SRS_STREAM_CASTER=NO 751 + SRS_STREAM_CASTER=YES
734 SRS_KAFKA=YES 752 SRS_KAFKA=YES
735 SRS_HTTP_API=YES 753 SRS_HTTP_API=YES
736 SRS_LIBRTMP=YES 754 SRS_LIBRTMP=YES
@@ -738,6 +756,7 @@ function apply_user_presets() { @@ -738,6 +756,7 @@ function apply_user_presets() {
738 SRS_UTEST=NO 756 SRS_UTEST=NO
739 SRS_GPERF=NO 757 SRS_GPERF=NO
740 SRS_GPERF_MC=NO 758 SRS_GPERF_MC=NO
  759 + SRS_GPERF_MD=NO
741 SRS_GPERF_MP=NO 760 SRS_GPERF_MP=NO
742 SRS_GPERF_CP=NO 761 SRS_GPERF_CP=NO
743 SRS_GPROF=NO 762 SRS_GPROF=NO
@@ -766,6 +785,7 @@ function apply_user_presets() { @@ -766,6 +785,7 @@ function apply_user_presets() {
766 SRS_UTEST=NO 785 SRS_UTEST=NO
767 SRS_GPERF=NO 786 SRS_GPERF=NO
768 SRS_GPERF_MC=NO 787 SRS_GPERF_MC=NO
  788 + SRS_GPERF_MD=NO
769 SRS_GPERF_MP=NO 789 SRS_GPERF_MP=NO
770 SRS_GPERF_CP=NO 790 SRS_GPERF_CP=NO
771 SRS_GPROF=NO 791 SRS_GPROF=NO
@@ -829,6 +849,7 @@ function apply_user_detail_options() { @@ -829,6 +849,7 @@ function apply_user_detail_options() {
829 SRS_UTEST=NO 849 SRS_UTEST=NO
830 SRS_GPERF=NO 850 SRS_GPERF=NO
831 SRS_GPERF_MC=NO 851 SRS_GPERF_MC=NO
  852 + SRS_GPERF_MD=NO
832 SRS_GPERF_MP=NO 853 SRS_GPERF_MP=NO
833 SRS_GPERF_CP=NO 854 SRS_GPERF_CP=NO
834 SRS_GPROF=NO 855 SRS_GPROF=NO
@@ -861,6 +882,7 @@ SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}" @@ -861,6 +882,7 @@ SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}"
861 if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-utest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-utest"; fi 882 if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-utest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-utest"; fi
862 if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi 883 if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi
863 if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi 884 if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi
  885 + if [ $SRS_GPERF_MD = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmd"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmd"; fi
864 if [ $SRS_GPERF_MP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmp"; fi 886 if [ $SRS_GPERF_MP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmp"; fi
865 if [ $SRS_GPERF_CP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gcp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gcp"; fi 887 if [ $SRS_GPERF_CP = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gcp"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gcp"; fi
866 if [ $SRS_GPROF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gprof"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gprof"; fi 888 if [ $SRS_GPROF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gprof"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gprof"; fi
@@ -882,6 +904,7 @@ function check_option_conflicts() { @@ -882,6 +904,7 @@ function check_option_conflicts() {
882 # check conflict 904 # check conflict
883 if [ $SRS_GPERF = NO ]; then 905 if [ $SRS_GPERF = NO ]; then
884 if [ $SRS_GPERF_MC = YES ]; then echo "gperf-mc depends on gperf, see: ./configure --help"; __check_ok=NO; fi 906 if [ $SRS_GPERF_MC = YES ]; then echo "gperf-mc depends on gperf, see: ./configure --help"; __check_ok=NO; fi
  907 + if [ $SRS_GPERF_MD = YES ]; then echo "gperf-md depends on gperf, see: ./configure --help"; __check_ok=NO; fi
885 if [ $SRS_GPERF_MP = YES ]; then echo "gperf-mp depends on gperf, see: ./configure --help"; __check_ok=NO; fi 908 if [ $SRS_GPERF_MP = YES ]; then echo "gperf-mp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
886 if [ $SRS_GPERF_CP = YES ]; then echo "gperf-cp depends on gperf, see: ./configure --help"; __check_ok=NO; fi 909 if [ $SRS_GPERF_CP = YES ]; then echo "gperf-cp depends on gperf, see: ./configure --help"; __check_ok=NO; fi
887 fi 910 fi
@@ -897,6 +920,7 @@ function check_option_conflicts() { @@ -897,6 +920,7 @@ function check_option_conflicts() {
897 # generate the group option: SRS_GPERF 920 # generate the group option: SRS_GPERF
898 __gperf_slow=NO 921 __gperf_slow=NO
899 if [ $SRS_GPERF_MC = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi 922 if [ $SRS_GPERF_MC = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
  923 + if [ $SRS_GPERF_MD = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
900 if [ $SRS_GPERF_MP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi 924 if [ $SRS_GPERF_MP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
901 if [ $SRS_GPERF_CP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi 925 if [ $SRS_GPERF_CP = YES ]; then SRS_GPERF=YES; __gperf_slow=YES; fi
902 if [ $__gperf_slow = YES ]; then if [ $SRS_GPROF = YES ]; then 926 if [ $__gperf_slow = YES ]; then if [ $SRS_GPROF = YES ]; then
@@ -910,14 +934,24 @@ function check_option_conflicts() { @@ -910,14 +934,24 @@ function check_option_conflicts() {
910 if [ $SRS_RESEARCH = YES ]; then echo "research for arm is not available, see: ./configure --help"; __check_ok=NO; fi 934 if [ $SRS_RESEARCH = YES ]; then echo "research for arm is not available, see: ./configure --help"; __check_ok=NO; fi
911 if [ $SRS_GPERF = YES ]; then echo "gperf for arm is not available, see: ./configure --help"; __check_ok=NO; fi 935 if [ $SRS_GPERF = YES ]; then echo "gperf for arm is not available, see: ./configure --help"; __check_ok=NO; fi
912 if [ $SRS_GPERF_MC = YES ]; then echo "gmc for arm is not available, see: ./configure --help"; __check_ok=NO; fi 936 if [ $SRS_GPERF_MC = YES ]; then echo "gmc for arm is not available, see: ./configure --help"; __check_ok=NO; fi
  937 + if [ $SRS_GPERF_MD = YES ]; then echo "gmd for arm is not available, see: ./configure --help"; __check_ok=NO; fi
913 if [ $SRS_GPERF_MP = YES ]; then echo "gmp for arm is not available, see: ./configure --help"; __check_ok=NO; fi 938 if [ $SRS_GPERF_MP = YES ]; then echo "gmp for arm is not available, see: ./configure --help"; __check_ok=NO; fi
914 if [ $SRS_GPERF_CP = YES ]; then echo "gcp for arm is not available, see: ./configure --help"; __check_ok=NO; fi 939 if [ $SRS_GPERF_CP = YES ]; then echo "gcp for arm is not available, see: ./configure --help"; __check_ok=NO; fi
915 if [ $SRS_GPROF = YES ]; then echo "gprof for arm is not available, see: ./configure --help"; __check_ok=NO; fi 940 if [ $SRS_GPROF = YES ]; then echo "gprof for arm is not available, see: ./configure --help"; __check_ok=NO; fi
916 fi 941 fi
917 942
918 - # if x86/x64 or directly build, never use static  
919 - if [[ $SRS_X86_X64 = YES && $SRS_STATIC = YES ]]; then  
920 - echo "x86/x64 should never use static, see: ./configure --help"; __check_ok=NO; 943 + # osx not support gperf.
  944 + if [ $SRS_OSX = YES ]; then
  945 + if [ $SRS_GPERF = YES ]; then echo "gperf for osx is not available, see: ./configure --help"; __check_ok=NO; fi
  946 + if [ $SRS_GPERF_MC = YES ]; then echo "gmc for osx is not available, see: ./configure --help"; __check_ok=NO; fi
  947 + if [ $SRS_GPERF_MD = YES ]; then echo "gmd for osx is not available, see: ./configure --help"; __check_ok=NO; fi
  948 + if [ $SRS_GPERF_MP = YES ]; then echo "gmp for osx is not available, see: ./configure --help"; __check_ok=NO; fi
  949 + if [ $SRS_GPERF_CP = YES ]; then echo "gcp for osx is not available, see: ./configure --help"; __check_ok=NO; fi
  950 + fi
  951 +
  952 + # if osx, never use static
  953 + if [[ $SRS_OSX = YES && $SRS_STATIC = YES ]]; then
  954 + echo "osx should never use static, see: ./configure --help"; __check_ok=NO;
921 fi 955 fi
922 956
923 # TODO: FIXME: check more os. 957 # TODO: FIXME: check more os.
@@ -939,6 +973,7 @@ function check_option_conflicts() { @@ -939,6 +973,7 @@ function check_option_conflicts() {
939 if [ $SRS_UTEST = RESERVED ]; then echo "you must specifies the utest, see: ./configure --help"; __check_ok=NO; fi 973 if [ $SRS_UTEST = RESERVED ]; then echo "you must specifies the utest, see: ./configure --help"; __check_ok=NO; fi
940 if [ $SRS_GPERF = RESERVED ]; then echo "you must specifies the gperf, see: ./configure --help"; __check_ok=NO; fi 974 if [ $SRS_GPERF = RESERVED ]; then echo "you must specifies the gperf, see: ./configure --help"; __check_ok=NO; fi
941 if [ $SRS_GPERF_MC = RESERVED ]; then echo "you must specifies the gperf-mc, see: ./configure --help"; __check_ok=NO; fi 975 if [ $SRS_GPERF_MC = RESERVED ]; then echo "you must specifies the gperf-mc, see: ./configure --help"; __check_ok=NO; fi
  976 + if [ $SRS_GPERF_MD = RESERVED ]; then echo "you must specifies the gperf-md, see: ./configure --help"; __check_ok=NO; fi
942 if [ $SRS_GPERF_MP = RESERVED ]; then echo "you must specifies the gperf-mp, see: ./configure --help"; __check_ok=NO; fi 977 if [ $SRS_GPERF_MP = RESERVED ]; then echo "you must specifies the gperf-mp, see: ./configure --help"; __check_ok=NO; fi
943 if [ $SRS_GPERF_CP = RESERVED ]; then echo "you must specifies the gperf-cp, see: ./configure --help"; __check_ok=NO; fi 978 if [ $SRS_GPERF_CP = RESERVED ]; then echo "you must specifies the gperf-cp, see: ./configure --help"; __check_ok=NO; fi
944 if [ $SRS_GPROF = RESERVED ]; then echo "you must specifies the gprof, see: ./configure --help"; __check_ok=NO; fi 979 if [ $SRS_GPROF = RESERVED ]; then echo "you must specifies the gprof, see: ./configure --help"; __check_ok=NO; fi
@@ -19,6 +19,7 @@ SrsResearchSummaryColor="\${GREEN}{disabled} "; if [ $SRS_RESEARCH = YES ]; then @@ -19,6 +19,7 @@ SrsResearchSummaryColor="\${GREEN}{disabled} "; if [ $SRS_RESEARCH = YES ]; then
19 SrsUtestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\${GREEN}"; fi 19 SrsUtestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\${GREEN}"; fi
20 SrsGperfSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\${GREEN}"; fi 20 SrsGperfSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\${GREEN}"; fi
21 SrsGperfMCSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi 21 SrsGperfMCSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi
  22 +SrsGperfMDSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MD = YES ]; then SrsGperfMDSummaryColor="\${YELLOW}"; fi
22 SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then SrsGperfMPSummaryColor="\${YELLOW}"; fi 23 SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then SrsGperfMPSummaryColor="\${YELLOW}"; fi
23 SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi 24 SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
24 SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi 25 SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi
@@ -37,6 +38,9 @@ BLACK="\\${BLACK}" @@ -37,6 +38,9 @@ BLACK="\\${BLACK}"
37 echo -e "\${GREEN}build summary:\${BLACK}" 38 echo -e "\${GREEN}build summary:\${BLACK}"
38 echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}" 39 echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}"
39 echo -e " |${SrsGperfSummaryColor}gperf @see: https://github.com/ossrs/srs/wiki/v1_CN_GPERF\${BLACK}" 40 echo -e " |${SrsGperfSummaryColor}gperf @see: https://github.com/ossrs/srs/wiki/v1_CN_GPERF\${BLACK}"
  41 +echo -e " | ${SrsGperfMDSummaryColor}gmd @see: http://blog.csdn.net/win_lin/article/details/50461709\${BLACK}"
  42 +echo -e " | ${SrsGperfMDSummaryColor}gmd: gperf memory defense, or memory corrupt detect\${BLACK}"
  43 +echo -e " | ${SrsGperfMDSummaryColor}env TCMALLOC_PAGE_FENCE=1 ./objs/srs -c conf/console.conf\${BLACK}"
40 echo -e " | ${SrsGperfMCSummaryColor}gmc @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\${BLACK}" 44 echo -e " | ${SrsGperfMCSummaryColor}gmc @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\${BLACK}"
41 echo -e " | ${SrsGperfMCSummaryColor}gmc: gperf memory check, or memory leak detect\${BLACK}" 45 echo -e " | ${SrsGperfMCSummaryColor}gmc: gperf memory check, or memory leak detect\${BLACK}"
42 echo -e " | ${SrsGperfMCSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/console.conf 2>gmc.log # start gmc\${BLACK}" 46 echo -e " | ${SrsGperfMCSummaryColor}env PPROF_PATH=./objs/pprof HEAPCHECK=normal ./objs/srs -c conf/console.conf 2>gmc.log # start gmc\${BLACK}"
@@ -7,6 +7,9 @@ @@ -7,6 +7,9 @@
7 # for example, 192.168.1.100:1935 10.10.10.100:1935 7 # for example, 192.168.1.100:1935 10.10.10.100:1935
8 # where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935 8 # where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935
9 listen 1935; 9 listen 1935;
  10 +# change to this dir as the cwd.
  11 +# ignore if empty or not configed.
  12 +work_dir /usr/local/srs;
10 # the pid file 13 # the pid file
11 # to ensure only one process can use a pid file 14 # to ensure only one process can use a pid file
12 # and provides the current running process id, for script, 15 # and provides the current running process id, for script,
@@ -126,6 +126,7 @@ if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS @@ -126,6 +126,7 @@ if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS
126 # gperftools-2.1, for mem check and mem/cpu profile 126 # gperftools-2.1, for mem check and mem/cpu profile
127 LibGperfRoot=""; LibGperfFile="" 127 LibGperfRoot=""; LibGperfFile=""
128 if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a"; fi 128 if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a"; fi
  129 +if [ $SRS_GPERF_MD = YES ]; then LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a"; fi
129 # the link options, always use static link 130 # the link options, always use static link
130 SrsLinkOptions="-ldl"; 131 SrsLinkOptions="-ldl";
131 if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl"; fi fi 132 if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl"; fi fi
@@ -181,7 +182,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then @@ -181,7 +182,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
181 "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_http_static" 182 "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_http_static"
182 "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds" 183 "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds"
183 "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call" 184 "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call"
184 - "srs_app_caster_flv" "srs_app_process" "srs_app_ng_exec" "srs_app_kafka") 185 + "srs_app_caster_flv" "srs_app_process" "srs_app_ng_exec" "srs_app_kafka"
  186 + "srs_app_hourglass")
185 DEFINES="" 187 DEFINES=""
186 # add each modules for app 188 # add each modules for app
187 for SRS_MODULE in ${SRS_MODULES[*]}; do 189 for SRS_MODULE in ${SRS_MODULES[*]}; do
@@ -608,6 +610,11 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then @@ -608,6 +610,11 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
608 else 610 else
609 echo -e "${GREEN}note: gmc(gperf memory check) for srs are not builded${BLACK}" 611 echo -e "${GREEN}note: gmc(gperf memory check) for srs are not builded${BLACK}"
610 fi 612 fi
  613 + if [ $SRS_GPERF_MD = YES ]; then
  614 + echo -e "${YELLOW}gmd(gperf memory defense) for srs are builded -- Performance may suffer${BLACK}"
  615 + else
  616 + echo -e "${GREEN}note: gmd(gperf memory defense) for srs are not builded${BLACK}"
  617 + fi
611 if [ $SRS_GPERF_MP = YES ]; then 618 if [ $SRS_GPERF_MP = YES ]; then
612 echo -e "${YELLOW}gmp(gperf memory profile) for srs are builded -- Performance may suffer${BLACK}" 619 echo -e "${YELLOW}gmp(gperf memory profile) for srs are builded -- Performance may suffer${BLACK}"
613 else 620 else
@@ -78,7 +78,7 @@ start() { @@ -78,7 +78,7 @@ start() {
78 if [[ -z $log_file ]]; then 78 if [[ -z $log_file ]]; then
79 (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) 79 (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1)
80 else 80 else
81 - (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) 81 + (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file.sys 2>&1)
82 fi 82 fi
83 83
84 # check again after start server 84 # check again after start server
@@ -78,7 +78,7 @@ start() { @@ -78,7 +78,7 @@ start() {
78 if [[ -z $log_file ]]; then 78 if [[ -z $log_file ]]; then
79 (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) 79 (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1)
80 else 80 else
81 - (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) 81 + (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file.sys 2>&1)
82 fi 82 fi
83 83
84 # check again after start server 84 # check again after start server
@@ -78,7 +78,7 @@ start() { @@ -78,7 +78,7 @@ start() {
78 if [[ -z $log_file ]]; then 78 if [[ -z $log_file ]]; then
79 (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) 79 (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1)
80 else 80 else
81 - (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) 81 + (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file.sys 2>&1)
82 fi 82 fi
83 83
84 # check again after start server 84 # check again after start server
@@ -75,6 +75,8 @@ @@ -75,6 +75,8 @@
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 3C1EE6AE1AB1055800576EE9 /* srs_app_hds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */; }; 76 3C1EE6AE1AB1055800576EE9 /* srs_app_hds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */; };
77 3C1EE6D71AB1367D00576EE9 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6D61AB1367D00576EE9 /* README.md */; }; 77 3C1EE6D71AB1367D00576EE9 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6D61AB1367D00576EE9 /* README.md */; };
  78 + 3C24ECCD1C3B824800460622 /* memory.error.notcmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C24ECCB1C3B824800460622 /* memory.error.notcmalloc.cpp */; };
  79 + 3C24ECCE1C3B824800460622 /* memory.error.tcmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C24ECCC1C3B824800460622 /* memory.error.tcmalloc.cpp */; };
78 3C26E3C61BB146FF00D0F9DB /* srs_app_kafka.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C26E3C41BB146FF00D0F9DB /* srs_app_kafka.cpp */; }; 80 3C26E3C61BB146FF00D0F9DB /* srs_app_kafka.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C26E3C41BB146FF00D0F9DB /* srs_app_kafka.cpp */; };
79 3C28EDDF1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */; }; 81 3C28EDDF1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */; };
80 3C36DB5B1ABD1CB90066CCAF /* srs_lib_bandwidth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB551ABD1CB90066CCAF /* srs_lib_bandwidth.cpp */; }; 82 3C36DB5B1ABD1CB90066CCAF /* srs_lib_bandwidth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB551ABD1CB90066CCAF /* srs_lib_bandwidth.cpp */; };
@@ -103,6 +105,7 @@ @@ -103,6 +105,7 @@
103 3C689FA01AB6AAC800C9CEEE /* stk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9C1AB6AAC800C9CEEE /* stk.c */; }; 105 3C689FA01AB6AAC800C9CEEE /* stk.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9C1AB6AAC800C9CEEE /* stk.c */; };
104 3C689FA11AB6AAC800C9CEEE /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9D1AB6AAC800C9CEEE /* sync.c */; }; 106 3C689FA11AB6AAC800C9CEEE /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C689F9D1AB6AAC800C9CEEE /* sync.c */; };
105 3C82802C1BAFF8CC004A1794 /* srs_kafka_stack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C82802A1BAFF8CC004A1794 /* srs_kafka_stack.cpp */; }; 107 3C82802C1BAFF8CC004A1794 /* srs_kafka_stack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C82802A1BAFF8CC004A1794 /* srs_kafka_stack.cpp */; };
  108 + 3C8CE01E1C3F482100548CC6 /* srs_app_hourglass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C8CE01D1C3F482100548CC6 /* srs_app_hourglass.cpp */; };
106 3CB25C2A1BB269FD00C97A63 /* jmp_sp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */; }; 109 3CB25C2A1BB269FD00C97A63 /* jmp_sp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */; };
107 3CC52DD81ACE4023006FEB01 /* srs_utest_amf0.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC52DCA1ACE4023006FEB01 /* srs_utest_amf0.cpp */; }; 110 3CC52DD81ACE4023006FEB01 /* srs_utest_amf0.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC52DCA1ACE4023006FEB01 /* srs_utest_amf0.cpp */; };
108 3CC52DD91ACE4023006FEB01 /* srs_utest_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC52DCC1ACE4023006FEB01 /* srs_utest_config.cpp */; }; 111 3CC52DD91ACE4023006FEB01 /* srs_utest_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC52DCC1ACE4023006FEB01 /* srs_utest_config.cpp */; };
@@ -326,6 +329,8 @@ @@ -326,6 +329,8 @@
326 3C1EE6D41AB1367D00576EE9 /* DONATIONS.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DONATIONS.txt; path = ../../../DONATIONS.txt; sourceTree = "<group>"; }; 329 3C1EE6D41AB1367D00576EE9 /* DONATIONS.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DONATIONS.txt; path = ../../../DONATIONS.txt; sourceTree = "<group>"; };
327 3C1EE6D51AB1367D00576EE9 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../../../LICENSE; sourceTree = "<group>"; }; 330 3C1EE6D51AB1367D00576EE9 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../../../LICENSE; sourceTree = "<group>"; };
328 3C1EE6D61AB1367D00576EE9 /* README.md */ = {isa = PBXFileReference; explicitFileType = net.daringfireball.markdown; fileEncoding = 4; name = README.md; path = ../../../README.md; sourceTree = "<group>"; wrapsLines = 0; }; 331 3C1EE6D61AB1367D00576EE9 /* README.md */ = {isa = PBXFileReference; explicitFileType = net.daringfireball.markdown; fileEncoding = 4; name = README.md; path = ../../../README.md; sourceTree = "<group>"; wrapsLines = 0; };
  332 + 3C24ECCB1C3B824800460622 /* memory.error.notcmalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = memory.error.notcmalloc.cpp; path = ../../../research/gperftools/memory.error.notcmalloc.cpp; sourceTree = "<group>"; };
  333 + 3C24ECCC1C3B824800460622 /* memory.error.tcmalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = memory.error.tcmalloc.cpp; path = ../../../research/gperftools/memory.error.tcmalloc.cpp; sourceTree = "<group>"; };
329 3C26E3C41BB146FF00D0F9DB /* srs_app_kafka.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_kafka.cpp; path = ../../../src/app/srs_app_kafka.cpp; sourceTree = "<group>"; }; 334 3C26E3C41BB146FF00D0F9DB /* srs_app_kafka.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_kafka.cpp; path = ../../../src/app/srs_app_kafka.cpp; sourceTree = "<group>"; };
330 3C26E3C51BB146FF00D0F9DB /* srs_app_kafka.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_kafka.hpp; path = ../../../src/app/srs_app_kafka.hpp; sourceTree = "<group>"; }; 335 3C26E3C51BB146FF00D0F9DB /* srs_app_kafka.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_kafka.hpp; path = ../../../src/app/srs_app_kafka.hpp; sourceTree = "<group>"; };
331 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_caster_flv.cpp; path = ../../../src/app/srs_app_caster_flv.cpp; sourceTree = "<group>"; }; 336 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_caster_flv.cpp; path = ../../../src/app/srs_app_caster_flv.cpp; sourceTree = "<group>"; };
@@ -374,6 +379,8 @@ @@ -374,6 +379,8 @@
374 3C8280291BAFF896004A1794 /* transform.edge.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = transform.edge.conf; path = ../../../conf/transform.edge.conf; sourceTree = "<group>"; }; 379 3C8280291BAFF896004A1794 /* transform.edge.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = transform.edge.conf; path = ../../../conf/transform.edge.conf; sourceTree = "<group>"; };
375 3C82802A1BAFF8CC004A1794 /* srs_kafka_stack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_kafka_stack.cpp; path = ../../../src/protocol/srs_kafka_stack.cpp; sourceTree = "<group>"; }; 380 3C82802A1BAFF8CC004A1794 /* srs_kafka_stack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_kafka_stack.cpp; path = ../../../src/protocol/srs_kafka_stack.cpp; sourceTree = "<group>"; };
376 3C82802B1BAFF8CC004A1794 /* srs_kafka_stack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_kafka_stack.hpp; path = ../../../src/protocol/srs_kafka_stack.hpp; sourceTree = "<group>"; }; 381 3C82802B1BAFF8CC004A1794 /* srs_kafka_stack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_kafka_stack.hpp; path = ../../../src/protocol/srs_kafka_stack.hpp; sourceTree = "<group>"; };
  382 + 3C8CE01C1C3F482100548CC6 /* srs_app_hourglass.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_hourglass.hpp; path = ../../../src/app/srs_app_hourglass.hpp; sourceTree = "<group>"; };
  383 + 3C8CE01D1C3F482100548CC6 /* srs_app_hourglass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_hourglass.cpp; path = ../../../src/app/srs_app_hourglass.cpp; sourceTree = "<group>"; };
377 3CB25C281BB2596300C97A63 /* setup_variables.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = setup_variables.sh; path = ../../../auto/setup_variables.sh; sourceTree = "<group>"; }; 384 3CB25C281BB2596300C97A63 /* setup_variables.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = setup_variables.sh; path = ../../../auto/setup_variables.sh; sourceTree = "<group>"; };
378 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jmp_sp.cpp; path = ../../../research/arm/jmp_sp.cpp; sourceTree = "<group>"; }; 385 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jmp_sp.cpp; path = ../../../research/arm/jmp_sp.cpp; sourceTree = "<group>"; };
379 3CC52DCA1ACE4023006FEB01 /* srs_utest_amf0.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_utest_amf0.cpp; path = ../../src/utest/srs_utest_amf0.cpp; sourceTree = "<group>"; }; 386 3CC52DCA1ACE4023006FEB01 /* srs_utest_amf0.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_utest_amf0.cpp; path = ../../src/utest/srs_utest_amf0.cpp; sourceTree = "<group>"; };
@@ -444,6 +451,7 @@ @@ -444,6 +451,7 @@
444 3C1232041AAE80CB00CE8F6C /* main */, 451 3C1232041AAE80CB00CE8F6C /* main */,
445 3C1231F91AAE670E00CE8F6C /* objs */, 452 3C1231F91AAE670E00CE8F6C /* objs */,
446 3C1232BA1AAE826F00CE8F6C /* auto */, 453 3C1232BA1AAE826F00CE8F6C /* auto */,
  454 + 3C96ADC41B00A71000885304 /* modules */,
447 3C1232B91AAE825100CE8F6C /* scripts */, 455 3C1232B91AAE825100CE8F6C /* scripts */,
448 3C1EE6AF1AB107EE00576EE9 /* conf */, 456 3C1EE6AF1AB107EE00576EE9 /* conf */,
449 3C36DB541ABD1CA70066CCAF /* libs */, 457 3C36DB541ABD1CA70066CCAF /* libs */,
@@ -581,6 +589,8 @@ @@ -581,6 +589,8 @@
581 3C12325F1AAE81D900CE8F6C /* srs_app_heartbeat.hpp */, 589 3C12325F1AAE81D900CE8F6C /* srs_app_heartbeat.hpp */,
582 3C1232601AAE81D900CE8F6C /* srs_app_hls.cpp */, 590 3C1232601AAE81D900CE8F6C /* srs_app_hls.cpp */,
583 3C1232611AAE81D900CE8F6C /* srs_app_hls.hpp */, 591 3C1232611AAE81D900CE8F6C /* srs_app_hls.hpp */,
  592 + 3C8CE01D1C3F482100548CC6 /* srs_app_hourglass.cpp */,
  593 + 3C8CE01C1C3F482100548CC6 /* srs_app_hourglass.hpp */,
584 3C1232621AAE81D900CE8F6C /* srs_app_http_api.cpp */, 594 3C1232621AAE81D900CE8F6C /* srs_app_http_api.cpp */,
585 3C1232631AAE81D900CE8F6C /* srs_app_http_api.hpp */, 595 3C1232631AAE81D900CE8F6C /* srs_app_http_api.hpp */,
586 3C1232641AAE81D900CE8F6C /* srs_app_http_client.cpp */, 596 3C1232641AAE81D900CE8F6C /* srs_app_http_client.cpp */,
@@ -782,6 +792,8 @@ @@ -782,6 +792,8 @@
782 isa = PBXGroup; 792 isa = PBXGroup;
783 children = ( 793 children = (
784 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */, 794 3CB25C291BB269FD00C97A63 /* jmp_sp.cpp */,
  795 + 3C24ECCB1C3B824800460622 /* memory.error.notcmalloc.cpp */,
  796 + 3C24ECCC1C3B824800460622 /* memory.error.tcmalloc.cpp */,
785 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */, 797 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */,
786 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */, 798 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */,
787 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */, 799 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */,
@@ -816,6 +828,14 @@ @@ -816,6 +828,14 @@
816 name = "st-1.9"; 828 name = "st-1.9";
817 sourceTree = "<group>"; 829 sourceTree = "<group>";
818 }; 830 };
  831 + 3C96ADC41B00A71000885304 /* modules */ = {
  832 + isa = PBXGroup;
  833 + children = (
  834 + 3C24ECCA1C3A42D800460622 /* readme.txt */,
  835 + );
  836 + name = modules;
  837 + sourceTree = "<group>";
  838 + };
819 3CC52DC91ACE4006006FEB01 /* utest */ = { 839 3CC52DC91ACE4006006FEB01 /* utest */ = {
820 isa = PBXGroup; 840 isa = PBXGroup;
821 children = ( 841 children = (
@@ -904,6 +924,7 @@ @@ -904,6 +924,7 @@
904 3C663F171AB0155100286D8B /* srs_ingest_rtmp.c in Sources */, 924 3C663F171AB0155100286D8B /* srs_ingest_rtmp.c in Sources */,
905 3C26E3C61BB146FF00D0F9DB /* srs_app_kafka.cpp in Sources */, 925 3C26E3C61BB146FF00D0F9DB /* srs_app_kafka.cpp in Sources */,
906 3C663F131AB0155100286D8B /* srs_flv_injecter.c in Sources */, 926 3C663F131AB0155100286D8B /* srs_flv_injecter.c in Sources */,
  927 + 3C24ECCD1C3B824800460622 /* memory.error.notcmalloc.cpp in Sources */,
907 3C1232971AAE81D900CE8F6C /* srs_app_dvr.cpp in Sources */, 928 3C1232971AAE81D900CE8F6C /* srs_app_dvr.cpp in Sources */,
908 3CD247C31BB3F14100DC1922 /* srs_kernel_balance.cpp in Sources */, 929 3CD247C31BB3F14100DC1922 /* srs_kernel_balance.cpp in Sources */,
909 3C1232271AAE814D00CE8F6C /* srs_kernel_log.cpp in Sources */, 930 3C1232271AAE814D00CE8F6C /* srs_kernel_log.cpp in Sources */,
@@ -928,6 +949,7 @@ @@ -928,6 +949,7 @@
928 3CC52DDA1ACE4023006FEB01 /* srs_utest_core.cpp in Sources */, 949 3CC52DDA1ACE4023006FEB01 /* srs_utest_core.cpp in Sources */,
929 3C36DB5C1ABD1CB90066CCAF /* srs_lib_simple_socket.cpp in Sources */, 950 3C36DB5C1ABD1CB90066CCAF /* srs_lib_simple_socket.cpp in Sources */,
930 3C1232201AAE814D00CE8F6C /* srs_kernel_aac.cpp in Sources */, 951 3C1232201AAE814D00CE8F6C /* srs_kernel_aac.cpp in Sources */,
  952 + 3C8CE01E1C3F482100548CC6 /* srs_app_hourglass.cpp in Sources */,
931 3C1232941AAE81D900CE8F6C /* srs_app_bandwidth.cpp in Sources */, 953 3C1232941AAE81D900CE8F6C /* srs_app_bandwidth.cpp in Sources */,
932 3C1232221AAE814D00CE8F6C /* srs_kernel_codec.cpp in Sources */, 954 3C1232221AAE814D00CE8F6C /* srs_kernel_codec.cpp in Sources */,
933 3C1232B71AAE81D900CE8F6C /* srs_app_utility.cpp in Sources */, 955 3C1232B71AAE81D900CE8F6C /* srs_app_utility.cpp in Sources */,
@@ -958,6 +980,7 @@ @@ -958,6 +980,7 @@
958 3C689F9F1AB6AAC800C9CEEE /* sched.c in Sources */, 980 3C689F9F1AB6AAC800C9CEEE /* sched.c in Sources */,
959 3C1232061AAE812C00CE8F6C /* srs_main_server.cpp in Sources */, 981 3C1232061AAE812C00CE8F6C /* srs_main_server.cpp in Sources */,
960 3C1232281AAE814D00CE8F6C /* srs_kernel_mp3.cpp in Sources */, 982 3C1232281AAE814D00CE8F6C /* srs_kernel_mp3.cpp in Sources */,
  983 + 3C24ECCE1C3B824800460622 /* memory.error.tcmalloc.cpp in Sources */,
961 3C1232B21AAE81D900CE8F6C /* srs_app_source.cpp in Sources */, 984 3C1232B21AAE81D900CE8F6C /* srs_app_source.cpp in Sources */,
962 3C1231F71AAE652D00CE8F6C /* srs_core_performance.cpp in Sources */, 985 3C1231F71AAE652D00CE8F6C /* srs_core_performance.cpp in Sources */,
963 3CC52DD81ACE4023006FEB01 /* srs_utest_amf0.cpp in Sources */, 986 3CC52DD81ACE4023006FEB01 /* srs_utest_amf0.cpp in Sources */,
  1 +/**
  2 +g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
  3 +*/
  4 +#include <unistd.h>
  5 +#include <string.h>
  6 +#include <stdio.h>
  7 +
  8 +void foo(char* p){
  9 + memcpy(p, "01234567890abcdef", 16);
  10 +}
  11 +int main(int argc, char** argv){
  12 + char* p = new char[10];
  13 + foo(p);
  14 + printf("p=%s\n", p);
  15 + return 0;
  16 +}
  1 +/**
  2 +g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
  3 +*/
  4 +#include <unistd.h>
  5 +#include <string.h>
  6 +#include <stdio.h>
  7 +
  8 +void foo(char* p){
  9 + memcpy(p, "01234567890abcdef", 16);
  10 +}
  11 +int main(int argc, char** argv){
  12 + char* p = new char[10];
  13 + foo(p);
  14 + printf("p=%s\n", p);
  15 + return 0;
  16 +}
@@ -26,6 +26,7 @@ gcc srs_detect_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_detect @@ -26,6 +26,7 @@ gcc srs_detect_rtmp.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_detect
26 26
27 #include <stdio.h> 27 #include <stdio.h>
28 #include <stdlib.h> 28 #include <stdlib.h>
  29 +#include <string.h>
29 30
30 #include "../../objs/include/srs_librtmp.h" 31 #include "../../objs/include/srs_librtmp.h"
31 32
@@ -41,8 +42,6 @@ int main(int argc, char** argv) @@ -41,8 +42,6 @@ int main(int argc, char** argv)
41 int64_t time_play_stream = 0; 42 int64_t time_play_stream = 0;
42 int64_t time_first_packet = 0; 43 int64_t time_first_packet = 0;
43 int64_t time_cleanup = 0; 44 int64_t time_cleanup = 0;
44 - // delay = actual - expect time when quit.  
45 - int delay = 0;  
46 // bytes 45 // bytes
47 int64_t bytes_nsend = 0; 46 int64_t bytes_nsend = 0;
48 int time_duration = 0; 47 int time_duration = 0;
@@ -59,6 +58,7 @@ int main(int argc, char** argv) @@ -59,6 +58,7 @@ int main(int argc, char** argv)
59 const char* rtmp_url = NULL; 58 const char* rtmp_url = NULL;
60 int duration = 0; 59 int duration = 0;
61 int timeout = 0; 60 int timeout = 0;
  61 + enum srs_url_schema sus;
62 62
63 printf("detect rtmp stream\n"); 63 printf("detect rtmp stream\n");
64 printf("srs(ossrs) client librtmp library.\n"); 64 printf("srs(ossrs) client librtmp library.\n");
@@ -66,12 +66,17 @@ int main(int argc, char** argv) @@ -66,12 +66,17 @@ int main(int argc, char** argv)
66 66
67 if (argc <= 3) { 67 if (argc <= 3) {
68 printf("detect stream on RTMP server, print result to stderr.\n" 68 printf("detect stream on RTMP server, print result to stderr.\n"
69 - "Usage: %s <rtmp_url> <duration> <timeout>\n" 69 + "Usage: %s <rtmp_url> <duration> <timeout> [url_schema]\n"
70 " rtmp_url RTMP stream url to play\n" 70 " rtmp_url RTMP stream url to play\n"
71 " duration how long to play, in seconds, stream time.\n" 71 " duration how long to play, in seconds, stream time.\n"
72 " timeout how long to timeout, in seconds, system time.\n" 72 " timeout how long to timeout, in seconds, system time.\n"
  73 + " url_schema the schema of url, default to vis, can be:\n"
  74 + " normal: rtmp://vhost:port/app/stream\n"
  75 + " via : rtmp://ip:port/vhost/app/stream\n"
  76 + " vis : rtmp://ip:port/app/stream?vhost=xxx\n"
  77 + " vis2 : rtmp://ip:port/app/stream?domain=xxx\n"
73 "For example:\n" 78 "For example:\n"
74 - " %s rtmp://127.0.0.1:1935/live/livestream 3 10\n", 79 + " %s rtmp://127.0.0.1:1935/bravo.chnvideo.com/live/livestream 3 10\n",
75 argv[0], argv[0]); 80 argv[0], argv[0]);
76 exit(-1); 81 exit(-1);
77 } 82 }
@@ -79,15 +84,36 @@ int main(int argc, char** argv) @@ -79,15 +84,36 @@ int main(int argc, char** argv)
79 rtmp_url = argv[1]; 84 rtmp_url = argv[1];
80 duration = atoi(argv[2]); 85 duration = atoi(argv[2]);
81 timeout = atoi(argv[3]); 86 timeout = atoi(argv[3]);
82 - 87 +
  88 + if (1) {
  89 + char *p = "vis";
  90 + if (argc > 4) {
  91 + p = argv[4];
  92 + }
  93 +
  94 + if (strcmp(p, "normal") == 0) {
  95 + sus = srs_url_schema_normal;
  96 + } else if (strcmp(p, "via") == 0) {
  97 + sus = srs_url_schema_via;
  98 + } else if (strcmp(p, "vis") == 0) {
  99 + sus = srs_url_schema_vis;
  100 + } else if (strcmp(p, "vis2") == 0){
  101 + sus = srs_url_schema_vis2;
  102 + } else {
  103 + srs_human_trace("url_schema must be normal/via/vis/vis2");
  104 + exit(-2);
  105 + }
  106 + srs_human_trace("url schema: %s", p);
  107 + }
  108 +
83 srs_human_trace("rtmp url: %s", rtmp_url); 109 srs_human_trace("rtmp url: %s", rtmp_url);
84 srs_human_trace("duration: %ds, timeout:%ds", duration, timeout); 110 srs_human_trace("duration: %ds, timeout:%ds", duration, timeout);
85 111
86 if (duration <= 0 || timeout <= 0) { 112 if (duration <= 0 || timeout <= 0) {
87 srs_human_trace("duration and timeout must be positive."); 113 srs_human_trace("duration and timeout must be positive.");
88 - exit(-2); 114 + exit(-3);
89 } 115 }
90 - 116 +
91 rtmp = srs_rtmp_create(rtmp_url); 117 rtmp = srs_rtmp_create(rtmp_url);
92 118
93 if ((ret = srs_rtmp_dns_resolve(rtmp)) != 0) { 119 if ((ret = srs_rtmp_dns_resolve(rtmp)) != 0) {
@@ -109,8 +135,8 @@ int main(int argc, char** argv) @@ -109,8 +135,8 @@ int main(int argc, char** argv)
109 goto rtmp_destroy; 135 goto rtmp_destroy;
110 } 136 }
111 srs_human_trace("do simple handshake success"); 137 srs_human_trace("do simple handshake success");
112 -  
113 - if ((ret = srs_rtmp_connect_app(rtmp)) != 0) { 138 +
  139 + if ((ret = srs_rtmp_connect_app3(rtmp, sus)) != 0) {
114 srs_human_trace("connect vhost/app failed. ret=%d", ret); 140 srs_human_trace("connect vhost/app failed. ret=%d", ret);
115 goto rtmp_destroy; 141 goto rtmp_destroy;
116 } 142 }
@@ -234,7 +234,6 @@ int main(int argc, char** argv) @@ -234,7 +234,6 @@ int main(int argc, char** argv)
234 goto rtmp_destroy; 234 goto rtmp_destroy;
235 } 235 }
236 236
237 -  
238 if (srs_rtmp_connect_app2(rtmp, 237 if (srs_rtmp_connect_app2(rtmp,
239 srs_server_ip, srs_server, srs_primary, srs_authors, srs_version, 238 srs_server_ip, srs_server, srs_primary, srs_authors, srs_version,
240 &srs_id, &srs_pid) != 0) { 239 &srs_id, &srs_pid) != 0) {
@@ -1905,11 +1905,6 @@ int SrsConfig::parse_options(int argc, char** argv) @@ -1905,11 +1905,6 @@ int SrsConfig::parse_options(int argc, char** argv)
1905 } 1905 }
1906 } 1906 }
1907 1907
1908 - // cwd  
1909 - char cwd[256];  
1910 - getcwd(cwd, sizeof(cwd));  
1911 - _cwd = cwd;  
1912 -  
1913 // config 1908 // config
1914 show_help = true; 1909 show_help = true;
1915 for (int i = 1; i < argc; i++) { 1910 for (int i = 1; i < argc; i++) {
@@ -1987,6 +1982,18 @@ int SrsConfig::parse_options(int argc, char** argv) @@ -1987,6 +1982,18 @@ int SrsConfig::parse_options(int argc, char** argv)
1987 return ret; 1982 return ret;
1988 } 1983 }
1989 1984
  1985 +int SrsConfig::initialize_cwd()
  1986 +{
  1987 + int ret = ERROR_SUCCESS;
  1988 +
  1989 + // cwd
  1990 + char cwd[256];
  1991 + getcwd(cwd, sizeof(cwd));
  1992 + _cwd = cwd;
  1993 +
  1994 + return ret;
  1995 +}
  1996 +
1990 int SrsConfig::persistence() 1997 int SrsConfig::persistence()
1991 { 1998 {
1992 int ret = ERROR_SUCCESS; 1999 int ret = ERROR_SUCCESS;
@@ -3529,7 +3536,7 @@ int SrsConfig::check_config() @@ -3529,7 +3536,7 @@ int SrsConfig::check_config()
3529 && n != "max_connections" && n != "daemon" && n != "heartbeat" 3536 && n != "max_connections" && n != "daemon" && n != "heartbeat"
3530 && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms" 3537 && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms"
3531 && n != "http_server" && n != "stream_caster" && n != "kafka" 3538 && n != "http_server" && n != "stream_caster" && n != "kafka"
3532 - && n != "utc_time" 3539 + && n != "utc_time" && n != "work_dir"
3533 ) { 3540 ) {
3534 ret = ERROR_SYSTEM_CONFIG_INVALID; 3541 ret = ERROR_SYSTEM_CONFIG_INVALID;
3535 srs_error("unsupported directive %s, ret=%d", n.c_str(), ret); 3542 srs_error("unsupported directive %s, ret=%d", n.c_str(), ret);
@@ -4179,6 +4186,17 @@ bool SrsConfig::get_utc_time() @@ -4179,6 +4186,17 @@ bool SrsConfig::get_utc_time()
4179 return SRS_CONF_PERFER_FALSE(conf->arg0()); 4186 return SRS_CONF_PERFER_FALSE(conf->arg0());
4180 } 4187 }
4181 4188
  4189 +string SrsConfig::get_work_dir() {
  4190 + static string DEFAULT = "";
  4191 +
  4192 + SrsConfDirective* conf = root->get("work_dir");
  4193 + if( !conf || conf->arg0().empty()) {
  4194 + return DEFAULT;
  4195 + }
  4196 +
  4197 + return conf->arg0();
  4198 +}
  4199 +
4182 vector<SrsConfDirective*> SrsConfig::get_stream_casters() 4200 vector<SrsConfDirective*> SrsConfig::get_stream_casters()
4183 { 4201 {
4184 srs_assert(root); 4202 srs_assert(root);
@@ -417,6 +417,11 @@ public: @@ -417,6 +417,11 @@ public:
417 */ 417 */
418 virtual int parse_options(int argc, char** argv); 418 virtual int parse_options(int argc, char** argv);
419 /** 419 /**
  420 + * initialize the cwd for server,
  421 + * because we may change the workdir.
  422 + */
  423 + virtual int initialize_cwd();
  424 + /**
420 * persistence current config to file. 425 * persistence current config to file.
421 */ 426 */
422 virtual int persistence(); 427 virtual int persistence();
@@ -607,6 +612,11 @@ public: @@ -607,6 +612,11 @@ public:
607 * whether use utc-time to format the time. 612 * whether use utc-time to format the time.
608 */ 613 */
609 virtual bool get_utc_time(); 614 virtual bool get_utc_time();
  615 + /**
  616 + * get the configed work dir.
  617 + * ignore if empty string.
  618 + */
  619 + virtual std::string get_work_dir();
610 // stream_caster section 620 // stream_caster section
611 public: 621 public:
612 /** 622 /**
  1 +/*
  2 + The MIT License (MIT)
  3 +
  4 + Copyright (c) 2013-2016 SRS(ossrs)
  5 +
  6 + Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 + this software and associated documentation files (the "Software"), to deal in
  8 + the Software without restriction, including without limitation the rights to
  9 + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 + the Software, and to permit persons to whom the Software is furnished to do so,
  11 + subject to the following conditions:
  12 +
  13 + The above copyright notice and this permission notice shall be included in all
  14 + copies or substantial portions of the Software.
  15 +
  16 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 + */
  23 +
  24 +#include <srs_app_hourglass.hpp>
  25 +
  26 +using namespace std;
  27 +
  28 +#include <srs_kernel_error.hpp>
  29 +#include <srs_app_st.hpp>
  30 +#include <srs_kernel_log.hpp>
  31 +
  32 +ISrsHourGlass::ISrsHourGlass()
  33 +{
  34 +}
  35 +
  36 +ISrsHourGlass::~ISrsHourGlass()
  37 +{
  38 +}
  39 +
  40 +SrsHourGlass::SrsHourGlass(ISrsHourGlass* h, int resolution_ms)
  41 +{
  42 + handler = h;
  43 + resolution = resolution_ms;
  44 + total_elapse = 0;
  45 +}
  46 +
  47 +SrsHourGlass::~SrsHourGlass()
  48 +{
  49 +}
  50 +
  51 +int SrsHourGlass::tick(int type, int interval)
  52 +{
  53 + int ret = ERROR_SUCCESS;
  54 +
  55 + if (resolution > 0 && (interval % resolution) != 0) {
  56 + ret = ERROR_SYSTEM_HOURGLASS_RESOLUTION;
  57 + srs_error("hourglass interval=%d invalid, resolution=%d. ret=%d", interval, resolution, ret);
  58 + return ret;
  59 + }
  60 +
  61 + ticks[type] = interval;
  62 +
  63 + return ret;
  64 +}
  65 +
  66 +int SrsHourGlass::cycle()
  67 +{
  68 + int ret = ERROR_SUCCESS;
  69 +
  70 + map<int, int>::iterator it;
  71 + for (it = ticks.begin(); it != ticks.end(); ++it) {
  72 + int type = it->first;
  73 + int interval = it->second;
  74 +
  75 + if (interval == 0 || (total_elapse % interval) == 0) {
  76 + if ((ret = handler->notify(type, interval, total_elapse)) != ERROR_SUCCESS) {
  77 + return ret;
  78 + }
  79 + }
  80 + }
  81 +
  82 + total_elapse += resolution;
  83 + st_usleep(resolution * 1000);
  84 +
  85 + return ret;
  86 +}
  1 +/*
  2 + The MIT License (MIT)
  3 +
  4 + Copyright (c) 2013-2016 SRS(ossrs)
  5 +
  6 + Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 + this software and associated documentation files (the "Software"), to deal in
  8 + the Software without restriction, including without limitation the rights to
  9 + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 + the Software, and to permit persons to whom the Software is furnished to do so,
  11 + subject to the following conditions:
  12 +
  13 + The above copyright notice and this permission notice shall be included in all
  14 + copies or substantial portions of the Software.
  15 +
  16 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 + */
  23 +
  24 +#ifndef SRS_APP_HOURGLASS_HPP
  25 +#define SRS_APP_HOURGLASS_HPP
  26 +
  27 +/*
  28 +#include <srs_app_hourglass.hpp>
  29 +*/
  30 +
  31 +#include <srs_core.hpp>
  32 +
  33 +#include <map>
  34 +
  35 +/**
  36 + * the handler for the tick.
  37 + */
  38 +class ISrsHourGlass
  39 +{
  40 +public:
  41 + ISrsHourGlass();
  42 + virtual ~ISrsHourGlass();
  43 +public:
  44 + /**
  45 + * notify the handler, the type and tick.
  46 + */
  47 + virtual int notify(int type, int interval, int64_t tick) = 0;
  48 +};
  49 +
  50 +/**
  51 + * the hourglass used to do some specieal task,
  52 + * while these task is cycle when some interval, for example,
  53 + * there are N=3 tasks to do:
  54 + * 1. heartbeat every 3s.
  55 + * 2. print message every 5s.
  56 + * 3. notify backend every 7s.
  57 + * the hourglass will call back when ticks:
  58 + * 1. notify(type=1, time=3)
  59 + * 2. notify(type=2, time=5)
  60 + * 3. notify(type=1, time=6)
  61 + * 4. notify(type=3, time=7)
  62 + * 5. notify(type=1, time=9)
  63 + * 6. notify(type=2, time=10)
  64 + * this is used for server and bocar server and other manager.
  65 + *
  66 + * Usage:
  67 + * SrsHourGlass* hg = new SrsHourGlass(handler, 1000);
  68 + * hg->tick(1, 3000);
  69 + * hg->tick(2, 5000);
  70 + * hg->tick(3, 7000);
  71 + * // create a thread to cycle, which will call handerl when ticked.
  72 + * while (true) {
  73 + * hg->cycle();
  74 + * }
  75 + */
  76 +class SrsHourGlass
  77 +{
  78 +private:
  79 + ISrsHourGlass* handler;
  80 + int resolution;
  81 + // key: the type of tick.
  82 + // value: the interval of tick.
  83 + std::map<int, int> ticks;
  84 + // the total elapsed time,
  85 + // for each cycle, we increase it with a resolution.
  86 + int64_t total_elapse;
  87 +public:
  88 + SrsHourGlass(ISrsHourGlass* h, int resolution_ms);
  89 + virtual ~SrsHourGlass();
  90 +public:
  91 + // add a pair of tick(type, interval).
  92 + // @param type the type of tick.
  93 + // @param interval the interval in ms of tick.
  94 + virtual int tick(int type, int interval);
  95 +public:
  96 + // cycle the hourglass, which will sleep resolution every time.
  97 + // and call handler when ticked.
  98 + virtual int cycle();
  99 +};
  100 +
  101 +#endif
@@ -41,6 +41,9 @@ using namespace std; @@ -41,6 +41,9 @@ using namespace std;
41 #include <srs_kernel_log.hpp> 41 #include <srs_kernel_log.hpp>
42 #include <srs_app_config.hpp> 42 #include <srs_app_config.hpp>
43 #include <srs_app_utility.hpp> 43 #include <srs_app_utility.hpp>
  44 +#include <srs_kernel_utility.hpp>
  45 +#include <srs_protocol_utility.hpp>
  46 +#include <srs_app_utility.hpp>
44 47
45 SrsProcess::SrsProcess() 48 SrsProcess::SrsProcess()
46 { 49 {
@@ -53,6 +56,11 @@ SrsProcess::~SrsProcess() @@ -53,6 +56,11 @@ SrsProcess::~SrsProcess()
53 { 56 {
54 } 57 }
55 58
  59 +int SrsProcess::get_pid()
  60 +{
  61 + return pid;
  62 +}
  63 +
56 bool SrsProcess::started() 64 bool SrsProcess::started()
57 { 65 {
58 return is_started; 66 return is_started;
@@ -64,39 +72,66 @@ int SrsProcess::initialize(string binary, vector<string> argv) @@ -64,39 +72,66 @@ int SrsProcess::initialize(string binary, vector<string> argv)
64 72
65 bin = binary; 73 bin = binary;
66 cli = ""; 74 cli = "";
  75 + actual_cli = "";
67 params.clear(); 76 params.clear();
68 77
69 for (int i = 0; i < (int)argv.size(); i++) { 78 for (int i = 0; i < (int)argv.size(); i++) {
70 std::string ffp = argv[i]; 79 std::string ffp = argv[i];
71 - cli += ffp;  
72 - if (i < (int)argv.size() - 1) {  
73 - cli += " "; 80 + std::string nffp = (i < (int)argv.size() - 1)? argv[i + 1] : "";
  81 + std::string nnffp = (i < (int)argv.size() - 2)? argv[i + 2] : "";
  82 +
  83 + // 1>file
  84 + if (srs_string_starts_with(ffp, "1>")) {
  85 + stdout_file = ffp.substr(2);
  86 + continue;
  87 + }
  88 +
  89 + // 2>file
  90 + if (srs_string_starts_with(ffp, "2>")) {
  91 + stderr_file = ffp.substr(2);
  92 + continue;
74 } 93 }
75 - }  
76 -  
77 - for (int i = 0; i < (int)argv.size(); i++) {  
78 - std::string ffp = argv[i];  
79 - std::string nffp = (i < (int)argv.size() -1)? argv[i + 1] : "";  
80 94
81 - // remove the stdout and stderr.  
82 - if (ffp == "1" && nffp == ">") {  
83 - if (i + 2 < (int)argv.size()) {  
84 - stdout_file = argv[i + 2];  
85 - i += 2; 95 + // 1 >X
  96 + if (ffp == "1" && srs_string_starts_with(nffp, ">")) {
  97 + if (nffp == ">") {
  98 + // 1 > file
  99 + if (!nnffp.empty()) {
  100 + stderr_file = nnffp;
  101 + i++;
  102 + }
  103 + } else {
  104 + // 1 >file
  105 + stdout_file = srs_string_trim_start(nffp, ">");
86 } 106 }
  107 + // skip the >
  108 + i++;
87 continue; 109 continue;
88 - } else if (ffp == "2" && nffp == ">") {  
89 - if (i + 2 < (int)argv.size()) {  
90 - stderr_file = argv[i + 2];  
91 - i += 2; 110 + }
  111 +
  112 + // 2 >X
  113 + if (ffp == "2" && srs_string_starts_with(nffp, ">")) {
  114 + if (nffp == ">") {
  115 + // 2 > file
  116 + if (!nnffp.empty()) {
  117 + stderr_file = nnffp;
  118 + i++;
  119 + }
  120 + } else {
  121 + // 2 >file
  122 + stderr_file = srs_string_trim_start(nffp, ">");
92 } 123 }
  124 + // skip the >
  125 + i++;
93 continue; 126 continue;
94 } 127 }
95 128
96 - // startup params.  
97 params.push_back(ffp); 129 params.push_back(ffp);
98 } 130 }
99 131
  132 + actual_cli = srs_join_vector_string(params, " ");
  133 + cli = srs_join_vector_string(argv, " ");
  134 +
100 return ret; 135 return ret;
101 } 136 }
102 137
@@ -109,7 +144,7 @@ int SrsProcess::start() @@ -109,7 +144,7 @@ int SrsProcess::start()
109 } 144 }
110 145
111 // generate the argv of process. 146 // generate the argv of process.
112 - srs_trace("fork process: %s", cli.c_str()); 147 + srs_info("fork process: %s", cli.c_str());
113 148
114 // for log 149 // for log
115 int cid = _srs_context->get_id(); 150 int cid = _srs_context->get_id();
@@ -118,11 +153,12 @@ int SrsProcess::start() @@ -118,11 +153,12 @@ int SrsProcess::start()
118 // TODO: fork or vfork? 153 // TODO: fork or vfork?
119 if ((pid = fork()) < 0) { 154 if ((pid = fork()) < 0) {
120 ret = ERROR_ENCODER_FORK; 155 ret = ERROR_ENCODER_FORK;
121 - srs_error("vfork process failed. ret=%d", ret); 156 + srs_error("vfork process failed, cli=%s. ret=%d", cli.c_str(), ret);
122 return ret; 157 return ret;
123 } 158 }
124 159
125 // for osx(lldb) to debug the child process. 160 // for osx(lldb) to debug the child process.
  161 + // user can use "lldb -p <pid>" to resume the parent or child process.
126 //kill(0, SIGSTOP); 162 //kill(0, SIGSTOP);
127 163
128 // child process: ffmpeg encoder engine. 164 // child process: ffmpeg encoder engine.
@@ -176,6 +212,7 @@ int SrsProcess::start() @@ -176,6 +212,7 @@ int SrsProcess::start()
176 fprintf(stderr, "process parent cid=%d\n", cid); 212 fprintf(stderr, "process parent cid=%d\n", cid);
177 fprintf(stderr, "process binary=%s\n", bin.c_str()); 213 fprintf(stderr, "process binary=%s\n", bin.c_str());
178 fprintf(stderr, "process cli: %s\n", cli.c_str()); 214 fprintf(stderr, "process cli: %s\n", cli.c_str());
  215 + fprintf(stderr, "process actual cli: %s\n", actual_cli.c_str());
179 } 216 }
180 217
181 // close other fds 218 // close other fds
@@ -204,7 +241,8 @@ int SrsProcess::start() @@ -204,7 +241,8 @@ int SrsProcess::start()
204 // parent. 241 // parent.
205 if (pid > 0) { 242 if (pid > 0) {
206 is_started = true; 243 is_started = true;
207 - srs_trace("vfored process, pid=%d, bin=%s", pid, bin.c_str()); 244 + srs_trace("fored process, pid=%d, bin=%s, stdout=%s, stderr=%s, argv=%s",
  245 + pid, bin.c_str(), stdout_file.c_str(), stdout_file.c_str(), actual_cli.c_str());
208 return ret; 246 return ret;
209 } 247 }
210 248
@@ -238,7 +276,7 @@ int SrsProcess::cycle() @@ -238,7 +276,7 @@ int SrsProcess::cycle()
238 return ret; 276 return ret;
239 } 277 }
240 278
241 - srs_trace("process pid=%d terminate, restart it.", pid); 279 + srs_trace("process pid=%d terminate, please restart it.", pid);
242 is_started = false; 280 is_started = false;
243 281
244 return ret; 282 return ret;
@@ -61,11 +61,16 @@ private: @@ -61,11 +61,16 @@ private:
61 std::vector<std::string> params; 61 std::vector<std::string> params;
62 // the cli to fork process. 62 // the cli to fork process.
63 std::string cli; 63 std::string cli;
  64 + std::string actual_cli;
64 public: 65 public:
65 SrsProcess(); 66 SrsProcess();
66 virtual ~SrsProcess(); 67 virtual ~SrsProcess();
67 public: 68 public:
68 /** 69 /**
  70 + * get pid of process.
  71 + */
  72 + virtual int get_pid();
  73 + /**
69 * whether process is already started. 74 * whether process is already started.
70 */ 75 */
71 virtual bool started(); 76 virtual bool started();
@@ -73,6 +78,7 @@ public: @@ -73,6 +78,7 @@ public:
73 * initialize the process with binary and argv. 78 * initialize the process with binary and argv.
74 * @param binary the binary path to exec. 79 * @param binary the binary path to exec.
75 * @param argv the argv for binary path, the argv[0] generally is the binary. 80 * @param argv the argv for binary path, the argv[0] generally is the binary.
  81 + * @remark the argv[0] must be the binary.
76 */ 82 */
77 virtual int initialize(std::string binary, std::vector<std::string> argv); 83 virtual int initialize(std::string binary, std::vector<std::string> argv);
78 public: 84 public:
@@ -959,6 +959,7 @@ int SrsServer::do_cycle() @@ -959,6 +959,7 @@ int SrsServer::do_cycle()
959 #endif 959 #endif
960 960
961 // the deamon thread, update the time cache 961 // the deamon thread, update the time cache
  962 + // TODO: FIXME: use SrsHourGlass.
962 while (true) { 963 while (true) {
963 if (handler && (ret = handler->on_cycle()) != ERROR_SUCCESS) { 964 if (handler && (ret = handler->on_cycle()) != ERROR_SUCCESS) {
964 srs_error("cycle handle failed. ret=%d", ret); 965 srs_error("cycle handle failed. ret=%d", ret);
@@ -1270,6 +1270,66 @@ vector<string>& srs_get_local_ipv4_ips() @@ -1270,6 +1270,66 @@ vector<string>& srs_get_local_ipv4_ips()
1270 return _srs_system_ipv4_ips; 1270 return _srs_system_ipv4_ips;
1271 } 1271 }
1272 1272
  1273 +std::string _public_internet_address;
  1274 +
  1275 +string srs_get_public_internet_address()
  1276 +{
  1277 + if (!_public_internet_address.empty()) {
  1278 + return _public_internet_address;
  1279 + }
  1280 +
  1281 + std::vector<std::string>& ips = srs_get_local_ipv4_ips();
  1282 +
  1283 + // find the best match public address.
  1284 + for (int i = 0; i < (int)ips.size(); i++) {
  1285 + std::string ip = ips[i];
  1286 + in_addr_t addr = inet_addr(ip.c_str());
  1287 + u_int32_t addr_h = ntohl(addr);
  1288 + // lo, 127.0.0.0-127.0.0.1
  1289 + if (addr_h >= 0x7f000000 && addr_h <= 0x7f000001) {
  1290 + srs_trace("ignore private address: %s", ip.c_str());
  1291 + continue;
  1292 + }
  1293 + // Class A 10.0.0.0-10.255.255.255
  1294 + if (addr_h >= 0x0a000000 && addr_h <= 0x0affffff) {
  1295 + srs_trace("ignore private address: %s", ip.c_str());
  1296 + continue;
  1297 + }
  1298 + // Class B 172.16.0.0-172.31.255.255
  1299 + if (addr_h >= 0xac100000 && addr_h <= 0xac1fffff) {
  1300 + srs_trace("ignore private address: %s", ip.c_str());
  1301 + continue;
  1302 + }
  1303 + // Class C 192.168.0.0-192.168.255.255
  1304 + if (addr_h >= 0xc0a80000 && addr_h <= 0xc0a8ffff) {
  1305 + srs_trace("ignore private address: %s", ip.c_str());
  1306 + continue;
  1307 + }
  1308 + srs_warn("use public address as ip: %s", ip.c_str());
  1309 +
  1310 + _public_internet_address = ip;
  1311 + return ip;
  1312 + }
  1313 +
  1314 + // no public address, use private address.
  1315 + for (int i = 0; i < (int)ips.size(); i++) {
  1316 + std::string ip = ips[i];
  1317 + in_addr_t addr = inet_addr(ip.c_str());
  1318 + u_int32_t addr_h = ntohl(addr);
  1319 + // lo, 127.0.0.0-127.0.0.1
  1320 + if (addr_h >= 0x7f000000 && addr_h <= 0x7f000001) {
  1321 + srs_trace("ignore private address: %s", ip.c_str());
  1322 + continue;
  1323 + }
  1324 + srs_warn("use private address as ip: %s", ip.c_str());
  1325 +
  1326 + _public_internet_address = ip;
  1327 + return ip;
  1328 + }
  1329 +
  1330 + return "";
  1331 +}
  1332 +
1273 string srs_get_local_ip(int fd) 1333 string srs_get_local_ip(int fd)
1274 { 1334 {
1275 std::string ip; 1335 std::string ip;
@@ -1347,6 +1407,11 @@ bool srs_string_is_http(string url) @@ -1347,6 +1407,11 @@ bool srs_string_is_http(string url)
1347 return srs_string_starts_with(url, "http://", "https://"); 1407 return srs_string_starts_with(url, "http://", "https://");
1348 } 1408 }
1349 1409
  1410 +bool srs_string_is_rtmp(string url)
  1411 +{
  1412 + return srs_string_starts_with(url, "rtmp://");
  1413 +}
  1414 +
1350 bool srs_is_digit_number(const string& str) 1415 bool srs_is_digit_number(const string& str)
1351 { 1416 {
1352 if (str.empty()) { 1417 if (str.empty()) {
@@ -664,6 +664,7 @@ extern std::string srs_get_peer_ip(int fd); @@ -664,6 +664,7 @@ extern std::string srs_get_peer_ip(int fd);
664 664
665 // whether the url is starts with http:// or https:// 665 // whether the url is starts with http:// or https://
666 extern bool srs_string_is_http(std::string url); 666 extern bool srs_string_is_http(std::string url);
  667 +extern bool srs_string_is_rtmp(std::string url);
667 668
668 // whether string is digit number 669 // whether string is digit number
669 // is_digit("1234567890") === true 670 // is_digit("1234567890") === true
@@ -45,12 +45,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -45,12 +45,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45 #define RTMP_SIG_SRS_EMAIL "winlin@vip.126.com" 45 #define RTMP_SIG_SRS_EMAIL "winlin@vip.126.com"
46 // debug info. 46 // debug info.
47 #define RTMP_SIG_SRS_ROLE "cluster" 47 #define RTMP_SIG_SRS_ROLE "cluster"
48 -#define RTMP_SIG_SRS_NAME RTMP_SIG_SRS_KEY"(Simple RTMP Server)" 48 +#define RTMP_SIG_SRS_NAME RTMP_SIG_SRS_KEY"(Stream Media Server)"
49 #define RTMP_SIG_SRS_URL_SHORT "github.com/ossrs/srs" 49 #define RTMP_SIG_SRS_URL_SHORT "github.com/ossrs/srs"
50 #define RTMP_SIG_SRS_URL "https://"RTMP_SIG_SRS_URL_SHORT 50 #define RTMP_SIG_SRS_URL "https://"RTMP_SIG_SRS_URL_SHORT
51 #define RTMP_SIG_SRS_LICENSE "The MIT License (MIT)" 51 #define RTMP_SIG_SRS_LICENSE "The MIT License (MIT)"
52 -#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013-2016 SRS(ossrs)"  
53 -#define RTMP_SIG_SRS_PRIMARY "SRS/"VERSION_STABLE_BRANCH 52 +#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013-2016 "RTMP_SIG_SRS_KEY"("RTMP_SIG_SRS_AUTHROS")"
  53 +#define RTMP_SIG_SRS_PRIMARY RTMP_SIG_SRS_KEY"/"VERSION_STABLE_BRANCH
54 #define RTMP_SIG_SRS_CONTRIBUTORS_URL RTMP_SIG_SRS_URL"/blob/master/AUTHORS.txt" 54 #define RTMP_SIG_SRS_CONTRIBUTORS_URL RTMP_SIG_SRS_URL"/blob/master/AUTHORS.txt"
55 #define RTMP_SIG_SRS_HANDSHAKE RTMP_SIG_SRS_KEY"("RTMP_SIG_SRS_VERSION")" 55 #define RTMP_SIG_SRS_HANDSHAKE RTMP_SIG_SRS_KEY"("RTMP_SIG_SRS_VERSION")"
56 #define RTMP_SIG_SRS_RELEASE RTMP_SIG_SRS_URL"/tree/"VERSION_STABLE_BRANCH".0release" 56 #define RTMP_SIG_SRS_RELEASE RTMP_SIG_SRS_URL"/tree/"VERSION_STABLE_BRANCH".0release"
@@ -188,5 +188,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -188,5 +188,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
188 #undef SRS_PERF_FAST_FLV_ENCODER 188 #undef SRS_PERF_FAST_FLV_ENCODER
189 #define SRS_PERF_FAST_FLV_ENCODER 189 #define SRS_PERF_FAST_FLV_ENCODER
190 190
  191 +/**
  192 + * whether ensure glibc memory check.
  193 + */
  194 +#undef SRS_PERF_GLIBC_MEMORY_CHECK
  195 +#define SRS_PERF_GLIBC_MEMORY_CHECK
  196 +
191 #endif 197 #endif
192 198
@@ -103,6 +103,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -103,6 +103,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
103 #define ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED 1062 103 #define ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED 1062
104 #define ERROR_SYSTEM_CONFIG_RAW_PARAMS 1063 104 #define ERROR_SYSTEM_CONFIG_RAW_PARAMS 1063
105 #define ERROR_SYSTEM_FILE_NOT_EXISTS 1064 105 #define ERROR_SYSTEM_FILE_NOT_EXISTS 1064
  106 +#define ERROR_SYSTEM_HOURGLASS_RESOLUTION 1065
106 107
107 /////////////////////////////////////////////////////// 108 ///////////////////////////////////////////////////////
108 // RTMP protocol error. 109 // RTMP protocol error.
@@ -467,6 +467,8 @@ int srs_librtmp_context_parse_uri(Context* context) @@ -467,6 +467,8 @@ int srs_librtmp_context_parse_uri(Context* context)
467 std::string schema; 467 std::string schema;
468 468
469 srs_parse_rtmp_url(context->url, context->tcUrl, context->stream); 469 srs_parse_rtmp_url(context->url, context->tcUrl, context->stream);
  470 +
  471 + // when connect, we only need to parse the tcUrl
470 srs_discovery_tc_url(context->tcUrl, 472 srs_discovery_tc_url(context->tcUrl,
471 schema, context->host, context->vhost, context->app, context->port, 473 schema, context->host, context->vhost, context->app, context->port,
472 context->param); 474 context->param);
@@ -688,11 +690,11 @@ int srs_rtmp_connect_app(srs_rtmp_t rtmp) @@ -688,11 +690,11 @@ int srs_rtmp_connect_app(srs_rtmp_t rtmp)
688 690
689 srs_assert(rtmp != NULL); 691 srs_assert(rtmp != NULL);
690 Context* context = (Context*)rtmp; 692 Context* context = (Context*)rtmp;
691 - 693 +
692 string tcUrl = srs_generate_tc_url( 694 string tcUrl = srs_generate_tc_url(
693 - context->ip, context->vhost, context->app, context->port,  
694 - context->param  
695 - ); 695 + context->ip, context->vhost, context->app, context->port,
  696 + context->param
  697 + );
696 698
697 if ((ret = context->rtmp->connect_app( 699 if ((ret = context->rtmp->connect_app(
698 context->app, tcUrl, context->req, true)) != ERROR_SUCCESS) 700 context->app, tcUrl, context->req, true)) != ERROR_SUCCESS)
@@ -742,6 +744,38 @@ int srs_rtmp_connect_app2(srs_rtmp_t rtmp, @@ -742,6 +744,38 @@ int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
742 return ret; 744 return ret;
743 } 745 }
744 746
  747 +int srs_rtmp_connect_app3(srs_rtmp_t rtmp, enum srs_url_schema sus)
  748 +{
  749 + int ret = ERROR_SUCCESS;
  750 +
  751 + srs_assert(rtmp != NULL);
  752 + Context* context = (Context*)rtmp;
  753 +
  754 + string tcUrl;
  755 + switch(sus) {
  756 + case srs_url_schema_normal:
  757 + tcUrl=srs_generate_normal_tc_url(context->ip, context->vhost, context->app, context->port);
  758 + break;
  759 + case srs_url_schema_via:
  760 + tcUrl=srs_generate_via_tc_url(context->ip, context->vhost, context->app, context->port);
  761 + break;
  762 + case srs_url_schema_vis:
  763 + case srs_url_schema_vis2:
  764 + tcUrl=srs_generate_vis_tc_url(context->ip, context->vhost, context->app, context->port);
  765 + break;
  766 + default:
  767 + break;
  768 + }
  769 +
  770 + if ((ret = context->rtmp->connect_app(
  771 + context->app, tcUrl, context->req, true)) != ERROR_SUCCESS)
  772 + {
  773 + return ret;
  774 + }
  775 +
  776 + return ret;
  777 +}
  778 +
745 int srs_rtmp_play_stream(srs_rtmp_t rtmp) 779 int srs_rtmp_play_stream(srs_rtmp_t rtmp)
746 { 780 {
747 int ret = ERROR_SUCCESS; 781 int ret = ERROR_SUCCESS;
@@ -68,6 +68,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -68,6 +68,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
68 extern "C"{ 68 extern "C"{
69 #endif 69 #endif
70 70
  71 +/**
  72 +* the schema of url, now bravo support 4 kinds of url:
  73 +* srs_url_schema_normal: rtmp://vhost:port/app/stream
  74 +* srs_url_schema_via : rtmp://ip:port/vhost/app/stream
  75 +* srs_url_schema_vis : rtmp://ip:port/app/stream?vhost=xxx
  76 +* srs_url_schema_vis2 : rtmp://ip:port/app/stream?domain=xxx
  77 +*/
  78 +enum srs_url_schema{
  79 + srs_url_schema_normal = 0,
  80 + srs_url_schema_via,
  81 + srs_url_schema_vis,
  82 + srs_url_schema_vis2
  83 +};
  84 +
71 // typedefs 85 // typedefs
72 typedef int srs_bool; 86 typedef int srs_bool;
73 87
@@ -188,6 +202,16 @@ extern int srs_rtmp_connect_app2(srs_rtmp_t rtmp, @@ -188,6 +202,16 @@ extern int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
188 ); 202 );
189 203
190 /** 204 /**
  205 +* connect to rtmp vhost/app
  206 +* category: publish/play
  207 +* previous: handshake
  208 +* next: publish or play
  209 +*
  210 +* @return 0, success; otherswise, failed.
  211 +*/
  212 +extern int srs_rtmp_connect_app3(srs_rtmp_t rtmp, enum srs_url_schema sus);
  213 +
  214 +/**
191 * play a live/vod stream. 215 * play a live/vod stream.
192 * category: play 216 * category: play
193 * previous: connect-app 217 * previous: connect-app
@@ -261,7 +261,17 @@ int main(int argc, char** argv) @@ -261,7 +261,17 @@ int main(int argc, char** argv)
261 if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) { 261 if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) {
262 return ret; 262 return ret;
263 } 263 }
264 - 264 +
  265 + // change the work dir and set cwd.
  266 + string cwd = _srs_config->get_work_dir();
  267 + if (!cwd.empty() && (ret = chdir(cwd.c_str())) != ERROR_SUCCESS) {
  268 + srs_error("change cwd to %s failed. ret=%d", cwd.c_str(), ret);
  269 + return ret;
  270 + }
  271 + if ((ret = _srs_config->initialize_cwd()) != ERROR_SUCCESS) {
  272 + return ret;
  273 + }
  274 +
265 // config parsed, initialize log. 275 // config parsed, initialize log.
266 if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) { 276 if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) {
267 return ret; 277 return ret;
@@ -277,6 +287,24 @@ int main(int argc, char** argv) @@ -277,6 +287,24 @@ int main(int argc, char** argv)
277 #ifdef SRS_AUTO_EMBEDED_TOOL_CHAIN 287 #ifdef SRS_AUTO_EMBEDED_TOOL_CHAIN
278 srs_trace("crossbuild tool chain: "SRS_AUTO_EMBEDED_TOOL_CHAIN); 288 srs_trace("crossbuild tool chain: "SRS_AUTO_EMBEDED_TOOL_CHAIN);
279 #endif 289 #endif
  290 + srs_trace("cwd=%s, work_dir=%s", _srs_config->cwd().c_str(), cwd.c_str());
  291 +
  292 +#ifdef SRS_PERF_GLIBC_MEMORY_CHECK
  293 + // ensure glibc write error to stderr.
  294 + setenv("LIBC_FATAL_STDERR_", "1", 1);
  295 + // ensure glibc to do alloc check.
  296 + setenv("MALLOC_CHECK_", "1", 1);
  297 + srs_trace("env MALLOC_CHECK_=1 LIBC_FATAL_STDERR_=1");
  298 +#endif
  299 +
  300 +#ifdef SRS_AUTO_GPERF_MD
  301 + char* TCMALLOC_PAGE_FENCE = getenv("TCMALLOC_PAGE_FENCE");
  302 + if (!TCMALLOC_PAGE_FENCE || strcmp(TCMALLOC_PAGE_FENCE, "1")) {
  303 + srs_trace("gmd enabled without env TCMALLOC_PAGE_FENCE=1");
  304 + } else {
  305 + srs_trace("env TCMALLOC_PAGE_FENCE=1");
  306 + }
  307 +#endif
280 308
281 // we check the config when the log initialized. 309 // we check the config when the log initialized.
282 if ((ret = _srs_config->check_config()) != ERROR_SUCCESS) { 310 if ((ret = _srs_config->check_config()) != ERROR_SUCCESS) {
@@ -149,11 +149,28 @@ string srs_generate_tc_url(string ip, string vhost, string app, int port, string @@ -149,11 +149,28 @@ string srs_generate_tc_url(string ip, string vhost, string app, int port, string
149 149
150 tcUrl += "/"; 150 tcUrl += "/";
151 tcUrl += app; 151 tcUrl += app;
152 - tcUrl += param; 152 + if (!param.empty()) {
  153 + tcUrl += "?" + param;
  154 + }
153 155
154 return tcUrl; 156 return tcUrl;
155 } 157 }
156 158
  159 +string srs_generate_normal_tc_url(string ip, string vhost, string app, int port)
  160 +{
  161 + return "rtmp://" + vhost + ":" + srs_int2str(port) + "/" + app;
  162 +}
  163 +
  164 +string srs_generate_via_tc_url(string ip, string vhost, string app, int port)
  165 +{
  166 + return "rtmp://" + ip + ":" + srs_int2str(port) + "/" + vhost + "/" + app;
  167 +}
  168 +
  169 +string srs_generate_vis_tc_url(string ip, string vhost, string app, int port)
  170 +{
  171 + return "rtmp://" + ip + ":" + srs_int2str(port) + "/" + app;
  172 +}
  173 +
157 /** 174 /**
158 * compare the memory in bytes. 175 * compare the memory in bytes.
159 */ 176 */
@@ -179,18 +196,19 @@ bool srs_bytes_equals(void* pa, void* pb, int size) @@ -179,18 +196,19 @@ bool srs_bytes_equals(void* pa, void* pb, int size)
179 return true; 196 return true;
180 } 197 }
181 198
182 -int srs_do_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, int stream_id, SrsSharedPtrMessage** ppmsg) 199 +template<typename T>
  200 +int srs_do_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, int stream_id, T** ppmsg)
183 { 201 {
184 int ret = ERROR_SUCCESS; 202 int ret = ERROR_SUCCESS;
185 203
186 *ppmsg = NULL; 204 *ppmsg = NULL;
187 - SrsSharedPtrMessage* msg = NULL; 205 + T* msg = NULL;
188 206
189 if (type == SrsCodecFlvTagAudio) { 207 if (type == SrsCodecFlvTagAudio) {
190 SrsMessageHeader header; 208 SrsMessageHeader header;
191 header.initialize_audio(size, timestamp, stream_id); 209 header.initialize_audio(size, timestamp, stream_id);
192 210
193 - msg = new SrsSharedPtrMessage(); 211 + msg = new T();
194 if ((ret = msg->create(&header, data, size)) != ERROR_SUCCESS) { 212 if ((ret = msg->create(&header, data, size)) != ERROR_SUCCESS) {
195 srs_freep(msg); 213 srs_freep(msg);
196 return ret; 214 return ret;
@@ -199,7 +217,7 @@ int srs_do_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, @@ -199,7 +217,7 @@ int srs_do_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size,
199 SrsMessageHeader header; 217 SrsMessageHeader header;
200 header.initialize_video(size, timestamp, stream_id); 218 header.initialize_video(size, timestamp, stream_id);
201 219
202 - msg = new SrsSharedPtrMessage(); 220 + msg = new T();
203 if ((ret = msg->create(&header, data, size)) != ERROR_SUCCESS) { 221 if ((ret = msg->create(&header, data, size)) != ERROR_SUCCESS) {
204 srs_freep(msg); 222 srs_freep(msg);
205 return ret; 223 return ret;
@@ -208,7 +226,7 @@ int srs_do_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, @@ -208,7 +226,7 @@ int srs_do_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size,
208 SrsMessageHeader header; 226 SrsMessageHeader header;
209 header.initialize_amf0_script(size, stream_id); 227 header.initialize_amf0_script(size, stream_id);
210 228
211 - msg = new SrsSharedPtrMessage(); 229 + msg = new T();
212 if ((ret = msg->create(&header, data, size)) != ERROR_SUCCESS) { 230 if ((ret = msg->create(&header, data, size)) != ERROR_SUCCESS) {
213 srs_freep(msg); 231 srs_freep(msg);
214 return ret; 232 return ret;
@@ -237,6 +255,19 @@ int srs_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, in @@ -237,6 +255,19 @@ int srs_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, in
237 return ret; 255 return ret;
238 } 256 }
239 257
  258 +int srs_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, int stream_id, SrsCommonMessage** ppmsg)
  259 +{
  260 + int ret = ERROR_SUCCESS;
  261 +
  262 + // only when failed, we must free the data.
  263 + if ((ret = srs_do_rtmp_create_msg(type, timestamp, data, size, stream_id, ppmsg)) != ERROR_SUCCESS) {
  264 + srs_freepa(data);
  265 + return ret;
  266 + }
  267 +
  268 + return ret;
  269 +}
  270 +
240 string srs_generate_stream_url(string vhost, string app, string stream) 271 string srs_generate_stream_url(string vhost, string app, string stream)
241 { 272 {
242 std::string url = ""; 273 std::string url = "";
@@ -334,3 +365,20 @@ string srs_join_vector_string(vector<string>& vs, string separator) @@ -334,3 +365,20 @@ string srs_join_vector_string(vector<string>& vs, string separator)
334 return str; 365 return str;
335 } 366 }
336 367
  368 +bool srs_is_ipv4(string domain)
  369 +{
  370 + for (int i = 0; i < (int)domain.length(); i++) {
  371 + char ch = domain.at(i);
  372 + if (ch == '.') {
  373 + continue;
  374 + }
  375 + if (ch >= '0' && ch <= '9') {
  376 + continue;
  377 + }
  378 +
  379 + return false;
  380 + }
  381 +
  382 + return true;
  383 +}
  384 +
@@ -36,11 +36,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -36,11 +36,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 36
37 #include <string> 37 #include <string>
38 #include <vector> 38 #include <vector>
  39 +#include <map>
39 40
40 #include <srs_kernel_consts.hpp> 41 #include <srs_kernel_consts.hpp>
41 42
42 class SrsMessageHeader; 43 class SrsMessageHeader;
43 class SrsSharedPtrMessage; 44 class SrsSharedPtrMessage;
  45 +class SrsCommonMessage;
44 class ISrsProtocolReaderWriter; 46 class ISrsProtocolReaderWriter;
45 47
46 /** 48 /**
@@ -62,6 +64,10 @@ extern void srs_discovery_tc_url( @@ -62,6 +64,10 @@ extern void srs_discovery_tc_url(
62 std::string& app, int& port, std::string& param 64 std::string& app, int& port, std::string& param
63 ); 65 );
64 66
  67 +// parse query string to map(k,v).
  68 +// must format as key=value&...&keyN=valueN
  69 +extern void srs_parse_query_string(std::string q, std::map<std::string, std::string>& query);
  70 +
65 /** 71 /**
66 * generate ramdom data for handshake. 72 * generate ramdom data for handshake.
67 */ 73 */
@@ -80,6 +86,24 @@ extern std::string srs_generate_tc_url( @@ -80,6 +86,24 @@ extern std::string srs_generate_tc_url(
80 ); 86 );
81 87
82 /** 88 /**
  89 + * srs_detect_tools generate the normal tcUrl
  90 + */
  91 +extern std::string srs_generate_normal_tc_url(
  92 + std::string ip, std::string vhost, std::string app, int port);
  93 +
  94 +/**
  95 + * srs_detect_tools generate the normal tcUrl
  96 + */
  97 +extern std::string srs_generate_via_tc_url(
  98 + std::string ip, std::string vhost, std::string app, int port);
  99 +
  100 +/**
  101 + * srs_detect_tools generate the vis/vis2 tcUrl
  102 + */
  103 +extern std::string srs_generate_vis_tc_url(
  104 + std::string ip, std::string vhost, std::string app, int port);
  105 +
  106 +/**
83 * compare the memory in bytes. 107 * compare the memory in bytes.
84 * @return true if completely equal; otherwise, false. 108 * @return true if completely equal; otherwise, false.
85 */ 109 */
@@ -94,6 +118,10 @@ extern int srs_rtmp_create_msg( @@ -94,6 +118,10 @@ extern int srs_rtmp_create_msg(
94 char type, u_int32_t timestamp, char* data, int size, int stream_id, 118 char type, u_int32_t timestamp, char* data, int size, int stream_id,
95 SrsSharedPtrMessage** ppmsg 119 SrsSharedPtrMessage** ppmsg
96 ); 120 );
  121 +extern int srs_rtmp_create_msg(
  122 + char type, u_int32_t timestamp, char* data, int size, int stream_id,
  123 + SrsCommonMessage** ppmsg
  124 +);
97 125
98 // get the stream identify, vhost/app/stream. 126 // get the stream identify, vhost/app/stream.
99 extern std::string srs_generate_stream_url( 127 extern std::string srs_generate_stream_url(