mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fixbug[play packet decode bug: srs only read bool type play reset value, actually this value can be bool or number]
This commit is contained in:
commit
bfef0eebfe
74 changed files with 1591 additions and 1050 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -76,10 +76,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define RTMP_SIG_SRS_URL "https://"RTMP_SIG_SRS_URL_SHORT
|
||||
#define RTMP_SIG_SRS_URL_SHORT "github.com/winlinvip/simple-rtmp-server"
|
||||
#define RTMP_SIG_SRS_WEB "http://blog.csdn.net/win_lin"
|
||||
#define RTMP_SIG_SRS_EMAIL "winterserver@126.com"
|
||||
#define RTMP_SIG_SRS_EMAIL "winlin@vip.126.com"
|
||||
#define RTMP_SIG_SRS_LICENSE "The MIT License (MIT)"
|
||||
#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013 winlin"
|
||||
#define RTMP_SIG_SRS_CONTRIBUTOR "winlin,wenjiegit"
|
||||
#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013-2014 winlin"
|
||||
#define RTMP_SIG_SRS_PRIMARY_AUTHROS "winlin,wenjiegit"
|
||||
|
||||
// compare
|
||||
#define srs_min(a, b) (((a) < (b))? (a) : (b))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 wenjiegit
|
||||
Copyright (c) 2013-2014 wenjiegit
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 wenjiegit
|
||||
Copyright (c) 2013-2014 wenjiegit
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -42,11 +42,6 @@ using namespace std;
|
|||
#include <srs_core_http.hpp>
|
||||
#include <srs_core_bandwidth.hpp>
|
||||
|
||||
#define SRS_PULSE_TIMEOUT_MS 100
|
||||
#define SRS_SEND_TIMEOUT_US 5000000L
|
||||
#define SRS_RECV_TIMEOUT_US SRS_SEND_TIMEOUT_US
|
||||
#define SRS_STREAM_BUSY_SLEEP_MS 2000
|
||||
|
||||
SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd)
|
||||
: SrsConnection(srs_server, client_stfd)
|
||||
{
|
||||
|
@ -198,7 +193,7 @@ int SrsClient::service_cycle()
|
|||
srs_warn("stream %s is already publishing. ret=%d",
|
||||
req->get_stream_url().c_str(), ret);
|
||||
// to delay request
|
||||
st_usleep(SRS_STREAM_BUSY_SLEEP_MS * 1000);
|
||||
st_usleep(SRS_STREAM_BUSY_SLEEP_US);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -324,12 +319,12 @@ int SrsClient::playing(SrsSource* source)
|
|||
SrsAutoFree(SrsConsumer, consumer, false);
|
||||
srs_verbose("consumer created success.");
|
||||
|
||||
rtmp->set_recv_timeout(SRS_PULSE_TIMEOUT_MS * 1000);
|
||||
rtmp->set_recv_timeout(SRS_PULSE_TIMEOUT_US);
|
||||
|
||||
SrsPithyPrint pithy_print(SRS_STAGE_PLAY_USER);
|
||||
|
||||
while (true) {
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_MS);
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_US / 1000);
|
||||
|
||||
// switch to other st-threads.
|
||||
st_usleep(0);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -735,9 +735,9 @@ int SrsConfig::parse_argv(int& i, char** argv)
|
|||
|
||||
void SrsConfig::print_help(char** argv)
|
||||
{
|
||||
printf(RTMP_SIG_SRS_NAME" "RTMP_SIG_SRS_VERSION
|
||||
" Copyright (c) 2013 winlin\n"
|
||||
"Contributors: "RTMP_SIG_SRS_CONTRIBUTOR"\n"
|
||||
printf(
|
||||
RTMP_SIG_SRS_NAME" "RTMP_SIG_SRS_VERSION" "RTMP_SIG_SRS_COPYRIGHT"\n"
|
||||
"Primary Authors: "RTMP_SIG_SRS_PRIMARY_AUTHROS"\n"
|
||||
"Build: "SRS_BUILD_DATE" Configuration: "SRS_CONFIGURE"\n"
|
||||
"Usage: %s [-h?vV] [-c <filename>]\n"
|
||||
"\n"
|
||||
|
@ -1664,4 +1664,3 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -57,7 +57,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// the interval in seconds for bandwidth check
|
||||
#define SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS 1000
|
||||
|
||||
#define SRS_CONF_DEFAULT_CHUNK_SIZE 4096
|
||||
// the default chunk size for system.
|
||||
#define SRS_CONF_DEFAULT_CHUNK_SIZE 60000
|
||||
|
||||
#define SRS_STAGE_PLAY_USER_INTERVAL_MS 1300
|
||||
#define SRS_STAGE_PUBLISH_USER_INTERVAL_MS 1100
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -37,11 +37,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_config.hpp>
|
||||
#include <srs_core_rtmp.hpp>
|
||||
#include <srs_core_pithy_print.hpp>
|
||||
#include <srs_core_protocol.hpp>
|
||||
|
||||
#ifdef SRS_FFMPEG
|
||||
|
||||
#define SRS_ENCODER_SLEEP_MS 2000
|
||||
|
||||
#define SRS_ENCODER_COPY "copy"
|
||||
#define SRS_ENCODER_VCODEC "libx264"
|
||||
#define SRS_ENCODER_ACODEC "libaacplus"
|
||||
|
@ -483,7 +482,7 @@ void SrsFFMPEG::stop()
|
|||
|
||||
SrsEncoder::SrsEncoder()
|
||||
{
|
||||
pthread = new SrsThread(this, SRS_ENCODER_SLEEP_MS);
|
||||
pthread = new SrsThread(this, SRS_ENCODER_SLEEP_US);
|
||||
pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER);
|
||||
}
|
||||
|
||||
|
@ -549,7 +548,7 @@ int SrsEncoder::cycle()
|
|||
|
||||
// pithy print
|
||||
encoder();
|
||||
pithy_print->elapse(SRS_ENCODER_SLEEP_MS);
|
||||
pithy_print->elapse(SRS_ENCODER_SLEEP_US / 1000);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -38,11 +38,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_source.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
|
||||
#define SRS_PULSE_TIMEOUT_MS 100
|
||||
#define SRS_FORWARDER_SLEEP_MS 2000
|
||||
#define SRS_SEND_TIMEOUT_US 3000000L
|
||||
#define SRS_RECV_TIMEOUT_US SRS_SEND_TIMEOUT_US
|
||||
|
||||
SrsForwarder::SrsForwarder(SrsSource* _source)
|
||||
{
|
||||
source = _source;
|
||||
|
@ -51,7 +46,7 @@ SrsForwarder::SrsForwarder(SrsSource* _source)
|
|||
stfd = NULL;
|
||||
stream_id = 0;
|
||||
|
||||
pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_MS);
|
||||
pthread = new SrsThread(this, SRS_FORWARDER_SLEEP_US);
|
||||
queue = new SrsMessageQueue();
|
||||
jitter = new SrsRtmpJitter();
|
||||
}
|
||||
|
@ -286,11 +281,11 @@ int SrsForwarder::forward()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
client->set_recv_timeout(SRS_PULSE_TIMEOUT_MS * 1000);
|
||||
client->set_recv_timeout(SRS_PULSE_TIMEOUT_US);
|
||||
|
||||
SrsPithyPrint pithy_print(SRS_STAGE_FORWARDER);
|
||||
|
||||
while (true) {
|
||||
while (pthread->can_loop()) {
|
||||
// switch to other st-threads.
|
||||
st_usleep(0);
|
||||
|
||||
|
@ -322,7 +317,7 @@ int SrsForwarder::forward()
|
|||
SrsAutoFree(SrsSharedPtrMessage*, msgs, true);
|
||||
|
||||
// pithy print
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_MS);
|
||||
pithy_print.elapse(SRS_PULSE_TIMEOUT_US / 1000);
|
||||
if (pithy_print.can_print()) {
|
||||
srs_trace("-> time=%"PRId64", msgs=%d, obytes=%"PRId64", ibytes=%"PRId64", okbps=%d, ikbps=%d",
|
||||
pithy_print.get_age(), count, client->get_send_bytes(), client->get_recv_bytes(), client->get_send_kbps(), client->get_recv_kbps());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -36,6 +36,37 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_log.hpp>
|
||||
#include <srs_core_error.hpp>
|
||||
|
||||
// the following is the timeout for rtmp protocol,
|
||||
// to avoid death connection.
|
||||
|
||||
// when got a messae header, there must be some data,
|
||||
// increase recv timeout to got an entire message.
|
||||
#define SRS_MIN_RECV_TIMEOUT_US 60*1000*1000L
|
||||
|
||||
// the timeout to wait for client control message,
|
||||
// if timeout, we generally ignore and send the data to client,
|
||||
// generally, it's the pulse time for data seding.
|
||||
#define SRS_PULSE_TIMEOUT_US 200*1000L
|
||||
|
||||
// the timeout to wait client data,
|
||||
// if timeout, close the connection.
|
||||
#define SRS_SEND_TIMEOUT_US 30*1000*1000L
|
||||
|
||||
// the timeout to send data to client,
|
||||
// if timeout, close the connection.
|
||||
#define SRS_RECV_TIMEOUT_US 30*1000*1000L
|
||||
|
||||
// when stream is busy, for example, streaming is already
|
||||
// publishing, when a new client to request to publish,
|
||||
// sleep a while and close the connection.
|
||||
#define SRS_STREAM_BUSY_SLEEP_US 3*1000*1000L
|
||||
|
||||
// when error, forwarder sleep for a while and retry.
|
||||
#define SRS_FORWARDER_SLEEP_US 3*1000*1000L
|
||||
|
||||
// when error, encoder sleep for a while and retry.
|
||||
#define SRS_ENCODER_SLEEP_US 3*1000*1000L
|
||||
|
||||
class SrsSocket;
|
||||
class SrsBuffer;
|
||||
class SrsPacket;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -391,12 +391,44 @@ int SrsRtmpClient::play(string stream, int stream_id)
|
|||
}
|
||||
}
|
||||
|
||||
// SetChunkSize
|
||||
if (true) {
|
||||
SrsCommonMessage* msg = new SrsCommonMessage();
|
||||
SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
|
||||
|
||||
pkt->chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE;
|
||||
msg->set_packet(pkt, 0);
|
||||
|
||||
if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
|
||||
srs_error("send set chunk size failed. "
|
||||
"stream=%s, chunk_size=%d, ret=%d",
|
||||
stream.c_str(), SRS_CONF_DEFAULT_CHUNK_SIZE, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsRtmpClient::publish(string stream, int stream_id)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// SetChunkSize
|
||||
if (true) {
|
||||
SrsCommonMessage* msg = new SrsCommonMessage();
|
||||
SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
|
||||
|
||||
pkt->chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE;
|
||||
msg->set_packet(pkt, 0);
|
||||
|
||||
if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
|
||||
srs_error("send set chunk size failed. "
|
||||
"stream=%s, chunk_size=%d, ret=%d",
|
||||
stream.c_str(), SRS_CONF_DEFAULT_CHUNK_SIZE, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// publish(stream)
|
||||
if (true) {
|
||||
|
@ -617,7 +649,7 @@ int SrsRtmp::response_connect_app(SrsRequest *req, const char* server_ip)
|
|||
data->set("srs_site", new SrsAmf0String(RTMP_SIG_SRS_WEB));
|
||||
data->set("srs_email", new SrsAmf0String(RTMP_SIG_SRS_EMAIL));
|
||||
data->set("srs_copyright", new SrsAmf0String(RTMP_SIG_SRS_COPYRIGHT));
|
||||
data->set("srs_contributor", new SrsAmf0String(RTMP_SIG_SRS_CONTRIBUTOR));
|
||||
data->set("srs_primary_authors", new SrsAmf0String(RTMP_SIG_SRS_PRIMARY_AUTHROS));
|
||||
|
||||
if (server_ip) {
|
||||
data->set("srs_server_ip", new SrsAmf0String(server_ip));
|
||||
|
@ -1194,4 +1226,3 @@ int SrsRtmp::identify_flash_publish_client(SrsPublishPacket* req, SrsClientType&
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -110,7 +110,7 @@ enum SrsClientType
|
|||
*/
|
||||
class SrsRtmpClient
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
SrsProtocol* protocol;
|
||||
st_netfd_t stfd;
|
||||
public:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_client.hpp>
|
||||
#include <srs_core_config.hpp>
|
||||
|
||||
#define SERVER_LISTEN_BACKLOG 10
|
||||
#define SERVER_LISTEN_BACKLOG 512
|
||||
#define SRS_TIME_RESOLUTION_MS 500
|
||||
|
||||
SrsListener::SrsListener(SrsServer* _server, SrsListenerType _type)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -642,7 +642,7 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata
|
|||
metadata->metadata->set("server", new SrsAmf0String(
|
||||
RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")"));
|
||||
metadata->metadata->set("contributor",
|
||||
new SrsAmf0String(RTMP_SIG_SRS_CONTRIBUTOR));
|
||||
new SrsAmf0String(RTMP_SIG_SRS_PRIMARY_AUTHROS));
|
||||
|
||||
SrsAmf0Any* prop = NULL;
|
||||
if ((prop = metadata->metadata->get_property("audiosamplerate")) != NULL) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -54,10 +54,10 @@ void ISrsThreadHandler::on_leave_loop()
|
|||
{
|
||||
}
|
||||
|
||||
SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_ms)
|
||||
SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us)
|
||||
{
|
||||
handler = thread_handler;
|
||||
cycle_interval_milliseconds = interval_ms;
|
||||
cycle_interval_us = interval_us;
|
||||
|
||||
tid = NULL;
|
||||
loop = false;
|
||||
|
@ -102,6 +102,11 @@ void SrsThread::stop()
|
|||
}
|
||||
}
|
||||
|
||||
bool SrsThread::can_loop()
|
||||
{
|
||||
return loop;
|
||||
}
|
||||
|
||||
void SrsThread::thread_cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -138,7 +143,7 @@ failed:
|
|||
break;
|
||||
}
|
||||
|
||||
st_usleep(cycle_interval_milliseconds * 1000);
|
||||
st_usleep(cycle_interval_us);
|
||||
}
|
||||
|
||||
handler->on_leave_loop();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -43,6 +43,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
* when stop, the thread will interrupt the st_thread,
|
||||
* which will cause the socket to return error and
|
||||
* terminate the cycle thread.
|
||||
*
|
||||
* when thread interrupt, the socket maybe not got EINT,
|
||||
* espectially on st_usleep(), so the cycle must check the loop,
|
||||
* when handler->cycle() has loop itself, for example:
|
||||
* handler->cycle() is:
|
||||
* while (true):
|
||||
* st_usleep(0);
|
||||
* if (read_from_socket(skt) < 0) break;
|
||||
* if thread stop when read_from_socket, it's ok, the loop will break,
|
||||
* but when thread stop interrupt the s_usleep(0), then the loop is
|
||||
* death loop.
|
||||
* in a word, the handler->cycle() must:
|
||||
* handler->cycle() is:
|
||||
* while (pthread->can_loop()):
|
||||
* st_usleep(0);
|
||||
* if (read_from_socket(skt) < 0) break;
|
||||
* check the loop, then it works.
|
||||
*/
|
||||
class ISrsThreadHandler
|
||||
{
|
||||
|
@ -68,14 +85,14 @@ private:
|
|||
bool loop;
|
||||
private:
|
||||
ISrsThreadHandler* handler;
|
||||
int64_t cycle_interval_milliseconds;
|
||||
int64_t cycle_interval_us;
|
||||
public:
|
||||
/**
|
||||
* initialize the thread.
|
||||
* @param thread_handler, the cycle handler for the thread.
|
||||
* @param interval_ms, the sleep interval when cycle finished.
|
||||
* @param interval_us, the sleep interval when cycle finished.
|
||||
*/
|
||||
SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_ms);
|
||||
SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us);
|
||||
virtual ~SrsThread();
|
||||
public:
|
||||
/**
|
||||
|
@ -90,6 +107,12 @@ public:
|
|||
* @remark user can stop multiple times, ignore if already stopped.
|
||||
*/
|
||||
virtual void stop();
|
||||
/**
|
||||
* whether the thread should loop,
|
||||
* used for handler->cycle() which has a loop method,
|
||||
* to check this method, break if false.
|
||||
*/
|
||||
virtual bool can_loop();
|
||||
private:
|
||||
virtual void thread_cycle();
|
||||
static void* thread_fun(void* arg);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 winlin
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
file
|
||||
main readonly separator,
|
||||
..\main\srs_main_server.cpp,
|
||||
..\main\srs_main_bandcheck.cpp,
|
||||
auto readonly separator,
|
||||
..\..\objs\srs_auto_headers.hpp,
|
||||
core readonly separator,
|
||||
|
@ -57,7 +58,7 @@ file
|
|||
..\core\srs_core_source.hpp,
|
||||
..\core\srs_core_source.cpp,
|
||||
research readonly separator,
|
||||
..\..\research\ts_info.cc;
|
||||
..\..\research\hls\ts_info.cc;
|
||||
|
||||
mainconfig
|
||||
"" = "MAIN";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue