#include #include #include #include #include #include #include #include "gmencoder.h" extern int NumCola; extern CFGGEN CfgGen; int ComprobacionesRippeo () { int FaltanFicheros = 0; /* Miro a ver si se especificó el fichero de salida y el de copia */ if (!strcmp ("", gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroSalidaGeneral)))) { gtk_widget_show (GTK_WIDGET(strFaltanDatos.lblFicheroSalida)); FaltanFicheros = 1; } else { gtk_widget_hide (GTK_WIDGET(strFaltanDatos.lblFicheroSalida)); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strPrincipal.chkCopiarADisco)) && !strcmp ("", gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroCopiarDisco)))) { gtk_widget_show (GTK_WIDGET(strFaltanDatos.lblFaltaCopiar)); FaltanFicheros = 1; } else { gtk_widget_hide (GTK_WIDGET(strFaltanDatos.lblFaltaCopiar)); } if (FaltanFicheros) { gtk_widget_show (GTK_WIDGET(strFaltanDatos.winFaltanDatos)); return -1; } return 0; } int CompruebaFicheros () { struct stat strStat; int SeSobreescribe = 0; if (!stat (gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroSalidaGeneral)), &strStat)) { gtk_label_set_text (GTK_LABEL(strSobreescribir.lblFicheroSalida), gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroSalidaGeneral))); gtk_widget_show (GTK_WIDGET(strSobreescribir.lblFicheroSalida)); SeSobreescribe = 1; } else { gtk_widget_hide (GTK_WIDGET(strSobreescribir.lblFicheroSalida)); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strPrincipal.chkCopiarADisco))) { if (!stat (gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroCopiarDisco)), &strStat)) { gtk_label_set_text (GTK_LABEL(strSobreescribir.lblFicheroCopia), gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroCopiarDisco))); gtk_widget_show (GTK_WIDGET(strSobreescribir.lblFicheroCopia)); SeSobreescribe = 1; } else { gtk_widget_hide (GTK_WIDGET(strSobreescribir.lblFicheroCopia)); } } else { gtk_widget_hide (GTK_WIDGET(strSobreescribir.lblFicheroCopia)); } if (SeSobreescribe) { Respuesta = NO_RESP; gtk_widget_show (GTK_WIDGET(strSobreescribir.winSobreescribir)); while (Respuesta == NO_RESP) { while (gtk_events_pending()) { gtk_main_iteration (); } usleep (10000); } gtk_widget_hide (GTK_WIDGET(strSobreescribir.winSobreescribir)); if (Respuesta == RESP_SI) { unlink (gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroSalidaGeneral))); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strPrincipal.chkCopiarADisco))) { unlink (gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroCopiarDisco))); } Respuesta = NO_RESP; return 0; } else if (Respuesta == RESP_NO) { Respuesta = NO_RESP; return -1; } } return 0; } int CompruebaFicherosTemporales (DATOS_RIPPEO *datos_rippeo) { int SacarDialogo = 0; FILE *fich; struct stat strStat; int TmpBR; int LocalizadoPasada1 = 0; int LocalizadoPasada2 = 0; int LocalizadoBr = 0; char tmp[512]; int i; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strFicheros.chkBorrarPass1), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strFicheros.chkBorrarPass2), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(strFicheros.chkBorrarBr), FALSE); if (strlen (datos_rippeo->FicheroPasada1) && !lstat (datos_rippeo->FicheroPasada1, &strStat)) { /* Se ha localizado frameno.avi */ datos_rippeo->SaltarPasada2 = 0; gtk_widget_show(strFicheros.chkBorrarPass1); SacarDialogo = 1; LocalizadoPasada1 = 1; } else { gtk_widget_hide(strFicheros.chkBorrarPass1); } if (strlen (datos_rippeo->FicheroPasada2) && !lstat (datos_rippeo->FicheroPasada2, &strStat)) { /* Se ha localizado de rippeo en dos pasadas de vídeo */ sprintf (tmp,_("Delete \"%s\" File (can be used instead the first video ripping)"), datos_rippeo->FicheroPasada2); for (i = strlen (tmp); i > -1; i --) { if (tmp[i] == '/') { break; } } gtk_button_set_label (GTK_BUTTON (strFicheros.chkBorrarPass2), &tmp[i+1]); datos_rippeo->SaltarPasada2 = 0; gtk_widget_show(strFicheros.chkBorrarPass2); SacarDialogo = 1; LocalizadoPasada2 = 1; } else { gtk_widget_hide(strFicheros.chkBorrarPass2); } if (strlen (datos_rippeo->FicheroBr) && !lstat (datos_rippeo->FicheroBr, &strStat)) { /* Se ha localizado frameno.br */ datos_rippeo->SaltarPasada1 = 0; gtk_widget_show(strFicheros.chkBorrarBr); SacarDialogo = 1; LocalizadoBr = 1; } else { gtk_widget_hide(strFicheros.chkBorrarBr); } if (SacarDialogo) { Respuesta = NO_RESP; gtk_widget_show (GTK_WIDGET(strFicheros.winFicheros)); while (Respuesta == NO_RESP) { while (gtk_events_pending()) { gtk_main_iteration (); } usleep (10000); } gtk_widget_hide (GTK_WIDGET(strFicheros.winFicheros)); if (Respuesta == RESP_OK) { Respuesta = NO_RESP; if (LocalizadoPasada1 && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(strFicheros.chkBorrarPass1))) { unlink (datos_rippeo->FicheroPasada1); } else { if (LocalizadoPasada1) { datos_rippeo->SaltarPasada1 = 1; } else { datos_rippeo->SaltarPasada1 = 0; } } if (LocalizadoPasada2 && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(strFicheros.chkBorrarPass2))) { unlink (datos_rippeo->FicheroPasada2); } else { if (LocalizadoPasada2) { datos_rippeo->SaltarPasada2 = 1; } else { datos_rippeo->SaltarPasada2 = 0; } } if (LocalizadoBr) { #ifdef DEBUG fprintf (stderr, _("Using Bitrate from file frameno.br...\n")); #endif if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(strFicheros.chkBorrarBr))) { /* Se ha localizado frameno.br y el bitrate no es automatico */ /* Leer el bitrate del fichero */ TmpBR = AnalizaBitrateFramenoBr (datos_rippeo->Path, datos_rippeo->Tamanio); if (TmpBR) { datos_rippeo->BitrateV = TmpBR; } else { MsgError ("Unable to load the bitrate from [%s]\n", datos_rippeo->FicheroBr); } } else { unlink (datos_rippeo->FicheroBr); } } return 0; } else if (Respuesta == RESP_CANCEL) { Respuesta = NO_RESP; return -1; } } return 0; } int AnalizaBitrateFramenoBr (char *Path, int TamanioCargar) { char Tmp[256]; int BitrateVideo = 0; FILE *fich; int Tamanio = 0; sprintf (Tmp, "%sframeno.br", Path); if (NULL != (fich = fopen (Tmp, "a+"))) { while (!feof (fich)) { fscanf (fich, "%d:%d\n", &Tamanio, &BitrateVideo); if (Tamanio == TamanioCargar) { #ifdef DEBUG fprintf (stderr, _("Loading bitrate from the file frameno.br [%d]\n"), BitrateVideo); #endif break; } else { BitrateVideo = 0; } } fclose (fich); } else { MsgError ("I can no open the file [%s]\n", Tmp); } return BitrateVideo; } int AnalizaBitrateFrameno (char *linea, char *Path, int Tamanio) { char Tmp[256]; int BitrateVideo = 0; FILE *fich; int TamanioGrabar = 0; if (NULL != AnalizaLinea (linea, Tmp, LINEA_650, INI_650, FIN_650, SALTA_650)) { TamanioGrabar = 1 * 650; BitrateVideo = atoi (Tmp); #ifdef DEBUG fprintf (stderr, _("New bitrate for 1 CD of [650] - [%d]\n"), BitrateVideo); #endif } if (NULL != AnalizaLinea (linea, Tmp, LINEA_700, INI_700, FIN_700, SALTA_700)) { TamanioGrabar = 1 * 700; BitrateVideo = atoi (Tmp); #ifdef DEBUG fprintf (stderr, _("New bitrate for 1 CD of [700] - [%d]\n"), BitrateVideo); #endif } if (NULL != AnalizaLinea (linea, Tmp, LINEA_800, INI_800, FIN_800, SALTA_800)) { TamanioGrabar = 1 * 800; BitrateVideo = atoi (Tmp); #ifdef DEBUG fprintf (stderr, _("New bitrate for 1 CD of [800] - [%d]\n"), BitrateVideo); #endif } if (NULL != AnalizaLinea (linea, Tmp, LINEA_2_650, INI_2_650, FIN_2_650, SALTA_2_650)) { TamanioGrabar = 2 * 650; BitrateVideo = atoi (Tmp); #ifdef DEBUG fprintf (stderr, _("New bitrate for 2 CD of [650] - [%d]\n"), BitrateVideo); #endif } if (NULL != AnalizaLinea (linea, Tmp, LINEA_2_700, INI_2_700, FIN_2_700, SALTA_2_700)) { TamanioGrabar = 2 * 700; BitrateVideo = atoi (Tmp); #ifdef DEBUG fprintf (stderr, _("New bitrate for 2 CD of [700] - [%d]\n"), BitrateVideo); #endif } if (NULL != AnalizaLinea (linea, Tmp, LINEA_2_800, INI_2_800, FIN_2_800, SALTA_2_800)) { TamanioGrabar = 2 * 800; BitrateVideo = atoi (Tmp); #ifdef DEBUG fprintf (stderr, _("New bitrate for 2 CD of [800] - [%d]\n"), BitrateVideo); #endif } if (BitrateVideo) { #ifdef DEBUG fprintf (stderr, _("Saving bitrate in the file frameno.br [%d]\n"), BitrateVideo); #endif sprintf (Tmp, "%sframeno.br", Path); if (NULL != (fich = fopen (Tmp, "a+"))) { fprintf (fich, "%d:%d\n", TamanioGrabar, BitrateVideo); fclose (fich); } else { MsgError ("I can no open the file [%s]\n", Tmp); } if (Tamanio != TamanioGrabar) BitrateVideo = 0; } return BitrateVideo; } int BuscaTantoPorCiento (char *linea, float *BarraAct) { int retorno = -1; char Tmp[64]; if (NULL != AnalizaLinea (linea, Tmp, LINEA_PORCENT, INI_PORCENT, FIN_PORCENT, SALTA_PORCENT)) { *BarraAct = (float) (atof (Tmp) / 100.0); retorno = 0; } return retorno; } int BuscaPosicion (char *linea, int *Posicion) { int retorno = -1; char Tmp[64]; if (NULL != AnalizaLinea (linea, Tmp, LINEA_POSICION, INI_POSICION, FIN_POSICION, SALTA_POSICION)) { *Posicion = atoi (Tmp); retorno = 0; } return retorno; } int BuscaMegas (char *linea, char *TextoMb) { int retorno = -1; char Tmp[64]; if (NULL != AnalizaLinea (linea, TextoMb, LINEA_MEGAS, INI_MEGAS, FIN_MEGAS, SALTA_MEGAS)) { retorno = 0; } return retorno; } int BuscaTiempo (char *linea, char *TextoTie) { char Tmp[64]; int retorno = -1; if (NULL != AnalizaLinea (linea, TextoTie, LINEA_TIEMPO, INI_TIEMPO, FIN_TIEMPO, SALTA_TIEMPO)) { retorno = 0; } return retorno; } int Rippea (DATOS_RIPPEO *datos_rippeo, int Ripeo, int NumRipeos) { int i; int j; int k; int estudiar_salida = 0; char Tmp[512]; char tmp[512]; GtkWidget *Aviso; char TextoMb[512]; char TextoTie[512]; int Tie; char TextoBarraPass[512]; char TextoBarraAct[512]; char TextoTitulo[512]; float BarraPass = 0.0; float BarraAct = 0.0; char Orden[512]; int BitrateVideo; FILE *pipe; char linea[512]; int lineas = 0; int NumPasadas; int Titulo = 0; int Tmp_int = 0; int fd_fich = 0; struct stat strStat; int pid; int cuantas_lineas = 4; int ret = 0; time_t ahora; time_t ultimo; int horas; int minutos; int segundos; time_t final; int Posicion; char ExtraTitulo[128]; /* La fase terminó todo al 100% por si acaso */ sprintf (TextoBarraAct, _("Current Pass 0 (0 %%)")); BarraAct = 0.0; BarraPass = 0.0; if (NumRipeos == 1) { sprintf (TextoBarraPass, _("Pass 0 of 0")); sprintf (TextoTitulo, _("Pass 0 of 0 [0%%] - gmencoder")); } else { sprintf (TextoBarraPass, _("%d/%d - Pass 0 of 0"), Ripeo, NumRipeos); sprintf (TextoTitulo, _("%d/%d - Pass 0 of 0 [0%%] - gmencoder"), Ripeo, NumRipeos); } sprintf (Tmp, _("0 mb")); sprintf (Tmp, _("00:00")); #ifdef DEBUG1 printf ("BarraAct: %s\n", TextoBarraAct); printf ("BarraPass: %s\n", TextoBarraPass); printf ("BarraAct: %f\n", BarraAct); printf ("BarraPass: %f\n", BarraPass); printf ("TextMb: %s\n", TextoMb); printf ("TextTie: %s\n", TextoTie); printf ("TextoTitulo: %s\n", TextoTitulo); #endif gtk_widget_set_sensitive (strProgreso.bntPause, TRUE); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), BarraAct); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), TextoBarraAct); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadas), BarraPass); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadas), TextoBarraPass); strcpy (tmp, datos_rippeo->Origen); i = -1; if (strncmp (tmp, "-dvd", 1) || strncmp (tmp, "-vcd", 1) || strncmp (tmp, "-tv", 1)) { if (tmp[strlen(tmp)-1] == '\"') tmp[strlen(tmp)-1] = 0; for (i = strlen (tmp); i > -1; i --) { if (tmp[i] == '/') { break; } } } gtk_label_set_text (GTK_LABEL(strProgreso.lblOrigen), &tmp[i+1]); strcpy (tmp, datos_rippeo->FicheroSalida); if (tmp[strlen(tmp)-1] == '\"') tmp[strlen(tmp)-1] = 0; for (i = strlen (tmp); i > -1; i --) { if (tmp[i] == '/') { break; } } gtk_label_set_text (GTK_LABEL(strProgreso.lblDestino), &tmp[i+1]); gtk_label_set_text (GTK_LABEL(strProgreso.lblTamanioFichero), TextoMb); gtk_label_set_text (GTK_LABEL(strProgreso.lblTiempoRestante), TextoTie); time (&ahora); if (ahora - ultimo > 0) { gtk_window_set_title (GTK_WINDOW (strProgreso.winProgreso), TextoTitulo); ultimo = ahora; } /* Pongo la ventana de progreso */ if (datos_rippeo->FicheroCopiarDisco[0]) { gtk_widget_show(strProgreso.chkBorrarCopia); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strProgreso.chkBorrarCopia), CfgGen.DeleteCopyFile); } else { gtk_widget_hide(strProgreso.chkBorrarCopia); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strProgreso.chkBorrarTemporal), CfgGen.DeleteTemporalFiles); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strProgreso.chkEjecutarOrden), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (strProgreso.chkPararDespues), FALSE); while (gtk_events_pending()) { gtk_main_iteration (); } memset (Tmp, 0, 512); memset (TextoMb, 0, 512); memset (TextoTie, 0, 512); memset (TextoBarraPass, 0, 512); memset (TextoBarraAct, 0, 512); if (datos_rippeo->BitrateAuto) { BitrateVideo = datos_rippeo->BitrateV; } NumPasadas = 4; for (i = 0; i < 4; i ++) { if (datos_rippeo->TipoOrden[i] == NO_ORDEN) { NumPasadas = i; break; } } if (datos_rippeo->BorrarTemporales) { #ifdef DEBUG fprintf (stderr, "Deleting temporal files [%s][%s][%s]\n", datos_rippeo->FicheroPasada1, datos_rippeo->FicheroPasada2, datos_rippeo->FicheroBr); #endif unlink (datos_rippeo->FicheroPasada1); unlink (datos_rippeo->FicheroPasada2); unlink (datos_rippeo->FicheroBr); } #ifdef DEBUG fprintf (stderr, "I have to wait until [%d].\n", datos_rippeo->Comienzo); #endif sprintf (TextoBarraAct, _("Current Pass 0 (0 %%)")); if (NumRipeos == 1) { sprintf (TextoTitulo, _("Pass 0 of 0 [0%%] - gmencoder")); sprintf (TextoBarraPass, _("Pass 0 of 0")); } else { sprintf (TextoTitulo, _("%d/%d - Pass 0 of 0 [0%%] - gmencoder"), Ripeo, NumRipeos); sprintf (TextoBarraPass, _("%d/%d - Pass 0 of 0"), Ripeo, NumRipeos); } gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), 0); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), TextoBarraAct); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadas), 0); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadas), TextoBarraPass); gtk_window_set_title (GTK_WINDOW (strProgreso.winProgreso), TextoTitulo); gtk_label_set_text (GTK_LABEL(strProgreso.lblTamanioFichero), "0 mb"); gtk_label_set_text (GTK_LABEL(strProgreso.lblDescripcion), " "); gtk_label_set_text (GTK_LABEL(strProgreso.lblOrden), " "); gtk_label_set_text (GTK_LABEL(strProgreso.lblTiempoRestante), "00:00"); time (&ultimo); if (datos_rippeo->Comienzo) { gtk_widget_set_sensitive (strProgreso.bntPause, FALSE); time (&ahora); while (ahora < datos_rippeo->Comienzo && !SalirRippeo) { horas = (datos_rippeo->Comienzo - ahora) / (3600); minutos = ((datos_rippeo->Comienzo - ahora) % (3600) / 60); segundos = ((datos_rippeo->Comienzo - ahora) % (3600) % 60); if (NumRipeos == 1) sprintf (TextoTitulo, _("Waiting for the time to start [%d:%02d:%02d] - gmencoder"), horas, minutos, segundos); else sprintf (TextoTitulo, _("%d/%d - Waiting for the time to start [%d:%02d:%02d] - gmencoder"), Ripeo, NumRipeos, horas, minutos, segundos); if (ahora - ultimo > 0) { gtk_window_set_title (GTK_WINDOW (strProgreso.winProgreso), TextoTitulo); ultimo = ahora; } sprintf (TextoTitulo, _("Waiting for the time to start [%02d:%02d:%02d]\n \n"), horas, minutos, segundos); gtk_label_set_text (GTK_LABEL(strProgreso.lblOrden), TextoTitulo); while (gtk_events_pending()) { gtk_main_iteration (); } usleep (100000); time (&ahora); } if (SalirRippeo) return -1; datos_rippeo->Comienzo = ahora; final = datos_rippeo->Comienzo + datos_rippeo->Tiempo + 1; } for (i = 0; i < 4; i ++) { switch (datos_rippeo->TipoOrden[i]) { case ORDEN_FRAMENO: estudiar_salida = 1; strcpy (Orden, datos_rippeo->Orden[i]); break; case ORDEN: estudiar_salida = 0; strcpy (Orden, datos_rippeo->Orden[i]); break; case ORDEN_VIDEO: estudiar_salida = 0; if (datos_rippeo->BitrateAuto) { if (BitrateVideo < 1) { MsgError ("Unable to caculate de video BitRate. is it a source with 0 lenth?"); sprintf (tmp, _("Unable to calculate the video bit rate.\nCould be a movie with cero length.\nMust be possible to calculate it if you use a standar CD size.")); Aviso = gnome_message_box_new (tmp, GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL, NULL); gtk_window_set_transient_for (GTK_WINDOW (Aviso), GTK_WINDOW (strPrincipal.winPrincipal)); gtk_window_set_position (GTK_WINDOW (Aviso), GTK_WIN_POS_CENTER); gnome_dialog_run (GNOME_DIALOG (Aviso)); return -1; } //BitrateVideo = CorrigeBitrateVideo (BitrateVideo); sprintf (Orden, datos_rippeo->Orden[i], BitrateVideo); } else { strcpy (Orden, datos_rippeo->Orden[i]); } break; default: SalirRippeo = 1; break; } if (SalirRippeo) { break; } gtk_label_set_text (GTK_LABEL(strProgreso.lblDescripcion), datos_rippeo->Descripcion[i]); gtk_label_set_text (GTK_LABEL(strProgreso.lblOrden), Orden); #ifdef DEBUG fprintf (stderr, _("Executing: [%s]\n"), Orden); #endif if (NULL == (pipe = mypopen (CfgGen.Path_mp, Orden, "r", &pid, datos_rippeo->Path))) { MsgError ("Error executing: [%s]", Orden); } else { #ifdef DEBUG fprintf (stderr, _("PID: %d\n"), pid); #endif lineas = 0; sprintf (ExtraTitulo, " "); while (!feof (pipe)) { if (datos_rippeo->Tiempo && ahora > final) { #ifdef DEBUG fprintf (stderr, _("The time has finished.... exiting [%d]\n"), pid); #endif SalirRippeo = 1; break; } if (SalirRippeo) { #ifdef DEBUG fprintf (stderr, _("Cancel was pressed.... exiting [%d]\n"), pid); #endif kill (pid, SIGTERM); mypclose (pipe); ret = -1; break; } if (Pausa == PAUSA) { #ifdef DEBUG fprintf (stderr, _("Pause was pressed.... SIGSTOP [%d]\n"), pid); #endif kill (pid, SIGSTOP); while (1) { time (&ahora); if (ahora % 2) { gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), _("Paused")); gtk_window_set_title (GTK_WINDOW (strProgreso.winProgreso), " "); } else { gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), " "); gtk_window_set_title (GTK_WINDOW (strProgreso.winProgreso), _("Paused - gmencoder")); } while (gtk_events_pending() ) { gtk_main_iteration (); } usleep (100000); if (SalirRippeo || Pausa != PAUSA) { #ifdef DEBUG fprintf (stderr, _("Play or exit was pressed.... SIGCONT [%d]\n"), pid); #endif kill (pid, SIGCONT); break; } } if (SalirRippeo) { continue; } } while (gtk_events_pending()) { gtk_main_iteration (); } LeeLinea (linea, 512, pipe); /* Ver si hay que buscar el bitrate */ if (datos_rippeo->BitrateAuto && datos_rippeo->TipoOrden[i] == ORDEN_FRAMENO) { if (0 < (Tmp_int = AnalizaBitrateFrameno (linea, datos_rippeo->Path, datos_rippeo->Tamanio))) { BitrateVideo = Tmp_int; } } /* Analizar linea */ time (&ahora); if (ahora - ultimo > 0) { if (datos_rippeo->Tiempo) { BarraAct = (float) (((float) (ahora - datos_rippeo->Comienzo)) / ((float) datos_rippeo->Tiempo)); BarraPass = ((1.0 / (float) NumPasadas) * (float) i) + (BarraAct / (float) NumPasadas); if (final - ahora < 0) sprintf (TextoTie, "0"); else sprintf (TextoTie, "%d", final - ahora); sprintf (TextoMb, "??"); if (!BuscaPosicion (linea, &Posicion)) { if (Posicion < ahora - datos_rippeo->Comienzo) { sprintf (ExtraTitulo, _(" - No Real Time Encoding")); } } } else { if (!BuscaTantoPorCiento (linea, &BarraAct)) { BarraPass = ((1.0 / (float) NumPasadas) * (float) i) + (BarraAct / (float) NumPasadas); } BuscaMegas (linea, TextoMb); BuscaTiempo (linea, TextoTie); } sprintf (TextoBarraAct, _("Current Pass %d (%d %%)"), i + 1, (int)(BarraAct*100.0)); if (NumRipeos == 1) { sprintf (TextoTitulo, _("Pass %d of %d [%d%%] - gmencoder %s"), i + 1, NumPasadas, (int)(BarraAct*100.0), ExtraTitulo); sprintf (TextoBarraPass, _("Pass %d of %d"), i+1, NumPasadas); } else { sprintf (TextoTitulo, _("%d/%d - Pass %d of %d [%d%%] - gmencoder %s"), Ripeo, NumRipeos, i + 1, NumPasadas, (int)(BarraAct*100.0), ExtraTitulo); sprintf (TextoBarraPass, _("%d/%d - Pass %d of %d"), Ripeo, NumRipeos, i+1, NumPasadas); } gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), BarraAct); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), TextoBarraAct); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadas), BarraPass); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadas), TextoBarraPass); gtk_window_set_title (GTK_WINDOW (strProgreso.winProgreso), TextoTitulo); sprintf (Tmp, _("%s mb"), TextoMb); gtk_label_set_text (GTK_LABEL(strProgreso.lblTamanioFichero), Tmp); Tie = atoi (TextoTie); if (Tie > 1440) { sprintf (Tmp, _("%dd %02d:%%02d "), Tie / 1440, Tie % 1440 / 60, Tie % 1440 % 60); } else { sprintf (Tmp, _("%02d:%02d "), Tie / 60, Tie % 60); } gtk_label_set_text (GTK_LABEL(strProgreso.lblTiempoRestante), Tmp); #ifdef DEBUG1 printf ("BarraAct: %s\n", TextoBarraAct); printf ("BarraPass: %s\n", TextoBarraPass); printf ("BarraAct: %f\n", BarraAct); printf ("BarraPass: %f\n", BarraPass); printf ("TextoTitulo: %s\n", TextoTitulo); printf ("TextMb: %s\n", TextoMb); printf ("TextTie: %s\n", TextoTie); #endif ultimo = ahora; } /* Actualizar datos si han cambiado */ while (gtk_events_pending()) { gtk_main_iteration (); } } /* La fase terminó todo al 100% por si acaso */ sprintf (TextoBarraAct, _("Current Pass %d (100 %%)"), i + 1); BarraAct = 1.0; BarraPass = ((1.0 / (float) NumPasadas) * (float) i+1); if (NumRipeos == 1) { sprintf (TextoTitulo, _("Pass %d of %d [100%%] - gmencoder"), i + 1, NumPasadas); sprintf (TextoBarraPass, _("Pass %d of %d"), i+1, NumPasadas); } else { sprintf (TextoTitulo, _("%d/%d - Pass %d of %d [100%%] - gmencoder"), Ripeo, NumRipeos, i + 1, NumPasadas); sprintf (TextoBarraPass, _("%d/%d - Pass %d of %d"), Ripeo, NumRipeos, i + 1, NumPasadas); } #ifdef DEBUG1 printf ("Numpasadas [%d]. i[%d] [%f]\n", NumPasadas, i, ((1.0 / (float) NumPasadas) * (float) i+1)); printf ("BarraAct: %s\n", TextoBarraAct); printf ("BarraPass: %s\n", TextoBarraPass); printf ("BarraAct: %f\n", BarraAct); printf ("BarraPass: %f\n", BarraPass); printf ("TextMb: %s\n", TextoMb); printf ("TextTie: %s\n", TextoTie); printf ("TextoTitulo: %s\n", TextoTitulo); #endif gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), BarraAct); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadaEnCurso), TextoBarraAct); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (strProgreso.pbPasadas), BarraPass); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (strProgreso.pbPasadas), TextoBarraPass); gtk_label_set_text (GTK_LABEL(strProgreso.lblTamanioFichero), TextoMb); gtk_label_set_text (GTK_LABEL(strProgreso.lblTiempoRestante), TextoTie); gtk_window_set_title (GTK_WINDOW (strProgreso.winProgreso), TextoTitulo); while (gtk_events_pending()) { gtk_main_iteration (); } if (SalirRippeo) { break; } mypclose (pipe); } if (SalirRippeo) { break; } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strProgreso.chkPararDespues))) { ret = -1; break; } } if (SalirRippeo || !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strProgreso.chkPararDespues))) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strProgreso.chkBorrarTemporal))) { sprintf (Orden, "%s", datos_rippeo->FicheroPasada1); if (unlink (Orden)) { MsgError ("Unable to delete the file 1 [%s]\n", Orden); } sprintf (Orden, "%s", datos_rippeo->FicheroBr); if (unlink (Orden)) { MsgError ("Unable to delete the file 2 [%s]\n", Orden); } sprintf (Orden, "%s", datos_rippeo->FicheroPasada2); if (unlink (Orden)) { MsgError ("Unable to delete the file 3 [%s]\n", Orden); } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strProgreso.chkBorrarCopia)) && GTK_WIDGET_VISIBLE (strProgreso.chkBorrarCopia) && datos_rippeo->FicheroCopiarDisco[0] && datos_rippeo->FicheroCopiarDisco[0] != ' '); { sprintf (Orden, "%s", datos_rippeo->FicheroCopiarDisco); if (unlink (Orden)) { MsgError ("Unable to delete the file 4 [%s]\n", Orden); } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(strProgreso.chkEjecutarOrden)) && NumCola == 1) { sprintf (Orden, "%s", gtk_entry_get_text (GTK_ENTRY(strProgreso.entOrden))); system (Orden); } } return ret; }