Commit a1de3bfd by xiongziliang

添加流创建时间、在线时间

parent cd27e5a9
Subproject commit f564c7ed27f141a3b5f08d239970b24d700a1244
Subproject commit 735f194e18d5fb576c0da03024226a6f38537e5a
......@@ -395,7 +395,9 @@ void installWebApi() {
item["vhost"] = media->getVhost();
item["app"] = media->getApp();
item["stream"] = media->getId();
item["bytes_speed"] = media->getBytesSpeed();
item["createStamp"] = (Json::UInt64) media->getCreateStamp();
item["aliveSecond"] = (Json::UInt64) media->getAliveSecond();
item["bytesSpeed"] = media->getBytesSpeed();
item["readerCount"] = media->readerCount();
item["totalReaderCount"] = media->totalReaderCount();
item["originType"] = (int) media->getOriginType();
......
......@@ -43,6 +43,7 @@ MediaSource::MediaSource(const string &schema, const string &vhost, const string
_schema = schema;
_app = app;
_stream_id = stream_id;
_create_stamp = time(NULL);
}
MediaSource::~MediaSource() {
......@@ -70,6 +71,15 @@ int MediaSource::getBytesSpeed(){
return _speed.getSpeed();
}
uint64_t MediaSource::getCreateStamp() const {
return _create_stamp;
}
uint64_t MediaSource::getAliveSecond() const {
//使用Ticker对象获取存活时间的目的是防止修改系统时间导致回退
return _ticker.createdTime() / 1000;
}
vector<Track::Ptr> MediaSource::getTracks(bool ready) const {
auto listener = _listener.lock();
if(!listener){
......
......@@ -218,6 +218,10 @@ public:
// 获取数据速率,单位bytes/s
int getBytesSpeed();
// 获取流创建GMT unix时间戳,单位秒
uint64_t getCreateStamp() const;
// 获取流上线时间,单位秒
uint64_t getAliveSecond() const;
////////////////MediaSourceEvent相关接口实现////////////////
......@@ -282,6 +286,8 @@ protected:
BytesSpeed _speed;
private:
time_t _create_stamp;
Ticker _ticker;
string _schema;
string _vhost;
string _app;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论