Exemplo n.º 1
0
static void start_preview(LiVESButton *button, lives_rfx_t *rfx) {
  int i;
  char *com;

  lives_widget_set_sensitive(mainw->framedraw_preview,FALSE);
  lives_widget_context_update();

  if (mainw->did_rfx_preview) {
    lives_kill_subprocesses(cfile->handle,TRUE);

    if (cfile->start==0) {
      cfile->start=1;
      cfile->end=cfile->frames;
    }

    do_rfx_cleanup(rfx);
  }

  com=lives_strdup_printf("%s clear_pre_files \"%s\" 2>%s",prefs->backend_sync,cfile->handle,LIVES_DEVNULL);
  lives_system(com,TRUE); // clear any .pre files from before

  for (i=0; i<rfx->num_params; i++) {
    rfx->params[i].changed=FALSE;
  }

  mainw->cancelled=CANCEL_NONE;
  mainw->error=FALSE;

  // within do_effect() we check and if
  do_effect(rfx,TRUE); // actually start effect processing in the background

  lives_widget_set_sensitive(mainw->framedraw_spinbutton,TRUE);
  lives_widget_set_sensitive(mainw->framedraw_scale,TRUE);

  if (mainw->framedraw_frame>cfile->start&&!(cfile->start==0&&mainw->framedraw_frame==1))
    lives_spin_button_set_value(LIVES_SPIN_BUTTON(mainw->framedraw_spinbutton),cfile->start);
  else {
    load_rfx_preview(rfx);
  }

  mainw->did_rfx_preview=TRUE;
}
Exemplo n.º 2
0
Arquivo: cvirtual.c Projeto: tbe/LiVES
void del_frame_index(lives_clip_t *sfile) {
  // physically delete the frame_index for a clip
  // only done once all

  char *idxfile;
  char *com;

  register int i;

  // cannot call check_if_non_virtual() else we end up recursing

  if (sfile->frame_index!=NULL) {
    for (i=1; i<=sfile->frames; i++) {
      if (sfile->frame_index[i-1]!=-1) {
        LIVES_ERROR("deleting frame_index with virtual frames in it !");
        return;
      }
    }
  }

  if (sfile!=clipboard) {
    idxfile=lives_build_filename(prefs->tmpdir,sfile->handle,"file_index",NULL);

#ifndef IS_MINGW
    com=lives_strdup_printf("/bin/rm -f \"%s\"",idxfile);
#else
    com=lives_strdup_printf("rm.exe -f \"%s\"",idxfile);
#endif

    lives_system(com,FALSE);
    lives_free(com);

    lives_free(idxfile);
  }

  if (sfile->frame_index!=NULL) lives_free(sfile->frame_index);
  sfile->frame_index=NULL;
}
Exemplo n.º 3
0
Arquivo: cvirtual.c Projeto: tbe/LiVES
void clean_images_from_virtual(lives_clip_t *sfile, int oldframes) {
  // remove images on disk where the frame_index points to a frame in
  // the original clip

  // only needed if frames were reordered when rendered and the process is
  // then undone

  // in future, a smarter function could trace the images back to their
  // original source frames, and just rename them


  // should be threadsafe

  register int i;
  char *iname=NULL,*com;

  if (sfile==NULL||sfile->frame_index==NULL) return;

  for (i=0; i<oldframes; i++) {
    threaded_dialog_spin();
    lives_widget_context_update();
    threaded_dialog_spin();

    if ((i<sfile->frames&&sfile->frame_index[i]!=-1)||i>=sfile->frames) {
      iname=lives_strdup_printf("%s/%s/%08d.%s",prefs->tmpdir,sfile->handle,i,get_image_ext_for_type(sfile->img_type));

#ifndef IS_MINGW
      com=lives_strdup_printf("/bin/rm -f \"%s\"",iname);
#else
      com=lives_strdup_printf("rm.exe -f \"%s\"",iname);
#endif
      lives_system(com,FALSE);
      lives_free(com);
    }
  }
}
Exemplo n.º 4
0
void on_live_fw_activate(LiVESMenuItem *menuitem, livespointer user_data) {

  char *com,*tmp;
  int cardno;
  int cache=1024;

  int new_file=mainw->first_free_file;

  int response;

  char *fifofile=lives_strdup_printf("%s/firew.%d",prefs->tmpdir,capable->mainpid);
  char *fname;

  LiVESWidget *card_dialog;

  mainw->open_deint=FALSE;

  card_dialog=create_cdtrack_dialog(5,NULL);
  response=lives_dialog_run(LIVES_DIALOG(card_dialog));
  if (response==LIVES_RESPONSE_CANCEL) {
    lives_widget_destroy(card_dialog);
    lives_free(fifofile);
    return;
  }

  cardno=(int)mainw->fx1_val;

  lives_widget_destroy(card_dialog);

  if (lives_list_find(fw_cards,LIVES_INT_TO_POINTER(cardno))) {
    lives_free(fifofile);
    do_card_in_use_error();
    return;
  }

  fname=lives_strdup_printf(_("Firewire card %d"),cardno);

  if (!get_new_handle(new_file,fname)) {
    lives_free(fifofile);
    lives_free(fname);
    return;
  }

  fw_cards=lives_list_append(fw_cards,LIVES_INT_TO_POINTER(cardno));

  mainw->current_file=new_file;
  cfile->deinterlace=mainw->open_deint;

  unlink(fifofile);
  mkfifo(fifofile,S_IRUSR|S_IWUSR);

  com=lives_strdup_printf("%s open_fw_card \"%s\" %d %d \"%s\"",prefs->backend,cfile->handle,cardno,cache,fifofile);
  mainw->com_failed=FALSE;
  lives_system(com,FALSE);
  lives_free(com);

  if (mainw->com_failed) {
    mainw->com_failed=FALSE;
    lives_free(fname);
    lives_free(fifofile);
    return;
  }

  if (!open_yuv4m_inner(fifofile,fname,new_file,YUV4_TYPE_FW,cardno)) {
    lives_free(fname);
    lives_free(fifofile);
    return;
  }

  lives_snprintf(cfile->type,40,"%s",fname);

  d_print((tmp=lives_strdup_printf(_("Opened firewire card %d"),cardno)));

  lives_free(tmp);
  lives_free(fname);
  lives_free(fifofile);

}
Exemplo n.º 5
0
void on_live_tvcard_activate(LiVESMenuItem *menuitem, livespointer user_data) {
  int cardno=0;

  int new_file=mainw->first_free_file;

  int response;

  char *com,*tmp;
  char *fifofile=lives_strdup_printf("%s/tvpic.%d",prefs->tmpdir,capable->mainpid);

  char *chanstr;
  char *devstr;

  char *fname;

  LiVESWidget *card_dialog;

  lives_tvcardw_t *tvcardw;

  mainw->open_deint=FALSE;

  card_dialog=create_cdtrack_dialog(4,NULL);

  tvcardw=(lives_tvcardw_t *)lives_widget_object_get_data(LIVES_WIDGET_OBJECT(card_dialog),"tvcard_data");


  response=lives_dialog_run(LIVES_DIALOG(card_dialog));
  if (response==LIVES_RESPONSE_CANCEL) {
    lives_widget_destroy(card_dialog);
    lives_free(fifofile);
    lives_free(tvcardw);
    return;
  }

  cardno=(int)mainw->fx1_val;
  chanstr=lives_strdup_printf("%d",(int)mainw->fx2_val);

  if (lives_list_find(mainw->videodevs,LIVES_INT_TO_POINTER(cardno))) {
    lives_widget_destroy(card_dialog);
    do_card_in_use_error();
    lives_free(chanstr);
    lives_free(fifofile);
    lives_free(tvcardw);
    return;
  }

  fname=lives_strdup_printf(_("TV card %d"),cardno);

  if (!get_new_handle(new_file,fname)) {
    lives_widget_destroy(card_dialog);
    lives_free(chanstr);
    lives_free(fifofile);
    lives_free(fname);
    lives_free(tvcardw);
    return;
  }

  devstr=lives_strdup_printf("/dev/video%d",cardno);

  if (!check_dev_busy(devstr)) {
    lives_widget_destroy(card_dialog);
    do_dev_busy_error(fname);
    lives_free(devstr);
    lives_free(chanstr);
    lives_free(fifofile);
    lives_free(fname);
    lives_free(tvcardw);
    return;
  }

  mainw->videodevs=lives_list_append(mainw->videodevs,LIVES_INT_TO_POINTER(cardno));

  mainw->current_file=new_file;

  cfile->deinterlace=mainw->open_deint;

  unlink(fifofile);
  mkfifo(fifofile,S_IRUSR|S_IWUSR);

  if (!tvcardw->use_advanced) {
    com=lives_strdup_printf("%s open_tv_card \"%s\" \"%s\" \"%s\" \"%s\"",prefs->backend,cfile->handle,chanstr,
                            devstr,fifofile);
  } else {
    double fps=0.;
    char *driver=NULL,*outfmt=NULL;
    int width=0,height=0;
    int input=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttoni));

    if (!lives_toggle_button_get_active(LIVES_TOGGLE_BUTTON(tvcardw->radiobuttond))) {
      width=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttonw));
      height=lives_spin_button_get_value_as_int(LIVES_SPIN_BUTTON(tvcardw->spinbuttonh));
      fps=lives_spin_button_get_value(LIVES_SPIN_BUTTON(tvcardw->spinbuttonf));
    }

    driver=lives_combo_get_active_text(LIVES_COMBO(tvcardw->combod));
    outfmt=lives_combo_get_active_text(LIVES_COMBO(tvcardw->comboo));

    com=lives_strdup_printf("%s open_tv_card \"%s\" \"%s\" \"%s\" \"%s\" %d %d %d %.3f \"%s\" \"%s\"",
                            prefs->backend,cfile->handle,chanstr,
                            devstr,fifofile,input,width,height,fps,driver,outfmt);
    lives_free(driver);
    lives_free(outfmt);

  }
  lives_widget_destroy(card_dialog);
  lives_free(tvcardw);

  mainw->com_failed=FALSE;
  lives_system(com,FALSE);
  lives_free(com);

  if (mainw->com_failed) {
    mainw->com_failed=FALSE;
    lives_free(fname);
    lives_free(chanstr);
    lives_free(fifofile);
    lives_free(devstr);
    return;
  }

  if (!open_yuv4m_inner(fifofile,fname,new_file,YUV4_TYPE_TV,cardno)) {
    lives_free(fname);
    lives_free(chanstr);
    lives_free(fifofile);
    lives_free(devstr);
    return;
  }

  lives_snprintf(cfile->type,40,"%s",fname);

  d_print((tmp=lives_strdup_printf(_("Opened TV card %d (%s)"),cardno,devstr)));

  lives_free(tmp);
  lives_free(fname);
  lives_free(chanstr);
  lives_free(devstr);
  lives_free(fifofile);

}
Exemplo n.º 6
0
void on_open_yuv4m_activate(LiVESMenuItem *menuitem, livespointer user_data) {
  // open a general yuvmpeg stream
  // start "playing" but open frames in yuv4mpeg format on stdin

  int old_file=mainw->current_file,new_file=mainw->first_free_file;
  char *tmp;
  char *filename;
  char *fname;

  char *audio_real,*audio_fake;

  if (menuitem && !do_yuv4m_open_warning()) return;

  fname=lives_strdup(_("yuv4mpeg stream"));

  if (!get_new_handle(new_file,fname)) {
    lives_free(fname);
    return;
  }

  mainw->current_file=new_file;

  if (!strlen(prefs->yuvin))
    filename=lives_build_filename(prefs->tmpdir,"stream.yuv",NULL);
  else
    filename=lives_strdup(prefs->yuvin);

  mkfifo(filename,S_IRUSR|S_IWUSR);

  if (!open_yuv4m_inner(filename,fname,new_file,YUV4_TYPE_GENERIC,0)) {
    close_current_file(old_file);
    lives_free(filename);
    lives_free(fname);
    return;
  }

  lives_free(fname);

  if (!lives_yuv_stream_start_read(cfile)) {
    close_current_file(old_file);
    lives_free(filename);
    return;
  }

  new_file=mainw->current_file;

  lives_snprintf(cfile->type,40,"%s",_("yu4mpeg stream in"));

  d_print((tmp=lives_strdup_printf(_("Opened yuv4mpeg stream on %s"),filename)));
  lives_free(tmp);
  lives_free(filename);

  d_print(_("Audio: "));

  if (cfile->achans==0) {
    d_print(_("none\n"));
  } else {
    d_print((tmp=lives_strdup_printf(P_("%d Hz %d channel %d bps\n","%d Hz %d channels %d bps\n",cfile->achans),
                                     cfile->arate,cfile->achans,cfile->asampsize)));
    lives_free(tmp);
  }

  // if not playing, start playing
  if (mainw->playing_file==-1) {

    // temp kludge, symlink audiodump.pcm to wav file, then pretend we are playing
    // an opening preview . Doesn't work with fifo.
    // and we dont really care if it doesnt work

    // but what it means is, if we have an audio file or stream at
    // "prefs->tmpdir/audiodump.pcm" we will try to play it



    // real is tmpdir/audiodump.pcm
    audio_real=lives_build_filename(prefs->tmpdir,"audiodump.pcm",NULL);
    // fake is tmpdir/handle/audiodump.pcm
    audio_fake=lives_build_filename(prefs->tmpdir,cfile->handle,"audiodump.pcm",NULL);


#ifndef IS_MINGW
    // fake file will go away when we close the current clip
    lives_system((tmp=lives_strdup_printf("/bin/ln -s \"%s\" \"%s\" >/dev/null 2>&1",
                                          audio_real,audio_fake)),TRUE);
#else
    // TODO
#endif

    lives_free(audio_real);
    lives_free(audio_fake);

    lives_free(tmp);

    // start playing
    play_file();

    mainw->noswitch=FALSE;
  }
  // TODO - else...

  if (mainw->current_file!=old_file&&mainw->current_file!=new_file)
    old_file=mainw->current_file; // we could have rendered to a new file

  mainw->current_file=new_file;

  // close this temporary clip
  close_current_file(old_file);

}
Exemplo n.º 7
0
static void start_preview(LiVESButton *button, lives_rfx_t *rfx) {
  int i;
  char *com;

  lives_widget_set_sensitive(mainw->framedraw_preview,FALSE);
  lives_widget_context_update();

  if (mainw->did_rfx_preview) {
#ifndef IS_MINGW
    com=lives_strdup_printf("%s stopsubsub \"%s\" 2>/dev/null",prefs->backend_sync,cfile->handle);
    lives_system(com,TRUE); // try to stop any in-progress preview
#else
    // get pid from backend
    FILE *rfile;
    ssize_t rlen;
    char val[16];
    int pid;
    com=lives_strdup_printf("%s get_pid_for_handle \"%s\"",prefs->backend_sync,cfile->handle);
    rfile=popen(com,"r");
    rlen=fread(val,1,16,rfile);
    pclose(rfile);
    memset(val+rlen,0,1);
    pid=atoi(val);

    lives_win32_kill_subprocesses(pid,TRUE);
#endif
    lives_free(com);

    if (cfile->start==0) {
      cfile->start=1;
      cfile->end=cfile->frames;
    }

    do_rfx_cleanup(rfx);
  }

#ifndef IS_MINGW
  com=lives_strdup_printf("%s clear_pre_files \"%s\" 2>/dev/null",prefs->backend_sync,cfile->handle);
#else
  com=lives_strdup_printf("%s clear_pre_files \"%s\" 2>NUL",prefs->backend_sync,cfile->handle);
#endif
  lives_system(com,TRUE); // clear any .pre files from before

  for (i=0; i<rfx->num_params; i++) {
    rfx->params[i].changed=FALSE;
  }

  mainw->cancelled=CANCEL_NONE;
  mainw->error=FALSE;

  // within do_effect() we check and if
  do_effect(rfx,TRUE); // actually start effect processing in the background

  lives_widget_set_sensitive(mainw->framedraw_spinbutton,TRUE);
  lives_widget_set_sensitive(mainw->framedraw_scale,TRUE);

  if (mainw->framedraw_frame>cfile->start&&!(cfile->start==0&&mainw->framedraw_frame==1))
    lives_spin_button_set_value(LIVES_SPIN_BUTTON(mainw->framedraw_spinbutton),cfile->start);
  else {
    load_rfx_preview(rfx);
  }

  mainw->did_rfx_preview=TRUE;
}