正在显示
16 个修改的文件
包含
25 行增加
和
553 行删除
| @@ -963,12 +963,6 @@ vhost with-hls.srs.com { | @@ -963,12 +963,6 @@ vhost with-hls.srs.com { | ||
| 963 | # @see https://github.com/ossrs/srs/issues/264 | 963 | # @see https://github.com/ossrs/srs/issues/264 |
| 964 | # default: continue | 964 | # default: continue |
| 965 | hls_on_error continue; | 965 | hls_on_error continue; |
| 966 | - # the hls storage: disk, ram or both. | ||
| 967 | - # disk, to write hls m3u8/ts to disk. | ||
| 968 | - # ram, serve m3u8/ts in memory, which use embedded http server to delivery. | ||
| 969 | - # both, disk and ram. | ||
| 970 | - # default: disk | ||
| 971 | - hls_storage disk; | ||
| 972 | # the hls output path. | 966 | # the hls output path. |
| 973 | # the m3u8 file is configured by hls_path/hls_m3u8_file, the default is: | 967 | # the m3u8 file is configured by hls_path/hls_m3u8_file, the default is: |
| 974 | # ./objs/nginx/html/[app]/[stream].m3u8 | 968 | # ./objs/nginx/html/[app]/[stream].m3u8 |
| @@ -1017,13 +1011,6 @@ vhost with-hls.srs.com { | @@ -1017,13 +1011,6 @@ vhost with-hls.srs.com { | ||
| 1017 | # ... | 1011 | # ... |
| 1018 | # optional, default to empty string. | 1012 | # optional, default to empty string. |
| 1019 | hls_entry_prefix http://your-server; | 1013 | hls_entry_prefix http://your-server; |
| 1020 | - # the hls mount for hls_storage ram, | ||
| 1021 | - # which use srs embedded http server to delivery HLS, | ||
| 1022 | - # where the mount specifies the HTTP url to mount. | ||
| 1023 | - # @see the mount of http_remux. | ||
| 1024 | - # @remark the hls_mount must endswith .m3u8. | ||
| 1025 | - # default: [vhost]/[app]/[stream].m3u8 | ||
| 1026 | - hls_mount [vhost]/[app]/[stream].m3u8; | ||
| 1027 | # the default audio codec of hls. | 1014 | # the default audio codec of hls. |
| 1028 | # when codec changed, write the PAT/PMT table, but maybe ok util next ts. | 1015 | # when codec changed, write the PAT/PMT table, but maybe ok util next ts. |
| 1029 | # so user can set the default codec for mp3. | 1016 | # so user can set the default codec for mp3. |
trunk/conf/ram.hls.conf
已删除
100644 → 0
| 1 | -# the config for srs to delivery hls | ||
| 2 | -# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleHLS | ||
| 3 | -# @see full.conf for detail config. | ||
| 4 | - | ||
| 5 | -listen 1935; | ||
| 6 | -max_connections 1000; | ||
| 7 | -http_server { | ||
| 8 | - enabled on; | ||
| 9 | - listen 8080; | ||
| 10 | - dir ./objs/nginx/html; | ||
| 11 | -} | ||
| 12 | -vhost __defaultVhost__ { | ||
| 13 | - hls { | ||
| 14 | - enabled on; | ||
| 15 | - hls_fragment 10; | ||
| 16 | - hls_window 60; | ||
| 17 | - hls_storage ram; | ||
| 18 | - hls_mount /[app]/[stream].m3u8; | ||
| 19 | - } | ||
| 20 | -} |
| @@ -319,7 +319,6 @@ | @@ -319,7 +319,6 @@ | ||
| 319 | 3C1EE6C91AB1080900576EE9 /* origin.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = origin.conf; path = ../../../conf/origin.conf; sourceTree = "<group>"; }; | 319 | 3C1EE6C91AB1080900576EE9 /* origin.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = origin.conf; path = ../../../conf/origin.conf; sourceTree = "<group>"; }; |
| 320 | 3C1EE6CA1AB1080900576EE9 /* push.mpegts.over.udp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = push.mpegts.over.udp.conf; path = ../../../conf/push.mpegts.over.udp.conf; sourceTree = "<group>"; }; | 320 | 3C1EE6CA1AB1080900576EE9 /* push.mpegts.over.udp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = push.mpegts.over.udp.conf; path = ../../../conf/push.mpegts.over.udp.conf; sourceTree = "<group>"; }; |
| 321 | 3C1EE6CB1AB1080900576EE9 /* push.rtsp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = push.rtsp.conf; path = ../../../conf/push.rtsp.conf; sourceTree = "<group>"; }; | 321 | 3C1EE6CB1AB1080900576EE9 /* push.rtsp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = push.rtsp.conf; path = ../../../conf/push.rtsp.conf; sourceTree = "<group>"; }; |
| 322 | - 3C1EE6CC1AB1080900576EE9 /* ram.hls.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ram.hls.conf; path = ../../../conf/ram.hls.conf; sourceTree = "<group>"; }; | ||
| 323 | 3C1EE6CD1AB1080900576EE9 /* realtime.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = realtime.conf; path = ../../../conf/realtime.conf; sourceTree = "<group>"; }; | 322 | 3C1EE6CD1AB1080900576EE9 /* realtime.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = realtime.conf; path = ../../../conf/realtime.conf; sourceTree = "<group>"; }; |
| 324 | 3C1EE6CE1AB1080900576EE9 /* rtmp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = rtmp.conf; path = ../../../conf/rtmp.conf; sourceTree = "<group>"; }; | 323 | 3C1EE6CE1AB1080900576EE9 /* rtmp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = rtmp.conf; path = ../../../conf/rtmp.conf; sourceTree = "<group>"; }; |
| 325 | 3C1EE6CF1AB1080900576EE9 /* security.deny.publish.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = security.deny.publish.conf; path = ../../../conf/security.deny.publish.conf; sourceTree = "<group>"; }; | 324 | 3C1EE6CF1AB1080900576EE9 /* security.deny.publish.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = security.deny.publish.conf; path = ../../../conf/security.deny.publish.conf; sourceTree = "<group>"; }; |
| @@ -755,7 +754,6 @@ | @@ -755,7 +754,6 @@ | ||
| 755 | 3C8280281BAFF896004A1794 /* push.flv.conf */, | 754 | 3C8280281BAFF896004A1794 /* push.flv.conf */, |
| 756 | 3C1EE6CA1AB1080900576EE9 /* push.mpegts.over.udp.conf */, | 755 | 3C1EE6CA1AB1080900576EE9 /* push.mpegts.over.udp.conf */, |
| 757 | 3C1EE6CB1AB1080900576EE9 /* push.rtsp.conf */, | 756 | 3C1EE6CB1AB1080900576EE9 /* push.rtsp.conf */, |
| 758 | - 3C1EE6CC1AB1080900576EE9 /* ram.hls.conf */, | ||
| 759 | 3C1EE6CD1AB1080900576EE9 /* realtime.conf */, | 757 | 3C1EE6CD1AB1080900576EE9 /* realtime.conf */, |
| 760 | 3C1EE6CE1AB1080900576EE9 /* rtmp.conf */, | 758 | 3C1EE6CE1AB1080900576EE9 /* rtmp.conf */, |
| 761 | 3C1EE6CF1AB1080900576EE9 /* security.deny.publish.conf */, | 759 | 3C1EE6CF1AB1080900576EE9 /* security.deny.publish.conf */, |
| @@ -3910,6 +3910,11 @@ int SrsConfig::check_config() | @@ -3910,6 +3910,11 @@ int SrsConfig::check_config() | ||
| 3910 | srs_error("unsupported vhost hls directive %s, ret=%d", m.c_str(), ret); | 3910 | srs_error("unsupported vhost hls directive %s, ret=%d", m.c_str(), ret); |
| 3911 | return ret; | 3911 | return ret; |
| 3912 | } | 3912 | } |
| 3913 | + | ||
| 3914 | + // TODO: FIXME: remove it in future. | ||
| 3915 | + if (m == "hls_storage" || m == "hls_mount") { | ||
| 3916 | + srs_warn("HLS RAM is removed from SRS2 to SRS3+, please read https://github.com/ossrs/srs/issues/513."); | ||
| 3917 | + } | ||
| 3913 | } | 3918 | } |
| 3914 | } else if (n == "http_hooks") { | 3919 | } else if (n == "http_hooks") { |
| 3915 | for (int j = 0; j < (int)conf->directives.size(); j++) { | 3920 | for (int j = 0; j < (int)conf->directives.size(); j++) { |
| @@ -6075,40 +6080,6 @@ string SrsConfig::get_hls_on_error(string vhost) | @@ -6075,40 +6080,6 @@ string SrsConfig::get_hls_on_error(string vhost) | ||
| 6075 | return conf->arg0(); | 6080 | return conf->arg0(); |
| 6076 | } | 6081 | } |
| 6077 | 6082 | ||
| 6078 | -string SrsConfig::get_hls_storage(string vhost) | ||
| 6079 | -{ | ||
| 6080 | - static string DEFAULT = "disk"; | ||
| 6081 | - | ||
| 6082 | - SrsConfDirective* conf = get_hls(vhost); | ||
| 6083 | - if (!conf) { | ||
| 6084 | - return DEFAULT; | ||
| 6085 | - } | ||
| 6086 | - | ||
| 6087 | - conf = conf->get("hls_storage"); | ||
| 6088 | - if (!conf || conf->arg0().empty()) { | ||
| 6089 | - return DEFAULT; | ||
| 6090 | - } | ||
| 6091 | - | ||
| 6092 | - return conf->arg0(); | ||
| 6093 | -} | ||
| 6094 | - | ||
| 6095 | -string SrsConfig::get_hls_mount(string vhost) | ||
| 6096 | -{ | ||
| 6097 | - static string DEFAULT = "[vhost]/[app]/[stream].m3u8"; | ||
| 6098 | - | ||
| 6099 | - SrsConfDirective* conf = get_hls(vhost); | ||
| 6100 | - if (!conf) { | ||
| 6101 | - return DEFAULT; | ||
| 6102 | - } | ||
| 6103 | - | ||
| 6104 | - conf = conf->get("hls_mount"); | ||
| 6105 | - if (!conf || conf->arg0().empty()) { | ||
| 6106 | - return DEFAULT; | ||
| 6107 | - } | ||
| 6108 | - | ||
| 6109 | - return conf->arg0(); | ||
| 6110 | -} | ||
| 6111 | - | ||
| 6112 | string SrsConfig::get_hls_acodec(string vhost) | 6083 | string SrsConfig::get_hls_acodec(string vhost) |
| 6113 | { | 6084 | { |
| 6114 | static string DEFAULT = "aac"; | 6085 | static string DEFAULT = "aac"; |
| @@ -1184,14 +1184,6 @@ public: | @@ -1184,14 +1184,6 @@ public: | ||
| 1184 | */ | 1184 | */ |
| 1185 | virtual std::string get_hls_on_error(std::string vhost); | 1185 | virtual std::string get_hls_on_error(std::string vhost); |
| 1186 | /** | 1186 | /** |
| 1187 | - * get the HLS storage type. | ||
| 1188 | - */ | ||
| 1189 | - virtual std::string get_hls_storage(std::string vhost); | ||
| 1190 | - /** | ||
| 1191 | - * get the HLS mount url for HTTP server. | ||
| 1192 | - */ | ||
| 1193 | - virtual std::string get_hls_mount(std::string vhost); | ||
| 1194 | - /** | ||
| 1195 | * get the HLS default audio codec. | 1187 | * get the HLS default audio codec. |
| 1196 | */ | 1188 | */ |
| 1197 | virtual std::string get_hls_acodec(std::string vhost); | 1189 | virtual std::string get_hls_acodec(std::string vhost); |
| @@ -61,14 +61,6 @@ using namespace std; | @@ -61,14 +61,6 @@ using namespace std; | ||
| 61 | // reset the piece id when deviation overflow this. | 61 | // reset the piece id when deviation overflow this. |
| 62 | #define SRS_JUMP_WHEN_PIECE_DEVIATION 20 | 62 | #define SRS_JUMP_WHEN_PIECE_DEVIATION 20 |
| 63 | 63 | ||
| 64 | -ISrsHlsHandler::ISrsHlsHandler() | ||
| 65 | -{ | ||
| 66 | -} | ||
| 67 | - | ||
| 68 | -ISrsHlsHandler::~ISrsHlsHandler() | ||
| 69 | -{ | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | /** | 64 | /** |
| 73 | * * the HLS section, only available when HLS enabled. | 65 | * * the HLS section, only available when HLS enabled. |
| 74 | * */ | 66 | * */ |
| @@ -294,7 +286,6 @@ string SrsDvrAsyncCallOnHlsNotify::to_string() | @@ -294,7 +286,6 @@ string SrsDvrAsyncCallOnHlsNotify::to_string() | ||
| 294 | SrsHlsMuxer::SrsHlsMuxer() | 286 | SrsHlsMuxer::SrsHlsMuxer() |
| 295 | { | 287 | { |
| 296 | req = NULL; | 288 | req = NULL; |
| 297 | - handler = NULL; | ||
| 298 | hls_fragment = hls_window = 0; | 289 | hls_fragment = hls_window = 0; |
| 299 | hls_aof_ratio = 1.0; | 290 | hls_aof_ratio = 1.0; |
| 300 | deviation_ts = 0; | 291 | deviation_ts = 0; |
| @@ -384,11 +375,9 @@ int SrsHlsMuxer::deviation() | @@ -384,11 +375,9 @@ int SrsHlsMuxer::deviation() | ||
| 384 | return deviation_ts; | 375 | return deviation_ts; |
| 385 | } | 376 | } |
| 386 | 377 | ||
| 387 | -int SrsHlsMuxer::initialize(ISrsHlsHandler* h) | 378 | +int SrsHlsMuxer::initialize() |
| 388 | { | 379 | { |
| 389 | int ret = ERROR_SUCCESS; | 380 | int ret = ERROR_SUCCESS; |
| 390 | - | ||
| 391 | - handler = h; | ||
| 392 | 381 | ||
| 393 | if ((ret = async->start()) != ERROR_SUCCESS) { | 382 | if ((ret = async->start()) != ERROR_SUCCESS) { |
| 394 | return ret; | 383 | return ret; |
| @@ -425,19 +414,10 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, | @@ -425,19 +414,10 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, | ||
| 425 | 414 | ||
| 426 | // when update config, reset the history target duration. | 415 | // when update config, reset the history target duration. |
| 427 | max_td = (int)(fragment * _srs_config->get_hls_td_ratio(r->vhost)); | 416 | max_td = (int)(fragment * _srs_config->get_hls_td_ratio(r->vhost)); |
| 428 | - | ||
| 429 | - std::string storage = _srs_config->get_hls_storage(r->vhost); | ||
| 430 | - if (storage == "ram") { | ||
| 431 | - should_write_cache = true; | ||
| 432 | - should_write_file = false; | ||
| 433 | - } else if (storage == "disk") { | ||
| 434 | - should_write_cache = false; | ||
| 435 | - should_write_file = true; | ||
| 436 | - } else { | ||
| 437 | - srs_assert(storage == "both"); | ||
| 438 | - should_write_cache = true; | ||
| 439 | - should_write_file = true; | ||
| 440 | - } | 417 | + |
| 418 | + // TODO: FIXME: refine better for SRS2 only support disk. | ||
| 419 | + should_write_cache = false; | ||
| 420 | + should_write_file = true; | ||
| 441 | 421 | ||
| 442 | // create m3u8 dir once. | 422 | // create m3u8 dir once. |
| 443 | m3u8_dir = srs_path_dirname(m3u8); | 423 | m3u8_dir = srs_path_dirname(m3u8); |
| @@ -756,13 +736,6 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -756,13 +736,6 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 756 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, | 736 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, |
| 757 | current->segment_start_dts); | 737 | current->segment_start_dts); |
| 758 | 738 | ||
| 759 | - // notify handler for update ts. | ||
| 760 | - srs_assert(current->writer); | ||
| 761 | - if (handler && (ret = handler->on_update_ts(req, current->uri, current->writer->cache())) != ERROR_SUCCESS) { | ||
| 762 | - srs_error("notify handler for update ts failed. ret=%d", ret); | ||
| 763 | - return ret; | ||
| 764 | - } | ||
| 765 | - | ||
| 766 | // close the muxer of finished segment. | 739 | // close the muxer of finished segment. |
| 767 | srs_freep(current->muxer); | 740 | srs_freep(current->muxer); |
| 768 | std::string full_path = current->full_path; | 741 | std::string full_path = current->full_path; |
| @@ -828,14 +801,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -828,14 +801,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 828 | srs_warn("cleanup unlink path failed, file=%s.", segment->full_path.c_str()); | 801 | srs_warn("cleanup unlink path failed, file=%s.", segment->full_path.c_str()); |
| 829 | } | 802 | } |
| 830 | } | 803 | } |
| 831 | - | ||
| 832 | - if (should_write_cache) { | ||
| 833 | - if ((ret = handler->on_remove_ts(req, segment->uri)) != ERROR_SUCCESS) { | ||
| 834 | - srs_warn("remove the ts from ram hls failed. ret=%d", ret); | ||
| 835 | - return ret; | ||
| 836 | - } | ||
| 837 | - } | ||
| 838 | - | 804 | + |
| 839 | srs_freep(segment); | 805 | srs_freep(segment); |
| 840 | } | 806 | } |
| 841 | segment_to_remove.clear(); | 807 | segment_to_remove.clear(); |
| @@ -957,12 +923,6 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file) | @@ -957,12 +923,6 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file) | ||
| 957 | return ret; | 923 | return ret; |
| 958 | } | 924 | } |
| 959 | srs_info("write m3u8 %s success.", m3u8_file.c_str()); | 925 | srs_info("write m3u8 %s success.", m3u8_file.c_str()); |
| 960 | - | ||
| 961 | - // notify handler for update m3u8. | ||
| 962 | - if (handler && (ret = handler->on_update_m3u8(req, writer.cache())) != ERROR_SUCCESS) { | ||
| 963 | - srs_error("notify handler for update m3u8 failed. ret=%d", ret); | ||
| 964 | - return ret; | ||
| 965 | - } | ||
| 966 | 926 | ||
| 967 | return ret; | 927 | return ret; |
| 968 | } | 928 | } |
| @@ -1171,7 +1131,6 @@ SrsHls::SrsHls() | @@ -1171,7 +1131,6 @@ SrsHls::SrsHls() | ||
| 1171 | { | 1131 | { |
| 1172 | req = NULL; | 1132 | req = NULL; |
| 1173 | source = NULL; | 1133 | source = NULL; |
| 1174 | - handler = NULL; | ||
| 1175 | 1134 | ||
| 1176 | hls_enabled = false; | 1135 | hls_enabled = false; |
| 1177 | hls_can_dispose = false; | 1136 | hls_can_dispose = false; |
| @@ -1243,15 +1202,14 @@ int SrsHls::cycle() | @@ -1243,15 +1202,14 @@ int SrsHls::cycle() | ||
| 1243 | return ret; | 1202 | return ret; |
| 1244 | } | 1203 | } |
| 1245 | 1204 | ||
| 1246 | -int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h, SrsRequest* r) | 1205 | +int SrsHls::initialize(SrsSource* s, SrsRequest* r) |
| 1247 | { | 1206 | { |
| 1248 | int ret = ERROR_SUCCESS; | 1207 | int ret = ERROR_SUCCESS; |
| 1249 | 1208 | ||
| 1250 | source = s; | 1209 | source = s; |
| 1251 | - handler = h; | ||
| 1252 | req = r; | 1210 | req = r; |
| 1253 | 1211 | ||
| 1254 | - if ((ret = muxer->initialize(h)) != ERROR_SUCCESS) { | 1212 | + if ((ret = muxer->initialize()) != ERROR_SUCCESS) { |
| 1255 | return ret; | 1213 | return ret; |
| 1256 | } | 1214 | } |
| 1257 | 1215 |
| @@ -54,39 +54,6 @@ class SrsTsCache; | @@ -54,39 +54,6 @@ class SrsTsCache; | ||
| 54 | class SrsTsContext; | 54 | class SrsTsContext; |
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| 57 | -* the handler for hls event. | ||
| 58 | -* for example, we use memory only hls for | ||
| 59 | -*/ | ||
| 60 | -class ISrsHlsHandler | ||
| 61 | -{ | ||
| 62 | -public: | ||
| 63 | - ISrsHlsHandler(); | ||
| 64 | - virtual ~ISrsHlsHandler(); | ||
| 65 | -public: | ||
| 66 | - /** | ||
| 67 | - * when publish stream | ||
| 68 | - */ | ||
| 69 | - virtual int on_hls_publish(SrsRequest* req) = 0; | ||
| 70 | - /** | ||
| 71 | - * when update the m3u8 file. | ||
| 72 | - */ | ||
| 73 | - virtual int on_update_m3u8(SrsRequest* r, std::string m3u8) = 0; | ||
| 74 | - /** | ||
| 75 | - * when reap new ts file. | ||
| 76 | - */ | ||
| 77 | - virtual int on_update_ts(SrsRequest* r, std::string uri, std::string ts) = 0; | ||
| 78 | - /** | ||
| 79 | - * when remove the specified ts file, | ||
| 80 | - * for the hls to remove the expired ts not in hls window. | ||
| 81 | - */ | ||
| 82 | - virtual int on_remove_ts(SrsRequest* r, std::string uri) = 0; | ||
| 83 | - /** | ||
| 84 | - * when unpublish stream | ||
| 85 | - */ | ||
| 86 | - virtual int on_hls_unpublish(SrsRequest* req) = 0; | ||
| 87 | -}; | ||
| 88 | - | ||
| 89 | -/** | ||
| 90 | * * the HLS section, only available when HLS enabled. | 57 | * * the HLS section, only available when HLS enabled. |
| 91 | * */ | 58 | * */ |
| 92 | #ifdef SRS_AUTO_HLS | 59 | #ifdef SRS_AUTO_HLS |
| @@ -239,8 +206,7 @@ private: | @@ -239,8 +206,7 @@ private: | ||
| 239 | std::string m3u8; | 206 | std::string m3u8; |
| 240 | std::string m3u8_url; | 207 | std::string m3u8_url; |
| 241 | private: | 208 | private: |
| 242 | - ISrsHlsHandler* handler; | ||
| 243 | - // TODO: FIXME: supports reload. | 209 | + // TODO: FIXME: remove it. |
| 244 | bool should_write_cache; | 210 | bool should_write_cache; |
| 245 | bool should_write_file; | 211 | bool should_write_file; |
| 246 | private: | 212 | private: |
| @@ -277,7 +243,7 @@ public: | @@ -277,7 +243,7 @@ public: | ||
| 277 | /** | 243 | /** |
| 278 | * initialize the hls muxer. | 244 | * initialize the hls muxer. |
| 279 | */ | 245 | */ |
| 280 | - virtual int initialize(ISrsHlsHandler* h); | 246 | + virtual int initialize(); |
| 281 | /** | 247 | /** |
| 282 | * when publish, update the config for muxer. | 248 | * when publish, update the config for muxer. |
| 283 | */ | 249 | */ |
| @@ -390,7 +356,6 @@ class SrsHls | @@ -390,7 +356,6 @@ class SrsHls | ||
| 390 | private: | 356 | private: |
| 391 | SrsHlsMuxer* muxer; | 357 | SrsHlsMuxer* muxer; |
| 392 | SrsHlsCache* hls_cache; | 358 | SrsHlsCache* hls_cache; |
| 393 | - ISrsHlsHandler* handler; | ||
| 394 | private: | 359 | private: |
| 395 | SrsRequest* req; | 360 | SrsRequest* req; |
| 396 | bool hls_enabled; | 361 | bool hls_enabled; |
| @@ -426,7 +391,7 @@ public: | @@ -426,7 +391,7 @@ public: | ||
| 426 | /** | 391 | /** |
| 427 | * initialize the hls by handler and source. | 392 | * initialize the hls by handler and source. |
| 428 | */ | 393 | */ |
| 429 | - virtual int initialize(SrsSource* s, ISrsHlsHandler* h, SrsRequest* r); | 394 | + virtual int initialize(SrsSource* s, SrsRequest* r); |
| 430 | /** | 395 | /** |
| 431 | * publish stream event, continue to write the m3u8, | 396 | * publish stream event, continue to write the m3u8, |
| 432 | * for the muxer object not destroyed. | 397 | * for the muxer object not destroyed. |
| @@ -1297,30 +1297,5 @@ void SrsHttpServer::http_unmount(SrsSource* s, SrsRequest* r) | @@ -1297,30 +1297,5 @@ void SrsHttpServer::http_unmount(SrsSource* s, SrsRequest* r) | ||
| 1297 | http_stream->http_unmount(s, r); | 1297 | http_stream->http_unmount(s, r); |
| 1298 | } | 1298 | } |
| 1299 | 1299 | ||
| 1300 | -int SrsHttpServer::mount_hls(SrsRequest* r) | ||
| 1301 | -{ | ||
| 1302 | - return http_stream->mount_hls(r); | ||
| 1303 | -} | ||
| 1304 | - | ||
| 1305 | -int SrsHttpServer::hls_update_m3u8(SrsRequest* r, std::string m3u8) | ||
| 1306 | -{ | ||
| 1307 | - return http_stream->hls_update_m3u8(r, m3u8); | ||
| 1308 | -} | ||
| 1309 | - | ||
| 1310 | -int SrsHttpServer::hls_update_ts(SrsRequest* r, std::string uri, std::string ts) | ||
| 1311 | -{ | ||
| 1312 | - return http_stream->hls_update_ts(r, uri, ts); | ||
| 1313 | -} | ||
| 1314 | - | ||
| 1315 | -int SrsHttpServer::hls_remove_ts(SrsRequest* r, std::string uri) | ||
| 1316 | -{ | ||
| 1317 | - return http_stream->hls_remove_ts(r, uri); | ||
| 1318 | -} | ||
| 1319 | - | ||
| 1320 | -void SrsHttpServer::unmount_hls(SrsRequest* r) | ||
| 1321 | -{ | ||
| 1322 | - http_stream->unmount_hls(r); | ||
| 1323 | -} | ||
| 1324 | - | ||
| 1325 | #endif | 1300 | #endif |
| 1326 | 1301 |
| @@ -417,13 +417,6 @@ public: | @@ -417,13 +417,6 @@ public: | ||
| 417 | public: | 417 | public: |
| 418 | virtual int http_mount(SrsSource* s, SrsRequest* r); | 418 | virtual int http_mount(SrsSource* s, SrsRequest* r); |
| 419 | virtual void http_unmount(SrsSource* s, SrsRequest* r); | 419 | virtual void http_unmount(SrsSource* s, SrsRequest* r); |
| 420 | -// hls stream | ||
| 421 | -public: | ||
| 422 | - virtual int mount_hls(SrsRequest* r); | ||
| 423 | - virtual int hls_update_m3u8(SrsRequest* r, std::string m3u8); | ||
| 424 | - virtual int hls_update_ts(SrsRequest* r, std::string uri, std::string ts); | ||
| 425 | - virtual int hls_remove_ts(SrsRequest* r, std::string uri); | ||
| 426 | - virtual void unmount_hls(SrsRequest* r); | ||
| 427 | }; | 420 | }; |
| 428 | 421 | ||
| 429 | #endif | 422 | #endif |
| @@ -764,22 +764,6 @@ SrsHttpStreamServer::~SrsHttpStreamServer() | @@ -764,22 +764,6 @@ SrsHttpStreamServer::~SrsHttpStreamServer() | ||
| 764 | } | 764 | } |
| 765 | sflvs.clear(); | 765 | sflvs.clear(); |
| 766 | } | 766 | } |
| 767 | - if (true) { | ||
| 768 | - std::map<std::string, SrsHlsEntry*>::iterator it; | ||
| 769 | - for (it = thls.begin(); it != thls.end(); ++it) { | ||
| 770 | - SrsHlsEntry* entry = it->second; | ||
| 771 | - srs_freep(entry); | ||
| 772 | - } | ||
| 773 | - thls.clear(); | ||
| 774 | - } | ||
| 775 | - if (true) { | ||
| 776 | - std::map<std::string, SrsHlsEntry*>::iterator it; | ||
| 777 | - for (it = shls.begin(); it != shls.end(); ++it) { | ||
| 778 | - SrsHlsEntry* entry = it->second; | ||
| 779 | - srs_freep(entry); | ||
| 780 | - } | ||
| 781 | - shls.clear(); | ||
| 782 | - } | ||
| 783 | } | 767 | } |
| 784 | 768 | ||
| 785 | int SrsHttpStreamServer::initialize() | 769 | int SrsHttpStreamServer::initialize() |
| @@ -791,11 +775,6 @@ int SrsHttpStreamServer::initialize() | @@ -791,11 +775,6 @@ int SrsHttpStreamServer::initialize() | ||
| 791 | return ret; | 775 | return ret; |
| 792 | } | 776 | } |
| 793 | 777 | ||
| 794 | - // remux rtmp to hls live streaming | ||
| 795 | - if ((ret = initialize_hls_streaming()) != ERROR_SUCCESS) { | ||
| 796 | - return ret; | ||
| 797 | - } | ||
| 798 | - | ||
| 799 | return ret; | 778 | return ret; |
| 800 | } | 779 | } |
| 801 | 780 | ||
| @@ -961,190 +940,6 @@ int SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost) | @@ -961,190 +940,6 @@ int SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost) | ||
| 961 | return ret; | 940 | return ret; |
| 962 | } | 941 | } |
| 963 | 942 | ||
| 964 | -int SrsHttpStreamServer::mount_hls(SrsRequest* r) | ||
| 965 | -{ | ||
| 966 | - int ret = ERROR_SUCCESS; | ||
| 967 | - | ||
| 968 | - std::string sid = r->get_stream_url(); | ||
| 969 | - | ||
| 970 | - if (shls.find(sid) == shls.end()) { | ||
| 971 | - srs_info("ignore mount hls stream for disabled"); | ||
| 972 | - return ret; | ||
| 973 | - } | ||
| 974 | - | ||
| 975 | - SrsHlsEntry* entry = shls[sid]; | ||
| 976 | - | ||
| 977 | - // TODO: FIXME: supports reload. | ||
| 978 | - std::map<std::string, ISrsHttpHandler*>::iterator it; | ||
| 979 | - for (it = entry->streams.begin(); it != entry->streams.end(); ++it) { | ||
| 980 | - ISrsHttpHandler* stream = it->second; | ||
| 981 | - stream->entry->enabled = true; | ||
| 982 | - } | ||
| 983 | - | ||
| 984 | - return ret; | ||
| 985 | -} | ||
| 986 | - | ||
| 987 | -int SrsHttpStreamServer::hls_update_m3u8(SrsRequest* r, string m3u8) | ||
| 988 | -{ | ||
| 989 | - int ret = ERROR_SUCCESS; | ||
| 990 | - | ||
| 991 | - std::string mount; | ||
| 992 | - | ||
| 993 | - std::string sid = r->get_stream_url(); | ||
| 994 | - SrsHlsEntry* entry = NULL; | ||
| 995 | - | ||
| 996 | - // create stream from template when not found. | ||
| 997 | - if (shls.find(sid) == shls.end()) { | ||
| 998 | - if (thls.find(r->vhost) == thls.end()) { | ||
| 999 | - srs_info("ignore mount hls stream for disabled"); | ||
| 1000 | - return ret; | ||
| 1001 | - } | ||
| 1002 | - | ||
| 1003 | - SrsHlsEntry* tmpl = thls[r->vhost]; | ||
| 1004 | - srs_assert(tmpl); | ||
| 1005 | - | ||
| 1006 | - entry = new SrsHlsEntry(); | ||
| 1007 | - mount = tmpl->mount; | ||
| 1008 | - | ||
| 1009 | - // replace the vhost variable | ||
| 1010 | - mount = srs_string_replace(mount, "[vhost]", r->vhost); | ||
| 1011 | - mount = srs_string_replace(mount, "[app]", r->app); | ||
| 1012 | - mount = srs_string_replace(mount, "[stream]", r->stream); | ||
| 1013 | - | ||
| 1014 | - // remove the default vhost mount | ||
| 1015 | - mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); | ||
| 1016 | - | ||
| 1017 | - entry->tmpl = tmpl; | ||
| 1018 | - entry->mount = mount; | ||
| 1019 | - shls[sid] = entry; | ||
| 1020 | - | ||
| 1021 | - if (entry->streams.find(mount) == entry->streams.end()) { | ||
| 1022 | - ISrsHttpHandler* he = new SrsHlsM3u8Stream(); | ||
| 1023 | - entry->streams[mount] = he; | ||
| 1024 | - | ||
| 1025 | - if ((ret = mux.handle(mount, he)) != ERROR_SUCCESS) { | ||
| 1026 | - srs_error("handle mount=%s failed. ret=%d", mount.c_str(), ret); | ||
| 1027 | - return ret; | ||
| 1028 | - } | ||
| 1029 | - } | ||
| 1030 | - } else { | ||
| 1031 | - entry = shls[sid]; | ||
| 1032 | - } | ||
| 1033 | - | ||
| 1034 | - mount = entry->mount; | ||
| 1035 | - | ||
| 1036 | - // update the m3u8 stream. | ||
| 1037 | - SrsHlsM3u8Stream* hms = dynamic_cast<SrsHlsM3u8Stream*>(entry->streams[mount]); | ||
| 1038 | - if (hms) { | ||
| 1039 | - hms->set_m3u8(m3u8); | ||
| 1040 | - } | ||
| 1041 | - srs_trace("hls update m3u8 ok, mount=%s", mount.c_str()); | ||
| 1042 | - | ||
| 1043 | - return ret; | ||
| 1044 | -} | ||
| 1045 | - | ||
| 1046 | -int SrsHttpStreamServer::hls_update_ts(SrsRequest* r, string uri, string ts) | ||
| 1047 | -{ | ||
| 1048 | - int ret = ERROR_SUCCESS; | ||
| 1049 | - | ||
| 1050 | - std::string sid = r->get_stream_url(); | ||
| 1051 | - | ||
| 1052 | - // when no hls mounted, init with empty m3u8. | ||
| 1053 | - if (shls.find(sid) == shls.end()) { | ||
| 1054 | - if ((ret = hls_update_m3u8(r, "")) != ERROR_SUCCESS) { | ||
| 1055 | - return ret; | ||
| 1056 | - } | ||
| 1057 | - } | ||
| 1058 | - | ||
| 1059 | - // find again, ignore if not exits. | ||
| 1060 | - if (shls.find(sid) == shls.end()) { | ||
| 1061 | - return ret; | ||
| 1062 | - } | ||
| 1063 | - | ||
| 1064 | - SrsHlsEntry* entry = shls[sid]; | ||
| 1065 | - srs_assert(entry); | ||
| 1066 | - srs_assert(entry->tmpl); | ||
| 1067 | - | ||
| 1068 | - std::string mount = hls_mount_generate(r, uri, entry->tmpl->mount); | ||
| 1069 | - | ||
| 1070 | - if (entry->streams.find(mount) == entry->streams.end()) { | ||
| 1071 | - ISrsHttpHandler* he = new SrsHlsTsStream(); | ||
| 1072 | - entry->streams[mount] = he; | ||
| 1073 | - | ||
| 1074 | - if ((ret = mux.handle(mount, he)) != ERROR_SUCCESS) { | ||
| 1075 | - srs_error("handle mount=%s failed. ret=%d", mount.c_str(), ret); | ||
| 1076 | - return ret; | ||
| 1077 | - } | ||
| 1078 | - } | ||
| 1079 | - | ||
| 1080 | - // update the ts stream. | ||
| 1081 | - SrsHlsTsStream* hts = dynamic_cast<SrsHlsTsStream*>(entry->streams[mount]); | ||
| 1082 | - if (hts) { | ||
| 1083 | - hts->set_ts(ts); | ||
| 1084 | - } | ||
| 1085 | - srs_trace("hls update ts ok, mount=%s", mount.c_str()); | ||
| 1086 | - | ||
| 1087 | - return ret; | ||
| 1088 | -} | ||
| 1089 | - | ||
| 1090 | -int SrsHttpStreamServer::hls_remove_ts(SrsRequest* r, string uri) | ||
| 1091 | -{ | ||
| 1092 | - int ret = ERROR_SUCCESS; | ||
| 1093 | - | ||
| 1094 | - std::string sid = r->get_stream_url(); | ||
| 1095 | - | ||
| 1096 | - // when no hls mounted, ignore. | ||
| 1097 | - if (shls.find(sid) == shls.end()) { | ||
| 1098 | - return ret; | ||
| 1099 | - } | ||
| 1100 | - | ||
| 1101 | - SrsHlsEntry* entry = shls[sid]; | ||
| 1102 | - srs_assert(entry); | ||
| 1103 | - srs_assert(entry->tmpl); | ||
| 1104 | - | ||
| 1105 | - std::string mount = hls_mount_generate(r, uri, entry->tmpl->mount); | ||
| 1106 | - | ||
| 1107 | - // ignore when no ts mounted. | ||
| 1108 | - if (entry->streams.find(mount) == entry->streams.end()) { | ||
| 1109 | - return ret; | ||
| 1110 | - } | ||
| 1111 | - | ||
| 1112 | - // update the ts stream. | ||
| 1113 | - SrsHlsTsStream* hts = dynamic_cast<SrsHlsTsStream*>(entry->streams[mount]); | ||
| 1114 | - if (hts) { | ||
| 1115 | - hts->set_ts(""); | ||
| 1116 | - // TODO: FIXME: unmount and remove the http handler. | ||
| 1117 | - } | ||
| 1118 | - srs_trace("hls remove ts ok, mount=%s", mount.c_str()); | ||
| 1119 | - | ||
| 1120 | - return ret; | ||
| 1121 | -} | ||
| 1122 | - | ||
| 1123 | -void SrsHttpStreamServer::unmount_hls(SrsRequest* r) | ||
| 1124 | -{ | ||
| 1125 | - std::string sid = r->get_stream_url(); | ||
| 1126 | - | ||
| 1127 | - if (shls.find(sid) == shls.end()) { | ||
| 1128 | - srs_info("ignore unmount hls stream for disabled"); | ||
| 1129 | - return; | ||
| 1130 | - } | ||
| 1131 | - | ||
| 1132 | - SrsHlsEntry* entry = shls[sid]; | ||
| 1133 | - | ||
| 1134 | - std::map<std::string, ISrsHttpHandler*>::iterator it; | ||
| 1135 | - for (it = entry->streams.begin(); it != entry->streams.end(); ++it) { | ||
| 1136 | - ISrsHttpHandler* stream = it->second; | ||
| 1137 | - stream->entry->enabled = false; | ||
| 1138 | - } | ||
| 1139 | -} | ||
| 1140 | - | ||
| 1141 | -int SrsHttpStreamServer::on_reload_vhost_hls(string vhost) | ||
| 1142 | -{ | ||
| 1143 | - int ret = ERROR_SUCCESS; | ||
| 1144 | - // TODO: FIXME: implements it. | ||
| 1145 | - return ret; | ||
| 1146 | -} | ||
| 1147 | - | ||
| 1148 | int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | 943 | int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) |
| 1149 | { | 944 | { |
| 1150 | int ret = ERROR_SUCCESS; | 945 | int ret = ERROR_SUCCESS; |
| @@ -1233,7 +1028,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | @@ -1233,7 +1028,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | ||
| 1233 | } | 1028 | } |
| 1234 | 1029 | ||
| 1235 | SrsSource* s = NULL; | 1030 | SrsSource* s = NULL; |
| 1236 | - if ((ret = SrsSource::fetch_or_create(r, server, server, &s)) != ERROR_SUCCESS) { | 1031 | + if ((ret = SrsSource::fetch_or_create(r, server, &s)) != ERROR_SUCCESS) { |
| 1237 | return ret; | 1032 | return ret; |
| 1238 | } | 1033 | } |
| 1239 | srs_assert(s != NULL); | 1034 | srs_assert(s != NULL); |
| @@ -1299,59 +1094,5 @@ int SrsHttpStreamServer::initialize_flv_entry(std::string vhost) | @@ -1299,59 +1094,5 @@ int SrsHttpStreamServer::initialize_flv_entry(std::string vhost) | ||
| 1299 | return ret; | 1094 | return ret; |
| 1300 | } | 1095 | } |
| 1301 | 1096 | ||
| 1302 | -int SrsHttpStreamServer::initialize_hls_streaming() | ||
| 1303 | -{ | ||
| 1304 | - int ret = ERROR_SUCCESS; | ||
| 1305 | - | ||
| 1306 | - // http hls live stream mount for each vhost. | ||
| 1307 | - SrsConfDirective* root = _srs_config->get_root(); | ||
| 1308 | - for (int i = 0; i < (int)root->directives.size(); i++) { | ||
| 1309 | - SrsConfDirective* conf = root->at(i); | ||
| 1310 | - | ||
| 1311 | - if (!conf->is_vhost()) { | ||
| 1312 | - continue; | ||
| 1313 | - } | ||
| 1314 | - | ||
| 1315 | - std::string vhost = conf->arg0(); | ||
| 1316 | - if (!_srs_config->get_hls_enabled(vhost)) { | ||
| 1317 | - continue; | ||
| 1318 | - } | ||
| 1319 | - | ||
| 1320 | - std::string storage = _srs_config->get_hls_storage(vhost); | ||
| 1321 | - if (storage != "ram" && storage != "both") { | ||
| 1322 | - continue; | ||
| 1323 | - } | ||
| 1324 | - | ||
| 1325 | - SrsHlsEntry* entry = new SrsHlsEntry(); | ||
| 1326 | - entry->mount = _srs_config->get_hls_mount(vhost); | ||
| 1327 | - thls[vhost] = entry; | ||
| 1328 | - srs_trace("http hls live stream, vhost=%s, mount=%s", | ||
| 1329 | - vhost.c_str(), entry->mount.c_str()); | ||
| 1330 | - } | ||
| 1331 | - | ||
| 1332 | - return ret; | ||
| 1333 | -} | ||
| 1334 | - | ||
| 1335 | -string SrsHttpStreamServer::hls_mount_generate(SrsRequest* r, string uri, string tmpl) | ||
| 1336 | -{ | ||
| 1337 | - std::string mount = tmpl; | ||
| 1338 | - | ||
| 1339 | - // the ts is relative from the m3u8, the same start dir. | ||
| 1340 | - mount = srs_path_dirname(mount); | ||
| 1341 | - | ||
| 1342 | - // replace the vhost variable | ||
| 1343 | - mount = srs_string_replace(mount, "[vhost]", r->vhost); | ||
| 1344 | - mount = srs_string_replace(mount, "[app]", r->app); | ||
| 1345 | - | ||
| 1346 | - // remove the default vhost mount | ||
| 1347 | - mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); | ||
| 1348 | - | ||
| 1349 | - // mount with ts. | ||
| 1350 | - mount += "/"; | ||
| 1351 | - mount += uri; | ||
| 1352 | - | ||
| 1353 | - return mount; | ||
| 1354 | -} | ||
| 1355 | - | ||
| 1356 | #endif | 1097 | #endif |
| 1357 | 1098 |
| @@ -334,10 +334,6 @@ public: | @@ -334,10 +334,6 @@ public: | ||
| 334 | std::map<std::string, SrsLiveEntry*> tflvs; | 334 | std::map<std::string, SrsLiveEntry*> tflvs; |
| 335 | // the http live streaming streams, crote by template. | 335 | // the http live streaming streams, crote by template. |
| 336 | std::map<std::string, SrsLiveEntry*> sflvs; | 336 | std::map<std::string, SrsLiveEntry*> sflvs; |
| 337 | - // the hls live streaming template, to create streams. | ||
| 338 | - std::map<std::string, SrsHlsEntry*> thls; | ||
| 339 | - // the hls live streaming streams, crote by template. | ||
| 340 | - std::map<std::string, SrsHlsEntry*> shls; | ||
| 341 | public: | 337 | public: |
| 342 | SrsHttpStreamServer(SrsServer* svr); | 338 | SrsHttpStreamServer(SrsServer* svr); |
| 343 | virtual ~SrsHttpStreamServer(); | 339 | virtual ~SrsHttpStreamServer(); |
| @@ -347,26 +343,16 @@ public: | @@ -347,26 +343,16 @@ public: | ||
| 347 | public: | 343 | public: |
| 348 | virtual int http_mount(SrsSource* s, SrsRequest* r); | 344 | virtual int http_mount(SrsSource* s, SrsRequest* r); |
| 349 | virtual void http_unmount(SrsSource* s, SrsRequest* r); | 345 | virtual void http_unmount(SrsSource* s, SrsRequest* r); |
| 350 | -// hls stream | ||
| 351 | -public: | ||
| 352 | - virtual int mount_hls(SrsRequest* r); | ||
| 353 | - virtual int hls_update_m3u8(SrsRequest* r, std::string m3u8); | ||
| 354 | - virtual int hls_update_ts(SrsRequest* r, std::string uri, std::string ts); | ||
| 355 | - virtual int hls_remove_ts(SrsRequest* r, std::string uri); | ||
| 356 | - virtual void unmount_hls(SrsRequest* r); | ||
| 357 | // interface ISrsReloadHandler. | 346 | // interface ISrsReloadHandler. |
| 358 | public: | 347 | public: |
| 359 | virtual int on_reload_vhost_added(std::string vhost); | 348 | virtual int on_reload_vhost_added(std::string vhost); |
| 360 | virtual int on_reload_vhost_http_remux_updated(std::string vhost); | 349 | virtual int on_reload_vhost_http_remux_updated(std::string vhost); |
| 361 | - virtual int on_reload_vhost_hls(std::string vhost); | ||
| 362 | // interface ISrsHttpMatchHijacker | 350 | // interface ISrsHttpMatchHijacker |
| 363 | public: | 351 | public: |
| 364 | virtual int hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph); | 352 | virtual int hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph); |
| 365 | private: | 353 | private: |
| 366 | virtual int initialize_flv_streaming(); | 354 | virtual int initialize_flv_streaming(); |
| 367 | virtual int initialize_flv_entry(std::string vhost); | 355 | virtual int initialize_flv_entry(std::string vhost); |
| 368 | - virtual int initialize_hls_streaming(); | ||
| 369 | - virtual std::string hls_mount_generate(SrsRequest* r, std::string uri, std::string tmpl); | ||
| 370 | }; | 356 | }; |
| 371 | 357 | ||
| 372 | #endif | 358 | #endif |
| @@ -710,7 +710,7 @@ int SrsRtmpConn::stream_service_cycle() | @@ -710,7 +710,7 @@ int SrsRtmpConn::stream_service_cycle() | ||
| 710 | 710 | ||
| 711 | // find a source to serve. | 711 | // find a source to serve. |
| 712 | SrsSource* source = NULL; | 712 | SrsSource* source = NULL; |
| 713 | - if ((ret = SrsSource::fetch_or_create(req, server, server, &source)) != ERROR_SUCCESS) { | 713 | + if ((ret = SrsSource::fetch_or_create(req, server, &source)) != ERROR_SUCCESS) { |
| 714 | return ret; | 714 | return ret; |
| 715 | } | 715 | } |
| 716 | srs_assert(source != NULL); | 716 | srs_assert(source != NULL); |
| @@ -1514,67 +1514,3 @@ void SrsServer::on_unpublish(SrsSource* s, SrsRequest* r) | @@ -1514,67 +1514,3 @@ void SrsServer::on_unpublish(SrsSource* s, SrsRequest* r) | ||
| 1514 | #endif | 1514 | #endif |
| 1515 | } | 1515 | } |
| 1516 | 1516 | ||
| 1517 | -int SrsServer::on_hls_publish(SrsRequest* r) | ||
| 1518 | -{ | ||
| 1519 | - int ret = ERROR_SUCCESS; | ||
| 1520 | - | ||
| 1521 | -#ifdef SRS_AUTO_HTTP_SERVER | ||
| 1522 | - if ((ret = http_server->mount_hls(r)) != ERROR_SUCCESS) { | ||
| 1523 | - return ret; | ||
| 1524 | - } | ||
| 1525 | -#endif | ||
| 1526 | - | ||
| 1527 | - return ret; | ||
| 1528 | -} | ||
| 1529 | - | ||
| 1530 | -int SrsServer::on_update_m3u8(SrsRequest* r, string m3u8) | ||
| 1531 | -{ | ||
| 1532 | - int ret = ERROR_SUCCESS; | ||
| 1533 | - | ||
| 1534 | -#ifdef SRS_AUTO_HTTP_SERVER | ||
| 1535 | - if ((ret = http_server->hls_update_m3u8(r, m3u8)) != ERROR_SUCCESS) { | ||
| 1536 | - return ret; | ||
| 1537 | - } | ||
| 1538 | -#endif | ||
| 1539 | - | ||
| 1540 | - return ret; | ||
| 1541 | -} | ||
| 1542 | - | ||
| 1543 | -int SrsServer::on_update_ts(SrsRequest* r, string uri, string ts) | ||
| 1544 | -{ | ||
| 1545 | - int ret = ERROR_SUCCESS; | ||
| 1546 | - | ||
| 1547 | -#ifdef SRS_AUTO_HTTP_SERVER | ||
| 1548 | - if ((ret = http_server->hls_update_ts(r, uri, ts)) != ERROR_SUCCESS) { | ||
| 1549 | - return ret; | ||
| 1550 | - } | ||
| 1551 | -#endif | ||
| 1552 | - | ||
| 1553 | - return ret; | ||
| 1554 | -} | ||
| 1555 | - | ||
| 1556 | - | ||
| 1557 | -int SrsServer::on_remove_ts(SrsRequest* r, string uri) | ||
| 1558 | -{ | ||
| 1559 | - int ret = ERROR_SUCCESS; | ||
| 1560 | - | ||
| 1561 | -#ifdef SRS_AUTO_HTTP_SERVER | ||
| 1562 | - if ((ret = http_server->hls_remove_ts(r, uri)) != ERROR_SUCCESS) { | ||
| 1563 | - return ret; | ||
| 1564 | - } | ||
| 1565 | -#endif | ||
| 1566 | - | ||
| 1567 | - return ret; | ||
| 1568 | -} | ||
| 1569 | - | ||
| 1570 | -int SrsServer::on_hls_unpublish(SrsRequest* r) | ||
| 1571 | -{ | ||
| 1572 | - int ret = ERROR_SUCCESS; | ||
| 1573 | - | ||
| 1574 | -#ifdef SRS_AUTO_HTTP_SERVER | ||
| 1575 | - http_server->unmount_hls(r); | ||
| 1576 | -#endif | ||
| 1577 | - | ||
| 1578 | - return ret; | ||
| 1579 | -} | ||
| 1580 | - |
| @@ -237,7 +237,7 @@ public: | @@ -237,7 +237,7 @@ public: | ||
| 237 | * start connection service thread, destroy client. | 237 | * start connection service thread, destroy client. |
| 238 | */ | 238 | */ |
| 239 | class SrsServer : virtual public ISrsReloadHandler | 239 | class SrsServer : virtual public ISrsReloadHandler |
| 240 | - , virtual public ISrsSourceHandler, virtual public ISrsHlsHandler | 240 | + , virtual public ISrsSourceHandler |
| 241 | , virtual public IConnectionManager | 241 | , virtual public IConnectionManager |
| 242 | { | 242 | { |
| 243 | private: | 243 | private: |
| @@ -391,13 +391,6 @@ public: | @@ -391,13 +391,6 @@ public: | ||
| 391 | public: | 391 | public: |
| 392 | virtual int on_publish(SrsSource* s, SrsRequest* r); | 392 | virtual int on_publish(SrsSource* s, SrsRequest* r); |
| 393 | virtual void on_unpublish(SrsSource* s, SrsRequest* r); | 393 | virtual void on_unpublish(SrsSource* s, SrsRequest* r); |
| 394 | -// interface ISrsHlsHandler | ||
| 395 | -public: | ||
| 396 | - virtual int on_hls_publish(SrsRequest* r); | ||
| 397 | - virtual int on_update_m3u8(SrsRequest* r, std::string m3u8); | ||
| 398 | - virtual int on_update_ts(SrsRequest* r, std::string uri, std::string ts); | ||
| 399 | - virtual int on_remove_ts(SrsRequest* r, std::string uri); | ||
| 400 | - virtual int on_hls_unpublish(SrsRequest* r); | ||
| 401 | }; | 394 | }; |
| 402 | 395 | ||
| 403 | #endif | 396 | #endif |
| @@ -737,7 +737,7 @@ ISrsSourceHandler::~ISrsSourceHandler() | @@ -737,7 +737,7 @@ ISrsSourceHandler::~ISrsSourceHandler() | ||
| 737 | 737 | ||
| 738 | std::map<std::string, SrsSource*> SrsSource::pool; | 738 | std::map<std::string, SrsSource*> SrsSource::pool; |
| 739 | 739 | ||
| 740 | -int SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps) | 740 | +int SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps) |
| 741 | { | 741 | { |
| 742 | int ret = ERROR_SUCCESS; | 742 | int ret = ERROR_SUCCESS; |
| 743 | 743 | ||
| @@ -754,7 +754,7 @@ int SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandl | @@ -754,7 +754,7 @@ int SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandl | ||
| 754 | srs_assert (pool.find(stream_url) == pool.end()); | 754 | srs_assert (pool.find(stream_url) == pool.end()); |
| 755 | 755 | ||
| 756 | source = new SrsSource(); | 756 | source = new SrsSource(); |
| 757 | - if ((ret = source->initialize(r, h, hh)) != ERROR_SUCCESS) { | 757 | + if ((ret = source->initialize(r, h)) != ERROR_SUCCESS) { |
| 758 | srs_freep(source); | 758 | srs_freep(source); |
| 759 | return ret; | 759 | return ret; |
| 760 | } | 760 | } |
| @@ -1058,12 +1058,11 @@ bool SrsSource::expired() | @@ -1058,12 +1058,11 @@ bool SrsSource::expired() | ||
| 1058 | return false; | 1058 | return false; |
| 1059 | } | 1059 | } |
| 1060 | 1060 | ||
| 1061 | -int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh) | 1061 | +int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h) |
| 1062 | { | 1062 | { |
| 1063 | int ret = ERROR_SUCCESS; | 1063 | int ret = ERROR_SUCCESS; |
| 1064 | 1064 | ||
| 1065 | srs_assert(h); | 1065 | srs_assert(h); |
| 1066 | - srs_assert(hh); | ||
| 1067 | srs_assert(!req); | 1066 | srs_assert(!req); |
| 1068 | 1067 | ||
| 1069 | handler = h; | 1068 | handler = h; |
| @@ -1071,7 +1070,7 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | @@ -1071,7 +1070,7 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | ||
| 1071 | atc = _srs_config->get_atc(req->vhost); | 1070 | atc = _srs_config->get_atc(req->vhost); |
| 1072 | 1071 | ||
| 1073 | #ifdef SRS_AUTO_HLS | 1072 | #ifdef SRS_AUTO_HLS |
| 1074 | - if ((ret = hls->initialize(this, hh, req)) != ERROR_SUCCESS) { | 1073 | + if ((ret = hls->initialize(this, req)) != ERROR_SUCCESS) { |
| 1075 | return ret; | 1074 | return ret; |
| 1076 | } | 1075 | } |
| 1077 | #endif | 1076 | #endif |
| @@ -63,7 +63,6 @@ class SrsDvr; | @@ -63,7 +63,6 @@ class SrsDvr; | ||
| 63 | class SrsEncoder; | 63 | class SrsEncoder; |
| 64 | #endif | 64 | #endif |
| 65 | class SrsBuffer; | 65 | class SrsBuffer; |
| 66 | -class ISrsHlsHandler; | ||
| 67 | #ifdef SRS_AUTO_HDS | 66 | #ifdef SRS_AUTO_HDS |
| 68 | class SrsHds; | 67 | class SrsHds; |
| 69 | #endif | 68 | #endif |
| @@ -423,10 +422,9 @@ public: | @@ -423,10 +422,9 @@ public: | ||
| 423 | * create source when fetch from cache failed. | 422 | * create source when fetch from cache failed. |
| 424 | * @param r the client request. | 423 | * @param r the client request. |
| 425 | * @param h the event handler for source. | 424 | * @param h the event handler for source. |
| 426 | - * @param hh the event handler for hls. | ||
| 427 | * @param pps the matched source, if success never be NULL. | 425 | * @param pps the matched source, if success never be NULL. |
| 428 | */ | 426 | */ |
| 429 | - static int fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps); | 427 | + static int fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps); |
| 430 | private: | 428 | private: |
| 431 | /** | 429 | /** |
| 432 | * get the exists source, NULL when not exists. | 430 | * get the exists source, NULL when not exists. |
| @@ -533,7 +531,7 @@ public: | @@ -533,7 +531,7 @@ public: | ||
| 533 | /** | 531 | /** |
| 534 | * initialize the hls with handlers. | 532 | * initialize the hls with handlers. |
| 535 | */ | 533 | */ |
| 536 | - virtual int initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh); | 534 | + virtual int initialize(SrsRequest* r, ISrsSourceHandler* h); |
| 537 | // interface ISrsReloadHandler | 535 | // interface ISrsReloadHandler |
| 538 | public: | 536 | public: |
| 539 | virtual int on_reload_vhost_play(std::string vhost); | 537 | virtual int on_reload_vhost_play(std::string vhost); |
-
请 注册 或 登录 后发表评论