winlin

fix #121, srs_info detail log compile failed. 0.9.168.

@@ -209,6 +209,7 @@ Supported operating systems and hardware: @@ -209,6 +209,7 @@ Supported operating systems and hardware:
209 * 2013-10-17, Created.<br/> 209 * 2013-10-17, Created.<br/>
210 210
211 ## History 211 ## History
  212 +* v1.0, 2014-07-19, fix [#121](https://github.com/winlinvip/simple-rtmp-server/issues/121), srs_info detail log compile failed. 0.9.168.
212 * v1.0, 2014-07-19, fix [#119](https://github.com/winlinvip/simple-rtmp-server/issues/119), use iformat and oformat for ffmpeg transcode. 0.9.163. 213 * v1.0, 2014-07-19, fix [#119](https://github.com/winlinvip/simple-rtmp-server/issues/119), use iformat and oformat for ffmpeg transcode. 0.9.163.
213 * <strong>v1.0, 2014-07-13, [1.0 mainline6(0.9.160)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline8) released. 50029 lines.</strong> 214 * <strong>v1.0, 2014-07-13, [1.0 mainline6(0.9.160)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline8) released. 50029 lines.</strong>
214 * v1.0, 2014-07-13, refine the bandwidth check/test, add as/js library, use srs-librtmp for linux tool. 0.9.159 215 * v1.0, 2014-07-13, refine the bandwidth check/test, add as/js library, use srs-librtmp for linux tool. 0.9.159
@@ -141,9 +141,8 @@ int SrsHttpClient::connect(SrsHttpUri* uri) @@ -141,9 +141,8 @@ int SrsHttpClient::connect(SrsHttpUri* uri)
141 server.c_str(), port, timeout, ret); 141 server.c_str(), port, timeout, ret);
142 return ret; 142 return ret;
143 } 143 }
144 - srs_info("connect to server success. "  
145 - "http url=%s, server=%s, ip=%s, port=%d",  
146 - uri->get_url(), uri->get_host(), ip.c_str(), uri->get_port()); 144 + srs_info("connect to server success. http url=%s, server=%s, port=%d",
  145 + uri->get_url(), uri->get_host(), uri->get_port());
147 146
148 connected = true; 147 connected = true;
149 148
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "167" 34 +#define VERSION_REVISION "168"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"
@@ -133,11 +133,11 @@ extern ISrsThreadContext* _srs_context; @@ -133,11 +133,11 @@ extern ISrsThreadContext* _srs_context;
133 #define srs_error(msg, ...) _srs_log->error(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__) 133 #define srs_error(msg, ...) _srs_log->error(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
134 #endif 134 #endif
135 135
136 -#if 1 136 +#if 0
137 #undef srs_verbose 137 #undef srs_verbose
138 #define srs_verbose(msg, ...) (void)0 138 #define srs_verbose(msg, ...) (void)0
139 #endif 139 #endif
140 -#if 1 140 +#if 0
141 #undef srs_info 141 #undef srs_info
142 #define srs_info(msg, ...) (void)0 142 #define srs_info(msg, ...) (void)0
143 #endif 143 #endif
@@ -1071,7 +1071,7 @@ int SrsAmf0StrictArray::write(SrsStream* stream) @@ -1071,7 +1071,7 @@ int SrsAmf0StrictArray::write(SrsStream* stream)
1071 return ret; 1071 return ret;
1072 } 1072 }
1073 1073
1074 - srs_verbose("write amf0 property success. name=%s", name.c_str()); 1074 + srs_verbose("write amf0 property success.");
1075 } 1075 }
1076 1076
1077 srs_verbose("write strict_array object success."); 1077 srs_verbose("write strict_array object success.");
@@ -289,6 +289,128 @@ messages. @@ -289,6 +289,128 @@ messages.
289 ***************************************************************************** 289 *****************************************************************************
290 ****************************************************************************/ 290 ****************************************************************************/
291 291
  292 +SrsMessageHeader::SrsMessageHeader()
  293 +{
  294 + message_type = 0;
  295 + payload_length = 0;
  296 + timestamp_delta = 0;
  297 + stream_id = 0;
  298 +
  299 + timestamp = 0;
  300 + // we always use the connection chunk-id
  301 + perfer_cid = RTMP_CID_OverConnection;
  302 +}
  303 +
  304 +SrsMessageHeader::~SrsMessageHeader()
  305 +{
  306 +}
  307 +
  308 +bool SrsMessageHeader::is_audio()
  309 +{
  310 + return message_type == RTMP_MSG_AudioMessage;
  311 +}
  312 +
  313 +bool SrsMessageHeader::is_video()
  314 +{
  315 + return message_type == RTMP_MSG_VideoMessage;
  316 +}
  317 +
  318 +bool SrsMessageHeader::is_amf0_command()
  319 +{
  320 + return message_type == RTMP_MSG_AMF0CommandMessage;
  321 +}
  322 +
  323 +bool SrsMessageHeader::is_amf0_data()
  324 +{
  325 + return message_type == RTMP_MSG_AMF0DataMessage;
  326 +}
  327 +
  328 +bool SrsMessageHeader::is_amf3_command()
  329 +{
  330 + return message_type == RTMP_MSG_AMF3CommandMessage;
  331 +}
  332 +
  333 +bool SrsMessageHeader::is_amf3_data()
  334 +{
  335 + return message_type == RTMP_MSG_AMF3DataMessage;
  336 +}
  337 +
  338 +bool SrsMessageHeader::is_window_ackledgement_size()
  339 +{
  340 + return message_type == RTMP_MSG_WindowAcknowledgementSize;
  341 +}
  342 +
  343 +bool SrsMessageHeader::is_ackledgement()
  344 +{
  345 + return message_type == RTMP_MSG_Acknowledgement;
  346 +}
  347 +
  348 +bool SrsMessageHeader::is_set_chunk_size()
  349 +{
  350 + return message_type == RTMP_MSG_SetChunkSize;
  351 +}
  352 +
  353 +bool SrsMessageHeader::is_user_control_message()
  354 +{
  355 + return message_type == RTMP_MSG_UserControlMessage;
  356 +}
  357 +
  358 +bool SrsMessageHeader::is_set_peer_bandwidth()
  359 +{
  360 + return message_type == RTMP_MSG_SetPeerBandwidth;
  361 +}
  362 +
  363 +bool SrsMessageHeader::is_aggregate()
  364 +{
  365 + return message_type == RTMP_MSG_AggregateMessage;
  366 +}
  367 +
  368 +void SrsMessageHeader::initialize_amf0_script(int size, int stream)
  369 +{
  370 + message_type = RTMP_MSG_AMF0DataMessage;
  371 + payload_length = (int32_t)size;
  372 + timestamp_delta = (int32_t)0;
  373 + timestamp = (int64_t)0;
  374 + stream_id = (int32_t)stream;
  375 +
  376 + // amf0 script use connection2 chunk-id
  377 + perfer_cid = RTMP_CID_OverConnection2;
  378 +}
  379 +
  380 +void SrsMessageHeader::initialize_audio(int size, u_int32_t time, int stream)
  381 +{
  382 + message_type = RTMP_MSG_AudioMessage;
  383 + payload_length = (int32_t)size;
  384 + timestamp_delta = (int32_t)time;
  385 + timestamp = (int64_t)time;
  386 + stream_id = (int32_t)stream;
  387 +
  388 + // audio chunk-id
  389 + perfer_cid = RTMP_CID_Audio;
  390 +}
  391 +
  392 +void SrsMessageHeader::initialize_video(int size, u_int32_t time, int stream)
  393 +{
  394 + message_type = RTMP_MSG_VideoMessage;
  395 + payload_length = (int32_t)size;
  396 + timestamp_delta = (int32_t)time;
  397 + timestamp = (int64_t)time;
  398 + stream_id = (int32_t)stream;
  399 +
  400 + // video chunk-id
  401 + perfer_cid = RTMP_CID_Video;
  402 +}
  403 +
  404 +SrsMessage::SrsMessage()
  405 +{
  406 + payload = NULL;
  407 + size = 0;
  408 +}
  409 +
  410 +SrsMessage::~SrsMessage()
  411 +{
  412 +}
  413 +
292 SrsProtocol::AckWindowSize::AckWindowSize() 414 SrsProtocol::AckWindowSize::AckWindowSize()
293 { 415 {
294 ack_window_size = acked_size = 0; 416 ack_window_size = acked_size = 0;
@@ -1494,118 +1616,6 @@ int SrsProtocol::response_ping_message(int32_t timestamp) @@ -1494,118 +1616,6 @@ int SrsProtocol::response_ping_message(int32_t timestamp)
1494 return ret; 1616 return ret;
1495 } 1617 }
1496 1618
1497 -SrsMessageHeader::SrsMessageHeader()  
1498 -{  
1499 - message_type = 0;  
1500 - payload_length = 0;  
1501 - timestamp_delta = 0;  
1502 - stream_id = 0;  
1503 -  
1504 - timestamp = 0;  
1505 - // we always use the connection chunk-id  
1506 - perfer_cid = RTMP_CID_OverConnection;  
1507 -}  
1508 -  
1509 -SrsMessageHeader::~SrsMessageHeader()  
1510 -{  
1511 -}  
1512 -  
1513 -bool SrsMessageHeader::is_audio()  
1514 -{  
1515 - return message_type == RTMP_MSG_AudioMessage;  
1516 -}  
1517 -  
1518 -bool SrsMessageHeader::is_video()  
1519 -{  
1520 - return message_type == RTMP_MSG_VideoMessage;  
1521 -}  
1522 -  
1523 -bool SrsMessageHeader::is_amf0_command()  
1524 -{  
1525 - return message_type == RTMP_MSG_AMF0CommandMessage;  
1526 -}  
1527 -  
1528 -bool SrsMessageHeader::is_amf0_data()  
1529 -{  
1530 - return message_type == RTMP_MSG_AMF0DataMessage;  
1531 -}  
1532 -  
1533 -bool SrsMessageHeader::is_amf3_command()  
1534 -{  
1535 - return message_type == RTMP_MSG_AMF3CommandMessage;  
1536 -}  
1537 -  
1538 -bool SrsMessageHeader::is_amf3_data()  
1539 -{  
1540 - return message_type == RTMP_MSG_AMF3DataMessage;  
1541 -}  
1542 -  
1543 -bool SrsMessageHeader::is_window_ackledgement_size()  
1544 -{  
1545 - return message_type == RTMP_MSG_WindowAcknowledgementSize;  
1546 -}  
1547 -  
1548 -bool SrsMessageHeader::is_ackledgement()  
1549 -{  
1550 - return message_type == RTMP_MSG_Acknowledgement;  
1551 -}  
1552 -  
1553 -bool SrsMessageHeader::is_set_chunk_size()  
1554 -{  
1555 - return message_type == RTMP_MSG_SetChunkSize;  
1556 -}  
1557 -  
1558 -bool SrsMessageHeader::is_user_control_message()  
1559 -{  
1560 - return message_type == RTMP_MSG_UserControlMessage;  
1561 -}  
1562 -  
1563 -bool SrsMessageHeader::is_set_peer_bandwidth()  
1564 -{  
1565 - return message_type == RTMP_MSG_SetPeerBandwidth;  
1566 -}  
1567 -  
1568 -bool SrsMessageHeader::is_aggregate()  
1569 -{  
1570 - return message_type == RTMP_MSG_AggregateMessage;  
1571 -}  
1572 -  
1573 -void SrsMessageHeader::initialize_amf0_script(int size, int stream)  
1574 -{  
1575 - message_type = RTMP_MSG_AMF0DataMessage;  
1576 - payload_length = (int32_t)size;  
1577 - timestamp_delta = (int32_t)0;  
1578 - timestamp = (int64_t)0;  
1579 - stream_id = (int32_t)stream;  
1580 -  
1581 - // amf0 script use connection2 chunk-id  
1582 - perfer_cid = RTMP_CID_OverConnection2;  
1583 -}  
1584 -  
1585 -void SrsMessageHeader::initialize_audio(int size, u_int32_t time, int stream)  
1586 -{  
1587 - message_type = RTMP_MSG_AudioMessage;  
1588 - payload_length = (int32_t)size;  
1589 - timestamp_delta = (int32_t)time;  
1590 - timestamp = (int64_t)time;  
1591 - stream_id = (int32_t)stream;  
1592 -  
1593 - // audio chunk-id  
1594 - perfer_cid = RTMP_CID_Audio;  
1595 -}  
1596 -  
1597 -void SrsMessageHeader::initialize_video(int size, u_int32_t time, int stream)  
1598 -{  
1599 - message_type = RTMP_MSG_VideoMessage;  
1600 - payload_length = (int32_t)size;  
1601 - timestamp_delta = (int32_t)time;  
1602 - timestamp = (int64_t)time;  
1603 - stream_id = (int32_t)stream;  
1604 -  
1605 - // video chunk-id  
1606 - perfer_cid = RTMP_CID_Video;  
1607 -}  
1608 -  
1609 SrsChunkStream::SrsChunkStream(int _cid) 1619 SrsChunkStream::SrsChunkStream(int _cid)
1610 { 1620 {
1611 fmt = 0; 1621 fmt = 0;
@@ -1620,16 +1630,6 @@ SrsChunkStream::~SrsChunkStream() @@ -1620,16 +1630,6 @@ SrsChunkStream::~SrsChunkStream()
1620 srs_freep(msg); 1630 srs_freep(msg);
1621 } 1631 }
1622 1632
1623 -SrsMessage::SrsMessage()  
1624 -{  
1625 - payload = NULL;  
1626 - size = 0;  
1627 -}  
1628 -  
1629 -SrsMessage::~SrsMessage()  
1630 -{  
1631 -}  
1632 -  
1633 SrsCommonMessage::SrsCommonMessage() 1633 SrsCommonMessage::SrsCommonMessage()
1634 { 1634 {
1635 } 1635 }
@@ -48,6 +48,120 @@ class SrsMessage; @@ -48,6 +48,120 @@ class SrsMessage;
48 class SrsChunkStream; 48 class SrsChunkStream;
49 49
50 /** 50 /**
  51 +* 4.1. Message Header
  52 +*/
  53 +class SrsMessageHeader
  54 +{
  55 +public:
  56 + /**
  57 + * 3bytes.
  58 + * Three-byte field that contains a timestamp delta of the message.
  59 + * The 4 bytes are packed in the big-endian order.
  60 + * @remark, only used for decoding message from chunk stream.
  61 + */
  62 + int32_t timestamp_delta;
  63 + /**
  64 + * 3bytes.
  65 + * Three-byte field that represents the size of the payload in bytes.
  66 + * It is set in big-endian format.
  67 + */
  68 + int32_t payload_length;
  69 + /**
  70 + * 1byte.
  71 + * One byte field to represent the message type. A range of type IDs
  72 + * (1-7) are reserved for protocol control messages.
  73 + */
  74 + int8_t message_type;
  75 + /**
  76 + * 4bytes.
  77 + * Four-byte field that identifies the stream of the message. These
  78 + * bytes are set in big-endian format.
  79 + */
  80 + int32_t stream_id;
  81 +
  82 + /**
  83 + * Four-byte field that contains a timestamp of the message.
  84 + * The 4 bytes are packed in the big-endian order.
  85 + * @remark, used as calc timestamp when decode and encode time.
  86 + * @remark, we use 64bits for large time for jitter detect and hls.
  87 + */
  88 + int64_t timestamp;
  89 +public:
  90 + /**
  91 + * get the perfered cid(chunk stream id) which sendout over.
  92 + * set at decoding, and canbe used for directly send message,
  93 + * for example, dispatch to all connections.
  94 + */
  95 + int perfer_cid;
  96 +public:
  97 + SrsMessageHeader();
  98 + virtual ~SrsMessageHeader();
  99 +public:
  100 + bool is_audio();
  101 + bool is_video();
  102 + bool is_amf0_command();
  103 + bool is_amf0_data();
  104 + bool is_amf3_command();
  105 + bool is_amf3_data();
  106 + bool is_window_ackledgement_size();
  107 + bool is_ackledgement();
  108 + bool is_set_chunk_size();
  109 + bool is_user_control_message();
  110 + bool is_set_peer_bandwidth();
  111 + bool is_aggregate();
  112 +public:
  113 + /**
  114 + * create a amf0 script header, set the size and stream_id.
  115 + */
  116 + void initialize_amf0_script(int size, int stream);
  117 + /**
  118 + * create a audio header, set the size, timestamp and stream_id.
  119 + */
  120 + void initialize_audio(int size, u_int32_t time, int stream);
  121 + /**
  122 + * create a video header, set the size, timestamp and stream_id.
  123 + */
  124 + void initialize_video(int size, u_int32_t time, int stream);
  125 +};
  126 +
  127 +/**
  128 +* message is raw data RTMP message, bytes oriented,
  129 +* protcol always recv RTMP message, and can send RTMP message or RTMP packet.
  130 +* the shared-ptr message is a special RTMP message, use ref-count for performance issue.
  131 +*
  132 +* @remark, never directly new SrsMessage, the constructor is protected,
  133 +* for in the SrsMessage, we never know whether we should free the message,
  134 +* for SrsCommonMessage, we should free the payload,
  135 +* while for SrsSharedPtrMessage, we should use ref-count to free it.
  136 +* so, use these two concrete message, SrsCommonMessage or SrsSharedPtrMessage instread.
  137 +*/
  138 +class SrsMessage
  139 +{
  140 +// 4.1. Message Header
  141 +public:
  142 + SrsMessageHeader header;
  143 +// 4.2. Message Payload
  144 +public:
  145 + /**
  146 + * current message parsed size,
  147 + * size <= header.payload_length
  148 + * for the payload maybe sent in multiple chunks.
  149 + */
  150 + int size;
  151 + /**
  152 + * the payload of message, the SrsMessage never know about the detail of payload,
  153 + * user must use SrsProtocol.decode_message to get concrete packet.
  154 + * @remark, not all message payload can be decoded to packet. for example,
  155 + * video/audio packet use raw bytes, no video/audio packet.
  156 + */
  157 + char* payload;
  158 +protected:
  159 + SrsMessage();
  160 +public:
  161 + virtual ~SrsMessage();
  162 +};
  163 +
  164 +/**
51 * the protocol provides the rtmp-message-protocol services, 165 * the protocol provides the rtmp-message-protocol services,
52 * to recv RTMP message from RTMP chunk stream, 166 * to recv RTMP message from RTMP chunk stream,
53 * and to send out RTMP message over RTMP chunk stream. 167 * and to send out RTMP message over RTMP chunk stream.
@@ -278,83 +392,6 @@ private: @@ -278,83 +392,6 @@ private:
278 }; 392 };
279 393
280 /** 394 /**
281 -* 4.1. Message Header  
282 -*/  
283 -class SrsMessageHeader  
284 -{  
285 -public:  
286 - /**  
287 - * 3bytes.  
288 - * Three-byte field that contains a timestamp delta of the message.  
289 - * The 4 bytes are packed in the big-endian order.  
290 - * @remark, only used for decoding message from chunk stream.  
291 - */  
292 - int32_t timestamp_delta;  
293 - /**  
294 - * 3bytes.  
295 - * Three-byte field that represents the size of the payload in bytes.  
296 - * It is set in big-endian format.  
297 - */  
298 - int32_t payload_length;  
299 - /**  
300 - * 1byte.  
301 - * One byte field to represent the message type. A range of type IDs  
302 - * (1-7) are reserved for protocol control messages.  
303 - */  
304 - int8_t message_type;  
305 - /**  
306 - * 4bytes.  
307 - * Four-byte field that identifies the stream of the message. These  
308 - * bytes are set in big-endian format.  
309 - */  
310 - int32_t stream_id;  
311 -  
312 - /**  
313 - * Four-byte field that contains a timestamp of the message.  
314 - * The 4 bytes are packed in the big-endian order.  
315 - * @remark, used as calc timestamp when decode and encode time.  
316 - * @remark, we use 64bits for large time for jitter detect and hls.  
317 - */  
318 - int64_t timestamp;  
319 -public:  
320 - /**  
321 - * get the perfered cid(chunk stream id) which sendout over.  
322 - * set at decoding, and canbe used for directly send message,  
323 - * for example, dispatch to all connections.  
324 - */  
325 - int perfer_cid;  
326 -public:  
327 - SrsMessageHeader();  
328 - virtual ~SrsMessageHeader();  
329 -public:  
330 - bool is_audio();  
331 - bool is_video();  
332 - bool is_amf0_command();  
333 - bool is_amf0_data();  
334 - bool is_amf3_command();  
335 - bool is_amf3_data();  
336 - bool is_window_ackledgement_size();  
337 - bool is_ackledgement();  
338 - bool is_set_chunk_size();  
339 - bool is_user_control_message();  
340 - bool is_set_peer_bandwidth();  
341 - bool is_aggregate();  
342 -public:  
343 - /**  
344 - * create a amf0 script header, set the size and stream_id.  
345 - */  
346 - void initialize_amf0_script(int size, int stream);  
347 - /**  
348 - * create a audio header, set the size, timestamp and stream_id.  
349 - */  
350 - void initialize_audio(int size, u_int32_t time, int stream);  
351 - /**  
352 - * create a video header, set the size, timestamp and stream_id.  
353 - */  
354 - void initialize_video(int size, u_int32_t time, int stream);  
355 -};  
356 -  
357 -/**  
358 * incoming chunk stream maybe interlaced, 395 * incoming chunk stream maybe interlaced,
359 * use the chunk stream to cache the input RTMP chunk streams. 396 * use the chunk stream to cache the input RTMP chunk streams.
360 */ 397 */
@@ -393,43 +430,6 @@ public: @@ -393,43 +430,6 @@ public:
393 }; 430 };
394 431
395 /** 432 /**
396 -* message is raw data RTMP message, bytes oriented,  
397 -* protcol always recv RTMP message, and can send RTMP message or RTMP packet.  
398 -* the shared-ptr message is a special RTMP message, use ref-count for performance issue.  
399 -*  
400 -* @remark, never directly new SrsMessage, the constructor is protected,  
401 -* for in the SrsMessage, we never know whether we should free the message,  
402 -* for SrsCommonMessage, we should free the payload,  
403 -* while for SrsSharedPtrMessage, we should use ref-count to free it.  
404 -* so, use these two concrete message, SrsCommonMessage or SrsSharedPtrMessage instread.  
405 -*/  
406 -class SrsMessage  
407 -{  
408 -// 4.1. Message Header  
409 -public:  
410 - SrsMessageHeader header;  
411 -// 4.2. Message Payload  
412 -public:  
413 - /**  
414 - * current message parsed size,  
415 - * size <= header.payload_length  
416 - * for the payload maybe sent in multiple chunks.  
417 - */  
418 - int size;  
419 - /**  
420 - * the payload of message, the SrsMessage never know about the detail of payload,  
421 - * user must use SrsProtocol.decode_message to get concrete packet.  
422 - * @remark, not all message payload can be decoded to packet. for example,  
423 - * video/audio packet use raw bytes, no video/audio packet.  
424 - */  
425 - char* payload;  
426 -protected:  
427 - SrsMessage();  
428 -public:  
429 - virtual ~SrsMessage();  
430 -};  
431 -  
432 -/**  
433 * the common message used free the payload in common way. 433 * the common message used free the payload in common way.
434 */ 434 */
435 class SrsCommonMessage : public SrsMessage 435 class SrsCommonMessage : public SrsMessage