正在显示
6 个修改的文件
包含
63 行增加
和
8 行删除
| @@ -440,7 +440,7 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socke | @@ -440,7 +440,7 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socke | ||
| 440 | "srs_app_http" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" | 440 | "srs_app_http" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" |
| 441 | "srs_app_config" "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" | 441 | "srs_app_config" "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" |
| 442 | "srs_app_http_conn" "srs_app_http_hooks" "srs_app_json" "srs_app_ingest" | 442 | "srs_app_http_conn" "srs_app_http_hooks" "srs_app_json" "srs_app_ingest" |
| 443 | - "srs_app_ffmpeg" "srs_app_utility" "srs_app_flv") | 443 | + "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr") |
| 444 | APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh | 444 | APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh |
| 445 | APP_OBJS="${MODULE_OBJS[@]}" | 445 | APP_OBJS="${MODULE_OBJS[@]}" |
| 446 | # | 446 | # |
| @@ -21,7 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | @@ -21,7 +21,7 @@ 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. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | -#include <srs_app_flv.hpp> | 24 | +#include <srs_app_dvr.hpp> |
| 25 | 25 | ||
| 26 | #ifdef SRS_AUTO_DVR | 26 | #ifdef SRS_AUTO_DVR |
| 27 | 27 |
| @@ -21,11 +21,11 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | @@ -21,11 +21,11 @@ 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. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | -#ifndef SRS_APP_FLV_HPP | ||
| 25 | -#define SRS_APP_FLV_HPP | 24 | +#ifndef SRS_APP_DVR_HPP |
| 25 | +#define SRS_APP_DVR_HPP | ||
| 26 | 26 | ||
| 27 | /* | 27 | /* |
| 28 | -#include <srs_app_flv.hpp> | 28 | +#include <srs_app_dvr.hpp> |
| 29 | */ | 29 | */ |
| 30 | #include <srs_core.hpp> | 30 | #include <srs_core.hpp> |
| 31 | 31 |
| @@ -36,6 +36,7 @@ using namespace std; | @@ -36,6 +36,7 @@ using namespace std; | ||
| 36 | #include <srs_app_config.hpp> | 36 | #include <srs_app_config.hpp> |
| 37 | #include <srs_app_encoder.hpp> | 37 | #include <srs_app_encoder.hpp> |
| 38 | #include <srs_protocol_rtmp.hpp> | 38 | #include <srs_protocol_rtmp.hpp> |
| 39 | +#include <srs_app_dvr.hpp> | ||
| 39 | 40 | ||
| 40 | #define CONST_MAX_JITTER_MS 500 | 41 | #define CONST_MAX_JITTER_MS 500 |
| 41 | #define DEFAULT_FRAME_TIME_MS 40 | 42 | #define DEFAULT_FRAME_TIME_MS 40 |
| @@ -431,6 +432,9 @@ SrsSource::SrsSource(SrsRequest* _req) | @@ -431,6 +432,9 @@ SrsSource::SrsSource(SrsRequest* _req) | ||
| 431 | #ifdef SRS_AUTO_HLS | 432 | #ifdef SRS_AUTO_HLS |
| 432 | hls = new SrsHls(this); | 433 | hls = new SrsHls(this); |
| 433 | #endif | 434 | #endif |
| 435 | +#ifdef SRS_AUTO_DVR | ||
| 436 | + dvr = new SrsDvr(this); | ||
| 437 | +#endif | ||
| 434 | #ifdef SRS_AUTO_TRANSCODE | 438 | #ifdef SRS_AUTO_TRANSCODE |
| 435 | encoder = new SrsEncoder(); | 439 | encoder = new SrsEncoder(); |
| 436 | #endif | 440 | #endif |
| @@ -477,6 +481,9 @@ SrsSource::~SrsSource() | @@ -477,6 +481,9 @@ SrsSource::~SrsSource() | ||
| 477 | #ifdef SRS_AUTO_HLS | 481 | #ifdef SRS_AUTO_HLS |
| 478 | srs_freep(hls); | 482 | srs_freep(hls); |
| 479 | #endif | 483 | #endif |
| 484 | +#ifdef SRS_AUTO_DVR | ||
| 485 | + srs_freep(dvr); | ||
| 486 | +#endif | ||
| 480 | #ifdef SRS_AUTO_TRANSCODE | 487 | #ifdef SRS_AUTO_TRANSCODE |
| 481 | srs_freep(encoder); | 488 | srs_freep(encoder); |
| 482 | #endif | 489 | #endif |
| @@ -678,6 +685,13 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | @@ -678,6 +685,13 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | ||
| 678 | } | 685 | } |
| 679 | #endif | 686 | #endif |
| 680 | 687 | ||
| 688 | +#ifdef SRS_AUTO_DVR | ||
| 689 | + if (metadata && (ret = dvr->on_meta_data(metadata->metadata)) != ERROR_SUCCESS) { | ||
| 690 | + srs_error("dvr process onMetaData message failed. ret=%d", ret); | ||
| 691 | + return ret; | ||
| 692 | + } | ||
| 693 | +#endif | ||
| 694 | + | ||
| 681 | metadata->metadata->set("server", SrsAmf0Any::str(RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")")); | 695 | metadata->metadata->set("server", SrsAmf0Any::str(RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")")); |
| 682 | metadata->metadata->set("contributor", SrsAmf0Any::str(RTMP_SIG_SRS_PRIMARY_AUTHROS)); | 696 | metadata->metadata->set("contributor", SrsAmf0Any::str(RTMP_SIG_SRS_PRIMARY_AUTHROS)); |
| 683 | 697 | ||
| @@ -772,6 +786,18 @@ int SrsSource::on_audio(SrsCommonMessage* audio) | @@ -772,6 +786,18 @@ int SrsSource::on_audio(SrsCommonMessage* audio) | ||
| 772 | } | 786 | } |
| 773 | #endif | 787 | #endif |
| 774 | 788 | ||
| 789 | +#ifdef SRS_AUTO_DVR | ||
| 790 | + if ((ret = dvr->on_audio(msg->copy())) != ERROR_SUCCESS) { | ||
| 791 | + srs_warn("dvr process audio message failed, ignore and disable dvr. ret=%d", ret); | ||
| 792 | + | ||
| 793 | + // unpublish, ignore ret. | ||
| 794 | + dvr->on_unpublish(); | ||
| 795 | + | ||
| 796 | + // ignore. | ||
| 797 | + ret = ERROR_SUCCESS; | ||
| 798 | + } | ||
| 799 | +#endif | ||
| 800 | + | ||
| 775 | // copy to all consumer | 801 | // copy to all consumer |
| 776 | if (true) { | 802 | if (true) { |
| 777 | std::vector<SrsConsumer*>::iterator it; | 803 | std::vector<SrsConsumer*>::iterator it; |
| @@ -849,6 +875,18 @@ int SrsSource::on_video(SrsCommonMessage* video) | @@ -849,6 +875,18 @@ int SrsSource::on_video(SrsCommonMessage* video) | ||
| 849 | } | 875 | } |
| 850 | #endif | 876 | #endif |
| 851 | 877 | ||
| 878 | +#ifdef SRS_AUTO_DVR | ||
| 879 | + if ((ret = dvr->on_video(msg->copy())) != ERROR_SUCCESS) { | ||
| 880 | + srs_warn("dvr process video message failed, ignore and disable dvr. ret=%d", ret); | ||
| 881 | + | ||
| 882 | + // unpublish, ignore ret. | ||
| 883 | + dvr->on_unpublish(); | ||
| 884 | + | ||
| 885 | + // ignore. | ||
| 886 | + ret = ERROR_SUCCESS; | ||
| 887 | + } | ||
| 888 | +#endif | ||
| 889 | + | ||
| 852 | // copy to all consumer | 890 | // copy to all consumer |
| 853 | if (true) { | 891 | if (true) { |
| 854 | std::vector<SrsConsumer*>::iterator it; | 892 | std::vector<SrsConsumer*>::iterator it; |
| @@ -932,6 +970,13 @@ int SrsSource::on_publish(SrsRequest* _req) | @@ -932,6 +970,13 @@ int SrsSource::on_publish(SrsRequest* _req) | ||
| 932 | return ret; | 970 | return ret; |
| 933 | } | 971 | } |
| 934 | #endif | 972 | #endif |
| 973 | + | ||
| 974 | +#ifdef SRS_AUTO_DVR | ||
| 975 | + if ((ret = dvr->on_publish(req)) != ERROR_SUCCESS) { | ||
| 976 | + srs_error("start dvr failed. ret=%d", ret); | ||
| 977 | + return ret; | ||
| 978 | + } | ||
| 979 | +#endif | ||
| 935 | 980 | ||
| 936 | return ret; | 981 | return ret; |
| 937 | } | 982 | } |
| @@ -945,10 +990,13 @@ void SrsSource::on_unpublish() | @@ -945,10 +990,13 @@ void SrsSource::on_unpublish() | ||
| 945 | encoder->on_unpublish(); | 990 | encoder->on_unpublish(); |
| 946 | #endif | 991 | #endif |
| 947 | 992 | ||
| 948 | - // TODO: HLS should continue previous sequence and stream. | ||
| 949 | #ifdef SRS_AUTO_HLS | 993 | #ifdef SRS_AUTO_HLS |
| 950 | hls->on_unpublish(); | 994 | hls->on_unpublish(); |
| 951 | #endif | 995 | #endif |
| 996 | + | ||
| 997 | +#ifdef SRS_AUTO_DVR | ||
| 998 | + dvr->on_unpublish(); | ||
| 999 | +#endif | ||
| 952 | 1000 | ||
| 953 | gop_cache->clear(); | 1001 | gop_cache->clear(); |
| 954 | 1002 |
| @@ -46,6 +46,9 @@ class SrsRequest; | @@ -46,6 +46,9 @@ class SrsRequest; | ||
| 46 | #ifdef SRS_AUTO_HLS | 46 | #ifdef SRS_AUTO_HLS |
| 47 | class SrsHls; | 47 | class SrsHls; |
| 48 | #endif | 48 | #endif |
| 49 | +#ifdef SRS_AUTO_DVR | ||
| 50 | +class SrsDvr; | ||
| 51 | +#endif | ||
| 49 | #ifdef SRS_AUTO_TRANSCODE | 52 | #ifdef SRS_AUTO_TRANSCODE |
| 50 | class SrsEncoder; | 53 | class SrsEncoder; |
| 51 | #endif | 54 | #endif |
| @@ -223,6 +226,10 @@ private: | @@ -223,6 +226,10 @@ private: | ||
| 223 | #ifdef SRS_AUTO_HLS | 226 | #ifdef SRS_AUTO_HLS |
| 224 | SrsHls* hls; | 227 | SrsHls* hls; |
| 225 | #endif | 228 | #endif |
| 229 | + // dvr handler. | ||
| 230 | +#ifdef SRS_AUTO_DVR | ||
| 231 | + SrsDvr* dvr; | ||
| 232 | +#endif | ||
| 226 | // transcoding handler. | 233 | // transcoding handler. |
| 227 | #ifdef SRS_AUTO_TRANSCODE | 234 | #ifdef SRS_AUTO_TRANSCODE |
| 228 | SrsEncoder* encoder; | 235 | SrsEncoder* encoder; |
| @@ -47,12 +47,12 @@ file | @@ -47,12 +47,12 @@ file | ||
| 47 | ..\app\srs_app_conn.cpp, | 47 | ..\app\srs_app_conn.cpp, |
| 48 | ..\app\srs_app_config.hpp, | 48 | ..\app\srs_app_config.hpp, |
| 49 | ..\app\srs_app_config.cpp, | 49 | ..\app\srs_app_config.cpp, |
| 50 | + ..\app\srs_app_dvr.hpp, | ||
| 51 | + ..\app\srs_app_dvr.cpp, | ||
| 50 | ..\app\srs_app_encoder.hpp, | 52 | ..\app\srs_app_encoder.hpp, |
| 51 | ..\app\srs_app_encoder.cpp, | 53 | ..\app\srs_app_encoder.cpp, |
| 52 | ..\app\srs_app_ffmpeg.hpp, | 54 | ..\app\srs_app_ffmpeg.hpp, |
| 53 | ..\app\srs_app_ffmpeg.cpp, | 55 | ..\app\srs_app_ffmpeg.cpp, |
| 54 | - ..\app\srs_app_flv.hpp, | ||
| 55 | - ..\app\srs_app_flv.cpp, | ||
| 56 | ..\app\srs_app_forward.hpp, | 56 | ..\app\srs_app_forward.hpp, |
| 57 | ..\app\srs_app_forward.cpp, | 57 | ..\app\srs_app_forward.cpp, |
| 58 | ..\app\srs_app_hls.hpp, | 58 | ..\app\srs_app_hls.hpp, |
-
请 注册 或 登录 后发表评论