epoll fully removed - needs testing still

This commit is contained in:
Thulinma 2011-09-22 07:09:43 +02:00
parent f45d02124a
commit 1640dbb933
3 changed files with 25 additions and 39 deletions

View file

@ -140,7 +140,7 @@ namespace Buffer{
}
std::string waiting_ip = "";
bool ip_waiting = false;
int ip_input = -1;
Socket::Connection ip_input;
if (argc >= 4){
waiting_ip += argv[3];
ip_waiting = true;
@ -174,7 +174,7 @@ namespace Buffer{
if (
(!ip_waiting &&
(std_input.canRead()) && ringbuf[current_buffer]->FLV.FileLoader(stdin)
) || (ip_waiting && (ip_input > -1) &&
) || (ip_waiting && (ip_input.connected()) &&
ringbuf[current_buffer]->FLV.SockLoader(ip_input)
)
){
@ -217,6 +217,7 @@ namespace Buffer{
lastproper = current_buffer;
}
}
if (loopcount > 5){gotData = true;}
//keep track of buffers
ringbuf[current_buffer]->number = loopcount;
current_buffer++;
@ -236,14 +237,20 @@ namespace Buffer{
if (!users.back().S.write(FLV::Header, 13)){
users.back().Disconnect("failed to receive the header!");
}else{
if (!users.back().S.write(metadata.data, metadata.len)){
users.back().Disconnect("failed to receive metadata!");
if (metadata.len > 0){
if (!users.back().S.write(metadata.data, metadata.len)){
users.back().Disconnect("failed to receive metadata!");
}
}
if (!users.back().S.write(audio_init.data, audio_init.len)){
users.back().Disconnect("failed to receive audio init!");
if (audio_init.len > 0){
if (!users.back().S.write(audio_init.data, audio_init.len)){
users.back().Disconnect("failed to receive audio init!");
}
}
if (!users.back().S.write(video_init.data, video_init.len)){
users.back().Disconnect("failed to receive video init!");
if (video_init.len > 0){
if (!users.back().S.write(video_init.data, video_init.len)){
users.back().Disconnect("failed to receive video init!");
}
}
}
}
@ -265,7 +272,13 @@ namespace Buffer{
if (tmp != ""){
std::cout << "Push attempt from IP " << tmp << std::endl;
if (tmp == waiting_ip){
std::cout << "Push accepted!" << std::endl;
if (!ip_input.connected()){
std::cout << "Push accepted!" << std::endl;
ip_input = (*usersIt).S;
users.erase(usersIt); break;
}else{
std::cout << "Push denied - push already in progress!" << std::endl;
}
}else{
std::cout << "Push denied!" << std::endl;
}

View file

@ -9,7 +9,6 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/epoll.h>
#include <getopt.h>
#include <ctime>
#include "../util/socket.h"
@ -134,15 +133,6 @@ namespace Connector_HTTP{
bool FlashFirstAudio = false;
HTTP::Parser HTTP_R, HTTP_S;//HTTP Receiver en HTTP Sender.
int retval;
int poller = epoll_create(1);
int sspoller = epoll_create(1);
struct epoll_event ev;
ev.events = EPOLLIN;
ev.data.fd = conn.getSocket();
epoll_ctl(poller, EPOLL_CTL_ADD, conn.getSocket(), &ev);
struct epoll_event events[1];
std::string Movie = "";
std::string Quality = "";
int Segment = -1;
@ -221,9 +211,6 @@ namespace Connector_HTTP{
conn.close();
break;
}
ev.events = EPOLLIN;
ev.data.fd = ss.getSocket();
epoll_ctl(sspoller, EPOLL_CTL_ADD, ss.getSocket(), &ev);
#if DEBUG >= 3
fprintf(stderr, "Everything connected, starting to send video data...\n");
#endif
@ -240,7 +227,7 @@ namespace Connector_HTTP{
fprintf(stderr, "Sending a video fragment. %i left in buffer, %i requested\n", (int)Flash_FragBuffer.size(), Flash_RequestPending);
#endif
}
retval = epoll_wait(sspoller, events, 1, 1);
ss.canRead();
switch (ss.ready()){
case -1:
conn.close();

View file

@ -9,7 +9,6 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/epoll.h>
#include <getopt.h>
#include "../util/socket.h"
#include "../util/flv_tag.h"
@ -59,20 +58,10 @@ int Connector_RTMP::Connector_RTMP(Socket::Connection conn){
return 0;
}
int retval;
int poller = epoll_create(1);
int sspoller = epoll_create(1);
struct epoll_event ev;
ev.events = EPOLLIN;
ev.data.fd = Socket.getSocket();
epoll_ctl(poller, EPOLL_CTL_ADD, Socket.getSocket(), &ev);
struct epoll_event events[1];
while (Socket.connected() && !FLV::Parse_Error){
//only parse input if available or not yet init'ed
//rightnow = getNowMS();
retval = epoll_wait(poller, events, 1, 1);
if ((retval > 0) || !ready4data){// || (snd_cnt - snd_window_at >= snd_window_size)
if (Socket.canRead() || !ready4data){// || (snd_cnt - snd_window_at >= snd_window_size)
switch (Socket.ready()){
case -1: break; //disconnected
case 0: break; //not ready yet
@ -90,15 +79,12 @@ int Connector_RTMP::Connector_RTMP(Socket::Connection conn){
Socket.close();//disconnect user
break;
}
ev.events = EPOLLIN;
ev.data.fd = SS.getSocket();
epoll_ctl(sspoller, EPOLL_CTL_ADD, SS.getSocket(), &ev);
#if DEBUG >= 3
fprintf(stderr, "Everything connected, starting to send video data...\n");
#endif
inited = true;
}
retval = epoll_wait(sspoller, events, 1, 1);
SS.canRead();
switch (SS.ready()){
case -1:
#if DEBUG >= 1