mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
add SrsPid and SrsId to client response, add pid to log
This commit is contained in:
parent
5ff1ce7cba
commit
e39eed6519
8 changed files with 57 additions and 9 deletions
Binary file not shown.
|
@ -137,6 +137,7 @@ package
|
||||||
private var srs_server:String = null;
|
private var srs_server:String = null;
|
||||||
private var srs_primary_authors:String = null;
|
private var srs_primary_authors:String = null;
|
||||||
private var srs_id:String = null;
|
private var srs_id:String = null;
|
||||||
|
private var srs_pid:String = null;
|
||||||
private function update_context_items():void {
|
private function update_context_items():void {
|
||||||
// for context menu
|
// for context menu
|
||||||
var customItems:Array = [new ContextMenuItem("SrsPlayer")];
|
var customItems:Array = [new ContextMenuItem("SrsPlayer")];
|
||||||
|
@ -146,6 +147,9 @@ package
|
||||||
if (srs_primary_authors != null) {
|
if (srs_primary_authors != null) {
|
||||||
customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
|
customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
|
||||||
}
|
}
|
||||||
|
if (srs_pid != null) {
|
||||||
|
customItems.push(new ContextMenuItem("SrsPid: " + srs_pid));
|
||||||
|
}
|
||||||
if (srs_id != null) {
|
if (srs_id != null) {
|
||||||
customItems.push(new ContextMenuItem("SrsId: " + srs_id));
|
customItems.push(new ContextMenuItem("SrsId: " + srs_id));
|
||||||
}
|
}
|
||||||
|
@ -166,6 +170,9 @@ package
|
||||||
if (evt.info.data.hasOwnProperty("srs_id")) {
|
if (evt.info.data.hasOwnProperty("srs_id")) {
|
||||||
srs_id = evt.info.data.srs_id;
|
srs_id = evt.info.data.srs_id;
|
||||||
}
|
}
|
||||||
|
if (evt.info.data.hasOwnProperty("srs_pid")) {
|
||||||
|
srs_pid = evt.info.data.srs_pid;
|
||||||
|
}
|
||||||
update_context_items();
|
update_context_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -269,6 +269,7 @@ package
|
||||||
private var srs_server:String = null;
|
private var srs_server:String = null;
|
||||||
private var srs_primary_authors:String = null;
|
private var srs_primary_authors:String = null;
|
||||||
private var srs_id:String = null;
|
private var srs_id:String = null;
|
||||||
|
private var srs_pid:String = null;
|
||||||
private function update_context_items():void {
|
private function update_context_items():void {
|
||||||
// for context menu
|
// for context menu
|
||||||
var customItems:Array = [new ContextMenuItem("SrsPlayer")];
|
var customItems:Array = [new ContextMenuItem("SrsPlayer")];
|
||||||
|
@ -278,6 +279,9 @@ package
|
||||||
if (srs_primary_authors != null) {
|
if (srs_primary_authors != null) {
|
||||||
customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
|
customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
|
||||||
}
|
}
|
||||||
|
if (srs_pid != null) {
|
||||||
|
customItems.push(new ContextMenuItem("SrsPid: " + srs_pid));
|
||||||
|
}
|
||||||
if (srs_id != null) {
|
if (srs_id != null) {
|
||||||
customItems.push(new ContextMenuItem("SrsId: " + srs_id));
|
customItems.push(new ContextMenuItem("SrsId: " + srs_id));
|
||||||
}
|
}
|
||||||
|
@ -316,6 +320,9 @@ package
|
||||||
if (evt.info.data.hasOwnProperty("srs_id")) {
|
if (evt.info.data.hasOwnProperty("srs_id")) {
|
||||||
srs_id = evt.info.data.srs_id;
|
srs_id = evt.info.data.srs_id;
|
||||||
}
|
}
|
||||||
|
if (evt.info.data.hasOwnProperty("srs_pid")) {
|
||||||
|
srs_pid = evt.info.data.srs_pid;
|
||||||
|
}
|
||||||
update_context_items();
|
update_context_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -138,6 +138,7 @@ package
|
||||||
private var srs_server:String = null;
|
private var srs_server:String = null;
|
||||||
private var srs_primary_authors:String = null;
|
private var srs_primary_authors:String = null;
|
||||||
private var srs_id:String = null;
|
private var srs_id:String = null;
|
||||||
|
private var srs_pid:String = null;
|
||||||
private function update_context_items():void {
|
private function update_context_items():void {
|
||||||
// for context menu
|
// for context menu
|
||||||
var customItems:Array = [new ContextMenuItem("SrsPlayer")];
|
var customItems:Array = [new ContextMenuItem("SrsPlayer")];
|
||||||
|
@ -147,6 +148,9 @@ package
|
||||||
if (srs_primary_authors != null) {
|
if (srs_primary_authors != null) {
|
||||||
customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
|
customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
|
||||||
}
|
}
|
||||||
|
if (srs_pid != null) {
|
||||||
|
customItems.push(new ContextMenuItem("SrsPid: " + srs_pid));
|
||||||
|
}
|
||||||
if (srs_id != null) {
|
if (srs_id != null) {
|
||||||
customItems.push(new ContextMenuItem("SrsId: " + srs_id));
|
customItems.push(new ContextMenuItem("SrsId: " + srs_id));
|
||||||
}
|
}
|
||||||
|
@ -215,6 +219,9 @@ package
|
||||||
if (evt.info.data.hasOwnProperty("srs_id")) {
|
if (evt.info.data.hasOwnProperty("srs_id")) {
|
||||||
srs_id = evt.info.data.srs_id;
|
srs_id = evt.info.data.srs_id;
|
||||||
}
|
}
|
||||||
|
if (evt.info.data.hasOwnProperty("srs_pid")) {
|
||||||
|
srs_pid = evt.info.data.srs_pid;
|
||||||
|
}
|
||||||
update_context_items();
|
update_context_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,26 +265,26 @@ bool SrsFastLog::generate_header(bool error, const char* tag, int context_id, co
|
||||||
if (error) {
|
if (error) {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d][%d] ",
|
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d][%d][%d] ",
|
||||||
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
||||||
level_name, tag, context_id, errno);
|
level_name, tag, getpid(), context_id, errno);
|
||||||
} else {
|
} else {
|
||||||
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%d] ",
|
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%d][%d] ",
|
||||||
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
||||||
level_name, context_id, errno);
|
level_name, getpid(), context_id, errno);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d] ",
|
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d][%d] ",
|
||||||
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
||||||
level_name, tag, context_id);
|
level_name, tag, getpid(), context_id);
|
||||||
} else {
|
} else {
|
||||||
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
log_header_size = snprintf(log_data, LOG_MAX_SIZE,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d] ",
|
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%d] ",
|
||||||
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
|
||||||
level_name, context_id);
|
level_name, getpid(), context_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -492,7 +492,33 @@ int SrsRtmpClient::connect_app(string app, string tc_url)
|
||||||
}
|
}
|
||||||
SrsAutoFree(SrsMessage, msg);
|
SrsAutoFree(SrsMessage, msg);
|
||||||
SrsAutoFree(SrsConnectAppResPacket, pkt);
|
SrsAutoFree(SrsConnectAppResPacket, pkt);
|
||||||
srs_info("get connect app response message");
|
|
||||||
|
// server info
|
||||||
|
std::string srs_version;
|
||||||
|
std::string srs_server_ip;
|
||||||
|
int srs_id = 0;
|
||||||
|
int srs_pid = 0;
|
||||||
|
|
||||||
|
SrsAmf0Any* data = pkt->info->get_property("data");
|
||||||
|
if (data && data->is_ecma_array()) {
|
||||||
|
SrsAmf0EcmaArray* arr = data->to_ecma_array();
|
||||||
|
|
||||||
|
SrsAmf0Any* prop = NULL;
|
||||||
|
if ((prop = arr->ensure_property_string("srs_version")) != NULL) {
|
||||||
|
srs_version = prop->to_str();
|
||||||
|
}
|
||||||
|
if ((prop = arr->ensure_property_string("srs_server_ip")) != NULL) {
|
||||||
|
srs_server_ip = prop->to_str();
|
||||||
|
}
|
||||||
|
if ((prop = arr->ensure_property_number("srs_id")) != NULL) {
|
||||||
|
srs_id = (int)prop->to_number();
|
||||||
|
}
|
||||||
|
if ((prop = arr->ensure_property_number("srs_pid")) != NULL) {
|
||||||
|
srs_pid = (int)prop->to_number();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
srs_trace("connected, version=%s, ip=%s, identity=[%d][%d]",
|
||||||
|
srs_version.c_str(), srs_server_ip.c_str(), srs_pid, srs_id);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -867,6 +893,7 @@ int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip)
|
||||||
data->set("srs_server_ip", SrsAmf0Any::str(server_ip));
|
data->set("srs_server_ip", SrsAmf0Any::str(server_ip));
|
||||||
}
|
}
|
||||||
// for edge to directly get the id of client.
|
// for edge to directly get the id of client.
|
||||||
|
data->set("srs_pid", SrsAmf0Any::number(getpid()));
|
||||||
data->set("srs_id", SrsAmf0Any::number(_srs_context->get_id()));
|
data->set("srs_id", SrsAmf0Any::number(_srs_context->get_id()));
|
||||||
|
|
||||||
if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) {
|
if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) {
|
||||||
|
|
Loading…
Reference in a new issue