Increased maximum simultaneous tracks from 5 to 10, made this a define option. Allow multiple pushes through a single RTMP connection.
This commit is contained in:
parent
8d377602be
commit
69cf17d01d
8 changed files with 68 additions and 47 deletions
|
@ -619,7 +619,7 @@ namespace Mist {
|
|||
}
|
||||
}
|
||||
if (trackMap.size()){
|
||||
for (std::map<unsigned long, unsigned long>::iterator it = trackMap.begin(); it != trackMap.end() && tNum < 5; it++){
|
||||
for (std::map<unsigned long, unsigned long>::iterator it = trackMap.begin(); it != trackMap.end() && tNum < SIMUL_TRACKS; it++){
|
||||
unsigned int tId = it->second;
|
||||
char * thisData = userClient.getData() + (6 * tNum);
|
||||
thisData[0] = ((tId >> 24) & 0xFF);
|
||||
|
@ -631,7 +631,7 @@ namespace Mist {
|
|||
tNum ++;
|
||||
}
|
||||
}else{
|
||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end() && tNum < 5; it++){
|
||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end() && tNum < SIMUL_TRACKS; it++){
|
||||
unsigned int tId = *it;
|
||||
char * thisData = userClient.getData() + (6 * tNum);
|
||||
thisData[0] = ((tId >> 24) & 0xFF);
|
||||
|
@ -644,8 +644,8 @@ namespace Mist {
|
|||
}
|
||||
}
|
||||
userClient.keepAlive();
|
||||
if (tNum >= 5){
|
||||
DEBUG_MSG(DLVL_WARN, "Too many tracks selected, using only first 5");
|
||||
if (tNum > SIMUL_TRACKS){
|
||||
DEBUG_MSG(DLVL_WARN, "Too many tracks selected, using only first %d", SIMUL_TRACKS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,6 @@ namespace Mist {
|
|||
bool isInitialized;///< If false, triggers initialization if parseData is true.
|
||||
bool sentHeader;///< If false, triggers sendHeader if parseData is true.
|
||||
|
||||
DTSC::Meta meta_out;
|
||||
std::deque<JSON::Value> preBuf;
|
||||
std::map<int,DTSCPageData> bookKeeping;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,9 +30,6 @@ namespace Mist {
|
|||
DEBUG_MSG(DLVL_DEVEL, "Handshake fail!");
|
||||
}
|
||||
setBlocking(false);
|
||||
counter = 0;
|
||||
sending = false;
|
||||
streamReset = false;
|
||||
maxSkipAhead = 1500;
|
||||
minSkipAhead = 500;
|
||||
}
|
||||
|
@ -448,6 +445,9 @@ namespace Mist {
|
|||
if (amfData.getContentP(3)) {
|
||||
streamName = amfData.getContentP(3)->StrValue();
|
||||
|
||||
if (streamName.find('/')){
|
||||
streamName = streamName.substr(0, streamName.find('/'));
|
||||
}
|
||||
|
||||
size_t colonPos = streamName.find(':');
|
||||
if (colonPos != std::string::npos && colonPos < 6){
|
||||
|
@ -792,39 +792,40 @@ namespace Mist {
|
|||
case 8: //audio data
|
||||
case 9: //video data
|
||||
case 18: {//meta data
|
||||
pushData & p = pushes[next.cs_id];
|
||||
if (!isInitialized) {
|
||||
DEBUG_MSG(DLVL_MEDIUM, "Received useless media data\n");
|
||||
myConn.close();
|
||||
break;
|
||||
}
|
||||
if (streamReset) {
|
||||
//reset push data to empty, in case stream properties change
|
||||
meta_out.reset();
|
||||
preBuf.clear();
|
||||
sending = false;
|
||||
counter = 0;
|
||||
streamReset = false;
|
||||
}
|
||||
F.ChunkLoader(next);
|
||||
JSON::Value pack_out = F.toJSON(meta_out);
|
||||
JSON::Value pack_out = F.toJSON(p.meta);
|
||||
if ( !pack_out.isNull()){
|
||||
//Check for backwards timestamps
|
||||
if (pack_out["time"].asInt() < meta_out.tracks[pack_out["trackid"].asInt()].lastms){
|
||||
if (pack_out["time"].asInt() < p.meta.tracks[pack_out["trackid"].asInt()].lastms){
|
||||
///Reset all internals
|
||||
sending = false;
|
||||
counter = 0;
|
||||
preBuf.clear();
|
||||
meta_out = DTSC::Meta();
|
||||
pack_out = F.toJSON(meta_out);//Reinitialize the metadata with this packet.
|
||||
p.sending = false;
|
||||
p.counter = 0;
|
||||
p.preBuf.clear();
|
||||
p.meta = DTSC::Meta();
|
||||
pack_out = F.toJSON(p.meta);//Reinitialize the metadata with this packet.
|
||||
///Reset negotiation with buffer
|
||||
userClient.finish();
|
||||
userClient = IPC::sharedClient(streamName + "_users", PLAY_EX_SIZE, true);
|
||||
}
|
||||
if ( !sending){
|
||||
counter++;
|
||||
if (counter > 8){
|
||||
sending = true;
|
||||
myMeta = meta_out;
|
||||
pack_out["trackid"] = pack_out["trackid"].asInt() + next.cs_id * 3;
|
||||
if ( !p.sending){
|
||||
p.counter++;
|
||||
if (p.counter > 8){
|
||||
p.sending = true;
|
||||
if (myMeta.tracks.count(1)){
|
||||
myMeta = DTSC::Meta();
|
||||
}
|
||||
for (unsigned int i = 1; i < 4; ++i){
|
||||
if (p.meta.tracks.count(i)){
|
||||
myMeta.tracks[next.cs_id*3+i] = p.meta.tracks[i];
|
||||
}
|
||||
}
|
||||
if (!userClient.getData()){
|
||||
char userPageName[NAME_BUFFER_SIZE];
|
||||
snprintf(userPageName, NAME_BUFFER_SIZE, SHM_USERS, streamName.c_str());
|
||||
|
@ -834,14 +835,13 @@ namespace Mist {
|
|||
DEBUG_MSG(DLVL_MEDIUM, "Starting negotiation for track %d", it->first);
|
||||
continueNegotiate(it->first);
|
||||
}
|
||||
//negotiatePushTracks();
|
||||
for (std::deque<JSON::Value>::iterator it = preBuf.begin(); it != preBuf.end(); it++){
|
||||
for (std::deque<JSON::Value>::iterator it = p.preBuf.begin(); it != p.preBuf.end(); it++){
|
||||
bufferLivePacket((*it));
|
||||
}
|
||||
preBuf.clear(); //clear buffer
|
||||
p.preBuf.clear(); //clear buffer
|
||||
bufferLivePacket(pack_out);
|
||||
}else{
|
||||
preBuf.push_back(pack_out);
|
||||
p.preBuf.push_back(pack_out);
|
||||
}
|
||||
}else{
|
||||
bufferLivePacket(pack_out);
|
||||
|
|
|
@ -5,6 +5,20 @@
|
|||
|
||||
|
||||
namespace Mist {
|
||||
|
||||
class pushData {
|
||||
public:
|
||||
DTSC::Meta meta;
|
||||
bool sending;
|
||||
int counter;
|
||||
std::deque<JSON::Value> preBuf;
|
||||
pushData(){
|
||||
sending = false;
|
||||
counter = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class OutRTMP : public Output {
|
||||
public:
|
||||
OutRTMP(Socket::Connection & conn);
|
||||
|
@ -16,12 +30,10 @@ namespace Mist {
|
|||
protected:
|
||||
void parseVars(std::string data);
|
||||
std::string app_name;
|
||||
bool sending;
|
||||
int counter;
|
||||
bool streamReset;
|
||||
void parseChunk(Socket::Buffer & inputBuffer);
|
||||
void parseAMFCommand(AMF::Object & amfData, int messageType, int streamId);
|
||||
void sendCommand(AMF::Object & amfReply, int messageType, int streamId);
|
||||
std::map<unsigned int, pushData> pushes;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue