AI: Fix naming issue for protocol module. v7.0.83 (#4482)

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
This commit is contained in:
Winlin 2025-09-09 21:06:45 -04:00 committed by GitHub
parent 8f87d4092b
commit 3a29e5c550
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
67 changed files with 2872 additions and 2871 deletions

View File

@ -185,7 +185,7 @@ code_patterns:
public:
srs_error_t initialize();
};
scope: "Applies ONLY to fields (member variables) in classes and structs - NOT to functions, methods, or parameters"
scope: "Applies ONLY to fields (member variables) in classes and structs - NOT to functions, methods, comments, error messages, or parameters"
exceptions: "Only applies to SRS-defined classes/structs - do NOT change 3rd party code like llhttp"
rationale: "Consistent naming convention across SRS codebase for better code readability and maintenance - underscore distinguishes member variables from local variables and parameters"

View File

@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v7-changes"></a>
## SRS 7.0 Changelog
* v7.0, 2025-09-09, Merge [#4482](https://github.com/ossrs/srs/pull/4482): AI: Fix naming issue for protocol module. v7.0.83 (#4482)
* v7.0, 2025-09-07, Merge [#4479](https://github.com/ossrs/srs/pull/4479): AI: Fix naming problem in kernel module. v7.0.82 (#4479)
* v7.0, 2025-09-06, Merge [#4478](https://github.com/ossrs/srs/pull/4478): AI: Add more utests for kernel module. v7.0.81 (#4478)
* v7.0, 2025-09-06, Merge [#4475](https://github.com/ossrs/srs/pull/4475): AI: Support anonymous coroutine with code block. v7.0.80 (#4475)

View File

@ -355,7 +355,7 @@ bool srs_config_apply_filter(SrsConfDirective *dvr_apply, ISrsRequest *req)
return true;
}
string id = req->app + "/" + req->stream;
string id = req->app_ + "/" + req->stream_;
if (std::find(args.begin(), args.end(), id) != args.end()) {
return true;
}

View File

@ -98,7 +98,7 @@ SrsJsonAny *SrsCoWorkers::dumps(string vhost, string coworker, string app, strin
return SrsJsonAny::object()
->set("ip", SrsJsonAny::str(service_ip.c_str()))
->set("port", SrsJsonAny::integer(listen_port))
->set("vhost", SrsJsonAny::str(r->vhost.c_str()))
->set("vhost", SrsJsonAny::str(r->vhost_.c_str()))
->set("api", SrsJsonAny::str(backend.c_str()))
->set("routers", routers);
}

View File

@ -91,7 +91,7 @@ srs_error_t SrsFragmentedMp4::initialize(ISrsRequest *r, bool video, int64_t tim
(uint32_t)sequence_number, file_home.c_str(), file_name.c_str());
}
string home = _srs_config->get_dash_path(r->vhost);
string home = _srs_config->get_dash_path(r->vhost_);
set_path(home + "/" + file_home + "/" + file_name);
// Set number of the fragment, use in mpd SegmentTemplate@startNumber later.
set_number(sequence_number);
@ -177,7 +177,7 @@ SrsMpdWriter::~SrsMpdWriter()
void SrsMpdWriter::dispose()
{
if (req) {
string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
string mpd_path = srs_path_build_stream(mpd_file, req->vhost_, req->app_, req->stream_);
string full_path = home + "/" + mpd_path;
if (unlink(full_path.c_str()) < 0) {
srs_warn("ignore remove mpd failed, %s", full_path.c_str());
@ -201,15 +201,15 @@ srs_error_t SrsMpdWriter::on_publish()
{
ISrsRequest *r = req;
fragment = _srs_config->get_dash_fragment(r->vhost);
update_period = _srs_config->get_dash_update_period(r->vhost);
timeshit = _srs_config->get_dash_timeshift(r->vhost);
home = _srs_config->get_dash_path(r->vhost);
mpd_file = _srs_config->get_dash_mpd_file(r->vhost);
fragment = _srs_config->get_dash_fragment(r->vhost_);
update_period = _srs_config->get_dash_update_period(r->vhost_);
timeshit = _srs_config->get_dash_timeshift(r->vhost_);
home = _srs_config->get_dash_path(r->vhost_);
mpd_file = _srs_config->get_dash_mpd_file(r->vhost_);
string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream;
window_size_ = _srs_config->get_dash_window_size(r->vhost);
string mpd_path = srs_path_build_stream(mpd_file, req->vhost_, req->app_, req->stream_);
fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream_;
window_size_ = _srs_config->get_dash_window_size(r->vhost_);
srs_trace("DASH: Config fragment=%dms, period=%dms, window=%d, timeshit=%dms, home=%s, mpd=%s",
srsu2msi(fragment), srsu2msi(update_period), window_size_, srsu2msi(timeshit), home.c_str(), mpd_file.c_str());
@ -230,11 +230,11 @@ srs_error_t SrsMpdWriter::write(SrsFormat *format, SrsFragmentWindow *afragments
return err;
}
string mpd_path = srs_path_build_stream(mpd_file, req->vhost, req->app, req->stream);
string mpd_path = srs_path_build_stream(mpd_file, req->vhost_, req->app_, req->stream_);
string full_path = home + "/" + mpd_path;
string full_home = srs_path_filepath_dir(full_path);
fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream;
fragment_home = srs_path_filepath_dir(mpd_path) + "/" + req->stream_;
if ((err = srs_os_mkdir_all(full_home)) != srs_success) {
return srs_error_wrap(err, "Create MPD home failed, home=%s", full_home.c_str());
@ -254,7 +254,7 @@ srs_error_t SrsMpdWriter::write(SrsFormat *format, SrsFragmentWindow *afragments
<< " publishTime=\"" << srs_time_to_utc_format_str(srs_time_now_cached()) << "\" " << endl
<< " minBufferTime=\"PT" << srs_fmt_sprintf("%.3f", 2 * last_duration) << "S\" >" << endl;
ss << " <BaseURL>" << req->stream << "/" << "</BaseURL>" << endl;
ss << " <BaseURL>" << req->stream_ << "/" << "</BaseURL>" << endl;
ss << " <Period start=\"PT0S\">" << endl;
@ -425,8 +425,8 @@ srs_error_t SrsDashController::on_publish()
ISrsRequest *r = req;
fragment = _srs_config->get_dash_fragment(r->vhost);
home = _srs_config->get_dash_path(r->vhost);
fragment = _srs_config->get_dash_fragment(r->vhost_);
home = _srs_config->get_dash_path(r->vhost_);
if ((err = mpd->on_publish()) != srs_success) {
return srs_error_wrap(err, "mpd");
@ -531,8 +531,8 @@ srs_error_t SrsDashController::on_audio(SrsMediaPacket *shared_audio, SrsFormat
return srs_error_wrap(err, "Write audio to fragment failed");
}
srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost);
int window_size = _srs_config->get_dash_window_size(req->vhost);
srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost_);
int window_size = _srs_config->get_dash_window_size(req->vhost_);
int dash_window = 2 * window_size * fragment;
if (afragments->size() > window_size) {
int w = 0;
@ -545,7 +545,7 @@ srs_error_t SrsDashController::on_audio(SrsMediaPacket *shared_audio, SrsFormat
afragments->shrink(dash_window);
}
bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost);
bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost_);
// remove the m4s file.
afragments->clear_expired(dash_cleanup);
@ -604,8 +604,8 @@ srs_error_t SrsDashController::on_video(SrsMediaPacket *shared_video, SrsFormat
return srs_error_wrap(err, "Write video to fragment failed");
}
srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost);
int window_size = _srs_config->get_dash_window_size(req->vhost);
srs_utime_t fragment = _srs_config->get_dash_fragment(req->vhost_);
int window_size = _srs_config->get_dash_window_size(req->vhost_);
int dash_window = 2 * window_size * fragment;
if (vfragments->size() > window_size) {
int w = 0;
@ -618,7 +618,7 @@ srs_error_t SrsDashController::on_video(SrsMediaPacket *shared_video, SrsFormat
vfragments->shrink(dash_window);
}
bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost);
bool dash_cleanup = _srs_config->get_dash_cleanup(req->vhost_);
// remove the m4s file.
vfragments->clear_expired(dash_cleanup);
@ -650,7 +650,7 @@ srs_error_t SrsDashController::refresh_init_mp4(SrsMediaPacket *msg, SrsFormat *
return err;
}
string full_home = home + "/" + req->app + "/" + req->stream;
string full_home = home + "/" + req->app_ + "/" + req->stream_;
if ((err = srs_os_mkdir_all(full_home)) != srs_success) {
return srs_error_wrap(err, "Create media home failed, home=%s", full_home.c_str());
}
@ -703,7 +703,7 @@ void SrsDash::dispose()
}
// Ignore when dash_dispose disabled.
srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost);
srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost_);
if (!dash_dispose) {
return;
}
@ -723,7 +723,7 @@ srs_error_t SrsDash::cycle()
return err;
}
srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost);
srs_utime_t dash_dispose = _srs_config->get_dash_dispose(req->vhost_);
if (dash_dispose <= 0) {
return err;
}
@ -746,7 +746,7 @@ srs_error_t SrsDash::cycle()
srs_utime_t SrsDash::cleanup_delay()
{
// We use larger timeout to cleanup the HLS, after disposed it if required.
return _srs_config->get_dash_dispose(req->vhost) * 1.1;
return _srs_config->get_dash_dispose(req->vhost_) * 1.1;
}
// CRITICAL: This method is called AFTER the source has been added to the source pool
@ -778,7 +778,7 @@ srs_error_t SrsDash::on_publish()
return err;
}
if (!_srs_config->get_dash_enabled(req->vhost)) {
if (!_srs_config->get_dash_enabled(req->vhost_)) {
return err;
}
enabled = true;

View File

@ -62,8 +62,8 @@ srs_error_t SrsDvrSegmenter::initialize(SrsDvrPlan *p, ISrsRequest *r)
req = r;
plan = p;
jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_dvr_time_jitter(req->vhost);
wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost);
jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_dvr_time_jitter(req->vhost_);
wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost_);
return srs_success;
}
@ -113,7 +113,7 @@ srs_error_t SrsDvrSegmenter::open()
return srs_error_wrap(err, "open encoder");
}
srs_trace("dvr stream %s to file %s", req->stream.c_str(), path.c_str());
srs_trace("dvr stream %s to file %s", req->stream_.c_str(), path.c_str());
return err;
}
@ -200,7 +200,7 @@ string SrsDvrSegmenter::generate_path()
{
// the path in config, for example,
// /data/[vhost]/[app]/[stream]/[2006]/[01]/[02]/[15].[04].[05].[999].flv
std::string path_config = _srs_config->get_dvr_path(req->vhost);
std::string path_config = _srs_config->get_dvr_path(req->vhost_);
// add [stream].[timestamp].flv as filename for dir
if (!srs_strings_ends_with(path_config, ".flv", ".mp4")) {
@ -209,7 +209,7 @@ string SrsDvrSegmenter::generate_path()
// the flv file path
std::string flv_path = path_config;
flv_path = srs_path_build_stream(flv_path, req->vhost, req->app, req->stream);
flv_path = srs_path_build_stream(flv_path, req->vhost_, req->app_, req->stream_);
flv_path = srs_path_build_timestamp(flv_path);
return flv_path;
@ -525,7 +525,7 @@ srs_error_t SrsDvrAsyncCallOnDvr::call()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -535,7 +535,7 @@ srs_error_t SrsDvrAsyncCallOnDvr::call()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_dvr(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_dvr(req->vhost_);
if (conf) {
hooks = conf->args;
}
@ -554,7 +554,7 @@ srs_error_t SrsDvrAsyncCallOnDvr::call()
string SrsDvrAsyncCallOnDvr::to_string()
{
std::stringstream ss;
ss << "vhost=" << req->vhost << ", file=" << path;
ss << "vhost=" << req->vhost_ << ", file=" << path;
return ss.str();
}
@ -706,7 +706,7 @@ srs_error_t SrsDvrSessionPlan::on_publish(ISrsRequest *r)
return err;
}
if (!_srs_config->get_dvr_enabled(req->vhost)) {
if (!_srs_config->get_dvr_enabled(req->vhost_)) {
return err;
}
@ -763,9 +763,9 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub *h, SrsDvrSegmenter *s, I
return srs_error_wrap(err, "segment plan");
}
wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost);
wait_keyframe = _srs_config->get_dvr_wait_keyframe(req->vhost_);
cduration = _srs_config->get_dvr_duration(req->vhost);
cduration = _srs_config->get_dvr_duration(req->vhost_);
return srs_success;
}
@ -783,7 +783,7 @@ srs_error_t SrsDvrSegmentPlan::on_publish(ISrsRequest *r)
return err;
}
if (!_srs_config->get_dvr_enabled(req->vhost)) {
if (!_srs_config->get_dvr_enabled(req->vhost_)) {
return err;
}
@ -934,15 +934,15 @@ srs_error_t SrsDvr::initialize(SrsOriginHub *h, ISrsRequest *r)
req = r->copy();
hub = h;
SrsConfDirective *conf = _srs_config->get_dvr_apply(r->vhost);
SrsConfDirective *conf = _srs_config->get_dvr_apply(r->vhost_);
actived = srs_config_apply_filter(conf, r);
srs_freep(plan);
if ((err = SrsDvrPlan::create_plan(r->vhost, &plan)) != srs_success) {
if ((err = SrsDvrPlan::create_plan(r->vhost_, &plan)) != srs_success) {
return srs_error_wrap(err, "create plan");
}
std::string path = _srs_config->get_dvr_path(r->vhost);
std::string path = _srs_config->get_dvr_path(r->vhost_);
SrsDvrSegmenter *segmenter = NULL;
if (srs_strings_ends_with(path, ".mp4")) {
segmenter = new SrsDvrMp4Segmenter();

View File

@ -70,12 +70,12 @@ srs_error_t SrsEdgeRtmpUpstream::connect(ISrsRequest *r, ISrsLbRoundRobin *lb)
std::string url;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_edge_origin(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_edge_origin(req->vhost_);
// when origin is error, for instance, server is shutdown,
// then user remove the vhost then reload, the conf is empty.
if (!conf) {
return srs_error_new(ERROR_EDGE_VHOST_REMOVED, "vhost %s removed", req->vhost.c_str());
return srs_error_new(ERROR_EDGE_VHOST_REMOVED, "vhost %s removed", req->vhost_.c_str());
}
// select the origin.
@ -98,10 +98,10 @@ srs_error_t SrsEdgeRtmpUpstream::connect(ISrsRequest *r, ISrsLbRoundRobin *lb)
selected_port = port;
// support vhost tranform for edge,
std::string vhost = _srs_config->get_vhost_edge_transform_vhost(req->vhost);
vhost = srs_strings_replace(vhost, "[vhost]", req->vhost);
std::string vhost = _srs_config->get_vhost_edge_transform_vhost(req->vhost_);
vhost = srs_strings_replace(vhost, "[vhost]", req->vhost_);
url = srs_net_url_encode_rtmp_url(server, port, req->host, vhost, req->app, req->stream, req->param);
url = srs_net_url_encode_rtmp_url(server, port, req->host_, vhost, req->app_, req->stream_, req->param_);
}
srs_freep(sdk);
@ -116,11 +116,11 @@ srs_error_t SrsEdgeRtmpUpstream::connect(ISrsRequest *r, ISrsLbRoundRobin *lb)
// For RTMP client, we pass the vhost in tcUrl when connecting,
// so we publish without vhost in stream.
string stream;
if ((err = sdk->play(_srs_config->get_chunk_size(req->vhost), false, &stream)) != srs_success) {
if ((err = sdk->play(_srs_config->get_chunk_size(req->vhost_), false, &stream)) != srs_success) {
return srs_error_wrap(err, "edge pull %s stream failed", url.c_str());
}
srs_trace("edge-pull publish url %s, stream=%s%s as %s", url.c_str(), req->stream.c_str(), req->param.c_str(), stream.c_str());
srs_trace("edge-pull publish url %s, stream=%s%s as %s", url.c_str(), req->stream_.c_str(), req->param_.c_str(), stream.c_str());
return err;
}
@ -192,12 +192,12 @@ srs_error_t SrsEdgeFlvUpstream::do_connect(ISrsRequest *r, ISrsLbRoundRobin *lb,
ISrsRequest *req = r;
if (redirect_depth == 0) {
SrsConfDirective *conf = _srs_config->get_vhost_edge_origin(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_edge_origin(req->vhost_);
// when origin is error, for instance, server is shutdown,
// then user remove the vhost then reload, the conf is empty.
if (!conf) {
return srs_error_new(ERROR_EDGE_VHOST_REMOVED, "vhost %s removed", req->vhost.c_str());
return srs_error_new(ERROR_EDGE_VHOST_REMOVED, "vhost %s removed", req->vhost_.c_str());
}
// select the origin.
@ -213,20 +213,20 @@ srs_error_t SrsEdgeFlvUpstream::do_connect(ISrsRequest *r, ISrsLbRoundRobin *lb,
selected_port = port;
} else {
// If HTTP redirect, use the server in location.
schema_ = req->schema;
selected_ip = req->host;
selected_port = req->port;
schema_ = req->schema_;
selected_ip = req->host_;
selected_port = req->port_;
}
srs_freep(sdk_);
sdk_ = new SrsHttpClient();
string path = "/" + req->app + "/" + req->stream;
if (!srs_strings_ends_with(req->stream, ".flv")) {
string path = "/" + req->app_ + "/" + req->stream_;
if (!srs_strings_ends_with(req->stream_, ".flv")) {
path += ".flv";
}
if (!req->param.empty()) {
path += req->param;
if (!req->param_.empty()) {
path += req->param_;
}
string url = schema_ + "://" + selected_ip + ":" + srs_strconv_format_int(selected_port);
@ -267,12 +267,12 @@ srs_error_t SrsEdgeFlvUpstream::do_connect(ISrsRequest *r, ISrsLbRoundRobin *lb,
string schema, host, vhost, param;
srs_net_url_parse_tcurl(tcUrl, schema, host, vhost, app, stream_name, port, param);
r->schema = schema;
r->host = host;
r->port = port;
r->app = app;
r->stream = stream_name;
r->param = param;
r->schema_ = schema;
r->host_ = host;
r->port_ = port;
r->app_ = app;
r->stream_ = stream_name;
r->param_ = param;
}
return do_connect(r, lb, redirect_depth + 1);
}
@ -519,12 +519,12 @@ srs_error_t SrsEdgeIngester::do_cycle()
}
// Use protocol in config.
string edge_protocol = _srs_config->get_vhost_edge_protocol(req->vhost);
string edge_protocol = _srs_config->get_vhost_edge_protocol(req->vhost_);
// If follow client protocol, change to protocol of client.
bool follow_client = _srs_config->get_vhost_edge_follow_client(req->vhost);
if (follow_client && !req->protocol.empty()) {
edge_protocol = req->protocol;
bool follow_client = _srs_config->get_vhost_edge_follow_client(req->vhost_);
if (follow_client && !req->protocol_.empty()) {
edge_protocol = req->protocol_;
}
// Create object by protocol.
@ -670,12 +670,12 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsRtmpCommonMessage *msg,
// RTMP 302 redirect
if (dynamic_cast<SrsCallPacket *>(pkt.get())) {
SrsCallPacket *call = dynamic_cast<SrsCallPacket *>(pkt.get());
if (!call->arguments->is_object()) {
if (!call->arguments_->is_object()) {
return err;
}
SrsAmf0Any *prop = NULL;
SrsAmf0Object *evt = call->arguments->to_object();
SrsAmf0Object *evt = call->arguments_->to_object();
if ((prop = evt->ensure_property_string("level")) == NULL) {
return err;
@ -758,7 +758,7 @@ srs_error_t SrsEdgeForwarder::start()
std::string url;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_edge_origin(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_edge_origin(req->vhost_);
srs_assert(conf);
// select the origin.
@ -767,10 +767,10 @@ srs_error_t SrsEdgeForwarder::start()
srs_net_split_hostport(server, server, port);
// support vhost tranform for edge,
std::string vhost = _srs_config->get_vhost_edge_transform_vhost(req->vhost);
vhost = srs_strings_replace(vhost, "[vhost]", req->vhost);
std::string vhost = _srs_config->get_vhost_edge_transform_vhost(req->vhost_);
vhost = srs_strings_replace(vhost, "[vhost]", req->vhost_);
url = srs_net_url_encode_rtmp_url(server, port, req->host, vhost, req->app, req->stream, req->param);
url = srs_net_url_encode_rtmp_url(server, port, req->host_, vhost, req->app_, req->stream_, req->param_);
}
// We must stop the coroutine before disposing the sdk.
@ -790,7 +790,7 @@ srs_error_t SrsEdgeForwarder::start()
// For RTMP client, we pass the vhost in tcUrl when connecting,
// so we publish without vhost in stream.
string stream;
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost), false, &stream)) != srs_success) {
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost_), false, &stream)) != srs_success) {
return srs_error_wrap(err, "sdk publish");
}
@ -799,7 +799,7 @@ srs_error_t SrsEdgeForwarder::start()
return srs_error_wrap(err, "coroutine");
}
srs_trace("edge-fwr publish url %s, stream=%s%s as %s", url.c_str(), req->stream.c_str(), req->param.c_str(), stream.c_str());
srs_trace("edge-fwr publish url %s, stream=%s%s as %s", url.c_str(), req->stream_.c_str(), req->param_.c_str(), stream.c_str());
return err;
}
@ -881,9 +881,9 @@ srs_error_t SrsEdgeForwarder::do_cycle()
}
// forward all messages.
// each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
// each msg in msgs.msgs_ must be free, for the SrsMessageArray never free them.
int count = 0;
if ((err = queue->dump_packets(msgs.max, msgs.msgs, count)) != srs_success) {
if ((err = queue->dump_packets(msgs.max_, msgs.msgs_, count)) != srs_success) {
return srs_error_wrap(err, "queue dumps packets");
}
@ -901,7 +901,7 @@ srs_error_t SrsEdgeForwarder::do_cycle()
}
// sendout messages, all messages are freed by send_and_free_messages().
if ((err = sdk->send_and_free_messages(msgs.msgs, count)) != srs_success) {
if ((err = sdk->send_and_free_messages(msgs.msgs_, count)) != srs_success) {
return srs_error_wrap(err, "send messages");
}
}

View File

@ -164,22 +164,22 @@ srs_error_t SrsEncoder::parse_scope_engines(ISrsRequest *req)
// parse vhost scope engines
std::string scope = "";
if ((conf = _srs_config->get_transcode(req->vhost, scope)) != NULL) {
if ((conf = _srs_config->get_transcode(req->vhost_, scope)) != NULL) {
if ((err = parse_ffmpeg(req, conf)) != srs_success) {
return srs_error_wrap(err, "parse ffmpeg");
}
}
// parse app scope engines
scope = req->app;
if ((conf = _srs_config->get_transcode(req->vhost, scope)) != NULL) {
scope = req->app_;
if ((conf = _srs_config->get_transcode(req->vhost_, scope)) != NULL) {
if ((err = parse_ffmpeg(req, conf)) != srs_success) {
return srs_error_wrap(err, "parse ffmpeg");
}
}
// parse stream scope engines
scope += "/";
scope += req->stream;
if ((conf = _srs_config->get_transcode(req->vhost, scope)) != NULL) {
scope += req->stream_;
if ((conf = _srs_config->get_transcode(req->vhost_, scope)) != NULL) {
if ((err = parse_ffmpeg(req, conf)) != srs_success) {
return srs_error_wrap(err, "parse ffmpeg");
}
@ -244,29 +244,29 @@ srs_error_t SrsEncoder::initialize_ffmpeg(SrsFFMPEG *ffmpeg, ISrsRequest *req, S
input = "rtmp://";
input += SRS_CONSTS_LOCALHOST;
input += ":";
input += srs_strconv_format_int(req->port);
input += srs_strconv_format_int(req->port_);
input += "/";
input += req->app;
input += req->app_;
input += "/";
input += req->stream;
input += req->stream_;
input += "?vhost=";
input += req->vhost;
input += req->vhost_;
// stream name: vhost/app/stream for print
input_stream_name = req->vhost;
input_stream_name = req->vhost_;
input_stream_name += "/";
input_stream_name += req->app;
input_stream_name += req->app_;
input_stream_name += "/";
input_stream_name += req->stream;
input_stream_name += req->stream_;
std::string output = _srs_config->get_engine_output(engine);
// output stream, to other/self server
// ie. rtmp://localhost:1935/live/livestream_sd
output = srs_strings_replace(output, "[vhost]", req->vhost);
output = srs_strings_replace(output, "[port]", srs_strconv_format_int(req->port));
output = srs_strings_replace(output, "[app]", req->app);
output = srs_strings_replace(output, "[stream]", req->stream);
output = srs_strings_replace(output, "[param]", req->param);
output = srs_strings_replace(output, "[vhost]", req->vhost_);
output = srs_strings_replace(output, "[port]", srs_strconv_format_int(req->port_));
output = srs_strings_replace(output, "[app]", req->app_);
output = srs_strings_replace(output, "[stream]", req->stream_);
output = srs_strings_replace(output, "[param]", req->param_);
output = srs_strings_replace(output, "[engine]", engine->arg0());
output = srs_path_build_timestamp(output);
@ -277,11 +277,11 @@ srs_error_t SrsEncoder::initialize_ffmpeg(SrsFFMPEG *ffmpeg, ISrsRequest *req, S
log_file += "/";
log_file += "ffmpeg-encoder";
log_file += "-";
log_file += req->vhost;
log_file += req->vhost_;
log_file += "-";
log_file += req->app;
log_file += req->app_;
log_file += "-";
log_file += req->stream;
log_file += req->stream_;
if (!engine->args.empty()) {
log_file += "-";
log_file += engine->arg0();

View File

@ -209,7 +209,7 @@ srs_error_t SrsForwarder::do_cycle()
srs_net_split_hostport(ep_forward, server, port);
// generate url
url = srs_net_url_encode_rtmp_url(server, port, req->host, req->vhost, req->app, req->stream, req->param);
url = srs_net_url_encode_rtmp_url(server, port, req->host_, req->vhost_, req->app_, req->stream_, req->param_);
}
srs_freep(sdk);
@ -224,7 +224,7 @@ srs_error_t SrsForwarder::do_cycle()
// For RTMP client, we pass the vhost in tcUrl when connecting,
// so we publish without vhost in stream.
string stream;
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost), false, &stream)) != srs_success) {
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost_), false, &stream)) != srs_success) {
return srs_error_wrap(err, "sdk publish");
}
@ -236,7 +236,7 @@ srs_error_t SrsForwarder::do_cycle()
return srs_error_wrap(err, "forward");
}
srs_trace("forward publish url %s, stream=%s%s as %s", url.c_str(), req->stream.c_str(), req->param.c_str(), stream.c_str());
srs_trace("forward publish url %s, stream=%s%s as %s", url.c_str(), req->stream_.c_str(), req->param_.c_str(), stream.c_str());
return err;
}
@ -286,9 +286,9 @@ srs_error_t SrsForwarder::forward()
}
// forward all messages.
// each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
// each msg in msgs.msgs_ must be free, for the SrsMessageArray never free them.
int count = 0;
if ((err = queue->dump_packets(msgs.max, msgs.msgs, count)) != srs_success) {
if ((err = queue->dump_packets(msgs.max_, msgs.msgs_, count)) != srs_success) {
return srs_error_wrap(err, "dump packets");
}
@ -303,7 +303,7 @@ srs_error_t SrsForwarder::forward()
}
// sendout messages, all messages are freed by send_and_free_messages().
if ((err = sdk->send_and_free_messages(msgs.msgs, count)) != srs_success) {
if ((err = sdk->send_and_free_messages(msgs.msgs_, count)) != srs_success) {
return srs_error_wrap(err, "send messages");
}
}

View File

@ -1180,7 +1180,7 @@ srs_error_t SrsGbMuxer::on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs)
}
aac_specific_config_ = sh;
codec.aac_packet_type = 0;
codec.aac_packet_type_ = 0;
if ((err = write_audio_raw_frame((char *)sh.data(), (int)sh.length(), &codec, dts)) != srs_success) {
return srs_error_wrap(err, "write raw audio frame");
@ -1188,7 +1188,7 @@ srs_error_t SrsGbMuxer::on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs)
}
// audio raw data.
codec.aac_packet_type = 1;
codec.aac_packet_type_ = 1;
if ((err = write_audio_raw_frame(frame, frame_size, &codec, dts)) != srs_success) {
return srs_error_wrap(err, "write audio raw frame");
}

View File

@ -275,7 +275,7 @@ srs_error_t SrsDvrAsyncCallOnHls::call()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -285,7 +285,7 @@ srs_error_t SrsDvrAsyncCallOnHls::call()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_hls(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_hls(req->vhost_);
if (!conf) {
return err;
@ -325,7 +325,7 @@ srs_error_t SrsDvrAsyncCallOnHlsNotify::call()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -335,7 +335,7 @@ srs_error_t SrsDvrAsyncCallOnHlsNotify::call()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_hls_notify(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_hls_notify(req->vhost_);
if (!conf) {
return err;
@ -344,7 +344,7 @@ srs_error_t SrsDvrAsyncCallOnHlsNotify::call()
hooks = conf->args;
}
int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost);
int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost_);
for (int i = 0; i < (int)hooks.size(); i++) {
std::string url = hooks.at(i);
if ((err = _srs_hooks->on_hls_notify(cid, url, req, ts_url, nb_notify)) != srs_success) {
@ -494,9 +494,9 @@ srs_error_t SrsHlsFmp4Muxer::write_init_mp4(SrsFormat *format, bool has_video, b
{
srs_error_t err = srs_success;
std::string vhost = req_->vhost;
std::string stream = req_->stream;
std::string app = req_->app;
std::string vhost = req_->vhost_;
std::string stream = req_->stream_;
std::string app = req_->app_;
// Get init.mp4 file template from configuration
std::string init_file = _srs_config->get_hls_init_file(vhost);
@ -645,9 +645,9 @@ srs_error_t SrsHlsFmp4Muxer::update_config(ISrsRequest *r)
srs_freep(req_);
req_ = r->copy();
std::string vhost = req_->vhost;
std::string stream = req_->stream;
std::string app = req_->app;
std::string vhost = req_->vhost_;
std::string stream = req_->stream_;
std::string app = req_->app_;
hls_fragment_ = _srs_config->get_hls_fragment(vhost);
double hls_td_ratio = _srs_config->get_hls_td_ratio(vhost);
@ -722,7 +722,7 @@ srs_error_t SrsHlsFmp4Muxer::segment_open(srs_utime_t basetime)
// generate filename.
std::string m4s_file = hls_m4s_file_;
m4s_file = srs_path_build_stream(m4s_file, req_->vhost, req_->app, req_->stream);
m4s_file = srs_path_build_stream(m4s_file, req_->vhost_, req_->app_, req_->stream_);
if (hls_ts_floor_) {
// accept the floor ts for the first piece.
int64_t current_floor_ts = srs_time_now_realtime() / hls_fragment_;
@ -903,7 +903,7 @@ srs_error_t SrsHlsFmp4Muxer::write_hls_key()
return srs_error_wrap(err, "rand iv failed.");
}
string key_file = srs_path_build_stream(hls_key_file_, req_->vhost, req_->app, req_->stream);
string key_file = srs_path_build_stream(hls_key_file_, req_->vhost_, req_->app_, req_->stream_);
key_file = srs_strings_replace(key_file, "[seq]", srs_strconv_format_int(current_->sequence_no));
string key_url = hls_key_file_path_ + "/" + key_file;
@ -1016,7 +1016,7 @@ srs_error_t SrsHlsFmp4Muxer::_refresh_m3u8(std::string m3u8_file)
srs_hex_encode_to_string(hexiv, segment->iv, 16);
hexiv[32] = '\0';
string key_file = srs_path_build_stream(hls_key_file_, req_->vhost, req_->app, req_->stream);
string key_file = srs_path_build_stream(hls_key_file_, req_->vhost_, req_->app_, req_->stream_);
key_file = srs_strings_replace(key_file, "[seq]", srs_strconv_format_int(segment->sequence_no));
string key_path = key_file;
@ -1236,11 +1236,11 @@ srs_error_t SrsHlsMuxer::update_config(ISrsRequest *r, string entry_prefix,
hls_key_url = key_url;
// generate the m3u8 dir and path.
m3u8_url = srs_path_build_stream(m3u8_file, req->vhost, req->app, req->stream);
m3u8_url = srs_path_build_stream(m3u8_file, req->vhost_, req->app_, req->stream_);
m3u8 = path + "/" + m3u8_url;
// when update config, reset the history target duration.
max_td = fragment * _srs_config->get_hls_td_ratio(r->vhost);
max_td = fragment * _srs_config->get_hls_td_ratio(r->vhost_);
// create m3u8 dir once.
m3u8_dir = srs_path_filepath_dir(m3u8);
@ -1249,7 +1249,7 @@ srs_error_t SrsHlsMuxer::update_config(ISrsRequest *r, string entry_prefix,
}
if (hls_keys && (hls_path != hls_key_file_path)) {
string key_file = srs_path_build_stream(hls_key_file, req->vhost, req->app, req->stream);
string key_file = srs_path_build_stream(hls_key_file, req->vhost_, req->app_, req->stream_);
string key_url = hls_key_file_path + "/" + key_file;
string key_dir = srs_path_filepath_dir(key_url);
if ((err = srs_os_mkdir_all(key_dir)) != srs_success) {
@ -1382,7 +1382,7 @@ srs_error_t SrsHlsMuxer::recover_hls()
// new segment.
SrsHlsSegment *seg = new SrsHlsSegment(context, default_acodec, default_vcodec, writer);
seg->sequence_no = _sequence_no++;
seg->set_path(hls_path + "/" + req->app + "/" + ts_url);
seg->set_path(hls_path + "/" + req->app_ + "/" + ts_url);
seg->uri = ts_url;
seg->set_sequence_header(discon);
@ -1448,7 +1448,7 @@ srs_error_t SrsHlsMuxer::segment_open()
// generate filename.
std::string ts_file = hls_ts_file;
ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream);
ts_file = srs_path_build_stream(ts_file, req->vhost_, req->app_, req->stream_);
if (hls_ts_floor) {
// accept the floor ts for the first piece.
int64_t current_floor_ts = srs_time_now_realtime() / hls_fragment;
@ -1741,7 +1741,7 @@ srs_error_t SrsHlsMuxer::write_hls_key()
return srs_error_wrap(err, "rand iv failed.");
}
string key_file = srs_path_build_stream(hls_key_file, req->vhost, req->app, req->stream);
string key_file = srs_path_build_stream(hls_key_file, req->vhost_, req->app_, req->stream_);
key_file = srs_strings_replace(key_file, "[seq]", srs_strconv_format_int(current->sequence_no));
string key_url = hls_key_file_path + "/" + key_file;
@ -1852,7 +1852,7 @@ srs_error_t SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
srs_hex_encode_to_string(hexiv, segment->iv, 16);
hexiv[32] = '\0';
string key_file = srs_path_build_stream(hls_key_file, req->vhost, req->app, req->stream);
string key_file = srs_path_build_stream(hls_key_file, req->vhost_, req->app_, req->stream_);
key_file = srs_strings_replace(key_file, "[seq]", srs_strconv_format_int(segment->sequence_no));
string key_path = key_file;
@ -1957,9 +1957,9 @@ srs_error_t SrsHlsController::on_publish(ISrsRequest *req)
{
srs_error_t err = srs_success;
std::string vhost = req->vhost;
std::string stream = req->stream;
std::string app = req->app;
std::string vhost = req->vhost_;
std::string stream = req->stream_;
std::string app = req->app_;
srs_utime_t hls_fragment = _srs_config->get_hls_fragment(vhost);
double hls_td_ratio = _srs_config->get_hls_td_ratio(vhost);
@ -2011,7 +2011,7 @@ srs_error_t SrsHlsController::on_publish(ISrsRequest *req)
// This config item is used in SrsHls, we just log its value here.
// If enabled, directly turn FLV timestamp to TS DTS.
// @remark It'll be reloaded automatically, because the origin hub will republish while reloading.
hls_dts_directly = _srs_config->get_vhost_hls_dts_directly(req->vhost);
hls_dts_directly = _srs_config->get_vhost_hls_dts_directly(req->vhost_);
srs_trace("hls: win=%dms, frag=%dms, prefix=%s, path=%s, m3u8=%s, ts=%s, tdr=%.2f, aof=%.2f, floor=%d, clean=%d, waitk=%d, dispose=%dms, dts_directly=%d",
srsu2msi(hls_window), srsu2msi(hls_fragment), entry_prefix.c_str(), path.c_str(), m3u8_file.c_str(), ts_file.c_str(),
@ -2268,9 +2268,9 @@ srs_error_t SrsHlsMp4Controller::on_publish(ISrsRequest *req)
srs_error_t err = srs_success;
req_ = req;
std::string vhost = req->vhost;
std::string stream = req->stream;
std::string app = req->app;
std::string vhost = req->vhost_;
std::string stream = req->stream_;
std::string app = req->app_;
// get the hls m3u8 ts list entry prefix config
std::string entry_prefix = _srs_config->get_hls_entry_prefix(vhost);
@ -2483,7 +2483,7 @@ void SrsHls::dispose()
// Ignore when hls_dispose disabled.
// @see https://github.com/ossrs/srs/issues/865
srs_utime_t hls_dispose = _srs_config->get_hls_dispose(req->vhost);
srs_utime_t hls_dispose = _srs_config->get_hls_dispose(req->vhost_);
if (!hls_dispose) {
return;
}
@ -2512,7 +2512,7 @@ srs_error_t SrsHls::cycle()
return err;
// If not unpublishing and not reloading, try to dispose HLS stream.
srs_utime_t hls_dispose = _srs_config->get_hls_dispose(req->vhost);
srs_utime_t hls_dispose = _srs_config->get_hls_dispose(req->vhost_);
if (hls_dispose <= 0) {
return err;
}
@ -2535,7 +2535,7 @@ srs_error_t SrsHls::cycle()
srs_utime_t SrsHls::cleanup_delay()
{
// We use larger timeout to cleanup the HLS, after disposed it if required.
return _srs_config->get_hls_dispose(req->vhost) * 1.1;
return _srs_config->get_hls_dispose(req->vhost_) * 1.1;
}
// CRITICAL: This method is called AFTER the source has been added to the source pool
@ -2551,7 +2551,7 @@ srs_error_t SrsHls::initialize(SrsOriginHub *h, ISrsRequest *r)
hub = h;
req = r;
bool is_fmp4_enabled = _srs_config->get_hls_use_fmp4(r->vhost);
bool is_fmp4_enabled = _srs_config->get_hls_use_fmp4(r->vhost_);
if (!controller) {
if (is_fmp4_enabled) {
@ -2580,7 +2580,7 @@ srs_error_t SrsHls::on_publish()
return err;
}
if (!_srs_config->get_hls_enabled(req->vhost)) {
if (!_srs_config->get_hls_enabled(req->vhost_)) {
return err;
}

View File

@ -64,13 +64,13 @@ srs_error_t SrsHttpHooks::on_connect(string url, ISrsRequest *req)
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_connect"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl_.c_str()));
std::string data = obj->dumps();
std::string res;
@ -100,9 +100,9 @@ void SrsHttpHooks::on_close(string url, ISrsRequest *req, int64_t send_bytes, in
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_close"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("send_bytes", SrsJsonAny::integer(send_bytes));
obj->set("recv_bytes", SrsJsonAny::integer(recv_bytes));
@ -137,12 +137,12 @@ srs_error_t SrsHttpHooks::on_publish(string url, ISrsRequest *req)
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_publish"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
obj->set("stream_url", SrsJsonAny::str(req->get_stream_url().c_str()));
SrsStatisticStream *stream = stat->find_stream_by_url(req->get_stream_url());
@ -178,12 +178,12 @@ void SrsHttpHooks::on_unpublish(string url, ISrsRequest *req)
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_unpublish"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
obj->set("stream_url", SrsJsonAny::str(req->get_stream_url().c_str()));
SrsStatisticStream *stream = stat->find_stream_by_url(req->get_stream_url());
@ -222,13 +222,13 @@ srs_error_t SrsHttpHooks::on_play(string url, ISrsRequest *req)
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_play"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl_.c_str()));
obj->set("stream_url", SrsJsonAny::str(req->get_stream_url().c_str()));
SrsStatisticStream *stream = stat->find_stream_by_url(req->get_stream_url());
@ -264,12 +264,12 @@ void SrsHttpHooks::on_stop(string url, ISrsRequest *req)
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_stop"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
obj->set("stream_url", SrsJsonAny::str(req->get_stream_url().c_str()));
SrsStatisticStream *stream = stat->find_stream_by_url(req->get_stream_url());
@ -310,12 +310,12 @@ srs_error_t SrsHttpHooks::on_dvr(SrsContextId c, string url, ISrsRequest *req, s
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_dvr"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
obj->set("cwd", SrsJsonAny::str(cwd.c_str()));
obj->set("file", SrsJsonAny::str(file.c_str()));
@ -361,12 +361,12 @@ srs_error_t SrsHttpHooks::on_hls(SrsContextId c, string url, ISrsRequest *req, s
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_hls"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
obj->set("duration", SrsJsonAny::number(srsu2ms(duration) / 1000.0));
obj->set("cwd", SrsJsonAny::str(cwd.c_str()));
obj->set("file", SrsJsonAny::str(file.c_str()));
@ -411,10 +411,10 @@ srs_error_t SrsHttpHooks::on_hls_notify(SrsContextId c, std::string url, ISrsReq
url = srs_strings_replace(url, "[server_id]", stat->server_id().c_str());
url = srs_strings_replace(url, "[service_id]", stat->service_id().c_str());
url = srs_strings_replace(url, "[app]", req->app);
url = srs_strings_replace(url, "[stream]", req->stream);
url = srs_strings_replace(url, "[app]", req->app_);
url = srs_strings_replace(url, "[stream]", req->stream_);
url = srs_strings_replace(url, "[ts_url]", ts_url);
url = srs_strings_replace(url, "[param]", req->param);
url = srs_strings_replace(url, "[param]", req->param_);
int64_t starttime = srsu2ms(srs_time_now_realtime());
@ -533,12 +533,12 @@ srs_error_t SrsHttpHooks::on_forward_backend(string url, ISrsRequest *req, std::
obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
obj->set("app", SrsJsonAny::str(req->app.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream.c_str()));
obj->set("param", SrsJsonAny::str(req->param.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost_.c_str()));
obj->set("app", SrsJsonAny::str(req->app_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("stream", SrsJsonAny::str(req->stream_.c_str()));
obj->set("param", SrsJsonAny::str(req->param_.c_str()));
std::string data = obj->dumps();
std::string res;

View File

@ -85,14 +85,14 @@ srs_error_t SrsHlsStream::serve_m3u8_ctx(ISrsHttpResponseWriter *w, ISrsHttpMess
string ctx = r->query_get(SRS_CONTEXT_IN_HLS);
// If HLS stream is disabled, use SrsHttpFileServer to serve HLS, which is normal file server.
if (!_srs_config->get_hls_ctx_enabled(req->vhost)) {
if (!_srs_config->get_hls_ctx_enabled(req->vhost_)) {
*served = false;
return srs_success;
}
// Correct the app and stream by path, which is created from template.
// @remark Be careful that the stream has extension now, might cause identify fail.
req->stream = srs_path_filepath_base(r->path());
req->stream_ = srs_path_filepath_base(r->path());
// Served by us.
*served = true;
@ -100,7 +100,7 @@ srs_error_t SrsHlsStream::serve_m3u8_ctx(ISrsHttpResponseWriter *w, ISrsHttpMess
// Already exists context, response with rebuilt m3u8 content.
if (!ctx.empty() && ctx_is_exist(ctx)) {
// If HLS stream is disabled, use SrsHttpFileServer to serve HLS, which is normal file server.
if (!_srs_config->get_hls_ts_ctx_enabled(req->vhost)) {
if (!_srs_config->get_hls_ts_ctx_enabled(req->vhost_)) {
*served = false;
return srs_success;
}
@ -167,7 +167,7 @@ srs_error_t SrsHlsStream::serve_new_session(ISrsHttpResponseWriter *w, ISrsHttpM
return srs_error_wrap(err, "stat on client");
}
if ((err = security_->check(SrsHlsPlay, req->ip, req)) != srs_success) {
if ((err = security_->check(SrsHlsPlay, req->ip_, req)) != srs_success) {
return srs_error_wrap(err, "HLS: security check");
}
@ -312,7 +312,7 @@ srs_error_t SrsHlsStream::http_hooks_on_play(ISrsRequest *req)
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -322,7 +322,7 @@ srs_error_t SrsHlsStream::http_hooks_on_play(ISrsRequest *req)
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost_);
if (!conf) {
return err;
@ -343,7 +343,7 @@ srs_error_t SrsHlsStream::http_hooks_on_play(ISrsRequest *req)
void SrsHlsStream::http_hooks_on_stop(ISrsRequest *req)
{
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return;
}
@ -353,7 +353,7 @@ void SrsHlsStream::http_hooks_on_stop(ISrsRequest *req)
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req->vhost_);
if (!conf) {
srs_info("ignore the empty http callback: on_stop");
@ -380,7 +380,7 @@ srs_error_t SrsHlsStream::on_timer(srs_utime_t interval)
string ctx = it->first;
SrsHlsVirtualConn *info = it->second;
srs_utime_t hls_window = _srs_config->get_hls_window(info->req->vhost);
srs_utime_t hls_window = _srs_config->get_hls_window(info->req->vhost_);
if (info->request_time + (2 * hls_window) < srs_time_now_cached()) {
SrsContextRestore(_srs_context->get_id());
_srs_context->set_id(SrsContextId().set_value(ctx));
@ -555,9 +555,9 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter *w, ISrsHttpMess
SrsUniquePtr<ISrsRequest> req(hr->to_request(hr->host())->as_http());
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(req->vhost);
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(req->vhost_);
if (parsed_vhost) {
req->vhost = parsed_vhost->arg0();
req->vhost_ = parsed_vhost->arg0();
}
// Try to serve by HLS streaming.

View File

@ -47,7 +47,7 @@ SrsBufferCache::SrsBufferCache(SrsServer *s, ISrsRequest *r)
trd = new SrsSTCoroutine("http-stream", this);
// TODO: FIXME: support reload.
fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost);
fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost_);
server_ = s;
}
@ -188,7 +188,7 @@ srs_error_t SrsBufferCache::cycle()
// free the messages.
for (int i = 0; i < count; i++) {
SrsMediaPacket *msg = msgs.msgs[i];
SrsMediaPacket *msg = msgs.msgs_[i];
queue->enqueue(msg);
}
}
@ -655,12 +655,12 @@ srs_error_t SrsLiveStream::serve_http_impl(ISrsHttpResponseWriter *w, ISrsHttpMe
// Correct the app and stream by path, which is created from template.
// @remark Be careful that the stream has extension now, might cause identify fail.
req->stream = srs_path_filepath_base(r->path());
req->stream_ = srs_path_filepath_base(r->path());
// remove the extension of stream if have. for instance, test.flv -> test
req->stream = srs_path_filepath_filename(req->stream);
req->stream_ = srs_path_filepath_filename(req->stream_);
// update client ip
req->ip = hc->remote_ip();
req->ip_ = hc->remote_ip();
// We must do stat the client before hooks, because hooks depends on it.
SrsStatistic *stat = SrsStatistic::instance();
@ -668,7 +668,7 @@ srs_error_t SrsLiveStream::serve_http_impl(ISrsHttpResponseWriter *w, ISrsHttpMe
return srs_error_wrap(err, "stat on client");
}
if ((err = security_->check(SrsFlvPlay, req->ip, req)) != srs_success) {
if ((err = security_->check(SrsFlvPlay, req->ip_, req)) != srs_success) {
return srs_error_wrap(err, "flv: security check");
}
@ -689,8 +689,8 @@ srs_error_t SrsLiveStream::serve_http_impl(ISrsHttpResponseWriter *w, ISrsHttpMe
}
srs_assert(live_source.get() != NULL);
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
int gcmf = _srs_config->get_gop_cache_max_frames(req->vhost);
bool enabled_cache = _srs_config->get_gop_cache(req->vhost_);
int gcmf = _srs_config->get_gop_cache_max_frames(req->vhost_);
live_source->set_cache(enabled_cache);
live_source->set_gop_cache_max_frames(gcmf);
@ -740,10 +740,10 @@ srs_error_t SrsLiveStream::do_serve_http(SrsLiveSource *source, SrsLiveConsumer
ISrsBufferEncoder *enc_raw = NULL;
srs_assert(entry);
bool drop_if_not_match = _srs_config->get_vhost_http_remux_drop_if_not_match(req->vhost);
bool has_audio = _srs_config->get_vhost_http_remux_has_audio(req->vhost);
bool has_video = _srs_config->get_vhost_http_remux_has_video(req->vhost);
bool guess_has_av = _srs_config->get_vhost_http_remux_guess_has_av(req->vhost);
bool drop_if_not_match = _srs_config->get_vhost_http_remux_drop_if_not_match(req->vhost_);
bool has_audio = _srs_config->get_vhost_http_remux_has_audio(req->vhost_);
bool has_video = _srs_config->get_vhost_http_remux_has_video(req->vhost_);
bool guess_has_av = _srs_config->get_vhost_http_remux_guess_has_av(req->vhost_);
if (srs_strings_ends_with(entry->pattern, ".flv")) {
w->header()->set_content_type("video/x-flv");
@ -816,9 +816,9 @@ srs_error_t SrsLiveStream::do_serve_http(SrsLiveSource *source, SrsLiveConsumer
return srs_error_wrap(err, "start recv thread");
}
srs_utime_t mw_sleep = _srs_config->get_mw_sleep(req->vhost);
srs_utime_t mw_sleep = _srs_config->get_mw_sleep(req->vhost_);
srs_trace("FLV %s, encoder=%s, mw_sleep=%dms, cache=%d, msgs=%d, dinm=%d, guess_av=%d/%d/%d",
entry->pattern.c_str(), enc_desc.c_str(), srsu2msi(mw_sleep), enc->has_cache(), msgs.max, drop_if_not_match,
entry->pattern.c_str(), enc_desc.c_str(), srsu2msi(mw_sleep), enc->has_cache(), msgs.max_, drop_if_not_match,
has_audio, has_video, guess_has_av);
// TODO: free and erase the disabled entry after all related connections is closed.
@ -853,16 +853,16 @@ srs_error_t SrsLiveStream::do_serve_http(SrsLiveSource *source, SrsLiveConsumer
// sendout all messages.
if (ffe) {
err = ffe->write_tags(msgs.msgs, count);
err = ffe->write_tags(msgs.msgs_, count);
} else {
err = streaming_send_messages(enc.get(), msgs.msgs, count);
err = streaming_send_messages(enc.get(), msgs.msgs_, count);
}
// TODO: FIXME: Update the stat.
// free the messages.
for (int i = 0; i < count; i++) {
SrsMediaPacket *msg = msgs.msgs[i];
SrsMediaPacket *msg = msgs.msgs_[i];
srs_freep(msg);
}
@ -881,13 +881,13 @@ srs_error_t SrsLiveStream::http_hooks_on_play(ISrsHttpMessage *r)
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
// Create request to report for the specified connection.
SrsHttpMessage *hr = dynamic_cast<SrsHttpMessage *>(r);
SrsUniquePtr<ISrsRequest> nreq(hr->to_request(req->vhost));
SrsUniquePtr<ISrsRequest> nreq(hr->to_request(req->vhost_));
// the http hooks will cause context switch,
// so we must copy all hooks for the on_connect may freed.
@ -895,7 +895,7 @@ srs_error_t SrsLiveStream::http_hooks_on_play(ISrsHttpMessage *r)
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_play(nreq->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_play(nreq->vhost_);
if (!conf) {
return err;
@ -916,13 +916,13 @@ srs_error_t SrsLiveStream::http_hooks_on_play(ISrsHttpMessage *r)
void SrsLiveStream::http_hooks_on_stop(ISrsHttpMessage *r)
{
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return;
}
// Create request to report for the specified connection.
SrsHttpMessage *hr = dynamic_cast<SrsHttpMessage *>(r);
SrsUniquePtr<ISrsRequest> nreq(hr->to_request(req->vhost));
SrsUniquePtr<ISrsRequest> nreq(hr->to_request(req->vhost_));
// the http hooks will cause context switch,
// so we must copy all hooks for the on_connect may freed.
@ -930,7 +930,7 @@ void SrsLiveStream::http_hooks_on_stop(ISrsHttpMessage *r)
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(nreq->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(nreq->vhost_);
if (!conf) {
srs_info("ignore the empty http callback: on_stop");
@ -1077,18 +1077,18 @@ srs_error_t SrsHttpStreamServer::http_mount(ISrsRequest *r)
// create stream from template when not found.
if (streamHandlers.find(sid) == streamHandlers.end()) {
if (templateHandlers.find(r->vhost) == templateHandlers.end()) {
if (templateHandlers.find(r->vhost_) == templateHandlers.end()) {
return err;
}
SrsLiveEntry *tmpl = templateHandlers[r->vhost];
SrsLiveEntry *tmpl = templateHandlers[r->vhost_];
std::string mount = tmpl->mount;
// replace the vhost variable
mount = srs_strings_replace(mount, "[vhost]", r->vhost);
mount = srs_strings_replace(mount, "[app]", r->app);
mount = srs_strings_replace(mount, "[stream]", r->stream);
mount = srs_strings_replace(mount, "[vhost]", r->vhost_);
mount = srs_strings_replace(mount, "[app]", r->app_);
mount = srs_strings_replace(mount, "[stream]", r->stream_);
// remove the default vhost mount
mount = srs_strings_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST "/", "/");
@ -1256,7 +1256,7 @@ srs_error_t SrsHttpStreamServer::dynamic_match(ISrsHttpMessage *request, ISrsHtt
// only when the http entry is disabled, check the config whether http flv disable,
// for the http flv edge use match to trigger the edge ingester, we always mount it
// eventhough the origin does not exists the specified stream.
if (!_srs_config->get_vhost_http_remux_enabled(r->vhost)) {
if (!_srs_config->get_vhost_http_remux_enabled(r->vhost_)) {
return srs_error_new(ERROR_HTTP_DYNAMIC_MATCH, "stream disabled");
}
}

View File

@ -566,7 +566,7 @@ srs_error_t SrsMpegtsOverUdp::on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs)
}
aac_specific_config = sh;
codec.aac_packet_type = 0;
codec.aac_packet_type_ = 0;
if ((err = write_audio_raw_frame((char *)sh.data(), (int)sh.length(), &codec, dts)) != srs_success) {
return srs_error_wrap(err, "write raw audio frame");
@ -574,7 +574,7 @@ srs_error_t SrsMpegtsOverUdp::on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs)
}
// audio raw data.
codec.aac_packet_type = 1;
codec.aac_packet_type_ = 1;
if ((err = write_audio_raw_frame(frame, frame_size, &codec, dts)) != srs_success) {
return srs_error_wrap(err, "write audio raw frame");
}

View File

@ -124,19 +124,19 @@ srs_error_t SrsNgExec::parse_exec_publish(ISrsRequest *req)
{
srs_error_t err = srs_success;
if (!_srs_config->get_exec_enabled(req->vhost)) {
srs_trace("ignore disabled exec for vhost=%s", req->vhost.c_str());
if (!_srs_config->get_exec_enabled(req->vhost_)) {
srs_trace("ignore disabled exec for vhost=%s", req->vhost_.c_str());
return err;
}
// stream name: vhost/app/stream for print
input_stream_name = req->vhost;
input_stream_name = req->vhost_;
input_stream_name += "/";
input_stream_name += req->app;
input_stream_name += req->app_;
input_stream_name += "/";
input_stream_name += req->stream;
input_stream_name += req->stream_;
std::vector<SrsConfDirective *> eps = _srs_config->get_exec_publishs(req->vhost);
std::vector<SrsConfDirective *> eps = _srs_config->get_exec_publishs(req->vhost_);
for (int i = 0; i < (int)eps.size(); i++) {
SrsConfDirective *ep = eps.at(i);
SrsProcess *process = new SrsProcess();
@ -162,7 +162,7 @@ srs_error_t SrsNgExec::parse_exec_publish(ISrsRequest *req)
if ((err = process->initialize(binary, argv)) != srs_success) {
srs_freep(process);
return srs_error_wrap(err, "initialize process failed, binary=%s, vhost=%s", binary.c_str(), req->vhost.c_str());
return srs_error_wrap(err, "initialize process failed, binary=%s, vhost=%s", binary.c_str(), req->vhost_.c_str());
}
exec_publishs.push_back(process);
@ -197,19 +197,19 @@ string SrsNgExec::parse(ISrsRequest *req, string tmpl)
{
string output = tmpl;
output = srs_strings_replace(output, "[vhost]", req->vhost);
output = srs_strings_replace(output, "[port]", srs_strconv_format_int(req->port));
output = srs_strings_replace(output, "[app]", req->app);
output = srs_strings_replace(output, "[stream]", req->stream);
output = srs_strings_replace(output, "[vhost]", req->vhost_);
output = srs_strings_replace(output, "[port]", srs_strconv_format_int(req->port_));
output = srs_strings_replace(output, "[app]", req->app_);
output = srs_strings_replace(output, "[stream]", req->stream_);
output = srs_strings_replace(output, "[tcUrl]", req->tcUrl);
output = srs_strings_replace(output, "[swfUrl]", req->swfUrl);
output = srs_strings_replace(output, "[pageUrl]", req->pageUrl);
output = srs_strings_replace(output, "[tcUrl]", req->tcUrl_);
output = srs_strings_replace(output, "[swfUrl]", req->swfUrl_);
output = srs_strings_replace(output, "[pageUrl]", req->pageUrl_);
output = srs_path_build_timestamp(output);
if (output.find("[url]") != string::npos) {
string url = srs_net_url_encode_rtmp_url(req->host, req->port, req->host, req->vhost, req->app, req->stream, req->param);
string url = srs_net_url_encode_rtmp_url(req->host_, req->port_, req->host_, req->vhost_, req->app_, req->stream_, req->param_);
output = srs_strings_replace(output, "[url]", url);
}

View File

@ -276,10 +276,10 @@ SrsPublishRecvThread::SrsPublishRecvThread(SrsRtmpServer *rtmp_sdk, ISrsRequest
mr_fd = mr_sock_fd;
// the mr settings,
mr = _srs_config->get_mr_enabled(req->vhost);
mr_sleep = _srs_config->get_mr_sleep(req->vhost);
mr = _srs_config->get_mr_enabled(req->vhost_);
mr_sleep = _srs_config->get_mr_sleep(req->vhost_);
realtime = _srs_config->get_realtime_enabled(req->vhost);
realtime = _srs_config->get_realtime_enabled(req->vhost_);
_srs_config->subscribe(this);
}

View File

@ -126,18 +126,18 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
// The RTC user config object.
SrsRtcUserConfig ruc;
ruc.req_->ip = clientip;
ruc.req_->ip_ = clientip;
ruc.api_ = api;
srs_net_url_parse_rtmp_url(streamurl, ruc.req_->tcUrl, ruc.req_->stream);
srs_net_url_parse_rtmp_url(streamurl, ruc.req_->tcUrl_, ruc.req_->stream_);
srs_net_url_parse_tcurl(ruc.req_->tcUrl, ruc.req_->schema, ruc.req_->host, ruc.req_->vhost,
ruc.req_->app, ruc.req_->stream, ruc.req_->port, ruc.req_->param);
srs_net_url_parse_tcurl(ruc.req_->tcUrl_, ruc.req_->schema_, ruc.req_->host_, ruc.req_->vhost_,
ruc.req_->app_, ruc.req_->stream_, ruc.req_->port_, ruc.req_->param_);
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(ruc.req_->vhost);
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(ruc.req_->vhost_);
if (parsed_vhost) {
ruc.req_->vhost = parsed_vhost->arg0();
ruc.req_->vhost_ = parsed_vhost->arg0();
}
// For client to specifies the candidate(EIP) of server.
@ -152,8 +152,8 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
srs_trace(
"RTC play %s, api=%s, tid=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s, srtp=%s, dtls=%s",
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), ruc.req_->app.c_str(),
ruc.req_->stream.c_str(), remote_sdp_str.length(),
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), ruc.req_->app_.c_str(),
ruc.req_->stream_.c_str(), remote_sdp_str.length(),
eip.c_str(), codec.c_str(), srtp.c_str(), dtls.c_str());
ruc.eip_ = eip;
@ -200,18 +200,18 @@ srs_error_t SrsGoApiRtcPlay::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessa
SrsSdp local_sdp;
// Config for SDP and session.
local_sdp.session_config_.dtls_role = _srs_config->get_rtc_dtls_role(ruc->req_->vhost);
local_sdp.session_config_.dtls_version = _srs_config->get_rtc_dtls_version(ruc->req_->vhost);
local_sdp.session_config_.dtls_role = _srs_config->get_rtc_dtls_role(ruc->req_->vhost_);
local_sdp.session_config_.dtls_version = _srs_config->get_rtc_dtls_version(ruc->req_->vhost_);
// Whether enabled.
bool server_enabled = _srs_config->get_rtc_server_enabled();
bool rtc_enabled = _srs_config->get_rtc_enabled(ruc->req_->vhost);
bool rtc_enabled = _srs_config->get_rtc_enabled(ruc->req_->vhost_);
if (server_enabled && !rtc_enabled) {
srs_warn("RTC disabled in vhost %s", ruc->req_->vhost.c_str());
srs_warn("RTC disabled in vhost %s", ruc->req_->vhost_.c_str());
}
if (!server_enabled || !rtc_enabled) {
return srs_error_new(ERROR_RTC_DISABLED, "Disabled server=%d, rtc=%d, vhost=%s",
server_enabled, rtc_enabled, ruc->req_->vhost.c_str());
server_enabled, rtc_enabled, ruc->req_->vhost_.c_str());
}
// Whether RTC stream is active.
@ -222,14 +222,14 @@ srs_error_t SrsGoApiRtcPlay::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessa
}
// For RTMP to RTC, fail if disabled and RTMP is active, see https://github.com/ossrs/srs/issues/2728
if (!is_rtc_stream_active && !_srs_config->get_rtc_from_rtmp(ruc->req_->vhost)) {
if (!is_rtc_stream_active && !_srs_config->get_rtc_from_rtmp(ruc->req_->vhost_)) {
SrsSharedPtr<SrsLiveSource> live_source = _srs_sources->fetch(ruc->req_);
if (live_source.get() && !live_source->inactive()) {
return srs_error_new(ERROR_RTC_DISABLED, "Disabled rtmp_to_rtc of %s, see #2728", ruc->req_->vhost.c_str());
return srs_error_new(ERROR_RTC_DISABLED, "Disabled rtmp_to_rtc of %s, see #2728", ruc->req_->vhost_.c_str());
}
}
if ((err = security_->check(SrsRtcConnPlay, ruc->req_->ip, ruc->req_)) != srs_success) {
if ((err = security_->check(SrsRtcConnPlay, ruc->req_->ip_, ruc->req_)) != srs_success) {
return srs_error_wrap(err, "RTC: security check");
}
@ -297,7 +297,7 @@ srs_error_t SrsGoApiRtcPlay::http_hooks_on_play(ISrsRequest *req)
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -307,7 +307,7 @@ srs_error_t SrsGoApiRtcPlay::http_hooks_on_play(ISrsRequest *req)
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost_);
if (!conf) {
return err;
@ -422,20 +422,20 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter *w, ISrsHtt
// The RTC user config object.
SrsRtcUserConfig ruc;
ruc.req_->ip = clientip;
ruc.req_->ip_ = clientip;
ruc.api_ = api;
srs_net_url_parse_rtmp_url(streamurl, ruc.req_->tcUrl, ruc.req_->stream);
srs_net_url_parse_tcurl(ruc.req_->tcUrl, ruc.req_->schema, ruc.req_->host, ruc.req_->vhost,
ruc.req_->app, ruc.req_->stream, ruc.req_->port, ruc.req_->param);
srs_net_url_parse_rtmp_url(streamurl, ruc.req_->tcUrl_, ruc.req_->stream_);
srs_net_url_parse_tcurl(ruc.req_->tcUrl_, ruc.req_->schema_, ruc.req_->host_, ruc.req_->vhost_,
ruc.req_->app_, ruc.req_->stream_, ruc.req_->port_, ruc.req_->param_);
// Identify WebRTC publisher by param upstream=rtc
ruc.req_->param = srs_strings_trim_start(ruc.req_->param + "&upstream=rtc", "&");
ruc.req_->param_ = srs_strings_trim_start(ruc.req_->param_ + "&upstream=rtc", "&");
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(ruc.req_->vhost);
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(ruc.req_->vhost_);
if (parsed_vhost) {
ruc.req_->vhost = parsed_vhost->arg0();
ruc.req_->vhost_ = parsed_vhost->arg0();
}
// For client to specifies the candidate(EIP) of server.
@ -446,7 +446,7 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter *w, ISrsHtt
string codec = r->query_get("codec");
srs_trace("RTC publish %s, api=%s, tid=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s",
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), ruc.req_->app.c_str(), ruc.req_->stream.c_str(),
streamurl.c_str(), api.c_str(), tid.c_str(), clientip.c_str(), ruc.req_->app_.c_str(), ruc.req_->stream_.c_str(),
remote_sdp_str.length(), eip.c_str(), codec.c_str());
ruc.eip_ = eip;
@ -488,18 +488,18 @@ srs_error_t SrsGoApiRtcPublish::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
// TODO: FIXME: move to create_session.
// Config for SDP and session.
local_sdp.session_config_.dtls_role = _srs_config->get_rtc_dtls_role(ruc->req_->vhost);
local_sdp.session_config_.dtls_version = _srs_config->get_rtc_dtls_version(ruc->req_->vhost);
local_sdp.session_config_.dtls_role = _srs_config->get_rtc_dtls_role(ruc->req_->vhost_);
local_sdp.session_config_.dtls_version = _srs_config->get_rtc_dtls_version(ruc->req_->vhost_);
// Whether enabled.
bool server_enabled = _srs_config->get_rtc_server_enabled();
bool rtc_enabled = _srs_config->get_rtc_enabled(ruc->req_->vhost);
bool rtc_enabled = _srs_config->get_rtc_enabled(ruc->req_->vhost_);
if (server_enabled && !rtc_enabled) {
srs_warn("RTC disabled in vhost %s", ruc->req_->vhost.c_str());
srs_warn("RTC disabled in vhost %s", ruc->req_->vhost_.c_str());
}
if (!server_enabled || !rtc_enabled) {
return srs_error_new(ERROR_RTC_DISABLED, "Disabled server=%d, rtc=%d, vhost=%s",
server_enabled, rtc_enabled, ruc->req_->vhost.c_str());
server_enabled, rtc_enabled, ruc->req_->vhost_.c_str());
}
// TODO: FIXME: When server enabled, but vhost disabled, should report error.
@ -509,7 +509,7 @@ srs_error_t SrsGoApiRtcPublish::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
return srs_error_wrap(err, "create session");
}
if ((err = security_->check(SrsRtcConnPublish, ruc->req_->ip, ruc->req_)) != srs_success) {
if ((err = security_->check(SrsRtcConnPublish, ruc->req_->ip_, ruc->req_)) != srs_success) {
return srs_error_wrap(err, "RTC: security check");
}
@ -572,7 +572,7 @@ srs_error_t SrsGoApiRtcPublish::http_hooks_on_publish(ISrsRequest *req)
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -582,7 +582,7 @@ srs_error_t SrsGoApiRtcPublish::http_hooks_on_publish(ISrsRequest *req)
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_publish(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_publish(req->vhost_);
if (!conf) {
return err;
}
@ -657,7 +657,7 @@ srs_error_t SrsGoApiRtcWhip::serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessa
w->header()->set("Content-Type", "application/sdp");
// The location for DELETE resource, not required by SRS, but required by WHIP.
w->header()->set("Location", srs_fmt_sprintf("/rtc/v1/whip/?action=delete&token=%s&app=%s&stream=%s&session=%s",
ruc.token_.c_str(), ruc.req_->app.c_str(), ruc.req_->stream.c_str(), ruc.session_id_.c_str()));
ruc.token_.c_str(), ruc.req_->app_.c_str(), ruc.req_->stream_.c_str(), ruc.session_id_.c_str()));
w->header()->set_content_length((int64_t)sdp.length());
// Must be 201, see https://datatracker.ietf.org/doc/draft-ietf-wish-whip/
w->write_header(201);
@ -703,12 +703,12 @@ srs_error_t SrsGoApiRtcWhip::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
}
// The RTC user config object.
ruc->req_->ip = clientip;
ruc->req_->host = r->host();
ruc->req_->vhost = ruc->req_->host;
ruc->req_->app = app.empty() ? "live" : app;
ruc->req_->stream = stream.empty() ? "livestream" : stream;
ruc->req_->param = r->query();
ruc->req_->ip_ = clientip;
ruc->req_->host_ = r->host();
ruc->req_->vhost_ = ruc->req_->host_;
ruc->req_->app_ = app.empty() ? "live" : app;
ruc->req_->stream_ = stream.empty() ? "livestream" : stream;
ruc->req_->param_ = r->query();
ruc->req_->ice_ufrag_ = r->query_get("ice-ufrag");
ruc->req_->ice_pwd_ = r->query_get("ice-pwd");
@ -720,9 +720,9 @@ srs_error_t SrsGoApiRtcWhip::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
}
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(ruc->req_->vhost);
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(ruc->req_->vhost_);
if (parsed_vhost) {
ruc->req_->vhost = parsed_vhost->arg0();
ruc->req_->vhost_ = parsed_vhost->arg0();
}
// For client to specifies whether encrypt by SRTP.
@ -730,9 +730,9 @@ srs_error_t SrsGoApiRtcWhip::do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMe
string dtls = r->query_get("dtls");
srs_trace("RTC whip %s %s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s, srtp=%s, dtls=%s, ufrag=%s, pwd=%s, param=%s",
action.c_str(), ruc->req_->get_stream_url().c_str(), clientip.c_str(), ruc->req_->app.c_str(), ruc->req_->stream.c_str(),
action.c_str(), ruc->req_->get_stream_url().c_str(), clientip.c_str(), ruc->req_->app_.c_str(), ruc->req_->stream_.c_str(),
remote_sdp_str.length(), eip.c_str(), codec.c_str(), srtp.c_str(), dtls.c_str(), ruc->req_->ice_ufrag_.c_str(),
ruc->req_->ice_pwd_.c_str(), ruc->req_->param.c_str());
ruc->req_->ice_pwd_.c_str(), ruc->req_->param_.c_str());
ruc->eip_ = eip;
ruc->codec_ = codec;

View File

@ -381,7 +381,7 @@ srs_error_t SrsRtcAsyncCallOnStop::call()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -391,7 +391,7 @@ srs_error_t SrsRtcAsyncCallOnStop::call()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req->vhost_);
if (!conf) {
return err;
@ -505,8 +505,8 @@ srs_error_t SrsRtcPlayStream::initialize(ISrsRequest *req, std::map<uint32_t, Sr
}
// TODO: FIXME: Support reload.
nack_enabled_ = _srs_config->get_rtc_nack_enabled(req->vhost);
nack_no_copy_ = _srs_config->get_rtc_nack_no_copy(req->vhost);
nack_enabled_ = _srs_config->get_rtc_nack_enabled(req->vhost_);
nack_no_copy_ = _srs_config->get_rtc_nack_no_copy(req->vhost_);
srs_trace("RTC player nack=%d, nnc=%d", nack_enabled_, nack_no_copy_);
// Setup tracks.
@ -642,8 +642,8 @@ srs_error_t SrsRtcPlayStream::cycle()
return srs_error_wrap(err, "dumps consumer, url=%s", req_->get_stream_url().c_str());
}
realtime = _srs_config->get_realtime_enabled(req_->vhost, true);
mw_msgs = _srs_config->get_mw_msgs(req_->vhost, realtime, true);
realtime = _srs_config->get_realtime_enabled(req_->vhost_, true);
mw_msgs = _srs_config->get_mw_msgs(req_->vhost_, realtime, true);
// TODO: FIXME: Add cost in ms.
SrsContextId cid = source->source_id();
@ -1042,7 +1042,7 @@ srs_error_t SrsRtcAsyncCallOnUnpublish::call()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -1052,7 +1052,7 @@ srs_error_t SrsRtcAsyncCallOnUnpublish::call()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_unpublish(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_unpublish(req->vhost_);
if (!conf) {
return err;
@ -1176,10 +1176,10 @@ srs_error_t SrsRtcPublishStream::initialize(ISrsRequest *r, SrsRtcSourceDescript
rtcp_twcc_.set_media_ssrc(media_ssrc);
}
nack_enabled_ = _srs_config->get_rtc_nack_enabled(req_->vhost);
nack_no_copy_ = _srs_config->get_rtc_nack_no_copy(req_->vhost);
pt_to_drop_ = (uint16_t)_srs_config->get_rtc_drop_for_pt(req_->vhost);
twcc_enabled_ = _srs_config->get_rtc_twcc_enabled(req_->vhost);
nack_enabled_ = _srs_config->get_rtc_nack_enabled(req_->vhost_);
nack_no_copy_ = _srs_config->get_rtc_nack_no_copy(req_->vhost_);
pt_to_drop_ = (uint16_t)_srs_config->get_rtc_drop_for_pt(req_->vhost_);
twcc_enabled_ = _srs_config->get_rtc_twcc_enabled(req_->vhost_);
// No TWCC when negotiate, disable it.
if (twcc_id <= 0) {
@ -1213,7 +1213,7 @@ srs_error_t SrsRtcPublishStream::initialize(ISrsRequest *r, SrsRtcSourceDescript
// Check whether SRT stream is busy.
bool srt_server_enabled = _srs_config->get_srt_enabled();
bool srt_enabled = _srs_config->get_srt_enabled(r->vhost);
bool srt_enabled = _srs_config->get_srt_enabled(r->vhost_);
if (srt_server_enabled && srt_enabled) {
SrsSharedPtr<SrsSrtSource> srt;
if ((err = _srs_srt_sources->fetch_or_create(r, srt)) != srs_success) {
@ -1227,7 +1227,7 @@ srs_error_t SrsRtcPublishStream::initialize(ISrsRequest *r, SrsRtcSourceDescript
// Bridge to rtmp
#if defined(SRS_FFMPEG_FIT)
bool rtc_to_rtmp = _srs_config->get_rtc_to_rtmp(req_->vhost);
bool rtc_to_rtmp = _srs_config->get_rtc_to_rtmp(req_->vhost_);
if (rtc_to_rtmp) {
if ((err = _srs_sources->fetch_or_create(r, live_source)) != srs_success) {
return srs_error_wrap(err, "create source");
@ -2052,10 +2052,10 @@ srs_error_t SrsRtcConnection::initialize(ISrsRequest *r, bool dtls, bool srtp, s
}
// TODO: FIXME: Support reload.
session_timeout = _srs_config->get_rtc_stun_timeout(req_->vhost);
session_timeout = _srs_config->get_rtc_stun_timeout(req_->vhost_);
last_stun_time = srs_time_now_cached();
nack_enabled_ = _srs_config->get_rtc_nack_enabled(req_->vhost);
nack_enabled_ = _srs_config->get_rtc_nack_enabled(req_->vhost_);
srs_trace("RTC init session, user=%s, url=%s, encrypt=%u/%u, DTLS(role=%s, version=%s), timeout=%dms, nack=%d",
username.c_str(), r->get_stream_url().c_str(), dtls, srtp, cfg->dtls_role.c_str(), cfg->dtls_version.c_str(),
@ -2564,7 +2564,7 @@ srs_error_t SrsRtcConnection::on_binding_request(SrsStunPacket *r, string &ice_p
++_srs_pps_sstuns->sugar_;
bool strict_check = _srs_config->get_rtc_stun_strict_check(req_->vhost);
bool strict_check = _srs_config->get_rtc_stun_strict_check(req_->vhost_);
if (strict_check && r->get_ice_controlled()) {
// @see: https://tools.ietf.org/html/draft-ietf-ice-rfc5245bis-00#section-6.1.3.1
// TODO: Send 487 (Role Conflict) error response.
@ -2679,8 +2679,8 @@ srs_error_t SrsRtcConnection::negotiate_publish_capability(SrsRtcUserConfig *ruc
ISrsRequest *req = ruc->req_;
const SrsSdp &remote_sdp = ruc->remote_sdp_;
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost);
bool twcc_enabled = _srs_config->get_rtc_twcc_enabled(req->vhost);
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost_);
bool twcc_enabled = _srs_config->get_rtc_twcc_enabled(req->vhost_);
// TODO: FIME: Should check packetization-mode=1 also.
bool has_42e01f = srs_sdp_has_h264_profile(remote_sdp, "42e01f");
@ -2989,7 +2989,7 @@ srs_error_t SrsRtcConnection::generate_publish_local_sdp(ISrsRequest *req, SrsSd
local_sdp.session_name_ = "SRSPublishSession";
local_sdp.msid_semantic_ = "WMS";
std::string stream_id = req->app + "/" + req->stream;
std::string stream_id = req->app_ + "/" + req->stream_;
local_sdp.msids_.push_back(stream_id);
local_sdp.group_policy_ = "BUNDLE";
@ -3111,8 +3111,8 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRtcUserConfig *ruc, s
ISrsRequest *req = ruc->req_;
const SrsSdp &remote_sdp = ruc->remote_sdp_;
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost);
bool twcc_enabled = _srs_config->get_rtc_twcc_enabled(req->vhost);
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost_);
bool twcc_enabled = _srs_config->get_rtc_twcc_enabled(req->vhost_);
SrsSharedPtr<SrsRtcSource> source;
if ((err = _srs_rtc_sources->fetch_or_create(req, source)) != srs_success) {
@ -3367,7 +3367,7 @@ srs_error_t SrsRtcConnection::generate_play_local_sdp(ISrsRequest *req, SrsSdp &
local_sdp.session_name_ = "SRSPlaySession";
local_sdp.msid_semantic_ = "WMS";
std::string stream_id = req->app + "/" + req->stream;
std::string stream_id = req->app_ + "/" + req->stream_;
local_sdp.msids_.push_back(stream_id);
local_sdp.group_policy_ = "BUNDLE";

View File

@ -229,8 +229,8 @@ set<string> discover_candidates(SrsRtcUserConfig *ruc)
}
// Try to discover from api of request, if api_as_candidates enabled.
if ((err = api_server_as_candidates(ruc->req_->host, candidate_ips)) != srs_success) {
srs_warn("ignore discovering ip from api %s, err %s", ruc->req_->host.c_str(), srs_error_summary(err).c_str());
if ((err = api_server_as_candidates(ruc->req_->host_, candidate_ips)) != srs_success) {
srs_warn("ignore discovering ip from api %s, err %s", ruc->req_->host_.c_str(), srs_error_summary(err).c_str());
srs_freep(err);
}

View File

@ -689,7 +689,7 @@ srs_error_t SrsRtcSource::on_publish()
}
// The PLI interval for RTC2RTMP.
pli_for_rtmp_ = _srs_config->get_rtc_pli_for_rtmp(req->vhost);
pli_for_rtmp_ = _srs_config->get_rtc_pli_for_rtmp(req->vhost_);
// @see SrsRtcSource::on_timer()
_srs_shared_timer->timer100ms()->subscribe(this);
@ -975,10 +975,10 @@ srs_error_t SrsRtcRtpBuilder::initialize(ISrsRequest *r)
}
// Setup the SPS/PPS parsing strategy.
format->try_annexb_first_ = _srs_config->try_annexb_first(r->vhost);
format->try_annexb_first_ = _srs_config->try_annexb_first(r->vhost_);
keep_bframe = _srs_config->get_rtc_keep_bframe(req->vhost);
keep_avc_nalu_sei = _srs_config->get_rtc_keep_avc_nalu_sei(req->vhost);
keep_bframe = _srs_config->get_rtc_keep_bframe(req->vhost_);
keep_avc_nalu_sei = _srs_config->get_rtc_keep_avc_nalu_sei(req->vhost_);
merge_nalus = _srs_config->get_rtc_server_merge_nalus();
srs_trace("RTC bridge from RTMP, keep_bframe=%d, keep_avc_nalu_sei=%d, merge_nalus=%d",
keep_bframe, keep_avc_nalu_sei, merge_nalus);
@ -1098,7 +1098,7 @@ srs_error_t SrsRtcRtpBuilder::init_codec(SrsAudioCodecId codec)
codec_ = new SrsAudioTranscoder();
// Initialize the codec according to the codec in stream.
int bitrate = _srs_config->get_rtc_opus_bitrate(req->vhost); // The output bitrate in bps.
int bitrate = _srs_config->get_rtc_opus_bitrate(req->vhost_); // The output bitrate in bps.
if ((err = codec_->initialize(codec, SrsAudioCodecIdOpus, kAudioChannel, kAudioSamplerate, bitrate)) != srs_success) {
return srs_error_wrap(err, "init codec=%d", codec);
}
@ -1767,10 +1767,10 @@ srs_error_t SrsRtcFrameBuilder::initialize(ISrsRequest *r, SrsAudioCodecId audio
srs_freep(audio_transcoder_);
audio_transcoder_ = new SrsAudioTranscoder();
SrsAudioCodecId to = SrsAudioCodecIdAAC; // The output audio codec.
int channels = 2; // The output audio channels.
int sample_rate = 48000; // The output audio sample rate in HZ.
int bitrate = _srs_config->get_rtc_aac_bitrate(r->vhost); // The output audio bitrate in bps.
SrsAudioCodecId to = SrsAudioCodecIdAAC; // The output audio codec.
int channels = 2; // The output audio channels.
int sample_rate = 48000; // The output audio sample rate in HZ.
int bitrate = _srs_config->get_rtc_aac_bitrate(r->vhost_); // The output audio bitrate in bps.
// TODO: FIXME:
// In the future, when we support enhanced-RTMP with Opus format,

View File

@ -74,7 +74,7 @@ srs_error_t SrsSimpleRtmpClient::connect_app()
srs_assert(_srs_config->get_stats_network() < (int)ips.size());
SrsIPAddress *local_ip = ips[_srs_config->get_stats_network()];
bool debug_srs_upnode = _srs_config->get_debug_srs_upnode(req->vhost);
bool debug_srs_upnode = _srs_config->get_debug_srs_upnode(req_->vhost_);
return do_connect_app(local_ip->ip, debug_srs_upnode);
}
@ -286,31 +286,31 @@ srs_error_t SrsRtmpConn::do_cycle()
}
// set client ip to request.
req->ip = ip;
req->ip_ = ip;
srs_trace("connect app, tcUrl=%s, pageUrl=%s, swfUrl=%s, schema=%s, vhost=%s, port=%d, app=%s, args=%s",
req->tcUrl.c_str(), req->pageUrl.c_str(), req->swfUrl.c_str(),
req->schema.c_str(), req->vhost.c_str(), req->port,
req->app.c_str(), (req->args ? "(obj)" : "null"));
req->tcUrl_.c_str(), req->pageUrl_.c_str(), req->swfUrl_.c_str(),
req->schema_.c_str(), req->vhost_.c_str(), req->port_,
req->app_.c_str(), (req->args_ ? "(obj)" : "null"));
// show client identity
if (req->args) {
if (req->args_) {
std::string srs_version;
std::string srs_server_ip;
int srs_pid = 0;
int srs_id = 0;
SrsAmf0Any *prop = NULL;
if ((prop = req->args->ensure_property_string("srs_version")) != NULL) {
if ((prop = req->args_->ensure_property_string("srs_version")) != NULL) {
srs_version = prop->to_str();
}
if ((prop = req->args->ensure_property_string("srs_server_ip")) != NULL) {
if ((prop = req->args_->ensure_property_string("srs_server_ip")) != NULL) {
srs_server_ip = prop->to_str();
}
if ((prop = req->args->ensure_property_number("srs_pid")) != NULL) {
if ((prop = req->args_->ensure_property_number("srs_pid")) != NULL) {
srs_pid = (int)prop->to_number();
}
if ((prop = req->args->ensure_property_number("srs_id")) != NULL) {
if ((prop = req->args_->ensure_property_number("srs_id")) != NULL) {
srs_id = (int)prop->to_number();
}
@ -349,12 +349,12 @@ srs_error_t SrsRtmpConn::service_cycle()
ISrsRequest *req = info->req;
int out_ack_size = _srs_config->get_out_ack_size(req->vhost);
int out_ack_size = _srs_config->get_out_ack_size(req->vhost_);
if (out_ack_size && (err = rtmp->set_window_ack_size(out_ack_size)) != srs_success) {
return srs_error_wrap(err, "rtmp: set out window ack size");
}
int in_ack_size = _srs_config->get_in_ack_size(req->vhost);
int in_ack_size = _srs_config->get_in_ack_size(req->vhost_);
if (in_ack_size && (err = rtmp->set_in_window_ack_size(in_ack_size)) != srs_success) {
return srs_error_wrap(err, "rtmp: set in window ack size");
}
@ -369,7 +369,7 @@ srs_error_t SrsRtmpConn::service_cycle()
// set chunk size to larger.
// set the chunk size before any larger response greater than 128,
// to make OBS happy, @see https://github.com/ossrs/srs/issues/454
int chunk_size = _srs_config->get_chunk_size(req->vhost);
int chunk_size = _srs_config->get_chunk_size(req->vhost_);
if ((err = rtmp->set_chunk_size(chunk_size)) != srs_success) {
return srs_error_wrap(err, "rtmp: set chunk size %d", chunk_size);
}
@ -443,32 +443,32 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
srs_error_t err = srs_success;
ISrsRequest *req = info->req;
if ((err = rtmp->identify_client(info->res->stream_id, info->type, req->stream, req->duration)) != srs_success) {
if ((err = rtmp->identify_client(info->res->stream_id_, info->type, req->stream_, req->duration_)) != srs_success) {
return srs_error_wrap(err, "rtmp: identify client");
}
srs_net_url_parse_tcurl(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param);
srs_net_url_parse_tcurl(req->tcUrl_, req->schema_, req->host_, req->vhost_, req->app_, req->stream_, req->port_, req->param_);
// guess stream name
if (req->stream.empty()) {
string app = req->app, param = req->param;
srs_net_url_guess_stream(req->app, req->param, req->stream);
srs_trace("Guessing by app=%s, param=%s to app=%s, param=%s, stream=%s", app.c_str(), param.c_str(), req->app.c_str(), req->param.c_str(), req->stream.c_str());
if (req->stream_.empty()) {
string app = req->app_, param = req->param_;
srs_net_url_guess_stream(req->app_, req->param_, req->stream_);
srs_trace("Guessing by app=%s, param=%s to app=%s, param=%s, stream=%s", app.c_str(), param.c_str(), req->app_.c_str(), req->param_.c_str(), req->stream_.c_str());
}
req->strip();
srs_trace("client identified, type=%s, vhost=%s, app=%s, stream=%s, param=%s, duration=%dms",
srs_client_type_string(info->type).c_str(), req->vhost.c_str(), req->app.c_str(), req->stream.c_str(), req->param.c_str(), srsu2msi(req->duration));
srs_client_type_string(info->type).c_str(), req->vhost_.c_str(), req->app_.c_str(), req->stream_.c_str(), req->param_.c_str(), srsu2msi(req->duration_));
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(req->vhost);
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(req->vhost_);
if (parsed_vhost) {
req->vhost = parsed_vhost->arg0();
req->vhost_ = parsed_vhost->arg0();
}
if (req->schema.empty() || req->vhost.empty() || req->port == 0 || req->app.empty()) {
if (req->schema_.empty() || req->vhost_.empty() || req->port_ == 0 || req->app_.empty()) {
return srs_error_new(ERROR_RTMP_REQ_TCURL, "discovery tcUrl failed, tcUrl=%s, schema=%s, vhost=%s, port=%d, app=%s",
req->tcUrl.c_str(), req->schema.c_str(), req->vhost.c_str(), req->port, req->app.c_str());
req->tcUrl_.c_str(), req->schema_.c_str(), req->vhost_.c_str(), req->port_, req->app_.c_str());
}
// check vhost, allow default vhost.
@ -477,14 +477,14 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
}
srs_trace("connected stream, tcUrl=%s, pageUrl=%s, swfUrl=%s, schema=%s, vhost=%s, port=%d, app=%s, stream=%s, param=%s, args=%s",
req->tcUrl.c_str(), req->pageUrl.c_str(), req->swfUrl.c_str(), req->schema.c_str(), req->vhost.c_str(), req->port,
req->app.c_str(), req->stream.c_str(), req->param.c_str(), (req->args ? "(obj)" : "null"));
req->tcUrl_.c_str(), req->pageUrl_.c_str(), req->swfUrl_.c_str(), req->schema_.c_str(), req->vhost_.c_str(), req->port_,
req->app_.c_str(), req->stream_.c_str(), req->param_.c_str(), (req->args_ ? "(obj)" : "null"));
// do token traverse before serve it.
// @see https://github.com/ossrs/srs/pull/239
if (true) {
info->edge = _srs_config->get_vhost_is_edge(req->vhost);
bool edge_traverse = _srs_config->get_vhost_edge_token_traverse(req->vhost);
info->edge = _srs_config->get_vhost_is_edge(req->vhost_);
bool edge_traverse = _srs_config->get_vhost_edge_token_traverse(req->vhost_);
if (info->edge && edge_traverse) {
if ((err = check_edge_token_traverse_auth()) != srs_success) {
return srs_error_wrap(err, "rtmp: check token traverse");
@ -499,7 +499,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
// Never allow the empty stream name, for HLS may write to a file with empty name.
// @see https://github.com/ossrs/srs/issues/834
if (req->stream.empty()) {
if (req->stream_.empty()) {
return srs_error_new(ERROR_RTMP_STREAM_NAME_EMPTY, "rtmp: empty stream");
}
@ -525,8 +525,8 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
}
srs_assert(live_source.get() != NULL);
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
int gcmf = _srs_config->get_gop_cache_max_frames(req->vhost);
bool enabled_cache = _srs_config->get_gop_cache(req->vhost_);
int gcmf = _srs_config->get_gop_cache_max_frames(req->vhost_);
srs_trace("source url=%s, ip=%s, cache=%d/%d, is_edge=%d, source_id=%s/%s",
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, gcmf, info->edge, live_source->source_id().c_str(),
live_source->pre_source_id().c_str());
@ -536,7 +536,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
switch (info->type) {
case SrsRtmpConnPlay: {
// response connection start play
if ((err = rtmp->start_play(info->res->stream_id)) != srs_success) {
if ((err = rtmp->start_play(info->res->stream_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: start play");
}
@ -564,7 +564,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
return err;
}
case SrsRtmpConnFMLEPublish: {
if ((err = rtmp->start_fmle_publish(info->res->stream_id)) != srs_success) {
if ((err = rtmp->start_fmle_publish(info->res->stream_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: start FMLE publish");
}
@ -578,7 +578,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
return publishing(live_source);
}
case SrsRtmpConnHaivisionPublish: {
if ((err = rtmp->start_haivision_publish(info->res->stream_id)) != srs_success) {
if ((err = rtmp->start_haivision_publish(info->res->stream_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: start HAIVISION publish");
}
@ -592,7 +592,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
return publishing(live_source);
}
case SrsRtmpConnFlashPublish: {
if ((err = rtmp->start_flash_publish(info->res->stream_id)) != srs_success) {
if ((err = rtmp->start_flash_publish(info->res->stream_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: start FLASH publish");
}
@ -620,22 +620,22 @@ srs_error_t SrsRtmpConn::check_vhost(bool try_default_vhost)
ISrsRequest *req = info->req;
srs_assert(req != NULL);
SrsConfDirective *vhost = _srs_config->get_vhost(req->vhost, try_default_vhost);
SrsConfDirective *vhost = _srs_config->get_vhost(req->vhost_, try_default_vhost);
if (vhost == NULL) {
return srs_error_new(ERROR_RTMP_VHOST_NOT_FOUND, "rtmp: no vhost %s", req->vhost.c_str());
return srs_error_new(ERROR_RTMP_VHOST_NOT_FOUND, "rtmp: no vhost %s", req->vhost_.c_str());
}
if (!_srs_config->get_vhost_enabled(req->vhost)) {
return srs_error_new(ERROR_RTMP_VHOST_NOT_FOUND, "rtmp: vhost %s disabled", req->vhost.c_str());
if (!_srs_config->get_vhost_enabled(req->vhost_)) {
return srs_error_new(ERROR_RTMP_VHOST_NOT_FOUND, "rtmp: vhost %s disabled", req->vhost_.c_str());
}
if (req->vhost != vhost->arg0()) {
srs_trace("vhost change from %s to %s", req->vhost.c_str(), vhost->arg0().c_str());
req->vhost = vhost->arg0();
if (req->vhost_ != vhost->arg0()) {
srs_trace("vhost change from %s to %s", req->vhost_.c_str(), vhost->arg0().c_str());
req->vhost_ = vhost->arg0();
}
if (_srs_config->get_refer_enabled(req->vhost)) {
if ((err = refer->check(req->pageUrl, _srs_config->get_refer_all(req->vhost))) != srs_success) {
if (_srs_config->get_refer_enabled(req->vhost_)) {
if ((err = refer->check(req->pageUrl_, _srs_config->get_refer_all(req->vhost_))) != srs_success) {
return srs_error_wrap(err, "rtmp: referer check");
}
}
@ -653,23 +653,23 @@ srs_error_t SrsRtmpConn::playing(SrsSharedPtr<SrsLiveSource> source)
// Check page referer of player.
ISrsRequest *req = info->req;
if (_srs_config->get_refer_enabled(req->vhost)) {
if ((err = refer->check(req->pageUrl, _srs_config->get_refer_play(req->vhost))) != srs_success) {
if (_srs_config->get_refer_enabled(req->vhost_)) {
if ((err = refer->check(req->pageUrl_, _srs_config->get_refer_play(req->vhost_))) != srs_success) {
return srs_error_wrap(err, "rtmp: referer check");
}
}
// When origin cluster enabled, try to redirect to the origin which is active.
// A active origin is a server which is delivering stream.
if (!info->edge && _srs_config->get_vhost_origin_cluster(req->vhost) && source->inactive()) {
vector<string> coworkers = _srs_config->get_vhost_coworkers(req->vhost);
if (!info->edge && _srs_config->get_vhost_origin_cluster(req->vhost_) && source->inactive()) {
vector<string> coworkers = _srs_config->get_vhost_coworkers(req->vhost_);
for (int i = 0; i < (int)coworkers.size(); i++) {
// TODO: FIXME: User may config the server itself as coworker, we must identify and ignore it.
string host;
int port = 0;
string coworker = coworkers.at(i);
string url = "http://" + coworker + "/api/v1/clusters?" + "vhost=" + req->vhost + "&ip=" + req->host + "&app=" + req->app + "&stream=" + req->stream + "&coworker=" + coworker;
string url = "http://" + coworker + "/api/v1/clusters?" + "vhost=" + req->vhost_ + "&ip=" + req->host_ + "&app=" + req->app_ + "&stream=" + req->stream_ + "&coworker=" + coworker;
if ((err = _srs_hooks->discover_co_workers(url, host, port)) != srs_success) {
// If failed to discovery stream in this coworker, we should request the next one util the last.
// @see https://github.com/ossrs/srs/issues/1223
@ -679,9 +679,9 @@ srs_error_t SrsRtmpConn::playing(SrsSharedPtr<SrsLiveSource> source)
return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str());
}
string rurl = srs_net_url_encode_rtmp_url(host, port, req->host, req->vhost, req->app, req->stream, req->param);
string rurl = srs_net_url_encode_rtmp_url(host, port, req->host_, req->vhost_, req->app_, req->stream_, req->param_);
srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s, rurl=%s",
req->host.c_str(), req->port, host.c_str(), port, url.c_str(), rurl.c_str());
req->host_.c_str(), req->port_, host.c_str(), port, url.c_str(), rurl.c_str());
// Ignore if host or port is invalid.
if (host.empty() || port == 0) {
@ -747,18 +747,18 @@ srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveC
SrsUniquePtr<SrsPithyPrint> pprint(SrsPithyPrint::create_rtmp_play());
SrsMessageArray msgs(SRS_PERF_MW_MSGS);
bool user_specified_duration_to_stop = (req->duration > 0);
bool user_specified_duration_to_stop = (req->duration_ > 0);
int64_t starttime = -1;
// setup the realtime.
realtime = _srs_config->get_realtime_enabled(req->vhost);
realtime = _srs_config->get_realtime_enabled(req->vhost_);
// setup the mw config.
// when mw_sleep changed, resize the socket send buffer.
mw_msgs = _srs_config->get_mw_msgs(req->vhost, realtime);
mw_sleep = _srs_config->get_mw_sleep(req->vhost);
mw_msgs = _srs_config->get_mw_msgs(req->vhost_, realtime);
mw_sleep = _srs_config->get_mw_sleep(req->vhost_);
transport_->set_socket_buffer(mw_sleep);
// initialize the send_min_interval
send_min_interval = _srs_config->get_send_min_interval(req->vhost);
send_min_interval = _srs_config->get_send_min_interval(req->vhost_);
srs_trace("start play smi=%dms, mw_sleep=%d, mw_msgs=%d, realtime=%d, tcp_nodelay=%d",
srsu2msi(send_min_interval), srsu2msi(mw_sleep), mw_msgs, realtime, tcp_nodelay);
@ -825,7 +825,7 @@ srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveC
// we start to collect the durations for each message.
if (user_specified_duration_to_stop) {
for (int i = 0; i < count; i++) {
SrsMediaPacket *msg = msgs.msgs[i];
SrsMediaPacket *msg = msgs.msgs_[i];
// foreach msg, collect the duration.
// @remark: never use msg when sent it, for the protocol sdk will free it.
@ -839,15 +839,15 @@ srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveC
// sendout messages, all messages are freed by send_and_free_messages().
// no need to assert msg, for the rtmp will assert it.
if (count > 0 && (err = rtmp->send_and_free_messages(msgs.msgs, count, info->res->stream_id)) != srs_success) {
if (count > 0 && (err = rtmp->send_and_free_messages(msgs.msgs_, count, info->res->stream_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: send %d messages", count);
}
// if duration specified, and exceed it, stop play live.
// @see: https://github.com/ossrs/srs/issues/45
if (user_specified_duration_to_stop) {
if (duration >= req->duration) {
return srs_error_new(ERROR_RTMP_DURATION_EXCEED, "rtmp: time %d up %d", srsu2msi(duration), srsu2msi(req->duration));
if (duration >= req->duration_) {
return srs_error_new(ERROR_RTMP_DURATION_EXCEED, "rtmp: time %d up %d", srsu2msi(duration), srsu2msi(req->duration_));
}
}
@ -870,8 +870,8 @@ srs_error_t SrsRtmpConn::publishing(SrsSharedPtr<SrsLiveSource> source)
ISrsRequest *req = info->req;
if (_srs_config->get_refer_enabled(req->vhost)) {
if ((err = refer->check(req->pageUrl, _srs_config->get_refer_publish(req->vhost))) != srs_success) {
if (_srs_config->get_refer_enabled(req->vhost_)) {
if ((err = refer->check(req->pageUrl_, _srs_config->get_refer_publish(req->vhost_))) != srs_success) {
return srs_error_wrap(err, "rtmp: referer check");
}
}
@ -921,16 +921,16 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPu
}
// initialize the publish timeout.
publish_1stpkt_timeout = _srs_config->get_publish_1stpkt_timeout(req->vhost);
publish_normal_timeout = _srs_config->get_publish_normal_timeout(req->vhost);
srs_utime_t publish_kickoff_for_idle = _srs_config->get_publish_kickoff_for_idle(req->vhost);
publish_1stpkt_timeout = _srs_config->get_publish_1stpkt_timeout(req->vhost_);
publish_normal_timeout = _srs_config->get_publish_normal_timeout(req->vhost_);
srs_utime_t publish_kickoff_for_idle = _srs_config->get_publish_kickoff_for_idle(req->vhost_);
// set the sock options.
set_sock_options();
if (true) {
bool mr = _srs_config->get_mr_enabled(req->vhost);
srs_utime_t mr_sleep = _srs_config->get_mr_sleep(req->vhost);
bool mr = _srs_config->get_mr_enabled(req->vhost_);
srs_utime_t mr_sleep = _srs_config->get_mr_sleep(req->vhost_);
srs_trace("start publish mr=%d/%d, p1stpt=%d, pnt=%d, tcp_nodelay=%d", mr, srsu2msi(mr_sleep), srsu2msi(publish_1stpkt_timeout), srsu2msi(publish_normal_timeout), tcp_nodelay);
}
@ -939,7 +939,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPu
#endif
// Response the start publishing message, let client start to publish messages.
if ((err = rtmp->start_publishing(info->res->stream_id)) != srs_success) {
if ((err = rtmp->start_publishing(info->res->stream_id_)) != srs_success) {
return srs_error_wrap(err, "start publishing");
}
@ -952,7 +952,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPu
// Kick off the publisher when idle for a period of timeout.
if (source->publisher_is_idle_for(publish_kickoff_for_idle)) {
return srs_error_new(ERROR_KICKOFF_FOR_IDLE, "kicked for idle, url=%s, timeout=%ds", req->tcUrl.c_str(), srsu2si(publish_kickoff_for_idle));
return srs_error_new(ERROR_KICKOFF_FOR_IDLE, "kicked for idle, url=%s, timeout=%ds", req->tcUrl_.c_str(), srsu2si(publish_kickoff_for_idle));
}
pprint->elapse();
@ -988,8 +988,8 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSharedPtr<SrsLiveSource> source, SrsPu
// reportable
if (pprint->can_print()) {
kbps->sample();
bool mr = _srs_config->get_mr_enabled(req->vhost);
srs_utime_t mr_sleep = _srs_config->get_mr_sleep(req->vhost);
bool mr = _srs_config->get_mr_enabled(req->vhost_);
srs_utime_t mr_sleep = _srs_config->get_mr_sleep(req->vhost_);
srs_trace("<- " SRS_CONSTS_LOG_CLIENT_PUBLISH " time=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d, mr=%d/%d, p1stpt=%d, pnt=%d",
(int)pprint->age(), kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), mr, srsu2msi(mr_sleep),
@ -1020,7 +1020,7 @@ srs_error_t SrsRtmpConn::acquire_publish(SrsSharedPtr<SrsLiveSource> source)
// Check whether RTC stream is busy.
SrsSharedPtr<SrsRtcSource> rtc;
bool rtc_server_enabled = _srs_config->get_rtc_server_enabled();
bool rtc_enabled = _srs_config->get_rtc_enabled(req->vhost);
bool rtc_enabled = _srs_config->get_rtc_enabled(req->vhost_);
if (rtc_server_enabled && rtc_enabled && !info->edge) {
if ((err = _srs_rtc_sources->fetch_or_create(req, rtc)) != srs_success) {
return srs_error_wrap(err, "create source");
@ -1033,7 +1033,7 @@ srs_error_t SrsRtmpConn::acquire_publish(SrsSharedPtr<SrsLiveSource> source)
// Check whether SRT stream is busy.
bool srt_server_enabled = _srs_config->get_srt_enabled();
bool srt_enabled = _srs_config->get_srt_enabled(req->vhost);
bool srt_enabled = _srs_config->get_srt_enabled(req->vhost_);
if (srt_server_enabled && srt_enabled && !info->edge) {
SrsSharedPtr<SrsSrtSource> srt;
if ((err = _srs_srt_sources->fetch_or_create(req, srt)) != srs_success) {
@ -1049,7 +1049,7 @@ srs_error_t SrsRtmpConn::acquire_publish(SrsSharedPtr<SrsLiveSource> source)
// RTSP only support viewer, so we don't need to check it.
SrsSharedPtr<SrsRtspSource> rtsp;
bool rtsp_server_enabled = _srs_config->get_rtsp_server_enabled();
bool rtsp_enabled = _srs_config->get_rtsp_enabled(req->vhost);
bool rtsp_enabled = _srs_config->get_rtsp_enabled(req->vhost_);
if (rtsp_server_enabled && rtsp_enabled && !info->edge) {
if ((err = _srs_rtsp_sources->fetch_or_create(req, rtsp)) != srs_success) {
return srs_error_wrap(err, "create source");
@ -1062,13 +1062,13 @@ srs_error_t SrsRtmpConn::acquire_publish(SrsSharedPtr<SrsLiveSource> source)
SrsCompositeBridge *bridge = new SrsCompositeBridge();
#if defined(SRS_FFMPEG_FIT)
if (rtc.get() && _srs_config->get_rtc_from_rtmp(req->vhost)) {
if (rtc.get() && _srs_config->get_rtc_from_rtmp(req->vhost_)) {
bridge->append(new SrsFrameToRtcBridge(rtc));
}
#endif
#ifdef SRS_RTSP
if (rtsp.get() && _srs_config->get_rtsp_from_rtmp(req->vhost)) {
if (rtsp.get() && _srs_config->get_rtsp_from_rtmp(req->vhost_)) {
bridge->append(new SrsFrameToRtspBridge(rtsp));
}
#endif
@ -1126,7 +1126,7 @@ srs_error_t SrsRtmpConn::handle_publish_message(SrsSharedPtr<SrsLiveSource> &sou
// for fmle, drop others except the fmle start packet.
if (dynamic_cast<SrsFMLEStartPacket *>(pkt.get())) {
SrsFMLEStartPacket *unpublish = dynamic_cast<SrsFMLEStartPacket *>(pkt.get());
if ((err = rtmp->fmle_unpublish(info->res->stream_id, unpublish->transaction_id)) != srs_success) {
if ((err = rtmp->fmle_unpublish(info->res->stream_id_, unpublish->transaction_id_)) != srs_success) {
return srs_error_wrap(err, "rtmp: republish");
}
return srs_error_new(ERROR_CONTROL_REPUBLISH, "rtmp: republish");
@ -1232,10 +1232,10 @@ srs_error_t SrsRtmpConn::process_play_control_msg(SrsLiveConsumer *consumer, Srs
if (call) {
// only response it when transaction id not zero,
// for the zero means donot need response.
if (call->transaction_id > 0) {
SrsCallResPacket *res = new SrsCallResPacket(call->transaction_id);
res->command_object = SrsAmf0Any::null();
res->response = SrsAmf0Any::null();
if (call->transaction_id_ > 0) {
SrsCallResPacket *res = new SrsCallResPacket(call->transaction_id_);
res->command_object_ = SrsAmf0Any::null();
res->response_ = SrsAmf0Any::null();
if ((err = rtmp->send_and_free_packet(res, 0)) != srs_success) {
return srs_error_wrap(err, "rtmp: send packets");
}
@ -1246,10 +1246,10 @@ srs_error_t SrsRtmpConn::process_play_control_msg(SrsLiveConsumer *consumer, Srs
// pause
SrsPausePacket *pause = dynamic_cast<SrsPausePacket *>(pkt.get());
if (pause) {
if ((err = rtmp->on_play_client_pause(info->res->stream_id, pause->is_pause)) != srs_success) {
if ((err = rtmp->on_play_client_pause(info->res->stream_id_, pause->is_pause_)) != srs_success) {
return srs_error_wrap(err, "rtmp: pause");
}
if ((err = consumer->on_play_client_pause(pause->is_pause)) != srs_success) {
if ((err = consumer->on_play_client_pause(pause->is_pause_)) != srs_success) {
return srs_error_wrap(err, "rtmp: pause");
}
return err;
@ -1263,7 +1263,7 @@ void SrsRtmpConn::set_sock_options()
{
ISrsRequest *req = info->req;
bool nvalue = _srs_config->get_tcp_nodelay(req->vhost);
bool nvalue = _srs_config->get_tcp_nodelay(req->vhost_);
if (nvalue != tcp_nodelay) {
tcp_nodelay = nvalue;
@ -1282,7 +1282,7 @@ srs_error_t SrsRtmpConn::check_edge_token_traverse_auth()
ISrsRequest *req = info->req;
srs_assert(req);
vector<string> args = _srs_config->get_vhost_edge_origin(req->vhost)->args;
vector<string> args = _srs_config->get_vhost_edge_origin(req->vhost_)->args;
if (args.empty()) {
return err;
}
@ -1297,7 +1297,7 @@ srs_error_t SrsRtmpConn::check_edge_token_traverse_auth()
SrsUniquePtr<SrsTcpClient> transport(new SrsTcpClient(server, port, SRS_EDGE_TOKEN_TRAVERSE_TIMEOUT));
if ((err = transport->connect()) != srs_success) {
srs_warn("Illegal edge token, tcUrl=%s, %s", req->tcUrl.c_str(), srs_error_desc(err).c_str());
srs_warn("Illegal edge token, tcUrl=%s, %s", req->tcUrl_.c_str(), srs_error_desc(err).c_str());
srs_freep(err);
continue;
}
@ -1325,11 +1325,11 @@ srs_error_t SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient *client)
// for token tranverse, always take the debug info(which carries token).
SrsServerInfo si;
if ((err = client->connect_app(req->app, req->tcUrl, req, true, &si)) != srs_success) {
if ((err = client->connect_app(req->app_, req->tcUrl_, req, true, &si)) != srs_success) {
return srs_error_wrap(err, "rtmp: connect tcUrl");
}
srs_trace("edge token auth ok, tcUrl=%s", req->tcUrl.c_str());
srs_trace("edge token auth ok, tcUrl=%s", req->tcUrl_.c_str());
return err;
}
@ -1350,7 +1350,7 @@ srs_error_t SrsRtmpConn::http_hooks_on_connect()
ISrsRequest *req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -1360,7 +1360,7 @@ srs_error_t SrsRtmpConn::http_hooks_on_connect()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_connect(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_connect(req->vhost_);
if (!conf) {
return err;
@ -1383,7 +1383,7 @@ void SrsRtmpConn::http_hooks_on_close()
{
ISrsRequest *req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return;
}
@ -1393,7 +1393,7 @@ void SrsRtmpConn::http_hooks_on_close()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_close(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_close(req->vhost_);
if (!conf) {
return;
@ -1414,7 +1414,7 @@ srs_error_t SrsRtmpConn::http_hooks_on_publish()
ISrsRequest *req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -1424,7 +1424,7 @@ srs_error_t SrsRtmpConn::http_hooks_on_publish()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_publish(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_publish(req->vhost_);
if (!conf) {
return err;
@ -1447,7 +1447,7 @@ void SrsRtmpConn::http_hooks_on_unpublish()
{
ISrsRequest *req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return;
}
@ -1457,7 +1457,7 @@ void SrsRtmpConn::http_hooks_on_unpublish()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_unpublish(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_unpublish(req->vhost_);
if (!conf) {
return;
@ -1478,7 +1478,7 @@ srs_error_t SrsRtmpConn::http_hooks_on_play()
ISrsRequest *req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -1488,7 +1488,7 @@ srs_error_t SrsRtmpConn::http_hooks_on_play()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost_);
if (!conf) {
return err;
@ -1511,7 +1511,7 @@ void SrsRtmpConn::http_hooks_on_stop()
{
ISrsRequest *req = info->req;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return;
}
@ -1521,7 +1521,7 @@ void SrsRtmpConn::http_hooks_on_stop()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req->vhost_);
if (!conf) {
return;

View File

@ -359,7 +359,7 @@ SrsRtspConnection::SrsRtspConnection(ISrsResourceManager *cm, ISrsProtocolReadWr
disposing_ = false;
request_ = new SrsRequest();
request_->ip = cip;
request_->ip_ = cip;
ip_ = cip;
port_ = port;
rtsp_ = new SrsRtspStack(skt);
@ -683,15 +683,15 @@ void SrsRtspConnection::alive()
srs_error_t SrsRtspConnection::do_describe(SrsRtspRequest *req, std::string &sdp)
{
srs_error_t err = srs_success;
srs_net_url_parse_rtmp_url(req->uri, request_->tcUrl, request_->stream);
srs_net_url_parse_rtmp_url(req->uri, request_->tcUrl_, request_->stream_);
srs_net_url_parse_tcurl(request_->tcUrl, request_->schema, request_->host, request_->vhost,
request_->app, request_->stream, request_->port, request_->param);
srs_net_url_parse_tcurl(request_->tcUrl_, request_->schema_, request_->host_, request_->vhost_,
request_->app_, request_->stream_, request_->port_, request_->param_);
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(request_->vhost);
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(request_->vhost_);
if (parsed_vhost) {
request_->vhost = parsed_vhost->arg0();
request_->vhost_ = parsed_vhost->arg0();
}
if ((err = security_->check(SrsRtcConnPlay, ip_, request_)) != srs_success) {
@ -854,7 +854,7 @@ srs_error_t SrsRtspConnection::http_hooks_on_play(ISrsRequest *req)
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost_)) {
return err;
}
@ -864,7 +864,7 @@ srs_error_t SrsRtspConnection::http_hooks_on_play(ISrsRequest *req)
std::vector<std::string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req->vhost_);
if (!conf) {
return err;

View File

@ -666,7 +666,7 @@ srs_error_t SrsRtspRtpBuilder::initialize(ISrsRequest *r)
}
// Setup the SPS/PPS parsing strategy.
format->try_annexb_first_ = _srs_config->try_annexb_first(r->vhost);
format->try_annexb_first_ = _srs_config->try_annexb_first(r->vhost_);
srs_trace("RTSP bridge from RTMP, try_annexb_first=%d", format->try_annexb_first_);

View File

@ -24,12 +24,12 @@ srs_error_t SrsSecurity::check(SrsRtmpConnType type, string ip, ISrsRequest *req
srs_error_t err = srs_success;
// allow all if security disabled.
if (!_srs_config->get_security_enabled(req->vhost)) {
if (!_srs_config->get_security_enabled(req->vhost_)) {
return err; // OK
}
// rules to apply
SrsConfDirective *rules = _srs_config->get_security_rules(req->vhost);
SrsConfDirective *rules = _srs_config->get_security_rules(req->vhost_);
return do_check(rules, type, ip, req);
}

View File

@ -1342,7 +1342,7 @@ srs_error_t SrsServer::create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_s
// Security or system flow control check. For WebRTC, use 0 as fd and port, because for
// the WebRTC HTTP API, it's not useful information.
if ((err = on_before_connection("RTC", (int)0, req->ip, 0)) != srs_success) {
if ((err = on_before_connection("RTC", (int)0, req->ip_, 0)) != srs_success) {
return srs_error_wrap(err, "check");
}

View File

@ -494,10 +494,10 @@ srs_error_t SrsLiveConsumer::dump_packets(SrsMessageArray *msgs, int &count)
srs_error_t err = srs_success;
srs_assert(count >= 0);
srs_assert(msgs->max > 0);
srs_assert(msgs->max_ > 0);
// the count used as input to reset the max if positive.
int max = count ? srs_min(count, msgs->max) : msgs->max;
int max = count ? srs_min(count, msgs->max_) : msgs->max_;
// the count specifies the max acceptable count,
// here maybe 1+, and we must set to 0 when got nothing.
@ -514,7 +514,7 @@ srs_error_t SrsLiveConsumer::dump_packets(SrsMessageArray *msgs, int &count)
}
// pump msgs from queue.
if ((err = queue->dump_packets(max, msgs->msgs, count)) != srs_success) {
if ((err = queue->dump_packets(max, msgs->msgs_, count)) != srs_success) {
return srs_error_wrap(err, "dump packets");
}
@ -978,7 +978,7 @@ srs_error_t SrsOriginHub::on_audio(SrsMediaPacket *shared_audio)
if ((err = hls->on_audio(msg, format)) != srs_success) {
// apply the error strategy for hls.
std::string hls_error_strategy = _srs_config->get_hls_on_error(req_->vhost);
std::string hls_error_strategy = _srs_config->get_hls_on_error(req_->vhost_);
if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) {
srs_warn("hls: ignore audio error %s", srs_error_desc(err).c_str());
hls->on_unpublish();
@ -1069,7 +1069,7 @@ srs_error_t SrsOriginHub::on_video(SrsMediaPacket *shared_video, bool is_sequenc
if ((err = hls->on_video(msg, format)) != srs_success) {
// TODO: We should support more strategies.
// apply the error strategy for hls.
std::string hls_error_strategy = _srs_config->get_hls_on_error(req_->vhost);
std::string hls_error_strategy = _srs_config->get_hls_on_error(req_->vhost_);
if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) {
srs_warn("hls: ignore video error %s", srs_error_desc(err).c_str());
hls->on_unpublish();
@ -1260,7 +1260,7 @@ srs_error_t SrsOriginHub::create_forwarders()
{
srs_error_t err = srs_success;
if (!_srs_config->get_forward_enabled(req_->vhost)) {
if (!_srs_config->get_forward_enabled(req_->vhost_)) {
return err;
}
@ -1277,7 +1277,7 @@ srs_error_t SrsOriginHub::create_forwarders()
}
// For destanition config
SrsConfDirective *conf = _srs_config->get_forwards(req_->vhost);
SrsConfDirective *conf = _srs_config->get_forwards(req_->vhost_);
for (int i = 0; conf && i < (int)conf->args.size(); i++) {
std::string forward_server = conf->args.at(i);
@ -1289,12 +1289,12 @@ srs_error_t SrsOriginHub::create_forwarders()
return srs_error_wrap(err, "init forwarder");
}
srs_utime_t queue_size = _srs_config->get_queue_length(req_->vhost);
srs_utime_t queue_size = _srs_config->get_queue_length(req_->vhost_);
forwarder->set_queue_size(queue_size);
if ((err = forwarder->on_publish()) != srs_success) {
return srs_error_wrap(err, "start forwarder failed, vhost=%s, app=%s, stream=%s, forward-to=%s",
req_->vhost.c_str(), req_->app.c_str(), req_->stream.c_str(), forward_server.c_str());
req_->vhost_.c_str(), req_->app_.c_str(), req_->stream_.c_str(), forward_server.c_str());
}
}
@ -1308,7 +1308,7 @@ srs_error_t SrsOriginHub::create_backend_forwarders(bool &applied)
// default not configure backend service
applied = false;
SrsConfDirective *conf = _srs_config->get_forward_backend(req_->vhost);
SrsConfDirective *conf = _srs_config->get_forward_backend(req_->vhost_);
if (!conf || conf->arg0().empty()) {
return err;
}
@ -1332,27 +1332,27 @@ srs_error_t SrsOriginHub::create_backend_forwarders(bool &applied)
// create temp Request by url
SrsUniquePtr<ISrsRequest> req(new SrsRequest());
srs_net_url_parse_rtmp_url(url, req->tcUrl, req->stream);
srs_net_url_parse_tcurl(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param);
srs_net_url_parse_rtmp_url(url, req->tcUrl_, req->stream_);
srs_net_url_parse_tcurl(req->tcUrl_, req->schema_, req->host_, req->vhost_, req->app_, req->stream_, req->port_, req->param_);
// create forwarder
SrsForwarder *forwarder = new SrsForwarder(this);
forwarders.push_back(forwarder);
std::stringstream forward_server;
forward_server << req->host << ":" << req->port;
forward_server << req->host_ << ":" << req->port_;
// initialize the forwarder with request.
if ((err = forwarder->initialize(req.get(), forward_server.str())) != srs_success) {
return srs_error_wrap(err, "init backend forwarder failed, forward-to=%s", forward_server.str().c_str());
}
srs_utime_t queue_size = _srs_config->get_queue_length(req_->vhost);
srs_utime_t queue_size = _srs_config->get_queue_length(req_->vhost_);
forwarder->set_queue_size(queue_size);
if ((err = forwarder->on_publish()) != srs_success) {
return srs_error_wrap(err, "start backend forwarder failed, vhost=%s, app=%s, stream=%s, forward-to=%s",
req_->vhost.c_str(), req_->app.c_str(), req_->stream.c_str(), forward_server.str().c_str());
req_->vhost_.c_str(), req_->app_.c_str(), req_->stream_.c_str(), forward_server.str().c_str());
}
}
@ -1479,32 +1479,32 @@ srs_error_t SrsMetaCache::update_data(SrsMessageHeader *header, SrsOnMetaDataPac
SrsAmf0Any *prop = NULL;
// when exists the duration, remove it to make ExoPlayer happy.
if (metadata->metadata->get_property("duration") != NULL) {
metadata->metadata->remove("duration");
if (metadata->metadata_->get_property("duration") != NULL) {
metadata->metadata_->remove("duration");
}
// generate metadata info to print
std::stringstream ss;
if ((prop = metadata->metadata->ensure_property_number("width")) != NULL) {
if ((prop = metadata->metadata_->ensure_property_number("width")) != NULL) {
ss << ", width=" << (int)prop->to_number();
}
if ((prop = metadata->metadata->ensure_property_number("height")) != NULL) {
if ((prop = metadata->metadata_->ensure_property_number("height")) != NULL) {
ss << ", height=" << (int)prop->to_number();
}
if ((prop = metadata->metadata->ensure_property_number("videocodecid")) != NULL) {
if ((prop = metadata->metadata_->ensure_property_number("videocodecid")) != NULL) {
ss << ", vcodec=" << (int)prop->to_number();
}
if ((prop = metadata->metadata->ensure_property_number("audiocodecid")) != NULL) {
if ((prop = metadata->metadata_->ensure_property_number("audiocodecid")) != NULL) {
ss << ", acodec=" << (int)prop->to_number();
}
srs_trace("got metadata%s", ss.str().c_str());
// add server info to metadata
metadata->metadata->set("server", SrsAmf0Any::str(RTMP_SIG_SRS_SERVER));
metadata->metadata_->set("server", SrsAmf0Any::str(RTMP_SIG_SRS_SERVER));
// version, for example, 1.0.0
// add version to metadata, please donot remove it, for debug.
metadata->metadata->set("server_version", SrsAmf0Any::str(RTMP_SIG_SRS_VERSION));
metadata->metadata_->set("server_version", SrsAmf0Any::str(RTMP_SIG_SRS_VERSION));
// encode the metadata to payload
int size = 0;
@ -1823,17 +1823,17 @@ srs_error_t SrsLiveSource::initialize(SrsSharedPtr<SrsLiveSource> wrapper, ISrsR
srs_assert(!req);
req = r->copy();
atc = _srs_config->get_atc(req->vhost);
atc = _srs_config->get_atc(req->vhost_);
jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(req->vhost);
mix_correct = _srs_config->get_mix_correct(req->vhost);
jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(req->vhost_);
mix_correct = _srs_config->get_mix_correct(req->vhost_);
if ((err = format_->initialize()) != srs_success) {
return srs_error_wrap(err, "format initialize");
}
// Setup the SPS/PPS parsing strategy.
format_->try_annexb_first_ = _srs_config->try_annexb_first(r->vhost);
format_->try_annexb_first_ = _srs_config->try_annexb_first(r->vhost_);
if ((err = play_edge->initialize(wrapper, req)) != srs_success) {
return srs_error_wrap(err, "edge(play)");
@ -1842,7 +1842,7 @@ srs_error_t SrsLiveSource::initialize(SrsSharedPtr<SrsLiveSource> wrapper, ISrsR
return srs_error_wrap(err, "edge(publish)");
}
srs_utime_t queue_size = _srs_config->get_queue_length(req->vhost);
srs_utime_t queue_size = _srs_config->get_queue_length(req->vhost_);
publish_edge->set_queue_size(queue_size);
if ((err = hub->initialize(wrapper, req)) != srs_success) {
@ -1922,9 +1922,9 @@ srs_error_t SrsLiveSource::on_meta_data(SrsRtmpCommonMessage *msg, SrsOnMetaData
// if allow atc_auto and bravo-atc detected, open atc for vhost.
SrsAmf0Any *prop = NULL;
atc = _srs_config->get_atc(req->vhost);
if (_srs_config->get_atc_auto(req->vhost)) {
if ((prop = metadata->metadata->get_property("bravo_atc")) != NULL) {
atc = _srs_config->get_atc(req->vhost_);
if (_srs_config->get_atc_auto(req->vhost_)) {
if ((prop = metadata->metadata_->get_property("bravo_atc")) != NULL) {
if (prop->is_string() && prop->to_str() == "true") {
atc = true;
}
@ -1942,7 +1942,7 @@ srs_error_t SrsLiveSource::on_meta_data(SrsRtmpCommonMessage *msg, SrsOnMetaData
// when already got metadata, drop when reduce sequence header.
bool drop_for_reduce = false;
if (meta->data() && _srs_config->get_reduce_sequence_header(req->vhost)) {
if (meta->data() && _srs_config->get_reduce_sequence_header(req->vhost_)) {
drop_for_reduce = true;
srs_warn("drop for reduce sh metadata, size=%d", msg->size());
}
@ -2036,7 +2036,7 @@ srs_error_t SrsLiveSource::on_audio_imp(SrsMediaPacket *msg)
// whether consumer should drop for the duplicated sequence header.
bool drop_for_reduce = false;
if (is_sequence_header && meta->previous_ash() && _srs_config->get_reduce_sequence_header(req->vhost)) {
if (is_sequence_header && meta->previous_ash() && _srs_config->get_reduce_sequence_header(req->vhost_)) {
if (meta->previous_ash()->size() == msg->size()) {
drop_for_reduce = srs_bytes_equal(meta->previous_ash()->payload(), msg->payload(), msg->size());
srs_warn("drop for reduce sh audio, size=%d", msg->size());
@ -2136,7 +2136,7 @@ srs_error_t SrsLiveSource::on_video_imp(SrsMediaPacket *msg)
// user can disable the sps parse to workaround when parse sps failed.
// @see https://github.com/ossrs/srs/issues/474
if (is_sequence_header) {
format_->avc_parse_sps_ = _srs_config->get_parse_sps(req->vhost);
format_->avc_parse_sps_ = _srs_config->get_parse_sps(req->vhost_);
}
if ((err = format_->on_video(msg)) != srs_success) {
@ -2151,7 +2151,7 @@ srs_error_t SrsLiveSource::on_video_imp(SrsMediaPacket *msg)
// whether consumer should drop for the duplicated sequence header.
bool drop_for_reduce = false;
if (is_sequence_header && meta->previous_vsh() && _srs_config->get_reduce_sequence_header(req->vhost)) {
if (is_sequence_header && meta->previous_vsh() && _srs_config->get_reduce_sequence_header(req->vhost_)) {
if (meta->previous_vsh()->size() == msg->size()) {
drop_for_reduce = srs_bytes_equal(meta->previous_vsh()->payload(), msg->payload(), msg->size());
srs_warn("drop for reduce sh video, size=%d", msg->size());
@ -2404,7 +2404,7 @@ srs_error_t SrsLiveSource::create_consumer(SrsLiveConsumer *&consumer)
srs_error_t err = srs_success;
// for edge, when play edge stream, check the state
if (_srs_config->get_vhost_is_edge(req->vhost)) {
if (_srs_config->get_vhost_is_edge(req->vhost_)) {
// notice edge to start for the first client.
if ((err = play_edge->on_client_play()) != srs_success) {
return srs_error_wrap(err, "play edge");
@ -2425,7 +2425,7 @@ srs_error_t SrsLiveSource::consumer_dumps(SrsLiveConsumer *consumer, bool ds, bo
{
srs_error_t err = srs_success;
srs_utime_t queue_size = _srs_config->get_queue_length(req->vhost);
srs_utime_t queue_size = _srs_config->get_queue_length(req->vhost_);
consumer->set_queue_size(queue_size);
// if atc, update the sequence header to gop cache time.
@ -2482,7 +2482,7 @@ void SrsLiveSource::on_consumer_destroy(SrsLiveConsumer *consumer)
// For edge server, the stream die when the last player quit, because the edge stream is created by player
// activities, so it should die when all players quit.
if (_srs_config->get_vhost_is_edge(req->vhost)) {
if (_srs_config->get_vhost_is_edge(req->vhost_)) {
stream_die_at_ = srs_time_now_cached();
}

View File

@ -173,7 +173,7 @@ SrsMpegtsSrtConn::SrsMpegtsSrtConn(ISrsResourceManager *resource_manager, srs_sr
trd_ = new SrsSTCoroutine("ts-srt", this, _srs_context->get_id());
req_ = new SrsRequest();
req_->ip = ip;
req_->ip_ = ip;
security_ = new SrsSecurity();
}
@ -273,17 +273,17 @@ srs_error_t SrsMpegtsSrtConn::do_cycle()
}
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(req_->vhost);
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(req_->vhost_);
if (parsed_vhost) {
req_->vhost = parsed_vhost->arg0();
req_->vhost_ = parsed_vhost->arg0();
}
if (!_srs_config->get_srt_enabled(req_->vhost)) {
return srs_error_new(ERROR_SRT_CONN, "srt disabled, vhost=%s", req_->vhost.c_str());
if (!_srs_config->get_srt_enabled(req_->vhost_)) {
return srs_error_new(ERROR_SRT_CONN, "srt disabled, vhost=%s", req_->vhost_.c_str());
}
srs_trace("@srt, streamid=%s, stream_url=%s, vhost=%s, app=%s, stream=%s, param=%s",
streamid.c_str(), req_->get_stream_url().c_str(), req_->vhost.c_str(), req_->app.c_str(), req_->stream.c_str(), req_->param.c_str());
streamid.c_str(), req_->get_stream_url().c_str(), req_->vhost_.c_str(), req_->app_.c_str(), req_->stream_.c_str(), req_->param_.c_str());
// Acquire stream publish token to prevent race conditions across all protocols.
SrsStreamPublishToken *publish_token_raw = NULL;
@ -390,8 +390,8 @@ srs_error_t SrsMpegtsSrtConn::acquire_publish()
srs_assert(live_source.get() != NULL);
bool enabled_cache = _srs_config->get_gop_cache(req_->vhost);
int gcmf = _srs_config->get_gop_cache_max_frames(req_->vhost);
bool enabled_cache = _srs_config->get_gop_cache(req_->vhost_);
int gcmf = _srs_config->get_gop_cache_max_frames(req_->vhost_);
live_source->set_cache(enabled_cache);
live_source->set_gop_cache_max_frames(gcmf);
@ -401,8 +401,8 @@ srs_error_t SrsMpegtsSrtConn::acquire_publish()
// Check whether RTC stream is busy.
SrsSharedPtr<SrsRtcSource> rtc;
bool rtc_server_enabled = _srs_config->get_rtc_server_enabled();
bool rtc_enabled = _srs_config->get_rtc_enabled(req_->vhost);
bool edge = _srs_config->get_vhost_is_edge(req_->vhost);
bool rtc_enabled = _srs_config->get_rtc_enabled(req_->vhost_);
bool edge = _srs_config->get_vhost_is_edge(req_->vhost_);
if (rtc_server_enabled && rtc_enabled && !edge) {
if ((err = _srs_rtc_sources->fetch_or_create(req_, rtc)) != srs_success) {
return srs_error_wrap(err, "create source");
@ -413,13 +413,13 @@ srs_error_t SrsMpegtsSrtConn::acquire_publish()
}
}
if (_srs_config->get_srt_to_rtmp(req_->vhost)) {
if (_srs_config->get_srt_to_rtmp(req_->vhost_)) {
// Bridge to RTMP and RTC streaming.
SrsCompositeBridge *bridge = new SrsCompositeBridge();
bridge->append(new SrsFrameToRtmpBridge(live_source));
#if defined(SRS_FFMPEG_FIT)
if (rtc.get() && _srs_config->get_rtc_from_rtmp(req_->vhost)) {
if (rtc.get() && _srs_config->get_rtc_from_rtmp(req_->vhost_)) {
bridge->append(new SrsFrameToRtcBridge(rtc));
}
#endif
@ -605,7 +605,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_connect()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost_)) {
return err;
}
@ -615,7 +615,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_connect()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_connect(req_->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_connect(req_->vhost_);
if (!conf) {
return err;
@ -636,7 +636,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_connect()
void SrsMpegtsSrtConn::http_hooks_on_close()
{
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost_)) {
return;
}
@ -646,7 +646,7 @@ void SrsMpegtsSrtConn::http_hooks_on_close()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_close(req_->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_close(req_->vhost_);
if (!conf) {
return;
@ -665,7 +665,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_publish()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost_)) {
return err;
}
@ -675,7 +675,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_publish()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_publish(req_->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_publish(req_->vhost_);
if (!conf) {
return err;
@ -696,7 +696,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_publish()
void SrsMpegtsSrtConn::http_hooks_on_unpublish()
{
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost_)) {
return;
}
@ -706,7 +706,7 @@ void SrsMpegtsSrtConn::http_hooks_on_unpublish()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_unpublish(req_->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_unpublish(req_->vhost_);
if (!conf) {
return;
@ -725,7 +725,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_play()
{
srs_error_t err = srs_success;
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost_)) {
return err;
}
@ -735,7 +735,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_play()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req_->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_play(req_->vhost_);
if (!conf) {
return err;
@ -756,7 +756,7 @@ srs_error_t SrsMpegtsSrtConn::http_hooks_on_play()
void SrsMpegtsSrtConn::http_hooks_on_stop()
{
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost)) {
if (!_srs_config->get_vhost_http_hooks_enabled(req_->vhost_)) {
return;
}
@ -766,7 +766,7 @@ void SrsMpegtsSrtConn::http_hooks_on_stop()
vector<string> hooks;
if (true) {
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req_->vhost);
SrsConfDirective *conf = _srs_config->get_vhost_on_stop(req_->vhost_);
if (!conf) {
return;

View File

@ -808,7 +808,7 @@ srs_error_t SrsSrtFrameBuilder::on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs)
// May have more than one aac frame in PES packet, and shared same timestamp,
// so we must calculate each aac frame's timestamp.
int sample_rate = 44100;
switch (codec.sound_rate) {
switch (codec.sound_rate_) {
case SrsAudioSampleRate5512:
sample_rate = 5512;
break;

View File

@ -115,7 +115,7 @@ bool srs_srt_streamid_info(const std::string &streamid, SrtMode &mode, std::stri
bool srs_srt_streamid_to_request(const std::string &streamid, SrtMode &mode, ISrsRequest *request)
{
string url_subpath = "";
bool ret = srs_srt_streamid_info(streamid, mode, request->vhost, url_subpath);
bool ret = srs_srt_streamid_info(streamid, mode, request->vhost_, url_subpath);
if (!ret) {
return ret;
}
@ -123,25 +123,25 @@ bool srs_srt_streamid_to_request(const std::string &streamid, SrtMode &mode, ISr
size_t pos = url_subpath.find("/");
string stream_with_params = "";
if (pos == string::npos) {
request->app = _srs_config->get_default_app_name();
request->app_ = _srs_config->get_default_app_name();
stream_with_params = url_subpath;
} else {
request->app = url_subpath.substr(0, pos);
request->app_ = url_subpath.substr(0, pos);
stream_with_params = url_subpath.substr(pos + 1);
}
pos = stream_with_params.find("?");
if (pos == string::npos) {
request->stream = stream_with_params;
request->stream_ = stream_with_params;
} else {
request->stream = stream_with_params.substr(0, pos);
request->param = stream_with_params.substr(pos + 1);
request->stream_ = stream_with_params.substr(0, pos);
request->param_ = stream_with_params.substr(pos + 1);
}
request->host = srs_get_public_internet_address();
if (request->vhost.empty())
request->vhost = request->host;
request->tcUrl = srs_net_url_encode_tcurl("srt", request->host, request->vhost, request->app, request->port);
request->host_ = srs_get_public_internet_address();
if (request->vhost_.empty())
request->vhost_ = request->host_;
request->tcUrl_ = srs_net_url_encode_tcurl("srt", request->host_, request->vhost_, request->app_, request->port_);
return ret;
}

View File

@ -225,12 +225,12 @@ srs_error_t SrsStatisticClient::dumps(SrsJsonObject *obj)
obj->set("id", SrsJsonAny::str(id.c_str()));
obj->set("vhost", SrsJsonAny::str(stream->vhost->id.c_str()));
obj->set("stream", SrsJsonAny::str(stream->id.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str()));
obj->set("swfUrl", SrsJsonAny::str(req->swfUrl.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip_.c_str()));
obj->set("pageUrl", SrsJsonAny::str(req->pageUrl_.c_str()));
obj->set("swfUrl", SrsJsonAny::str(req->swfUrl_.c_str()));
obj->set("tcUrl", SrsJsonAny::str(req->tcUrl_.c_str()));
obj->set("url", SrsJsonAny::str(req->get_stream_url().c_str()));
obj->set("name", SrsJsonAny::str(req->stream.c_str()));
obj->set("name", SrsJsonAny::str(req->stream_.c_str()));
obj->set("type", SrsJsonAny::str(srs_client_type_string(type).c_str()));
obj->set("publish", SrsJsonAny::boolean(srs_client_type_is_publish(type)));
obj->set("alive", SrsJsonAny::number(srsu2ms(srs_time_now_cached() - create) / 1000.0));
@ -739,15 +739,15 @@ SrsStatisticVhost *SrsStatistic::create_vhost(ISrsRequest *req)
SrsStatisticVhost *vhost = NULL;
// create vhost if not exists.
if (rvhosts.find(req->vhost) == rvhosts.end()) {
if (rvhosts.find(req->vhost_) == rvhosts.end()) {
vhost = new SrsStatisticVhost();
vhost->vhost = req->vhost;
rvhosts[req->vhost] = vhost;
vhost->vhost = req->vhost_;
rvhosts[req->vhost_] = vhost;
vhosts[vhost->id] = vhost;
return vhost;
}
vhost = rvhosts[req->vhost];
vhost = rvhosts[req->vhost_];
return vhost;
}
@ -767,10 +767,10 @@ SrsStatisticStream *SrsStatistic::create_stream(SrsStatisticVhost *vhost, ISrsRe
if (rstreams.find(url) == rstreams.end()) {
stream = new SrsStatisticStream();
stream->vhost = vhost;
stream->stream = req->stream;
stream->app = req->app;
stream->stream = req->stream_;
stream->app = req->app_;
stream->url = url;
stream->tcUrl = req->tcUrl;
stream->tcUrl = req->tcUrl_;
rstreams[url] = stream;
streams[stream->id] = stream;
return stream;

View File

@ -9,6 +9,6 @@
#define VERSION_MAJOR 7
#define VERSION_MINOR 0
#define VERSION_REVISION 82
#define VERSION_REVISION 83
#endif

View File

@ -46,7 +46,7 @@ using namespace srs_internal;
SrsAmf0Any::SrsAmf0Any()
{
marker = RTMP_AMF0_Invalid;
marker_ = RTMP_AMF0_Invalid;
}
SrsAmf0Any::~SrsAmf0Any()
@ -55,47 +55,47 @@ SrsAmf0Any::~SrsAmf0Any()
bool SrsAmf0Any::is_string()
{
return marker == RTMP_AMF0_String;
return marker_ == RTMP_AMF0_String;
}
bool SrsAmf0Any::is_boolean()
{
return marker == RTMP_AMF0_Boolean;
return marker_ == RTMP_AMF0_Boolean;
}
bool SrsAmf0Any::is_number()
{
return marker == RTMP_AMF0_Number;
return marker_ == RTMP_AMF0_Number;
}
bool SrsAmf0Any::is_null()
{
return marker == RTMP_AMF0_Null;
return marker_ == RTMP_AMF0_Null;
}
bool SrsAmf0Any::is_undefined()
{
return marker == RTMP_AMF0_Undefined;
return marker_ == RTMP_AMF0_Undefined;
}
bool SrsAmf0Any::is_object()
{
return marker == RTMP_AMF0_Object;
return marker_ == RTMP_AMF0_Object;
}
bool SrsAmf0Any::is_ecma_array()
{
return marker == RTMP_AMF0_EcmaArray;
return marker_ == RTMP_AMF0_EcmaArray;
}
bool SrsAmf0Any::is_strict_array()
{
return marker == RTMP_AMF0_StrictArray;
return marker_ == RTMP_AMF0_StrictArray;
}
bool SrsAmf0Any::is_date()
{
return marker == RTMP_AMF0_Date;
return marker_ == RTMP_AMF0_Date;
}
bool SrsAmf0Any::is_complex_object()
@ -107,28 +107,28 @@ string SrsAmf0Any::to_str()
{
SrsAmf0String *p = dynamic_cast<SrsAmf0String *>(this);
srs_assert(p != NULL);
return p->value;
return p->value_;
}
const char *SrsAmf0Any::to_str_raw()
{
SrsAmf0String *p = dynamic_cast<SrsAmf0String *>(this);
srs_assert(p != NULL);
return p->value.data();
return p->value_.data();
}
bool SrsAmf0Any::to_boolean()
{
SrsAmf0Boolean *p = dynamic_cast<SrsAmf0Boolean *>(this);
srs_assert(p != NULL);
return p->value;
return p->value_;
}
double SrsAmf0Any::to_number()
{
SrsAmf0Number *p = dynamic_cast<SrsAmf0Number *>(this);
srs_assert(p != NULL);
return p->value;
return p->value_;
}
int64_t SrsAmf0Any::to_date()
@ -170,12 +170,12 @@ void SrsAmf0Any::set_number(double value)
{
SrsAmf0Number *p = dynamic_cast<SrsAmf0Number *>(this);
srs_assert(p != NULL);
p->value = value;
p->value_ = value;
}
bool SrsAmf0Any::is_object_eof()
{
return marker == RTMP_AMF0_ObjectEnd;
return marker_ == RTMP_AMF0_ObjectEnd;
}
void srs_fill_level_spaces(stringstream &ss, int level)
@ -273,7 +273,7 @@ char *SrsAmf0Any::human_print(char **pdata, int *psize)
SrsJsonAny *SrsAmf0Any::to_json()
{
switch (marker) {
switch (marker_) {
case RTMP_AMF0_String: {
return SrsJsonAny::str(to_str().c_str());
}
@ -442,38 +442,38 @@ SrsUnSortedHashtable::~SrsUnSortedHashtable()
int SrsUnSortedHashtable::count()
{
return (int)properties.size();
return (int)properties_.size();
}
void SrsUnSortedHashtable::clear()
{
std::vector<SrsAmf0ObjectPropertyType>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsAmf0ObjectPropertyType &elem = *it;
SrsAmf0Any *any = elem.second;
srs_freep(any);
}
properties.clear();
properties_.clear();
}
string SrsUnSortedHashtable::key_at(int index)
{
srs_assert(index < count());
SrsAmf0ObjectPropertyType &elem = properties[index];
SrsAmf0ObjectPropertyType &elem = properties_[index];
return elem.first;
}
const char *SrsUnSortedHashtable::key_raw_at(int index)
{
srs_assert(index < count());
SrsAmf0ObjectPropertyType &elem = properties[index];
SrsAmf0ObjectPropertyType &elem = properties_[index];
return elem.first.data();
}
SrsAmf0Any *SrsUnSortedHashtable::value_at(int index)
{
srs_assert(index < count());
SrsAmf0ObjectPropertyType &elem = properties[index];
SrsAmf0ObjectPropertyType &elem = properties_[index];
return elem.second;
}
@ -481,20 +481,20 @@ void SrsUnSortedHashtable::set(string key, SrsAmf0Any *value)
{
std::vector<SrsAmf0ObjectPropertyType>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsAmf0ObjectPropertyType &elem = *it;
std::string name = elem.first;
SrsAmf0Any *any = elem.second;
if (key == name) {
srs_freep(any);
it = properties.erase(it);
it = properties_.erase(it);
break;
}
}
if (value) {
properties.push_back(std::make_pair(key, value));
properties_.push_back(std::make_pair(key, value));
}
}
@ -502,7 +502,7 @@ SrsAmf0Any *SrsUnSortedHashtable::get_property(string name)
{
std::vector<SrsAmf0ObjectPropertyType>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsAmf0ObjectPropertyType &elem = *it;
std::string key = elem.first;
SrsAmf0Any *any = elem.second;
@ -548,14 +548,14 @@ void SrsUnSortedHashtable::remove(string name)
{
std::vector<SrsAmf0ObjectPropertyType>::iterator it;
for (it = properties.begin(); it != properties.end();) {
for (it = properties_.begin(); it != properties_.end();) {
std::string key = it->first;
SrsAmf0Any *any = it->second;
if (key == name) {
srs_freep(any);
it = properties.erase(it);
it = properties_.erase(it);
} else {
++it;
}
@ -565,7 +565,7 @@ void SrsUnSortedHashtable::remove(string name)
void SrsUnSortedHashtable::copy(SrsUnSortedHashtable *src)
{
std::vector<SrsAmf0ObjectPropertyType>::iterator it;
for (it = src->properties.begin(); it != src->properties.end(); ++it) {
for (it = src->properties_.begin(); it != src->properties_.end(); ++it) {
SrsAmf0ObjectPropertyType &elem = *it;
std::string key = elem.first;
SrsAmf0Any *any = elem.second;
@ -575,7 +575,7 @@ void SrsUnSortedHashtable::copy(SrsUnSortedHashtable *src)
SrsAmf0ObjectEOF::SrsAmf0ObjectEOF()
{
marker = RTMP_AMF0_ObjectEnd;
marker_ = RTMP_AMF0_ObjectEnd;
}
SrsAmf0ObjectEOF::~SrsAmf0ObjectEOF()
@ -640,22 +640,22 @@ SrsAmf0Any *SrsAmf0ObjectEOF::copy()
SrsAmf0Object::SrsAmf0Object()
{
properties = new SrsUnSortedHashtable();
eof = new SrsAmf0ObjectEOF();
marker = RTMP_AMF0_Object;
properties_ = new SrsUnSortedHashtable();
eof_ = new SrsAmf0ObjectEOF();
marker_ = RTMP_AMF0_Object;
}
SrsAmf0Object::~SrsAmf0Object()
{
srs_freep(properties);
srs_freep(eof);
srs_freep(properties_);
srs_freep(eof_);
}
int SrsAmf0Object::total_size()
{
int size = 1;
for (int i = 0; i < properties->count(); i++) {
for (int i = 0; i < properties_->count(); i++) {
std::string name = key_at(i);
SrsAmf0Any *value = value_at(i);
@ -724,7 +724,7 @@ srs_error_t SrsAmf0Object::write(SrsBuffer *stream)
stream->write_1bytes(RTMP_AMF0_Object);
// value
for (int i = 0; i < properties->count(); i++) {
for (int i = 0; i < properties_->count(); i++) {
std::string name = this->key_at(i);
SrsAmf0Any *any = this->value_at(i);
@ -737,7 +737,7 @@ srs_error_t SrsAmf0Object::write(SrsBuffer *stream)
}
}
if ((err = eof->write(stream)) != srs_success) {
if ((err = eof_->write(stream)) != srs_success) {
return srs_error_wrap(err, "write EOF");
}
@ -747,7 +747,7 @@ srs_error_t SrsAmf0Object::write(SrsBuffer *stream)
SrsAmf0Any *SrsAmf0Object::copy()
{
SrsAmf0Object *copy = new SrsAmf0Object();
copy->properties->copy(properties);
copy->properties_->copy(properties_);
return copy;
}
@ -755,7 +755,7 @@ SrsJsonAny *SrsAmf0Object::to_json()
{
SrsJsonObject *obj = SrsJsonAny::object();
for (int i = 0; i < properties->count(); i++) {
for (int i = 0; i < properties_->count(); i++) {
std::string name = this->key_at(i);
SrsAmf0Any *any = this->value_at(i);
@ -767,73 +767,73 @@ SrsJsonAny *SrsAmf0Object::to_json()
void SrsAmf0Object::clear()
{
properties->clear();
properties_->clear();
}
int SrsAmf0Object::count()
{
return properties->count();
return properties_->count();
}
string SrsAmf0Object::key_at(int index)
{
return properties->key_at(index);
return properties_->key_at(index);
}
const char *SrsAmf0Object::key_raw_at(int index)
{
return properties->key_raw_at(index);
return properties_->key_raw_at(index);
}
SrsAmf0Any *SrsAmf0Object::value_at(int index)
{
return properties->value_at(index);
return properties_->value_at(index);
}
void SrsAmf0Object::set(string key, SrsAmf0Any *value)
{
properties->set(key, value);
properties_->set(key, value);
}
SrsAmf0Any *SrsAmf0Object::get_property(string name)
{
return properties->get_property(name);
return properties_->get_property(name);
}
SrsAmf0Any *SrsAmf0Object::ensure_property_string(string name)
{
return properties->ensure_property_string(name);
return properties_->ensure_property_string(name);
}
SrsAmf0Any *SrsAmf0Object::ensure_property_number(string name)
{
return properties->ensure_property_number(name);
return properties_->ensure_property_number(name);
}
void SrsAmf0Object::remove(string name)
{
properties->remove(name);
properties_->remove(name);
}
SrsAmf0EcmaArray::SrsAmf0EcmaArray()
{
_count = 0;
properties = new SrsUnSortedHashtable();
eof = new SrsAmf0ObjectEOF();
marker = RTMP_AMF0_EcmaArray;
properties_ = new SrsUnSortedHashtable();
eof_ = new SrsAmf0ObjectEOF();
marker_ = RTMP_AMF0_EcmaArray;
}
SrsAmf0EcmaArray::~SrsAmf0EcmaArray()
{
srs_freep(properties);
srs_freep(eof);
srs_freep(properties_);
srs_freep(eof_);
}
int SrsAmf0EcmaArray::total_size()
{
int size = 1 + 4;
for (int i = 0; i < properties->count(); i++) {
for (int i = 0; i < properties_->count(); i++) {
std::string name = key_at(i);
SrsAmf0Any *value = value_at(i);
@ -917,7 +917,7 @@ srs_error_t SrsAmf0EcmaArray::write(SrsBuffer *stream)
stream->write_4bytes(this->_count);
// value
for (int i = 0; i < properties->count(); i++) {
for (int i = 0; i < properties_->count(); i++) {
std::string name = this->key_at(i);
SrsAmf0Any *any = this->value_at(i);
@ -930,7 +930,7 @@ srs_error_t SrsAmf0EcmaArray::write(SrsBuffer *stream)
}
}
if ((err = eof->write(stream)) != srs_success) {
if ((err = eof_->write(stream)) != srs_success) {
return srs_error_wrap(err, "write EOF");
}
@ -940,7 +940,7 @@ srs_error_t SrsAmf0EcmaArray::write(SrsBuffer *stream)
SrsAmf0Any *SrsAmf0EcmaArray::copy()
{
SrsAmf0EcmaArray *copy = new SrsAmf0EcmaArray();
copy->properties->copy(properties);
copy->properties_->copy(properties_);
copy->_count = _count;
return copy;
}
@ -949,7 +949,7 @@ SrsJsonAny *SrsAmf0EcmaArray::to_json()
{
SrsJsonObject *obj = SrsJsonAny::object();
for (int i = 0; i < properties->count(); i++) {
for (int i = 0; i < properties_->count(); i++) {
std::string name = this->key_at(i);
SrsAmf0Any *any = this->value_at(i);
@ -961,52 +961,52 @@ SrsJsonAny *SrsAmf0EcmaArray::to_json()
void SrsAmf0EcmaArray::clear()
{
properties->clear();
properties_->clear();
}
int SrsAmf0EcmaArray::count()
{
return properties->count();
return properties_->count();
}
string SrsAmf0EcmaArray::key_at(int index)
{
return properties->key_at(index);
return properties_->key_at(index);
}
const char *SrsAmf0EcmaArray::key_raw_at(int index)
{
return properties->key_raw_at(index);
return properties_->key_raw_at(index);
}
SrsAmf0Any *SrsAmf0EcmaArray::value_at(int index)
{
return properties->value_at(index);
return properties_->value_at(index);
}
void SrsAmf0EcmaArray::set(string key, SrsAmf0Any *value)
{
properties->set(key, value);
properties_->set(key, value);
}
SrsAmf0Any *SrsAmf0EcmaArray::get_property(string name)
{
return properties->get_property(name);
return properties_->get_property(name);
}
SrsAmf0Any *SrsAmf0EcmaArray::ensure_property_string(string name)
{
return properties->ensure_property_string(name);
return properties_->ensure_property_string(name);
}
SrsAmf0Any *SrsAmf0EcmaArray::ensure_property_number(string name)
{
return properties->ensure_property_number(name);
return properties_->ensure_property_number(name);
}
SrsAmf0StrictArray::SrsAmf0StrictArray()
{
marker = RTMP_AMF0_StrictArray;
marker_ = RTMP_AMF0_StrictArray;
_count = 0;
}
@ -1019,8 +1019,8 @@ int SrsAmf0StrictArray::total_size()
{
int size = 1 + 4;
for (int i = 0; i < (int)properties.size(); i++) {
SrsAmf0Any *any = properties[i];
for (int i = 0; i < (int)properties_.size(); i++) {
SrsAmf0Any *any = properties_[i];
size += any->total_size();
}
@ -1059,7 +1059,7 @@ srs_error_t SrsAmf0StrictArray::read(SrsBuffer *stream)
}
// add property
properties.push_back(elem);
properties_.push_back(elem);
}
return err;
@ -1084,8 +1084,8 @@ srs_error_t SrsAmf0StrictArray::write(SrsBuffer *stream)
stream->write_4bytes(this->_count);
// value
for (int i = 0; i < (int)properties.size(); i++) {
SrsAmf0Any *any = properties[i];
for (int i = 0; i < (int)properties_.size(); i++) {
SrsAmf0Any *any = properties_[i];
if ((err = srs_amf0_write_any(stream, any)) != srs_success) {
return srs_error_wrap(err, "write property");
@ -1100,7 +1100,7 @@ SrsAmf0Any *SrsAmf0StrictArray::copy()
SrsAmf0StrictArray *copy = new SrsAmf0StrictArray();
std::vector<SrsAmf0Any *>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsAmf0Any *any = *it;
copy->append(any->copy());
}
@ -1113,8 +1113,8 @@ SrsJsonAny *SrsAmf0StrictArray::to_json()
{
SrsJsonArray *arr = SrsJsonAny::array();
for (int i = 0; i < (int)properties.size(); i++) {
SrsAmf0Any *any = properties[i];
for (int i = 0; i < (int)properties_.size(); i++) {
SrsAmf0Any *any = properties_[i];
arr->append(any->to_json());
}
@ -1125,28 +1125,28 @@ SrsJsonAny *SrsAmf0StrictArray::to_json()
void SrsAmf0StrictArray::clear()
{
std::vector<SrsAmf0Any *>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsAmf0Any *any = *it;
srs_freep(any);
}
properties.clear();
properties_.clear();
}
int SrsAmf0StrictArray::count()
{
return (int)properties.size();
return (int)properties_.size();
}
SrsAmf0Any *SrsAmf0StrictArray::at(int index)
{
srs_assert(index < (int)properties.size());
return properties.at(index);
srs_assert(index < (int)properties_.size());
return properties_.at(index);
}
void SrsAmf0StrictArray::append(SrsAmf0Any *any)
{
properties.push_back(any);
_count = (int32_t)properties.size();
properties_.push_back(any);
_count = (int32_t)properties_.size();
}
int SrsAmf0Size::utf8(string value)
@ -1227,9 +1227,9 @@ int SrsAmf0Size::any(SrsAmf0Any *o)
SrsAmf0String::SrsAmf0String(const char *_value)
{
marker = RTMP_AMF0_String;
marker_ = RTMP_AMF0_String;
if (_value) {
value = _value;
value_ = _value;
}
}
@ -1239,29 +1239,29 @@ SrsAmf0String::~SrsAmf0String()
int SrsAmf0String::total_size()
{
return SrsAmf0Size::str(value);
return SrsAmf0Size::str(value_);
}
srs_error_t SrsAmf0String::read(SrsBuffer *stream)
{
return srs_amf0_read_string(stream, value);
return srs_amf0_read_string(stream, value_);
}
srs_error_t SrsAmf0String::write(SrsBuffer *stream)
{
return srs_amf0_write_string(stream, value);
return srs_amf0_write_string(stream, value_);
}
SrsAmf0Any *SrsAmf0String::copy()
{
SrsAmf0String *copy = new SrsAmf0String(value.c_str());
SrsAmf0String *copy = new SrsAmf0String(value_.c_str());
return copy;
}
SrsAmf0Boolean::SrsAmf0Boolean(bool _value)
{
marker = RTMP_AMF0_Boolean;
value = _value;
marker_ = RTMP_AMF0_Boolean;
value_ = _value;
}
SrsAmf0Boolean::~SrsAmf0Boolean()
@ -1275,24 +1275,24 @@ int SrsAmf0Boolean::total_size()
srs_error_t SrsAmf0Boolean::read(SrsBuffer *stream)
{
return srs_amf0_read_boolean(stream, value);
return srs_amf0_read_boolean(stream, value_);
}
srs_error_t SrsAmf0Boolean::write(SrsBuffer *stream)
{
return srs_amf0_write_boolean(stream, value);
return srs_amf0_write_boolean(stream, value_);
}
SrsAmf0Any *SrsAmf0Boolean::copy()
{
SrsAmf0Boolean *copy = new SrsAmf0Boolean(value);
SrsAmf0Boolean *copy = new SrsAmf0Boolean(value_);
return copy;
}
SrsAmf0Number::SrsAmf0Number(double _value)
{
marker = RTMP_AMF0_Number;
value = _value;
marker_ = RTMP_AMF0_Number;
value_ = _value;
}
SrsAmf0Number::~SrsAmf0Number()
@ -1306,23 +1306,23 @@ int SrsAmf0Number::total_size()
srs_error_t SrsAmf0Number::read(SrsBuffer *stream)
{
return srs_amf0_read_number(stream, value);
return srs_amf0_read_number(stream, value_);
}
srs_error_t SrsAmf0Number::write(SrsBuffer *stream)
{
return srs_amf0_write_number(stream, value);
return srs_amf0_write_number(stream, value_);
}
SrsAmf0Any *SrsAmf0Number::copy()
{
SrsAmf0Number *copy = new SrsAmf0Number(value);
SrsAmf0Number *copy = new SrsAmf0Number(value_);
return copy;
}
SrsAmf0Date::SrsAmf0Date(int64_t value)
{
marker = RTMP_AMF0_Date;
marker_ = RTMP_AMF0_Date;
_date_value = value;
_time_zone = 0;
}
@ -1424,7 +1424,7 @@ int16_t SrsAmf0Date::time_zone()
SrsAmf0Null::SrsAmf0Null()
{
marker = RTMP_AMF0_Null;
marker_ = RTMP_AMF0_Null;
}
SrsAmf0Null::~SrsAmf0Null()
@ -1454,7 +1454,7 @@ SrsAmf0Any *SrsAmf0Null::copy()
SrsAmf0Undefined::SrsAmf0Undefined()
{
marker = RTMP_AMF0_Undefined;
marker_ = RTMP_AMF0_Undefined;
}
SrsAmf0Undefined::~SrsAmf0Undefined()

View File

@ -108,7 +108,7 @@ class SrsAmf0Date;
class SrsAmf0Any
{
public:
char marker;
char marker_;
public:
SrsAmf0Any();
@ -319,8 +319,8 @@ public:
class SrsAmf0Object : public SrsAmf0Any
{
private:
srs_internal::SrsUnSortedHashtable *properties;
srs_internal::SrsAmf0ObjectEOF *eof;
srs_internal::SrsUnSortedHashtable *properties_;
srs_internal::SrsAmf0ObjectEOF *eof_;
private:
friend class SrsAmf0Any;
@ -411,8 +411,8 @@ public:
class SrsAmf0EcmaArray : public SrsAmf0Any
{
private:
srs_internal::SrsUnSortedHashtable *properties;
srs_internal::SrsAmf0ObjectEOF *eof;
srs_internal::SrsUnSortedHashtable *properties_;
srs_internal::SrsAmf0ObjectEOF *eof_;
int32_t _count;
private:
@ -499,7 +499,7 @@ public:
class SrsAmf0StrictArray : public SrsAmf0Any
{
private:
std::vector<SrsAmf0Any *> properties;
std::vector<SrsAmf0Any *> properties_;
int32_t _count;
private:
@ -628,7 +628,7 @@ namespace srs_internal
class SrsAmf0String : public SrsAmf0Any
{
public:
std::string value;
std::string value_;
private:
friend class SrsAmf0Any;
@ -658,7 +658,7 @@ public:
class SrsAmf0Boolean : public SrsAmf0Any
{
public:
bool value;
bool value_;
private:
friend class SrsAmf0Any;
@ -687,7 +687,7 @@ public:
class SrsAmf0Number : public SrsAmf0Any
{
public:
double value;
double value_;
private:
friend class SrsAmf0Any;
@ -807,7 +807,7 @@ class SrsUnSortedHashtable
{
private:
typedef std::pair<std::string, SrsAmf0Any *> SrsAmf0ObjectPropertyType;
std::vector<SrsAmf0ObjectPropertyType> properties;
std::vector<SrsAmf0ObjectPropertyType> properties_;
public:
SrsUnSortedHashtable();

View File

@ -35,22 +35,22 @@ int srs_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
SrsSslClient::SrsSslClient(SrsTcpClient *tcp)
{
transport = tcp;
ssl_ctx = NULL;
ssl = NULL;
transport_ = tcp;
ssl_ctx_ = NULL;
ssl_ = NULL;
}
SrsSslClient::~SrsSslClient()
{
if (ssl) {
// this function will free bio_in and bio_out
SSL_free(ssl);
ssl = NULL;
if (ssl_) {
// this function will free bio_in_ and bio_out_
SSL_free(ssl_);
ssl_ = NULL;
}
if (ssl_ctx) {
SSL_CTX_free(ssl_ctx);
ssl_ctx = NULL;
if (ssl_ctx_) {
SSL_CTX_free(ssl_ctx_);
ssl_ctx_ = NULL;
}
}
@ -62,54 +62,54 @@ srs_error_t SrsSslClient::handshake(const std::string &host)
// For HTTPS, try to connect over security transport.
#if (OPENSSL_VERSION_NUMBER < 0x10002000L) // v1.0.2
ssl_ctx = SSL_CTX_new(TLS_method());
ssl_ctx_ = SSL_CTX_new(TLS_method());
#else
ssl_ctx = SSL_CTX_new(TLSv1_2_method());
ssl_ctx_ = SSL_CTX_new(TLSv1_2_method());
#endif
SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, srs_verify_callback);
srs_assert(SSL_CTX_set_cipher_list(ssl_ctx, "ALL") == 1);
SSL_CTX_set_verify(ssl_ctx_, SSL_VERIFY_PEER, srs_verify_callback);
srs_assert(SSL_CTX_set_cipher_list(ssl_ctx_, "ALL") == 1);
// TODO: Setup callback, see SSL_set_ex_data and SSL_set_info_callback
if ((ssl = SSL_new(ssl_ctx)) == NULL) {
if ((ssl_ = SSL_new(ssl_ctx_)) == NULL) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "SSL_new ssl");
}
if ((bio_in = BIO_new(BIO_s_mem())) == NULL) {
if ((bio_in_ = BIO_new(BIO_s_mem())) == NULL) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "BIO_new in");
}
if ((bio_out = BIO_new(BIO_s_mem())) == NULL) {
BIO_free(bio_in);
if ((bio_out_ = BIO_new(BIO_s_mem())) == NULL) {
BIO_free(bio_in_);
return srs_error_new(ERROR_TLS_HANDSHAKE, "BIO_new out");
}
SSL_set_bio(ssl, bio_in, bio_out);
SSL_set_bio(ssl_, bio_in_, bio_out_);
// SSL setup active, as client role.
SSL_set_connect_state(ssl);
SSL_set_mode(ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
SSL_set_connect_state(ssl_);
SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE);
// If the server address is not in IP address format, set the host in the Server Name Indication (SNI) field.
if (!srs_net_is_valid_ip(host)) {
SSL_set_tlsext_host_name(ssl, host.c_str());
SSL_set_tlsext_host_name(ssl_, host.c_str());
}
// Send ClientHello.
int r0 = SSL_do_handshake(ssl);
int r1 = SSL_get_error(ssl, r0);
int r0 = SSL_do_handshake(ssl_);
int r1 = SSL_get_error(ssl_, r0);
ERR_clear_error();
if (r0 != -1 || r1 != SSL_ERROR_WANT_READ) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "handshake r0=%d, r1=%d", r0, r1);
}
uint8_t *data = NULL;
int size = BIO_get_mem_data(bio_out, &data);
int size = BIO_get_mem_data(bio_out_, &data);
if (!data || size <= 0) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "handshake data=%p, size=%d", data, size);
}
if ((err = transport->write(data, size, NULL)) != srs_success) {
if ((err = transport_->write(data, size, NULL)) != srs_success) {
return srs_error_wrap(err, "handshake: write data=%p, size=%d", data, size);
}
if ((r0 = BIO_reset(bio_out)) != 1) {
if ((r0 = BIO_reset(bio_out_)) != 1) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "BIO_reset r0=%d", r0);
}
@ -119,25 +119,25 @@ srs_error_t SrsSslClient::handshake(const std::string &host)
while (true) {
char buf[512];
ssize_t nn = 0;
if ((err = transport->read(buf, sizeof(buf), &nn)) != srs_success) {
if ((err = transport_->read(buf, sizeof(buf), &nn)) != srs_success) {
return srs_error_wrap(err, "handshake: read");
}
if ((r0 = BIO_write(bio_in, buf, nn)) <= 0) {
if ((r0 = BIO_write(bio_in_, buf, nn)) <= 0) {
// TODO: 0 or -1 maybe block, use BIO_should_retry to check.
return srs_error_new(ERROR_TLS_HANDSHAKE, "BIO_write r0=%d, data=%p, size=%d", r0, buf, nn);
}
r0 = SSL_do_handshake(ssl);
r1 = SSL_get_error(ssl, r0);
r0 = SSL_do_handshake(ssl_);
r1 = SSL_get_error(ssl_, r0);
ERR_clear_error();
if (r0 != -1 || r1 != SSL_ERROR_WANT_READ) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "handshake r0=%d, r1=%d", r0, r1);
}
if ((size = BIO_get_mem_data(bio_out, &data)) > 0) {
if ((size = BIO_get_mem_data(bio_out_, &data)) > 0) {
// OK, reset it for the next write.
if ((r0 = BIO_reset(bio_in)) != 1) {
if ((r0 = BIO_reset(bio_in_)) != 1) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "BIO_reset r0=%d", r0);
}
break;
@ -147,10 +147,10 @@ srs_error_t SrsSslClient::handshake(const std::string &host)
srs_info("tls: ServerHello done");
// Send Client Key Exchange, Change Cipher Spec, Encrypted Handshake Message
if ((err = transport->write(data, size, NULL)) != srs_success) {
if ((err = transport_->write(data, size, NULL)) != srs_success) {
return srs_error_wrap(err, "handshake: write data=%p, size=%d", data, size);
}
if ((r0 = BIO_reset(bio_out)) != 1) {
if ((r0 = BIO_reset(bio_out_)) != 1) {
return srs_error_new(ERROR_TLS_HANDSHAKE, "BIO_reset r0=%d", r0);
}
@ -160,17 +160,17 @@ srs_error_t SrsSslClient::handshake(const std::string &host)
while (true) {
char buf[128];
ssize_t nn = 0;
if ((err = transport->read(buf, sizeof(buf), &nn)) != srs_success) {
if ((err = transport_->read(buf, sizeof(buf), &nn)) != srs_success) {
return srs_error_wrap(err, "handshake: read");
}
if ((r0 = BIO_write(bio_in, buf, nn)) <= 0) {
if ((r0 = BIO_write(bio_in_, buf, nn)) <= 0) {
// TODO: 0 or -1 maybe block, use BIO_should_retry to check.
return srs_error_new(ERROR_TLS_HANDSHAKE, "BIO_write r0=%d, data=%p, size=%d", r0, buf, nn);
}
r0 = SSL_do_handshake(ssl);
r1 = SSL_get_error(ssl, r0);
r0 = SSL_do_handshake(ssl_);
r1 = SSL_get_error(ssl_, r0);
ERR_clear_error();
if (r0 == 1 && r1 == SSL_ERROR_NONE) {
break;
@ -192,11 +192,11 @@ srs_error_t SrsSslClient::read(void *plaintext, size_t nn_plaintext, ssize_t *nr
srs_error_t err = srs_success;
while (true) {
int r0 = SSL_read(ssl, plaintext, nn_plaintext);
int r1 = SSL_get_error(ssl, r0);
int r0 = SSL_read(ssl_, plaintext, nn_plaintext);
int r1 = SSL_get_error(ssl_, r0);
ERR_clear_error();
int r2 = BIO_ctrl_pending(bio_in);
int r3 = SSL_is_init_finished(ssl);
int r2 = BIO_ctrl_pending(bio_in_);
int r3 = SSL_is_init_finished(ssl_);
// OK, got data.
if (r0 > 0) {
@ -215,11 +215,11 @@ srs_error_t SrsSslClient::read(void *plaintext, size_t nn_plaintext, ssize_t *nr
// Read the cipher from SSL.
ssize_t nn = 0;
if ((err = transport->read(cipher.get(), nn_cipher, &nn)) != srs_success) {
if ((err = transport_->read(cipher.get(), nn_cipher, &nn)) != srs_success) {
return srs_error_wrap(err, "https: read");
}
int r0 = BIO_write(bio_in, cipher.get(), nn);
int r0 = BIO_write(bio_in_, cipher.get(), nn);
if (r0 <= 0) {
// TODO: 0 or -1 maybe block, use BIO_should_retry to check.
return srs_error_new(ERROR_TLS_READ, "BIO_write r0=%d, cipher=%p, size=%d", r0, cipher.get(), nn);
@ -241,8 +241,8 @@ srs_error_t SrsSslClient::write(void *plaintext, size_t nn_plaintext, ssize_t *n
for (char *p = (char *)plaintext; p < (char *)plaintext + nn_plaintext;) {
int left = (int)nn_plaintext - (p - (char *)plaintext);
int r0 = SSL_write(ssl, (const void *)p, left);
int r1 = SSL_get_error(ssl, r0);
int r0 = SSL_write(ssl_, (const void *)p, left);
int r1 = SSL_get_error(ssl_, r0);
ERR_clear_error();
if (r0 <= 0) {
return srs_error_new(ERROR_TLS_WRITE, "tls: write data=%p, size=%d, r0=%d, r1=%d", p, left, r0, r1);
@ -255,11 +255,11 @@ srs_error_t SrsSslClient::write(void *plaintext, size_t nn_plaintext, ssize_t *n
}
uint8_t *data = NULL;
int size = BIO_get_mem_data(bio_out, &data);
if ((err = transport->write(data, size, NULL)) != srs_success) {
int size = BIO_get_mem_data(bio_out_, &data);
if ((err = transport_->write(data, size, NULL)) != srs_success) {
return srs_error_wrap(err, "tls: write data=%p, size=%d", data, size);
}
if ((r0 = BIO_reset(bio_out)) != 1) {
if ((r0 = BIO_reset(bio_out_)) != 1) {
return srs_error_new(ERROR_TLS_WRITE, "BIO_reset r0=%d", r0);
}
}
@ -269,58 +269,58 @@ srs_error_t SrsSslClient::write(void *plaintext, size_t nn_plaintext, ssize_t *n
SrsHttpClient::SrsHttpClient()
{
transport = NULL;
ssl_transport = NULL;
kbps = new SrsNetworkKbps();
parser = NULL;
recv_timeout = timeout = SRS_UTIME_NO_TIMEOUT;
port = 0;
transport_ = NULL;
ssl_transport_ = NULL;
kbps_ = new SrsNetworkKbps();
parser_ = NULL;
recv_timeout_ = timeout_ = SRS_UTIME_NO_TIMEOUT;
port_ = 0;
}
SrsHttpClient::~SrsHttpClient()
{
disconnect();
srs_freep(kbps);
srs_freep(parser);
srs_freep(kbps_);
srs_freep(parser_);
}
srs_error_t SrsHttpClient::initialize(string schema, string h, int p, srs_utime_t tm)
{
srs_error_t err = srs_success;
srs_freep(parser);
parser = new SrsHttpParser();
srs_freep(parser_);
parser_ = new SrsHttpParser();
if ((err = parser->initialize(HTTP_RESPONSE)) != srs_success) {
if ((err = parser_->initialize(HTTP_RESPONSE)) != srs_success) {
return srs_error_wrap(err, "http: init parser");
}
// Always disconnect the transport.
schema_ = schema;
host = h;
port = p;
recv_timeout = timeout = tm;
host_ = h;
port_ = p;
recv_timeout_ = timeout_ = tm;
disconnect();
// ep used for host in header.
string ep = host;
if (port > 0 && port != SRS_CONSTS_HTTP_DEFAULT_PORT) {
ep += ":" + srs_strconv_format_int(port);
string ep = host_;
if (port_ > 0 && port_ != SRS_CONSTS_HTTP_DEFAULT_PORT) {
ep += ":" + srs_strconv_format_int(port_);
}
// Set default value for headers.
headers["Host"] = ep;
headers["Connection"] = "Keep-Alive";
headers["User-Agent"] = RTMP_SIG_SRS_SERVER;
headers["Content-Type"] = "application/json";
headers_["Host"] = ep;
headers_["Connection"] = "Keep-Alive";
headers_["User-Agent"] = RTMP_SIG_SRS_SERVER;
headers_["Content-Type"] = "application/json";
return err;
}
SrsHttpClient *SrsHttpClient::set_header(string k, string v)
{
headers[k] = v;
headers_[k] = v;
return this;
}
@ -332,7 +332,7 @@ srs_error_t SrsHttpClient::post(string path, string req, ISrsHttpMessage **ppmsg
srs_error_t err = srs_success;
// always set the content length.
headers["Content-Length"] = srs_strconv_format_int(req.length());
headers_["Content-Length"] = srs_strconv_format_int(req.length());
if ((err = connect()) != srs_success) {
return srs_error_wrap(err, "http: connect server");
@ -342,12 +342,12 @@ srs_error_t SrsHttpClient::post(string path, string req, ISrsHttpMessage **ppmsg
path = "/";
}
// TODO: FIXME: Use SrsHttpMessageWriter, never use stringstream and headers.
// TODO: FIXME: Use SrsHttpMessageWriter, never use stringstream and headers_.
// send POST request to uri
// POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s
std::stringstream ss;
ss << "POST " << path << " " << "HTTP/1.1" << SRS_HTTP_CRLF;
for (map<string, string>::iterator it = headers.begin(); it != headers.end(); ++it) {
for (map<string, string>::iterator it = headers_.begin(); it != headers_.end(); ++it) {
string key = it->first;
string value = it->second;
ss << key << ": " << value << SRS_HTTP_CRLF;
@ -362,7 +362,7 @@ srs_error_t SrsHttpClient::post(string path, string req, ISrsHttpMessage **ppmsg
}
ISrsHttpMessage *msg = NULL;
if ((err = parser->parse_message(reader(), &msg)) != srs_success) {
if ((err = parser_->parse_message(reader(), &msg)) != srs_success) {
return srs_error_wrap(err, "http: parse response");
}
srs_assert(msg);
@ -383,7 +383,7 @@ srs_error_t SrsHttpClient::get(string path, string req, ISrsHttpMessage **ppmsg)
srs_error_t err = srs_success;
// always set the content length.
headers["Content-Length"] = srs_strconv_format_int(req.length());
headers_["Content-Length"] = srs_strconv_format_int(req.length());
if ((err = connect()) != srs_success) {
return srs_error_wrap(err, "http: connect server");
@ -393,7 +393,7 @@ srs_error_t SrsHttpClient::get(string path, string req, ISrsHttpMessage **ppmsg)
// GET %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s
std::stringstream ss;
ss << "GET " << path << " " << "HTTP/1.1" << SRS_HTTP_CRLF;
for (map<string, string>::iterator it = headers.begin(); it != headers.end(); ++it) {
for (map<string, string>::iterator it = headers_.begin(); it != headers_.end(); ++it) {
string key = it->first;
string value = it->second;
ss << key << ": " << value << SRS_HTTP_CRLF;
@ -408,7 +408,7 @@ srs_error_t SrsHttpClient::get(string path, string req, ISrsHttpMessage **ppmsg)
}
ISrsHttpMessage *msg = NULL;
if ((err = parser->parse_message(reader(), &msg)) != srs_success) {
if ((err = parser_->parse_message(reader(), &msg)) != srs_success) {
return srs_error_wrap(err, "http: parse response");
}
srs_assert(msg);
@ -424,28 +424,28 @@ srs_error_t SrsHttpClient::get(string path, string req, ISrsHttpMessage **ppmsg)
void SrsHttpClient::set_recv_timeout(srs_utime_t tm)
{
recv_timeout = tm;
recv_timeout_ = tm;
}
void SrsHttpClient::kbps_sample(const char *label, srs_utime_t age)
{
kbps->sample();
kbps_->sample();
int sr = kbps->get_send_kbps();
int sr30s = kbps->get_send_kbps_30s();
int sr5m = kbps->get_send_kbps_5m();
int rr = kbps->get_recv_kbps();
int rr30s = kbps->get_recv_kbps_30s();
int rr5m = kbps->get_recv_kbps_5m();
int sr = kbps_->get_send_kbps();
int sr30s = kbps_->get_send_kbps_30s();
int sr5m = kbps_->get_send_kbps_5m();
int rr = kbps_->get_recv_kbps();
int rr30s = kbps_->get_recv_kbps_30s();
int rr5m = kbps_->get_recv_kbps_5m();
srs_trace("<- %s time=%" PRId64 ", okbps=%d,%d,%d, ikbps=%d,%d,%d", label, srsu2ms(age), sr, sr30s, sr5m, rr, rr30s, rr5m);
}
void SrsHttpClient::disconnect()
{
kbps->set_io(NULL, NULL);
srs_freep(ssl_transport);
srs_freep(transport);
kbps_->set_io(NULL, NULL);
srs_freep(ssl_transport_);
srs_freep(transport_);
}
srs_error_t SrsHttpClient::connect()
@ -453,22 +453,22 @@ srs_error_t SrsHttpClient::connect()
srs_error_t err = srs_success;
// When transport connected, ignore.
if (transport) {
if (transport_) {
return err;
}
transport = new SrsTcpClient(host, port, timeout);
if ((err = transport->connect()) != srs_success) {
transport_ = new SrsTcpClient(host_, port_, timeout_);
if ((err = transport_->connect()) != srs_success) {
disconnect();
return srs_error_wrap(err, "http: tcp connect %s %s:%d to=%dms, rto=%dms",
schema_.c_str(), host.c_str(), port, srsu2msi(timeout), srsu2msi(recv_timeout));
schema_.c_str(), host_.c_str(), port_, srsu2msi(timeout_), srsu2msi(recv_timeout_));
}
// Set the recv/send timeout in srs_utime_t.
transport->set_recv_timeout(recv_timeout);
transport->set_send_timeout(timeout);
transport_->set_recv_timeout(recv_timeout_);
transport_->set_send_timeout(timeout_);
kbps->set_io(transport, transport);
kbps_->set_io(transport_, transport_);
if (schema_ != "https") {
return err;
@ -477,19 +477,19 @@ srs_error_t SrsHttpClient::connect()
#if !defined(SRS_HTTPS)
return srs_error_new(ERROR_HTTPS_NOT_SUPPORTED, "should configure with --https=on");
#else
srs_assert(!ssl_transport);
ssl_transport = new SrsSslClient(transport);
srs_assert(!ssl_transport_);
ssl_transport_ = new SrsSslClient(transport_);
srs_utime_t starttime = srs_time_now_realtime();
if ((err = ssl_transport->handshake(host)) != srs_success) {
if ((err = ssl_transport_->handshake(host_)) != srs_success) {
disconnect();
return srs_error_wrap(err, "http: ssl connect %s %s:%d to=%dms, rto=%dms",
schema_.c_str(), host.c_str(), port, srsu2msi(timeout), srsu2msi(recv_timeout));
schema_.c_str(), host_.c_str(), port_, srsu2msi(timeout_), srsu2msi(recv_timeout_));
}
int cost = srsu2msi(srs_time_now_realtime() - starttime);
srs_trace("https: connected to %s://%s:%d, cost=%dms", schema_.c_str(), host.c_str(), port, cost);
srs_trace("https: connected to %s://%s:%d, cost=%dms", schema_.c_str(), host_.c_str(), port_, cost);
return err;
#endif
@ -497,16 +497,16 @@ srs_error_t SrsHttpClient::connect()
ISrsStreamWriter *SrsHttpClient::writer()
{
if (ssl_transport) {
return ssl_transport;
if (ssl_transport_) {
return ssl_transport_;
}
return transport;
return transport_;
}
ISrsReader *SrsHttpClient::reader()
{
if (ssl_transport) {
return ssl_transport;
if (ssl_transport_) {
return ssl_transport_;
}
return transport;
return transport_;
}

View File

@ -33,13 +33,13 @@ class SrsTcpClient;
class SrsSslClient : public ISrsReader, public ISrsStreamWriter
{
private:
SrsTcpClient *transport;
SrsTcpClient *transport_;
private:
SSL_CTX *ssl_ctx;
SSL *ssl;
BIO *bio_in;
BIO *bio_out;
SSL_CTX *ssl_ctx_;
SSL *ssl_;
BIO *bio_in_;
BIO *bio_out_;
public:
SrsSslClient(SrsTcpClient *tcp);
@ -65,22 +65,22 @@ class SrsHttpClient
private:
// The underlayer TCP transport, set to NULL when disconnect, or never not NULL when connected.
// We will disconnect transport when initialize or channel error, such as send/recv error.
SrsTcpClient *transport;
SrsHttpParser *parser;
std::map<std::string, std::string> headers;
SrsNetworkKbps *kbps;
SrsTcpClient *transport_;
SrsHttpParser *parser_;
std::map<std::string, std::string> headers_;
SrsNetworkKbps *kbps_;
private:
// The timeout in srs_utime_t.
srs_utime_t timeout;
srs_utime_t recv_timeout;
srs_utime_t timeout_;
srs_utime_t recv_timeout_;
// The schema, host name or ip.
std::string schema_;
std::string host;
int port;
std::string host_;
int port_;
private:
SrsSslClient *ssl_transport;
SrsSslClient *ssl_transport_;
public:
SrsHttpClient();

View File

@ -22,8 +22,8 @@ using namespace std;
SrsHttpParser::SrsHttpParser()
{
buffer = new SrsFastStream();
header = NULL;
buffer_ = new SrsFastStream();
header_ = NULL;
type_ = HTTP_REQUEST;
parsed_type_ = HTTP_BOTH;
@ -31,37 +31,37 @@ SrsHttpParser::SrsHttpParser()
SrsHttpParser::~SrsHttpParser()
{
srs_freep(buffer);
srs_freep(header);
srs_freep(buffer_);
srs_freep(header_);
}
srs_error_t SrsHttpParser::initialize(enum llhttp_type type)
{
srs_error_t err = srs_success;
jsonp = false;
jsonp_ = false;
type_ = type;
// Initialize the settings first
llhttp_settings_init(&settings);
settings.on_message_begin = on_message_begin;
settings.on_url = on_url;
settings.on_header_field = on_header_field;
settings.on_header_value = on_header_value;
settings.on_headers_complete = on_headers_complete;
settings.on_body = on_body;
settings.on_message_complete = on_message_complete;
llhttp_settings_init(&settings_);
settings_.on_message_begin = on_message_begin;
settings_.on_url = on_url;
settings_.on_header_field = on_header_field;
settings_.on_header_value = on_header_value;
settings_.on_headers_complete = on_headers_complete;
settings_.on_body = on_body;
settings_.on_message_complete = on_message_complete;
// Initialize the parser with settings
llhttp_init(&parser, type_, &settings);
parser.data = (void *)this;
llhttp_init(&parser_, type_, &settings_);
parser_.data = (void *)this;
return err;
}
void SrsHttpParser::set_jsonp(bool allow_jsonp)
{
jsonp = allow_jsonp;
jsonp_ = allow_jsonp;
}
srs_error_t SrsHttpParser::parse_message(ISrsReader *reader, ISrsHttpMessage **ppmsg)
@ -71,15 +71,15 @@ srs_error_t SrsHttpParser::parse_message(ISrsReader *reader, ISrsHttpMessage **p
*ppmsg = NULL;
// Reset parser data and state.
state = SrsHttpParseStateInit;
memset(&hp_header, 0, sizeof(llhttp_t));
state_ = SrsHttpParseStateInit;
memset(&hp_header_, 0, sizeof(llhttp_t));
// We must reset the field name and value, because we may get a partial value in on_header_value.
field_name = field_value = "";
field_name_ = field_value_ = "";
// Reset the url.
url = "";
url_ = "";
// The header of the request.
srs_freep(header);
header = new SrsHttpHeader();
srs_freep(header_);
header_ = new SrsHttpHeader();
// Reset parser for each message.
// If the request is large, such as the fifth message at @utest ProtocolHTTPTest.ParsingLargeMessages,
@ -90,14 +90,14 @@ srs_error_t SrsHttpParser::parse_message(ISrsReader *reader, ISrsHttpMessage **p
// when got next message, the whole next message is parsed as the body of previous one,
// and the message fail.
// @note You can comment the bellow line, the utest will fail.
llhttp_reset(&parser);
llhttp_reset(&parser_);
// Reset the parsed type.
parsed_type_ = HTTP_BOTH;
// callback object ptr.
parser.data = (void *)this;
parser_.data = (void *)this;
// Always skip body, because we only want to parse the header.
parser.flags |= F_SKIPBODY;
parser_.flags |= F_SKIPBODY;
// do parse
if ((err = parse_message_imp(reader)) != srs_success) {
@ -105,15 +105,15 @@ srs_error_t SrsHttpParser::parse_message(ISrsReader *reader, ISrsHttpMessage **p
}
// create msg
SrsHttpMessage *msg = new SrsHttpMessage(reader, buffer);
SrsHttpMessage *msg = new SrsHttpMessage(reader, buffer_);
// Initialize the basic information.
msg->set_basic(hp_header.type, (llhttp_method_t)hp_header.method, (llhttp_status_t)hp_header.status_code, hp_header.content_length);
msg->set_header(header, llhttp_should_keep_alive(&hp_header));
msg->set_basic(hp_header_.type, (llhttp_method_t)hp_header_.method, (llhttp_status_t)hp_header_.status_code, hp_header_.content_length);
msg->set_header(header_, llhttp_should_keep_alive(&hp_header_));
// For HTTP response, no url.
if (parsed_type_ != HTTP_RESPONSE && (err = msg->set_url(url, jsonp)) != srs_success) {
if (parsed_type_ != HTTP_RESPONSE && (err = msg->set_url(url_, jsonp_)) != srs_success) {
srs_freep(msg);
return srs_error_wrap(err, "set url=%s, jsonp=%d", url.c_str(), jsonp);
return srs_error_wrap(err, "set url=%s, jsonp=%d", url_.c_str(), jsonp_);
}
// parse ok, return the msg.
@ -127,17 +127,17 @@ srs_error_t SrsHttpParser::parse_message_imp(ISrsReader *reader)
srs_error_t err = srs_success;
while (true) {
if (buffer->size() > 0) {
const char *data_start = buffer->bytes();
llhttp_errno_t code = llhttp_execute(&parser, data_start, buffer->size());
if (buffer_->size() > 0) {
const char *data_start = buffer_->bytes();
llhttp_errno_t code = llhttp_execute(&parser_, data_start, buffer_->size());
ssize_t consumed = 0;
if (code == HPE_OK) {
// No problem, all buffer should be consumed.
consumed = buffer->size();
consumed = buffer_->size();
} else if (code == HPE_PAUSED) {
// We only consume the header, not message or body.
const char *error_pos = llhttp_get_error_pos(&parser);
const char *error_pos = llhttp_get_error_pos(&parser_);
if (error_pos && error_pos < data_start) {
return srs_error_new(ERROR_HTTP_PARSE_HEADER, "llhttp error_pos=%p < data_start=%p", error_pos, data_start);
}
@ -152,33 +152,33 @@ srs_error_t SrsHttpParser::parse_message_imp(ISrsReader *reader)
// HPE_PAUSED: we use to skip body
if (code != HPE_OK && code != HPE_PAUSED) {
return srs_error_new(ERROR_HTTP_PARSE_HEADER, "parse %dB, nparsed=%d, err=%d/%s %s",
buffer->size(), (int)consumed, code, llhttp_errno_name(code),
llhttp_get_error_reason(&parser) ? llhttp_get_error_reason(&parser) : "");
buffer_->size(), (int)consumed, code, llhttp_errno_name(code),
llhttp_get_error_reason(&parser_) ? llhttp_get_error_reason(&parser_) : "");
}
srs_info("size=%d, nparsed=%d", buffer->size(), (int)consumed);
srs_info("size=%d, nparsed=%d", buffer_->size(), (int)consumed);
// Only consume the header bytes.
if (consumed > 0) {
buffer->read_slice(consumed);
buffer_->read_slice(consumed);
}
// Done when header completed, never wait for body completed, because it maybe chunked.
if (state >= SrsHttpParseStateHeaderComplete) {
if (state_ >= SrsHttpParseStateHeaderComplete) {
break;
}
}
// when nothing parsed, read more to parse.
// when requires more, only grow 1bytes, but the buffer will cache more.
if ((err = buffer->grow(reader, buffer->size() + 1)) != srs_success) {
if ((err = buffer_->grow(reader, buffer_->size() + 1)) != srs_success) {
return srs_error_wrap(err, "grow buffer");
}
}
SrsHttpParser *obj = this;
if (!obj->field_value.empty()) {
obj->header->set(obj->field_name, obj->field_value);
if (!obj->field_value_.empty()) {
obj->header_->set(obj->field_name_, obj->field_value_);
}
return err;
@ -190,7 +190,7 @@ int SrsHttpParser::on_message_begin(llhttp_t *parser)
srs_assert(obj);
// Now, we start to parse HTTP message.
obj->state = SrsHttpParseStateStart;
obj->state_ = SrsHttpParseStateStart;
// If we set to HTTP_BOTH, the type is detected and speicifed by parser.
obj->parsed_type_ = (llhttp_type)parser->type;
@ -205,9 +205,9 @@ int SrsHttpParser::on_headers_complete(llhttp_t *parser)
SrsHttpParser *obj = (SrsHttpParser *)parser->data;
srs_assert(obj);
obj->hp_header = *parser;
obj->hp_header_ = *parser;
// save the parser when header parse completed.
obj->state = SrsHttpParseStateHeaderComplete;
obj->state_ = SrsHttpParseStateHeaderComplete;
srs_info("***HEADERS COMPLETE***");
@ -227,7 +227,7 @@ int SrsHttpParser::on_message_complete(llhttp_t *parser)
srs_assert(obj);
// Note that we should never get here, because we always return HPE_PAUSED in on_headers_complete.
obj->state = SrsHttpParseStateMessageComplete;
obj->state_ = SrsHttpParseStateMessageComplete;
srs_info("***MESSAGE COMPLETE***\n");
@ -241,7 +241,7 @@ int SrsHttpParser::on_url(llhttp_t *parser, const char *at, size_t length)
if (length > 0) {
// Note that this function might be called for multiple times, and we got pieces of content.
obj->url.append(at, (int)length);
obj->url_.append(at, (int)length);
}
srs_info("Method: %d, Url: %.*s", parser->method, (int)length, at);
@ -254,13 +254,13 @@ int SrsHttpParser::on_header_field(llhttp_t *parser, const char *at, size_t leng
SrsHttpParser *obj = (SrsHttpParser *)parser->data;
srs_assert(obj);
if (!obj->field_value.empty()) {
obj->header->set(obj->field_name, obj->field_value);
obj->field_name = obj->field_value = "";
if (!obj->field_value_.empty()) {
obj->header_->set(obj->field_name_, obj->field_value_);
obj->field_name_ = obj->field_value_ = "";
}
if (length > 0) {
obj->field_name.append(at, (int)length);
obj->field_name_.append(at, (int)length);
}
srs_info("Header field(%d bytes): %.*s", (int)length, (int)length, at);
@ -273,7 +273,7 @@ int SrsHttpParser::on_header_value(llhttp_t *parser, const char *at, size_t leng
srs_assert(obj);
if (length > 0) {
obj->field_value.append(at, (int)length);
obj->field_value_.append(at, (int)length);
}
srs_info("Header value(%d bytes): %.*s", (int)length, (int)length, at);
@ -286,7 +286,7 @@ int SrsHttpParser::on_body(llhttp_t *parser, const char *at, size_t length)
srs_assert(obj);
// save the parser when body parsed.
obj->state = SrsHttpParseStateBody;
obj->state_ = SrsHttpParseStateBody;
srs_info("Body: %.*s", (int)length, at);
@ -295,12 +295,12 @@ int SrsHttpParser::on_body(llhttp_t *parser, const char *at, size_t length)
SrsHttpMessage::SrsHttpMessage(ISrsReader *reader, SrsFastStream *buffer) : ISrsHttpMessage()
{
owner_conn = NULL;
chunked = false;
owner_conn_ = NULL;
chunked_ = false;
_uri = new SrsHttpUri();
_body = new SrsHttpResponseReader(this, reader, buffer);
jsonp = false;
jsonp_ = false;
// As 0 is DELETE, so we use GET as default.
_method = (llhttp_method_t)SRS_CONSTS_HTTP_GET;
@ -340,7 +340,7 @@ void SrsHttpMessage::set_header(SrsHttpHeader *header, bool keep_alive)
_keep_alive = keep_alive;
// whether chunked.
chunked = (header->get("Transfer-Encoding") == "chunked");
chunked_ = (header->get("Transfer-Encoding") == "chunked");
// Update the content-length in header.
string clv = header->get("Content-Length");
@ -350,7 +350,7 @@ void SrsHttpMessage::set_header(SrsHttpHeader *header, bool keep_alive)
// If no size(content-length or chunked), it's infinite chunked,
// it means there is no body, so we must close the body reader.
if (!chunked && _content_length == -1) {
if (!chunked_ && _content_length == -1) {
// The infinite chunked is only enabled for HTTP_RESPONSE, so we close the body for request.
if (type_ == HTTP_REQUEST) {
_body->close();
@ -414,10 +414,10 @@ srs_error_t SrsHttpMessage::set_url(string url, bool allow_jsonp)
// parse jsonp request message.
if (allow_jsonp) {
string callback = query_get("callback");
jsonp = !callback.empty();
jsonp_ = !callback.empty();
if (jsonp) {
jsonp_method = query_get("method");
if (jsonp_) {
jsonp_method_ = query_get("method");
}
if (!srs_is_valid_jsonp_callback(callback)) {
@ -436,12 +436,12 @@ void SrsHttpMessage::set_https(bool v)
ISrsConnection *SrsHttpMessage::connection()
{
return owner_conn;
return owner_conn_;
}
void SrsHttpMessage::set_connection(ISrsConnection *conn)
{
owner_conn = conn;
owner_conn_ = conn;
}
string SrsHttpMessage::schema()
@ -456,14 +456,14 @@ uint8_t SrsHttpMessage::message_type()
uint8_t SrsHttpMessage::method()
{
if (jsonp && !jsonp_method.empty()) {
if (jsonp_method == "GET") {
if (jsonp_ && !jsonp_method_.empty()) {
if (jsonp_method_ == "GET") {
return SRS_CONSTS_HTTP_GET;
} else if (jsonp_method == "PUT") {
} else if (jsonp_method_ == "PUT") {
return SRS_CONSTS_HTTP_PUT;
} else if (jsonp_method == "POST") {
} else if (jsonp_method_ == "POST") {
return SRS_CONSTS_HTTP_POST;
} else if (jsonp_method == "DELETE") {
} else if (jsonp_method_ == "DELETE") {
return SRS_CONSTS_HTTP_DELETE;
}
}
@ -478,8 +478,8 @@ uint16_t SrsHttpMessage::status_code()
string SrsHttpMessage::method_str()
{
if (jsonp && !jsonp_method.empty()) {
return jsonp_method;
if (jsonp_ && !jsonp_method_.empty()) {
return jsonp_method_;
}
return llhttp_method_name((llhttp_method_t)_method);
@ -512,7 +512,7 @@ bool SrsHttpMessage::is_http_options()
bool SrsHttpMessage::is_chunked()
{
return chunked;
return chunked_;
}
bool SrsHttpMessage::is_keep_alive()
@ -627,52 +627,52 @@ ISrsRequest *SrsHttpMessage::to_request(string vhost)
// http path, for instance, /live/livestream.flv, parse to
// app: /live
// stream: livestream.flv
srs_net_url_parse_rtmp_url(_uri->get_path(), req->app, req->stream);
srs_net_url_parse_rtmp_url(_uri->get_path(), req->app_, req->stream_);
// trim the start slash, for instance, /live to live
req->app = srs_strings_trim_start(req->app, "/");
req->app_ = srs_strings_trim_start(req->app_, "/");
// remove the extension, for instance, livestream.flv to livestream
req->stream = srs_path_filepath_filename(req->stream);
req->stream_ = srs_path_filepath_filename(req->stream_);
// generate others.
req->tcUrl = "rtmp://" + vhost + "/" + req->app;
req->pageUrl = _header.get("Referer");
req->objectEncoding = 0;
req->tcUrl_ = "rtmp://" + vhost + "/" + req->app_;
req->pageUrl_ = _header.get("Referer");
req->objectEncoding_ = 0;
std::string query = _uri->get_query();
if (!query.empty()) {
req->param = "?" + query;
req->param_ = "?" + query;
}
srs_net_url_parse_tcurl(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param);
srs_net_url_parse_tcurl(req->tcUrl_, req->schema_, req->host_, req->vhost_, req->app_, req->stream_, req->port_, req->param_);
req->strip();
// reset the host to http request host.
if (req->host == SRS_CONSTS_RTMP_DEFAULT_VHOST) {
req->host = _uri->get_host();
if (req->host_ == SRS_CONSTS_RTMP_DEFAULT_VHOST) {
req->host_ = _uri->get_host();
}
// Set ip by remote ip of connection.
if (owner_conn) {
req->ip = owner_conn->remote_ip();
if (owner_conn_) {
req->ip_ = owner_conn_->remote_ip();
}
// Overwrite by ip from proxy.
string oip = srs_get_original_ip(this);
if (!oip.empty()) {
req->ip = oip;
req->ip_ = oip;
}
// The request streaming protocol.
req->protocol = (schema_ == "http") ? "flv" : "flvs";
req->protocol_ = (schema_ == "http") ? "flv" : "flvs";
return req;
}
bool SrsHttpMessage::is_jsonp()
{
return jsonp;
return jsonp_;
}
ISrsHttpHeaderFilter::ISrsHttpHeaderFilter()
@ -693,22 +693,22 @@ ISrsHttpFirstLineWriter::~ISrsHttpFirstLineWriter()
SrsHttpMessageWriter::SrsHttpMessageWriter(ISrsProtocolReadWriter *io, ISrsHttpFirstLineWriter *flw)
{
skt = io;
hdr = new SrsHttpHeader();
skt_ = io;
hdr_ = new SrsHttpHeader();
header_wrote_ = false;
content_length = -1;
written = 0;
header_sent = false;
nb_iovss_cache = 0;
iovss_cache = NULL;
content_length_ = -1;
written_ = 0;
header_sent_ = false;
nb_iovss_cache_ = 0;
iovss_cache_ = NULL;
hf_ = NULL;
flw_ = flw;
}
SrsHttpMessageWriter::~SrsHttpMessageWriter()
{
srs_freep(hdr);
srs_freepa(iovss_cache);
srs_freep(hdr_);
srs_freepa(iovss_cache_);
}
srs_error_t SrsHttpMessageWriter::final_request()
@ -726,11 +726,11 @@ srs_error_t SrsHttpMessageWriter::final_request()
}
// complete the chunked encoding.
if (content_length == -1) {
if (content_length_ == -1) {
std::stringstream ss;
ss << 0 << SRS_HTTP_CRLF << SRS_HTTP_CRLF;
std::string ch = ss.str();
return skt->write((void *)ch.data(), (int)ch.length(), NULL);
return skt_->write((void *)ch.data(), (int)ch.length(), NULL);
}
// flush when send with content length
@ -739,7 +739,7 @@ srs_error_t SrsHttpMessageWriter::final_request()
SrsHttpHeader *SrsHttpMessageWriter::header()
{
return hdr;
return hdr_;
}
srs_error_t SrsHttpMessageWriter::write(char *data, int size)
@ -748,11 +748,11 @@ srs_error_t SrsHttpMessageWriter::write(char *data, int size)
// write the header data in memory.
if (!header_wrote_) {
if (hdr->content_type().empty()) {
hdr->set_content_type("text/plain; charset=utf-8");
if (hdr_->content_type().empty()) {
hdr_->set_content_type("text/plain; charset=utf-8");
}
if (hdr->content_length() == -1) {
hdr->set_content_length(size);
if (hdr_->content_length() == -1) {
hdr_->set_content_length(size);
}
flw_->write_default_header();
}
@ -763,9 +763,9 @@ srs_error_t SrsHttpMessageWriter::write(char *data, int size)
}
// check the bytes send and content length.
written += size;
if (content_length != -1 && written > content_length) {
return srs_error_new(ERROR_HTTP_CONTENT_LENGTH, "overflow writen=%" PRId64 ", max=%" PRId64, written, content_length);
written_ += size;
if (content_length_ != -1 && written_ > content_length_) {
return srs_error_new(ERROR_HTTP_CONTENT_LENGTH, "overflow writen=%" PRId64 ", max=%" PRId64, written_, content_length_);
}
// ignore NULL content.
@ -774,18 +774,18 @@ srs_error_t SrsHttpMessageWriter::write(char *data, int size)
}
// directly send with content length
if (content_length != -1) {
return skt->write((void *)data, size, NULL);
if (content_length_ != -1) {
return skt_->write((void *)data, size, NULL);
}
// send in chunked encoding.
int nb_size = snprintf(header_cache, SRS_HTTP_HEADER_CACHE_SIZE, "%x", size);
int nb_size = snprintf(header_cache_, SRS_HTTP_HEADER_CACHE_SIZE, "%x", size);
if (nb_size <= 0 || nb_size >= SRS_HTTP_HEADER_CACHE_SIZE) {
return srs_error_new(ERROR_HTTP_CONTENT_LENGTH, "overflow size=%d, expect=%d", size, nb_size);
}
iovec iovs[4];
iovs[0].iov_base = (char *)header_cache;
iovs[0].iov_base = (char *)header_cache_;
iovs[0].iov_len = (int)nb_size;
iovs[1].iov_base = (char *)SRS_HTTP_CRLF;
iovs[1].iov_len = 2;
@ -795,7 +795,7 @@ srs_error_t SrsHttpMessageWriter::write(char *data, int size)
iovs[3].iov_len = 2;
ssize_t nwrite = 0;
if ((err = skt->writev(iovs, 4, &nwrite)) != srs_success) {
if ((err = skt_->writev(iovs, 4, &nwrite)) != srs_success) {
return srs_error_wrap(err, "write chunk");
}
@ -807,7 +807,7 @@ srs_error_t SrsHttpMessageWriter::writev(const iovec *iov, int iovcnt, ssize_t *
srs_error_t err = srs_success;
// when header not ready, or not chunked, send one by one.
if (!header_wrote_ || content_length != -1) {
if (!header_wrote_ || content_length_ != -1) {
ssize_t nwrite = 0;
for (int i = 0; i < iovcnt; i++) {
nwrite += iov[i].iov_len;
@ -835,11 +835,11 @@ srs_error_t SrsHttpMessageWriter::writev(const iovec *iov, int iovcnt, ssize_t *
// send in chunked encoding.
int nb_iovss = 3 + iovcnt;
iovec *iovss = iovss_cache;
if (nb_iovss_cache < nb_iovss) {
srs_freepa(iovss_cache);
nb_iovss_cache = nb_iovss;
iovss = iovss_cache = new iovec[nb_iovss];
iovec *iovss = iovss_cache_;
if (nb_iovss_cache_ < nb_iovss) {
srs_freepa(iovss_cache_);
nb_iovss_cache_ = nb_iovss;
iovss = iovss_cache_ = new iovec[nb_iovss];
}
// Send all iovs in one chunk, the size is the total size of iovs.
@ -848,14 +848,14 @@ srs_error_t SrsHttpMessageWriter::writev(const iovec *iov, int iovcnt, ssize_t *
const iovec *data_iov = iov + i;
size += data_iov->iov_len;
}
written += size;
written_ += size;
// chunk header
int nb_size = snprintf(header_cache, SRS_HTTP_HEADER_CACHE_SIZE, "%x", size);
int nb_size = snprintf(header_cache_, SRS_HTTP_HEADER_CACHE_SIZE, "%x", size);
if (nb_size <= 0 || nb_size >= SRS_HTTP_HEADER_CACHE_SIZE) {
return srs_error_new(ERROR_HTTP_CONTENT_LENGTH, "overflow size=%d, expect=%d", size, nb_size);
}
iovss[0].iov_base = (char *)header_cache;
iovss[0].iov_base = (char *)header_cache_;
iovss[0].iov_len = (int)nb_size;
// chunk header eof.
@ -874,7 +874,7 @@ srs_error_t SrsHttpMessageWriter::writev(const iovec *iov, int iovcnt, ssize_t *
// sendout all ioves.
ssize_t nwrite = 0;
if ((err = srs_write_large_iovs(skt, iovss, nb_iovss, &nwrite)) != srs_success) {
if ((err = srs_write_large_iovs(skt_, iovss, nb_iovss, &nwrite)) != srs_success) {
return srs_error_wrap(err, "writev large iovs");
}
@ -892,17 +892,17 @@ void SrsHttpMessageWriter::write_header()
header_wrote_ = true;
// parse the content length from header.
content_length = hdr->content_length();
content_length_ = hdr_->content_length();
}
srs_error_t SrsHttpMessageWriter::send_header(char *data, int size)
{
srs_error_t err = srs_success;
if (header_sent) {
if (header_sent_) {
return err;
}
header_sent = true;
header_sent_ = true;
std::stringstream ss;
@ -912,33 +912,33 @@ srs_error_t SrsHttpMessageWriter::send_header(char *data, int size)
}
// set server if not set.
if (hdr->get("Server").empty()) {
hdr->set("Server", RTMP_SIG_SRS_SERVER);
if (hdr_->get("Server").empty()) {
hdr_->set("Server", RTMP_SIG_SRS_SERVER);
}
// chunked encoding
if (content_length == -1) {
hdr->set("Transfer-Encoding", "chunked");
if (content_length_ == -1) {
hdr_->set("Transfer-Encoding", "chunked");
}
// keep alive to make vlc happy.
if (hdr->get("Connection").empty()) {
hdr->set("Connection", "Keep-Alive");
if (hdr_->get("Connection").empty()) {
hdr_->set("Connection", "Keep-Alive");
}
// Filter the header before writing it.
if (hf_ && ((err = hf_->filter(hdr)) != srs_success)) {
if (hf_ && ((err = hf_->filter(hdr_)) != srs_success)) {
return srs_error_wrap(err, "filter header");
}
// write header
hdr->write(ss);
hdr_->write(ss);
// header_eof
ss << SRS_HTTP_CRLF;
std::string buf = ss.str();
return skt->write((void *)buf.c_str(), buf.length(), NULL);
return skt_->write((void *)buf.c_str(), buf.length(), NULL);
}
bool SrsHttpMessageWriter::header_wrote()
@ -954,7 +954,7 @@ void SrsHttpMessageWriter::set_header_filter(ISrsHttpHeaderFilter *hf)
SrsHttpResponseWriter::SrsHttpResponseWriter(ISrsProtocolReadWriter *io)
{
writer_ = new SrsHttpMessageWriter(io, this);
status = SRS_CONSTS_HTTP_OK;
status_ = SRS_CONSTS_HTTP_OK;
}
SrsHttpResponseWriter::~SrsHttpResponseWriter()
@ -990,11 +990,11 @@ srs_error_t SrsHttpResponseWriter::writev(const iovec *iov, int iovcnt, ssize_t
void SrsHttpResponseWriter::write_header(int code)
{
if (writer_->header_wrote()) {
srs_warn("http: multiple write_header calls, status=%d, code=%d", status, code);
srs_warn("http: multiple write_header calls, status=%d, code=%d", status_, code);
return;
}
status = code;
status_ = code;
return writer_->write_header();
}
@ -1003,11 +1003,11 @@ srs_error_t SrsHttpResponseWriter::build_first_line(std::stringstream &ss, char
srs_error_t err = srs_success;
// Write status line for response.
ss << "HTTP/1.1 " << status << " " << srs_generate_http_status_text(status) << SRS_HTTP_CRLF;
ss << "HTTP/1.1 " << status_ << " " << srs_generate_http_status_text(status_) << SRS_HTTP_CRLF;
// Try to detect content type from response body data.
SrsHttpHeader *hdr = writer_->header();
if (srs_go_http_body_allowd(status)) {
if (srs_go_http_body_allowd(status_)) {
if (data && hdr->content_type().empty()) {
hdr->set_content_type(srs_go_http_detect(data, size));
}
@ -1086,13 +1086,13 @@ void SrsHttpRequestWriter::write_default_header()
SrsHttpResponseReader::SrsHttpResponseReader(SrsHttpMessage *msg, ISrsReader *reader, SrsFastStream *body)
{
skt = reader;
owner = msg;
is_eof = false;
nb_total_read = 0;
nb_left_chunk = 0;
buffer = body;
nb_chunk = 0;
skt_ = reader;
owner_ = msg;
is_eof_ = false;
nb_total_read_ = 0;
nb_left_chunk_ = 0;
buffer_ = body;
nb_chunk_ = 0;
}
SrsHttpResponseReader::~SrsHttpResponseReader()
@ -1101,32 +1101,32 @@ SrsHttpResponseReader::~SrsHttpResponseReader()
void SrsHttpResponseReader::close()
{
is_eof = true;
is_eof_ = true;
}
bool SrsHttpResponseReader::eof()
{
return is_eof;
return is_eof_;
}
srs_error_t SrsHttpResponseReader::read(void *data, size_t nb_data, ssize_t *nb_read)
{
srs_error_t err = srs_success;
if (is_eof) {
if (is_eof_) {
return srs_error_new(ERROR_HTTP_RESPONSE_EOF, "EOF");
}
// chunked encoding.
if (owner->is_chunked()) {
if (owner_->is_chunked()) {
return read_chunked(data, nb_data, nb_read);
}
// read by specified content-length
if (owner->content_length() != -1) {
size_t max = (size_t)owner->content_length() - (size_t)nb_total_read;
if (owner_->content_length() != -1) {
size_t max = (size_t)owner_->content_length() - (size_t)nb_total_read_;
if (max <= 0) {
is_eof = true;
is_eof_ = true;
return err;
}
@ -1142,7 +1142,7 @@ srs_error_t SrsHttpResponseReader::read(void *data, size_t nb_data, ssize_t *nb_
// For infinite chunked, the socket close event is EOF.
if (srs_error_code(err) == ERROR_SOCKET_READ) {
srs_freep(err);
is_eof = true;
is_eof_ = true;
return err;
}
}
@ -1156,13 +1156,13 @@ srs_error_t SrsHttpResponseReader::read_chunked(void *data, size_t nb_data, ssiz
// when no bytes left in chunk,
// parse the chunk length first.
if (nb_left_chunk <= 0) {
if (nb_left_chunk_ <= 0) {
char *at = NULL;
int length = 0;
while (!at) {
// find the CRLF of chunk header end.
char *start = buffer->bytes();
char *end = start + buffer->size();
char *start = buffer_->bytes();
char *end = start + buffer_->size();
for (char *p = start; p < end - 1; p++) {
if (p[0] == SRS_HTTP_CR && p[1] == SRS_HTTP_LF) {
@ -1171,7 +1171,7 @@ srs_error_t SrsHttpResponseReader::read_chunked(void *data, size_t nb_data, ssiz
return srs_error_new(ERROR_HTTP_INVALID_CHUNK_HEADER, "chunk header");
}
length = (int)(p - start + 2);
at = buffer->read_slice(length);
at = buffer_->read_slice(length);
break;
}
}
@ -1182,7 +1182,7 @@ srs_error_t SrsHttpResponseReader::read_chunked(void *data, size_t nb_data, ssiz
}
// when empty, only grow 1bytes, but the buffer will cache more.
if ((err = buffer->grow(skt, buffer->size() + 1)) != srs_success) {
if ((err = buffer_->grow(skt_, buffer_->size() + 1)) != srs_success) {
return srs_error_wrap(err, "grow buffer");
}
}
@ -1204,44 +1204,44 @@ srs_error_t SrsHttpResponseReader::read_chunked(void *data, size_t nb_data, ssiz
}
// all bytes in chunk is left now.
nb_chunk = nb_left_chunk = (size_t)ilength;
nb_chunk_ = nb_left_chunk_ = (size_t)ilength;
}
if (nb_chunk <= 0) {
if (nb_chunk_ <= 0) {
// for the last chunk, eof.
is_eof = true;
is_eof_ = true;
if (nb_read) {
*nb_read = 0;
}
} else {
// for not the last chunk, there must always exists bytes.
// left bytes in chunk, read some.
srs_assert(nb_left_chunk);
srs_assert(nb_left_chunk_);
size_t nb_bytes = srs_min(nb_left_chunk, nb_data);
size_t nb_bytes = srs_min(nb_left_chunk_, nb_data);
err = read_specified(data, nb_bytes, (ssize_t *)&nb_bytes);
// the nb_bytes used for output already read size of bytes.
if (nb_read) {
*nb_read = nb_bytes;
}
nb_left_chunk -= nb_bytes;
nb_left_chunk_ -= nb_bytes;
if (err != srs_success) {
return srs_error_wrap(err, "read specified");
}
// If still left bytes in chunk, ignore and read in future.
if (nb_left_chunk > 0) {
if (nb_left_chunk_ > 0) {
return err;
}
}
// for both the last or not, the CRLF of chunk payload end.
if ((err = buffer->grow(skt, 2)) != srs_success) {
if ((err = buffer_->grow(skt_, 2)) != srs_success) {
return srs_error_wrap(err, "grow buffer");
}
buffer->read_slice(2);
buffer_->read_slice(2);
return err;
}
@ -1250,31 +1250,31 @@ srs_error_t SrsHttpResponseReader::read_specified(void *data, size_t nb_data, ss
{
srs_error_t err = srs_success;
if (buffer->size() <= 0) {
if (buffer_->size() <= 0) {
// when empty, only grow 1bytes, but the buffer will cache more.
if ((err = buffer->grow(skt, 1)) != srs_success) {
if ((err = buffer_->grow(skt_, 1)) != srs_success) {
return srs_error_wrap(err, "grow buffer");
}
}
size_t nb_bytes = srs_min(nb_data, (size_t)buffer->size());
size_t nb_bytes = srs_min(nb_data, (size_t)buffer_->size());
// read data to buffer.
srs_assert(nb_bytes);
char *p = buffer->read_slice(nb_bytes);
char *p = buffer_->read_slice(nb_bytes);
memcpy(data, p, nb_bytes);
if (nb_read) {
*nb_read = nb_bytes;
}
// increase the total read to determine whether EOF.
nb_total_read += nb_bytes;
nb_total_read_ += nb_bytes;
// for not chunked and specified content length.
if (!owner->is_chunked() && owner->content_length() != -1) {
if (!owner_->is_chunked() && owner_->content_length() != -1) {
// when read completed, eof.
if (nb_total_read >= (int)owner->content_length()) {
is_eof = true;
if (nb_total_read_ >= (int)owner_->content_length()) {
is_eof_ = true;
}
}

View File

@ -26,20 +26,20 @@ class ISrsProtocolReadWriter;
class SrsHttpParser
{
private:
llhttp_settings_t settings;
llhttp_t parser;
llhttp_settings_t settings_;
llhttp_t parser_;
// The global parse buffer.
SrsFastStream *buffer;
SrsFastStream *buffer_;
// Whether allow jsonp parse.
bool jsonp;
bool jsonp_;
private:
std::string field_name;
std::string field_value;
SrsHttpParseState state;
llhttp_t hp_header;
std::string url;
SrsHttpHeader *header;
std::string field_name_;
std::string field_value_;
SrsHttpParseState state_;
llhttp_t hp_header_;
std::string url_;
SrsHttpHeader *header_;
enum llhttp_type type_;
enum llhttp_type parsed_type_;
@ -88,7 +88,7 @@ private:
SrsHttpResponseReader *_body;
// Use a buffer to read and send ts file.
// The transport connection, can be NULL.
ISrsConnection *owner_conn;
ISrsConnection *owner_conn_;
private:
// The request type defined as
@ -105,7 +105,7 @@ private:
// Whether the request indicates should keep alive for the http connection.
bool _keep_alive;
// Whether the body is chunked.
bool chunked;
bool chunked_;
private:
std::string schema_;
@ -120,9 +120,9 @@ private:
private:
// Whether request is jsonp.
bool jsonp;
bool jsonp_;
// The method in QueryString will override the HTTP method.
std::string jsonp_method;
std::string jsonp_method_;
public:
SrsHttpMessage(ISrsReader *reader = NULL, SrsFastStream *buffer = NULL);
@ -232,8 +232,8 @@ public:
class SrsHttpMessageWriter
{
private:
ISrsProtocolReadWriter *skt;
SrsHttpHeader *hdr;
ISrsProtocolReadWriter *skt_;
SrsHttpHeader *hdr_;
// Before writing header, there is a chance to filter it,
// such as remove some headers or inject new.
ISrsHttpHeaderFilter *hf_;
@ -241,9 +241,9 @@ private:
ISrsHttpFirstLineWriter *flw_;
private:
char header_cache[SRS_HTTP_HEADER_CACHE_SIZE];
iovec *iovss_cache;
int nb_iovss_cache;
char header_cache_[SRS_HTTP_HEADER_CACHE_SIZE];
iovec *iovss_cache_;
int nb_iovss_cache_;
private:
// Reply header has been (logically) written
@ -251,16 +251,16 @@ private:
private:
// The explicitly-declared Content-Length; or -1
int64_t content_length;
int64_t content_length_;
// The number of bytes written in body
int64_t written;
int64_t written_;
private:
// The wroteHeader tells whether the header's been written to "the
// wire" (or rather: w.conn.buf). this is unlike
// (*response).wroteHeader, which tells only whether it was
// logically written.
bool header_sent;
bool header_sent_;
public:
SrsHttpMessageWriter(ISrsProtocolReadWriter *io, ISrsHttpFirstLineWriter *flw);
@ -285,7 +285,7 @@ class SrsHttpResponseWriter : public ISrsHttpResponseWriter, public ISrsHttpFirs
protected:
SrsHttpMessageWriter *writer_;
// The status code passed to WriteHeader, for response only.
int status;
int status_;
public:
SrsHttpResponseWriter(ISrsProtocolReadWriter *io);
@ -335,16 +335,16 @@ public:
class SrsHttpResponseReader : public ISrsHttpResponseReader
{
private:
ISrsReader *skt;
SrsHttpMessage *owner;
SrsFastStream *buffer;
bool is_eof;
ISrsReader *skt_;
SrsHttpMessage *owner_;
SrsFastStream *buffer_;
bool is_eof_;
// The left bytes in chunk.
size_t nb_left_chunk;
size_t nb_left_chunk_;
// The number of bytes of current chunk.
size_t nb_chunk;
size_t nb_chunk_;
// Already read total bytes.
int64_t nb_total_read;
int64_t nb_total_read_;
public:
// Generally the reader is the under-layer io such as socket,

View File

@ -1205,7 +1205,7 @@ ISrsHttpMessage::~ISrsHttpMessage()
SrsHttpUri::SrsHttpUri()
{
port = 0;
port_ = 0;
}
SrsHttpUri::~SrsHttpUri()
@ -1214,7 +1214,7 @@ SrsHttpUri::~SrsHttpUri()
srs_error_t SrsHttpUri::initialize(string url)
{
schema = host = path = query = fragment_ = "";
schema_ = host_ = path_ = query_ = fragment_ = "";
url_ = url;
// Replace the default vhost to a domain like string, or parse failed.
@ -1226,25 +1226,25 @@ srs_error_t SrsHttpUri::initialize(string url)
// Simple URL parser to replace http-parser URL parsing
srs_error_t err = srs_success;
if ((err = parse_url_simple(parsing_url, schema, host, port, path, query, fragment_, username_, password_)) != srs_success) {
if ((err = parse_url_simple(parsing_url, schema_, host_, port_, path_, query_, fragment_, username_, password_)) != srs_success) {
return srs_error_wrap(err, "parse url %s as %s failed", url.c_str(), parsing_url.c_str());
}
// Restore the default vhost.
if (pos_default_vhost != string::npos) {
host = SRS_CONSTS_RTMP_DEFAULT_VHOST;
host_ = SRS_CONSTS_RTMP_DEFAULT_VHOST;
}
// Set default ports if not specified
if (port <= 0) {
if (schema == "https") {
port = SRS_DEFAULT_HTTPS_PORT;
} else if (schema == "rtmp") {
port = SRS_CONSTS_RTMP_DEFAULT_PORT;
} else if (schema == "redis") {
port = SRS_DEFAULT_REDIS_PORT;
if (port_ <= 0) {
if (schema_ == "https") {
port_ = SRS_DEFAULT_HTTPS_PORT;
} else if (schema_ == "rtmp") {
port_ = SRS_CONSTS_RTMP_DEFAULT_PORT;
} else if (schema_ == "redis") {
port_ = SRS_DEFAULT_REDIS_PORT;
} else {
port = SRS_DEFAULT_HTTP_PORT;
port_ = SRS_DEFAULT_HTTP_PORT;
}
}
@ -1253,12 +1253,12 @@ srs_error_t SrsHttpUri::initialize(string url)
void SrsHttpUri::set_schema(std::string v)
{
schema = v;
schema_ = v;
// Update url with new schema.
size_t pos = url_.find("://");
if (pos != string::npos) {
url_ = schema + "://" + url_.substr(pos + 3);
url_ = schema_ + "://" + url_.substr(pos + 3);
}
}
@ -1269,27 +1269,27 @@ string SrsHttpUri::get_url()
string SrsHttpUri::get_schema()
{
return schema;
return schema_;
}
string SrsHttpUri::get_host()
{
return host;
return host_;
}
int SrsHttpUri::get_port()
{
return port;
return port_;
}
string SrsHttpUri::get_path()
{
return path;
return path_;
}
string SrsHttpUri::get_query()
{
return query;
return query_;
}
string SrsHttpUri::get_query_by_key(std::string key)
@ -1416,17 +1416,17 @@ srs_error_t SrsHttpUri::parse_url_simple(const string &url, string &schema, stri
srs_error_t SrsHttpUri::parse_query()
{
srs_error_t err = srs_success;
if (query.empty()) {
if (query_.empty()) {
return err;
}
size_t begin = query.find("?");
size_t begin = query_.find("?");
if (string::npos != begin) {
begin++;
} else {
begin = 0;
}
string query_str = query.substr(begin);
string query_str = query_.substr(begin);
query_values_.clear();
srs_net_url_parse_query(query_str, query_values_);

View File

@ -637,11 +637,11 @@ class SrsHttpUri
{
private:
std::string url_;
std::string schema;
std::string host;
int port;
std::string path;
std::string query;
std::string schema_;
std::string host_;
int port_;
std::string path_;
std::string query_;
std::string fragment_;
std::string username_;
std::string password_;

View File

@ -1309,14 +1309,14 @@ public:
SrsJsonString(const char *v)
{
marker = SRS_JSON_String;
marker_ = SRS_JSON_String;
if (v) {
value = v;
}
}
SrsJsonString(const char *v, int s)
{
marker = SRS_JSON_String;
marker_ = SRS_JSON_String;
if (v) {
value.append(v, s);
}
@ -1333,7 +1333,7 @@ public:
SrsJsonBoolean(bool v)
{
marker = SRS_JSON_Boolean;
marker_ = SRS_JSON_Boolean;
value = v;
}
virtual ~SrsJsonBoolean()
@ -1348,7 +1348,7 @@ public:
SrsJsonInteger(int64_t v)
{
marker = SRS_JSON_Integer;
marker_ = SRS_JSON_Integer;
value = v;
}
virtual ~SrsJsonInteger()
@ -1363,7 +1363,7 @@ public:
SrsJsonNumber(double v)
{
marker = SRS_JSON_Number;
marker_ = SRS_JSON_Number;
value = v;
}
virtual ~SrsJsonNumber()
@ -1376,7 +1376,7 @@ class SrsJsonNull : public SrsJsonAny
public:
SrsJsonNull()
{
marker = SRS_JSON_Null;
marker_ = SRS_JSON_Null;
}
virtual ~SrsJsonNull()
{
@ -1385,7 +1385,7 @@ public:
SrsJsonAny::SrsJsonAny()
{
marker = 0;
marker_ = 0;
}
SrsJsonAny::~SrsJsonAny()
@ -1394,37 +1394,37 @@ SrsJsonAny::~SrsJsonAny()
bool SrsJsonAny::is_string()
{
return marker == SRS_JSON_String;
return marker_ == SRS_JSON_String;
}
bool SrsJsonAny::is_boolean()
{
return marker == SRS_JSON_Boolean;
return marker_ == SRS_JSON_Boolean;
}
bool SrsJsonAny::is_number()
{
return marker == SRS_JSON_Number;
return marker_ == SRS_JSON_Number;
}
bool SrsJsonAny::is_integer()
{
return marker == SRS_JSON_Integer;
return marker_ == SRS_JSON_Integer;
}
bool SrsJsonAny::is_object()
{
return marker == SRS_JSON_Object;
return marker_ == SRS_JSON_Object;
}
bool SrsJsonAny::is_array()
{
return marker == SRS_JSON_Array;
return marker_ == SRS_JSON_Array;
}
bool SrsJsonAny::is_null()
{
return marker == SRS_JSON_Null;
return marker_ == SRS_JSON_Null;
}
string SrsJsonAny::to_str()
@ -1514,7 +1514,7 @@ string json_serialize_string(const string &v)
string SrsJsonAny::dumps()
{
switch (marker) {
switch (marker_) {
case SRS_JSON_String: {
SrsJsonString *p = dynamic_cast<SrsJsonString *>(this);
srs_assert(p != NULL);
@ -1551,7 +1551,7 @@ string SrsJsonAny::dumps()
SrsAmf0Any *SrsJsonAny::to_amf0()
{
switch (marker) {
switch (marker_) {
case SRS_JSON_String: {
return SrsAmf0Any::str(to_str().c_str());
}
@ -1688,36 +1688,36 @@ SrsJsonAny *SrsJsonAny::loads(string str)
SrsJsonObject::SrsJsonObject()
{
marker = SRS_JSON_Object;
marker_ = SRS_JSON_Object;
}
SrsJsonObject::~SrsJsonObject()
{
std::vector<SrsJsonObjectPropertyType>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsJsonObjectPropertyType item = *it;
SrsJsonAny *obj = item.second;
srs_freep(obj);
}
properties.clear();
properties_.clear();
}
int SrsJsonObject::count()
{
return (int)properties.size();
return (int)properties_.size();
}
string SrsJsonObject::key_at(int index)
{
srs_assert(index < count());
SrsJsonObjectPropertyType &elem = properties[index];
SrsJsonObjectPropertyType &elem = properties_[index];
return elem.first;
}
SrsJsonAny *SrsJsonObject::value_at(int index)
{
srs_assert(index < count());
SrsJsonObjectPropertyType &elem = properties[index];
SrsJsonObjectPropertyType &elem = properties_[index];
return elem.second;
}
@ -1727,12 +1727,12 @@ string SrsJsonObject::dumps()
ss << SRS_JOBJECT_START;
for (int i = 0; i < (int)properties.size(); i++) {
for (int i = 0; i < (int)properties_.size(); i++) {
std::string name = this->key_at(i);
SrsJsonAny *any = this->value_at(i);
ss << SRS_JFIELD_NAME(name) << any->dumps();
if (i < (int)properties.size() - 1) {
if (i < (int)properties_.size() - 1) {
ss << SRS_JFIELD_CONT;
}
}
@ -1746,7 +1746,7 @@ SrsAmf0Any *SrsJsonObject::to_amf0()
{
SrsAmf0Object *obj = SrsAmf0Any::object();
for (int i = 0; i < (int)properties.size(); i++) {
for (int i = 0; i < (int)properties_.size(); i++) {
std::string name = this->key_at(i);
SrsJsonAny *any = this->value_at(i);
@ -1765,19 +1765,19 @@ SrsJsonObject *SrsJsonObject::set(string key, SrsJsonAny *value)
std::vector<SrsJsonObjectPropertyType>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsJsonObjectPropertyType &elem = *it;
std::string name = elem.first;
SrsJsonAny *any = elem.second;
if (key == name) {
srs_freep(any);
it = properties.erase(it);
it = properties_.erase(it);
break;
}
}
properties.push_back(std::make_pair(key, value));
properties_.push_back(std::make_pair(key, value));
return this;
}
@ -1785,7 +1785,7 @@ SrsJsonAny *SrsJsonObject::get_property(string name)
{
std::vector<SrsJsonObjectPropertyType>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsJsonObjectPropertyType &elem = *it;
std::string key = elem.first;
SrsJsonAny *any = elem.second;
@ -1889,34 +1889,34 @@ SrsJsonAny *SrsJsonObject::ensure_property_array(string name)
SrsJsonArray::SrsJsonArray()
{
marker = SRS_JSON_Array;
marker_ = SRS_JSON_Array;
}
SrsJsonArray::~SrsJsonArray()
{
std::vector<SrsJsonAny *>::iterator it;
for (it = properties.begin(); it != properties.end(); ++it) {
for (it = properties_.begin(); it != properties_.end(); ++it) {
SrsJsonAny *item = *it;
srs_freep(item);
}
properties.clear();
properties_.clear();
}
int SrsJsonArray::count()
{
return (int)properties.size();
return (int)properties_.size();
}
SrsJsonAny *SrsJsonArray::at(int index)
{
srs_assert(index < count());
SrsJsonAny *elem = properties[index];
SrsJsonAny *elem = properties_[index];
return elem;
}
SrsJsonArray *SrsJsonArray::add(SrsJsonAny *value)
{
properties.push_back(value);
properties_.push_back(value);
return this;
}
@ -1932,12 +1932,12 @@ string SrsJsonArray::dumps()
ss << SRS_JARRAY_START;
for (int i = 0; i < (int)properties.size(); i++) {
SrsJsonAny *any = properties[i];
for (int i = 0; i < (int)properties_.size(); i++) {
SrsJsonAny *any = properties_[i];
ss << any->dumps();
if (i < (int)properties.size() - 1) {
if (i < (int)properties_.size() - 1) {
ss << SRS_JFIELD_CONT;
}
}
@ -1951,8 +1951,8 @@ SrsAmf0Any *SrsJsonArray::to_amf0()
{
SrsAmf0StrictArray *arr = SrsAmf0Any::strict_array();
for (int i = 0; i < (int)properties.size(); i++) {
SrsJsonAny *any = properties[i];
for (int i = 0; i < (int)properties_.size(); i++) {
SrsJsonAny *any = properties_[i];
arr->append(any->to_amf0());
}

View File

@ -41,7 +41,7 @@ class SrsJsonObject;
class SrsJsonAny
{
public:
char marker;
char marker_;
// Don't directly create this object,
// please use SrsJsonAny::str() to create a concreated one.
protected:
@ -103,7 +103,7 @@ class SrsJsonObject : public SrsJsonAny
{
private:
typedef std::pair<std::string, SrsJsonAny *> SrsJsonObjectPropertyType;
std::vector<SrsJsonObjectPropertyType> properties;
std::vector<SrsJsonObjectPropertyType> properties_;
private:
// Use SrsJsonAny::object() to create it.
@ -138,7 +138,7 @@ public:
class SrsJsonArray : public SrsJsonAny
{
private:
std::vector<SrsJsonAny *> properties;
std::vector<SrsJsonAny *> properties_;
private:
// Use SrsJsonAny::array() to create it.

View File

@ -10,9 +10,9 @@
SrsKbpsSlice::SrsKbpsSlice(SrsWallClock *c)
{
clk = c;
starttime = 0;
bytes = 0;
clk_ = c;
starttime_ = 0;
bytes_ = 0;
}
SrsKbpsSlice::~SrsKbpsSlice()
@ -21,36 +21,36 @@ SrsKbpsSlice::~SrsKbpsSlice()
void SrsKbpsSlice::sample()
{
srs_utime_t now = clk->now();
srs_utime_t now = clk_->now();
if (sample_30s.time_ < 0) {
sample_30s.update(bytes, now, 0);
if (sample_30s_.time_ < 0) {
sample_30s_.update(bytes_, now, 0);
}
if (sample_1m.time_ < 0) {
sample_1m.update(bytes, now, 0);
if (sample_1m_.time_ < 0) {
sample_1m_.update(bytes_, now, 0);
}
if (sample_5m.time_ < 0) {
sample_5m.update(bytes, now, 0);
if (sample_5m_.time_ < 0) {
sample_5m_.update(bytes_, now, 0);
}
if (sample_60m.time_ < 0) {
sample_60m.update(bytes, now, 0);
if (sample_60m_.time_ < 0) {
sample_60m_.update(bytes_, now, 0);
}
if (now - sample_30s.time_ >= 30 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes - sample_30s.total_) * 8 / srsu2ms(now - sample_30s.time_));
sample_30s.update(bytes, now, kbps);
if (now - sample_30s_.time_ >= 30 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes_ - sample_30s_.total_) * 8 / srsu2ms(now - sample_30s_.time_));
sample_30s_.update(bytes_, now, kbps);
}
if (now - sample_1m.time_ >= 60 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes - sample_1m.total_) * 8 / srsu2ms(now - sample_1m.time_));
sample_1m.update(bytes, now, kbps);
if (now - sample_1m_.time_ >= 60 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes_ - sample_1m_.total_) * 8 / srsu2ms(now - sample_1m_.time_));
sample_1m_.update(bytes_, now, kbps);
}
if (now - sample_5m.time_ >= 300 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes - sample_5m.total_) * 8 / srsu2ms(now - sample_5m.time_));
sample_5m.update(bytes, now, kbps);
if (now - sample_5m_.time_ >= 300 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes_ - sample_5m_.total_) * 8 / srsu2ms(now - sample_5m_.time_));
sample_5m_.update(bytes_, now, kbps);
}
if (now - sample_60m.time_ >= 3600 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes - sample_60m.total_) * 8 / srsu2ms(now - sample_60m.time_));
sample_60m.update(bytes, now, kbps);
if (now - sample_60m_.time_ >= 3600 * SRS_UTIME_SECONDS) {
int kbps = (int)((bytes_ - sample_60m_.total_) * 8 / srsu2ms(now - sample_60m_.time_));
sample_60m_.update(bytes_, now, kbps);
}
}
@ -136,20 +136,20 @@ void SrsNetworkDelta::remark(int64_t *in, int64_t *out)
SrsKbps::SrsKbps(SrsWallClock *c)
{
clk = c ? c : _srs_clock;
is = new SrsKbpsSlice(clk);
os = new SrsKbpsSlice(clk);
clk_ = c ? c : _srs_clock;
is_ = new SrsKbpsSlice(clk_);
os_ = new SrsKbpsSlice(clk_);
}
SrsKbps::~SrsKbps()
{
srs_freep(is);
srs_freep(os);
srs_freep(is_);
srs_freep(os_);
}
int SrsKbps::get_send_kbps()
{
int duration = srsu2ms(clk->now() - is->starttime);
int duration = srsu2ms(clk_->now() - is_->starttime_);
if (duration <= 0) {
return 0;
}
@ -160,7 +160,7 @@ int SrsKbps::get_send_kbps()
int SrsKbps::get_recv_kbps()
{
int duration = srsu2ms(clk->now() - os->starttime);
int duration = srsu2ms(clk_->now() - os_->starttime_);
if (duration <= 0) {
return 0;
}
@ -171,22 +171,22 @@ int SrsKbps::get_recv_kbps()
int SrsKbps::get_send_kbps_30s()
{
return os->sample_30s.rate_;
return os_->sample_30s_.rate_;
}
int SrsKbps::get_recv_kbps_30s()
{
return is->sample_30s.rate_;
return is_->sample_30s_.rate_;
}
int SrsKbps::get_send_kbps_5m()
{
return os->sample_5m.rate_;
return os_->sample_5m_.rate_;
}
int SrsKbps::get_recv_kbps_5m()
{
return is->sample_5m.rate_;
return is_->sample_5m_.rate_;
}
void SrsKbps::add_delta(ISrsKbpsDelta *delta)
@ -202,26 +202,26 @@ void SrsKbps::add_delta(ISrsKbpsDelta *delta)
void SrsKbps::add_delta(int64_t in, int64_t out)
{
// update the total bytes
is->bytes += in;
os->bytes += out;
is_->bytes_ += in;
os_->bytes_ += out;
// we donot sample, please use sample() to do resample.
}
void SrsKbps::sample()
{
is->sample();
os->sample();
is_->sample();
os_->sample();
}
int64_t SrsKbps::get_send_bytes()
{
return os->bytes;
return os_->bytes_;
}
int64_t SrsKbps::get_recv_bytes()
{
return is->bytes;
return is_->bytes_;
}
SrsNetworkKbps::SrsNetworkKbps(SrsWallClock *clock)

View File

@ -18,22 +18,22 @@
class SrsKbpsSlice
{
private:
SrsWallClock *clk;
SrsWallClock *clk_;
public:
// session startup bytes
// @remark, use total_bytes() to get the total bytes of slice.
int64_t bytes;
int64_t bytes_;
// slice starttime, the first time to record bytes.
srs_utime_t starttime;
srs_utime_t starttime_;
// samples
SrsRateSample sample_30s;
SrsRateSample sample_1m;
SrsRateSample sample_5m;
SrsRateSample sample_60m;
SrsRateSample sample_30s_;
SrsRateSample sample_1m_;
SrsRateSample sample_5m_;
SrsRateSample sample_60m_;
public:
SrsKbpsSlice(SrsWallClock *clk);
SrsKbpsSlice(SrsWallClock *c);
virtual ~SrsKbpsSlice();
public:
@ -119,9 +119,9 @@ public:
class SrsKbps
{
private:
SrsKbpsSlice *is;
SrsKbpsSlice *os;
SrsWallClock *clk;
SrsKbpsSlice *is_;
SrsKbpsSlice *os_;
SrsWallClock *clk_;
public:
// Note that we won't free the clock c.

View File

@ -107,14 +107,14 @@ impl_SrsContextRestore::~impl_SrsContextRestore()
SrsConsoleLog::SrsConsoleLog(SrsLogLevel l, bool u)
{
level_ = l;
utc = u;
utc_ = u;
buffer = new char[SRS_BASIC_LOG_SIZE];
buffer_ = new char[SRS_BASIC_LOG_SIZE];
}
SrsConsoleLog::~SrsConsoleLog()
{
srs_freepa(buffer);
srs_freepa(buffer_);
}
srs_error_t SrsConsoleLog::initialize()
@ -133,12 +133,12 @@ void SrsConsoleLog::log(SrsLogLevel level, const char *tag, const SrsContextId &
}
int size = 0;
if (!srs_log_header(buffer, SRS_BASIC_LOG_SIZE, utc, level >= SrsLogLevelWarn, tag, context_id, srs_log_level_strings[level], &size)) {
if (!srs_log_header(buffer_, SRS_BASIC_LOG_SIZE, utc_, level >= SrsLogLevelWarn, tag, context_id, srs_log_level_strings[level], &size)) {
return;
}
// Something not expected, drop the log.
int r0 = vsnprintf(buffer + size, SRS_BASIC_LOG_SIZE - size, fmt, args);
int r0 = vsnprintf(buffer_ + size, SRS_BASIC_LOG_SIZE - size, fmt, args);
if (r0 <= 0 || r0 >= SRS_BASIC_LOG_SIZE - size) {
return;
}
@ -146,7 +146,7 @@ void SrsConsoleLog::log(SrsLogLevel level, const char *tag, const SrsContextId &
// Add errno and strerror() if error.
if (level == SrsLogLevelError && errno != 0) {
r0 = snprintf(buffer + size, SRS_BASIC_LOG_SIZE - size, "(%s)", strerror(errno));
r0 = snprintf(buffer_ + size, SRS_BASIC_LOG_SIZE - size, "(%s)", strerror(errno));
// Something not expected, drop the log.
if (r0 <= 0 || r0 >= SRS_BASIC_LOG_SIZE - size) {
@ -156,9 +156,9 @@ void SrsConsoleLog::log(SrsLogLevel level, const char *tag, const SrsContextId &
}
if (level >= SrsLogLevelWarn) {
fprintf(stderr, "%s\n", buffer);
fprintf(stderr, "%s\n", buffer_);
} else {
fprintf(stdout, "%s\n", buffer);
fprintf(stdout, "%s\n", buffer_);
}
}

View File

@ -20,7 +20,7 @@
class SrsThreadContext : public ISrsContext
{
private:
std::map<srs_thread_t, SrsContextId> cache;
std::map<srs_thread_t, SrsContextId> cache_;
public:
SrsThreadContext();
@ -57,10 +57,10 @@ class SrsConsoleLog : public ISrsLog
{
private:
SrsLogLevel level_;
bool utc;
bool utc_;
private:
char *buffer;
char *buffer_;
public:
SrsConsoleLog(SrsLogLevel l, bool u);

View File

@ -755,30 +755,30 @@ srs_error_t SrsRawAacStream::adts_demux(SrsBuffer *stream, char **pframe, int *p
}
// the codec info.
codec.protection_absent = protection_absent;
codec.aac_object = srs_aac_ts2rtmp((SrsAacProfile)profile);
codec.sampling_frequency_index = sampling_frequency_index;
codec.channel_configuration = channel_configuration;
codec.frame_length = frame_length;
codec.protection_absent_ = protection_absent;
codec.aac_object_ = srs_aac_ts2rtmp((SrsAacProfile)profile);
codec.sampling_frequency_index_ = sampling_frequency_index;
codec.channel_configuration_ = channel_configuration;
codec.frame_length_ = frame_length;
// The aac sampleing rate defined in srs_aac_srates.
// TODO: FIXME: maybe need to resample audio.
codec.sound_format = 10; // AAC
codec.sound_format_ = 10; // AAC
if (sampling_frequency_index <= 0x0c && sampling_frequency_index > 0x0a) {
codec.sound_rate = SrsAudioSampleRate5512;
codec.sound_rate_ = SrsAudioSampleRate5512;
} else if (sampling_frequency_index <= 0x0a && sampling_frequency_index > 0x07) {
codec.sound_rate = SrsAudioSampleRate11025;
codec.sound_rate_ = SrsAudioSampleRate11025;
} else if (sampling_frequency_index <= 0x07 && sampling_frequency_index > 0x04) {
codec.sound_rate = SrsAudioSampleRate22050;
codec.sound_rate_ = SrsAudioSampleRate22050;
} else if (sampling_frequency_index <= 0x04) {
codec.sound_rate = SrsAudioSampleRate44100;
codec.sound_rate_ = SrsAudioSampleRate44100;
} else {
codec.sound_rate = SrsAudioSampleRate44100;
codec.sound_rate_ = SrsAudioSampleRate44100;
srs_warn("adts invalid sample rate for flv, rate=%#x", sampling_frequency_index);
}
codec.sound_type = srs_max(0, srs_min(1, channel_configuration - 1));
codec.sound_type_ = srs_max(0, srs_min(1, channel_configuration - 1));
// TODO: FIXME: finger it out the sound size by adts.
codec.sound_size = 1; // 0(8bits) or 1(16bits).
codec.sound_size_ = 1; // 0(8bits) or 1(16bits).
// frame data.
*pframe = stream->data() + stream->pos();
@ -796,12 +796,12 @@ srs_error_t SrsRawAacStream::mux_sequence_header(SrsRawAacStreamCodec *codec, st
srs_error_t err = srs_success;
// only support aac profile 1-4.
if (codec->aac_object == SrsAacObjectTypeReserved) {
if (codec->aac_object_ == SrsAacObjectTypeReserved) {
return srs_error_new(ERROR_AAC_DATA_INVALID, "invalid aac object");
}
SrsAacObjectType audioObjectType = codec->aac_object;
char channelConfiguration = codec->channel_configuration;
SrsAacObjectType audioObjectType = codec->aac_object_;
char channelConfiguration = codec->channel_configuration_;
// Here we are generating AAC sequence header, the ASC structure,
// because we have already parsed the sampling rate from AAC codec,
@ -810,9 +810,9 @@ srs_error_t SrsRawAacStream::mux_sequence_header(SrsRawAacStreamCodec *codec, st
// For example, AAC sampling_frequency_index is 3(48000HZ) or 4(44100HZ),
// the sound_rate is always 3(44100HZ), if we covert sound_rate to
// sampling_frequency_index, we may make mistake.
uint8_t samplingFrequencyIndex = (uint8_t)codec->sampling_frequency_index;
uint8_t samplingFrequencyIndex = (uint8_t)codec->sampling_frequency_index_;
if (samplingFrequencyIndex >= SrsAacSampleRateUnset) {
switch (codec->sound_rate) {
switch (codec->sound_rate_) {
case SrsAudioSampleRate5512:
samplingFrequencyIndex = 0x0c;
break;
@ -864,11 +864,11 @@ srs_error_t SrsRawAacStream::mux_aac2flv(char *frame, int nb_frame, SrsRawAacStr
{
srs_error_t err = srs_success;
char sound_format = codec->sound_format;
char sound_type = codec->sound_type;
char sound_size = codec->sound_size;
char sound_rate = codec->sound_rate;
char aac_packet_type = codec->aac_packet_type;
char sound_format = codec->sound_format_;
char sound_type = codec->sound_type_;
char sound_size = codec->sound_size_;
char sound_rate = codec->sound_rate_;
char aac_packet_type = codec->aac_packet_type_;
// for audio frame, there is 1 or 2 bytes header:
// 1bytes, SoundFormat|SoundRate|SoundSize|SoundType

View File

@ -110,19 +110,19 @@ public:
// The header of adts sample.
struct SrsRawAacStreamCodec {
// Codec level informations.
int8_t protection_absent;
SrsAacObjectType aac_object;
int8_t sampling_frequency_index;
int8_t channel_configuration;
int16_t frame_length;
int8_t protection_absent_;
SrsAacObjectType aac_object_;
int8_t sampling_frequency_index_;
int8_t channel_configuration_;
int16_t frame_length_;
// Format level, RTMP as such, informations.
char sound_format;
char sound_rate;
char sound_size;
char sound_type;
char sound_format_;
char sound_rate_;
char sound_size_;
char sound_type_;
// 0 for sh; 1 for raw data.
int8_t aac_packet_type;
int8_t aac_packet_type_;
};
// The raw aac stream, in adts.

View File

@ -109,14 +109,14 @@ static srs_error_t hmac_encode(const std::string &algo, const char *key, const i
SrsStunPacket::SrsStunPacket()
{
message_type = 0;
local_ufrag = "";
remote_ufrag = "";
use_candidate = false;
ice_controlled = false;
ice_controlling = false;
mapped_port = 0;
mapped_address = 0;
message_type_ = 0;
local_ufrag_ = "";
remote_ufrag_ = "";
use_candidate_ = false;
ice_controlled_ = false;
ice_controlling_ = false;
mapped_port_ = 0;
mapped_address_ = 0;
}
SrsStunPacket::~SrsStunPacket()
@ -125,92 +125,92 @@ SrsStunPacket::~SrsStunPacket()
bool SrsStunPacket::is_binding_request() const
{
return message_type == BindingRequest;
return message_type_ == BindingRequest;
}
bool SrsStunPacket::is_binding_response() const
{
return message_type == BindingResponse;
return message_type_ == BindingResponse;
}
uint16_t SrsStunPacket::get_message_type() const
{
return message_type;
return message_type_;
}
std::string SrsStunPacket::get_username() const
{
return username;
return username_;
}
std::string SrsStunPacket::get_local_ufrag() const
{
return local_ufrag;
return local_ufrag_;
}
std::string SrsStunPacket::get_remote_ufrag() const
{
return remote_ufrag;
return remote_ufrag_;
}
std::string SrsStunPacket::get_transcation_id() const
{
return transcation_id;
return transcation_id_;
}
uint32_t SrsStunPacket::get_mapped_address() const
{
return mapped_address;
return mapped_address_;
}
uint16_t SrsStunPacket::get_mapped_port() const
{
return mapped_port;
return mapped_port_;
}
bool SrsStunPacket::get_ice_controlled() const
{
return ice_controlled;
return ice_controlled_;
}
bool SrsStunPacket::get_ice_controlling() const
{
return ice_controlling;
return ice_controlling_;
}
bool SrsStunPacket::get_use_candidate() const
{
return use_candidate;
return use_candidate_;
}
void SrsStunPacket::set_message_type(const uint16_t &m)
{
message_type = m;
message_type_ = m;
}
void SrsStunPacket::set_local_ufrag(const std::string &u)
{
local_ufrag = u;
local_ufrag_ = u;
}
void SrsStunPacket::set_remote_ufrag(const std::string &u)
{
remote_ufrag = u;
remote_ufrag_ = u;
}
void SrsStunPacket::set_transcation_id(const std::string &t)
{
transcation_id = t;
transcation_id_ = t;
}
void SrsStunPacket::set_mapped_address(const uint32_t &addr)
{
mapped_address = addr;
mapped_address_ = addr;
}
void SrsStunPacket::set_mapped_port(const uint32_t &port)
{
mapped_port = port;
mapped_port_ = port;
}
srs_error_t SrsStunPacket::decode(const char *buf, const int nb_buf)
@ -223,10 +223,10 @@ srs_error_t SrsStunPacket::decode(const char *buf, const int nb_buf)
return srs_error_new(ERROR_RTC_STUN, "invalid stun packet, size=%d", stream->size());
}
message_type = stream->read_2bytes();
message_type_ = stream->read_2bytes();
uint16_t message_len = stream->read_2bytes();
string magic_cookie = stream->read_string(4);
transcation_id = stream->read_string(12);
transcation_id_ = stream->read_string(12);
if (nb_buf != 20 + message_len) {
return srs_error_new(ERROR_RTC_STUN, "invalid stun packet, message_len=%d, nb_buf=%d", message_len, nb_buf);
@ -248,18 +248,18 @@ srs_error_t SrsStunPacket::decode(const char *buf, const int nb_buf)
switch (type) {
case Username: {
username = val;
username_ = val;
size_t p = val.find(":");
if (p != string::npos) {
local_ufrag = val.substr(0, p);
remote_ufrag = val.substr(p + 1);
srs_verbose("stun packet local_ufrag=%s, remote_ufrag=%s", local_ufrag.c_str(), remote_ufrag.c_str());
local_ufrag_ = val.substr(0, p);
remote_ufrag_ = val.substr(p + 1);
srs_verbose("stun packet local_ufrag=%s, remote_ufrag=%s", local_ufrag_.c_str(), remote_ufrag_.c_str());
}
break;
}
case UseCandidate: {
use_candidate = true;
use_candidate_ = true;
srs_verbose("stun use-candidate");
break;
}
@ -270,13 +270,13 @@ srs_error_t SrsStunPacket::decode(const char *buf, const int nb_buf)
// agent will form check lists, run the ICE state machines, and
// generate connectivity checks.
case IceControlled: {
ice_controlled = true;
ice_controlled_ = true;
srs_verbose("stun ice-controlled");
break;
}
case IceControlling: {
ice_controlling = true;
ice_controlling_ = true;
srs_verbose("stun ice-controlling");
break;
}
@ -311,7 +311,7 @@ srs_error_t SrsStunPacket::encode_binding_response(const string &pwd, SrsBuffer
stream->write_2bytes(BindingResponse);
stream->write_2bytes(property_username.size() + mapped_address.size());
stream->write_4bytes(kStunMagicCookie);
stream->write_string(transcation_id);
stream->write_string(transcation_id_);
stream->write_string(property_username);
stream->write_string(mapped_address);
@ -347,7 +347,7 @@ string SrsStunPacket::encode_username()
char buf[1460];
SrsUniquePtr<SrsBuffer> stream(new SrsBuffer(buf, sizeof(buf)));
string username = remote_ufrag + ":" + local_ufrag;
string username = remote_ufrag_ + ":" + local_ufrag_;
stream->write_2bytes(Username);
stream->write_2bytes(username.size());
@ -370,8 +370,8 @@ string SrsStunPacket::encode_mapped_address()
stream->write_2bytes(8);
stream->write_1bytes(0); // ignore this bytes
stream->write_1bytes(1); // ipv4 family
stream->write_2bytes(mapped_port ^ (kStunMagicCookie >> 16));
stream->write_4bytes(mapped_address ^ kStunMagicCookie);
stream->write_2bytes(mapped_port_ ^ (kStunMagicCookie >> 16));
stream->write_4bytes(mapped_address_ ^ kStunMagicCookie);
return string(stream->data(), stream->pos());
}

View File

@ -60,16 +60,16 @@ enum SrsStunMessageAttribute {
class SrsStunPacket
{
private:
uint16_t message_type;
std::string username;
std::string local_ufrag;
std::string remote_ufrag;
std::string transcation_id;
uint32_t mapped_address;
uint16_t mapped_port;
bool use_candidate;
bool ice_controlled;
bool ice_controlling;
uint16_t message_type_;
std::string username_;
std::string local_ufrag_;
std::string remote_ufrag_;
std::string transcation_id_;
uint32_t mapped_address_;
uint16_t mapped_port_;
bool use_candidate_;
bool ice_controlled_;
bool ice_controlling_;
public:
SrsStunPacket();

View File

@ -17,35 +17,35 @@ using namespace std;
SrsBasicRtmpClient::SrsBasicRtmpClient(string r, srs_utime_t ctm, srs_utime_t stm)
{
kbps = new SrsNetworkKbps();
kbps_ = new SrsNetworkKbps();
url = r;
connect_timeout = ctm;
stream_timeout = stm;
url_ = r;
connect_timeout_ = ctm;
stream_timeout_ = stm;
req = new SrsRequest();
srs_net_url_parse_rtmp_url(url, req->tcUrl, req->stream);
srs_net_url_parse_tcurl(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param);
req_ = new SrsRequest();
srs_net_url_parse_rtmp_url(url_, req_->tcUrl_, req_->stream_);
srs_net_url_parse_tcurl(req_->tcUrl_, req_->schema_, req_->host_, req_->vhost_, req_->app_, req_->stream_, req_->port_, req_->param_);
transport = NULL;
client = NULL;
transport_ = NULL;
client_ = NULL;
stream_id = 0;
stream_id_ = 0;
}
SrsBasicRtmpClient::~SrsBasicRtmpClient()
{
close();
srs_freep(kbps);
srs_freep(req);
srs_freep(kbps_);
srs_freep(req_);
}
SrsAmf0Object *SrsBasicRtmpClient::extra_args()
{
if (req->args == NULL) {
req->args = SrsAmf0Any::object();
if (req_->args_ == NULL) {
req_->args_ = SrsAmf0Any::object();
}
return req->args;
return req_->args_;
}
srs_error_t SrsBasicRtmpClient::connect()
@ -54,27 +54,27 @@ srs_error_t SrsBasicRtmpClient::connect()
close();
transport = new SrsTcpClient(req->host, req->port, srs_utime_t(connect_timeout));
client = new SrsRtmpClient(transport);
kbps->set_io(transport, transport);
transport_ = new SrsTcpClient(req_->host_, req_->port_, srs_utime_t(connect_timeout_));
client_ = new SrsRtmpClient(transport_);
kbps_->set_io(transport_, transport_);
if ((err = transport->connect()) != srs_success) {
if ((err = transport_->connect()) != srs_success) {
close();
return srs_error_wrap(err, "connect");
}
client->set_recv_timeout(stream_timeout);
client->set_send_timeout(stream_timeout);
client_->set_recv_timeout(stream_timeout_);
client_->set_send_timeout(stream_timeout_);
// connect to vhost/app
if ((err = client->handshake()) != srs_success) {
if ((err = client_->handshake()) != srs_success) {
return srs_error_wrap(err, "handshake");
}
if ((err = connect_app()) != srs_success) {
return srs_error_wrap(err, "connect app");
}
if ((err = client->create_stream(stream_id)) != srs_success) {
return srs_error_wrap(err, "create stream_id=%d", stream_id);
if ((err = client_->create_stream(stream_id_)) != srs_success) {
return srs_error_wrap(err, "create stream_id=%d", stream_id_);
}
return err;
@ -82,9 +82,9 @@ srs_error_t SrsBasicRtmpClient::connect()
void SrsBasicRtmpClient::close()
{
kbps->set_io(NULL, NULL);
srs_freep(client);
srs_freep(transport);
kbps_->set_io(NULL, NULL);
srs_freep(client_);
srs_freep(transport_);
}
srs_error_t SrsBasicRtmpClient::connect_app()
@ -112,17 +112,17 @@ srs_error_t SrsBasicRtmpClient::do_connect_app(string local_ip, bool debug)
// generate the tcUrl
std::string param = "";
std::string target_vhost = req->vhost;
std::string tc_url = srs_net_url_encode_tcurl("rtmp", req->host, req->vhost, req->app, req->port);
std::string target_vhost = req_->vhost_;
std::string tc_url = srs_net_url_encode_tcurl("rtmp", req_->host_, req_->vhost_, req_->app_, req_->port_);
// replace the tcUrl in request,
// which will replace the tc_url in client.connect_app().
req->tcUrl = tc_url;
req_->tcUrl_ = tc_url;
// upnode server identity will show in the connect_app of client.
// the debug_srs_upnode is config in vhost and default to true.
SrsServerInfo si;
if ((err = client->connect_app(req->app, tc_url, req, debug, &si)) != srs_success) {
if ((err = client_->connect_app(req_->app_, tc_url, req_, debug, &si)) != srs_success) {
return srs_error_wrap(err, "connect app tcUrl=%s, debug=%d", tc_url.c_str(), debug);
}
@ -134,7 +134,7 @@ srs_error_t SrsBasicRtmpClient::publish(int chunk_size, bool with_vhost, std::st
srs_error_t err = srs_success;
// Pass params in stream, @see https://github.com/ossrs/srs/issues/1031#issuecomment-409745733
string stream = srs_net_url_encode_stream(req->host, req->vhost, req->stream, req->param, with_vhost);
string stream = srs_net_url_encode_stream(req_->host_, req_->vhost_, req_->stream_, req_->param_, with_vhost);
// Return the generated stream.
if (pstream) {
@ -142,8 +142,8 @@ srs_error_t SrsBasicRtmpClient::publish(int chunk_size, bool with_vhost, std::st
}
// publish.
if ((err = client->publish(stream, stream_id, chunk_size)) != srs_success) {
return srs_error_wrap(err, "publish failed, stream=%s, stream_id=%d", stream.c_str(), stream_id);
if ((err = client_->publish(stream, stream_id_, chunk_size)) != srs_success) {
return srs_error_wrap(err, "publish failed, stream=%s, stream_id=%d", stream.c_str(), stream_id_);
}
return err;
@ -154,15 +154,15 @@ srs_error_t SrsBasicRtmpClient::play(int chunk_size, bool with_vhost, std::strin
srs_error_t err = srs_success;
// Pass params in stream, @see https://github.com/ossrs/srs/issues/1031#issuecomment-409745733
string stream = srs_net_url_encode_stream(req->host, req->vhost, req->stream, req->param, with_vhost);
string stream = srs_net_url_encode_stream(req_->host_, req_->vhost_, req_->stream_, req_->param_, with_vhost);
// Return the generated stream.
if (pstream) {
*pstream = stream;
}
if ((err = client->play(stream, stream_id, chunk_size)) != srs_success) {
return srs_error_wrap(err, "connect with server failed, stream=%s, stream_id=%d", stream.c_str(), stream_id);
if ((err = client_->play(stream, stream_id_, chunk_size)) != srs_success) {
return srs_error_wrap(err, "connect with server failed, stream=%s, stream_id=%d", stream.c_str(), stream_id_);
}
return err;
@ -170,58 +170,58 @@ srs_error_t SrsBasicRtmpClient::play(int chunk_size, bool with_vhost, std::strin
void SrsBasicRtmpClient::kbps_sample(const char *label, srs_utime_t age)
{
kbps->sample();
kbps_->sample();
int sr = kbps->get_send_kbps();
int sr30s = kbps->get_send_kbps_30s();
int sr5m = kbps->get_send_kbps_5m();
int rr = kbps->get_recv_kbps();
int rr30s = kbps->get_recv_kbps_30s();
int rr5m = kbps->get_recv_kbps_5m();
int sr = kbps_->get_send_kbps();
int sr30s = kbps_->get_send_kbps_30s();
int sr5m = kbps_->get_send_kbps_5m();
int rr = kbps_->get_recv_kbps();
int rr30s = kbps_->get_recv_kbps_30s();
int rr5m = kbps_->get_recv_kbps_5m();
srs_trace("<- %s time=%" PRId64 ", okbps=%d,%d,%d, ikbps=%d,%d,%d", label, srsu2ms(age), sr, sr30s, sr5m, rr, rr30s, rr5m);
}
void SrsBasicRtmpClient::kbps_sample(const char *label, srs_utime_t age, int msgs)
{
kbps->sample();
kbps_->sample();
int sr = kbps->get_send_kbps();
int sr30s = kbps->get_send_kbps_30s();
int sr5m = kbps->get_send_kbps_5m();
int rr = kbps->get_recv_kbps();
int rr30s = kbps->get_recv_kbps_30s();
int rr5m = kbps->get_recv_kbps_5m();
int sr = kbps_->get_send_kbps();
int sr30s = kbps_->get_send_kbps_30s();
int sr5m = kbps_->get_send_kbps_5m();
int rr = kbps_->get_recv_kbps();
int rr30s = kbps_->get_recv_kbps_30s();
int rr5m = kbps_->get_recv_kbps_5m();
srs_trace("<- %s time=%" PRId64 ", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d", label, srsu2ms(age), msgs, sr, sr30s, sr5m, rr, rr30s, rr5m);
}
int SrsBasicRtmpClient::sid()
{
return stream_id;
return stream_id_;
}
srs_error_t SrsBasicRtmpClient::recv_message(SrsRtmpCommonMessage **pmsg)
{
return client->recv_message(pmsg);
return client_->recv_message(pmsg);
}
srs_error_t SrsBasicRtmpClient::decode_message(SrsRtmpCommonMessage *msg, SrsRtmpCommand **ppacket)
{
return client->decode_message(msg, ppacket);
return client_->decode_message(msg, ppacket);
}
srs_error_t SrsBasicRtmpClient::send_and_free_messages(SrsMediaPacket **msgs, int nb_msgs)
{
return client->send_and_free_messages(msgs, nb_msgs, stream_id);
return client_->send_and_free_messages(msgs, nb_msgs, stream_id_);
}
srs_error_t SrsBasicRtmpClient::send_and_free_message(SrsMediaPacket *msg)
{
return client->send_and_free_message(msg, stream_id);
return client_->send_and_free_message(msg, stream_id_);
}
void SrsBasicRtmpClient::set_recv_timeout(srs_utime_t timeout)
{
transport->set_recv_timeout(timeout);
transport_->set_recv_timeout(timeout);
}

View File

@ -31,18 +31,18 @@ class SrsAmf0Object;
class SrsBasicRtmpClient
{
private:
std::string url;
srs_utime_t connect_timeout;
srs_utime_t stream_timeout;
std::string url_;
srs_utime_t connect_timeout_;
srs_utime_t stream_timeout_;
protected:
ISrsRequest *req;
ISrsRequest *req_;
private:
SrsTcpClient *transport;
SrsRtmpClient *client;
SrsNetworkKbps *kbps;
int stream_id;
SrsTcpClient *transport_;
SrsRtmpClient *client_;
SrsNetworkKbps *kbps_;
int stream_id_;
public:
// Constructor.

View File

@ -331,39 +331,39 @@ srs_error_t SrsDH::do_initialize()
return err;
}
key_block::key_block()
SrsKeyBlock::SrsKeyBlock()
{
offset = (int32_t)srs_rand_integer();
random0 = NULL;
random1 = NULL;
offset_ = (int32_t)srs_rand_integer();
random0_ = NULL;
random1_ = NULL;
int valid_offset = calc_valid_offset();
srs_assert(valid_offset >= 0);
random0_size = valid_offset;
if (random0_size > 0) {
random0 = new char[random0_size];
srs_rand_gen_bytes(random0, random0_size);
snprintf(random0, random0_size, "%s", RTMP_SIG_SRS_HANDSHAKE);
random0_size_ = valid_offset;
if (random0_size_ > 0) {
random0_ = new char[random0_size_];
srs_rand_gen_bytes(random0_, random0_size_);
snprintf(random0_, random0_size_, "%s", RTMP_SIG_SRS_HANDSHAKE);
}
srs_rand_gen_bytes(key, sizeof(key));
srs_rand_gen_bytes(key_, sizeof(key_));
random1_size = 764 - valid_offset - 128 - 4;
if (random1_size > 0) {
random1 = new char[random1_size];
srs_rand_gen_bytes(random1, random1_size);
snprintf(random1, random1_size, "%s", RTMP_SIG_SRS_HANDSHAKE);
random1_size_ = 764 - valid_offset - 128 - 4;
if (random1_size_ > 0) {
random1_ = new char[random1_size_];
srs_rand_gen_bytes(random1_, random1_size_);
snprintf(random1_, random1_size_, "%s", RTMP_SIG_SRS_HANDSHAKE);
}
}
key_block::~key_block()
SrsKeyBlock::~SrsKeyBlock()
{
srs_freepa(random0);
srs_freepa(random1);
srs_freepa(random0_);
srs_freepa(random1_);
}
srs_error_t key_block::parse(SrsBuffer *stream)
srs_error_t SrsKeyBlock::parse(SrsBuffer *stream)
{
srs_error_t err = srs_success;
@ -372,7 +372,7 @@ srs_error_t key_block::parse(SrsBuffer *stream)
// read the last offset first, 760-763
stream->skip(764 - sizeof(int32_t));
offset = stream->read_4bytes();
offset_ = stream->read_4bytes();
// reset stream to read others.
stream->skip(-764);
@ -380,31 +380,31 @@ srs_error_t key_block::parse(SrsBuffer *stream)
int valid_offset = calc_valid_offset();
srs_assert(valid_offset >= 0);
random0_size = valid_offset;
if (random0_size > 0) {
srs_freepa(random0);
random0 = new char[random0_size];
stream->read_bytes(random0, random0_size);
random0_size_ = valid_offset;
if (random0_size_ > 0) {
srs_freepa(random0_);
random0_ = new char[random0_size_];
stream->read_bytes(random0_, random0_size_);
}
stream->read_bytes(key, 128);
stream->read_bytes(key_, 128);
random1_size = 764 - valid_offset - 128 - 4;
if (random1_size > 0) {
srs_freepa(random1);
random1 = new char[random1_size];
stream->read_bytes(random1, random1_size);
random1_size_ = 764 - valid_offset - 128 - 4;
if (random1_size_ > 0) {
srs_freepa(random1_);
random1_ = new char[random1_size_];
stream->read_bytes(random1_, random1_size_);
}
return err;
}
int key_block::calc_valid_offset()
int SrsKeyBlock::calc_valid_offset()
{
int max_offset_size = 764 - 128 - 4;
int valid_offset = 0;
uint8_t *pp = (uint8_t *)&offset;
uint8_t *pp = (uint8_t *)&offset_;
valid_offset += *pp++;
valid_offset += *pp++;
valid_offset += *pp++;
@ -413,75 +413,75 @@ int key_block::calc_valid_offset()
return valid_offset % max_offset_size;
}
digest_block::digest_block()
SrsDigestBlock::SrsDigestBlock()
{
offset = (int32_t)srs_rand_integer();
random0 = NULL;
random1 = NULL;
offset_ = (int32_t)srs_rand_integer();
random0_ = NULL;
random1_ = NULL;
int valid_offset = calc_valid_offset();
srs_assert(valid_offset >= 0);
random0_size = valid_offset;
if (random0_size > 0) {
random0 = new char[random0_size];
srs_rand_gen_bytes(random0, random0_size);
snprintf(random0, random0_size, "%s", RTMP_SIG_SRS_HANDSHAKE);
random0_size_ = valid_offset;
if (random0_size_ > 0) {
random0_ = new char[random0_size_];
srs_rand_gen_bytes(random0_, random0_size_);
snprintf(random0_, random0_size_, "%s", RTMP_SIG_SRS_HANDSHAKE);
}
srs_rand_gen_bytes(digest, sizeof(digest));
srs_rand_gen_bytes(digest_, sizeof(digest_));
random1_size = 764 - 4 - valid_offset - 32;
if (random1_size > 0) {
random1 = new char[random1_size];
srs_rand_gen_bytes(random1, random1_size);
snprintf(random1, random1_size, "%s", RTMP_SIG_SRS_HANDSHAKE);
random1_size_ = 764 - 4 - valid_offset - 32;
if (random1_size_ > 0) {
random1_ = new char[random1_size_];
srs_rand_gen_bytes(random1_, random1_size_);
snprintf(random1_, random1_size_, "%s", RTMP_SIG_SRS_HANDSHAKE);
}
}
digest_block::~digest_block()
SrsDigestBlock::~SrsDigestBlock()
{
srs_freepa(random0);
srs_freepa(random1);
srs_freepa(random0_);
srs_freepa(random1_);
}
srs_error_t digest_block::parse(SrsBuffer *stream)
srs_error_t SrsDigestBlock::parse(SrsBuffer *stream)
{
srs_error_t err = srs_success;
// the digest must be 764 bytes.
srs_assert(stream->require(764));
offset = stream->read_4bytes();
offset_ = stream->read_4bytes();
int valid_offset = calc_valid_offset();
srs_assert(valid_offset >= 0);
random0_size = valid_offset;
if (random0_size > 0) {
srs_freepa(random0);
random0 = new char[random0_size];
stream->read_bytes(random0, random0_size);
random0_size_ = valid_offset;
if (random0_size_ > 0) {
srs_freepa(random0_);
random0_ = new char[random0_size_];
stream->read_bytes(random0_, random0_size_);
}
stream->read_bytes(digest, 32);
stream->read_bytes(digest_, 32);
random1_size = 764 - 4 - valid_offset - 32;
if (random1_size > 0) {
srs_freepa(random1);
random1 = new char[random1_size];
stream->read_bytes(random1, random1_size);
random1_size_ = 764 - 4 - valid_offset - 32;
if (random1_size_ > 0) {
srs_freepa(random1_);
random1_ = new char[random1_size_];
stream->read_bytes(random1_, random1_size_);
}
return err;
}
int digest_block::calc_valid_offset()
int SrsDigestBlock::calc_valid_offset()
{
int max_offset_size = 764 - 32 - 4;
int valid_offset = 0;
uint8_t *pp = (uint8_t *)&offset;
uint8_t *pp = (uint8_t *)&offset_;
valid_offset += *pp++;
valid_offset += *pp++;
valid_offset += *pp++;
@ -490,31 +490,31 @@ int digest_block::calc_valid_offset()
return valid_offset % max_offset_size;
}
c1s1_strategy::c1s1_strategy()
SrsC1S1Strategy::SrsC1S1Strategy()
{
}
c1s1_strategy::~c1s1_strategy()
SrsC1S1Strategy::~SrsC1S1Strategy()
{
}
char *c1s1_strategy::get_digest()
char *SrsC1S1Strategy::get_digest()
{
return digest.digest;
return digest_.digest_;
}
char *c1s1_strategy::get_key()
char *SrsC1S1Strategy::get_key()
{
return key.key;
return key_.key_;
}
srs_error_t c1s1_strategy::dump(c1s1 *owner, char *_c1s1, int size)
srs_error_t SrsC1S1Strategy::dump(SrsC1S1 *owner, char *_c1s1, int size)
{
srs_assert(size == 1536);
return copy_to(owner, _c1s1, size, true);
}
srs_error_t c1s1_strategy::c1_create(c1s1 *owner)
srs_error_t SrsC1S1Strategy::c1_create(SrsC1S1 *owner)
{
srs_error_t err = srs_success;
@ -528,12 +528,12 @@ srs_error_t c1s1_strategy::c1_create(c1s1 *owner)
srs_assert(c1_digest_raw != NULL);
SrsUniquePtr<char[]> c1_digest(c1_digest_raw);
memcpy(digest.digest, c1_digest.get(), 32);
memcpy(digest_.digest_, c1_digest.get(), 32);
return err;
}
srs_error_t c1s1_strategy::c1_validate_digest(c1s1 *owner, bool &is_valid)
srs_error_t SrsC1S1Strategy::c1_validate_digest(SrsC1S1 *owner, bool &is_valid)
{
srs_error_t err = srs_success;
@ -546,12 +546,12 @@ srs_error_t c1s1_strategy::c1_validate_digest(c1s1 *owner, bool &is_valid)
srs_assert(c1_digest_raw != NULL);
SrsUniquePtr<char[]> c1_digest(c1_digest_raw);
is_valid = srs_bytes_equal(digest.digest, c1_digest.get(), 32);
is_valid = srs_bytes_equal(digest_.digest_, c1_digest.get(), 32);
return err;
}
srs_error_t c1s1_strategy::s1_create(c1s1 *owner, c1s1 *c1)
srs_error_t SrsC1S1Strategy::s1_create(SrsC1S1 *owner, SrsC1S1 *c1)
{
srs_error_t err = srs_success;
@ -564,7 +564,7 @@ srs_error_t c1s1_strategy::s1_create(c1s1 *owner, c1s1 *c1)
// directly generate the public key.
int pkey_size = 128;
if ((err = dh.copy_shared_key(c1->get_key(), 128, key.key, pkey_size)) != srs_success) {
if ((err = dh.copy_shared_key(c1->get_key(), 128, key_.key_, pkey_size)) != srs_success) {
return srs_error_wrap(err, "copy shared key");
}
@ -581,12 +581,12 @@ srs_error_t c1s1_strategy::s1_create(c1s1 *owner, c1s1 *c1)
srs_assert(s1_digest_raw != NULL);
SrsUniquePtr<char[]> s1_digest(s1_digest_raw);
memcpy(digest.digest, s1_digest.get(), 32);
memcpy(digest_.digest_, s1_digest.get(), 32);
return err;
}
srs_error_t c1s1_strategy::s1_validate_digest(c1s1 *owner, bool &is_valid)
srs_error_t SrsC1S1Strategy::s1_validate_digest(SrsC1S1 *owner, bool &is_valid)
{
srs_error_t err = srs_success;
@ -599,12 +599,12 @@ srs_error_t c1s1_strategy::s1_validate_digest(c1s1 *owner, bool &is_valid)
srs_assert(s1_digest_raw != NULL);
SrsUniquePtr<char[]> s1_digest(s1_digest_raw);
is_valid = srs_bytes_equal(digest.digest, s1_digest.get(), 32);
is_valid = srs_bytes_equal(digest_.digest_, s1_digest.get(), 32);
return err;
}
srs_error_t c1s1_strategy::calc_c1_digest(c1s1 *owner, char *&c1_digest)
srs_error_t SrsC1S1Strategy::calc_c1_digest(SrsC1S1 *owner, char *&c1_digest)
{
srs_error_t err = srs_success;
@ -627,7 +627,7 @@ srs_error_t c1s1_strategy::calc_c1_digest(c1s1 *owner, char *&c1_digest)
return err;
}
srs_error_t c1s1_strategy::calc_s1_digest(c1s1 *owner, char *&s1_digest)
srs_error_t SrsC1S1Strategy::calc_s1_digest(SrsC1S1 *owner, char *&s1_digest)
{
srs_error_t err = srs_success;
@ -650,43 +650,43 @@ srs_error_t c1s1_strategy::calc_s1_digest(c1s1 *owner, char *&s1_digest)
return err;
}
void c1s1_strategy::copy_time_version(SrsBuffer *stream, c1s1 *owner)
void SrsC1S1Strategy::copy_time_version(SrsBuffer *stream, SrsC1S1 *owner)
{
srs_assert(stream->require(8));
// 4bytes time
stream->write_4bytes(owner->time);
stream->write_4bytes(owner->time_);
// 4bytes version
stream->write_4bytes(owner->version);
stream->write_4bytes(owner->version_);
}
void c1s1_strategy::copy_key(SrsBuffer *stream)
void SrsC1S1Strategy::copy_key(SrsBuffer *stream)
{
srs_assert(key.random0_size >= 0);
srs_assert(key.random1_size >= 0);
srs_assert(key_.random0_size_ >= 0);
srs_assert(key_.random1_size_ >= 0);
int total = key.random0_size + 128 + key.random1_size + 4;
int total = key_.random0_size_ + 128 + key_.random1_size_ + 4;
srs_assert(stream->require(total));
// 764bytes key block
if (key.random0_size > 0) {
stream->write_bytes(key.random0, key.random0_size);
if (key_.random0_size_ > 0) {
stream->write_bytes(key_.random0_, key_.random0_size_);
}
stream->write_bytes(key.key, 128);
stream->write_bytes(key_.key_, 128);
if (key.random1_size > 0) {
stream->write_bytes(key.random1, key.random1_size);
if (key_.random1_size_ > 0) {
stream->write_bytes(key_.random1_, key_.random1_size_);
}
stream->write_4bytes(key.offset);
stream->write_4bytes(key_.offset_);
}
void c1s1_strategy::copy_digest(SrsBuffer *stream, bool with_digest)
void SrsC1S1Strategy::copy_digest(SrsBuffer *stream, bool with_digest)
{
srs_assert(key.random0_size >= 0);
srs_assert(key.random1_size >= 0);
srs_assert(key_.random0_size_ >= 0);
srs_assert(key_.random1_size_ >= 0);
int total = 4 + digest.random0_size + digest.random1_size;
int total = 4 + digest_.random0_size_ + digest_.random1_size_;
if (with_digest) {
total += 32;
}
@ -694,38 +694,38 @@ void c1s1_strategy::copy_digest(SrsBuffer *stream, bool with_digest)
// 732bytes digest block without the 32bytes digest-data
// nbytes digest block part1
stream->write_4bytes(digest.offset);
stream->write_4bytes(digest_.offset_);
// digest random padding.
if (digest.random0_size > 0) {
stream->write_bytes(digest.random0, digest.random0_size);
if (digest_.random0_size_ > 0) {
stream->write_bytes(digest_.random0_, digest_.random0_size_);
}
// digest
if (with_digest) {
stream->write_bytes(digest.digest, 32);
stream->write_bytes(digest_.digest_, 32);
}
// nbytes digest block part2
if (digest.random1_size > 0) {
stream->write_bytes(digest.random1, digest.random1_size);
if (digest_.random1_size_ > 0) {
stream->write_bytes(digest_.random1_, digest_.random1_size_);
}
}
c1s1_strategy_schema0::c1s1_strategy_schema0()
SrsC1S1StrategySchema0::SrsC1S1StrategySchema0()
{
}
c1s1_strategy_schema0::~c1s1_strategy_schema0()
SrsC1S1StrategySchema0::~SrsC1S1StrategySchema0()
{
}
srs_schema_type c1s1_strategy_schema0::schema()
srs_schema_type SrsC1S1StrategySchema0::schema()
{
return srs_schema0;
}
srs_error_t c1s1_strategy_schema0::parse(char *_c1s1, int size)
srs_error_t SrsC1S1StrategySchema0::parse(char *_c1s1, int size)
{
srs_error_t err = srs_success;
@ -734,7 +734,7 @@ srs_error_t c1s1_strategy_schema0::parse(char *_c1s1, int size)
if (true) {
SrsBuffer stream(_c1s1 + 8, 764);
if ((err = key.parse(&stream)) != srs_success) {
if ((err = key_.parse(&stream)) != srs_success) {
return srs_error_wrap(err, "parse the c1 key");
}
}
@ -742,7 +742,7 @@ srs_error_t c1s1_strategy_schema0::parse(char *_c1s1, int size)
if (true) {
SrsBuffer stream(_c1s1 + 8 + 764, 764);
if ((err = digest.parse(&stream)) != srs_success) {
if ((err = digest_.parse(&stream)) != srs_success) {
return srs_error_wrap(err, "parse the c1 digest");
}
}
@ -750,7 +750,7 @@ srs_error_t c1s1_strategy_schema0::parse(char *_c1s1, int size)
return err;
}
srs_error_t c1s1_strategy_schema0::copy_to(c1s1 *owner, char *bytes, int size, bool with_digest)
srs_error_t SrsC1S1StrategySchema0::copy_to(SrsC1S1 *owner, char *bytes, int size, bool with_digest)
{
srs_error_t err = srs_success;
@ -771,20 +771,20 @@ srs_error_t c1s1_strategy_schema0::copy_to(c1s1 *owner, char *bytes, int size, b
return err;
}
c1s1_strategy_schema1::c1s1_strategy_schema1()
SrsC1S1StrategySchema1::SrsC1S1StrategySchema1()
{
}
c1s1_strategy_schema1::~c1s1_strategy_schema1()
SrsC1S1StrategySchema1::~SrsC1S1StrategySchema1()
{
}
srs_schema_type c1s1_strategy_schema1::schema()
srs_schema_type SrsC1S1StrategySchema1::schema()
{
return srs_schema1;
}
srs_error_t c1s1_strategy_schema1::parse(char *_c1s1, int size)
srs_error_t SrsC1S1StrategySchema1::parse(char *_c1s1, int size)
{
srs_error_t err = srs_success;
@ -793,7 +793,7 @@ srs_error_t c1s1_strategy_schema1::parse(char *_c1s1, int size)
if (true) {
SrsBuffer stream(_c1s1 + 8, 764);
if ((err = digest.parse(&stream)) != srs_success) {
if ((err = digest_.parse(&stream)) != srs_success) {
return srs_error_wrap(err, "parse c1 digest");
}
}
@ -801,7 +801,7 @@ srs_error_t c1s1_strategy_schema1::parse(char *_c1s1, int size)
if (true) {
SrsBuffer stream(_c1s1 + 8 + 764, 764);
if ((err = key.parse(&stream)) != srs_success) {
if ((err = key_.parse(&stream)) != srs_success) {
return srs_error_wrap(err, "parse c1 key");
}
}
@ -809,7 +809,7 @@ srs_error_t c1s1_strategy_schema1::parse(char *_c1s1, int size)
return err;
}
srs_error_t c1s1_strategy_schema1::copy_to(c1s1 *owner, char *bytes, int size, bool with_digest)
srs_error_t SrsC1S1StrategySchema1::copy_to(SrsC1S1 *owner, char *bytes, int size, bool with_digest)
{
srs_error_t err = srs_success;
@ -830,43 +830,43 @@ srs_error_t c1s1_strategy_schema1::copy_to(c1s1 *owner, char *bytes, int size, b
return err;
}
c1s1::c1s1()
SrsC1S1::SrsC1S1()
{
payload = NULL;
version = 0;
time = 0;
payload_ = NULL;
version_ = 0;
time_ = 0;
}
c1s1::~c1s1()
SrsC1S1::~SrsC1S1()
{
srs_freep(payload);
srs_freep(payload_);
}
srs_schema_type c1s1::schema()
srs_schema_type SrsC1S1::schema()
{
srs_assert(payload != NULL);
return payload->schema();
srs_assert(payload_ != NULL);
return payload_->schema();
}
char *c1s1::get_digest()
char *SrsC1S1::get_digest()
{
srs_assert(payload != NULL);
return payload->get_digest();
srs_assert(payload_ != NULL);
return payload_->get_digest();
}
char *c1s1::get_key()
char *SrsC1S1::get_key()
{
srs_assert(payload != NULL);
return payload->get_key();
srs_assert(payload_ != NULL);
return payload_->get_key();
}
srs_error_t c1s1::dump(char *_c1s1, int size)
srs_error_t SrsC1S1::dump(char *_c1s1, int size)
{
srs_assert(size == 1536);
srs_assert(payload != NULL);
return payload->dump(this, _c1s1, size);
srs_assert(payload_ != NULL);
return payload_->dump(this, _c1s1, size);
}
srs_error_t c1s1::parse(char *_c1s1, int size, srs_schema_type schema)
srs_error_t SrsC1S1::parse(char *_c1s1, int size, srs_schema_type schema)
{
srs_assert(size == 1536);
@ -876,109 +876,109 @@ srs_error_t c1s1::parse(char *_c1s1, int size, srs_schema_type schema)
SrsBuffer stream(_c1s1, size);
time = stream.read_4bytes();
version = stream.read_4bytes(); // client c1 version
time_ = stream.read_4bytes();
version_ = stream.read_4bytes(); // client c1 version
srs_freep(payload);
srs_freep(payload_);
if (schema == srs_schema0) {
payload = new c1s1_strategy_schema0();
payload_ = new SrsC1S1StrategySchema0();
} else {
payload = new c1s1_strategy_schema1();
payload_ = new SrsC1S1StrategySchema1();
}
return payload->parse(_c1s1, size);
return payload_->parse(_c1s1, size);
}
srs_error_t c1s1::c1_create(srs_schema_type schema)
srs_error_t SrsC1S1::c1_create(srs_schema_type schema)
{
if (schema != srs_schema0 && schema != srs_schema1) {
return srs_error_new(ERROR_RTMP_CH_SCHEMA, "create c1 failed. invalid schema=%d", schema);
}
// client c1 time and version
time = (int32_t)::time(NULL);
version = 0x80000702; // client c1 version
time_ = (int32_t)::time(NULL);
version_ = 0x80000702; // client c1 version
// generate signature by schema
srs_freep(payload);
srs_freep(payload_);
if (schema == srs_schema0) {
payload = new c1s1_strategy_schema0();
payload_ = new SrsC1S1StrategySchema0();
} else {
payload = new c1s1_strategy_schema1();
payload_ = new SrsC1S1StrategySchema1();
}
return payload->c1_create(this);
return payload_->c1_create(this);
}
srs_error_t c1s1::c1_validate_digest(bool &is_valid)
srs_error_t SrsC1S1::c1_validate_digest(bool &is_valid)
{
is_valid = false;
srs_assert(payload);
return payload->c1_validate_digest(this, is_valid);
srs_assert(payload_);
return payload_->c1_validate_digest(this, is_valid);
}
srs_error_t c1s1::s1_create(c1s1 *c1)
srs_error_t SrsC1S1::s1_create(SrsC1S1 *c1)
{
if (c1->schema() != srs_schema0 && c1->schema() != srs_schema1) {
return srs_error_new(ERROR_RTMP_CH_SCHEMA, "create s1 failed. invalid schema=%d", c1->schema());
}
time = ::time(NULL);
version = 0x01000504; // server s1 version
time_ = ::time(NULL);
version_ = 0x01000504; // server s1 version
srs_freep(payload);
srs_freep(payload_);
if (c1->schema() == srs_schema0) {
payload = new c1s1_strategy_schema0();
payload_ = new SrsC1S1StrategySchema0();
} else {
payload = new c1s1_strategy_schema1();
payload_ = new SrsC1S1StrategySchema1();
}
return payload->s1_create(this, c1);
return payload_->s1_create(this, c1);
}
srs_error_t c1s1::s1_validate_digest(bool &is_valid)
srs_error_t SrsC1S1::s1_validate_digest(bool &is_valid)
{
is_valid = false;
srs_assert(payload);
return payload->s1_validate_digest(this, is_valid);
srs_assert(payload_);
return payload_->s1_validate_digest(this, is_valid);
}
c2s2::c2s2()
SrsC2S2::SrsC2S2()
{
srs_rand_gen_bytes(random, 1504);
srs_rand_gen_bytes(random_, 1504);
int size = snprintf(random, 1504, "%s", RTMP_SIG_SRS_HANDSHAKE);
int size = snprintf(random_, 1504, "%s", RTMP_SIG_SRS_HANDSHAKE);
srs_assert(size > 0 && size < 1504);
snprintf(random + 1504 - size, size, "%s", RTMP_SIG_SRS_HANDSHAKE);
snprintf(random_ + 1504 - size, size, "%s", RTMP_SIG_SRS_HANDSHAKE);
srs_rand_gen_bytes(digest, 32);
srs_rand_gen_bytes(digest_, 32);
}
c2s2::~c2s2()
SrsC2S2::~SrsC2S2()
{
}
srs_error_t c2s2::dump(char *_c2s2, int size)
srs_error_t SrsC2S2::dump(char *_c2s2, int size)
{
srs_assert(size == 1536);
memcpy(_c2s2, random, 1504);
memcpy(_c2s2 + 1504, digest, 32);
memcpy(_c2s2, random_, 1504);
memcpy(_c2s2 + 1504, digest_, 32);
return srs_success;
}
srs_error_t c2s2::parse(char *_c2s2, int size)
srs_error_t SrsC2S2::parse(char *_c2s2, int size)
{
srs_assert(size == 1536);
memcpy(random, _c2s2, 1504);
memcpy(digest, _c2s2 + 1504, 32);
memcpy(random_, _c2s2, 1504);
memcpy(digest_, _c2s2 + 1504, 32);
return srs_success;
}
srs_error_t c2s2::c2_create(c1s1 *s1)
srs_error_t SrsC2S2::c2_create(SrsC1S1 *s1)
{
srs_error_t err = srs_success;
@ -988,16 +988,16 @@ srs_error_t c2s2::c2_create(c1s1 *s1)
}
char _digest[SRS_OpensslHashSize];
if ((err = openssl_HMACsha256(temp_key, 32, random, 1504, _digest)) != srs_success) {
if ((err = openssl_HMACsha256(temp_key, 32, random_, 1504, _digest)) != srs_success) {
return srs_error_wrap(err, "create c2 digest");
}
memcpy(digest, _digest, 32);
memcpy(digest_, _digest, 32);
return err;
}
srs_error_t c2s2::c2_validate(c1s1 *s1, bool &is_valid)
srs_error_t SrsC2S2::c2_validate(SrsC1S1 *s1, bool &is_valid)
{
is_valid = false;
srs_error_t err = srs_success;
@ -1008,16 +1008,16 @@ srs_error_t c2s2::c2_validate(c1s1 *s1, bool &is_valid)
}
char _digest[SRS_OpensslHashSize];
if ((err = openssl_HMACsha256(temp_key, 32, random, 1504, _digest)) != srs_success) {
if ((err = openssl_HMACsha256(temp_key, 32, random_, 1504, _digest)) != srs_success) {
return srs_error_wrap(err, "create c2 digest");
}
is_valid = srs_bytes_equal(digest, _digest, 32);
is_valid = srs_bytes_equal(digest_, _digest, 32);
return err;
}
srs_error_t c2s2::s2_create(c1s1 *c1)
srs_error_t SrsC2S2::s2_create(SrsC1S1 *c1)
{
srs_error_t err = srs_success;
@ -1027,16 +1027,16 @@ srs_error_t c2s2::s2_create(c1s1 *c1)
}
char _digest[SRS_OpensslHashSize];
if ((err = openssl_HMACsha256(temp_key, 32, random, 1504, _digest)) != srs_success) {
if ((err = openssl_HMACsha256(temp_key, 32, random_, 1504, _digest)) != srs_success) {
return srs_error_wrap(err, "create s2 digest");
}
memcpy(digest, _digest, 32);
memcpy(digest_, _digest, 32);
return err;
}
srs_error_t c2s2::s2_validate(c1s1 *c1, bool &is_valid)
srs_error_t SrsC2S2::s2_validate(SrsC1S1 *c1, bool &is_valid)
{
is_valid = false;
srs_error_t err = srs_success;
@ -1047,11 +1047,11 @@ srs_error_t c2s2::s2_validate(c1s1 *c1, bool &is_valid)
}
char _digest[SRS_OpensslHashSize];
if ((err = openssl_HMACsha256(temp_key, 32, random, 1504, _digest)) != srs_success) {
if ((err = openssl_HMACsha256(temp_key, 32, random_, 1504, _digest)) != srs_success) {
return srs_error_wrap(err, "create s2 digest");
}
is_valid = srs_bytes_equal(digest, _digest, 32);
is_valid = srs_bytes_equal(digest_, _digest, 32);
return err;
}
@ -1076,15 +1076,15 @@ srs_error_t SrsSimpleHandshake::handshake_with_client(SrsHandshakeBytes *hs_byte
}
// plain text required.
if (hs_bytes->c0c1[0] != 0x03) {
return srs_error_new(ERROR_RTMP_PLAIN_REQUIRED, "only support rtmp plain text, version=%X", (uint8_t)hs_bytes->c0c1[0]);
if (hs_bytes->c0c1_[0] != 0x03) {
return srs_error_new(ERROR_RTMP_PLAIN_REQUIRED, "only support rtmp plain text, version=%X", (uint8_t)hs_bytes->c0c1_[0]);
}
if ((err = hs_bytes->create_s0s1s2(hs_bytes->c0c1 + 1)) != srs_success) {
if ((err = hs_bytes->create_s0s1s2(hs_bytes->c0c1_ + 1)) != srs_success) {
return srs_error_wrap(err, "create s0s1s2");
}
if ((err = io->write(hs_bytes->s0s1s2, 3073, &nsize)) != srs_success) {
if ((err = io->write(hs_bytes->s0s1s2_, 3073, &nsize)) != srs_success) {
return srs_error_wrap(err, "write s0s1s2");
}
@ -1108,7 +1108,7 @@ srs_error_t SrsSimpleHandshake::handshake_with_server(SrsHandshakeBytes *hs_byte
return srs_error_wrap(err, "create c0c1");
}
if ((err = io->write(hs_bytes->c0c1, 1537, &nsize)) != srs_success) {
if ((err = io->write(hs_bytes->c0c1_, 1537, &nsize)) != srs_success) {
return srs_error_wrap(err, "write c0c1");
}
@ -1117,8 +1117,8 @@ srs_error_t SrsSimpleHandshake::handshake_with_server(SrsHandshakeBytes *hs_byte
}
// plain text required.
if (hs_bytes->s0s1s2[0] != 0x03) {
return srs_error_new(ERROR_RTMP_HANDSHAKE, "handshake failed, plain text required, version=%X", (uint8_t)hs_bytes->s0s1s2[0]);
if (hs_bytes->s0s1s2_[0] != 0x03) {
return srs_error_new(ERROR_RTMP_HANDSHAKE, "handshake failed, plain text required, version=%X", (uint8_t)hs_bytes->s0s1s2_[0]);
}
if ((err = hs_bytes->create_c2()) != srs_success) {
@ -1127,9 +1127,9 @@ srs_error_t SrsSimpleHandshake::handshake_with_server(SrsHandshakeBytes *hs_byte
// for simple handshake, copy s1 to c2.
// @see https://github.com/ossrs/srs/issues/418
memcpy(hs_bytes->c2, hs_bytes->s0s1s2 + 1, 1536);
memcpy(hs_bytes->c2_, hs_bytes->s0s1s2_ + 1, 1536);
if ((err = io->write(hs_bytes->c2, 1536, &nsize)) != srs_success) {
if ((err = io->write(hs_bytes->c2_, 1536, &nsize)) != srs_success) {
return srs_error_wrap(err, "write c2");
}
@ -1157,10 +1157,10 @@ srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes *hs_byt
}
// decode c1
c1s1 c1;
SrsC1S1 c1;
// try schema0.
// @remark, use schema0 to make flash player happy.
if ((err = c1.parse(hs_bytes->c0c1 + 1, 1536, srs_schema0)) != srs_success) {
if ((err = c1.parse(hs_bytes->c0c1_ + 1, 1536, srs_schema0)) != srs_success) {
return srs_error_wrap(err, "parse c1, schema=%d", srs_schema0);
}
// try schema1
@ -1168,7 +1168,7 @@ srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes *hs_byt
if ((err = c1.c1_validate_digest(is_valid)) != srs_success || !is_valid) {
srs_freep(err);
if ((err = c1.parse(hs_bytes->c0c1 + 1, 1536, srs_schema1)) != srs_success) {
if ((err = c1.parse(hs_bytes->c0c1_ + 1, 1536, srs_schema1)) != srs_success) {
return srs_error_wrap(err, "parse c0c1, schame=%d", srs_schema1);
}
@ -1179,7 +1179,7 @@ srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes *hs_byt
}
// encode s1
c1s1 s1;
SrsC1S1 s1;
if ((err = s1.s1_create(&c1)) != srs_success) {
return srs_error_wrap(err, "create s1 from c1");
}
@ -1189,7 +1189,7 @@ srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes *hs_byt
return srs_error_new(ERROR_RTMP_TRY_SIMPLE_HS, "verify s1 failed, try simple handshake");
}
c2s2 s2;
SrsC2S2 s2;
if ((err = s2.s2_create(&c1)) != srs_success) {
return srs_error_wrap(err, "create s2 from c1");
}
@ -1203,13 +1203,13 @@ srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes *hs_byt
if ((err = hs_bytes->create_s0s1s2()) != srs_success) {
return srs_error_wrap(err, "create s0s1s2");
}
if ((err = s1.dump(hs_bytes->s0s1s2 + 1, 1536)) != srs_success) {
if ((err = s1.dump(hs_bytes->s0s1s2_ + 1, 1536)) != srs_success) {
return srs_error_wrap(err, "dump s1");
}
if ((err = s2.dump(hs_bytes->s0s1s2 + 1537, 1536)) != srs_success) {
if ((err = s2.dump(hs_bytes->s0s1s2_ + 1537, 1536)) != srs_success) {
return srs_error_wrap(err, "dump s2");
}
if ((err = io->write(hs_bytes->s0s1s2, 3073, &nsize)) != srs_success) {
if ((err = io->write(hs_bytes->s0s1s2_, 3073, &nsize)) != srs_success) {
return srs_error_wrap(err, "write s0s1s2");
}
@ -1217,8 +1217,8 @@ srs_error_t SrsComplexHandshake::handshake_with_client(SrsHandshakeBytes *hs_byt
if ((err = hs_bytes->read_c2(io)) != srs_success) {
return srs_error_wrap(err, "read c2");
}
c2s2 c2;
if ((err = c2.parse(hs_bytes->c2, 1536)) != srs_success) {
SrsC2S2 c2;
if ((err = c2.parse(hs_bytes->c2_, 1536)) != srs_success) {
return srs_error_wrap(err, "parse c2");
}
@ -1243,12 +1243,12 @@ srs_error_t SrsComplexHandshake::handshake_with_server(SrsHandshakeBytes *hs_byt
}
// sign c1
c1s1 c1;
SrsC1S1 c1;
// @remark, FMS requires the schema1(digest-key), or connect failed.
if ((err = c1.c1_create(srs_schema1)) != srs_success) {
return srs_error_wrap(err, "create c1");
}
if ((err = c1.dump(hs_bytes->c0c1 + 1, 1536)) != srs_success) {
if ((err = c1.dump(hs_bytes->c0c1_ + 1, 1536)) != srs_success) {
return srs_error_wrap(err, "dump c1");
}
@ -1259,7 +1259,7 @@ srs_error_t SrsComplexHandshake::handshake_with_server(SrsHandshakeBytes *hs_byt
return srs_error_new(ERROR_RTMP_TRY_SIMPLE_HS, "try simple handshake");
}
if ((err = io->write(hs_bytes->c0c1, 1537, &nsize)) != srs_success) {
if ((err = io->write(hs_bytes->c0c1_, 1537, &nsize)) != srs_success) {
return srs_error_wrap(err, "write c0c1");
}
@ -1269,13 +1269,13 @@ srs_error_t SrsComplexHandshake::handshake_with_server(SrsHandshakeBytes *hs_byt
}
// plain text required.
if (hs_bytes->s0s1s2[0] != 0x03) {
return srs_error_new(ERROR_RTMP_HANDSHAKE, "handshake failed, plain text required, version=%X", (uint8_t)hs_bytes->s0s1s2[0]);
if (hs_bytes->s0s1s2_[0] != 0x03) {
return srs_error_new(ERROR_RTMP_HANDSHAKE, "handshake failed, plain text required, version=%X", (uint8_t)hs_bytes->s0s1s2_[0]);
}
// verify s1s2
c1s1 s1;
if ((err = s1.parse(hs_bytes->s0s1s2 + 1, 1536, c1.schema())) != srs_success) {
SrsC1S1 s1;
if ((err = s1.parse(hs_bytes->s0s1s2_ + 1, 1536, c1.schema())) != srs_success) {
return srs_error_wrap(err, "parse s1");
}
@ -1288,15 +1288,15 @@ srs_error_t SrsComplexHandshake::handshake_with_server(SrsHandshakeBytes *hs_byt
return srs_error_wrap(err, "create c2");
}
c2s2 c2;
SrsC2S2 c2;
if ((err = c2.c2_create(&s1)) != srs_success) {
return srs_error_wrap(err, "create c2");
}
if ((err = c2.dump(hs_bytes->c2, 1536)) != srs_success) {
if ((err = c2.dump(hs_bytes->c2_, 1536)) != srs_success) {
return srs_error_wrap(err, "dump c2");
}
if ((err = io->write(hs_bytes->c2, 1536, &nsize)) != srs_success) {
if ((err = io->write(hs_bytes->c2_, 1536, &nsize)) != srs_success) {
return srs_error_wrap(err, "write c2");
}

View File

@ -88,26 +88,26 @@ enum srs_schema_type {
// random-data: (764-offset-128-4)bytes
// offset: 4bytes
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class key_block
class SrsKeyBlock
{
public:
// (offset)bytes
char *random0;
int random0_size;
char *random0_;
int random0_size_;
// 128bytes
char key[128];
char key_[128];
// (764-offset-128-4)bytes
char *random1;
int random1_size;
char *random1_;
int random1_size_;
// 4bytes
int32_t offset;
int32_t offset_;
public:
key_block();
virtual ~key_block();
SrsKeyBlock();
virtual ~SrsKeyBlock();
public:
// Parse key block from c1s1.
@ -127,26 +127,26 @@ private:
// digest-data: 32bytes
// random-data: (764-4-offset-32)bytes
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class digest_block
class SrsDigestBlock
{
public:
// 4bytes
int32_t offset;
int32_t offset_;
// (offset)bytes
char *random0;
int random0_size;
char *random0_;
int random0_size_;
// 32bytes
char digest[32];
char digest_[32];
// (764-4-offset-32)bytes
char *random1;
int random1_size;
char *random1_;
int random1_size_;
public:
digest_block();
virtual ~digest_block();
SrsDigestBlock();
virtual ~SrsDigestBlock();
public:
// Parse digest block from c1s1.
@ -160,20 +160,20 @@ private:
int calc_valid_offset();
};
class c1s1;
class SrsC1S1;
// The c1s1 strategy, use schema0 or schema1.
// The template method class to defines common behaviors,
// while the concrete class to implements in schema0 or schema1.
class c1s1_strategy
class SrsC1S1Strategy
{
protected:
key_block key;
digest_block digest;
SrsKeyBlock key_;
SrsDigestBlock digest_;
public:
c1s1_strategy();
virtual ~c1s1_strategy();
SrsC1S1Strategy();
virtual ~SrsC1S1Strategy();
public:
// Get the scema.
@ -184,7 +184,7 @@ public:
virtual char *get_key();
// Copy to bytes.
// @param size must be 1536.
virtual srs_error_t dump(c1s1 *owner, char *_c1s1, int size);
virtual srs_error_t dump(SrsC1S1 *owner, char *_c1s1, int size);
// For server: parse the c1s1, discovery the key and digest by schema.
// use the c1_validate_digest() to valid the digest of c1.
virtual srs_error_t parse(char *_c1s1, int size) = 0;
@ -203,9 +203,9 @@ public:
// schema = choose schema0 or schema1
// digest-data = calc_c1_digest(c1, schema)
// copy digest-data to c1
virtual srs_error_t c1_create(c1s1 *owner);
virtual srs_error_t c1_create(SrsC1S1 *owner);
// For server: validate the parsed c1 schema
virtual srs_error_t c1_validate_digest(c1s1 *owner, bool &is_valid);
virtual srs_error_t c1_validate_digest(SrsC1S1 *owner, bool &is_valid);
// For server: create and sign the s1 from c1.
// // decode c1 try schema0 then schema1
// c1-digest-data = get-c1-digest-data(schema0)
@ -231,20 +231,20 @@ public:
// s1-digest-data = HMACsha256(c1s1-joined, FMSKey, 36)
// copy s1-digest-data and s1-key-data to s1.
// @param c1, to get the peer_pub_key of client.
virtual srs_error_t s1_create(c1s1 *owner, c1s1 *c1);
virtual srs_error_t s1_create(SrsC1S1 *owner, SrsC1S1 *c1);
// For server: validate the parsed s1 schema
virtual srs_error_t s1_validate_digest(c1s1 *owner, bool &is_valid);
virtual srs_error_t s1_validate_digest(SrsC1S1 *owner, bool &is_valid);
public:
// Calculate the digest for c1
virtual srs_error_t calc_c1_digest(c1s1 *owner, char *&c1_digest);
virtual srs_error_t calc_c1_digest(SrsC1S1 *owner, char *&c1_digest);
// Calculate the digest for s1
virtual srs_error_t calc_s1_digest(c1s1 *owner, char *&s1_digest);
virtual srs_error_t calc_s1_digest(SrsC1S1 *owner, char *&s1_digest);
// Copy whole c1s1 to bytes.
// @param size must always be 1536 with digest, and 1504 without digest.
virtual srs_error_t copy_to(c1s1 *owner, char *bytes, int size, bool with_digest) = 0;
virtual srs_error_t copy_to(SrsC1S1 *owner, char *bytes, int size, bool with_digest) = 0;
// Copy time and version to stream.
virtual void copy_time_version(SrsBuffer *stream, c1s1 *owner);
virtual void copy_time_version(SrsBuffer *stream, SrsC1S1 *owner);
// Copy key to stream.
virtual void copy_key(SrsBuffer *stream);
// Copy digest to stream.
@ -254,35 +254,35 @@ public:
// The c1s1 schema0
// key: 764bytes
// digest: 764bytes
class c1s1_strategy_schema0 : public c1s1_strategy
class SrsC1S1StrategySchema0 : public SrsC1S1Strategy
{
public:
c1s1_strategy_schema0();
virtual ~c1s1_strategy_schema0();
SrsC1S1StrategySchema0();
virtual ~SrsC1S1StrategySchema0();
public:
virtual srs_schema_type schema();
virtual srs_error_t parse(char *_c1s1, int size);
public:
virtual srs_error_t copy_to(c1s1 *owner, char *bytes, int size, bool with_digest);
virtual srs_error_t copy_to(SrsC1S1 *owner, char *bytes, int size, bool with_digest);
};
// The c1s1 schema1
// digest: 764bytes
// key: 764bytes
class c1s1_strategy_schema1 : public c1s1_strategy
class SrsC1S1StrategySchema1 : public SrsC1S1Strategy
{
public:
c1s1_strategy_schema1();
virtual ~c1s1_strategy_schema1();
SrsC1S1StrategySchema1();
virtual ~SrsC1S1StrategySchema1();
public:
virtual srs_schema_type schema();
virtual srs_error_t parse(char *_c1s1, int size);
public:
virtual srs_error_t copy_to(c1s1 *owner, char *bytes, int size, bool with_digest);
virtual srs_error_t copy_to(SrsC1S1 *owner, char *bytes, int size, bool with_digest);
};
// The c1s1 schema0
@ -296,19 +296,19 @@ public:
// digest: 764bytes
// key: 764bytes
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class c1s1
class SrsC1S1
{
public:
// 4bytes
int32_t time;
int32_t time_;
// 4bytes
int32_t version;
int32_t version_;
// 764bytes+764bytes
c1s1_strategy *payload;
SrsC1S1Strategy *payload_;
public:
c1s1();
virtual ~c1s1();
SrsC1S1();
virtual ~SrsC1S1();
public:
// Get the scema.
@ -371,7 +371,7 @@ public:
// get c1s1-joined by specified schema
// s1-digest-data = HMACsha256(c1s1-joined, FMSKey, 36)
// copy s1-digest-data and s1-key-data to s1.
virtual srs_error_t s1_create(c1s1 *c1);
virtual srs_error_t s1_create(SrsC1S1 *c1);
// For server: validate the parsed s1 schema
virtual srs_error_t s1_validate_digest(bool &is_valid);
};
@ -380,15 +380,15 @@ public:
// random-data: 1504bytes
// digest-data: 32bytes
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class c2s2
class SrsC2S2
{
public:
char random[1504];
char digest[32];
char random_[1504];
char digest_[32];
public:
c2s2();
virtual ~c2s2();
SrsC2S2();
virtual ~SrsC2S2();
public:
// Copy to bytes.
@ -405,10 +405,10 @@ public:
// // client generate C2, or server valid C2
// temp-key = HMACsha256(s1-digest, FPKey, 62)
// c2-digest-data = HMACsha256(c2-random-data, temp-key, 32)
virtual srs_error_t c2_create(c1s1 *s1);
virtual srs_error_t c2_create(SrsC1S1 *s1);
// Validate the c2 from client.
virtual srs_error_t c2_validate(c1s1 *s1, bool &is_valid);
virtual srs_error_t c2_validate(SrsC1S1 *s1, bool &is_valid);
public:
// Create s2.
@ -417,10 +417,10 @@ public:
// For server generate S2, or client valid S2
// temp-key = HMACsha256(c1-digest, FMSKey, 68)
// s2-digest-data = HMACsha256(s2-random-data, temp-key, 32)
virtual srs_error_t s2_create(c1s1 *c1);
virtual srs_error_t s2_create(SrsC1S1 *c1);
// Validate the s2 from server.
virtual srs_error_t s2_validate(c1s1 *c1, bool &is_valid);
virtual srs_error_t s2_validate(SrsC1S1 *c1, bool &is_valid);
};
} // namespace srs_internal

View File

@ -12,8 +12,8 @@ SrsMessageArray::SrsMessageArray(int max_msgs)
{
srs_assert(max_msgs > 0);
msgs = new SrsMediaPacket *[max_msgs];
max = max_msgs;
msgs_ = new SrsMediaPacket *[max_msgs];
max_ = max_msgs;
zero(max_msgs);
}
@ -23,17 +23,17 @@ SrsMessageArray::~SrsMessageArray()
// we just free the msgs itself,
// both delete and delete[] is ok,
// for all msgs is already freed by send_and_free_messages.
srs_freepa(msgs);
srs_freepa(msgs_);
}
void SrsMessageArray::free(int count)
{
// initialize
for (int i = 0; i < count; i++) {
SrsMediaPacket *msg = msgs[i];
SrsMediaPacket *msg = msgs_[i];
srs_freep(msg);
msgs[i] = NULL;
msgs_[i] = NULL;
}
}
@ -41,6 +41,6 @@ void SrsMessageArray::zero(int count)
{
// initialize
for (int i = 0; i < count; i++) {
msgs[i] = NULL;
msgs_[i] = NULL;
}
}

View File

@ -22,10 +22,10 @@ class SrsMessageArray
{
public:
// When user already send all msgs, please set to NULL,
// for instance, msg= msgs.msgs[i], msgs.msgs[i]=NULL, send(msg),
// for instance, msg= msgs.msgs_[i], msgs.msgs_[i]=NULL, send(msg),
// where send(msg) will always send and free it.
SrsMediaPacket **msgs;
int max;
SrsMediaPacket **msgs_;
int max_;
public:
// Create msg array, initialize array to NULL ptrs.

File diff suppressed because it is too large Load Diff

View File

@ -136,55 +136,55 @@ private:
class AckWindowSize
{
public:
uint32_t window;
uint32_t window_;
// number of received bytes.
int64_t nb_recv_bytes;
int64_t nb_recv_bytes_;
// previous responsed sequence number.
uint32_t sequence_number;
uint32_t sequence_number_;
AckWindowSize();
};
// For peer in/out
private:
// The underlayer socket object, send/recv bytes.
ISrsProtocolReadWriter *skt;
ISrsProtocolReadWriter *skt_;
// The requests sent out, used to build the response.
// key: transactionId
// value: the request command name
std::map<double, std::string> requests;
std::map<double, std::string> requests_;
// For peer in
private:
// The chunk stream to decode RTMP messages.
std::map<int, SrsChunkStream *> chunk_streams;
std::map<int, SrsChunkStream *> chunk_streams_;
// Cache some frequently used chunk header.
// cs_cache, the chunk stream cache.
SrsChunkStream **cs_cache;
SrsChunkStream **cs_cache_;
// The bytes buffer cache, recv from skt, provide services for stream.
SrsFastStream *in_buffer;
SrsFastStream *in_buffer_;
// The input chunk size, default to 128, set by peer packet.
int32_t in_chunk_size;
int32_t in_chunk_size_;
// The input ack window, to response acknowledge to peer,
// For example, to respose the encoder, for server got lots of packets.
AckWindowSize in_ack_size;
AckWindowSize in_ack_size_;
// The output ack window, to require peer to response the ack.
AckWindowSize out_ack_size;
AckWindowSize out_ack_size_;
// The buffer length set by peer.
int32_t in_buffer_length;
int32_t in_buffer_length_;
// Whether print the protocol level debug info.
// Generally we print the debug info when got or send first A/V packet.
bool show_debug_info;
bool show_debug_info_;
// Whether auto response when recv messages.
// default to true for it's very easy to use the protocol stack.
bool auto_response_when_recv;
bool auto_response_when_recv_;
// When not auto response message, manual flush the messages in queue.
std::vector<SrsRtmpCommand *> manual_response_queue;
std::vector<SrsRtmpCommand *> manual_response_queue_;
// For peer out
private:
// Cache for multiple messages send,
// initialize to iovec[SRS_CONSTS_IOVS_MAX] and realloc when consumed,
// it's ok to realloc the iovs cache, for all ptr is ok.
iovec *out_iovs;
int nb_out_iovs;
iovec *out_iovs_;
int nb_out_iovs_;
// The output header cache.
// used for type0, 11bytes(or 15bytes with extended timestamp) header.
// or for type3, 1bytes(or 5bytes with extended timestamp) header.
@ -192,11 +192,11 @@ private:
//
// @remark, the c0c3 cache cannot be realloc.
// To allocate it in heap to make VS2015 happy.
char *out_c0c3_caches;
char *out_c0c3_caches_;
// Whether warned user to increase the c0c3 header cache.
bool warned_c0c3_cache_dry;
bool warned_c0c3_cache_dry_;
// The output chunk size, default to 128, set by config.
int32_t out_chunk_size;
int32_t out_chunk_size_;
public:
SrsProtocol(ISrsProtocolReadWriter *io);
@ -380,25 +380,25 @@ class SrsChunkStream
public:
// Represents the basic header fmt,
// which used to identify the variant message header type.
char fmt;
char fmt_;
// Represents the basic header cid,
// which is the chunk stream id.
int cid;
int cid_;
// Cached message header
SrsMessageHeader header;
SrsMessageHeader header_;
// Whether the chunk message header has extended timestamp.
bool has_extended_timestamp;
bool has_extended_timestamp_;
// The partially read message.
SrsRtmpCommonMessage *msg;
SrsRtmpCommonMessage *msg_;
// Current writing position of message.
char *writing_pos_;
// Decoded msg count, to identify whether the chunk stream is fresh.
int64_t msg_count;
int64_t msg_count_;
// Because the extended timestamp may be a delta timestamp, it can differ
// from the timestamp in the header, so it should be stored as a distinct field
// for comparison with the extended timestamp of subsequent chunks.
// See https://github.com/ossrs/srs/pull/4356 for details.
int32_t extended_timestamp;
int32_t extended_timestamp_;
public:
SrsChunkStream(int _cid);
@ -409,7 +409,7 @@ class ISrsRequest
{
public:
// The client ip.
std::string ip;
std::string ip_;
public:
// Support pass vhost in RTMP URL, such as:
@ -418,28 +418,28 @@ public:
// rtmp://ip:port/app?vhost=VHOST/stream
// rtmp://ip:port/app...vhost...VHOST/stream
// While tcUrl is url without stream.
std::string tcUrl;
std::string tcUrl_;
public:
std::string pageUrl;
std::string swfUrl;
double objectEncoding;
std::string pageUrl_;
std::string swfUrl_;
double objectEncoding_;
// The data discovery from request.
public:
// Discovery from tcUrl and play/publish.
std::string schema;
std::string schema_;
// The vhost in tcUrl.
std::string vhost;
std::string vhost_;
// The host in tcUrl.
std::string host;
std::string host_;
// The port in tcUrl.
int port;
int port_;
// The app in tcUrl, without param.
std::string app;
std::string app_;
// The param in tcUrl(app).
std::string param;
std::string param_;
// The stream in play/publish
std::string stream;
std::string stream_;
// User specify the ice-ufrag, the username of ice, for test only.
std::string ice_ufrag_;
// User specify the ice-pwd, the password of ice, for test only.
@ -447,18 +447,18 @@ public:
// For play live stream,
// used to specified the stop when exceed the duration.
// in srs_utime_t.
srs_utime_t duration;
srs_utime_t duration_;
// The token in the connect request,
// used for edge traverse to origin authentication,
// @see https://github.com/ossrs/srs/issues/104
SrsAmf0Object *args;
SrsAmf0Object *args_;
public:
// The protocol of client:
// rtmp, Adobe RTMP protocol.
// flv, HTTP-FLV protocol.
// flvs, HTTPS-FLV protocol.
std::string protocol;
std::string protocol_;
public:
ISrsRequest();
@ -509,7 +509,7 @@ class SrsResponse
{
public:
// The stream id to response client createStream.
int stream_id;
int stream_id_;
public:
SrsResponse();
@ -541,13 +541,13 @@ class SrsHandshakeBytes
{
public:
// For RTMP proxy, the real IP.
uint32_t proxy_real_ip;
uint32_t proxy_real_ip_;
// [1+1536]
char *c0c1;
char *c0c1_;
// [1+1536+1536]
char *s0s1s2;
char *s0s1s2_;
// [1536]
char *c2;
char *c2_;
public:
SrsHandshakeBytes();
@ -567,14 +567,14 @@ public:
// The information return from RTMP server.
struct SrsServerInfo {
std::string ip;
std::string sig;
int pid;
int cid;
int major;
int minor;
int revision;
int build;
std::string ip_;
std::string sig_;
int pid_;
int cid_;
int major_;
int minor_;
int revision_;
int build_;
SrsServerInfo();
};
@ -583,11 +583,11 @@ struct SrsServerInfo {
class SrsRtmpClient
{
private:
SrsHandshakeBytes *hs_bytes;
SrsHandshakeBytes *hs_bytes_;
protected:
SrsProtocol *protocol;
ISrsProtocolReadWriter *io;
SrsProtocol *protocol_;
ISrsProtocolReadWriter *io_;
public:
SrsRtmpClient(ISrsProtocolReadWriter *skt);
@ -649,7 +649,7 @@ public:
template <class T>
srs_error_t expect_message(SrsRtmpCommonMessage **pmsg, T **ppacket)
{
return protocol->expect_message<T>(pmsg, ppacket);
return protocol_->expect_message<T>(pmsg, ppacket);
}
};
@ -659,9 +659,9 @@ public:
class SrsRtmpServer
{
private:
SrsHandshakeBytes *hs_bytes;
SrsProtocol *protocol;
ISrsProtocolReadWriter *io;
SrsHandshakeBytes *hs_bytes_;
SrsProtocol *protocol_;
ISrsProtocolReadWriter *io_;
public:
SrsRtmpServer(ISrsProtocolReadWriter *skt);
@ -821,7 +821,7 @@ public:
template <class T>
srs_error_t expect_message(SrsRtmpCommonMessage **pmsg, T **ppacket)
{
return protocol->expect_message<T>(pmsg, ppacket);
return protocol_->expect_message<T>(pmsg, ppacket);
}
private:
@ -841,17 +841,17 @@ class SrsConnectAppPacket : public SrsRtmpCommand
{
public:
// Name of the command. Set to "connect".
std::string command_name;
std::string command_name_;
// Always set to 1.
double transaction_id;
double transaction_id_;
// Command information object which has the name-value pairs.
// @remark: alloc in packet constructor, user can directly use it,
// user should never alloc it again which will cause memory leak.
// @remark, never be NULL.
SrsAmf0Object *command_object;
SrsAmf0Object *command_object_;
// Any optional information
// @remark, optional, init to and maybe NULL.
SrsAmf0Object *args;
SrsAmf0Object *args_;
public:
SrsConnectAppPacket();
@ -872,16 +872,16 @@ class SrsConnectAppResPacket : public SrsRtmpCommand
{
public:
// The _result or _error; indicates whether the response is result or error.
std::string command_name;
std::string command_name_;
// Transaction ID is 1 for call connect responses
double transaction_id;
double transaction_id_;
// Name-value pairs that describe the properties(fmsver etc.) of the connection.
// @remark, never be NULL.
SrsAmf0Object *props;
SrsAmf0Object *props_;
// Name-value pairs that describe the response from|the server. 'code',
// 'level', 'description' are names of few among such information.
// @remark, never be NULL.
SrsAmf0Object *info;
SrsAmf0Object *info_;
public:
SrsConnectAppResPacket();
@ -906,16 +906,16 @@ class SrsCallPacket : public SrsRtmpCommand
{
public:
// Name of the remote procedure that is called.
std::string command_name;
std::string command_name_;
// If a response is expected we give a transaction Id. Else we pass a value of 0
double transaction_id;
double transaction_id_;
// If there exists any command info this
// is set, else this is set to null type.
// @remark, optional, init to and maybe NULL.
SrsAmf0Any *command_object;
SrsAmf0Any *command_object_;
// Any optional arguments to be provided
// @remark, optional, init to and maybe NULL.
SrsAmf0Any *arguments;
SrsAmf0Any *arguments_;
public:
SrsCallPacket();
@ -936,15 +936,15 @@ class SrsCallResPacket : public SrsRtmpCommand
{
public:
// Name of the command.
std::string command_name;
std::string command_name_;
// ID of the command, to which the response belongs to
double transaction_id;
double transaction_id_;
// If there exists any command info this is set, else this is set to null type.
// @remark, optional, init to and maybe NULL.
SrsAmf0Any *command_object;
SrsAmf0Any *command_object_;
// Response from the method that was called.
// @remark, optional, init to and maybe NULL.
SrsAmf0Any *response;
SrsAmf0Any *response_;
public:
SrsCallResPacket(double _transaction_id);
@ -967,12 +967,12 @@ class SrsCreateStreamPacket : public SrsRtmpCommand
{
public:
// Name of the command. Set to "createStream".
std::string command_name;
std::string command_name_;
// Transaction ID of the command.
double transaction_id;
double transaction_id_;
// If there exists any command info this is set, else this is set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
public:
SrsCreateStreamPacket();
virtual ~SrsCreateStreamPacket();
@ -995,14 +995,14 @@ class SrsCreateStreamResPacket : public SrsRtmpCommand
{
public:
// The _result or _error; indicates whether the response is result or error.
std::string command_name;
std::string command_name_;
// ID of the command that response belongs to.
double transaction_id;
double transaction_id_;
// If there exists any command info this is set, else this is set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
// The return value is either a stream ID or an error information object.
double stream_id;
double stream_id_;
public:
SrsCreateStreamResPacket(double _transaction_id, double _stream_id);
@ -1024,12 +1024,12 @@ class SrsCloseStreamPacket : public SrsRtmpCommand
{
public:
// Name of the command, set to "closeStream".
std::string command_name;
std::string command_name_;
// Transaction ID set to 0.
double transaction_id;
double transaction_id_;
// Command information object does not exist. Set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
public:
SrsCloseStreamPacket();
virtual ~SrsCloseStreamPacket();
@ -1043,14 +1043,14 @@ class SrsFMLEStartPacket : public SrsRtmpCommand
{
public:
// Name of the command
std::string command_name;
std::string command_name_;
// The transaction ID to get the response.
double transaction_id;
double transaction_id_;
// If there exists any command info this is set, else this is set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
// The stream name to start publish or release.
std::string stream_name;
std::string stream_name_;
public:
SrsFMLEStartPacket();
@ -1078,15 +1078,15 @@ class SrsFMLEStartResPacket : public SrsRtmpCommand
{
public:
// Name of the command
std::string command_name;
std::string command_name_;
// The transaction ID to get the response.
double transaction_id;
double transaction_id_;
// If there exists any command info this is set, else this is set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
// The optional args, set to undefined.
// @remark, never be NULL, an AMF0 undefined instance.
SrsAmf0Any *args; // undefined
SrsAmf0Any *args_; // undefined
public:
SrsFMLEStartResPacket(double _transaction_id);
virtual ~SrsFMLEStartResPacket();
@ -1115,14 +1115,14 @@ class SrsPublishPacket : public SrsRtmpCommand
{
public:
// Name of the command, set to "publish".
std::string command_name;
std::string command_name_;
// Transaction ID set to 0.
double transaction_id;
double transaction_id_;
// Command information object does not exist. Set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
// Name with which the stream is published.
std::string stream_name;
std::string stream_name_;
// Type of publishing. Set to "live", "record", or "append".
// record: The stream is published and the data is recorded to a new file.The file
// is stored on the server in a subdirectory within the directory that
@ -1133,7 +1133,7 @@ public:
// live: Live data is published without recording it in a file.
// @remark, SRS only support live.
// @remark, optional, default to live.
std::string type;
std::string type_;
public:
SrsPublishPacket();
@ -1160,19 +1160,19 @@ class SrsPausePacket : public SrsRtmpCommand
{
public:
// Name of the command, set to "pause".
std::string command_name;
std::string command_name_;
// There is no transaction ID for this command. Set to 0.
double transaction_id;
double transaction_id_;
// Command information object does not exist. Set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
// true or false, to indicate pausing or resuming play
bool is_pause;
bool is_pause_;
// Number of milliseconds at which the the stream is paused or play resumed.
// This is the current stream time at the Client when stream was paused. When the
// playback is resumed, the server will only send messages with timestamps
// greater than this value.
double time_ms;
double time_ms_;
public:
SrsPausePacket();
@ -1188,12 +1188,12 @@ class SrsPlayPacket : public SrsRtmpCommand
{
public:
// Name of the command. Set to "play".
std::string command_name;
std::string command_name_;
// Transaction ID set to 0.
double transaction_id;
double transaction_id_;
// Command information does not exist. Set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
// Name of the stream to play.
// To play video (FLV) files, specify the name of the stream without a file
// extension (for example, "sample").
@ -1202,7 +1202,7 @@ public:
// To play H.264/AAC files, you must precede the stream name with mp4: and specify the
// file extension. For example, to play the file sample.m4v, specify
// "mp4:sample.m4v"
std::string stream_name;
std::string stream_name_;
// An optional parameter that specifies the start time in seconds.
// The default value is -2, which means the subscriber first tries to play the live
// stream specified in the Stream Name field. If a live stream of that name is
@ -1213,7 +1213,7 @@ public:
// in the Stream Name field is played beginning from the time specified in the
// Start field.
// If no recorded stream is found, the next item in the playlist is played.
double start;
double start_;
// An optional parameter that specifies the duration of playback in seconds.
// The default value is -1. The -1 value means a live stream is played until it is no
// longer available or a recorded stream is played until it ends.
@ -1226,10 +1226,10 @@ public:
// time specified in the Duration field, playback ends when the stream ends.)
// If you pass a negative number other than -1 in the Duration field, it interprets the
// value as if it were -1.
double duration;
double duration_;
// An optional Boolean value or number that specifies whether to flush any
// previous playlist.
bool reset;
bool reset_;
public:
SrsPlayPacket();
@ -1253,17 +1253,17 @@ class SrsPlayResPacket : public SrsRtmpCommand
public:
// Name of the command. If the play command is successful, the command
// name is set to onStatus.
std::string command_name;
std::string command_name_;
// Transaction ID set to 0.
double transaction_id;
double transaction_id_;
// Command information does not exist. Set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *command_object; // null
SrsAmf0Any *command_object_; // null
// If the play command is successful, the client receives OnStatus message from
// server which is NetStream.Play.Start. If the specified stream is not found,
// NetStream.Play.StreamNotFound is received.
// @remark, never be NULL, an AMF0 object instance.
SrsAmf0Object *desc;
SrsAmf0Object *desc_;
public:
SrsPlayResPacket();
@ -1286,12 +1286,12 @@ class SrsOnBWDonePacket : public SrsRtmpCommand
{
public:
// Name of command. Set to "onBWDone"
std::string command_name;
std::string command_name_;
// Transaction ID set to 0.
double transaction_id;
double transaction_id_;
// Command information does not exist. Set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *args; // null
SrsAmf0Any *args_; // null
public:
SrsOnBWDonePacket();
virtual ~SrsOnBWDonePacket();
@ -1313,16 +1313,16 @@ class SrsOnStatusCallPacket : public SrsRtmpCommand
{
public:
// Name of command. Set to "onStatus"
std::string command_name;
std::string command_name_;
// Transaction ID set to 0.
double transaction_id;
double transaction_id_;
// Command information does not exist. Set to null type.
// @remark, never be NULL, an AMF0 null instance.
SrsAmf0Any *args; // null
SrsAmf0Any *args_; // null
// Name-value pairs that describe the response from the server.
// 'code','level', 'description' are names of few among such information.
// @remark, never be NULL, an AMF0 object instance.
SrsAmf0Object *data;
SrsAmf0Object *data_;
public:
SrsOnStatusCallPacket();
@ -1346,11 +1346,11 @@ class SrsOnStatusDataPacket : public SrsRtmpCommand
{
public:
// Name of command. Set to "onStatus"
std::string command_name;
std::string command_name_;
// Name-value pairs that describe the response from the server.
// 'code', are names of few among such information.
// @remark, never be NULL, an AMF0 object instance.
SrsAmf0Object *data;
SrsAmf0Object *data_;
public:
SrsOnStatusDataPacket();
@ -1374,13 +1374,13 @@ class SrsNaluSampleAccessPacket : public SrsRtmpCommand
{
public:
// Name of command. Set to "|RtmpSampleAccess".
std::string command_name;
std::string command_name_;
// Whether allow access the sample of video.
// @see: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#videoSampleAccess
bool video_sample_access;
bool video_sample_access_;
// Whether allow access the sample of audio.
// @see: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#audioSampleAccess
bool audio_sample_access;
bool audio_sample_access_;
public:
SrsNaluSampleAccessPacket();
@ -1401,10 +1401,10 @@ class SrsOnMetaDataPacket : public SrsRtmpCommand
{
public:
// Name of metadata. Set to "onMetaData"
std::string name;
std::string name_;
// Metadata of stream.
// @remark, never be NULL, an AMF0 object instance.
SrsAmf0Object *metadata;
SrsAmf0Object *metadata_;
public:
SrsOnMetaDataPacket();
@ -1430,7 +1430,7 @@ protected:
class SrsSetWindowAckSizePacket : public SrsRtmpCommand
{
public:
int32_t ackowledgement_window_size;
int32_t ackowledgement_window_size_;
public:
SrsSetWindowAckSizePacket();
@ -1453,7 +1453,7 @@ protected:
class SrsAcknowledgementPacket : public SrsRtmpCommand
{
public:
uint32_t sequence_number;
uint32_t sequence_number_;
public:
SrsAcknowledgementPacket();
@ -1478,7 +1478,7 @@ class SrsSetChunkSizePacket : public SrsRtmpCommand
public:
// The maximum chunk size can be 65536 bytes. The chunk size is
// maintained independently for each direction.
int32_t chunk_size;
int32_t chunk_size_;
public:
SrsSetChunkSizePacket();
@ -1510,9 +1510,9 @@ enum SrsPeerBandwidthType {
class SrsSetPeerBandwidthPacket : public SrsRtmpCommand
{
public:
int32_t bandwidth;
int32_t bandwidth_;
// @see: SrsPeerBandwidthType
int8_t type;
int8_t type_;
public:
SrsSetPeerBandwidthPacket();
@ -1614,13 +1614,13 @@ class SrsUserControlPacket : public SrsRtmpCommand
public:
// Event type is followed by Event data.
// @see: SrcPCUCEventType
int16_t event_type;
int16_t event_type_;
// The event data generally in 4bytes.
// @remark for event type is 0x001a, only 1bytes.
// @see SrsPCUCFmsEvent0
int32_t event_data;
int32_t event_data_;
// 4bytes if event_type is SetBufferLength; otherwise 0.
int32_t extra_data;
int32_t extra_data_;
public:
SrsUserControlPacket();

View File

@ -324,16 +324,16 @@ VOID TEST(SrsAVCTest, AACDemuxADTS)
uint8_t b[] = {0xff, 0xf9, 0x2c, 0x40, 0, 0xe0, 0};
SrsBuffer buf((char *)b, sizeof(b));
HELPER_ASSERT_SUCCESS(h.adts_demux(&buf, &frame, &nb_frame, codec));
EXPECT_EQ(1, codec.protection_absent); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object); // b[2]
EXPECT_EQ(0xb, codec.sampling_frequency_index); // b[2]
EXPECT_EQ(1, codec.channel_configuration); // b[3]
EXPECT_EQ(7, codec.frame_length); // b[5]
EXPECT_EQ(1, codec.protection_absent_); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object_); // b[2]
EXPECT_EQ(0xb, codec.sampling_frequency_index_); // b[2]
EXPECT_EQ(1, codec.channel_configuration_); // b[3]
EXPECT_EQ(7, codec.frame_length_); // b[5]
EXPECT_EQ(0, nb_frame);
EXPECT_EQ(SrsAudioSampleRate5512, codec.sound_rate);
EXPECT_EQ(0, codec.sound_type);
EXPECT_EQ(1, codec.sound_size);
EXPECT_EQ(SrsAudioSampleRate5512, codec.sound_rate_);
EXPECT_EQ(0, codec.sound_type_);
EXPECT_EQ(1, codec.sound_size_);
}
// For lower sampling rate, such as 22050HZ.
@ -345,16 +345,16 @@ VOID TEST(SrsAVCTest, AACDemuxADTS)
uint8_t b[] = {0xff, 0xf9, 0x18, 0x40, 0, 0xe0, 0};
SrsBuffer buf((char *)b, sizeof(b));
HELPER_ASSERT_SUCCESS(h.adts_demux(&buf, &frame, &nb_frame, codec));
EXPECT_EQ(1, codec.protection_absent); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object); // b[2]
EXPECT_EQ(6, codec.sampling_frequency_index); // b[2]
EXPECT_EQ(1, codec.channel_configuration); // b[3]
EXPECT_EQ(7, codec.frame_length); // b[5]
EXPECT_EQ(1, codec.protection_absent_); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object_); // b[2]
EXPECT_EQ(6, codec.sampling_frequency_index_); // b[2]
EXPECT_EQ(1, codec.channel_configuration_); // b[3]
EXPECT_EQ(7, codec.frame_length_); // b[5]
EXPECT_EQ(0, nb_frame);
EXPECT_EQ(SrsAudioSampleRate22050, codec.sound_rate);
EXPECT_EQ(0, codec.sound_type);
EXPECT_EQ(1, codec.sound_size);
EXPECT_EQ(SrsAudioSampleRate22050, codec.sound_rate_);
EXPECT_EQ(0, codec.sound_type_);
EXPECT_EQ(1, codec.sound_size_);
}
// For higher sampling rate, use 44100HZ.
@ -366,16 +366,16 @@ VOID TEST(SrsAVCTest, AACDemuxADTS)
uint8_t b[] = {0xff, 0xf9, 0x04, 0x40, 0, 0xe0, 0};
SrsBuffer buf((char *)b, sizeof(b));
HELPER_ASSERT_SUCCESS(h.adts_demux(&buf, &frame, &nb_frame, codec));
EXPECT_EQ(1, codec.protection_absent); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object); // b[2]
EXPECT_EQ(1, codec.sampling_frequency_index); // b[2]
EXPECT_EQ(1, codec.channel_configuration); // b[3]
EXPECT_EQ(7, codec.frame_length); // b[5]
EXPECT_EQ(1, codec.protection_absent_); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object_); // b[2]
EXPECT_EQ(1, codec.sampling_frequency_index_); // b[2]
EXPECT_EQ(1, codec.channel_configuration_); // b[3]
EXPECT_EQ(7, codec.frame_length_); // b[5]
EXPECT_EQ(0, nb_frame);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate);
EXPECT_EQ(0, codec.sound_type);
EXPECT_EQ(1, codec.sound_size);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate_);
EXPECT_EQ(0, codec.sound_type_);
EXPECT_EQ(1, codec.sound_size_);
}
// If protected, there are 2B signature.
@ -387,17 +387,17 @@ VOID TEST(SrsAVCTest, AACDemuxADTS)
uint8_t b[] = {0xff, 0xf0, 0x10, 0x40, 0x01, 0x40, 0, 0, 0, 1};
SrsBuffer buf((char *)b, sizeof(b));
HELPER_ASSERT_SUCCESS(h.adts_demux(&buf, &frame, &nb_frame, codec));
EXPECT_EQ(0, codec.protection_absent); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object); // b[2]
EXPECT_EQ(4, codec.sampling_frequency_index); // b[2]
EXPECT_EQ(1, codec.channel_configuration); // b[3]
EXPECT_EQ(10, codec.frame_length); // b[4,5]
EXPECT_EQ(0, codec.protection_absent_); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object_); // b[2]
EXPECT_EQ(4, codec.sampling_frequency_index_); // b[2]
EXPECT_EQ(1, codec.channel_configuration_); // b[3]
EXPECT_EQ(10, codec.frame_length_); // b[4,5]
ASSERT_EQ(1, nb_frame);
EXPECT_EQ(1, (uint8_t)frame[0]);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate);
EXPECT_EQ(0, codec.sound_type);
EXPECT_EQ(1, codec.sound_size);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate_);
EXPECT_EQ(0, codec.sound_type_);
EXPECT_EQ(1, codec.sound_size_);
}
// Fail if not enough data.
@ -442,17 +442,17 @@ VOID TEST(SrsAVCTest, AACDemuxADTS)
uint8_t b[] = {0xff, 0xf9, 0x10, 0x40, 0x01, 0, 0, 1};
SrsBuffer buf((char *)b, sizeof(b));
HELPER_ASSERT_SUCCESS(h.adts_demux(&buf, &frame, &nb_frame, codec));
EXPECT_EQ(1, codec.protection_absent); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object); // b[2]
EXPECT_EQ(4, codec.sampling_frequency_index); // b[2]
EXPECT_EQ(1, codec.channel_configuration); // b[3]
EXPECT_EQ(8, codec.frame_length); // b[4]
EXPECT_EQ(1, codec.protection_absent_); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object_); // b[2]
EXPECT_EQ(4, codec.sampling_frequency_index_); // b[2]
EXPECT_EQ(1, codec.channel_configuration_); // b[3]
EXPECT_EQ(8, codec.frame_length_); // b[4]
ASSERT_EQ(1, nb_frame);
EXPECT_EQ(1, (uint8_t)frame[0]);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate);
EXPECT_EQ(0, codec.sound_type);
EXPECT_EQ(1, codec.sound_size);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate_);
EXPECT_EQ(0, codec.sound_type_);
EXPECT_EQ(1, codec.sound_size_);
}
// Minimum AAC frame, no raw data.
@ -464,16 +464,16 @@ VOID TEST(SrsAVCTest, AACDemuxADTS)
uint8_t b[] = {0xff, 0xf9, 0x10, 0x40, 0, 0xe0, 0};
SrsBuffer buf((char *)b, sizeof(b));
HELPER_ASSERT_SUCCESS(h.adts_demux(&buf, &frame, &nb_frame, codec));
EXPECT_EQ(1, codec.protection_absent); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object); // b[2]
EXPECT_EQ(4, codec.sampling_frequency_index); // b[2]
EXPECT_EQ(1, codec.channel_configuration); // b[3]
EXPECT_EQ(7, codec.frame_length); // b[5]
EXPECT_EQ(1, codec.protection_absent_); // b[1]
EXPECT_EQ(SrsAacObjectTypeAacMain, codec.aac_object_); // b[2]
EXPECT_EQ(4, codec.sampling_frequency_index_); // b[2]
EXPECT_EQ(1, codec.channel_configuration_); // b[3]
EXPECT_EQ(7, codec.frame_length_); // b[5]
EXPECT_EQ(0, nb_frame);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate);
EXPECT_EQ(0, codec.sound_type);
EXPECT_EQ(1, codec.sound_size);
EXPECT_EQ(SrsAudioSampleRate44100, codec.sound_rate_);
EXPECT_EQ(0, codec.sound_type_);
EXPECT_EQ(1, codec.sound_size_);
}
}
@ -486,10 +486,10 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate22050;
codec.sampling_frequency_index = 7;
codec.aac_object_ = SrsAacObjectTypeAacMain;
codec.channel_configuration_ = 1;
codec.sound_rate_ = SrsAudioSampleRate22050;
codec.sampling_frequency_index_ = 7;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, (int)sh.length());
EXPECT_EQ(0x0b, (uint8_t)sh.at(0));
@ -501,10 +501,10 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate11025;
codec.sampling_frequency_index = 0xa;
codec.aac_object_ = SrsAacObjectTypeAacMain;
codec.channel_configuration_ = 1;
codec.sound_rate_ = SrsAudioSampleRate11025;
codec.sampling_frequency_index_ = 0xa;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, (int)sh.length());
EXPECT_EQ(0x0d, (uint8_t)sh.at(0));
@ -516,9 +516,9 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.sampling_frequency_index = SrsAacSampleRateUnset;
codec.sound_rate = SrsAudioSampleRateReserved;
codec.aac_object_ = SrsAacObjectTypeAacMain;
codec.sampling_frequency_index_ = SrsAacSampleRateUnset;
codec.sound_rate_ = SrsAudioSampleRateReserved;
HELPER_EXPECT_FAILED(h.mux_sequence_header(&codec, sh));
}
@ -527,10 +527,10 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sampling_frequency_index = 4;
codec.sound_rate = SrsAudioSampleRateReserved;
codec.aac_object_ = SrsAacObjectTypeAacMain;
codec.channel_configuration_ = 1;
codec.sampling_frequency_index_ = 4;
codec.sound_rate_ = SrsAudioSampleRateReserved;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, (int)sh.length());
EXPECT_EQ(0x0a, (uint8_t)sh.at(0));
@ -542,7 +542,7 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeReserved;
codec.aac_object_ = SrsAacObjectTypeReserved;
HELPER_EXPECT_FAILED(h.mux_sequence_header(&codec, sh));
}
@ -551,10 +551,10 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate44100;
codec.sampling_frequency_index = 4;
codec.aac_object_ = SrsAacObjectTypeAacMain;
codec.channel_configuration_ = 1;
codec.sound_rate_ = SrsAudioSampleRate44100;
codec.sampling_frequency_index_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, (int)sh.length());
EXPECT_EQ(0x0a, (uint8_t)sh.at(0));
@ -566,10 +566,10 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate22050;
codec.sampling_frequency_index = 4;
codec.aac_object_ = SrsAacObjectTypeAacMain;
codec.channel_configuration_ = 1;
codec.sound_rate_ = SrsAudioSampleRate22050;
codec.sampling_frequency_index_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, (int)sh.length());
EXPECT_EQ(0x0a, (uint8_t)sh.at(0));
@ -581,10 +581,10 @@ VOID TEST(SrsAVCTest, AACMuxSequenceHeader)
SrsRawAacStream h;
string sh;
SrsRawAacStreamCodec codec;
codec.aac_object = SrsAacObjectTypeAacMain;
codec.channel_configuration = 1;
codec.sound_rate = SrsAudioSampleRate44100;
codec.sampling_frequency_index = SrsAacSampleRateUnset;
codec.aac_object_ = SrsAacObjectTypeAacMain;
codec.channel_configuration_ = 1;
codec.sound_rate_ = SrsAudioSampleRate44100;
codec.sampling_frequency_index_ = SrsAacSampleRateUnset;
HELPER_ASSERT_SUCCESS(h.mux_sequence_header(&codec, sh));
EXPECT_EQ(2, (int)sh.length());
EXPECT_EQ(0x0a, (uint8_t)sh.at(0));
@ -603,11 +603,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdMP3;
codec.sound_rate = 0;
codec.sound_size = 1;
codec.sound_type = 1;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdMP3;
codec.sound_rate_ = 0;
codec.sound_size_ = 1;
codec.sound_type_ = 1;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(6, nb_flv);
EXPECT_EQ(0x23, (uint8_t)flv[0]);
@ -622,11 +622,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdOpus;
codec.sound_rate = 0;
codec.sound_size = 1;
codec.sound_type = 1;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdOpus;
codec.sound_rate_ = 0;
codec.sound_size_ = 1;
codec.sound_type_ = 1;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(6, nb_flv);
EXPECT_EQ(0xd3, (uint8_t)flv[0]);
@ -641,11 +641,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdSpeex;
codec.sound_rate = 0;
codec.sound_size = 1;
codec.sound_type = 1;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdSpeex;
codec.sound_rate_ = 0;
codec.sound_size_ = 1;
codec.sound_type_ = 1;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(6, nb_flv);
EXPECT_EQ(0xb3, (uint8_t)flv[0]);
@ -660,11 +660,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdAAC;
codec.sound_rate = 0;
codec.sound_size = 1;
codec.sound_type = 1;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdAAC;
codec.sound_rate_ = 0;
codec.sound_size_ = 1;
codec.sound_type_ = 1;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(7, nb_flv);
EXPECT_EQ(0xa3, (uint8_t)flv[0]);
@ -678,11 +678,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdAAC;
codec.sound_rate = 1;
codec.sound_size = 1;
codec.sound_type = 0;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdAAC;
codec.sound_rate_ = 1;
codec.sound_size_ = 1;
codec.sound_type_ = 0;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(7, nb_flv);
EXPECT_EQ(0xa6, (uint8_t)flv[0]);
@ -696,11 +696,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdAAC;
codec.sound_rate = 1;
codec.sound_size = 0;
codec.sound_type = 1;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdAAC;
codec.sound_rate_ = 1;
codec.sound_size_ = 0;
codec.sound_type_ = 1;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(7, nb_flv);
EXPECT_EQ(0xa5, (uint8_t)flv[0]);
@ -714,11 +714,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdAAC;
codec.sound_rate = 1;
codec.sound_size = 1;
codec.sound_type = 1;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdAAC;
codec.sound_rate_ = 1;
codec.sound_size_ = 1;
codec.sound_type_ = 1;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(7, nb_flv);
EXPECT_EQ(0xa7, (uint8_t)flv[0]);
@ -732,11 +732,11 @@ VOID TEST(SrsAVCTest, AACMuxToFLV)
SrsRawAacStreamCodec codec;
char *flv = NULL;
int nb_flv = 0;
codec.sound_format = SrsAudioCodecIdAAC;
codec.sound_rate = 3;
codec.sound_size = 1;
codec.sound_type = 1;
codec.aac_packet_type = 4;
codec.sound_format_ = SrsAudioCodecIdAAC;
codec.sound_rate_ = 3;
codec.sound_size_ = 1;
codec.sound_type_ = 1;
codec.aac_packet_type_ = 4;
HELPER_ASSERT_SUCCESS(h.mux_aac2flv((char *)frame.data(), frame.length(), &codec, 0, &flv, &nb_flv));
EXPECT_EQ(7, nb_flv);
EXPECT_EQ(0xaf, (uint8_t)flv[0]);

View File

@ -2488,8 +2488,8 @@ VOID TEST(ConfigUnitTest, ApplyFilter)
if (true) {
SrsConfDirective d;
SrsRequest r;
r.app = "live";
r.stream = "stream";
r.app_ = "live";
r.stream_ = "stream";
d.args.push_back("live/stream");
EXPECT_TRUE(srs_config_apply_filter(&d, &r));
}

View File

@ -24,9 +24,9 @@ class MockSrsRequest : public SrsRequest
public:
MockSrsRequest()
{
vhost = "__defaultVhost__";
app = "live";
stream = "livestream";
vhost_ = "__defaultVhost__";
app_ = "live";
stream_ = "livestream";
}
virtual ~MockSrsRequest() {}
};

View File

@ -1236,7 +1236,7 @@ VOID TEST(ProtocolHTTPTest, HTTPServerMuxerAuth)
HELPER_ASSERT_SUCCESS(auth.initialize(true, "admin", "123456"));
HELPER_ASSERT_SUCCESS(auth.serve_http(&w, &r));
EXPECT_EQ(401, w.w->status);
EXPECT_EQ(401, w.w->status_);
}
// incorrect token, duplicate Basic
@ -1261,7 +1261,7 @@ VOID TEST(ProtocolHTTPTest, HTTPServerMuxerAuth)
HELPER_ASSERT_SUCCESS(auth.initialize(true, "admin", "admin"));
HELPER_ASSERT_SUCCESS(auth.serve_http(&w, &r));
EXPECT_EQ(401, w.w->status);
EXPECT_EQ(401, w.w->status_);
}
// Authorization NOT start with 'Basic '
@ -1286,7 +1286,7 @@ VOID TEST(ProtocolHTTPTest, HTTPServerMuxerAuth)
HELPER_ASSERT_SUCCESS(auth.initialize(true, "admin", "admin"));
HELPER_ASSERT_SUCCESS(auth.serve_http(&w, &r));
EXPECT_EQ(401, w.w->status);
EXPECT_EQ(401, w.w->status_);
}
// NOT base64
@ -1311,7 +1311,7 @@ VOID TEST(ProtocolHTTPTest, HTTPServerMuxerAuth)
HELPER_ASSERT_SUCCESS(auth.initialize(true, "admin", "admin"));
HELPER_ASSERT_SUCCESS(auth.serve_http(&w, &r));
EXPECT_EQ(401, w.w->status);
EXPECT_EQ(401, w.w->status_);
}
// empty Authorization
@ -1331,7 +1331,7 @@ VOID TEST(ProtocolHTTPTest, HTTPServerMuxerAuth)
HELPER_ASSERT_SUCCESS(auth.initialize(true, "admin", "admin"));
HELPER_ASSERT_SUCCESS(auth.serve_http(&w, &r));
EXPECT_EQ(401, w.w->status);
EXPECT_EQ(401, w.w->status_);
}
// auth disabled, response with 200 ok, even though empty Authorization

View File

@ -663,18 +663,18 @@ VOID TEST(ProtocolHandshakeTest, VerifyFPC0C1)
EXPECT_EQ(0x03, c0c1[0]);
// c1
c1s1 c1;
SrsC1S1 c1;
// the schema of data must be schema0: key-digest.
HELPER_ASSERT_SUCCESS(c1.parse((char *)c0c1 + 1, 1536, srs_schema0));
EXPECT_EQ((int32_t)0x000f64d0, c1.time);
EXPECT_EQ((int32_t)0x80000702, c1.version);
EXPECT_EQ((int32_t)0x000f64d0, c1.time_);
EXPECT_EQ((int32_t)0x80000702, c1.version_);
// manually validate the c1
// @see: calc_c1_digest
char *c1s1_joined_bytes = new char[1536 - 32];
SrsUniquePtr<char[]> cp_uptr(c1s1_joined_bytes);
HELPER_ASSERT_SUCCESS(c1.payload->copy_to(&c1, c1s1_joined_bytes, 1536 - 32, false));
HELPER_ASSERT_SUCCESS(c1.payload_->copy_to(&c1, c1s1_joined_bytes, 1536 - 32, false));
bool is_valid;
HELPER_ASSERT_SUCCESS(c1.c1_validate_digest(is_valid));
@ -713,34 +713,34 @@ VOID TEST(ProtocolHandshakeTest, ComplexHandshake)
SrsHandshakeBytes bytes;
if (true) {
HELPER_ASSERT_SUCCESS(bytes.create_c0c1());
memcpy(bytes.c0c1, c0c1, 1537);
memcpy(bytes.c0c1_, c0c1, 1537);
HELPER_ASSERT_SUCCESS(bytes.create_s0s1s2());
memcpy(bytes.s0s1s2, s0s1s2, 3073);
memcpy(bytes.s0s1s2_, s0s1s2, 3073);
HELPER_ASSERT_SUCCESS(bytes.create_c2());
memcpy(bytes.c2, c2, 1536);
memcpy(bytes.c2_, c2, 1536);
}
SrsHandshakeBytes *hs_bytes = &bytes;
if (true) {
bool is_valid;
c1s1 c1;
HELPER_ASSERT_SUCCESS(c1.parse(hs_bytes->c0c1 + 1, 1536, srs_schema0));
SrsC1S1 c1;
HELPER_ASSERT_SUCCESS(c1.parse(hs_bytes->c0c1_ + 1, 1536, srs_schema0));
HELPER_ASSERT_SUCCESS(c1.c1_validate_digest(is_valid));
ASSERT_TRUE(is_valid);
c1s1 s1;
HELPER_ASSERT_SUCCESS(s1.parse(hs_bytes->s0s1s2 + 1, 1536, c1.schema()));
SrsC1S1 s1;
HELPER_ASSERT_SUCCESS(s1.parse(hs_bytes->s0s1s2_ + 1, 1536, c1.schema()));
HELPER_ASSERT_SUCCESS(s1.s1_validate_digest(is_valid));
ASSERT_TRUE(is_valid);
c2s2 c2;
c2.parse(hs_bytes->c2, 1536);
SrsC2S2 c2;
c2.parse(hs_bytes->c2_, 1536);
HELPER_ASSERT_SUCCESS(c2.c2_validate(&s1, is_valid));
ASSERT_TRUE(is_valid);
c2s2 s2;
s2.parse(hs_bytes->s0s1s2 + 1 + 1536, 1536);
SrsC2S2 s2;
s2.parse(hs_bytes->s0s1s2_ + 1 + 1536, 1536);
HELPER_ASSERT_SUCCESS(s2.s2_validate(&c1, is_valid));
ASSERT_TRUE(is_valid);
}
@ -790,11 +790,11 @@ VOID TEST(ProtocolHandshakeTest, SimpleHandshake)
if (true) {
SrsHandshakeBytes bytes;
HELPER_ASSERT_SUCCESS(bytes.create_c0c1());
memcpy(bytes.c0c1, c0c1, 1537);
memcpy(bytes.c0c1_, c0c1, 1537);
HELPER_ASSERT_SUCCESS(bytes.create_s0s1s2());
memcpy(bytes.s0s1s2, s0s1s2, 3073);
memcpy(bytes.s0s1s2_, s0s1s2, 3073);
HELPER_ASSERT_SUCCESS(bytes.create_c2());
memcpy(bytes.c2, c2, 1536);
memcpy(bytes.c2_, c2, 1536);
MockEmptyIO eio;
SrsSimpleHandshake hs;
@ -883,8 +883,8 @@ VOID TEST(ProtocolUtilityTest, GenerateTcUrl)
void srs_utest_free_message_array(SrsMessageArray *arr)
{
for (int i = 0; i < arr->max; i++) {
srs_freep(arr->msgs[i]);
for (int i = 0; i < arr->max_; i++) {
srs_freep(arr->msgs_[i]);
}
}
@ -908,11 +908,11 @@ VOID TEST(ProtocolMsgArrayTest, MessageArray)
SrsMessageArray *parr = &arr;
SrsUniquePtr<SrsMessageArray> parr2(parr, srs_utest_free_message_array);
arr.msgs[0] = msg.copy();
arr.msgs_[0] = msg.copy();
arr.msgs[1] = msg.copy();
arr.msgs_[1] = msg.copy();
arr.msgs[2] = msg.copy();
arr.msgs_[2] = msg.copy();
}
if (true) {
@ -921,9 +921,9 @@ VOID TEST(ProtocolMsgArrayTest, MessageArray)
SrsMessageArray *parr = &arr;
SrsUniquePtr<SrsMessageArray> parr2(parr, srs_utest_free_message_array);
arr.msgs[0] = msg.copy();
arr.msgs_[0] = msg.copy();
arr.msgs[2] = msg.copy();
arr.msgs_[2] = msg.copy();
}
}
@ -1057,8 +1057,8 @@ VOID TEST(ProtocolStackTest, ProtocolRecvMessageBug98)
SrsUserControlPacket *spkt = dynamic_cast<SrsUserControlPacket *>(pkt);
ASSERT_TRUE(NULL != spkt);
EXPECT_EQ(SrcPCUCPingRequest, spkt->event_type);
EXPECT_EQ(0x0d0f, spkt->event_data);
EXPECT_EQ(SrcPCUCPingRequest, spkt->event_type_);
EXPECT_EQ(0x0d0f, spkt->event_data_);
}
/**
@ -1093,7 +1093,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvAckSizeMessage)
SrsSetWindowAckSizePacket *spkt = dynamic_cast<SrsSetWindowAckSizePacket *>(pkt);
ASSERT_TRUE(NULL != spkt);
EXPECT_EQ(0x0763, spkt->ackowledgement_window_size);
EXPECT_EQ(0x0763, spkt->ackowledgement_window_size_);
}
/**
@ -4395,9 +4395,9 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsCallPacket)
SrsAmf0Object *args = SrsAmf0Any::object();
SrsCallPacket *pkt = new SrsCallPacket();
pkt->command_name = "my_call";
pkt->command_object = SrsAmf0Any::null();
pkt->arguments = args;
pkt->command_name_ = "my_call";
pkt->command_object_ = SrsAmf0Any::null();
pkt->arguments_ = args;
args->set("video_id", SrsAmf0Any::number(100));
args->set("url", SrsAmf0Any::str("http://ossrs.net/api/v1/videos/100"));
@ -4438,9 +4438,9 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsCallResPacket)
SrsAmf0Object *args = SrsAmf0Any::object();
SrsCallResPacket *pkt = new SrsCallResPacket(0);
pkt->command_name = "_result";
pkt->command_object = SrsAmf0Any::null();
pkt->response = args;
pkt->command_name_ = "_result";
pkt->command_object_ = SrsAmf0Any::null();
pkt->response_ = args;
args->set("video_id", SrsAmf0Any::number(100));
args->set("url", SrsAmf0Any::str("http://ossrs.net/api/v1/videos/100"));
@ -4502,9 +4502,9 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsFMLEStartPacket)
SrsProtocol proto(&bio);
SrsFMLEStartPacket *pkt = new SrsFMLEStartPacket();
pkt->command_name = "FMLEStart";
pkt->command_name_ = "FMLEStart";
pkt->set_command_object(SrsAmf0Any::null());
pkt->stream_name = "livestream";
pkt->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
char buf[] = {
@ -4530,7 +4530,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsFMLEStartResPacket)
SrsAmf0Object *args = SrsAmf0Any::object();
SrsFMLEStartResPacket *pkt = new SrsFMLEStartResPacket(1);
pkt->command_name = "FMLEStart";
pkt->command_name_ = "FMLEStart";
pkt->set_command_object(SrsAmf0Any::null());
pkt->set_args(args);
@ -4558,10 +4558,10 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsPublishPacket)
SrsProtocol proto(&bio);
SrsPublishPacket *pkt = new SrsPublishPacket();
pkt->command_name = "publish";
pkt->command_name_ = "publish";
pkt->set_command_object(SrsAmf0Any::null());
pkt->stream_name = "livestream";
pkt->type = "live";
pkt->stream_name_ = "livestream";
pkt->type_ = "live";
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
uint8_t buf[] = {
@ -4588,7 +4588,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsPlayResPacket)
SrsAmf0Object *args = SrsAmf0Any::object();
SrsPlayResPacket *pkt = new SrsPlayResPacket();
pkt->command_name = "_result";
pkt->command_name_ = "_result";
pkt->set_command_object(SrsAmf0Any::null());
pkt->set_desc(args);
@ -4621,7 +4621,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsOnBWDonePacket)
SrsProtocol proto(&bio);
SrsOnBWDonePacket *pkt = new SrsOnBWDonePacket();
pkt->command_name = "onBWDone";
pkt->command_name_ = "onBWDone";
pkt->set_args(SrsAmf0Any::null());
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
@ -4650,7 +4650,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsOnStatusCallPacket)
args->set("start", SrsAmf0Any::number(0));
SrsOnStatusCallPacket *pkt = new SrsOnStatusCallPacket();
pkt->command_name = "onStatus";
pkt->command_name_ = "onStatus";
pkt->set_args(SrsAmf0Any::null());
pkt->set_data(args);
@ -4685,7 +4685,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsOnStatusDataPacket)
args->set("start", SrsAmf0Any::number(0));
SrsOnStatusDataPacket *pkt = new SrsOnStatusDataPacket();
pkt->command_name = "onData";
pkt->command_name_ = "onData";
pkt->set_data(args);
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
@ -4712,9 +4712,9 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsNaluSampleAccessPacket)
SrsProtocol proto(&bio);
SrsNaluSampleAccessPacket *pkt = new SrsNaluSampleAccessPacket();
pkt->command_name = "|RtmpSampleAccess";
pkt->video_sample_access = true;
pkt->audio_sample_access = true;
pkt->command_name_ = "|RtmpSampleAccess";
pkt->video_sample_access_ = true;
pkt->audio_sample_access_ = true;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
char buf[] = {
@ -4742,7 +4742,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsOnMetaDataPacket)
args->set("height", SrsAmf0Any::number(576));
SrsOnMetaDataPacket *pkt = new SrsOnMetaDataPacket();
pkt->name = "onMetaData";
pkt->name_ = "onMetaData";
pkt->set_metadata(args);
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
@ -4769,7 +4769,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsSetWindowAckSizePacket)
SrsProtocol proto(&bio);
SrsSetWindowAckSizePacket *pkt = new SrsSetWindowAckSizePacket();
pkt->ackowledgement_window_size = 102400;
pkt->ackowledgement_window_size_ = 102400;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
uint8_t buf[] = {
@ -4789,7 +4789,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsAcknowledgementPacket)
SrsProtocol proto(&bio);
SrsAcknowledgementPacket *pkt = new SrsAcknowledgementPacket();
pkt->sequence_number = 1024;
pkt->sequence_number_ = 1024;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
char buf[] = {
@ -4809,7 +4809,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsSetChunkSizePacket)
SrsProtocol proto(&bio);
SrsSetChunkSizePacket *pkt = new SrsSetChunkSizePacket();
pkt->chunk_size = 1024;
pkt->chunk_size_ = 1024;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
char buf[] = {
@ -4829,8 +4829,8 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsSetPeerBandwidthPacket)
SrsProtocol proto(&bio);
SrsSetPeerBandwidthPacket *pkt = new SrsSetPeerBandwidthPacket();
pkt->type = SrsPeerBandwidthSoft;
pkt->bandwidth = 1024;
pkt->type_ = SrsPeerBandwidthSoft;
pkt->bandwidth_ = 1024;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
char buf[] = {
@ -4851,9 +4851,9 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsUserControlPacket)
SrsProtocol proto(&bio);
SrsUserControlPacket *pkt = new SrsUserControlPacket();
pkt->event_type = SrcPCUCSetBufferLength;
pkt->event_data = 0x01;
pkt->extra_data = 0x10;
pkt->event_type_ = SrcPCUCSetBufferLength;
pkt->event_data_ = 0x01;
pkt->extra_data_ = 0x10;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
char buf[] = {
@ -4925,7 +4925,7 @@ VOID TEST(ProtocolStackTest, ProtocolAckSizeFlow)
if (true) {
SrsSetWindowAckSizePacket *pkt = new SrsSetWindowAckSizePacket();
pkt->ackowledgement_window_size = 512;
pkt->ackowledgement_window_size_ = 512;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
}
@ -5034,8 +5034,8 @@ VOID TEST(ProtocolStackTest, ProtocolPingFlow)
// ping request
if (true) {
SrsUserControlPacket *pkt = new SrsUserControlPacket();
pkt->event_type = SrcPCUCPingRequest;
pkt->event_data = 0x3456;
pkt->event_type_ = SrcPCUCPingRequest;
pkt->event_data_ = 0x3456;
HELPER_EXPECT_SUCCESS(proto.send_and_free_packet(pkt, 0));
}
// copy output to input
@ -5071,8 +5071,8 @@ VOID TEST(ProtocolStackTest, ProtocolPingFlow)
SrsUserControlPacket *spkt = dynamic_cast<SrsUserControlPacket *>(pkt);
ASSERT_TRUE(spkt != NULL);
EXPECT_TRUE(SrcPCUCPingResponse == spkt->event_type);
EXPECT_TRUE(0x3456 == spkt->event_data);
EXPECT_TRUE(SrcPCUCPingResponse == spkt->event_type_);
EXPECT_TRUE(0x3456 == spkt->event_data_);
}
}
@ -5136,78 +5136,78 @@ VOID TEST(ProtocolRTMPTest, RTMPRequest)
SrsRequest req;
std::string param;
req.stream = "livestream";
req.stream_ = "livestream";
srs_net_url_parse_tcurl("rtmp://std.ossrs.net/live",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
req.strip();
EXPECT_STREQ("rtmp", req.schema.c_str());
EXPECT_STREQ("std.ossrs.net", req.host.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost.c_str());
EXPECT_STREQ("live", req.app.c_str());
EXPECT_EQ(1935, req.port);
EXPECT_STREQ("rtmp", req.schema_.c_str());
EXPECT_STREQ("std.ossrs.net", req.host_.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost_.c_str());
EXPECT_STREQ("live", req.app_.c_str());
EXPECT_EQ(1935, req.port_);
req.stream = "livestream";
req.stream_ = "livestream";
srs_net_url_parse_tcurl("rtmp://s td.os srs.n et/li v e",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
req.strip();
EXPECT_STREQ("rtmp", req.schema.c_str());
EXPECT_STREQ("std.ossrs.net", req.host.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost.c_str());
EXPECT_STREQ("live", req.app.c_str());
EXPECT_EQ(1935, req.port);
EXPECT_STREQ("rtmp", req.schema_.c_str());
EXPECT_STREQ("std.ossrs.net", req.host_.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost_.c_str());
EXPECT_STREQ("live", req.app_.c_str());
EXPECT_EQ(1935, req.port_);
req.stream = "livestream";
req.stream_ = "livestream";
srs_net_url_parse_tcurl("rtmp://s\ntd.o\rssrs.ne\nt/li\nve",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
req.strip();
EXPECT_STREQ("rtmp", req.schema.c_str());
EXPECT_STREQ("std.ossrs.net", req.host.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost.c_str());
EXPECT_STREQ("live", req.app.c_str());
EXPECT_EQ(1935, req.port);
EXPECT_STREQ("rtmp", req.schema_.c_str());
EXPECT_STREQ("std.ossrs.net", req.host_.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost_.c_str());
EXPECT_STREQ("live", req.app_.c_str());
EXPECT_EQ(1935, req.port_);
req.stream = "livestream";
req.stream_ = "livestream";
srs_net_url_parse_tcurl("rtmp://std.ossrs.net/live ",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
req.strip();
EXPECT_STREQ("rtmp", req.schema.c_str());
EXPECT_STREQ("std.ossrs.net", req.host.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost.c_str());
EXPECT_STREQ("live", req.app.c_str());
EXPECT_EQ(1935, req.port);
EXPECT_STREQ("rtmp", req.schema_.c_str());
EXPECT_STREQ("std.ossrs.net", req.host_.c_str());
EXPECT_STREQ("std.ossrs.net", req.vhost_.c_str());
EXPECT_STREQ("live", req.app_.c_str());
EXPECT_EQ(1935, req.port_);
EXPECT_TRUE(NULL == req.args);
EXPECT_TRUE(NULL == req.args_);
SrsRequest req1;
req1.args = SrsAmf0Any::object();
req1.args_ = SrsAmf0Any::object();
req.update_auth(&req1);
EXPECT_TRUE(NULL != req.args);
EXPECT_TRUE(req1.args != req.args);
EXPECT_TRUE(NULL != req.args_);
EXPECT_TRUE(req1.args_ != req.args_);
param = "";
req.stream = "livestream";
req.stream_ = "livestream";
srs_net_url_parse_tcurl("rtmp://std.ossrs.net/live#b=2",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
EXPECT_STREQ("#b=2/livestream", param.c_str());
param = "";
req.stream = "livestream";
req.stream_ = "livestream";
srs_net_url_parse_tcurl("rtmp://std.ossrs.net/live?a=1#b=2",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
EXPECT_STREQ("?a=1#b=2", param.c_str());
param = "";
srs_net_url_parse_tcurl("rtmp://std.ossrs.net/live?a=1&c=3#b=2",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
EXPECT_STREQ("?a=1&c=3#b=2", param.c_str());
param = "";
srs_net_url_parse_tcurl("rtmp://std.ossrs.net/live?a=1&c=3#b=2#d=4",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
EXPECT_STREQ("?a=1&c=3#b=2#d=4", param.c_str());
param = "";
srs_net_url_parse_tcurl("rtmp://std.ossrs.net/live?a=1#e=5&c=3#b=2#d=4",
req.schema, req.host, req.vhost, req.app, req.stream, req.port, param);
req.schema_, req.host_, req.vhost_, req.app_, req.stream_, req.port_, param);
EXPECT_STREQ("?a=1#e=5&c=3#b=2#d=4", param.c_str());
}
@ -5223,13 +5223,13 @@ VOID TEST(ProtocolRTMPTest, RTMPHandshakeBytes)
bio.in_buffer.append(hs, sizeof(hs));
HELPER_EXPECT_SUCCESS(bytes.read_c0c1(&bio));
EXPECT_TRUE(bytes.c0c1 != NULL);
EXPECT_TRUE(bytes.c0c1_ != NULL);
HELPER_EXPECT_SUCCESS(bytes.read_c2(&bio));
EXPECT_TRUE(bytes.c2 != NULL);
EXPECT_TRUE(bytes.c2_ != NULL);
HELPER_EXPECT_SUCCESS(bytes.read_s0s1s2(&bio));
EXPECT_TRUE(bytes.s0s1s2 != NULL);
EXPECT_TRUE(bytes.s0s1s2_ != NULL);
}
#ifdef SRS_RTSP

View File

@ -138,7 +138,7 @@ VOID TEST(ProtocolRTMPTest, ManualFlush)
HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1));
p.set_auto_response(true);
HELPER_EXPECT_SUCCESS(p.protocol->response_acknowledgement_message());
HELPER_EXPECT_SUCCESS(p.protocol_->response_acknowledgement_message());
EXPECT_EQ(12 + 4, io.out_buffer.length());
}
@ -424,7 +424,7 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages)
SrsProtocol p(&io);
SrsSetChunkSizePacket *pkt = new SrsSetChunkSizePacket();
pkt->chunk_size = 0;
pkt->chunk_size_ = 0;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1));
bytes.append(&io.out_buffer);
@ -471,7 +471,7 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages2)
SrsUniquePtr<SrsRtmpCommand> pkt_uptr(pkt);
SrsCallPacket *call = (SrsCallPacket *)pkt;
EXPECT_STREQ("s", call->command_name.c_str());
EXPECT_STREQ("s", call->command_name_.c_str());
}
if (true) {
@ -571,7 +571,7 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages3)
SrsProtocol p(&io);
SrsConnectAppPacket *request = new SrsConnectAppPacket();
request->transaction_id = 0.0;
request->transaction_id_ = 0.0;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1));
uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't', 0x00, 0, 0, 0, 0, 0, 0, 0, 0};
@ -589,7 +589,7 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages3)
SrsProtocol p(&io);
SrsCreateStreamPacket *request = new SrsCreateStreamPacket();
request->transaction_id = 0.0;
request->transaction_id_ = 0.0;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1));
uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't', 0x00, 0, 0, 0, 0, 0, 0, 0, 0};
@ -607,7 +607,7 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages3)
SrsProtocol p(&io);
SrsFMLEStartPacket *request = SrsFMLEStartPacket::create_FC_publish("livestream");
request->transaction_id = 0.0;
request->transaction_id_ = 0.0;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1));
uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't', 0x00, 0, 0, 0, 0, 0, 0, 0, 0};
@ -625,7 +625,7 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages3)
SrsProtocol p(&io);
SrsFMLEStartPacket *request = SrsFMLEStartPacket::create_release_stream("livestream");
request->transaction_id = 0.0;
request->transaction_id_ = 0.0;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1));
uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't', 0x00, 0, 0, 0, 0, 0, 0, 0, 0};
@ -643,8 +643,8 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages3)
SrsProtocol p(&io);
SrsFMLEStartPacket *request = SrsFMLEStartPacket::create_release_stream("livestream");
request->command_name = RTMP_AMF0_COMMAND_UNPUBLISH;
request->transaction_id = 0.0;
request->command_name_ = RTMP_AMF0_COMMAND_UNPUBLISH;
request->transaction_id_ = 0.0;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1));
uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't', 0x00, 0, 0, 0, 0, 0, 0, 0, 0};
@ -662,8 +662,8 @@ VOID TEST(ProtocolRTMPTest, OnDecodeMessages3)
SrsProtocol p(&io);
SrsFMLEStartPacket *request = new SrsFMLEStartPacket();
request->command_name = "srs";
request->transaction_id = 0.0;
request->command_name_ = "srs";
request->transaction_id_ = 0.0;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1));
uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't', 0x00, 0, 0, 0, 0, 0, 0, 0, 0};
@ -920,7 +920,7 @@ VOID TEST(ProtocolRTMPTest, RecvMessage2)
MockBufferIO io;
SrsProtocol p(&io);
p.in_chunk_size = 3;
p.in_chunk_size_ = 3;
uint8_t bytes[] = {0x03, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 1, 2, 3};
io.in_buffer.append((char *)bytes, sizeof(bytes));
@ -967,25 +967,25 @@ VOID TEST(ProtocolRTMPTest, RecvMessage3)
{
if (true) {
SrsRequest req;
req.ip = "10.11.12.13";
req.ip_ = "10.11.12.13";
ISrsRequest *cp = req.copy();
EXPECT_STREQ("10.11.12.13", cp->ip.c_str());
EXPECT_STREQ("10.11.12.13", cp->ip_.c_str());
srs_freep(cp);
}
if (true) {
SrsRequest req;
req.ip = "10.11.12.13";
req.ip_ = "10.11.12.13";
SrsAmf0Object *obj = SrsAmf0Any::object();
obj->set("id", SrsAmf0Any::str("srs"));
req.args = obj;
req.args_ = obj;
ISrsRequest *cp = req.copy();
EXPECT_STREQ("10.11.12.13", cp->ip.c_str());
EXPECT_STREQ("10.11.12.13", cp->ip_.c_str());
SrsAmf0Object *cpa = dynamic_cast<SrsAmf0Object *>(cp->args);
SrsAmf0Object *cpa = dynamic_cast<SrsAmf0Object *>(cp->args_);
SrsAmf0Any *cps = cpa->ensure_property_string("id");
EXPECT_STREQ("srs", cps->to_str().c_str());
srs_freep(cp);
@ -998,15 +998,15 @@ VOID TEST(ProtocolRTMPTest, RecvMessage3)
if (true) {
SrsRequest req;
EXPECT_STREQ("", req.schema.c_str());
EXPECT_STREQ("", req.schema_.c_str());
req.as_http();
EXPECT_STREQ("http", req.schema.c_str());
EXPECT_STREQ("http", req.schema_.c_str());
}
if (true) {
SrsResponse res;
EXPECT_EQ(1, res.stream_id);
EXPECT_EQ(1, res.stream_id_);
}
if (true) {
@ -1036,7 +1036,7 @@ VOID TEST(ProtocolRTMPTest, RecvMessage4)
SrsProtocol p(&io);
SrsSetChunkSizePacket *pkt = new SrsSetChunkSizePacket();
pkt->chunk_size = 256;
pkt->chunk_size_ = 256;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 0));
io.in_buffer.append(&io.out_buffer);
@ -1045,7 +1045,7 @@ VOID TEST(ProtocolRTMPTest, RecvMessage4)
HELPER_EXPECT_SUCCESS(p.recv_message(&msg));
SrsUniquePtr<SrsRtmpCommonMessage> msg_uptr(msg);
EXPECT_EQ(256, p.out_chunk_size);
EXPECT_EQ(256, p.out_chunk_size_);
}
if (true) {
@ -1053,8 +1053,8 @@ VOID TEST(ProtocolRTMPTest, RecvMessage4)
SrsProtocol p(&io);
SrsUserControlPacket *pkt = new SrsUserControlPacket();
pkt->event_type = SrcPCUCSetBufferLength;
pkt->extra_data = 256;
pkt->event_type_ = SrcPCUCSetBufferLength;
pkt->extra_data_ = 256;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 0));
io.in_buffer.append(&io.out_buffer);
@ -1063,7 +1063,7 @@ VOID TEST(ProtocolRTMPTest, RecvMessage4)
HELPER_EXPECT_SUCCESS(p.recv_message(&msg));
SrsUniquePtr<SrsRtmpCommonMessage> msg_uptr(msg);
EXPECT_EQ(256, p.in_buffer_length);
EXPECT_EQ(256, p.in_buffer_length_);
}
}
@ -1108,7 +1108,7 @@ VOID TEST(ProtocolRTMPTest, HandshakeC0C1)
SrsHandshakeBytes hs;
HELPER_EXPECT_SUCCESS(hs.read_c0c1(&io));
EXPECT_EQ((uint32_t)0x01020304, (uint32_t)hs.proxy_real_ip);
EXPECT_EQ((uint32_t)0x01020304, (uint32_t)hs.proxy_real_ip_);
}
// It's extended c0c1 prefixed with ip, which should be ok.
@ -1128,7 +1128,7 @@ VOID TEST(ProtocolRTMPTest, HandshakeC0C1)
io.append(buf, sizeof(buf));
SrsRtmpServer r(&io);
HELPER_EXPECT_SUCCESS(r.hs_bytes->read_c0c1(&io));
HELPER_EXPECT_SUCCESS(r.hs_bytes_->read_c0c1(&io));
EXPECT_EQ((uint32_t)0x01020304, (uint32_t)r.proxy_real_ip());
}
@ -1280,12 +1280,12 @@ VOID TEST(ProtocolRTMPTest, HandshakeC2)
VOID TEST(ProtocolRTMPTest, ServerInfo)
{
SrsServerInfo si;
EXPECT_EQ(0, si.pid);
EXPECT_EQ(0, si.cid);
EXPECT_EQ(0, si.major);
EXPECT_EQ(0, si.minor);
EXPECT_EQ(0, si.revision);
EXPECT_EQ(0, si.build);
EXPECT_EQ(0, si.pid_);
EXPECT_EQ(0, si.cid_);
EXPECT_EQ(0, si.major_);
EXPECT_EQ(0, si.minor_);
EXPECT_EQ(0, si.revision_);
EXPECT_EQ(0, si.build_);
}
VOID TEST(ProtocolRTMPTest, ClientCommandMessage)
@ -1300,7 +1300,7 @@ VOID TEST(ProtocolRTMPTest, ClientCommandMessage)
SrsConnectAppResPacket *res = new SrsConnectAppResPacket();
SrsAmf0EcmaArray *data = SrsAmf0Any::ecma_array();
res->info->set("data", data);
res->info_->set("data", data);
data->set("srs_server_ip", SrsAmf0Any::str("1.2.3.4"));
data->set("srs_server", SrsAmf0Any::str("srs"));
@ -1320,14 +1320,14 @@ VOID TEST(ProtocolRTMPTest, ClientCommandMessage)
SrsServerInfo si;
HELPER_EXPECT_SUCCESS(r.connect_app("live", "rtmp://127.0.0.1/live", &req, true, &si));
EXPECT_STREQ("1.2.3.4", si.ip.c_str());
EXPECT_STREQ("srs", si.sig.c_str());
EXPECT_EQ(100, si.cid);
EXPECT_EQ(200, si.pid);
EXPECT_EQ(3, si.major);
EXPECT_EQ(4, si.minor);
EXPECT_EQ(5, si.revision);
EXPECT_EQ(678, si.build);
EXPECT_STREQ("1.2.3.4", si.ip_.c_str());
EXPECT_STREQ("srs", si.sig_.c_str());
EXPECT_EQ(100, si.cid_);
EXPECT_EQ(200, si.pid_);
EXPECT_EQ(3, si.major_);
EXPECT_EQ(4, si.minor_);
EXPECT_EQ(5, si.revision_);
EXPECT_EQ(678, si.build_);
}
// CreateStream.
@ -1399,7 +1399,7 @@ VOID TEST(ProtocolRTMPTest, ServerCommandMessage)
if (true) {
SrsConnectAppPacket *res = new SrsConnectAppPacket();
res->command_object->set("tcUrl", SrsAmf0Any::str("rtmp://127.0.0.1/live"));
res->command_object_->set("tcUrl", SrsAmf0Any::str("rtmp://127.0.0.1/live"));
MockBufferIO tio;
SrsProtocol p(&tio);
@ -1412,10 +1412,10 @@ VOID TEST(ProtocolRTMPTest, ServerCommandMessage)
SrsRequest req;
HELPER_EXPECT_SUCCESS(r.connect_app(&req));
EXPECT_STREQ("rtmp", req.schema.c_str());
EXPECT_STREQ("127.0.0.1", req.host.c_str());
EXPECT_STREQ("127.0.0.1", req.vhost.c_str());
EXPECT_STREQ("live", req.app.c_str());
EXPECT_STREQ("rtmp", req.schema_.c_str());
EXPECT_STREQ("127.0.0.1", req.host_.c_str());
EXPECT_STREQ("127.0.0.1", req.vhost_.c_str());
EXPECT_STREQ("live", req.app_.c_str());
}
// Window ACK size.
@ -1433,7 +1433,7 @@ VOID TEST(ProtocolRTMPTest, ServerCommandMessage)
SrsRtmpCommonMessage *msg = NULL;
SrsSetWindowAckSizePacket *pkt = NULL;
HELPER_ASSERT_SUCCESS(p.expect_message(&msg, &pkt));
EXPECT_EQ(1024, pkt->ackowledgement_window_size);
EXPECT_EQ(1024, pkt->ackowledgement_window_size_);
srs_freep(msg);
srs_freep(pkt);
@ -1446,7 +1446,7 @@ VOID TEST(ProtocolRTMPTest, ServerCommandMessage)
SrsRtmpServer r(&io);
SrsRequest req;
req.objectEncoding = 3.0;
req.objectEncoding_ = 3.0;
const char *ip = "1.2.3.4";
HELPER_EXPECT_SUCCESS(r.response_connect_app(&req, ip));
@ -1468,11 +1468,11 @@ VOID TEST(ProtocolRTMPTest, ServerCommandMessage)
SrsConnectAppResPacket *pkt = NULL;
HELPER_ASSERT_SUCCESS(p.expect_message(&msg, &pkt));
SrsAmf0Any *prop = pkt->info->get_property("objectEncoding");
SrsAmf0Any *prop = pkt->info_->get_property("objectEncoding");
ASSERT_TRUE(prop && prop->is_number());
EXPECT_EQ(3.0, prop->to_number());
prop = pkt->info->get_property("data");
prop = pkt->info_->get_property("data");
ASSERT_TRUE(prop && prop->is_ecma_array());
SrsAmf0EcmaArray *arr = prop->to_ecma_array();
@ -1503,7 +1503,7 @@ VOID TEST(ProtocolRTMPTest, ServerCommandMessage)
SrsCallPacket *pkt = NULL;
HELPER_ASSERT_SUCCESS(p.expect_message(&msg, &pkt));
SrsAmf0Any *prop = pkt->arguments;
SrsAmf0Any *prop = pkt->arguments_;
ASSERT_TRUE(prop && prop->is_object());
prop = prop->to_object()->get_property(StatusDescription);
@ -1539,7 +1539,7 @@ VOID TEST(ProtocolRTMPTest, ServerCommandMessage)
HELPER_EXPECT_SUCCESS(p.recv_message(&msg));
SrsUniquePtr<SrsRtmpCommonMessage> msg_uptr(msg);
EXPECT_EQ(1024, p.in_chunk_size);
EXPECT_EQ(1024, p.in_chunk_size_);
}
}
}
@ -1554,13 +1554,13 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
SrsRtmpServer r(&io);
SrsRequest req;
req.app = "live";
req.stream = "livestream";
req.app_ = "live";
req.stream_ = "livestream";
string host = "target.net";
int port = 8888;
bool accepted = false;
string rurl = srs_net_url_encode_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param);
string rurl = srs_net_url_encode_rtmp_url(host, port, req.host_, req.vhost_, req.app_, req.stream_, req.param_);
HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted));
if (true) {
@ -1573,7 +1573,7 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
SrsCallPacket *pkt = NULL;
HELPER_ASSERT_SUCCESS(p.expect_message(&msg, &pkt));
SrsAmf0Any *prop = pkt->arguments;
SrsAmf0Any *prop = pkt->arguments_;
ASSERT_TRUE(prop && prop->is_object());
prop = prop->to_object()->get_property("ex");
@ -1611,22 +1611,22 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
SrsProtocol p(&tio);
SrsCallPacket *call = new SrsCallPacket();
call->command_name = "redirected";
call->command_object = SrsAmf0Any::object();
call->arguments = SrsAmf0Any::str("OK");
call->command_name_ = "redirected";
call->command_object_ = SrsAmf0Any::object();
call->arguments_ = SrsAmf0Any::str("OK");
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(call, 0));
io.in_buffer.append(&tio.out_buffer);
}
SrsRequest req;
req.app = "live";
req.stream = "livestream";
req.app_ = "live";
req.stream_ = "livestream";
string host = "target.net";
int port = 8888;
bool accepted = false;
string rurl = srs_net_url_encode_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param);
string rurl = srs_net_url_encode_rtmp_url(host, port, req.host_, req.vhost_, req.app_, req.stream_, req.param_);
HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted));
EXPECT_TRUE(accepted);
@ -1640,7 +1640,7 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
SrsCallPacket *pkt = NULL;
HELPER_ASSERT_SUCCESS(p.expect_message(&msg, &pkt));
SrsAmf0Any *prop = pkt->arguments;
SrsAmf0Any *prop = pkt->arguments_;
ASSERT_TRUE(prop && prop->is_object());
prop = prop->to_object()->get_property("ex");
@ -1697,8 +1697,8 @@ VOID TEST(ProtocolRTMPTest, ServerIdentify)
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(call, 0));
SrsPlayPacket *play = new SrsPlayPacket();
play->stream_name = "livestream";
play->duration = 100;
play->stream_name_ = "livestream";
play->duration_ = 100;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(play, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1728,8 +1728,8 @@ VOID TEST(ProtocolRTMPTest, ServerIdentify)
}
SrsPlayPacket *play = new SrsPlayPacket();
play->stream_name = "livestream";
play->duration = 100;
play->stream_name_ = "livestream";
play->duration_ = 100;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(play, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1757,7 +1757,7 @@ VOID TEST(ProtocolRTMPTest, ServerIdentify)
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(call, 0));
SrsPublishPacket *publish = new SrsPublishPacket();
publish->stream_name = "livestream";
publish->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(publish, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1784,7 +1784,7 @@ VOID TEST(ProtocolRTMPTest, ServerIdentify)
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(call, 0));
SrsFMLEStartPacket *fmle = new SrsFMLEStartPacket();
fmle->stream_name = "livestream";
fmle->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(fmle, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1808,8 +1808,8 @@ VOID TEST(ProtocolRTMPTest, ServerIdentify)
SrsProtocol p(&tio);
SrsPlayPacket *play = new SrsPlayPacket();
play->stream_name = "livestream";
play->duration = 100;
play->stream_name_ = "livestream";
play->duration_ = 100;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(play, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1834,7 +1834,7 @@ VOID TEST(ProtocolRTMPTest, ServerIdentify)
SrsProtocol p(&tio);
SrsFMLEStartPacket *fmle = new SrsFMLEStartPacket();
fmle->stream_name = "livestream";
fmle->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(fmle, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1862,14 +1862,14 @@ VOID TEST(ProtocolRTMPTest, ServerFMLEStart)
SrsProtocol p(&tio);
if (true) {
SrsFMLEStartPacket *fmle = new SrsFMLEStartPacket();
fmle->stream_name = "livestream";
fmle->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(fmle, 0));
SrsCreateStreamPacket *cs = new SrsCreateStreamPacket();
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(cs, 0));
SrsPublishPacket *publish = new SrsPublishPacket();
publish->stream_name = "livestream";
publish->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(publish, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1894,7 +1894,7 @@ VOID TEST(ProtocolRTMPTest, ServerFMLEStart)
SrsRtmpCommonMessage *msg = NULL;
SrsCreateStreamResPacket *pkt = NULL;
HELPER_ASSERT_SUCCESS(p.expect_message(&msg, &pkt));
EXPECT_EQ(1, pkt->stream_id);
EXPECT_EQ(1, pkt->stream_id_);
srs_freep(msg);
srs_freep(pkt);
}
@ -1935,7 +1935,7 @@ VOID TEST(ProtocolRTMPTest, ServerHaivisionPublish)
SrsProtocol p(&tio);
if (true) {
SrsPublishPacket *publish = new SrsPublishPacket();
publish->stream_name = "livestream";
publish->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(publish, 0));
io.in_buffer.append(&tio.out_buffer);
@ -1982,8 +1982,8 @@ VOID TEST(ProtocolRTMPTest, ServerFMLEUnpublish)
SrsProtocol p(&tio);
if (true) {
SrsFMLEStartPacket *fmle = new SrsFMLEStartPacket();
fmle->transaction_id = 3.0;
fmle->stream_name = "livestream";
fmle->transaction_id_ = 3.0;
fmle->stream_name_ = "livestream";
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(fmle, 0));
io.in_buffer.append(&tio.out_buffer);
@ -2194,21 +2194,21 @@ VOID TEST(ProtocolRTMPTest, ServerResponseCommands)
SrsProtocol p(&tio);
SrsCallPacket *call = new SrsCallPacket();
call->command_name = "_checkbw";
call->transaction_id = 5.0;
call->command_object = SrsAmf0Any::object();
call->command_name_ = "_checkbw";
call->transaction_id_ = 5.0;
call->command_object_ = SrsAmf0Any::object();
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(call, 0));
SrsOnStatusDataPacket *data = new SrsOnStatusDataPacket();
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(data, 0));
SrsSetChunkSizePacket *scs = new SrsSetChunkSizePacket();
scs->chunk_size = 1024;
scs->chunk_size_ = 1024;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(scs, 0));
SrsPlayPacket *play = new SrsPlayPacket();
play->stream_name = "livestream";
play->duration = 100;
play->stream_name_ = "livestream";
play->duration_ = 100;
HELPER_EXPECT_SUCCESS(p.send_and_free_packet(play, 0));
io.in_buffer.append(&tio.out_buffer);
@ -2276,7 +2276,7 @@ VOID TEST(ProtocolRTMPTest, CoverAll)
EXPECT_EQ(100 * SRS_UTIME_MILLISECONDS, r.get_send_timeout());
r.set_recv_buffer(SRS_DEFAULT_RECV_BUFFER_SIZE + 10);
EXPECT_EQ(SRS_DEFAULT_RECV_BUFFER_SIZE + 10, r.protocol->in_buffer->nb_buffer);
EXPECT_EQ(SRS_DEFAULT_RECV_BUFFER_SIZE + 10, r.protocol_->in_buffer_->nb_buffer);
EXPECT_EQ(0, r.get_recv_bytes());
EXPECT_EQ(0, r.get_send_bytes());
@ -2316,14 +2316,14 @@ VOID TEST(ProtocolRTMPTest, CoverAll)
SrsRtmpClient r(&io);
SrsAcknowledgementPacket *ack = new SrsAcknowledgementPacket();
ack->sequence_number = 1024;
ack->sequence_number_ = 1024;
HELPER_ASSERT_SUCCESS(r.send_and_free_packet(ack, 0));
io.in_buffer.append(&io.out_buffer);
SrsRtmpCommonMessage *msg = NULL;
SrsAcknowledgementPacket *pkt = NULL;
HELPER_ASSERT_SUCCESS(r.expect_message(&msg, &pkt));
EXPECT_EQ(1024, (int)pkt->sequence_number);
EXPECT_EQ(1024, (int)pkt->sequence_number_);
srs_freep(msg);
srs_freep(pkt);
}
@ -2355,7 +2355,7 @@ VOID TEST(ProtocolRTMPTest, CoverAllUnmarshal)
buf.skip(-1 * buf.pos());
HELPER_ASSERT_SUCCESS(p->decode(&buf));
SrsAmf0Any *prop = p->metadata->get_property("license");
SrsAmf0Any *prop = p->metadata_->get_property("license");
ASSERT_TRUE(prop && prop->is_string());
EXPECT_STREQ("MIT", prop->to_str().c_str());
}
@ -2366,13 +2366,13 @@ VOID TEST(ProtocolRTMPTest, CoverAllUnmarshal)
if (true) {
SrsConnectAppPacket *pkt = new SrsConnectAppPacket();
pkt->command_object->set("tcUrl", SrsAmf0Any::str("rtmp://127.0.0.1/live"));
pkt->command_object->set("pageUrl", SrsAmf0Any::str("http://ossrs.net"));
pkt->command_object->set("swfUrl", SrsAmf0Any::str("http://ossrs.net/index.swf"));
pkt->command_object->set("objectEncoding", SrsAmf0Any::number(5.0));
pkt->command_object_->set("tcUrl", SrsAmf0Any::str("rtmp://127.0.0.1/live"));
pkt->command_object_->set("pageUrl", SrsAmf0Any::str("http://ossrs.net"));
pkt->command_object_->set("swfUrl", SrsAmf0Any::str("http://ossrs.net/index.swf"));
pkt->command_object_->set("objectEncoding", SrsAmf0Any::number(5.0));
pkt->args = SrsAmf0Any::object();
pkt->args->set("license", SrsAmf0Any::str("MIT"));
pkt->args_ = SrsAmf0Any::object();
pkt->args_->set("license", SrsAmf0Any::str("MIT"));
HELPER_EXPECT_SUCCESS(r.send_and_free_packet(pkt, 0));
io.in_buffer.append(&io.out_buffer);
@ -2381,16 +2381,16 @@ VOID TEST(ProtocolRTMPTest, CoverAllUnmarshal)
SrsRequest req;
HELPER_EXPECT_SUCCESS(r.connect_app(&req));
EXPECT_STREQ("rtmp", req.schema.c_str());
EXPECT_STREQ("127.0.0.1", req.host.c_str());
EXPECT_STREQ("127.0.0.1", req.vhost.c_str());
EXPECT_STREQ("live", req.app.c_str());
EXPECT_STREQ("http://ossrs.net", req.pageUrl.c_str());
EXPECT_STREQ("http://ossrs.net/index.swf", req.swfUrl.c_str());
EXPECT_EQ(5.0, req.objectEncoding);
EXPECT_STREQ("rtmp", req.schema_.c_str());
EXPECT_STREQ("127.0.0.1", req.host_.c_str());
EXPECT_STREQ("127.0.0.1", req.vhost_.c_str());
EXPECT_STREQ("live", req.app_.c_str());
EXPECT_STREQ("http://ossrs.net", req.pageUrl_.c_str());
EXPECT_STREQ("http://ossrs.net/index.swf", req.swfUrl_.c_str());
EXPECT_EQ(5.0, req.objectEncoding_);
ASSERT_TRUE(req.args && req.args->is_object());
SrsAmf0Any *prop = req.args->get_property("license");
ASSERT_TRUE(req.args_ && req.args_->is_object());
SrsAmf0Any *prop = req.args_->get_property("license");
ASSERT_TRUE(prop && prop->is_string());
EXPECT_STREQ("MIT", prop->to_str().c_str());
}
@ -2401,7 +2401,7 @@ VOID TEST(ProtocolRTMPTest, CoverAllUnmarshal)
if (true) {
SrsConnectAppPacket *pkt = new SrsConnectAppPacket();
pkt->command_object->set("tcUrl", SrsAmf0Any::number(3.0));
pkt->command_object_->set("tcUrl", SrsAmf0Any::number(3.0));
HELPER_EXPECT_SUCCESS(r.send_and_free_packet(pkt, 0));
io.in_buffer.append(&io.out_buffer);
}
@ -2438,8 +2438,8 @@ VOID TEST(ProtocolRTMPTest, CoverAllUnmarshal)
buf.skip(-1 * buf.pos());
HELPER_ASSERT_SUCCESS(p->decode(&buf));
EXPECT_TRUE(p->is_pause);
EXPECT_EQ(30.0, p->time_ms);
EXPECT_TRUE(p->is_pause_);
EXPECT_EQ(30.0, p->time_ms_);
}
if (true) {
@ -2476,10 +2476,10 @@ VOID TEST(ProtocolRTMPTest, CoverAllUnmarshal)
buf.skip(-1 * buf.pos());
HELPER_ASSERT_SUCCESS(p->decode(&buf));
EXPECT_STREQ("livestream", p->stream_name.c_str());
EXPECT_EQ(20.0, p->start);
EXPECT_EQ(30.0, p->duration);
EXPECT_TRUE(p->reset);
EXPECT_STREQ("livestream", p->stream_name_.c_str());
EXPECT_EQ(20.0, p->start_);
EXPECT_EQ(30.0, p->duration_);
EXPECT_TRUE(p->reset_);
}
if (true) {
@ -2516,10 +2516,10 @@ VOID TEST(ProtocolRTMPTest, CoverAllUnmarshal)
buf.skip(-1 * buf.pos());
HELPER_ASSERT_SUCCESS(p->decode(&buf));
EXPECT_STREQ("livestream", p->stream_name.c_str());
EXPECT_EQ(20.0, p->start);
EXPECT_EQ(30.0, p->duration);
EXPECT_TRUE(p->reset);
EXPECT_STREQ("livestream", p->stream_name_.c_str());
EXPECT_EQ(20.0, p->start_);
EXPECT_EQ(30.0, p->duration_);
EXPECT_TRUE(p->reset_);
}
if (true) {
@ -2594,7 +2594,7 @@ VOID TEST(ProtocolRTMPTest, ConnectAppWithArgs)
SrsConnectAppResPacket *res = new SrsConnectAppResPacket();
SrsAmf0EcmaArray *data = SrsAmf0Any::ecma_array();
res->info->set("data", data);
res->info_->set("data", data);
data->set("srs_server_ip", SrsAmf0Any::str("1.2.3.4"));
data->set("srs_server", SrsAmf0Any::str("srs"));
@ -2608,21 +2608,21 @@ VOID TEST(ProtocolRTMPTest, ConnectAppWithArgs)
}
SrsRequest req;
req.args = SrsAmf0Any::object();
req.args->set("license", SrsAmf0Any::str("MIT"));
req.args_ = SrsAmf0Any::object();
req.args_->set("license", SrsAmf0Any::str("MIT"));
SrsRtmpClient r(&io);
SrsServerInfo si;
HELPER_EXPECT_SUCCESS(r.connect_app("live", "rtmp://127.0.0.1/live", &req, true, &si));
EXPECT_STREQ("1.2.3.4", si.ip.c_str());
EXPECT_STREQ("srs", si.sig.c_str());
EXPECT_EQ(100, si.cid);
EXPECT_EQ(200, si.pid);
EXPECT_EQ(3, si.major);
EXPECT_EQ(4, si.minor);
EXPECT_EQ(5, si.revision);
EXPECT_EQ(678, si.build);
EXPECT_STREQ("1.2.3.4", si.ip_.c_str());
EXPECT_STREQ("srs", si.sig_.c_str());
EXPECT_EQ(100, si.cid_);
EXPECT_EQ(200, si.pid_);
EXPECT_EQ(3, si.major_);
EXPECT_EQ(4, si.minor_);
EXPECT_EQ(5, si.revision_);
EXPECT_EQ(678, si.build_);
if (true) {
tio.in_buffer.append(&io.out_buffer);
@ -2633,12 +2633,12 @@ VOID TEST(ProtocolRTMPTest, ConnectAppWithArgs)
SrsUniquePtr<SrsRtmpCommonMessage> msg_uptr(msg);
SrsUniquePtr<SrsConnectAppPacket> pkt_uptr(pkt);
SrsAmf0Any *prop = pkt->command_object->get_property("tcUrl");
SrsAmf0Any *prop = pkt->command_object_->get_property("tcUrl");
ASSERT_TRUE(prop && prop->is_string());
EXPECT_STREQ("rtmp://127.0.0.1/live", prop->to_str().c_str());
ASSERT_TRUE(pkt->args);
prop = pkt->args->get_property("license");
ASSERT_TRUE(pkt->args_);
prop = pkt->args_->get_property("license");
ASSERT_TRUE(prop && prop->is_string());
EXPECT_STREQ("MIT", prop->to_str().c_str());
}
@ -3043,18 +3043,18 @@ VOID TEST(ProtocolRTMPTest, OthersAll)
SrsMessageArray *parr = &h;
SrsUniquePtr<SrsMessageArray> parr2(parr, srs_utest_free_message_array);
h.msgs[0] = new SrsMediaPacket();
h.msgs[1] = new SrsMediaPacket();
EXPECT_TRUE(NULL != h.msgs[0]);
EXPECT_TRUE(NULL != h.msgs[1]);
h.msgs_[0] = new SrsMediaPacket();
h.msgs_[1] = new SrsMediaPacket();
EXPECT_TRUE(NULL != h.msgs_[0]);
EXPECT_TRUE(NULL != h.msgs_[1]);
h.free(1);
EXPECT_TRUE(NULL == h.msgs[0]);
EXPECT_TRUE(NULL != h.msgs[1]);
EXPECT_TRUE(NULL == h.msgs_[0]);
EXPECT_TRUE(NULL != h.msgs_[1]);
h.free(2);
EXPECT_TRUE(NULL == h.msgs[0]);
EXPECT_TRUE(NULL == h.msgs[1]);
EXPECT_TRUE(NULL == h.msgs_[0]);
EXPECT_TRUE(NULL == h.msgs_[1]);
}
}

View File

@ -509,8 +509,8 @@ VOID TEST(HTTPServerTest, MessageConnection)
if (true) {
SrsHttpMessage m;
HELPER_EXPECT_SUCCESS(m.set_url("http://127.0.0.1/live/livestream.flv?callback=fn&method=POST", true));
EXPECT_TRUE(m.jsonp);
EXPECT_STREQ("POST", m.jsonp_method.c_str());
EXPECT_TRUE(m.jsonp_);
EXPECT_STREQ("POST", m.jsonp_method_.c_str());
EXPECT_TRUE(m.is_jsonp());
}
@ -635,9 +635,9 @@ VOID TEST(HTTPServerTest, MessageTurnRequest)
SrsHttpMessage m;
HELPER_ASSERT_SUCCESS(m.set_url("http://127.0.0.1/live/livestream.flv", false));
ISrsRequest *r = m.to_request("ossrs.net");
EXPECT_STREQ("live", r->app.c_str());
EXPECT_STREQ("livestream", r->stream.c_str());
EXPECT_STREQ("rtmp://ossrs.net/live", r->tcUrl.c_str());
EXPECT_STREQ("live", r->app_.c_str());
EXPECT_STREQ("livestream", r->stream_.c_str());
EXPECT_STREQ("rtmp://ossrs.net/live", r->tcUrl_.c_str());
srs_freep(r);
}
@ -645,8 +645,8 @@ VOID TEST(HTTPServerTest, MessageTurnRequest)
SrsHttpMessage m;
HELPER_ASSERT_SUCCESS(m.set_url("http://127.0.0.1/live/livestream.flv?token=key", false));
ISrsRequest *r = m.to_request("ossrs.net");
EXPECT_STREQ("rtmp://ossrs.net/live", r->tcUrl.c_str());
EXPECT_STREQ("?token=key", r->param.c_str());
EXPECT_STREQ("rtmp://ossrs.net/live", r->tcUrl_.c_str());
EXPECT_STREQ("?token=key", r->param_.c_str());
srs_freep(r);
}
@ -656,7 +656,7 @@ VOID TEST(HTTPServerTest, MessageTurnRequest)
m.set_connection(&conn);
ISrsRequest *r = m.to_request("ossrs.net");
EXPECT_STREQ("127.0.0.1", r->ip.c_str());
EXPECT_STREQ("127.0.0.1", r->ip_.c_str());
srs_freep(r);
}
@ -670,7 +670,7 @@ VOID TEST(HTTPServerTest, MessageTurnRequest)
m.set_header(&hdr, false);
ISrsRequest *r = m.to_request("ossrs.net");
EXPECT_STREQ("10.11.12.13", r->ip.c_str());
EXPECT_STREQ("10.11.12.13", r->ip_.c_str());
srs_freep(r);
}
}

View File

@ -47,29 +47,29 @@ public:
enable_context_switch = context_switch;
// Initialize all ISrsRequest members to safe defaults
objectEncoding = RTMP_SIG_AMF0_VER;
duration = -1;
port = SRS_CONSTS_RTMP_DEFAULT_PORT;
args = NULL; // Initialize to NULL to prevent crashes
protocol = "rtmp";
objectEncoding_ = RTMP_SIG_AMF0_VER;
duration_ = -1;
port_ = SRS_CONSTS_RTMP_DEFAULT_PORT;
args_ = NULL; // Initialize to NULL to prevent crashes
protocol_ = "rtmp";
// Parse the URL to set vhost, app, stream
size_t app_pos = url.find('/', 1); // Find second slash
if (app_pos != string::npos) {
size_t stream_pos = url.find('/', app_pos + 1); // Find third slash
if (stream_pos != string::npos) {
app = url.substr(app_pos + 1, stream_pos - app_pos - 1);
stream = url.substr(stream_pos + 1);
app_ = url.substr(app_pos + 1, stream_pos - app_pos - 1);
stream_ = url.substr(stream_pos + 1);
} else {
app = url.substr(app_pos + 1);
stream = "livestream";
app_ = url.substr(app_pos + 1);
stream_ = "livestream";
}
} else {
app = "live";
stream = "livestream";
app_ = "live";
stream_ = "livestream";
}
vhost = "localhost";
vhost_ = "localhost";
}
virtual string get_stream_url()
@ -93,8 +93,8 @@ public:
MockAsyncSrsRequest *cp = new MockAsyncSrsRequest(mock_stream_url, enable_context_switch);
*cp = *this;
if (args) {
cp->args = args->copy()->to_object();
if (args_) {
cp->args_ = args_->copy()->to_object();
}
return cp;

View File

@ -462,10 +462,10 @@ VOID TEST(ProtocolSrtTest, SrtStreamIdToRequest)
SrsRequest req;
EXPECT_TRUE(srs_srt_streamid_to_request("#!::r=live/livestream?key1=val1,key2=val2", mode, &req));
EXPECT_EQ(mode, SrtModePull);
EXPECT_STREQ(req.vhost.c_str(), srs_get_public_internet_address().c_str());
EXPECT_STREQ(req.app.c_str(), "live");
EXPECT_STREQ(req.stream.c_str(), "livestream");
EXPECT_STREQ(req.param.c_str(), "key1=val1&key2=val2");
EXPECT_STREQ(req.vhost_.c_str(), srs_get_public_internet_address().c_str());
EXPECT_STREQ(req.app_.c_str(), "live");
EXPECT_STREQ(req.stream_.c_str(), "livestream");
EXPECT_STREQ(req.param_.c_str(), "key1=val1&key2=val2");
}
if (true) {
@ -473,10 +473,10 @@ VOID TEST(ProtocolSrtTest, SrtStreamIdToRequest)
SrsRequest req;
EXPECT_TRUE(srs_srt_streamid_to_request("#!::h=srs.srt.com.cn,r=live/livestream?key1=val1,key2=val2", mode, &req));
EXPECT_EQ(mode, SrtModePull);
EXPECT_STREQ(req.vhost.c_str(), "srs.srt.com.cn");
EXPECT_STREQ(req.app.c_str(), "live");
EXPECT_STREQ(req.stream.c_str(), "livestream");
EXPECT_STREQ(req.param.c_str(), "vhost=srs.srt.com.cn&key1=val1&key2=val2");
EXPECT_STREQ(req.vhost_.c_str(), "srs.srt.com.cn");
EXPECT_STREQ(req.app_.c_str(), "live");
EXPECT_STREQ(req.stream_.c_str(), "livestream");
EXPECT_STREQ(req.param_.c_str(), "vhost=srs.srt.com.cn&key1=val1&key2=val2");
}
if (true) {
@ -484,10 +484,10 @@ VOID TEST(ProtocolSrtTest, SrtStreamIdToRequest)
SrsRequest req;
EXPECT_TRUE(srs_srt_streamid_to_request("#!::h=live/livestream?key1=val1,key2=val2", mode, &req));
EXPECT_EQ(mode, SrtModePull);
EXPECT_STREQ(req.vhost.c_str(), srs_get_public_internet_address().c_str());
EXPECT_STREQ(req.app.c_str(), "live");
EXPECT_STREQ(req.stream.c_str(), "livestream");
EXPECT_STREQ(req.param.c_str(), "key1=val1&key2=val2");
EXPECT_STREQ(req.vhost_.c_str(), srs_get_public_internet_address().c_str());
EXPECT_STREQ(req.app_.c_str(), "live");
EXPECT_STREQ(req.stream_.c_str(), "livestream");
EXPECT_STREQ(req.param_.c_str(), "key1=val1&key2=val2");
}
if (true) {
@ -495,10 +495,10 @@ VOID TEST(ProtocolSrtTest, SrtStreamIdToRequest)
SrsRequest req;
EXPECT_TRUE(srs_srt_streamid_to_request("#!::h=srs.srt.com.cn/live/livestream?key1=val1,key2=val2", mode, &req));
EXPECT_EQ(mode, SrtModePull);
EXPECT_STREQ(req.vhost.c_str(), "srs.srt.com.cn");
EXPECT_STREQ(req.app.c_str(), "live");
EXPECT_STREQ(req.stream.c_str(), "livestream");
EXPECT_STREQ(req.param.c_str(), "vhost=srs.srt.com.cn&key1=val1&key2=val2");
EXPECT_STREQ(req.vhost_.c_str(), "srs.srt.com.cn");
EXPECT_STREQ(req.app_.c_str(), "live");
EXPECT_STREQ(req.stream_.c_str(), "livestream");
EXPECT_STREQ(req.param_.c_str(), "vhost=srs.srt.com.cn&key1=val1&key2=val2");
}
}