mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
use librtmp to implemnts the bandwidth linux tool. 0.9.158
This commit is contained in:
parent
cc62d254f0
commit
9135aa117c
13 changed files with 371 additions and 81 deletions
|
@ -438,6 +438,25 @@ int SrsRtmpClient::connect_app(string app, string tc_url, SrsRequest* req)
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
std::string srs_server_ip;
|
||||
std::string srs_server;
|
||||
std::string srs_primary_authors;
|
||||
std::string srs_version;
|
||||
int srs_id = 0;
|
||||
int srs_pid = 0;
|
||||
|
||||
return connect_app2(app, tc_url, req,
|
||||
srs_server_ip, srs_server, srs_primary_authors,
|
||||
srs_version, srs_id, srs_pid);
|
||||
}
|
||||
|
||||
int SrsRtmpClient::connect_app2(
|
||||
string app, string tc_url, SrsRequest* req,
|
||||
string& srs_server_ip, string& srs_server, string& srs_primary_authors,
|
||||
string& srs_version, int& srs_id, int& srs_pid
|
||||
){
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// Connect(vhost, app)
|
||||
if (true) {
|
||||
SrsConnectAppPacket* pkt = new SrsConnectAppPacket();
|
||||
|
@ -492,22 +511,23 @@ int SrsRtmpClient::connect_app(string app, string tc_url, SrsRequest* req)
|
|||
SrsAutoFree(SrsConnectAppResPacket, pkt);
|
||||
|
||||
// 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_primary_authors")) != NULL) {
|
||||
srs_primary_authors = prop->to_str();
|
||||
}
|
||||
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_string("srs_server")) != NULL) {
|
||||
srs_server = prop->to_str();
|
||||
}
|
||||
if ((prop = arr->ensure_property_number("srs_id")) != NULL) {
|
||||
srs_id = (int)prop->to_number();
|
||||
}
|
||||
|
|
|
@ -249,6 +249,25 @@ public:
|
|||
*/
|
||||
virtual int connect_app(std::string app, std::string tc_url, SrsRequest* req=NULL);
|
||||
/**
|
||||
* connect to server, get the debug srs info.
|
||||
*
|
||||
* @param app, the app to connect at.
|
||||
* @param tc_url, the tcUrl to connect at.
|
||||
* @param req, the optional req object, use the swfUrl/pageUrl if specified. NULL to ignore.
|
||||
*
|
||||
* SRS debug info:
|
||||
* @param srs_server_ip, debug info, server ip client connected at.
|
||||
* @param srs_server, server info.
|
||||
* @param srs_primary_authors, primary authors.
|
||||
* @param srs_id, int, debug info, client id in server log.
|
||||
* @param srs_pid, int, debug info, server pid in log.
|
||||
*/
|
||||
virtual int connect_app2(
|
||||
std::string app, std::string tc_url, SrsRequest* req,
|
||||
std::string& srs_server_ip, std::string& srs_server, std::string& srs_primary_authors,
|
||||
std::string& srs_version, int& srs_id, int& srs_pid
|
||||
);
|
||||
/**
|
||||
* create a stream, then play/publish data over this stream.
|
||||
*/
|
||||
virtual int create_stream(int& stream_id);
|
||||
|
|
|
@ -3199,21 +3199,28 @@ int SrsBandwidthPacket::decode(SrsStream *stream)
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if ((ret = srs_amf0_read_string(stream, command_name)) != ERROR_SUCCESS) {
|
||||
srs_error("amf0 decode play command_name failed. ret=%d", ret);
|
||||
srs_error("amf0 decode bwtc command_name failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = srs_amf0_read_number(stream, transaction_id)) != ERROR_SUCCESS) {
|
||||
srs_error("amf0 decode play transaction_id failed. ret=%d", ret);
|
||||
srs_error("amf0 decode bwtc transaction_id failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = srs_amf0_read_null(stream)) != ERROR_SUCCESS) {
|
||||
srs_error("amf0 decode play command_object failed. ret=%d", ret);
|
||||
srs_error("amf0 decode bwtc command_object failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// @remark, for bandwidth test, ignore the data field.
|
||||
// only decode the stop-play, start-publish and finish packet.
|
||||
if (is_stop_play() || is_start_publish() || is_finish()) {
|
||||
if ((ret = data->read(stream)) != ERROR_SUCCESS) {
|
||||
srs_error("amf0 decode bwtc command_object failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
srs_info("decode SrsBandwidthPacket success.");
|
||||
|
||||
|
@ -3343,6 +3350,12 @@ SrsBandwidthPacket* SrsBandwidthPacket::create_stop_play()
|
|||
return pkt->set_command(SRS_BW_CHECK_STOP_PLAY);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_stopped_play()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STOPPED_PLAY);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_start_publish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
|
@ -3367,6 +3380,12 @@ SrsBandwidthPacket* SrsBandwidthPacket::create_stop_publish()
|
|||
return pkt->set_command(SRS_BW_CHECK_STOP_PUBLISH);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_stopped_publish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STOPPED_PUBLISH);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_finish()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
|
|
|
@ -1244,10 +1244,12 @@ public:
|
|||
static SrsBandwidthPacket* create_starting_play();
|
||||
static SrsBandwidthPacket* create_playing();
|
||||
static SrsBandwidthPacket* create_stop_play();
|
||||
static SrsBandwidthPacket* create_stopped_play();
|
||||
static SrsBandwidthPacket* create_start_publish();
|
||||
static SrsBandwidthPacket* create_starting_publish();
|
||||
static SrsBandwidthPacket* create_publishing();
|
||||
static SrsBandwidthPacket* create_stop_publish();
|
||||
static SrsBandwidthPacket* create_stopped_publish();
|
||||
static SrsBandwidthPacket* create_finish();
|
||||
static SrsBandwidthPacket* create_final();
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue