Merge branch 'master' into DTSC
Conflicts: Buffer/main.cpp
This commit is contained in:
commit
e080363196
2 changed files with 51 additions and 23 deletions
|
@ -241,21 +241,31 @@ void Connector_RTMP::parseChunk(){
|
|||
Socket.write(RTMPStream::SendCTL(5, RTMPStream::snd_window_size));//send window acknowledgement size (msg 5)
|
||||
break;
|
||||
case 8:
|
||||
#if DEBUG >= 4
|
||||
fprintf(stderr, "Received audio data\n");
|
||||
#endif
|
||||
F.ChunkLoader(next);
|
||||
if (SS.connected()){
|
||||
#if DEBUG >= 4
|
||||
fprintf(stderr, "A");
|
||||
#endif
|
||||
SS.write(std::string(F.data, F.len));
|
||||
}else{
|
||||
#if DEBUG >= 4
|
||||
fprintf(stderr, "Received useless audio data\n");
|
||||
#endif
|
||||
Socket.close();
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
#if DEBUG >= 4
|
||||
fprintf(stderr, "Received video data\n");
|
||||
#endif
|
||||
F.ChunkLoader(next);
|
||||
if (SS.connected()){
|
||||
#if DEBUG >= 4
|
||||
fprintf(stderr, "V");
|
||||
#endif
|
||||
SS.write(std::string(F.data, F.len));
|
||||
}else{
|
||||
#if DEBUG >= 4
|
||||
fprintf(stderr, "Received useless video data\n");
|
||||
#endif
|
||||
Socket.close();
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
|
@ -348,6 +358,9 @@ void Connector_RTMP::parseChunk(){
|
|||
Socket.write(RTMPStream::SendUSR(0, 1));//send UCM StreamBegin (0), stream 1
|
||||
parsed3 = true;
|
||||
}//createStream
|
||||
if ((amfdata.getContentP(0)->StrValue() == "closeStream") || (amfdata.getContentP(0)->StrValue() == "deleteStream")){
|
||||
if (SS.connected()){SS.close();}
|
||||
}
|
||||
if ((amfdata.getContentP(0)->StrValue() == "getStreamLength") || (amfdata.getContentP(0)->StrValue() == "getMovLen")){
|
||||
//send a _result reply
|
||||
AMF::Object amfreply("container", AMF::AMF0_DDV_CONTAINER);
|
||||
|
@ -569,6 +582,9 @@ void Connector_RTMP::parseChunk(){
|
|||
Socket.write(RTMPStream::SendUSR(0, 1));//send UCM StreamBegin (0), stream 1
|
||||
parsed = true;
|
||||
}//createStream
|
||||
if ((amfdata.getContentP(0)->StrValue() == "closeStream") || (amfdata.getContentP(0)->StrValue() == "deleteStream")){
|
||||
if (SS.connected()){SS.close();}
|
||||
}
|
||||
if ((amfdata.getContentP(0)->StrValue() == "getStreamLength") || (amfdata.getContentP(0)->StrValue() == "getMovLen")){
|
||||
//send a _result reply
|
||||
AMF::Object amfreply("container", AMF::AMF0_DDV_CONTAINER);
|
||||
|
|
|
@ -580,7 +580,14 @@ bool FLV::Tag::MemLoader(char * D, unsigned int S, unsigned int & P){
|
|||
len += (data[2] << 8);
|
||||
len += (data[1] << 16);
|
||||
if (buf < len){data = (char*)realloc(data, len); buf = len;}
|
||||
if (data[0] > 0x12){FLV::Parse_Error = true; Error_Str = "Invalid Tag received."; return false;}
|
||||
if (data[0] > 0x12){
|
||||
data[0] += 32;
|
||||
FLV::Parse_Error = true;
|
||||
Error_Str = "Invalid Tag received (";
|
||||
Error_Str += data[0];
|
||||
Error_Str += ").";
|
||||
return false;
|
||||
}
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
@ -607,20 +614,11 @@ bool FLV::Tag::MemLoader(char * D, unsigned int S, unsigned int & P){
|
|||
/// \param sock Socket to read from.
|
||||
/// \return True if count bytes are read succesfully, false otherwise.
|
||||
bool FLV::Tag::SockReadUntil(char * buffer, unsigned int count, unsigned int & sofar, Socket::Connection & sock){
|
||||
if (sofar == count){return true;}
|
||||
if (!sock.read(buffer + sofar,count-sofar)){
|
||||
if (errno != EWOULDBLOCK){
|
||||
FLV::Parse_Error = true;
|
||||
Error_Str = "Error reading from socket.";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
sofar += count-sofar;
|
||||
if (sofar == count){return true;}
|
||||
if (sofar > count){
|
||||
FLV::Parse_Error = true;
|
||||
Error_Str = "Socket buffer overflow.";
|
||||
}
|
||||
if (sofar >= count){return true;}
|
||||
int r = 0;
|
||||
r = sock.iread(buffer + sofar,count-sofar);
|
||||
sofar += r;
|
||||
if (sofar >= count){return true;}
|
||||
return false;
|
||||
}//Tag::SockReadUntil
|
||||
|
||||
|
@ -647,7 +645,14 @@ bool FLV::Tag::SockLoader(Socket::Connection sock){
|
|||
len += (data[2] << 8);
|
||||
len += (data[1] << 16);
|
||||
if (buf < len){data = (char*)realloc(data, len); buf = len;}
|
||||
if (data[0] > 0x12){FLV::Parse_Error = true; Error_Str = "Invalid Tag received."; return false;}
|
||||
if (data[0] > 0x12){
|
||||
data[0] += 32;
|
||||
FLV::Parse_Error = true;
|
||||
Error_Str = "Invalid Tag received (";
|
||||
Error_Str += data[0];
|
||||
Error_Str += ").";
|
||||
return false;
|
||||
}
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
@ -719,7 +724,14 @@ bool FLV::Tag::FileLoader(FILE * f){
|
|||
len += (data[2] << 8);
|
||||
len += (data[1] << 16);
|
||||
if (buf < len){data = (char*)realloc(data, len); buf = len;}
|
||||
if (data[0] > 0x12){FLV::Parse_Error = true; Error_Str = "Invalid Tag received."; return false;}
|
||||
if (data[0] > 0x12){
|
||||
data[0] += 32;
|
||||
FLV::Parse_Error = true;
|
||||
Error_Str = "Invalid Tag received (";
|
||||
Error_Str += data[0];
|
||||
Error_Str += ").";
|
||||
return false;
|
||||
}
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue