Epoll removal tested and found working! :D

This commit is contained in:
Thulinma 2011-09-25 22:44:55 +02:00
parent 1640dbb933
commit 40bcb2ba72
4 changed files with 41 additions and 8 deletions

View file

@ -237,7 +237,7 @@ namespace Connector_HTTP{
break; break;
case 0: break;//not ready yet case 0: break;//not ready yet
default: default:
if (tag.SockLoader(ss)){//able to read a full packet?f if (tag.SockLoader(ss)){//able to read a full packet?
if (handler == HANDLER_FLASH){ if (handler == HANDLER_FLASH){
if (tag.tagTime() > 0){ if (tag.tagTime() > 0){
if (Flash_StartTime == 0){ if (Flash_StartTime == 0){
@ -269,14 +269,18 @@ namespace Connector_HTTP{
FlashFirstVideo = true; FlashFirstVideo = true;
FlashFirstAudio = true; FlashFirstAudio = true;
} }
if (FlashFirstVideo && (tag.data[0] == 0x09) && (Video_Init.len > 0)){ if (FlashFirstVideo && (tag.data[0] == 0x09) && (!tag.needsInitData() || (Video_Init.len > 0))){
if (tag.needsInitData()){
Video_Init.tagTime(tag.tagTime()); Video_Init.tagTime(tag.tagTime());
FlashBuf.append(Video_Init.data, Video_Init.len); FlashBuf.append(Video_Init.data, Video_Init.len);
}
FlashFirstVideo = false; FlashFirstVideo = false;
} }
if (FlashFirstAudio && (tag.data[0] == 0x08) && (Audio_Init.len > 0)){ if (FlashFirstAudio && (tag.data[0] == 0x08) && (!tag.needsInitData() || (Audio_Init.len > 0))){
if (tag.needsInitData()){
Audio_Init.tagTime(tag.tagTime()); Audio_Init.tagTime(tag.tagTime());
FlashBuf.append(Audio_Init.data, Audio_Init.len); FlashBuf.append(Audio_Init.data, Audio_Init.len);
}
FlashFirstAudio = false; FlashFirstAudio = false;
} }
#if DEBUG >= 5 #if DEBUG >= 5

View file

@ -121,7 +121,10 @@ int Connector_RTMP::Connector_RTMP(Socket::Connection conn){
break; break;
} }
//not gotten init yet? cancel this tag //not gotten init yet? cancel this tag
if (viddata.len == 0 || auddata.len == 0){break;} if (tag.needsInitData()){
if ((tag.data[0] == 0x09) && (viddata.len == 0)){break;}
if ((tag.data[0] == 0x08) && (auddata.len == 0)){break;}
}
//send tag normally //send tag normally
Socket.write(RTMPStream::SendMedia(tag)); Socket.write(RTMPStream::SendMedia(tag));
#if DEBUG >= 8 #if DEBUG >= 8

View file

@ -495,3 +495,27 @@ bool Socket::Server::connected(){
/// Returns internal socket number. /// Returns internal socket number.
int Socket::Server::getSocket(){return sock;} int Socket::Server::getSocket(){return sock;}
/// Unescapes URLencoded C-strings to a std::string.
/// This function *will* destroy the incoming data!
std::string Socket::Connection::urlunescape(char *s){
char *p;
for (p = s; *s != '\0'; ++s){
if (*s == '%'){
if (*++s != '\0'){
*p = unhex(*s) << 4;
}
if (*++s != '\0'){
*p++ += unhex(*s);
}
} else {
if (*s == '+'){*p++ = ' ';}else{*p++ = *s;}
}
}
*p = '\0';
return std::string(s);
}
int Socket::Connection::unhex(char c){
return( c >= '0' && c <= '9' ? c - '0' : c >= 'A' && c <= 'F' ? c - 'A' + 10 : c - 'a' + 10 );
}

View file

@ -23,6 +23,7 @@ namespace Socket{
private: private:
int sock; ///< Internally saved socket number. int sock; ///< Internally saved socket number.
std::string remotehost; ///< Stores remote host address. std::string remotehost; ///< Stores remote host address.
int unhex(char c); ///< Helper function for urlunescape.
public: public:
Connection(); ///< Create a new disconnected base socket. Connection(); ///< Create a new disconnected base socket.
Connection(int sockNo); ///< Create a new base socket. Connection(int sockNo); ///< Create a new base socket.
@ -44,6 +45,7 @@ namespace Socket{
bool swrite(std::string & buffer); ///< Read call that is compatible with std::string. bool swrite(std::string & buffer); ///< Read call that is compatible with std::string.
bool iread(std::string & buffer); ///< Incremental write call that is compatible with std::string. bool iread(std::string & buffer); ///< Incremental write call that is compatible with std::string.
bool iwrite(std::string & buffer); ///< Write call that is compatible with std::string. bool iwrite(std::string & buffer); ///< Write call that is compatible with std::string.
std::string urlunescape(char *s); ///< Unescapes URLencoded C-strings to a std::string.
void close(); ///< Close connection. void close(); ///< Close connection.
std::string getHost(); ///< Gets hostname for connection, if available. std::string getHost(); ///< Gets hostname for connection, if available.
int getSocket(); ///< Returns internal socket number. int getSocket(); ///< Returns internal socket number.