String copies omitted
This commit is contained in:
parent
6b78cad546
commit
9812ab6f41
4 changed files with 104 additions and 111 deletions
|
@ -41,7 +41,6 @@ namespace Connector_HTTP {
|
||||||
//OGG::Page curOggPage;
|
//OGG::Page curOggPage;
|
||||||
OGG::converter oggConv;
|
OGG::converter oggConv;
|
||||||
std::map <long long unsigned int, std::vector<JSON::Value> > DTSCBuffer;
|
std::map <long long unsigned int, std::vector<JSON::Value> > DTSCBuffer;
|
||||||
std::set <long long unsigned int> sendReady;
|
|
||||||
//std::map <long long unsigned int, long long unsigned int> prevGran;
|
//std::map <long long unsigned int, long long unsigned int> prevGran;
|
||||||
std::vector<unsigned int> curSegTable;
|
std::vector<unsigned int> curSegTable;
|
||||||
long long int currID = 0;
|
long long int currID = 0;
|
||||||
|
@ -127,17 +126,13 @@ namespace Connector_HTTP {
|
||||||
oggConv.readDTSCHeader(Strm.metadata);
|
oggConv.readDTSCHeader(Strm.metadata);
|
||||||
conn.SendNow((char*)oggConv.parsedPages.c_str(), oggConv.parsedPages.size());
|
conn.SendNow((char*)oggConv.parsedPages.c_str(), oggConv.parsedPages.size());
|
||||||
progressive_has_sent_header = true;
|
progressive_has_sent_header = true;
|
||||||
//setting sendReady to not ready
|
|
||||||
sendReady.clear();
|
|
||||||
}
|
}
|
||||||
//parse DTSC to Ogg here
|
//parse DTSC to Ogg here
|
||||||
if (Strm.lastType() == DTSC::AUDIO || Strm.lastType() == DTSC::VIDEO){
|
if (Strm.lastType() == DTSC::AUDIO || Strm.lastType() == DTSC::VIDEO){
|
||||||
currID = Strm.getPacket()["trackid"].asInt();
|
std::string tmpString;
|
||||||
DTSCBuffer[currID].push_back(Strm.getPacket());
|
oggConv.readDTSCVector(Strm.getPacket(), tmpString);
|
||||||
std::string tmpString = oggConv.readDTSCVector(DTSCBuffer[currID]);
|
conn.SendNow(tmpString);
|
||||||
conn.SendNow((char*)tmpString.c_str(), tmpString.size());
|
|
||||||
DTSCBuffer[currID].clear();
|
|
||||||
sendReady.insert(currID);
|
|
||||||
}
|
}
|
||||||
if (Strm.lastType() == DTSC::PAUSEMARK){
|
if (Strm.lastType() == DTSC::PAUSEMARK){
|
||||||
conn.close();
|
conn.close();
|
||||||
|
|
|
@ -33,21 +33,23 @@ namespace Converters{
|
||||||
|
|
||||||
|
|
||||||
while(DTSCFile.getJSON()){
|
while(DTSCFile.getJSON()){
|
||||||
currID = DTSCFile.getJSON()["trackid"].asInt();
|
//currID = DTSCFile.getJSON()["trackid"].asInt();
|
||||||
if (!DTSCBuffer[currID].empty()){
|
//if (!DTSCBuffer[currID].empty()){
|
||||||
std::cout << oggMeta.readDTSCVector(DTSCBuffer[currID]);
|
std::string tmpString;
|
||||||
DTSCBuffer[currID].clear();
|
oggMeta.readDTSCVector(DTSCFile.getJSON(), tmpString);
|
||||||
}
|
std::cout << tmpString;
|
||||||
DTSCBuffer[currID].push_back(DTSCFile.getJSON());
|
//DTSCBuffer[currID].clear();
|
||||||
|
//}
|
||||||
|
//DTSCBuffer[currID].push_back(DTSCFile.getJSON());
|
||||||
|
|
||||||
DTSCFile.parseNext();
|
DTSCFile.parseNext();
|
||||||
}
|
}
|
||||||
//outputting end of stream pages
|
//outputting end of stream pages
|
||||||
for (std::map< long long int, std::vector<JSON::Value> >::iterator it = DTSCBuffer.begin(); it != DTSCBuffer.end(); it++){
|
//for (std::map< long long int, std::vector<JSON::Value> >::iterator it = DTSCBuffer.begin(); it != DTSCBuffer.end(); it++){
|
||||||
if (!DTSCBuffer[it->first].empty() && DTSCBuffer[it->first][0]["data"].asString() != ""){
|
//if (!DTSCBuffer[it->first].empty() && DTSCBuffer[it->first][0]["data"].asString() != ""){
|
||||||
std::cout << oggMeta.readDTSCVector(DTSCBuffer[it->first]);
|
//std::cout << oggMeta.readDTSCVector(DTSCBuffer[it->first]);
|
||||||
}
|
//}
|
||||||
}
|
//}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,19 +80,18 @@ namespace OGG{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string converter::readDTSCVector(std::vector <JSON::Value> DTSCVec){
|
void converter::readDTSCVector(JSON::Value & DTSCPart, std::string & pageBuffer){
|
||||||
Page retVal;
|
Page retVal;
|
||||||
int typeFlag = 0;//flag to remember if the page has a continued segment
|
int typeFlag = 0;//flag to remember if the page has a continued segment
|
||||||
std::string pageBuffer = "";
|
long long int DTSCID = DTSCPart["trackid"].asInt();
|
||||||
long long int DTSCID = DTSCVec[0]["trackid"].asInt();
|
|
||||||
std::vector<unsigned int> curSegTable;
|
std::vector<unsigned int> curSegTable;
|
||||||
std::string dataBuffer;
|
std::string dataBuffer;
|
||||||
long long unsigned int lastGran = 0;
|
long long unsigned int lastGran = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < DTSCVec.size(); i++){
|
//for (unsigned int i = 0; i < DTSCVec.size(); i++){
|
||||||
OGG::Page tempPage;
|
OGG::Page tempPage;
|
||||||
tempPage.setSegmentTable(curSegTable);
|
tempPage.setSegmentTable(curSegTable);
|
||||||
if (DTSCVec[i]["data"].asString().size() >= (255-tempPage.getPageSegments())*255u){//if segment is too big
|
if (DTSCPart["data"].asString().size() >= (255-tempPage.getPageSegments())*255u){//if segment is too big
|
||||||
//Put page in Buffer and start next page
|
//Put page in Buffer and start next page
|
||||||
if (!curSegTable.empty()){
|
if (!curSegTable.empty()){
|
||||||
//output page
|
//output page
|
||||||
|
@ -111,7 +110,7 @@ namespace OGG{
|
||||||
curSegTable.clear();
|
curSegTable.clear();
|
||||||
dataBuffer = "";
|
dataBuffer = "";
|
||||||
}
|
}
|
||||||
std::string remainingData = DTSCVec[i]["data"].asString();
|
std::string remainingData = DTSCPart["data"].asString();
|
||||||
typeFlag = 0;
|
typeFlag = 0;
|
||||||
while (remainingData.size() > 255*255){
|
while (remainingData.size() > 255*255){
|
||||||
//output part of the segment
|
//output part of the segment
|
||||||
|
@ -137,13 +136,12 @@ namespace OGG{
|
||||||
curSegTable.push_back(remainingData.size());
|
curSegTable.push_back(remainingData.size());
|
||||||
dataBuffer += remainingData;
|
dataBuffer += remainingData;
|
||||||
}else{//build data for page
|
}else{//build data for page
|
||||||
curSegTable.push_back(DTSCVec[i]["data"].asString().size());
|
curSegTable.push_back(DTSCPart["data"].asString().size());
|
||||||
dataBuffer += DTSCVec[i]["data"].asString();
|
dataBuffer += DTSCPart["data"].asString();
|
||||||
}
|
}
|
||||||
//lastGran = calcGranule(DTSCID, DTSCVec[i]["keyframe"].asBool());
|
|
||||||
//calculating granule position
|
//calculating granule position
|
||||||
if (trackInf[DTSCID].codec == "theora"){
|
if (trackInf[DTSCID].codec == "theora"){
|
||||||
if (DTSCVec[i]["keyframe"].asBool()){
|
if (DTSCPart["keyframe"].asBool()){
|
||||||
trackInf[DTSCID].lastKeyFrame += trackInf[DTSCID].sinceKeyFrame + 1;
|
trackInf[DTSCID].lastKeyFrame += trackInf[DTSCID].sinceKeyFrame + 1;
|
||||||
trackInf[DTSCID].sinceKeyFrame = 0;
|
trackInf[DTSCID].sinceKeyFrame = 0;
|
||||||
}else{
|
}else{
|
||||||
|
@ -151,9 +149,8 @@ namespace OGG{
|
||||||
}
|
}
|
||||||
lastGran = (trackInf[DTSCID].lastKeyFrame << trackInf[DTSCID].significantValue) + trackInf[DTSCID].sinceKeyFrame;
|
lastGran = (trackInf[DTSCID].lastKeyFrame << trackInf[DTSCID].significantValue) + trackInf[DTSCID].sinceKeyFrame;
|
||||||
} else if (trackInf[DTSCID].codec == "vorbis"){
|
} else if (trackInf[DTSCID].codec == "vorbis"){
|
||||||
//decode DTSCVec[i]["data"].asString() for mode index
|
|
||||||
Utils::bitstreamLSBF packet;
|
Utils::bitstreamLSBF packet;
|
||||||
packet.append(DTSCVec[i]["data"].asString());
|
packet.append(DTSCPart["data"].asString());
|
||||||
//calculate amount of samples associated with that block (from ID header)
|
//calculate amount of samples associated with that block (from ID header)
|
||||||
//check mode block in deque for index
|
//check mode block in deque for index
|
||||||
int curPCMSamples = 0;
|
int curPCMSamples = 0;
|
||||||
|
@ -178,7 +175,7 @@ namespace OGG{
|
||||||
trackInf[DTSCID].lastKeyFrame += curPCMSamples;
|
trackInf[DTSCID].lastKeyFrame += curPCMSamples;
|
||||||
lastGran = trackInf[DTSCID].lastKeyFrame;
|
lastGran = trackInf[DTSCID].lastKeyFrame;
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
//last parts of page put out
|
//last parts of page put out
|
||||||
if (!curSegTable.empty()){
|
if (!curSegTable.empty()){
|
||||||
retVal.clear();
|
retVal.clear();
|
||||||
|
@ -193,6 +190,5 @@ namespace OGG{
|
||||||
trackInf[DTSCID].seqNum++;
|
trackInf[DTSCID].seqNum++;
|
||||||
pageBuffer += std::string((char*)retVal.getPage(), retVal.getPageSize());
|
pageBuffer += std::string((char*)retVal.getPage(), retVal.getPageSize());
|
||||||
}
|
}
|
||||||
return pageBuffer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace OGG {
|
||||||
class converter{
|
class converter{
|
||||||
public:
|
public:
|
||||||
void readDTSCHeader(DTSC::Meta & meta);
|
void readDTSCHeader(DTSC::Meta & meta);
|
||||||
std::string readDTSCVector(std::vector <JSON::Value> DTSCVec);
|
void readDTSCVector(JSON::Value & DTSCPart, std::string & pageBuffer);
|
||||||
std::string parsedPages;
|
std::string parsedPages;
|
||||||
private:
|
private:
|
||||||
std::map <long long unsigned int, trackStats> trackInf;
|
std::map <long long unsigned int, trackStats> trackInf;
|
||||||
|
|
Loading…
Add table
Reference in a new issue