winlin

fix demo script, start nginx. fix warning of utest on ubuntu14

... ... @@ -4,7 +4,7 @@ if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本";
# step 1: build srs
echo "编译SRS"
./configure --x86-x64 && make
./configure --x86-x64 --with-nginx && make
ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi
echo "编译SRS成功"
... ...
... ... @@ -8,6 +8,9 @@ GREEN="\\e[32m"
YELLOW="\\e[33m"
BLACK="\\e[0m"
sudo ./objs/nginx/sbin/nginx
echo "启动nginx"
./etc/init.d/srs-demo restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi
echo "启动SRS服务器成功"
... ...
#!/bin/bash
sudo ./objs/nginx/sbin/nginx -s stop
echo "停止nginx"
./etc/init.d/srs-demo stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止SRS失败"; exit $ret; fi
echo "停止SRS服务器成功"
... ...
... ... @@ -262,18 +262,7 @@ int srs_connect_app(srs_rtmp_t rtmp)
srs_assert(rtmp != NULL);
Context* context = (Context*)rtmp;
string tcUrl = "rtmp://";
// TODO: FIXME: extrace shared method
if (context->vhost == RTMP_VHOST_DEFAULT) {
tcUrl += context->ip;
} else {
tcUrl += context->vhost;
}
tcUrl += ":";
tcUrl += context->port;
tcUrl += "/";
tcUrl += context->app;
string tcUrl = srs_generate_tc_url(context->ip, context->vhost, context->app, context->port);
if ((ret = context->rtmp->connect_app(context->app, tcUrl)) != ERROR_SUCCESS) {
return ret;
}
... ...
... ... @@ -24,11 +24,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_protocol_utility.hpp>
#include <stdlib.h>
using namespace std;
#include <srs_kernel_log.hpp>
#include <srs_kernel_utility.hpp>
void srs_vhost_resolve(std::string& vhost, std::string& app)
void srs_vhost_resolve(string& vhost, string& app)
{
app = srs_string_replace(app, "...", "?");
... ... @@ -71,3 +72,24 @@ void srs_random_generate(char* bytes, int size)
bytes[i] = cdata[rand() % (sizeof(cdata) - 1)];
}
}
string srs_generate_tc_url(string ip, string vhost, string app, string port)
{
string tcUrl = "rtmp://";
if (vhost == RTMP_VHOST_DEFAULT) {
tcUrl += ip;
} else {
tcUrl += vhost;
}
if (port != RTMP_DEFAULT_PORT) {
tcUrl += ":";
tcUrl += port;
}
tcUrl += "/";
tcUrl += app;
return tcUrl;
}
... ...
... ... @@ -31,9 +31,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
// default vhost for rtmp
// default vhost of rtmp
#define RTMP_VHOST_DEFAULT "__defaultVhost__"
// default port of rtmp
#define RTMP_DEFAULT_PORT "1935"
// the default chunk size for system.
... ... @@ -45,6 +45,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// app...vhost...request_vhost
extern void srs_vhost_resolve(std::string& vhost, std::string& app);
// generate ramdom data for handshake.
extern void srs_random_generate(char* bytes, int size);
// generate the tcUrl.
extern std::string srs_generate_tc_url(std::string ip, std::string vhost, std::string app, std::string port);
#endif
... ...