winlin

rename SrsMessage to SrsCommonMessage

@@ -172,28 +172,28 @@ int SrsClient::streaming_play(SrsSource* source) @@ -172,28 +172,28 @@ int SrsClient::streaming_play(SrsSource* source)
172 172
173 // read from client. 173 // read from client.
174 if (ready) { 174 if (ready) {
175 - SrsMessage* msg = NULL; 175 + SrsCommonMessage* msg = NULL;
176 if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) { 176 if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) {
177 srs_error("recv client control message failed. ret=%d", ret); 177 srs_error("recv client control message failed. ret=%d", ret);
178 return ret; 178 return ret;
179 } 179 }
180 180
181 - SrsAutoFree(SrsMessage, msg, false); 181 + SrsAutoFree(SrsCommonMessage, msg, false);
182 // TODO: process it. 182 // TODO: process it.
183 } 183 }
184 184
185 // get messages from consumer. 185 // get messages from consumer.
186 - SrsMessage** msgs = NULL; 186 + SrsCommonMessage** msgs = NULL;
187 int count = 0; 187 int count = 0;
188 if ((ret = consumer->get_packets(0, msgs, count)) != ERROR_SUCCESS) { 188 if ((ret = consumer->get_packets(0, msgs, count)) != ERROR_SUCCESS) {
189 srs_error("get messages from consumer failed. ret=%d", ret); 189 srs_error("get messages from consumer failed. ret=%d", ret);
190 return ret; 190 return ret;
191 } 191 }
192 - SrsAutoFree(SrsMessage*, msgs, true); 192 + SrsAutoFree(SrsCommonMessage*, msgs, true);
193 193
194 // sendout messages 194 // sendout messages
195 for (int i = 0; i < count; i++) { 195 for (int i = 0; i < count; i++) {
196 - SrsMessage* msg = msgs[i]; 196 + SrsCommonMessage* msg = msgs[i];
197 if ((ret = rtmp->send_message(msg)) != ERROR_SUCCESS) { 197 if ((ret = rtmp->send_message(msg)) != ERROR_SUCCESS) {
198 srs_error("send message to client failed. ret=%d", ret); 198 srs_error("send message to client failed. ret=%d", ret);
199 return ret; 199 return ret;
@@ -209,13 +209,13 @@ int SrsClient::streaming_publish(SrsSource* source) @@ -209,13 +209,13 @@ int SrsClient::streaming_publish(SrsSource* source)
209 int ret = ERROR_SUCCESS; 209 int ret = ERROR_SUCCESS;
210 210
211 while (true) { 211 while (true) {
212 - SrsMessage* msg = NULL; 212 + SrsCommonMessage* msg = NULL;
213 if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) { 213 if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) {
214 srs_error("recv identify client message failed. ret=%d", ret); 214 srs_error("recv identify client message failed. ret=%d", ret);
215 return ret; 215 return ret;
216 } 216 }
217 217
218 - SrsAutoFree(SrsMessage, msg, false); 218 + SrsAutoFree(SrsCommonMessage, msg, false);
219 219
220 // process audio packet 220 // process audio packet
221 if (msg->header.is_audio() && ((ret = source->on_audio(msg)) != ERROR_SUCCESS)) { 221 if (msg->header.is_audio() && ((ret = source->on_audio(msg)) != ERROR_SUCCESS)) {
@@ -279,14 +279,14 @@ int SrsProtocol::can_read(int timeout_ms, bool& ready) @@ -279,14 +279,14 @@ int SrsProtocol::can_read(int timeout_ms, bool& ready)
279 return skt->can_read(timeout_ms, ready); 279 return skt->can_read(timeout_ms, ready);
280 } 280 }
281 281
282 -int SrsProtocol::recv_message(SrsMessage** pmsg) 282 +int SrsProtocol::recv_message(SrsCommonMessage** pmsg)
283 { 283 {
284 *pmsg = NULL; 284 *pmsg = NULL;
285 285
286 int ret = ERROR_SUCCESS; 286 int ret = ERROR_SUCCESS;
287 287
288 while (true) { 288 while (true) {
289 - SrsMessage* msg = NULL; 289 + SrsCommonMessage* msg = NULL;
290 290
291 if ((ret = recv_interlaced_message(&msg)) != ERROR_SUCCESS) { 291 if ((ret = recv_interlaced_message(&msg)) != ERROR_SUCCESS) {
292 srs_error("recv interlaced message failed. ret=%d", ret); 292 srs_error("recv interlaced message failed. ret=%d", ret);
@@ -440,7 +440,7 @@ int SrsProtocol::send_message(SrsOutputableMessage* msg) @@ -440,7 +440,7 @@ int SrsProtocol::send_message(SrsOutputableMessage* msg)
440 return ret; 440 return ret;
441 } 441 }
442 442
443 -int SrsProtocol::on_recv_message(SrsMessage* msg) 443 +int SrsProtocol::on_recv_message(SrsCommonMessage* msg)
444 { 444 {
445 int ret = ERROR_SUCCESS; 445 int ret = ERROR_SUCCESS;
446 446
@@ -483,7 +483,7 @@ int SrsProtocol::on_send_message(SrsOutputableMessage* msg) @@ -483,7 +483,7 @@ int SrsProtocol::on_send_message(SrsOutputableMessage* msg)
483 { 483 {
484 int ret = ERROR_SUCCESS; 484 int ret = ERROR_SUCCESS;
485 485
486 - SrsMessage* common_msg = dynamic_cast<SrsMessage*>(msg); 486 + SrsCommonMessage* common_msg = dynamic_cast<SrsCommonMessage*>(msg);
487 if (!msg) { 487 if (!msg) {
488 srs_verbose("ignore the shared ptr message."); 488 srs_verbose("ignore the shared ptr message.");
489 return ret; 489 return ret;
@@ -506,7 +506,7 @@ int SrsProtocol::on_send_message(SrsOutputableMessage* msg) @@ -506,7 +506,7 @@ int SrsProtocol::on_send_message(SrsOutputableMessage* msg)
506 return ret; 506 return ret;
507 } 507 }
508 508
509 -int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg) 509 +int SrsProtocol::recv_interlaced_message(SrsCommonMessage** pmsg)
510 { 510 {
511 int ret = ERROR_SUCCESS; 511 int ret = ERROR_SUCCESS;
512 512
@@ -545,7 +545,7 @@ int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg) @@ -545,7 +545,7 @@ int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg)
545 chunk->header.payload_length, chunk->header.timestamp, chunk->header.stream_id); 545 chunk->header.payload_length, chunk->header.timestamp, chunk->header.stream_id);
546 546
547 // read msg payload from chunk stream. 547 // read msg payload from chunk stream.
548 - SrsMessage* msg = NULL; 548 + SrsCommonMessage* msg = NULL;
549 int payload_size = 0; 549 int payload_size = 0;
550 if ((ret = read_message_payload(chunk, bh_size, mh_size, payload_size, &msg)) != ERROR_SUCCESS) { 550 if ((ret = read_message_payload(chunk, bh_size, mh_size, payload_size, &msg)) != ERROR_SUCCESS) {
551 srs_error("read message payload failed. ret=%d", ret); 551 srs_error("read message payload failed. ret=%d", ret);
@@ -668,7 +668,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz @@ -668,7 +668,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
668 668
669 // create msg when new chunk stream start 669 // create msg when new chunk stream start
670 if (!chunk->msg) { 670 if (!chunk->msg) {
671 - chunk->msg = new SrsMessage(); 671 + chunk->msg = new SrsCommonMessage();
672 srs_verbose("create message for new chunk, fmt=%d, cid=%d", fmt, chunk->cid); 672 srs_verbose("create message for new chunk, fmt=%d, cid=%d", fmt, chunk->cid);
673 } 673 }
674 674
@@ -794,7 +794,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz @@ -794,7 +794,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
794 return ret; 794 return ret;
795 } 795 }
796 796
797 -int SrsProtocol::read_message_payload(SrsChunkStream* chunk, int bh_size, int mh_size, int& payload_size, SrsMessage** pmsg) 797 +int SrsProtocol::read_message_payload(SrsChunkStream* chunk, int bh_size, int mh_size, int& payload_size, SrsCommonMessage** pmsg)
798 { 798 {
799 int ret = ERROR_SUCCESS; 799 int ret = ERROR_SUCCESS;
800 800
@@ -943,19 +943,19 @@ void SrsOutputableMessage::free_payload() @@ -943,19 +943,19 @@ void SrsOutputableMessage::free_payload()
943 srs_freepa(payload); 943 srs_freepa(payload);
944 } 944 }
945 945
946 -SrsMessage::SrsMessage() 946 +SrsCommonMessage::SrsCommonMessage()
947 { 947 {
948 stream = NULL; 948 stream = NULL;
949 packet = NULL; 949 packet = NULL;
950 } 950 }
951 951
952 -SrsMessage::~SrsMessage() 952 +SrsCommonMessage::~SrsCommonMessage()
953 { 953 {
954 srs_freep(packet); 954 srs_freep(packet);
955 srs_freep(stream); 955 srs_freep(stream);
956 } 956 }
957 957
958 -int SrsMessage::decode_packet() 958 +int SrsCommonMessage::decode_packet()
959 { 959 {
960 int ret = ERROR_SUCCESS; 960 int ret = ERROR_SUCCESS;
961 961
@@ -1061,7 +1061,7 @@ int SrsMessage::decode_packet() @@ -1061,7 +1061,7 @@ int SrsMessage::decode_packet()
1061 return ret; 1061 return ret;
1062 } 1062 }
1063 1063
1064 -SrsPacket* SrsMessage::get_packet() 1064 +SrsPacket* SrsCommonMessage::get_packet()
1065 { 1065 {
1066 if (!packet) { 1066 if (!packet) {
1067 srs_error("the payload is raw/undecoded, invoke decode_packet to decode it."); 1067 srs_error("the payload is raw/undecoded, invoke decode_packet to decode it.");
@@ -1071,7 +1071,7 @@ SrsPacket* SrsMessage::get_packet() @@ -1071,7 +1071,7 @@ SrsPacket* SrsMessage::get_packet()
1071 return packet; 1071 return packet;
1072 } 1072 }
1073 1073
1074 -int SrsMessage::get_perfer_cid() 1074 +int SrsCommonMessage::get_perfer_cid()
1075 { 1075 {
1076 if (!packet) { 1076 if (!packet) {
1077 return RTMP_CID_ProtocolControl; 1077 return RTMP_CID_ProtocolControl;
@@ -1086,7 +1086,7 @@ int SrsMessage::get_perfer_cid() @@ -1086,7 +1086,7 @@ int SrsMessage::get_perfer_cid()
1086 return packet->get_perfer_cid(); 1086 return packet->get_perfer_cid();
1087 } 1087 }
1088 1088
1089 -void SrsMessage::set_packet(SrsPacket* pkt, int stream_id) 1089 +void SrsCommonMessage::set_packet(SrsPacket* pkt, int stream_id)
1090 { 1090 {
1091 srs_freep(packet); 1091 srs_freep(packet);
1092 1092
@@ -1097,7 +1097,7 @@ void SrsMessage::set_packet(SrsPacket* pkt, int stream_id) @@ -1097,7 +1097,7 @@ void SrsMessage::set_packet(SrsPacket* pkt, int stream_id)
1097 header.stream_id = stream_id; 1097 header.stream_id = stream_id;
1098 } 1098 }
1099 1099
1100 -int SrsMessage::encode_packet() 1100 +int SrsCommonMessage::encode_packet()
1101 { 1101 {
1102 int ret = ERROR_SUCCESS; 1102 int ret = ERROR_SUCCESS;
1103 1103
@@ -42,7 +42,7 @@ class SrsSocket; @@ -42,7 +42,7 @@ class SrsSocket;
42 class SrsBuffer; 42 class SrsBuffer;
43 class SrsPacket; 43 class SrsPacket;
44 class SrsStream; 44 class SrsStream;
45 -class SrsMessage; 45 +class SrsCommonMessage;
46 class SrsChunkStream; 46 class SrsChunkStream;
47 class SrsAmf0Object; 47 class SrsAmf0Object;
48 class SrsAmf0Null; 48 class SrsAmf0Null;
@@ -105,7 +105,7 @@ public: @@ -105,7 +105,7 @@ public:
105 * @pmsg, user must free it. NULL if not success. 105 * @pmsg, user must free it. NULL if not success.
106 * @remark, only when success, user can use and must free the pmsg. 106 * @remark, only when success, user can use and must free the pmsg.
107 */ 107 */
108 - virtual int recv_message(SrsMessage** pmsg); 108 + virtual int recv_message(SrsCommonMessage** pmsg);
109 /** 109 /**
110 * send out message with encoded payload to peer. 110 * send out message with encoded payload to peer.
111 * use the message encode method to encode to payload, 111 * use the message encode method to encode to payload,
@@ -117,7 +117,7 @@ private: @@ -117,7 +117,7 @@ private:
117 /** 117 /**
118 * when recv message, update the context. 118 * when recv message, update the context.
119 */ 119 */
120 - virtual int on_recv_message(SrsMessage* msg); 120 + virtual int on_recv_message(SrsCommonMessage* msg);
121 /** 121 /**
122 * when message sentout, update the context. 122 * when message sentout, update the context.
123 */ 123 */
@@ -128,7 +128,7 @@ private: @@ -128,7 +128,7 @@ private:
128 * return success and pmsg set to NULL if no entire message got, 128 * return success and pmsg set to NULL if no entire message got,
129 * return success and pmsg set to entire message if got one. 129 * return success and pmsg set to entire message if got one.
130 */ 130 */
131 - virtual int recv_interlaced_message(SrsMessage** pmsg); 131 + virtual int recv_interlaced_message(SrsCommonMessage** pmsg);
132 /** 132 /**
133 * read the chunk basic header(fmt, cid) from chunk stream. 133 * read the chunk basic header(fmt, cid) from chunk stream.
134 * user can discovery a SrsChunkStream by cid. 134 * user can discovery a SrsChunkStream by cid.
@@ -146,7 +146,7 @@ private: @@ -146,7 +146,7 @@ private:
146 * if got entire message, set the pmsg. 146 * if got entire message, set the pmsg.
147 * @payload_size read size in this roundtrip, generally a chunk size or left message size. 147 * @payload_size read size in this roundtrip, generally a chunk size or left message size.
148 */ 148 */
149 - virtual int read_message_payload(SrsChunkStream* chunk, int bh_size, int mh_size, int& payload_size, SrsMessage** pmsg); 149 + virtual int read_message_payload(SrsChunkStream* chunk, int bh_size, int mh_size, int& payload_size, SrsCommonMessage** pmsg);
150 }; 150 };
151 151
152 /** 152 /**
@@ -222,7 +222,7 @@ public: @@ -222,7 +222,7 @@ public:
222 /** 222 /**
223 * partially read message. 223 * partially read message.
224 */ 224 */
225 - SrsMessage* msg; 225 + SrsCommonMessage* msg;
226 /** 226 /**
227 * decoded msg count, to identify whether the chunk stream is fresh. 227 * decoded msg count, to identify whether the chunk stream is fresh.
228 */ 228 */
@@ -274,7 +274,7 @@ public: @@ -274,7 +274,7 @@ public:
274 * common RTMP message defines in rtmp.part2.Message-Formats.pdf. 274 * common RTMP message defines in rtmp.part2.Message-Formats.pdf.
275 * cannbe parse and decode. 275 * cannbe parse and decode.
276 */ 276 */
277 -class SrsMessage : public SrsOutputableMessage 277 +class SrsCommonMessage : public SrsOutputableMessage
278 { 278 {
279 private: 279 private:
280 typedef SrsOutputableMessage super; 280 typedef SrsOutputableMessage super;
@@ -283,8 +283,8 @@ private: @@ -283,8 +283,8 @@ private:
283 SrsStream* stream; 283 SrsStream* stream;
284 SrsPacket* packet; 284 SrsPacket* packet;
285 public: 285 public:
286 - SrsMessage();  
287 - virtual ~SrsMessage(); 286 + SrsCommonMessage();
  287 + virtual ~SrsCommonMessage();
288 /** 288 /**
289 * decode functions. 289 * decode functions.
290 */ 290 */
@@ -959,7 +959,7 @@ protected: @@ -959,7 +959,7 @@ protected:
959 * @remark, only when success, user can use and must free the pmsg/ppacket. 959 * @remark, only when success, user can use and must free the pmsg/ppacket.
960 */ 960 */
961 template<class T> 961 template<class T>
962 -int srs_rtmp_expect_message(SrsProtocol* protocol, SrsMessage** pmsg, T** ppacket) 962 +int srs_rtmp_expect_message(SrsProtocol* protocol, SrsCommonMessage** pmsg, T** ppacket)
963 { 963 {
964 *pmsg = NULL; 964 *pmsg = NULL;
965 *ppacket = NULL; 965 *ppacket = NULL;
@@ -967,7 +967,7 @@ int srs_rtmp_expect_message(SrsProtocol* protocol, SrsMessage** pmsg, T** ppacke @@ -967,7 +967,7 @@ int srs_rtmp_expect_message(SrsProtocol* protocol, SrsMessage** pmsg, T** ppacke
967 int ret = ERROR_SUCCESS; 967 int ret = ERROR_SUCCESS;
968 968
969 while (true) { 969 while (true) {
970 - SrsMessage* msg = NULL; 970 + SrsCommonMessage* msg = NULL;
971 if ((ret = protocol->recv_message(&msg)) != ERROR_SUCCESS) { 971 if ((ret = protocol->recv_message(&msg)) != ERROR_SUCCESS) {
972 srs_error("recv message failed. ret=%d", ret); 972 srs_error("recv message failed. ret=%d", ret);
973 return ret; 973 return ret;
@@ -142,7 +142,7 @@ SrsRtmp::~SrsRtmp() @@ -142,7 +142,7 @@ SrsRtmp::~SrsRtmp()
142 srs_freep(protocol); 142 srs_freep(protocol);
143 } 143 }
144 144
145 -int SrsRtmp::recv_message(SrsMessage** pmsg) 145 +int SrsRtmp::recv_message(SrsCommonMessage** pmsg)
146 { 146 {
147 return protocol->recv_message(pmsg); 147 return protocol->recv_message(pmsg);
148 } 148 }
@@ -152,7 +152,7 @@ int SrsRtmp::can_read(int timeout_ms, bool& ready) @@ -152,7 +152,7 @@ int SrsRtmp::can_read(int timeout_ms, bool& ready)
152 return protocol->can_read(timeout_ms, ready); 152 return protocol->can_read(timeout_ms, ready);
153 } 153 }
154 154
155 -int SrsRtmp::send_message(SrsMessage* msg) 155 +int SrsRtmp::send_message(SrsCommonMessage* msg)
156 { 156 {
157 return protocol->send_message(msg); 157 return protocol->send_message(msg);
158 } 158 }
@@ -207,13 +207,13 @@ int SrsRtmp::connect_app(SrsRequest* req) @@ -207,13 +207,13 @@ int SrsRtmp::connect_app(SrsRequest* req)
207 { 207 {
208 int ret = ERROR_SUCCESS; 208 int ret = ERROR_SUCCESS;
209 209
210 - SrsMessage* msg = NULL; 210 + SrsCommonMessage* msg = NULL;
211 SrsConnectAppPacket* pkt = NULL; 211 SrsConnectAppPacket* pkt = NULL;
212 if ((ret = srs_rtmp_expect_message<SrsConnectAppPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) { 212 if ((ret = srs_rtmp_expect_message<SrsConnectAppPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
213 srs_error("expect connect app message failed. ret=%d", ret); 213 srs_error("expect connect app message failed. ret=%d", ret);
214 return ret; 214 return ret;
215 } 215 }
216 - SrsAutoFree(SrsMessage, msg, false); 216 + SrsAutoFree(SrsCommonMessage, msg, false);
217 srs_info("get connect app message"); 217 srs_info("get connect app message");
218 218
219 SrsAmf0Any* prop = NULL; 219 SrsAmf0Any* prop = NULL;
@@ -246,7 +246,7 @@ int SrsRtmp::set_window_ack_size(int ack_size) @@ -246,7 +246,7 @@ int SrsRtmp::set_window_ack_size(int ack_size)
246 { 246 {
247 int ret = ERROR_SUCCESS; 247 int ret = ERROR_SUCCESS;
248 248
249 - SrsMessage* msg = new SrsMessage(); 249 + SrsCommonMessage* msg = new SrsCommonMessage();
250 SrsSetWindowAckSizePacket* pkt = new SrsSetWindowAckSizePacket(); 250 SrsSetWindowAckSizePacket* pkt = new SrsSetWindowAckSizePacket();
251 251
252 pkt->ackowledgement_window_size = ack_size; 252 pkt->ackowledgement_window_size = ack_size;
@@ -265,7 +265,7 @@ int SrsRtmp::set_peer_bandwidth(int bandwidth, int type) @@ -265,7 +265,7 @@ int SrsRtmp::set_peer_bandwidth(int bandwidth, int type)
265 { 265 {
266 int ret = ERROR_SUCCESS; 266 int ret = ERROR_SUCCESS;
267 267
268 - SrsMessage* msg = new SrsMessage(); 268 + SrsCommonMessage* msg = new SrsCommonMessage();
269 SrsSetPeerBandwidthPacket* pkt = new SrsSetPeerBandwidthPacket(); 269 SrsSetPeerBandwidthPacket* pkt = new SrsSetPeerBandwidthPacket();
270 270
271 pkt->bandwidth = bandwidth; 271 pkt->bandwidth = bandwidth;
@@ -286,7 +286,7 @@ int SrsRtmp::response_connect_app(SrsRequest* req) @@ -286,7 +286,7 @@ int SrsRtmp::response_connect_app(SrsRequest* req)
286 { 286 {
287 int ret = ERROR_SUCCESS; 287 int ret = ERROR_SUCCESS;
288 288
289 - SrsMessage* msg = new SrsMessage(); 289 + SrsCommonMessage* msg = new SrsCommonMessage();
290 SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket(); 290 SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket();
291 291
292 pkt->props->set("fmsVer", new SrsAmf0String("FMS/"RTMP_SIG_FMS_VER)); 292 pkt->props->set("fmsVer", new SrsAmf0String("FMS/"RTMP_SIG_FMS_VER));
@@ -320,7 +320,7 @@ int SrsRtmp::on_bw_done() @@ -320,7 +320,7 @@ int SrsRtmp::on_bw_done()
320 { 320 {
321 int ret = ERROR_SUCCESS; 321 int ret = ERROR_SUCCESS;
322 322
323 - SrsMessage* msg = new SrsMessage(); 323 + SrsCommonMessage* msg = new SrsCommonMessage();
324 SrsOnBWDonePacket* pkt = new SrsOnBWDonePacket(); 324 SrsOnBWDonePacket* pkt = new SrsOnBWDonePacket();
325 325
326 msg->set_packet(pkt, 0); 326 msg->set_packet(pkt, 0);
@@ -340,13 +340,13 @@ int SrsRtmp::identify_client(int stream_id, SrsClientType& type, std::string& st @@ -340,13 +340,13 @@ int SrsRtmp::identify_client(int stream_id, SrsClientType& type, std::string& st
340 int ret = ERROR_SUCCESS; 340 int ret = ERROR_SUCCESS;
341 341
342 while (true) { 342 while (true) {
343 - SrsMessage* msg = NULL; 343 + SrsCommonMessage* msg = NULL;
344 if ((ret = protocol->recv_message(&msg)) != ERROR_SUCCESS) { 344 if ((ret = protocol->recv_message(&msg)) != ERROR_SUCCESS) {
345 srs_error("recv identify client message failed. ret=%d", ret); 345 srs_error("recv identify client message failed. ret=%d", ret);
346 return ret; 346 return ret;
347 } 347 }
348 348
349 - SrsAutoFree(SrsMessage, msg, false); 349 + SrsAutoFree(SrsCommonMessage, msg, false);
350 350
351 if (!msg->header.is_amf0_command() && !msg->header.is_amf3_command()) { 351 if (!msg->header.is_amf0_command() && !msg->header.is_amf3_command()) {
352 srs_trace("identify ignore messages except " 352 srs_trace("identify ignore messages except "
@@ -381,7 +381,7 @@ int SrsRtmp::set_chunk_size(int chunk_size) @@ -381,7 +381,7 @@ int SrsRtmp::set_chunk_size(int chunk_size)
381 { 381 {
382 int ret = ERROR_SUCCESS; 382 int ret = ERROR_SUCCESS;
383 383
384 - SrsMessage* msg = new SrsMessage(); 384 + SrsCommonMessage* msg = new SrsCommonMessage();
385 SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket(); 385 SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
386 386
387 pkt->chunk_size = chunk_size; 387 pkt->chunk_size = chunk_size;
@@ -402,7 +402,7 @@ int SrsRtmp::start_play(int stream_id) @@ -402,7 +402,7 @@ int SrsRtmp::start_play(int stream_id)
402 402
403 // StreamBegin 403 // StreamBegin
404 if (true) { 404 if (true) {
405 - SrsMessage* msg = new SrsMessage(); 405 + SrsCommonMessage* msg = new SrsCommonMessage();
406 SrsPCUC4BytesPacket* pkt = new SrsPCUC4BytesPacket(); 406 SrsPCUC4BytesPacket* pkt = new SrsPCUC4BytesPacket();
407 407
408 pkt->event_type = SrcPCUCStreamBegin; 408 pkt->event_type = SrcPCUCStreamBegin;
@@ -418,7 +418,7 @@ int SrsRtmp::start_play(int stream_id) @@ -418,7 +418,7 @@ int SrsRtmp::start_play(int stream_id)
418 418
419 // onStatus(NetStream.Play.Reset) 419 // onStatus(NetStream.Play.Reset)
420 if (true) { 420 if (true) {
421 - SrsMessage* msg = new SrsMessage(); 421 + SrsCommonMessage* msg = new SrsCommonMessage();
422 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); 422 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
423 423
424 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus)); 424 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus));
@@ -438,7 +438,7 @@ int SrsRtmp::start_play(int stream_id) @@ -438,7 +438,7 @@ int SrsRtmp::start_play(int stream_id)
438 438
439 // onStatus(NetStream.Play.Start) 439 // onStatus(NetStream.Play.Start)
440 if (true) { 440 if (true) {
441 - SrsMessage* msg = new SrsMessage(); 441 + SrsCommonMessage* msg = new SrsCommonMessage();
442 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); 442 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
443 443
444 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus)); 444 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus));
@@ -458,7 +458,7 @@ int SrsRtmp::start_play(int stream_id) @@ -458,7 +458,7 @@ int SrsRtmp::start_play(int stream_id)
458 458
459 // |RtmpSampleAccess(false, false) 459 // |RtmpSampleAccess(false, false)
460 if (true) { 460 if (true) {
461 - SrsMessage* msg = new SrsMessage(); 461 + SrsCommonMessage* msg = new SrsCommonMessage();
462 SrsSampleAccessPacket* pkt = new SrsSampleAccessPacket(); 462 SrsSampleAccessPacket* pkt = new SrsSampleAccessPacket();
463 463
464 msg->set_packet(pkt, stream_id); 464 msg->set_packet(pkt, stream_id);
@@ -472,7 +472,7 @@ int SrsRtmp::start_play(int stream_id) @@ -472,7 +472,7 @@ int SrsRtmp::start_play(int stream_id)
472 472
473 // onStatus(NetStream.Data.Start) 473 // onStatus(NetStream.Data.Start)
474 if (true) { 474 if (true) {
475 - SrsMessage* msg = new SrsMessage(); 475 + SrsCommonMessage* msg = new SrsCommonMessage();
476 SrsOnStatusDataPacket* pkt = new SrsOnStatusDataPacket(); 476 SrsOnStatusDataPacket* pkt = new SrsOnStatusDataPacket();
477 477
478 pkt->data->set(StatusCode, new SrsAmf0String(StatusCodeDataStart)); 478 pkt->data->set(StatusCode, new SrsAmf0String(StatusCodeDataStart));
@@ -498,7 +498,7 @@ int SrsRtmp::start_publish(int stream_id) @@ -498,7 +498,7 @@ int SrsRtmp::start_publish(int stream_id)
498 // FCPublish 498 // FCPublish
499 double fc_publish_tid = 0; 499 double fc_publish_tid = 0;
500 if (true) { 500 if (true) {
501 - SrsMessage* msg = NULL; 501 + SrsCommonMessage* msg = NULL;
502 SrsFMLEStartPacket* pkt = NULL; 502 SrsFMLEStartPacket* pkt = NULL;
503 if ((ret = srs_rtmp_expect_message<SrsFMLEStartPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) { 503 if ((ret = srs_rtmp_expect_message<SrsFMLEStartPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
504 srs_error("recv FCPublish message failed. ret=%d", ret); 504 srs_error("recv FCPublish message failed. ret=%d", ret);
@@ -506,12 +506,12 @@ int SrsRtmp::start_publish(int stream_id) @@ -506,12 +506,12 @@ int SrsRtmp::start_publish(int stream_id)
506 } 506 }
507 srs_info("recv FCPublish request message success."); 507 srs_info("recv FCPublish request message success.");
508 508
509 - SrsAutoFree(SrsMessage, msg, false); 509 + SrsAutoFree(SrsCommonMessage, msg, false);
510 fc_publish_tid = pkt->transaction_id; 510 fc_publish_tid = pkt->transaction_id;
511 } 511 }
512 // FCPublish response 512 // FCPublish response
513 if (true) { 513 if (true) {
514 - SrsMessage* msg = new SrsMessage(); 514 + SrsCommonMessage* msg = new SrsCommonMessage();
515 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(fc_publish_tid); 515 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(fc_publish_tid);
516 516
517 msg->set_packet(pkt, 0); 517 msg->set_packet(pkt, 0);
@@ -526,7 +526,7 @@ int SrsRtmp::start_publish(int stream_id) @@ -526,7 +526,7 @@ int SrsRtmp::start_publish(int stream_id)
526 // createStream 526 // createStream
527 double create_stream_tid = 0; 527 double create_stream_tid = 0;
528 if (true) { 528 if (true) {
529 - SrsMessage* msg = NULL; 529 + SrsCommonMessage* msg = NULL;
530 SrsCreateStreamPacket* pkt = NULL; 530 SrsCreateStreamPacket* pkt = NULL;
531 if ((ret = srs_rtmp_expect_message<SrsCreateStreamPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) { 531 if ((ret = srs_rtmp_expect_message<SrsCreateStreamPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
532 srs_error("recv createStream message failed. ret=%d", ret); 532 srs_error("recv createStream message failed. ret=%d", ret);
@@ -534,12 +534,12 @@ int SrsRtmp::start_publish(int stream_id) @@ -534,12 +534,12 @@ int SrsRtmp::start_publish(int stream_id)
534 } 534 }
535 srs_info("recv createStream request message success."); 535 srs_info("recv createStream request message success.");
536 536
537 - SrsAutoFree(SrsMessage, msg, false); 537 + SrsAutoFree(SrsCommonMessage, msg, false);
538 create_stream_tid = pkt->transaction_id; 538 create_stream_tid = pkt->transaction_id;
539 } 539 }
540 // createStream response 540 // createStream response
541 if (true) { 541 if (true) {
542 - SrsMessage* msg = new SrsMessage(); 542 + SrsCommonMessage* msg = new SrsCommonMessage();
543 SrsCreateStreamResPacket* pkt = new SrsCreateStreamResPacket(create_stream_tid, stream_id); 543 SrsCreateStreamResPacket* pkt = new SrsCreateStreamResPacket(create_stream_tid, stream_id);
544 544
545 msg->set_packet(pkt, 0); 545 msg->set_packet(pkt, 0);
@@ -553,7 +553,7 @@ int SrsRtmp::start_publish(int stream_id) @@ -553,7 +553,7 @@ int SrsRtmp::start_publish(int stream_id)
553 553
554 // publish 554 // publish
555 if (true) { 555 if (true) {
556 - SrsMessage* msg = NULL; 556 + SrsCommonMessage* msg = NULL;
557 SrsPublishPacket* pkt = NULL; 557 SrsPublishPacket* pkt = NULL;
558 if ((ret = srs_rtmp_expect_message<SrsPublishPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) { 558 if ((ret = srs_rtmp_expect_message<SrsPublishPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
559 srs_error("recv publish message failed. ret=%d", ret); 559 srs_error("recv publish message failed. ret=%d", ret);
@@ -561,11 +561,11 @@ int SrsRtmp::start_publish(int stream_id) @@ -561,11 +561,11 @@ int SrsRtmp::start_publish(int stream_id)
561 } 561 }
562 srs_info("recv publish request message success."); 562 srs_info("recv publish request message success.");
563 563
564 - SrsAutoFree(SrsMessage, msg, false); 564 + SrsAutoFree(SrsCommonMessage, msg, false);
565 } 565 }
566 // publish response onFCPublish(NetStream.Publish.Start) 566 // publish response onFCPublish(NetStream.Publish.Start)
567 if (true) { 567 if (true) {
568 - SrsMessage* msg = new SrsMessage(); 568 + SrsCommonMessage* msg = new SrsCommonMessage();
569 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); 569 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
570 570
571 pkt->command_name = RTMP_AMF0_COMMAND_ON_FC_PUBLISH; 571 pkt->command_name = RTMP_AMF0_COMMAND_ON_FC_PUBLISH;
@@ -582,7 +582,7 @@ int SrsRtmp::start_publish(int stream_id) @@ -582,7 +582,7 @@ int SrsRtmp::start_publish(int stream_id)
582 } 582 }
583 // publish response onStatus(NetStream.Publish.Start) 583 // publish response onStatus(NetStream.Publish.Start)
584 if (true) { 584 if (true) {
585 - SrsMessage* msg = new SrsMessage(); 585 + SrsCommonMessage* msg = new SrsCommonMessage();
586 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); 586 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
587 587
588 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus)); 588 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus));
@@ -608,7 +608,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid) @@ -608,7 +608,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid)
608 608
609 // publish response onFCUnpublish(NetStream.unpublish.Success) 609 // publish response onFCUnpublish(NetStream.unpublish.Success)
610 if (true) { 610 if (true) {
611 - SrsMessage* msg = new SrsMessage(); 611 + SrsCommonMessage* msg = new SrsCommonMessage();
612 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); 612 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
613 613
614 pkt->command_name = RTMP_AMF0_COMMAND_ON_FC_UNPUBLISH; 614 pkt->command_name = RTMP_AMF0_COMMAND_ON_FC_UNPUBLISH;
@@ -625,7 +625,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid) @@ -625,7 +625,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid)
625 } 625 }
626 // FCUnpublish response 626 // FCUnpublish response
627 if (true) { 627 if (true) {
628 - SrsMessage* msg = new SrsMessage(); 628 + SrsCommonMessage* msg = new SrsCommonMessage();
629 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(unpublish_tid); 629 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(unpublish_tid);
630 630
631 msg->set_packet(pkt, stream_id); 631 msg->set_packet(pkt, stream_id);
@@ -638,7 +638,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid) @@ -638,7 +638,7 @@ int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid)
638 } 638 }
639 // publish response onStatus(NetStream.Unpublish.Success) 639 // publish response onStatus(NetStream.Unpublish.Success)
640 if (true) { 640 if (true) {
641 - SrsMessage* msg = new SrsMessage(); 641 + SrsCommonMessage* msg = new SrsCommonMessage();
642 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); 642 SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
643 643
644 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus)); 644 pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus));
@@ -665,7 +665,7 @@ int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int strea @@ -665,7 +665,7 @@ int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int strea
665 int ret = ERROR_SUCCESS; 665 int ret = ERROR_SUCCESS;
666 666
667 if (true) { 667 if (true) {
668 - SrsMessage* msg = new SrsMessage(); 668 + SrsCommonMessage* msg = new SrsCommonMessage();
669 SrsCreateStreamResPacket* pkt = new SrsCreateStreamResPacket(req->transaction_id, stream_id); 669 SrsCreateStreamResPacket* pkt = new SrsCreateStreamResPacket(req->transaction_id, stream_id);
670 670
671 msg->set_packet(pkt, 0); 671 msg->set_packet(pkt, 0);
@@ -678,13 +678,13 @@ int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int strea @@ -678,13 +678,13 @@ int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int strea
678 } 678 }
679 679
680 while (true) { 680 while (true) {
681 - SrsMessage* msg = NULL; 681 + SrsCommonMessage* msg = NULL;
682 if ((ret = protocol->recv_message(&msg)) != ERROR_SUCCESS) { 682 if ((ret = protocol->recv_message(&msg)) != ERROR_SUCCESS) {
683 srs_error("recv identify client message failed. ret=%d", ret); 683 srs_error("recv identify client message failed. ret=%d", ret);
684 return ret; 684 return ret;
685 } 685 }
686 686
687 - SrsAutoFree(SrsMessage, msg, false); 687 + SrsAutoFree(SrsCommonMessage, msg, false);
688 688
689 if (!msg->header.is_amf0_command() && !msg->header.is_amf3_command()) { 689 if (!msg->header.is_amf0_command() && !msg->header.is_amf3_command()) {
690 srs_trace("identify ignore messages except " 690 srs_trace("identify ignore messages except "
@@ -721,7 +721,7 @@ int SrsRtmp::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType @@ -721,7 +721,7 @@ int SrsRtmp::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType
721 721
722 // releaseStream response 722 // releaseStream response
723 if (true) { 723 if (true) {
724 - SrsMessage* msg = new SrsMessage(); 724 + SrsCommonMessage* msg = new SrsCommonMessage();
725 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(req->transaction_id); 725 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(req->transaction_id);
726 726
727 msg->set_packet(pkt, 0); 727 msg->set_packet(pkt, 0);
@@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 #include <st.h> 35 #include <st.h>
36 36
37 class SrsProtocol; 37 class SrsProtocol;
38 -class SrsMessage; 38 +class SrsCommonMessage;
39 class SrsCreateStreamPacket; 39 class SrsCreateStreamPacket;
40 class SrsFMLEStartPacket; 40 class SrsFMLEStartPacket;
41 41
@@ -100,9 +100,9 @@ public: @@ -100,9 +100,9 @@ public:
100 SrsRtmp(st_netfd_t client_stfd); 100 SrsRtmp(st_netfd_t client_stfd);
101 virtual ~SrsRtmp(); 101 virtual ~SrsRtmp();
102 public: 102 public:
103 - virtual int recv_message(SrsMessage** pmsg); 103 + virtual int recv_message(SrsCommonMessage** pmsg);
104 virtual int can_read(int timeout_ms, bool& ready); 104 virtual int can_read(int timeout_ms, bool& ready);
105 - virtual int send_message(SrsMessage* msg); 105 + virtual int send_message(SrsCommonMessage* msg);
106 public: 106 public:
107 virtual int handshake(); 107 virtual int handshake();
108 virtual int connect_app(SrsRequest* req); 108 virtual int connect_app(SrsRequest* req);
@@ -47,7 +47,7 @@ SrsConsumer::~SrsConsumer() @@ -47,7 +47,7 @@ SrsConsumer::~SrsConsumer()
47 { 47 {
48 } 48 }
49 49
50 -int SrsConsumer::get_packets(int max_count, SrsMessage**& msgs, int& count) 50 +int SrsConsumer::get_packets(int max_count, SrsCommonMessage**& msgs, int& count)
51 { 51 {
52 msgs = NULL; 52 msgs = NULL;
53 count = 0; 53 count = 0;
@@ -65,7 +65,7 @@ SrsSource::~SrsSource() @@ -65,7 +65,7 @@ SrsSource::~SrsSource()
65 { 65 {
66 } 66 }
67 67
68 -int SrsSource::on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata) 68 +int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata)
69 { 69 {
70 int ret = ERROR_SUCCESS; 70 int ret = ERROR_SUCCESS;
71 71
@@ -75,13 +75,13 @@ int SrsSource::on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata) @@ -75,13 +75,13 @@ int SrsSource::on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata)
75 return ret; 75 return ret;
76 } 76 }
77 77
78 -int SrsSource::on_audio(SrsMessage* audio) 78 +int SrsSource::on_audio(SrsCommonMessage* audio)
79 { 79 {
80 int ret = ERROR_SUCCESS; 80 int ret = ERROR_SUCCESS;
81 return ret; 81 return ret;
82 } 82 }
83 83
84 -int SrsSource::on_video(SrsMessage* audio) 84 +int SrsSource::on_video(SrsCommonMessage* audio)
85 { 85 {
86 int ret = ERROR_SUCCESS; 86 int ret = ERROR_SUCCESS;
87 return ret; 87 return ret;
@@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 #include <map> 33 #include <map>
34 #include <string> 34 #include <string>
35 35
36 -class SrsMessage; 36 +class SrsCommonMessage;
37 class SrsOnMetaDataPacket; 37 class SrsOnMetaDataPacket;
38 38
39 /** 39 /**
@@ -51,7 +51,7 @@ public: @@ -51,7 +51,7 @@ public:
51 * @count the count in array. 51 * @count the count in array.
52 * @max_count the max count to dequeue, 0 to dequeue all. 52 * @max_count the max count to dequeue, 0 to dequeue all.
53 */ 53 */
54 - virtual int get_packets(int max_count, SrsMessage**& msgs, int& count); 54 + virtual int get_packets(int max_count, SrsCommonMessage**& msgs, int& count);
55 }; 55 };
56 56
57 /** 57 /**
@@ -75,9 +75,9 @@ public: @@ -75,9 +75,9 @@ public:
75 SrsSource(std::string _stream_url); 75 SrsSource(std::string _stream_url);
76 virtual ~SrsSource(); 76 virtual ~SrsSource();
77 public: 77 public:
78 - virtual int on_meta_data(SrsMessage* msg, SrsOnMetaDataPacket* metadata);  
79 - virtual int on_audio(SrsMessage* audio);  
80 - virtual int on_video(SrsMessage* video); 78 + virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);
  79 + virtual int on_audio(SrsCommonMessage* audio);
  80 + virtual int on_video(SrsCommonMessage* video);
81 public: 81 public:
82 virtual SrsConsumer* create_consumer(); 82 virtual SrsConsumer* create_consumer();
83 }; 83 };