Fixed timestamps in HLS Manifest file
This commit is contained in:
parent
00a47f24d8
commit
cbb9b52d1c
1 changed files with 17 additions and 21 deletions
|
@ -56,18 +56,16 @@ namespace Connector_HTTP {
|
||||||
if (metadata.isMember("length") && metadata["length"].asInt() > 0){
|
if (metadata.isMember("length") && metadata["length"].asInt() > 0){
|
||||||
Result << "#EXTM3U\r\n"
|
Result << "#EXTM3U\r\n"
|
||||||
//"#EXT-X-VERSION:1\r\n"
|
//"#EXT-X-VERSION:1\r\n"
|
||||||
"#EXT-X-MEDIA-SEQUENCE:1\r\n"
|
|
||||||
//"#EXT-X-ALLOW-CACHE:YES\r\n"
|
//"#EXT-X-ALLOW-CACHE:YES\r\n"
|
||||||
"#EXT-X-TARGETDURATION:" << (longestFragment / 1000) + 1 << "\r\n";
|
"#EXT-X-TARGETDURATION:" << (longestFragment / 1000) + 1 << "\r\n"
|
||||||
|
"#EXT-X-MEDIA-SEQUENCE:0\r\n";
|
||||||
//"#EXT-X-PLAYLIST-TYPE:VOD\r\n";
|
//"#EXT-X-PLAYLIST-TYPE:VOD\r\n";
|
||||||
int lastDuration = 0;
|
int lastDuration = 0;
|
||||||
bool writeOffset = true;
|
bool writeOffset = true;
|
||||||
fragIndices.push_back(metadata["keytime"][metadata["keytime"].size() - 1].asInt() + 1);
|
|
||||||
for (int i = 0; i < fragIndices.size() - 1; i++){
|
for (int i = 0; i < fragIndices.size() - 1; i++){
|
||||||
Result << "#EXTINF:" << (metadata["keytime"][fragIndices[i]].asInt() - lastDuration) / 1000 << "." << std::setw(3) << std::setfill('0')
|
Result << "#EXTINF:" << (metadata["keytime"][fragIndices[i+1]].asInt() - lastDuration) / 1000 << ", no desc\r\n" << fragIndices[i] << "_"
|
||||||
<< ((metadata["keytime"][fragIndices[i]].asInt() - lastDuration) % 1000) << ",\r\n" << fragIndices[i] << "_"
|
|
||||||
<< fragIndices[i + 1] - fragIndices[i] << ".ts\r\n";
|
<< fragIndices[i + 1] - fragIndices[i] << ".ts\r\n";
|
||||||
lastDuration = metadata["keytime"][fragIndices[i]].asInt();
|
lastDuration = metadata["keytime"][fragIndices[i+1]].asInt();
|
||||||
}
|
}
|
||||||
Result << "#EXT-X-ENDLIST";
|
Result << "#EXT-X-ENDLIST";
|
||||||
}else{
|
}else{
|
||||||
|
@ -115,6 +113,8 @@ namespace Connector_HTTP {
|
||||||
|
|
||||||
std::vector<int> fragIndices;
|
std::vector<int> fragIndices;
|
||||||
|
|
||||||
|
std::string manifestType;
|
||||||
|
|
||||||
int Segment = -1;
|
int Segment = -1;
|
||||||
int temp;
|
int temp;
|
||||||
int Flash_RequestPending = 0;
|
int Flash_RequestPending = 0;
|
||||||
|
@ -169,19 +169,21 @@ namespace Connector_HTTP {
|
||||||
Flash_RequestPending++;
|
Flash_RequestPending++;
|
||||||
}else{
|
}else{
|
||||||
streamname = HTTP_R.url.substr(5, HTTP_R.url.find("/", 5) - 5);
|
streamname = HTTP_R.url.substr(5, HTTP_R.url.find("/", 5) - 5);
|
||||||
|
if (HTTP_R.url.find(".m3u8") != std::string::npos){
|
||||||
|
manifestType = "audio/x-mpegurl";
|
||||||
|
} else {
|
||||||
|
manifestType = "audio/mpegurl";
|
||||||
|
}
|
||||||
if ( !Strm.metadata.isNull()){
|
if ( !Strm.metadata.isNull()){
|
||||||
HTTP_S.Clean();
|
HTTP_S.Clean();
|
||||||
if (HTTP_R.url.find(".m3u8") != std::string::npos){
|
HTTP_S.SetHeader("Content-Type", manifestType);
|
||||||
HTTP_S.SetHeader("Content-Type", "application/vnd.apple.mpegurl"); //m3u8
|
|
||||||
}else{
|
|
||||||
HTTP_S.SetHeader("Content-Type", "audio/mpegurl"); //m3u
|
|
||||||
}
|
|
||||||
HTTP_S.SetHeader("Cache-Control", "no-cache");
|
HTTP_S.SetHeader("Cache-Control", "no-cache");
|
||||||
if (Strm.metadata.isMember("length")){
|
if (Strm.metadata.isMember("length")){
|
||||||
receive_marks = true;
|
receive_marks = true;
|
||||||
}
|
}
|
||||||
std::string manifest = BuildIndex(streamname, Strm.metadata);
|
std::string manifest = BuildIndex(streamname, Strm.metadata);
|
||||||
HTTP_S.SetBody(manifest);
|
HTTP_S.SetBody(manifest);
|
||||||
|
fprintf( stderr, "%s\n", HTTP_S.GetHeader( "Content-Type" ).c_str() );
|
||||||
conn.SendNow(HTTP_S.BuildResponse("200", "OK"));
|
conn.SendNow(HTTP_S.BuildResponse("200", "OK"));
|
||||||
#if DEBUG >= 3
|
#if DEBUG >= 3
|
||||||
printf("Sent manifest\n");
|
printf("Sent manifest\n");
|
||||||
|
@ -246,12 +248,9 @@ namespace Connector_HTTP {
|
||||||
receive_marks = true;
|
receive_marks = true;
|
||||||
}
|
}
|
||||||
std::string manifest = BuildIndex(streamname, Strm.metadata);
|
std::string manifest = BuildIndex(streamname, Strm.metadata);
|
||||||
if (HTTP_R.url.find(".m3u8") != std::string::npos){
|
HTTP_S.SetHeader("Content-Type", manifestType);
|
||||||
HTTP_S.SetHeader("Content-Type", "application/vnd.apple.mpegurl"); //m3u8
|
|
||||||
}else{
|
|
||||||
HTTP_S.SetHeader("Content-Type", "audio/mpegurl"); //m3u
|
|
||||||
}
|
|
||||||
HTTP_S.SetBody(manifest);
|
HTTP_S.SetBody(manifest);
|
||||||
|
fprintf( stderr, "%s\n", HTTP_S.GetHeader( "Content-Type" ).c_str() );
|
||||||
conn.SendNow(HTTP_S.BuildResponse("200", "OK"));
|
conn.SendNow(HTTP_S.BuildResponse("200", "OK"));
|
||||||
#if DEBUG >= 3
|
#if DEBUG >= 3
|
||||||
printf("Sent manifest\n");
|
printf("Sent manifest\n");
|
||||||
|
@ -389,13 +388,10 @@ namespace Connector_HTTP {
|
||||||
if (Strm.metadata.isMember("length")){
|
if (Strm.metadata.isMember("length")){
|
||||||
receive_marks = true;
|
receive_marks = true;
|
||||||
}
|
}
|
||||||
if (HTTP_R.url.find(".m3u8") != std::string::npos){
|
HTTP_S.SetHeader("Content-Type", manifestType);
|
||||||
HTTP_S.SetHeader("Content-Type", "application/vnd.apple.mpegurl"); //m3u8
|
|
||||||
}else{
|
|
||||||
HTTP_S.SetHeader("Content-Type", "audio/mpegurl"); //m3u
|
|
||||||
}
|
|
||||||
std::string manifest = BuildIndex(streamname, Strm.metadata);
|
std::string manifest = BuildIndex(streamname, Strm.metadata);
|
||||||
HTTP_S.SetBody(manifest);
|
HTTP_S.SetBody(manifest);
|
||||||
|
fprintf( stderr, "%s\n", HTTP_S.GetHeader( "Content-Type" ).c_str() );
|
||||||
conn.SendNow(HTTP_S.BuildResponse("200", "OK"));
|
conn.SendNow(HTTP_S.BuildResponse("200", "OK"));
|
||||||
#if DEBUG >= 3
|
#if DEBUG >= 3
|
||||||
printf("Sent manifest\n");
|
printf("Sent manifest\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue