player: require "seek" before outputting

This commit is contained in:
Peter Wu 2012-08-28 16:47:36 +02:00
parent 96f0ade4ca
commit b592d39bfd
4 changed files with 17 additions and 0 deletions

View file

@ -184,6 +184,7 @@ namespace Connector_HTTP{
#if DEBUG >= 3
fprintf(stderr, "Everything connected, starting to send video data...\n");
#endif
ss.Send("play\n");ss.flush();
inited = true;
}
if ((Flash_RequestPending > 0) && !Flash_FragBuffer.empty()){

View file

@ -74,6 +74,7 @@ namespace Connector_HTTP{
#if DEBUG >= 3
fprintf(stderr, "Everything connected, starting to send video data...\n");
#endif
ss.Send("play\n");ss.flush();
inited = true;
}
unsigned int now = time(0);

View file

@ -89,6 +89,7 @@ int Connector_RTMP::Connector_RTMP(Socket::Connection conn){
#if DEBUG >= 3
fprintf(stderr, "Everything connected, starting to send video data...\n");
#endif
SS.Send("play\n");SS.flush();
inited = true;
}
if (inited && !nostats){

View file

@ -147,9 +147,14 @@ seekDone:
/// Reads a command from stdin. Returns true if a command was read.
bool File::readCommand() {
char line[512];
size_t line_len;
if (fgets(line, sizeof(line), stdin) == NULL){
return false;
}
line_len = strlen(line);
if (line[line_len - 1] == '\n'){
line[--line_len] = 0;
}
{
int position = INT_MAX;// special value that says "invalid"
if (!strncmp("seek ", line, sizeof("seek ") - 1)){
@ -164,6 +169,9 @@ seekDone:
return true;
}
}
if (!strcmp("play", line)){
playing = true;
}
return false;
}
@ -173,6 +181,12 @@ seekDone:
if (readCommand()) {
continue;
}
if (!playing){
setBlocking(STDIN_FILENO, true);
continue;
}else{
setBlocking(STDIN_FILENO, false);
}
now = getNowMS();
if (now - timeDiff >= lastTime || lastTime - (now - timeDiff) > 5000) {
if (nextPacket()) {