#include "gmencoder.h" int AnalizaFichero () { char linea[512]; char Tmp[512]; char dato[32]; char dato1[32]; char dato2[32]; FILE *pipe; int j; int k; char comando[512]; int cuantos; GtkWidget *Aviso; int pid; char nombre[512]; nombre[0] = 0; if (!strcmp ("", (char *) gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroEntrada)))) { sprintf (Tmp, _("File is selected as source but the file name is not fill.")); 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; } sprintf (Tmp, _("Working. Wait...")); gtk_label_set_text (GTK_LABEL(strOperacion.lblOperacionEnCurso), Tmp); gtk_widget_show (strOperacion.winOperacionEnCurso); while (gtk_events_pending()) { gtk_main_iteration (); } sprintf (comando, ANALIZAR_FICHERO, gtk_entry_get_text (GTK_ENTRY(strPrincipal.entFileFicheroEntrada))); memset (&medio_fichero, 0, sizeof(DATOS_FICHERO)); if (NULL == (pipe = mypopen (CfgGen.Path_mp, comando, "r", &pid, "/"))) { MsgError ("Error executing: [%s]", comando); } else { while (!feof (pipe)) { LeeLinea (linea, 512, pipe); while (gtk_events_pending()) { gtk_main_iteration (); } /* Relacion de aspecto */ if (NULL != AnalizaLinea (linea, dato, LINEA_ASPECTO, INI_ASPECTO, FIN_ASPECTO, SALTA_ASPECTO)) { if (dato[0] == '1' && dato[2] == '7') { strcpy (medio_fichero.Aspecto, "16:9"); medio_fichero.AspectoNum = 1.777777; } else if (dato[0] == '1' && dato[2] == '3') { strcpy (medio_fichero.Aspecto, "4:3"); medio_fichero.AspectoNum = 1.333333; } else { #ifdef DEBUG fprintf (stderr, _("The aspect ratio [%s] is not valid in line: %s\n"), dato, linea); #endif } #ifdef DEBUG fprintf (stderr, _("We have an aspect ratio of [%s] in line: %s\n"), medio_fichero.Aspecto, linea); #endif } /* Tiempo original */ else if (NULL != AnalizaLinea (linea, dato, LINEA_TAMANIO, INI_TAMANIO, FIN_TAMANIO, SALTA_TAMANIO)) { medio_fichero.TiempoOrg = atoi (dato); #ifdef DEBUG fprintf (stderr, _("We have the source time of [%d] in line: %s\n"), medio_fichero.TiempoOrg, linea); #endif } /* Bitrate original del Video */ else if (NULL != AnalizaLinea (linea, dato, LINEA_BITRATE_V, INI_BITRATE_V, FIN_BITRATE_V, SALTA_BITRATE_V)) { medio_fichero.BitrateOrgV = atoi (dato) / 1024; #ifdef DEBUG fprintf (stderr, _("We have a video bitrate of [%d] in the source in line: %s\n"), medio_fichero.BitrateOrgV, linea); #endif } /* Bitrate original del Audio */ else if (NULL != AnalizaLinea (linea, dato, LINEA_BITRATE_A, INI_BITRATE_A, FIN_BITRATE_A, SALTA_BITRATE_A)) { medio_fichero.BitrateOrgA = atoi (dato) / 1024; #ifdef DEBUG fprintf (stderr, _("We have a audio bitrate of [%d] in the source in line: %s\n"), medio_fichero.BitrateOrgA, linea); #endif } /* Frames por Segundo originales */ else if (NULL != AnalizaLinea (linea, dato, LINEA_FPS, INI_FPS, FIN_FPS, SALTA_FPS)) { medio_fichero.FPS = atof (dato); #ifdef DEBUG fprintf (stderr, _("We have [%f] FPS in the source in line: %s\n"), medio_fichero.FPS, linea); #endif } /* Ver el ancho X */ else if (NULL != AnalizaLinea (linea, dato, LINEA_X, INI_X, FIN_X, SALTA_X)) { medio_fichero.x = atoi (dato); #ifdef DEBUG fprintf (stderr, _("We have a width (x) of [%d] in line: %s\n"), medio_fichero.x, linea); #endif } /* Ver el alto Y */ else if (NULL != AnalizaLinea (linea, dato, LINEA_Y, INI_Y, FIN_Y, SALTA_Y)) { medio_fichero.y = atoi (dato); #ifdef DEBUG fprintf (stderr, _("We have a height (y) of [%d] in line: %s\n"), medio_fichero.y, linea); #endif } /* Ver si es de subtitulos */ else if (NULL != AnalizaLinea (linea, dato, LINEA_SUBTITULOS, INI_LAN_SUBTITULOS, FIN_LAN_SUBTITULOS, SALTA_LAN_SUBTITULOS)) { if (NULL != AnalizaLinea (linea, dato1, LINEA_SUBTITULOS, INI_ID_SUBTITULOS, FIN_ID_SUBTITULOS, SALTA_ID_SUBTITULOS)) { sprintf (medio_fichero.TextoSubtitulos[medio_fichero.NumSubtitulos], _("%s"), dato); medio_fichero.IdSubtitulos[medio_fichero.NumSubtitulos] = atoi (dato1); cuantos = 0; for (j = 0; j < medio_fichero.NumSubtitulos; j ++) { if (!strcmp (medio_fichero.TextoSubtitulos[j], medio_fichero.TextoSubtitulos[medio_fichero.NumSubtitulos])) { cuantos ++; } } if (cuantos) { sprintf (medio_fichero.TextoSubtitulos[medio_fichero.NumSubtitulos], _("%s - %d"), dato, cuantos + 1); } #ifdef DEBUG fprintf (stderr, _("We have the subtitle Id [%d] Text [%s] in line: %s\n"), medio_fichero.IdSubtitulos[medio_fichero.NumSubtitulos], medio_fichero.TextoSubtitulos[medio_fichero.NumSubtitulos], linea); #endif medio_fichero.NumSubtitulos ++; } else { #ifdef DEBUG1 fprintf (stderr, _("%s"), dato); #endif } } else if (NULL != AnalizaLinea (linea, nombre, LINEA_NOMBRE, INI_NOMBRE, FIN_NOMBRE, SALTA_NOMBRE)) { #ifdef DEBUG fprintf (stderr, _("We have the name of the file [%s] in line: %s\n"), nombre, linea); #endif medio_fichero.Analizado = strlen (nombre); } else { #ifdef DEBUG1 fprintf (stderr, _("%s"), dato); #endif } } mypclose (pipe); } gtk_widget_hide (strOperacion.winOperacionEnCurso); return strlen (nombre); }