正在显示
2 个修改的文件
包含
25 行增加
和
12 行删除
| @@ -136,12 +136,15 @@ int SrsVodStream::serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* | @@ -136,12 +136,15 @@ int SrsVodStream::serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* | ||
| 136 | return ret; | 136 | return ret; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | -SrsLiveStream::SrsLiveStream() | 139 | +SrsLiveStream::SrsLiveStream(SrsSource* s, SrsRequest* r) |
| 140 | { | 140 | { |
| 141 | + source = s; | ||
| 142 | + req = r->copy(); | ||
| 141 | } | 143 | } |
| 142 | 144 | ||
| 143 | SrsLiveStream::~SrsLiveStream() | 145 | SrsLiveStream::~SrsLiveStream() |
| 144 | { | 146 | { |
| 147 | + srs_freep(req); | ||
| 145 | } | 148 | } |
| 146 | 149 | ||
| 147 | int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) | 150 | int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) |
| @@ -182,27 +185,33 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r) | @@ -182,27 +185,33 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r) | ||
| 182 | { | 185 | { |
| 183 | int ret = ERROR_SUCCESS; | 186 | int ret = ERROR_SUCCESS; |
| 184 | 187 | ||
| 185 | - if (flvs.empty()) { | ||
| 186 | - srs_info("ignore mount, no flv stream configed."); | 188 | + if (flvs.find(r->vhost) == flvs.end()) { |
| 189 | + srs_info("ignore mount flv stream for disabled"); | ||
| 187 | return ret; | 190 | return ret; |
| 188 | } | 191 | } |
| 192 | + | ||
| 193 | + std::string mount = flvs[r->vhost]; | ||
| 194 | + | ||
| 195 | + // replace the vhost variable | ||
| 196 | + mount = srs_string_replace(mount, "[vhost]", r->vhost); | ||
| 197 | + mount = srs_string_replace(mount, "[app]", r->app); | ||
| 198 | + mount = srs_string_replace(mount, "[stream]", r->stream); | ||
| 199 | + | ||
| 200 | + // remove the default vhost mount | ||
| 201 | + mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", ""); | ||
| 189 | 202 | ||
| 190 | - if (flvs.find(r->vhost) == flvs.end()) { | ||
| 191 | - srs_info("ignore mount flv stream for disabled"); | 203 | + // mount the http flv stream. |
| 204 | + if ((ret = mux.handle(mount, new SrsLiveStream(s, r))) != ERROR_SUCCESS) { | ||
| 205 | + srs_error("http: mount flv stream for vhost=%s failed. ret=%d", r->vhost.c_str(), ret); | ||
| 192 | return ret; | 206 | return ret; |
| 193 | } | 207 | } |
| 208 | + srs_trace("http: mount flv stream for vhost=%s, mount=%s", r->vhost.c_str(), mount.c_str()); | ||
| 194 | 209 | ||
| 195 | - // TODO: FIXME: implements it. | ||
| 196 | return ret; | 210 | return ret; |
| 197 | } | 211 | } |
| 198 | 212 | ||
| 199 | void SrsHttpServer::unmount(SrsSource* s, SrsRequest* r) | 213 | void SrsHttpServer::unmount(SrsSource* s, SrsRequest* r) |
| 200 | { | 214 | { |
| 201 | - if (flvs.empty()) { | ||
| 202 | - srs_info("ignore unmount, no flv stream configed."); | ||
| 203 | - return; | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | if (flvs.find(r->vhost) == flvs.end()) { | 215 | if (flvs.find(r->vhost) == flvs.end()) { |
| 207 | srs_info("ignore unmount flv stream for disabled"); | 216 | srs_info("ignore unmount flv stream for disabled"); |
| 208 | return; | 217 | return; |
| @@ -269,6 +278,7 @@ int SrsHttpServer::mount_static_file() | @@ -269,6 +278,7 @@ int SrsHttpServer::mount_static_file() | ||
| 269 | default_root_exists = true; | 278 | default_root_exists = true; |
| 270 | srs_warn("http: root mount to %s", dir.c_str()); | 279 | srs_warn("http: root mount to %s", dir.c_str()); |
| 271 | } | 280 | } |
| 281 | + srs_trace("http: vhost=%s mount to %s", vhost.c_str(), mount.c_str()); | ||
| 272 | } | 282 | } |
| 273 | 283 | ||
| 274 | if (!default_root_exists) { | 284 | if (!default_root_exists) { |
| @@ -65,8 +65,11 @@ protected: | @@ -65,8 +65,11 @@ protected: | ||
| 65 | */ | 65 | */ |
| 66 | class SrsLiveStream : public ISrsGoHttpHandler | 66 | class SrsLiveStream : public ISrsGoHttpHandler |
| 67 | { | 67 | { |
| 68 | +private: | ||
| 69 | + SrsRequest* req; | ||
| 70 | + SrsSource* source; | ||
| 68 | public: | 71 | public: |
| 69 | - SrsLiveStream(); | 72 | + SrsLiveStream(SrsSource* s, SrsRequest* r); |
| 70 | virtual ~SrsLiveStream(); | 73 | virtual ~SrsLiveStream(); |
| 71 | public: | 74 | public: |
| 72 | virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); | 75 | virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); |
-
请 注册 或 登录 后发表评论