Added canSeek* functionality to DTSC::Stream, minor optimization to MP4 lib.
This commit is contained in:
parent
00d06fe293
commit
f2b4e1d1a4
3 changed files with 39 additions and 1 deletions
36
lib/dtsc.cpp
36
lib/dtsc.cpp
|
@ -384,7 +384,39 @@ void DTSC::Stream::updateRingHeaders(){
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns 0 if seeking is possible, -1 if the wanted frame is too old, 1 if the wanted frame is too new.
|
||||
int DTSC::Stream::canSeekms(unsigned int ms){
|
||||
if ( !metadata["keytime"].size()){
|
||||
return 1;
|
||||
}
|
||||
if (ms > metadata["keytime"][metadata["keytime"].size() - 1].asInt()){
|
||||
return 1;
|
||||
}
|
||||
if (ms < metadata["keytime"][0u].asInt()){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Returns 0 if seeking is possible, -1 if the wanted frame is too old, 1 if the wanted frame is too new.
|
||||
int DTSC::Stream::canSeekFrame(unsigned int frameno){
|
||||
if ( !metadata["keynum"].size()){
|
||||
return 1;
|
||||
}
|
||||
if (frameno > metadata["keynum"][metadata["keynum"].size() - 1].asInt()){
|
||||
return 1;
|
||||
}
|
||||
if (frameno < metadata["keynum"][0u].asInt()){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int DTSC::Stream::msSeek(unsigned int ms){
|
||||
if (ms > buffers[keyframes[0u].b]["time"].asInt()){
|
||||
std::cerr << "Warning: seeking past ingest! (" << ms << "ms > " << buffers[keyframes[0u].b]["time"].asInt() << "ms)" << std::endl;
|
||||
return keyframes[0u].b;
|
||||
}
|
||||
for (std::deque<DTSC::Ring>::iterator it = keyframes.begin(); it != keyframes.end(); it++){
|
||||
if (buffers[it->b]["time"].asInt() <= ms){
|
||||
return it->b;
|
||||
|
@ -395,6 +427,10 @@ unsigned int DTSC::Stream::msSeek(unsigned int ms){
|
|||
}
|
||||
|
||||
unsigned int DTSC::Stream::frameSeek(unsigned int frameno){
|
||||
if (frameno > buffers[keyframes[0u].b]["fragnum"].asInt()){
|
||||
std::cerr << "Warning: seeking past ingest! (F" << frameno << " > F" << buffers[keyframes[0u].b]["fragnum"].asInt() << ")" << std::endl;
|
||||
return keyframes[0u].b;
|
||||
}
|
||||
for (std::deque<DTSC::Ring>::iterator it = keyframes.begin(); it != keyframes.end(); it++){
|
||||
if (buffers[it->b]["fragnum"].asInt() == frameno){
|
||||
return it->b;
|
||||
|
|
|
@ -127,6 +127,8 @@ namespace DTSC {
|
|||
unsigned int getTime();
|
||||
void dropRing(Ring * ptr);
|
||||
void updateHeaders();
|
||||
int canSeekms(unsigned int ms);
|
||||
int canSeekFrame(unsigned int frameno);
|
||||
unsigned int msSeek(unsigned int ms);
|
||||
unsigned int frameSeek(unsigned int frameno);
|
||||
void setBufferTime(unsigned int ms);
|
||||
|
|
|
@ -2180,7 +2180,7 @@ namespace MP4 {
|
|||
if (uuid_string[j] == '-'){
|
||||
continue;
|
||||
}
|
||||
data[8+i/2] |= (c2hex(uuid_string[j]) << (4-(4*(i%2))));
|
||||
data[8+i/2] |= (c2hex(uuid_string[j]) << ((~i & 1) << 2));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue