mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
add stream status to api.
This commit is contained in:
parent
ac13817aae
commit
7fc1cda392
5 changed files with 35 additions and 4 deletions
2
trunk/auto/depends.sh
Executable file → Normal file
2
trunk/auto/depends.sh
Executable file → Normal file
|
@ -572,7 +572,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
|||
rm -rf research/api-server/static-dir/forward &&
|
||||
mkdir -p `pwd`/${SRS_OBJS}/nginx/html/forward &&
|
||||
ln -sf `pwd`/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forward
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "link players to cherrypy static-dir failed, ret=$ret"; exit $ret; fi
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "[warn] link players to cherrypy static-dir failed"; fi
|
||||
fi
|
||||
|
||||
#####################################################################################
|
||||
|
|
|
@ -2570,7 +2570,7 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost)
|
|||
return SRS_CONF_DEFAULT_EDGE_MODE;
|
||||
}
|
||||
|
||||
return conf->arg0() == "remote";
|
||||
return "remote" == conf->arg0();
|
||||
}
|
||||
|
||||
SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost)
|
||||
|
|
|
@ -1917,7 +1917,8 @@ int SrsSource::on_publish()
|
|||
srs_error("handle on publish failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SrsStatistic* stat = SrsStatistic::instance();
|
||||
stat->on_stream_publish(_req);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1958,6 +1959,8 @@ void SrsSource::on_unpublish()
|
|||
|
||||
// notify the handler.
|
||||
srs_assert(handler);
|
||||
SrsStatistic* stat = SrsStatistic::instance();
|
||||
stat->on_stream_close(_req);
|
||||
handler->on_unpublish(this, _req);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ SrsStatisticStream::SrsStatisticStream()
|
|||
{
|
||||
id = srs_generate_id();
|
||||
vhost = NULL;
|
||||
status = STATISTIC_STREAM_STATUS_IDLING;
|
||||
|
||||
has_video = false;
|
||||
vcodec = SrsCodecVideoReserved;
|
||||
|
@ -79,10 +80,16 @@ SrsStatisticStream::~SrsStatisticStream()
|
|||
srs_freep(kbps);
|
||||
}
|
||||
|
||||
void SrsStatisticStream::publish()
|
||||
{
|
||||
status = STATISTIC_STREAM_STATUS_PUBLISHING;
|
||||
}
|
||||
|
||||
void SrsStatisticStream::close()
|
||||
{
|
||||
has_video = false;
|
||||
has_audio = false;
|
||||
status = STATISTIC_STREAM_STATUS_IDLING;
|
||||
}
|
||||
|
||||
SrsStatistic* SrsStatistic::_instance = new SrsStatistic();
|
||||
|
@ -161,6 +168,14 @@ int SrsStatistic::on_audio_info(SrsRequest* req,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void SrsStatistic::on_stream_publish(SrsRequest* req)
|
||||
{
|
||||
SrsStatisticVhost* vhost = create_vhost(req);
|
||||
SrsStatisticStream* stream = create_stream(vhost, req);
|
||||
|
||||
stream->publish();
|
||||
}
|
||||
|
||||
void SrsStatistic::on_stream_close(SrsRequest* req)
|
||||
{
|
||||
SrsStatisticVhost* vhost = create_vhost(req);
|
||||
|
@ -308,7 +323,8 @@ int SrsStatistic::dumps_streams(stringstream& ss)
|
|||
<< SRS_JFIELD_ORG("clients", client_num) << SRS_JFIELD_CONT
|
||||
<< SRS_JFIELD_ORG("send_bytes", stream->kbps->get_send_bytes()) << SRS_JFIELD_CONT
|
||||
<< SRS_JFIELD_ORG("recv_bytes", stream->kbps->get_recv_bytes()) << SRS_JFIELD_CONT
|
||||
<< SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT;
|
||||
<< SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT
|
||||
<< SRS_JFIELD_STR("status", stream->status) << SRS_JFIELD_CONT;
|
||||
|
||||
if (!stream->has_video) {
|
||||
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.
|
|||
|
||||
#include <srs_kernel_codec.hpp>
|
||||
|
||||
#define STATISTIC_STREAM_STATUS_PUBLISHING "publishing"
|
||||
#define STATISTIC_STREAM_STATUS_IDLING "idling"
|
||||
|
||||
class SrsKbps;
|
||||
class SrsRequest;
|
||||
class SrsConnection;
|
||||
|
@ -62,6 +65,7 @@ public:
|
|||
std::string app;
|
||||
std::string stream;
|
||||
std::string url;
|
||||
std::string status;
|
||||
public:
|
||||
/**
|
||||
* stream total kbps.
|
||||
|
@ -90,6 +94,10 @@ public:
|
|||
SrsStatisticStream();
|
||||
virtual ~SrsStatisticStream();
|
||||
public:
|
||||
/**
|
||||
* publish the stream.
|
||||
*/
|
||||
virtual void publish();
|
||||
/**
|
||||
* close the stream.
|
||||
*/
|
||||
|
@ -137,6 +145,10 @@ public:
|
|||
SrsAacObjectType aac_object
|
||||
);
|
||||
/**
|
||||
* when publish stream.
|
||||
*/
|
||||
virtual void on_stream_publish(SrsRequest* req);
|
||||
/**
|
||||
* when close stream.
|
||||
*/
|
||||
virtual void on_stream_close(SrsRequest* req);
|
||||
|
|
Loading…
Reference in a new issue