FIFO buffer for fragments
This commit is contained in:
parent
25640de402
commit
a6b04273aa
1 changed files with 9 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
#define DEBUG 4
|
#define DEBUG 4
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <queue>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -127,6 +128,7 @@ int mainHandler(int CONN_fd){
|
||||||
std::string FlashMeta;
|
std::string FlashMeta;
|
||||||
bool Flash_ManifestSent = false;
|
bool Flash_ManifestSent = false;
|
||||||
bool Flash_RequestPending = false;
|
bool Flash_RequestPending = false;
|
||||||
|
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.
|
||||||
|
|
||||||
|
@ -244,12 +246,17 @@ int mainHandler(int CONN_fd){
|
||||||
if (handler == HANDLER_FLASH){
|
if (handler == HANDLER_FLASH){
|
||||||
if(tag->data[0] != 0x12 ) {
|
if(tag->data[0] != 0x12 ) {
|
||||||
if (tag->isKeyframe){
|
if (tag->isKeyframe){
|
||||||
|
Flash_FragBuffer.push(FlashBuf);
|
||||||
|
FlashBuf = "";
|
||||||
if (Flash_RequestPending){
|
if (Flash_RequestPending){
|
||||||
HTTP_S.Clean();
|
HTTP_S.Clean();
|
||||||
HTTP_S.SetHeader("Content-Type","video/mp4");
|
HTTP_S.SetHeader("Content-Type","video/mp4");
|
||||||
HTTP_S.SetBody(Interface::mdatFold(FlashBuf));
|
HTTP_S.SetBody(Interface::mdatFold(Flash_FragBuffer.front()));
|
||||||
FlashBuf = "";
|
Flash_FragBuffer.pop();
|
||||||
HTTP_S.SendResponse(CONN_fd, "200", "OK");//schrijf de HTTP response header
|
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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue