正在显示
6 个修改的文件
包含
36 行增加
和
24 行删除
1 | # the listen ports, split by space. | 1 | # the listen ports, split by space. |
2 | -listen 1935; | 2 | +listen 1936; |
3 | # the default chunk size is 128, max is 65536, | 3 | # the default chunk size is 128, max is 65536, |
4 | # some client does not support chunk size change, | 4 | # some client does not support chunk size change, |
5 | # however, most clients supports it and it can improve | 5 | # however, most clients supports it and it can improve |
@@ -10,7 +10,7 @@ chunk_size 65000; | @@ -10,7 +10,7 @@ chunk_size 65000; | ||
10 | # for which cannot identify the required vhost. | 10 | # for which cannot identify the required vhost. |
11 | vhost __defaultVhost__ { | 11 | vhost __defaultVhost__ { |
12 | enabled on; | 12 | enabled on; |
13 | - gop_cache on; | 13 | + gop_cache off; |
14 | hls on; | 14 | hls on; |
15 | hls_path ./objs/nginx/html; | 15 | hls_path ./objs/nginx/html; |
16 | hls_fragment 5; | 16 | hls_fragment 5; |
@@ -384,7 +384,7 @@ int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg, | @@ -384,7 +384,7 @@ int SrsClient::process_publish_message(SrsSource* source, SrsCommonMessage* msg, | ||
384 | int ret = ERROR_SUCCESS; | 384 | int ret = ERROR_SUCCESS; |
385 | 385 | ||
386 | // process audio packet | 386 | // process audio packet |
387 | - if (msg->header.is_audio()) { | 387 | + if (false && msg->header.is_audio()) { |
388 | if ((ret = source->on_audio(msg)) != ERROR_SUCCESS) { | 388 | if ((ret = source->on_audio(msg)) != ERROR_SUCCESS) { |
389 | srs_error("source process audio message failed. ret=%d", ret); | 389 | srs_error("source process audio message failed. ret=%d", ret); |
390 | return ret; | 390 | return ret; |
@@ -41,7 +41,7 @@ void SrsCodecBuffer::append(void* data, int len) | @@ -41,7 +41,7 @@ void SrsCodecBuffer::append(void* data, int len) | ||
41 | { | 41 | { |
42 | srs_assert(data); | 42 | srs_assert(data); |
43 | srs_assert(len > 0); | 43 | srs_assert(len > 0); |
44 | - | 44 | + |
45 | bytes = (char*)realloc(bytes, size + len); | 45 | bytes = (char*)realloc(bytes, size + len); |
46 | memcpy(bytes + size, data, len); | 46 | memcpy(bytes + size, data, len); |
47 | size += len; | 47 | size += len; |
@@ -1356,11 +1356,26 @@ bool SrsSharedPtrMessage::can_decode() | @@ -1356,11 +1356,26 @@ bool SrsSharedPtrMessage::can_decode() | ||
1356 | return false; | 1356 | return false; |
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | -int SrsSharedPtrMessage::initialize(ISrsMessage* msg, char* payload, int size) | 1359 | +int SrsSharedPtrMessage::initialize(SrsCommonMessage* source) |
1360 | { | 1360 | { |
1361 | int ret = ERROR_SUCCESS; | 1361 | int ret = ERROR_SUCCESS; |
1362 | 1362 | ||
1363 | - srs_assert(msg != NULL); | 1363 | + if ((ret = initialize(source, (char*)source->payload, source->size)) != ERROR_SUCCESS) { |
1364 | + return ret; | ||
1365 | + } | ||
1366 | + | ||
1367 | + // detach the payload from source | ||
1368 | + source->payload = NULL; | ||
1369 | + source->size = 0; | ||
1370 | + | ||
1371 | + return ret; | ||
1372 | +} | ||
1373 | + | ||
1374 | +int SrsSharedPtrMessage::initialize(SrsCommonMessage* source, char* payload, int size) | ||
1375 | +{ | ||
1376 | + int ret = ERROR_SUCCESS; | ||
1377 | + | ||
1378 | + srs_assert(source != NULL); | ||
1364 | if (ptr) { | 1379 | if (ptr) { |
1365 | ret = ERROR_SYSTEM_ASSERT_FAILED; | 1380 | ret = ERROR_SYSTEM_ASSERT_FAILED; |
1366 | srs_error("should not set the payload twice. ret=%d", ret); | 1381 | srs_error("should not set the payload twice. ret=%d", ret); |
@@ -1369,20 +1384,18 @@ int SrsSharedPtrMessage::initialize(ISrsMessage* msg, char* payload, int size) | @@ -1369,20 +1384,18 @@ int SrsSharedPtrMessage::initialize(ISrsMessage* msg, char* payload, int size) | ||
1369 | return ret; | 1384 | return ret; |
1370 | } | 1385 | } |
1371 | 1386 | ||
1372 | - header = msg->header; | 1387 | + header = source->header; |
1373 | header.payload_length = size; | 1388 | header.payload_length = size; |
1374 | 1389 | ||
1375 | ptr = new SrsSharedPtr(); | 1390 | ptr = new SrsSharedPtr(); |
1376 | 1391 | ||
1377 | - // should copy the payload once | ||
1378 | - // TODO: maybe can directly attach the common message. | ||
1379 | - ptr->payload = new char[size]; | ||
1380 | - memcpy(ptr->payload, payload, size); | 1392 | + // direct attach the data of common message. |
1393 | + ptr->payload = payload; | ||
1381 | ptr->size = size; | 1394 | ptr->size = size; |
1382 | 1395 | ||
1383 | - if (msg->header.is_video()) { | 1396 | + if (source->header.is_video()) { |
1384 | ptr->perfer_cid = RTMP_CID_Video; | 1397 | ptr->perfer_cid = RTMP_CID_Video; |
1385 | - } else if (msg->header.is_audio()) { | 1398 | + } else if (source->header.is_audio()) { |
1386 | ptr->perfer_cid = RTMP_CID_Audio; | 1399 | ptr->perfer_cid = RTMP_CID_Audio; |
1387 | } else { | 1400 | } else { |
1388 | ptr->perfer_cid = RTMP_CID_OverConnection2; | 1401 | ptr->perfer_cid = RTMP_CID_OverConnection2; |
@@ -375,8 +375,15 @@ public: | @@ -375,8 +375,15 @@ public: | ||
375 | public: | 375 | public: |
376 | /** | 376 | /** |
377 | * set the shared payload. | 377 | * set the shared payload. |
378 | + * we will detach the payload of source, | ||
379 | + * so ensure donot use it before. | ||
378 | */ | 380 | */ |
379 | - virtual int initialize(ISrsMessage* msg, char* payload, int size); | 381 | + virtual int initialize(SrsCommonMessage* source); |
382 | + /** | ||
383 | + * set the shared payload. | ||
384 | + * we will use the payload, donot use the payload of source. | ||
385 | + */ | ||
386 | + virtual int initialize(SrsCommonMessage* source, char* payload, int size); | ||
380 | virtual SrsSharedPtrMessage* copy(); | 387 | virtual SrsSharedPtrMessage* copy(); |
381 | public: | 388 | public: |
382 | /** | 389 | /** |
@@ -370,7 +370,7 @@ int SrsSource::on_audio(SrsCommonMessage* audio) | @@ -370,7 +370,7 @@ int SrsSource::on_audio(SrsCommonMessage* audio) | ||
370 | 370 | ||
371 | SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); | 371 | SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); |
372 | SrsAutoFree(SrsSharedPtrMessage, msg, false); | 372 | SrsAutoFree(SrsSharedPtrMessage, msg, false); |
373 | - if ((ret = msg->initialize(audio, (char*)audio->payload, audio->size)) != ERROR_SUCCESS) { | 373 | + if ((ret = msg->initialize(audio)) != ERROR_SUCCESS) { |
374 | srs_error("initialize the audio failed. ret=%d", ret); | 374 | srs_error("initialize the audio failed. ret=%d", ret); |
375 | return ret; | 375 | return ret; |
376 | } | 376 | } |
@@ -383,10 +383,6 @@ int SrsSource::on_audio(SrsCommonMessage* audio) | @@ -383,10 +383,6 @@ int SrsSource::on_audio(SrsCommonMessage* audio) | ||
383 | } | 383 | } |
384 | #endif | 384 | #endif |
385 | 385 | ||
386 | - // detach the original audio | ||
387 | - audio->payload = NULL; | ||
388 | - audio->size = 0; | ||
389 | - | ||
390 | // copy to all consumer | 386 | // copy to all consumer |
391 | std::vector<SrsConsumer*>::iterator it; | 387 | std::vector<SrsConsumer*>::iterator it; |
392 | for (it = consumers.begin(); it != consumers.end(); ++it) { | 388 | for (it = consumers.begin(); it != consumers.end(); ++it) { |
@@ -422,7 +418,7 @@ int SrsSource::on_video(SrsCommonMessage* video) | @@ -422,7 +418,7 @@ int SrsSource::on_video(SrsCommonMessage* video) | ||
422 | 418 | ||
423 | SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); | 419 | SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); |
424 | SrsAutoFree(SrsSharedPtrMessage, msg, false); | 420 | SrsAutoFree(SrsSharedPtrMessage, msg, false); |
425 | - if ((ret = msg->initialize(video, (char*)video->payload, video->size)) != ERROR_SUCCESS) { | 421 | + if ((ret = msg->initialize(video)) != ERROR_SUCCESS) { |
426 | srs_error("initialize the video failed. ret=%d", ret); | 422 | srs_error("initialize the video failed. ret=%d", ret); |
427 | return ret; | 423 | return ret; |
428 | } | 424 | } |
@@ -435,10 +431,6 @@ int SrsSource::on_video(SrsCommonMessage* video) | @@ -435,10 +431,6 @@ int SrsSource::on_video(SrsCommonMessage* video) | ||
435 | } | 431 | } |
436 | #endif | 432 | #endif |
437 | 433 | ||
438 | - // detach the original audio | ||
439 | - video->payload = NULL; | ||
440 | - video->size = 0; | ||
441 | - | ||
442 | // copy to all consumer | 434 | // copy to all consumer |
443 | std::vector<SrsConsumer*>::iterator it; | 435 | std::vector<SrsConsumer*>::iterator it; |
444 | for (it = consumers.begin(); it != consumers.end(); ++it) { | 436 | for (it = consumers.begin(); it != consumers.end(); ++it) { |
-
请 注册 或 登录 后发表评论