winlin

add comments for RTMP packets.

@@ -484,15 +484,21 @@ protected: @@ -484,15 +484,21 @@ protected:
484 class SrsConnectAppPacket : public SrsPacket 484 class SrsConnectAppPacket : public SrsPacket
485 { 485 {
486 public: 486 public:
  487 + /**
  488 + * Name of the command. Set to “connect”.
  489 + */
487 std::string command_name; 490 std::string command_name;
  491 + /**
  492 + * Always set to 1.
  493 + */
488 double transaction_id; 494 double transaction_id;
489 /** 495 /**
490 - * alloc in packet constructor,  
491 - * so, directly use it, never alloc again. 496 + * Command information object which has the name-value pairs.
  497 + * @remark: alloc in packet constructor, user can directly use it,
  498 + * user should never alloc it again which will cause memory leak.
492 */ 499 */
493 SrsAmf0Object* command_object; 500 SrsAmf0Object* command_object;
494 /** 501 /**
495 - * Object  
496 * Any optional information 502 * Any optional information
497 */ 503 */
498 SrsAmf0Object* args; 504 SrsAmf0Object* args;
@@ -516,9 +522,22 @@ protected: @@ -516,9 +522,22 @@ protected:
516 class SrsConnectAppResPacket : public SrsPacket 522 class SrsConnectAppResPacket : public SrsPacket
517 { 523 {
518 public: 524 public:
  525 + /**
  526 + * _result or _error; indicates whether the response is result or error.
  527 + */
519 std::string command_name; 528 std::string command_name;
  529 + /**
  530 + * Transaction ID is 1 for call connect responses
  531 + */
520 double transaction_id; 532 double transaction_id;
  533 + /**
  534 + * Name-value pairs that describe the properties(fmsver etc.) of the connection.
  535 + */
521 SrsAmf0Object* props; 536 SrsAmf0Object* props;
  537 + /**
  538 + * Name-value pairs that describe the response from|the server. ‘code’,
  539 + * ‘level’, ‘description’ are names of few among such information.
  540 + */
522 SrsAmf0Object* info; 541 SrsAmf0Object* info;
523 public: 542 public:
524 SrsConnectAppResPacket(); 543 SrsConnectAppResPacket();
@@ -544,14 +563,22 @@ protected: @@ -544,14 +563,22 @@ protected:
544 class SrsCallPacket : public SrsPacket 563 class SrsCallPacket : public SrsPacket
545 { 564 {
546 public: 565 public:
  566 + /**
  567 + * Name of the remote procedure that is called.
  568 + */
547 std::string command_name; 569 std::string command_name;
  570 + /**
  571 + * If a response is expected we give a transaction Id. Else we pass a value of 0
  572 + */
548 double transaction_id; 573 double transaction_id;
549 /** 574 /**
550 * If there exists any command info this 575 * If there exists any command info this
551 * is set, else this is set to null type. 576 * is set, else this is set to null type.
552 */ 577 */
553 SrsAmf0Any* command_object; 578 SrsAmf0Any* command_object;
554 - // Any optional arguments to be provided 579 + /**
  580 + * Any optional arguments to be provided
  581 + */
555 SrsAmf0Any* arguments; 582 SrsAmf0Any* arguments;
556 public: 583 public:
557 SrsCallPacket(); 584 SrsCallPacket();
@@ -573,13 +600,21 @@ protected: @@ -573,13 +600,21 @@ protected:
573 class SrsCallResPacket : public SrsPacket 600 class SrsCallResPacket : public SrsPacket
574 { 601 {
575 public: 602 public:
  603 + /**
  604 + * Name of the command.
  605 + */
576 std::string command_name; 606 std::string command_name;
  607 + /**
  608 + * ID of the command, to which the response belongs to
  609 + */
577 double transaction_id; 610 double transaction_id;
578 - // If there exists any command info this  
579 - // is set, else this is set to null type. 611 + /**
  612 + * If there exists any command info this is set, else this is set to null type.
  613 + */
580 SrsAmf0Any* command_object; 614 SrsAmf0Any* command_object;
581 - // Response from the method that was  
582 - // called. 615 + /**
  616 + * Response from the method that was called.
  617 + */
583 SrsAmf0Any* response; 618 SrsAmf0Any* response;
584 public: 619 public:
585 SrsCallResPacket(double _transaction_id); 620 SrsCallResPacket(double _transaction_id);
@@ -603,8 +638,17 @@ protected: @@ -603,8 +638,17 @@ protected:
603 class SrsCreateStreamPacket : public SrsPacket 638 class SrsCreateStreamPacket : public SrsPacket
604 { 639 {
605 public: 640 public:
  641 + /**
  642 + * Name of the command. Set to “createStream”.
  643 + */
606 std::string command_name; 644 std::string command_name;
  645 + /**
  646 + * Transaction ID of the command.
  647 + */
607 double transaction_id; 648 double transaction_id;
  649 + /**
  650 + * If there exists any command info this is set, else this is set to null type.
  651 + */
608 SrsAmf0Any* command_object; // null 652 SrsAmf0Any* command_object; // null
609 public: 653 public:
610 SrsCreateStreamPacket(); 654 SrsCreateStreamPacket();
@@ -626,9 +670,21 @@ protected: @@ -626,9 +670,21 @@ protected:
626 class SrsCreateStreamResPacket : public SrsPacket 670 class SrsCreateStreamResPacket : public SrsPacket
627 { 671 {
628 public: 672 public:
  673 + /**
  674 + * _result or _error; indicates whether the response is result or error.
  675 + */
629 std::string command_name; 676 std::string command_name;
  677 + /**
  678 + * ID of the command that response belongs to.
  679 + */
630 double transaction_id; 680 double transaction_id;
  681 + /**
  682 + * If there exists any command info this is set, else this is set to null type.
  683 + */
631 SrsAmf0Any* command_object; // null 684 SrsAmf0Any* command_object; // null
  685 + /**
  686 + * The return value is either a stream ID or an error information object.
  687 + */
632 double stream_id; 688 double stream_id;
633 public: 689 public:
634 SrsCreateStreamResPacket(double _transaction_id, double _stream_id); 690 SrsCreateStreamResPacket(double _transaction_id, double _stream_id);
@@ -651,8 +707,17 @@ protected: @@ -651,8 +707,17 @@ protected:
651 class SrsCloseStreamPacket : public SrsPacket 707 class SrsCloseStreamPacket : public SrsPacket
652 { 708 {
653 public: 709 public:
  710 + /**
  711 + * Name of the command, set to “closeStream”.
  712 + */
654 std::string command_name; 713 std::string command_name;
  714 + /**
  715 + * Transaction ID set to 0.
  716 + */
655 double transaction_id; 717 double transaction_id;
  718 + /**
  719 + * Command information object does not exist. Set to null type.
  720 + */
656 SrsAmf0Any* command_object; // null 721 SrsAmf0Any* command_object; // null
657 public: 722 public:
658 SrsCloseStreamPacket(); 723 SrsCloseStreamPacket();
@@ -668,9 +733,21 @@ public: @@ -668,9 +733,21 @@ public:
668 class SrsFMLEStartPacket : public SrsPacket 733 class SrsFMLEStartPacket : public SrsPacket
669 { 734 {
670 public: 735 public:
  736 + /**
  737 + * Name of the command
  738 + */
671 std::string command_name; 739 std::string command_name;
  740 + /**
  741 + * the transaction ID to get the response.
  742 + */
672 double transaction_id; 743 double transaction_id;
  744 + /**
  745 + * If there exists any command info this is set, else this is set to null type.
  746 + */
673 SrsAmf0Any* command_object; // null 747 SrsAmf0Any* command_object; // null
  748 + /**
  749 + * the stream name to start publish or release.
  750 + */
674 std::string stream_name; 751 std::string stream_name;
675 public: 752 public:
676 SrsFMLEStartPacket(); 753 SrsFMLEStartPacket();
@@ -696,9 +773,21 @@ public: @@ -696,9 +773,21 @@ public:
696 class SrsFMLEStartResPacket : public SrsPacket 773 class SrsFMLEStartResPacket : public SrsPacket
697 { 774 {
698 public: 775 public:
  776 + /**
  777 + * Name of the command
  778 + */
699 std::string command_name; 779 std::string command_name;
  780 + /**
  781 + * the transaction ID to get the response.
  782 + */
700 double transaction_id; 783 double transaction_id;
  784 + /**
  785 + * If there exists any command info this is set, else this is set to null type.
  786 + */
701 SrsAmf0Any* command_object; // null 787 SrsAmf0Any* command_object; // null
  788 + /**
  789 + * the optional args, set to undefined.
  790 + */
702 SrsAmf0Any* args; // undefined 791 SrsAmf0Any* args; // undefined
703 public: 792 public:
704 SrsFMLEStartResPacket(double _transaction_id); 793 SrsFMLEStartResPacket(double _transaction_id);
@@ -725,11 +814,34 @@ protected: @@ -725,11 +814,34 @@ protected:
725 class SrsPublishPacket : public SrsPacket 814 class SrsPublishPacket : public SrsPacket
726 { 815 {
727 public: 816 public:
  817 + /**
  818 + * Name of the command, set to “publish”.
  819 + */
728 std::string command_name; 820 std::string command_name;
  821 + /**
  822 + * Transaction ID set to 0.
  823 + */
729 double transaction_id; 824 double transaction_id;
  825 + /**
  826 + * Command information object does not exist. Set to null type.
  827 + */
730 SrsAmf0Any* command_object; // null 828 SrsAmf0Any* command_object; // null
  829 + /**
  830 + * Name with which the stream is published.
  831 + */
731 std::string stream_name; 832 std::string stream_name;
732 - // optional, default to live. 833 + /**
  834 + * Type of publishing. Set to “live”, “record”, or “append”.
  835 + * record: The stream is published and the data is recorded to a new file.The file
  836 + * is stored on the server in a subdirectory within the directory that
  837 + * contains the server application. If the file already exists, it is
  838 + * overwritten.
  839 + * append: The stream is published and the data is appended to a file. If no file
  840 + * is found, it is created.
  841 + * live: Live data is published without recording it in a file.
  842 + * @remark, SRS only support live.
  843 + * @remark, optional, default to live.
  844 + */
733 std::string type; 845 std::string type;
734 public: 846 public:
735 SrsPublishPacket(); 847 SrsPublishPacket();
@@ -754,10 +866,28 @@ protected: @@ -754,10 +866,28 @@ protected:
754 class SrsPausePacket : public SrsPacket 866 class SrsPausePacket : public SrsPacket
755 { 867 {
756 public: 868 public:
  869 + /**
  870 + * Name of the command, set to “pause”.
  871 + */
757 std::string command_name; 872 std::string command_name;
  873 + /**
  874 + * There is no transaction ID for this command. Set to 0.
  875 + */
758 double transaction_id; 876 double transaction_id;
  877 + /**
  878 + * Command information object does not exist. Set to null type.
  879 + */
759 SrsAmf0Any* command_object; // null 880 SrsAmf0Any* command_object; // null
  881 + /**
  882 + * true or false, to indicate pausing or resuming play
  883 + */
760 bool is_pause; 884 bool is_pause;
  885 + /**
  886 + * Number of milliseconds at which the the stream is paused or play resumed.
  887 + * This is the current stream time at the Client when stream was paused. When the
  888 + * playback is resumed, the server will only send messages with timestamps
  889 + * greater than this value.
  890 + */
761 double time_ms; 891 double time_ms;
762 public: 892 public:
763 SrsPausePacket(); 893 SrsPausePacket();
@@ -774,12 +904,61 @@ public: @@ -774,12 +904,61 @@ public:
774 class SrsPlayPacket : public SrsPacket 904 class SrsPlayPacket : public SrsPacket
775 { 905 {
776 public: 906 public:
  907 + /**
  908 + * Name of the command. Set to “play”.
  909 + */
777 std::string command_name; 910 std::string command_name;
  911 + /**
  912 + * Transaction ID set to 0.
  913 + */
778 double transaction_id; 914 double transaction_id;
  915 + /**
  916 + * Command information does not exist. Set to null type.
  917 + */
779 SrsAmf0Any* command_object; // null 918 SrsAmf0Any* command_object; // null
  919 + /**
  920 + * Name of the stream to play.
  921 + * To play video (FLV) files, specify the name of the stream without a file
  922 + * extension (for example, "sample").
  923 + * To play back MP3 or ID3 tags, you must precede the stream name with mp3:
  924 + * (for example, "mp3:sample".)
  925 + * To play H.264/AAC files, you must precede the stream name with mp4: and specify the
  926 + * file extension. For example, to play the file sample.m4v, specify
  927 + * "mp4:sample.m4v"
  928 + */
780 std::string stream_name; 929 std::string stream_name;
  930 + /**
  931 + * An optional parameter that specifies the start time in seconds.
  932 + * The default value is -2, which means the subscriber first tries to play the live
  933 + * stream specified in the Stream Name field. If a live stream of that name is
  934 + * not found, it plays the recorded stream specified in the Stream Name field.
  935 + * If you pass -1 in the Start field, only the live stream specified in the Stream
  936 + * Name field is played.
  937 + * If you pass 0 or a positive number in the Start field, a recorded stream specified
  938 + * in the Stream Name field is played beginning from the time specified in the
  939 + * Start field.
  940 + * If no recorded stream is found, the next item in the playlist is played.
  941 + */
781 double start; 942 double start;
  943 + /**
  944 + * An optional parameter that specifies the duration of playback in seconds.
  945 + * The default value is -1. The -1 value means a live stream is played until it is no
  946 + * longer available or a recorded stream is played until it ends.
  947 + * If u pass 0, it plays the single frame since the time specified in the Start field
  948 + * from the beginning of a recorded stream. It is assumed that the value specified
  949 + * in the Start field is equal to or greater than 0.
  950 + * If you pass a positive number, it plays a live stream for the time period specified
  951 + * in the Duration field. After that it becomes available or plays a recorded
  952 + * stream for the time specified in the Duration field. (If a stream ends before the
  953 + * time specified in the Duration field, playback ends when the stream ends.)
  954 + * If you pass a negative number other than -1 in the Duration field, it interprets the
  955 + * value as if it were -1.
  956 + */
782 double duration; 957 double duration;
  958 + /**
  959 + * An optional Boolean value or number that specifies whether to flush any
  960 + * previous playlist.
  961 + */
783 bool reset; 962 bool reset;
784 public: 963 public:
785 SrsPlayPacket(); 964 SrsPlayPacket();
@@ -802,9 +981,24 @@ protected: @@ -802,9 +981,24 @@ protected:
802 class SrsPlayResPacket : public SrsPacket 981 class SrsPlayResPacket : public SrsPacket
803 { 982 {
804 public: 983 public:
  984 + /**
  985 + * Name of the command. If the play command is successful, the command
  986 + * name is set to onStatus.
  987 + */
805 std::string command_name; 988 std::string command_name;
  989 + /**
  990 + * Transaction ID set to 0.
  991 + */
806 double transaction_id; 992 double transaction_id;
  993 + /**
  994 + * Command information does not exist. Set to null type.
  995 + */
807 SrsAmf0Any* command_object; // null 996 SrsAmf0Any* command_object; // null
  997 + /**
  998 + * If the play command is successful, the client receives OnStatus message from
  999 + * server which is NetStream.Play.Start. If the specified stream is not found,
  1000 + * NetStream.Play.StreamNotFound is received.
  1001 + */
808 SrsAmf0Object* desc; 1002 SrsAmf0Object* desc;
809 public: 1003 public:
810 SrsPlayResPacket(); 1004 SrsPlayResPacket();
@@ -824,8 +1018,17 @@ protected: @@ -824,8 +1018,17 @@ protected:
824 class SrsOnBWDonePacket : public SrsPacket 1018 class SrsOnBWDonePacket : public SrsPacket
825 { 1019 {
826 public: 1020 public:
  1021 + /**
  1022 + * Name of command. Set to "onBWDone"
  1023 + */
827 std::string command_name; 1024 std::string command_name;
  1025 + /**
  1026 + * Transaction ID set to 0.
  1027 + */
828 double transaction_id; 1028 double transaction_id;
  1029 + /**
  1030 + * Command information does not exist. Set to null type.
  1031 + */
829 SrsAmf0Any* args; // null 1032 SrsAmf0Any* args; // null
830 public: 1033 public:
831 SrsOnBWDonePacket(); 1034 SrsOnBWDonePacket();
@@ -846,9 +1049,22 @@ protected: @@ -846,9 +1049,22 @@ protected:
846 class SrsOnStatusCallPacket : public SrsPacket 1049 class SrsOnStatusCallPacket : public SrsPacket
847 { 1050 {
848 public: 1051 public:
  1052 + /**
  1053 + * Name of command. Set to "onStatus"
  1054 + */
849 std::string command_name; 1055 std::string command_name;
  1056 + /**
  1057 + * Transaction ID set to 0.
  1058 + */
850 double transaction_id; 1059 double transaction_id;
  1060 + /**
  1061 + * Command information does not exist. Set to null type.
  1062 + */
851 SrsAmf0Any* args; // null 1063 SrsAmf0Any* args; // null
  1064 + /**
  1065 + * Name-value pairs that describe the response from the server.
  1066 + * ‘code’,‘level’, ‘description’ are names of few among such information.
  1067 + */
852 SrsAmf0Object* data; 1068 SrsAmf0Object* data;
853 public: 1069 public:
854 SrsOnStatusCallPacket(); 1070 SrsOnStatusCallPacket();
@@ -873,9 +1089,22 @@ class SrsBandwidthPacket : public SrsPacket @@ -873,9 +1089,22 @@ class SrsBandwidthPacket : public SrsPacket
873 private: 1089 private:
874 disable_default_copy(SrsBandwidthPacket); 1090 disable_default_copy(SrsBandwidthPacket);
875 public: 1091 public:
  1092 + /**
  1093 + * Name of command.
  1094 + */
876 std::string command_name; 1095 std::string command_name;
  1096 + /**
  1097 + * Transaction ID set to 0.
  1098 + */
877 double transaction_id; 1099 double transaction_id;
  1100 + /**
  1101 + * Command information does not exist. Set to null type.
  1102 + */
878 SrsAmf0Any* args; // null 1103 SrsAmf0Any* args; // null
  1104 + /**
  1105 + * Name-value pairs that describe the response from the server.
  1106 + * ‘code’,‘level’, ‘description’ are names of few among such information.
  1107 + */
879 SrsAmf0Object* data; 1108 SrsAmf0Object* data;
880 public: 1109 public:
881 SrsBandwidthPacket(); 1110 SrsBandwidthPacket();
@@ -914,7 +1143,14 @@ private: @@ -914,7 +1143,14 @@ private:
914 class SrsOnStatusDataPacket : public SrsPacket 1143 class SrsOnStatusDataPacket : public SrsPacket
915 { 1144 {
916 public: 1145 public:
  1146 + /**
  1147 + * Name of command. Set to "onStatus"
  1148 + */
917 std::string command_name; 1149 std::string command_name;
  1150 + /**
  1151 + * Name-value pairs that describe the response from the server.
  1152 + * ‘code’, are names of few among such information.
  1153 + */
918 SrsAmf0Object* data; 1154 SrsAmf0Object* data;
919 public: 1155 public:
920 SrsOnStatusDataPacket(); 1156 SrsOnStatusDataPacket();
@@ -935,8 +1171,17 @@ protected: @@ -935,8 +1171,17 @@ protected:
935 class SrsSampleAccessPacket : public SrsPacket 1171 class SrsSampleAccessPacket : public SrsPacket
936 { 1172 {
937 public: 1173 public:
  1174 + /**
  1175 + *
  1176 + */
938 std::string command_name; 1177 std::string command_name;
  1178 + /**
  1179 + *
  1180 + */
939 bool video_sample_access; 1181 bool video_sample_access;
  1182 + /**
  1183 + *
  1184 + */
940 bool audio_sample_access; 1185 bool audio_sample_access;
941 public: 1186 public:
942 SrsSampleAccessPacket(); 1187 SrsSampleAccessPacket();