正在显示
5 个修改的文件
包含
35 行增加
和
4 行删除
trunk/auto/depends.sh
100755 → 100644
| @@ -572,7 +572,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | @@ -572,7 +572,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | ||
| 572 | rm -rf research/api-server/static-dir/forward && | 572 | rm -rf research/api-server/static-dir/forward && |
| 573 | mkdir -p `pwd`/${SRS_OBJS}/nginx/html/forward && | 573 | mkdir -p `pwd`/${SRS_OBJS}/nginx/html/forward && |
| 574 | ln -sf `pwd`/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forward | 574 | ln -sf `pwd`/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forward |
| 575 | - ret=$?; if [[ $ret -ne 0 ]]; then echo "link players to cherrypy static-dir failed, ret=$ret"; exit $ret; fi | 575 | + ret=$?; if [[ $ret -ne 0 ]]; then echo "[warn] link players to cherrypy static-dir failed"; fi |
| 576 | fi | 576 | fi |
| 577 | 577 | ||
| 578 | ##################################################################################### | 578 | ##################################################################################### |
| @@ -2570,7 +2570,7 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost) | @@ -2570,7 +2570,7 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost) | ||
| 2570 | return SRS_CONF_DEFAULT_EDGE_MODE; | 2570 | return SRS_CONF_DEFAULT_EDGE_MODE; |
| 2571 | } | 2571 | } |
| 2572 | 2572 | ||
| 2573 | - return conf->arg0() == "remote"; | 2573 | + return "remote" == conf->arg0(); |
| 2574 | } | 2574 | } |
| 2575 | 2575 | ||
| 2576 | SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost) | 2576 | SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost) |
| @@ -1917,7 +1917,8 @@ int SrsSource::on_publish() | @@ -1917,7 +1917,8 @@ int SrsSource::on_publish() | ||
| 1917 | srs_error("handle on publish failed. ret=%d", ret); | 1917 | srs_error("handle on publish failed. ret=%d", ret); |
| 1918 | return ret; | 1918 | return ret; |
| 1919 | } | 1919 | } |
| 1920 | - | 1920 | + SrsStatistic* stat = SrsStatistic::instance(); |
| 1921 | + stat->on_stream_publish(_req); | ||
| 1921 | return ret; | 1922 | return ret; |
| 1922 | } | 1923 | } |
| 1923 | 1924 | ||
| @@ -1958,6 +1959,8 @@ void SrsSource::on_unpublish() | @@ -1958,6 +1959,8 @@ void SrsSource::on_unpublish() | ||
| 1958 | 1959 | ||
| 1959 | // notify the handler. | 1960 | // notify the handler. |
| 1960 | srs_assert(handler); | 1961 | srs_assert(handler); |
| 1962 | + SrsStatistic* stat = SrsStatistic::instance(); | ||
| 1963 | + stat->on_stream_close(_req); | ||
| 1961 | handler->on_unpublish(this, _req); | 1964 | handler->on_unpublish(this, _req); |
| 1962 | } | 1965 | } |
| 1963 | 1966 |
| @@ -58,6 +58,7 @@ SrsStatisticStream::SrsStatisticStream() | @@ -58,6 +58,7 @@ SrsStatisticStream::SrsStatisticStream() | ||
| 58 | { | 58 | { |
| 59 | id = srs_generate_id(); | 59 | id = srs_generate_id(); |
| 60 | vhost = NULL; | 60 | vhost = NULL; |
| 61 | + status = STATISTIC_STREAM_STATUS_IDLING; | ||
| 61 | 62 | ||
| 62 | has_video = false; | 63 | has_video = false; |
| 63 | vcodec = SrsCodecVideoReserved; | 64 | vcodec = SrsCodecVideoReserved; |
| @@ -79,10 +80,16 @@ SrsStatisticStream::~SrsStatisticStream() | @@ -79,10 +80,16 @@ SrsStatisticStream::~SrsStatisticStream() | ||
| 79 | srs_freep(kbps); | 80 | srs_freep(kbps); |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 83 | +void SrsStatisticStream::publish() | ||
| 84 | +{ | ||
| 85 | + status = STATISTIC_STREAM_STATUS_PUBLISHING; | ||
| 86 | +} | ||
| 87 | + | ||
| 82 | void SrsStatisticStream::close() | 88 | void SrsStatisticStream::close() |
| 83 | { | 89 | { |
| 84 | has_video = false; | 90 | has_video = false; |
| 85 | has_audio = false; | 91 | has_audio = false; |
| 92 | + status = STATISTIC_STREAM_STATUS_IDLING; | ||
| 86 | } | 93 | } |
| 87 | 94 | ||
| 88 | SrsStatistic* SrsStatistic::_instance = new SrsStatistic(); | 95 | SrsStatistic* SrsStatistic::_instance = new SrsStatistic(); |
| @@ -161,6 +168,14 @@ int SrsStatistic::on_audio_info(SrsRequest* req, | @@ -161,6 +168,14 @@ int SrsStatistic::on_audio_info(SrsRequest* req, | ||
| 161 | return ret; | 168 | return ret; |
| 162 | } | 169 | } |
| 163 | 170 | ||
| 171 | +void SrsStatistic::on_stream_publish(SrsRequest* req) | ||
| 172 | +{ | ||
| 173 | + SrsStatisticVhost* vhost = create_vhost(req); | ||
| 174 | + SrsStatisticStream* stream = create_stream(vhost, req); | ||
| 175 | + | ||
| 176 | + stream->publish(); | ||
| 177 | +} | ||
| 178 | + | ||
| 164 | void SrsStatistic::on_stream_close(SrsRequest* req) | 179 | void SrsStatistic::on_stream_close(SrsRequest* req) |
| 165 | { | 180 | { |
| 166 | SrsStatisticVhost* vhost = create_vhost(req); | 181 | SrsStatisticVhost* vhost = create_vhost(req); |
| @@ -308,7 +323,8 @@ int SrsStatistic::dumps_streams(stringstream& ss) | @@ -308,7 +323,8 @@ int SrsStatistic::dumps_streams(stringstream& ss) | ||
| 308 | << SRS_JFIELD_ORG("clients", client_num) << SRS_JFIELD_CONT | 323 | << SRS_JFIELD_ORG("clients", client_num) << SRS_JFIELD_CONT |
| 309 | << SRS_JFIELD_ORG("send_bytes", stream->kbps->get_send_bytes()) << SRS_JFIELD_CONT | 324 | << SRS_JFIELD_ORG("send_bytes", stream->kbps->get_send_bytes()) << SRS_JFIELD_CONT |
| 310 | << SRS_JFIELD_ORG("recv_bytes", stream->kbps->get_recv_bytes()) << SRS_JFIELD_CONT | 325 | << SRS_JFIELD_ORG("recv_bytes", stream->kbps->get_recv_bytes()) << SRS_JFIELD_CONT |
| 311 | - << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT; | 326 | + << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT |
| 327 | + << SRS_JFIELD_STR("status", stream->status) << SRS_JFIELD_CONT; | ||
| 312 | 328 | ||
| 313 | if (!stream->has_video) { | 329 | if (!stream->has_video) { |
| 314 | ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT; | 330 | ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT; |
| @@ -35,6 +35,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -35,6 +35,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 35 | 35 | ||
| 36 | #include <srs_kernel_codec.hpp> | 36 | #include <srs_kernel_codec.hpp> |
| 37 | 37 | ||
| 38 | +#define STATISTIC_STREAM_STATUS_PUBLISHING "publishing" | ||
| 39 | +#define STATISTIC_STREAM_STATUS_IDLING "idling" | ||
| 40 | + | ||
| 38 | class SrsKbps; | 41 | class SrsKbps; |
| 39 | class SrsRequest; | 42 | class SrsRequest; |
| 40 | class SrsConnection; | 43 | class SrsConnection; |
| @@ -62,6 +65,7 @@ public: | @@ -62,6 +65,7 @@ public: | ||
| 62 | std::string app; | 65 | std::string app; |
| 63 | std::string stream; | 66 | std::string stream; |
| 64 | std::string url; | 67 | std::string url; |
| 68 | + std::string status; | ||
| 65 | public: | 69 | public: |
| 66 | /** | 70 | /** |
| 67 | * stream total kbps. | 71 | * stream total kbps. |
| @@ -91,6 +95,10 @@ public: | @@ -91,6 +95,10 @@ public: | ||
| 91 | virtual ~SrsStatisticStream(); | 95 | virtual ~SrsStatisticStream(); |
| 92 | public: | 96 | public: |
| 93 | /** | 97 | /** |
| 98 | + * publish the stream. | ||
| 99 | + */ | ||
| 100 | + virtual void publish(); | ||
| 101 | + /** | ||
| 94 | * close the stream. | 102 | * close the stream. |
| 95 | */ | 103 | */ |
| 96 | virtual void close(); | 104 | virtual void close(); |
| @@ -137,6 +145,10 @@ public: | @@ -137,6 +145,10 @@ public: | ||
| 137 | SrsAacObjectType aac_object | 145 | SrsAacObjectType aac_object |
| 138 | ); | 146 | ); |
| 139 | /** | 147 | /** |
| 148 | + * when publish stream. | ||
| 149 | + */ | ||
| 150 | + virtual void on_stream_publish(SrsRequest* req); | ||
| 151 | + /** | ||
| 140 | * when close stream. | 152 | * when close stream. |
| 141 | */ | 153 | */ |
| 142 | virtual void on_stream_close(SrsRequest* req); | 154 | virtual void on_stream_close(SrsRequest* req); |
-
请 注册 或 登录 后发表评论