MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new ::Ui::MainWindow) { ui->setupUi(this); showNormal(); QLabel* l = new QLabel(ui->statusbar); ui->statusbar->showMessage("Loaded", 2000); VD_LOG("UI successully initalized"); grabKeyboard(); FfmpegPlugin ffmpeg; ffmpeg.install(); preview_.reset(new Preview(ui->video)); project_.reset(new Project(std::make_shared<SdlVideoPresenter>(ui->video), std::make_shared<SdlAudioPresenter>(preview_->audio()))); project_->_create_test(); preview_->bind(project_.get()); ui->timeline->bind(&*project_->time_line_); ui->timeline->set_preview(preview_.get()); pause_state_.reset(new QState()); pause_state_->assignProperty(ui->play_btn, "icon", QIcon(":/icon-play.png")); connect(pause_state_.get(), SIGNAL(entered()), preview_.get(), SLOT(pause_play())); play_state_.reset(new QState()); play_state_->assignProperty(ui->play_btn, "icon", QIcon(":/icon-pause.png")); connect(play_state_.get(), SIGNAL(entered()), preview_.get(), SLOT(continue_play())); pause_state_->addTransition(ui->play_btn, SIGNAL(clicked()), play_state_.get()); play_state_->addTransition(ui->play_btn, SIGNAL(clicked()), pause_state_.get()); machine_.addState(pause_state_.get()); machine_.addState(play_state_.get()); machine_.setInitialState(pause_state_.get()); machine_.start(); preview_thread_.reset(new QThread(this)); connect(preview_thread_.get(), SIGNAL(started()), preview_.get(), SLOT(_start_play())); preview_->moveToThread(preview_thread_.get()); connect(ui->volume, SIGNAL(valueChanged(int)), this, SLOT(audio_volume_changed(int))); VD_LOG("Running preview thread"); preview_thread_->start(); }
static enum mad_flow remote_parse_input(buffer *buf, playlist *pl) { char input[PATH_MAX + 5]; /* for filename as well as input and space */ char new_remote_input_buf[PATH_MAX + 5]; char *arg; int numread; int alreadyread; int linelen; fd_set fd; struct timeval tv = { 0, 0 }; FD_ZERO(&fd); FD_SET(0,&fd); alreadyread = strlen (remote_input_buf); if (select (1, &fd, NULL, NULL, &tv)) { if (!(numread = read(0, remote_input_buf + alreadyread, (sizeof(input)-1)-alreadyread)) > 0) { numread = 0; /* fprintf(stderr, "remote_parse_input() called with no input queued!"); exit(1); This never happens.. (read blocks) */ } } else { numread = 0; } remote_input_buf[numread+alreadyread] = '\0'; if ((arg = strchr(remote_input_buf, '\n'))) { *(arg) = '\0'; } linelen = strlen (remote_input_buf); strcpy (input, remote_input_buf); /* input[linelen] = '\0'; */ strcpy (new_remote_input_buf, remote_input_buf + linelen + 1); /* don't copy the \0... */ strcpy (remote_input_buf, new_remote_input_buf); trim_whitespace(input); /* Trims on left and right side only */ if (strlen(input) == 0) return 0; arg = strchr(input, ' '); if (arg) { *(arg++) = '\0'; arg = strdup(arg); trim_whitespace(arg); } if (strcasecmp(input, "L") == 0 || strcasecmp(input, "LOAD") == 0) { if(arg) { status = MPG321_PLAYING; play_remote_file(pl, arg); current_frame = 0; options.seek = 0; pause_play(NULL, NULL); /* reset pause data */ goto stop; } else { /* this works because if there's no argument, input is just 'l' or 'load' */ printf("@E Missing argument to '%s'\n",input); return 0; } } else if (strcasecmp(input, "J") == 0 || strcasecmp(input, "JUMP") == 0) { if (status == MPG321_PLAYING && arg) { /* relative seek */ if (arg[0] == '-' || arg[0] == '+') { signed long toMove = atol(arg); /* on forward seeks we don't need to stop decoding */ enum mad_flow toDo = move(buf, toMove); if (arg) free(arg); return toDo; } /* absolute seek */ else { long toSeek = atol(arg); seek(buf, toSeek); goto stop; } } else { /* mpg123 does no error checking, so we should emulate them */ } } else if (strcasecmp(input, "S") == 0 || strcasecmp(input, "STOP") == 0) { if (status != MPG321_STOPPED) { status = MPG321_STOPPED; clear_remote_file(pl); current_frame = 0; pause_play(NULL, NULL); /* reset pause data */ printf("@P 0\n"); } goto stop; } else if (strcasecmp(input, "Q") == 0 || strcasecmp(input, "QUIT") == 0) { quit_now = 1; goto stop; } else if (strcasecmp(input, "P") == 0 || strcasecmp(input, "PAUSE") == 0) { if (status == MPG321_PLAYING || status == MPG321_PAUSED) { pause_play(buf, pl); } goto stop; } else { fprintf(stderr, "@E Unknown command '%s'\n", input); } if (arg) free(arg); return 0; stop: if (arg) free(arg); return MAD_FLOW_STOP; }