mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add linux version of band check app; add web version of band check app
This commit is contained in:
commit
237fb13e1b
35 changed files with 1966 additions and 218 deletions
|
@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_bandwidth.hpp>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -260,21 +261,24 @@ int SrsBandwidth::check_play(
|
|||
int64_t current_time = srs_get_system_time_ms();
|
||||
int size = 1024; // TODO: FIXME: magic number
|
||||
char random_data[size];
|
||||
memset(random_data, 0x01, size);
|
||||
memset(random_data, 'A', size);
|
||||
|
||||
int interval = 0;
|
||||
int data_count = 1;
|
||||
while ( (srs_get_system_time_ms() - current_time) < duration_ms ) {
|
||||
st_usleep(interval);
|
||||
|
||||
// TODO: FIXME: use shared ptr message.
|
||||
SrsBandwidthPacket* pkt = SrsBandwidthPacket::create_playing();
|
||||
|
||||
// TODO: FIXME: magic number
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
char buf[32]; // TODO: FIXME: magic number
|
||||
sprintf(buf, "%d", i);
|
||||
pkt->data->set(buf, new SrsAmf0String(random_data));
|
||||
// TODO: FIXME: magic number
|
||||
for (int i = 0; i < data_count; ++i) {
|
||||
std::stringstream seq;
|
||||
seq << i;
|
||||
std::string play_data = "SrS band check data from server's playing......";
|
||||
pkt->data->set(seq.str(), new SrsAmf0String(play_data.c_str()));
|
||||
}
|
||||
data_count += 2;
|
||||
|
||||
// TODO: FIXME: get length from the rtmp protocol stack.
|
||||
play_bytes += pkt->get_payload_length();
|
||||
|
|
|
@ -2789,7 +2789,7 @@ SrsBandwidthPacket* SrsBandwidthPacket::create_start_play()
|
|||
SrsBandwidthPacket* SrsBandwidthPacket::create_playing()
|
||||
{
|
||||
SrsBandwidthPacket* pkt = new SrsBandwidthPacket();
|
||||
return pkt->set_command(SRS_BW_CHECK_STARTING_PLAY);
|
||||
return pkt->set_command(SRS_BW_CHECK_PLAYING);
|
||||
}
|
||||
|
||||
SrsBandwidthPacket* SrsBandwidthPacket::create_stop_play()
|
||||
|
|
|
@ -414,7 +414,17 @@ int SrsRtmpClient::publish(string stream, int stream_id)
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
SrsProtocol *SrsRtmpClient::get_protocol()
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
|
||||
st_netfd_t SrsRtmpClient::get_st_fd()
|
||||
{
|
||||
return stfd;
|
||||
}
|
||||
|
||||
SrsRtmp::SrsRtmp(st_netfd_t client_stfd)
|
||||
|
|
|
@ -131,6 +131,10 @@ public:
|
|||
virtual int create_stream(int& stream_id);
|
||||
virtual int play(std::string stream, int stream_id);
|
||||
virtual int publish(std::string stream, int stream_id);
|
||||
|
||||
protected:
|
||||
SrsProtocol* get_protocol();
|
||||
st_netfd_t get_st_fd();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue