Poging tot betere fragment queue
This commit is contained in:
parent
a6b04273aa
commit
ce29cf218e
1 changed files with 14 additions and 16 deletions
|
@ -127,7 +127,7 @@ int mainHandler(int CONN_fd){
|
||||||
std::string FlashBuf;
|
std::string FlashBuf;
|
||||||
std::string FlashMeta;
|
std::string FlashMeta;
|
||||||
bool Flash_ManifestSent = false;
|
bool Flash_ManifestSent = false;
|
||||||
bool Flash_RequestPending = false;
|
int Flash_RequestPending = 0;
|
||||||
std::queue<std::string> Flash_FragBuffer;
|
std::queue<std::string> Flash_FragBuffer;
|
||||||
FLV_Pack * tag = 0;
|
FLV_Pack * tag = 0;
|
||||||
HTTPReader HTTP_R, HTTP_S;//HTTP Receiver en HTTP Sender.
|
HTTPReader HTTP_R, HTTP_S;//HTTP Receiver en HTTP Sender.
|
||||||
|
@ -178,12 +178,9 @@ int mainHandler(int CONN_fd){
|
||||||
ReqFragment = atoi( HTTP_R.url.substr(temp).c_str() );
|
ReqFragment = atoi( HTTP_R.url.substr(temp).c_str() );
|
||||||
#if DEBUG >= 4
|
#if DEBUG >= 4
|
||||||
printf( "URL: %s\n", HTTP_R.url.c_str());
|
printf( "URL: %s\n", HTTP_R.url.c_str());
|
||||||
printf( "Movie Identifier: %s\n", Movie.c_str() );
|
printf( "Movie: %s, Quality: %s, Seg %d Frag %d\n", Movie.c_str(), Quality.c_str(), Segment, ReqFragment);
|
||||||
printf( "Quality Modifier: %s\n", Quality.c_str() );
|
|
||||||
printf( "Segment: %d\n", Segment );
|
|
||||||
printf( "Fragment: %d\n", ReqFragment );
|
|
||||||
#endif
|
#endif
|
||||||
Flash_RequestPending = true;
|
Flash_RequestPending++;
|
||||||
}else{
|
}else{
|
||||||
Movie = HTTP_R.url.substr(1);
|
Movie = HTTP_R.url.substr(1);
|
||||||
Movie = Movie.substr(0,Movie.find("/"));
|
Movie = Movie.substr(0,Movie.find("/"));
|
||||||
|
@ -232,6 +229,17 @@ int mainHandler(int CONN_fd){
|
||||||
#endif
|
#endif
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
if ((Flash_RequestPending > 0) && !Flash_FragBuffer.empty()){
|
||||||
|
HTTP_S.Clean();
|
||||||
|
HTTP_S.SetHeader("Content-Type","video/mp4");
|
||||||
|
HTTP_S.SetBody(Interface::mdatFold(Flash_FragBuffer.front()));
|
||||||
|
Flash_FragBuffer.pop();
|
||||||
|
HTTP_S.SendResponse(CONN_fd, "200", "OK");//schrijf de HTTP response header
|
||||||
|
Flash_RequestPending--;
|
||||||
|
#if DEBUG >= 4
|
||||||
|
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);
|
retval = epoll_wait(sspoller, events, 1, 1);
|
||||||
switch (DDV_ready(ss)){
|
switch (DDV_ready(ss)){
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -248,16 +256,6 @@ int mainHandler(int CONN_fd){
|
||||||
if (tag->isKeyframe){
|
if (tag->isKeyframe){
|
||||||
Flash_FragBuffer.push(FlashBuf);
|
Flash_FragBuffer.push(FlashBuf);
|
||||||
FlashBuf = "";
|
FlashBuf = "";
|
||||||
if (Flash_RequestPending){
|
|
||||||
HTTP_S.Clean();
|
|
||||||
HTTP_S.SetHeader("Content-Type","video/mp4");
|
|
||||||
HTTP_S.SetBody(Interface::mdatFold(Flash_FragBuffer.front()));
|
|
||||||
Flash_FragBuffer.pop();
|
|
||||||
HTTP_S.SendResponse(CONN_fd, "200", "OK");//schrijf de HTTP response header
|
|
||||||
#if DEBUG >= 4
|
|
||||||
fprintf(stderr, "Sending a video fragment. %i left in buffer.\n", (int)Flash_FragBuffer.size());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FlashBuf.append(tag->data,tag->len);
|
FlashBuf.append(tag->data,tag->len);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue