diff options
Diffstat (limited to 'src/input')
43 files changed, 2579 insertions, 2579 deletions
diff --git a/src/input/http_helper.c b/src/input/http_helper.c index 70e9fea99..9b3560b22 100644 --- a/src/input/http_helper.c +++ b/src/input/http_helper.c @@ -65,11 +65,11 @@ int _x_parse_url (char *url, char **proto, char** host, int *port, *password = NULL; *uri = NULL; - /* proto */ + /* proto */ start = strstr(url, "://"); if (!start || (start == url)) goto error; - + end = start + strlen(start) - 1; *proto = strndup(url, start - url); @@ -85,10 +85,10 @@ int _x_parse_url (char *url, char **proto, char** host, int *port, semicolon = strchr(start, ';'); if (semicolon && (!slash || (semicolon < slash))) slash = semicolon; - + if (at && slash && (at > slash)) at = NULL; - + if (at) { authcolon = strchr(start, ':'); if(authcolon && authcolon < at) { @@ -179,7 +179,7 @@ int _x_parse_url (char *url, char **proto, char** host, int *port, escapechars++; it++; } - + if ( escapechars == 0 ) *uri = strdup(start); else { @@ -204,9 +204,9 @@ int _x_parse_url (char *url, char **proto, char** host, int *port, } else { *uri = strdup("/"); } - + return 1; - + error: if (*proto) { free (*proto); @@ -231,7 +231,7 @@ error: free (*uri); *uri = NULL; } - return 0; + return 0; } @@ -244,7 +244,7 @@ static int check_url(char *url, int ok) { char *proto, *host, *user, *password, *uri; int port; int res; - + printf("--------------------------------\n"); printf("url=%s\n", url); res = _x_parse_url (url, @@ -287,7 +287,7 @@ static int check_paste(const char *base, const char *url, const char *ok) { int main(int argc, char** argv) { char *proto, host, port, user, password, uri; int res = 0; - + res += check_url("http://www.toto.com/test1.asx", 1); res += check_url("http://www.toto.com:8080/test2.asx", 1); res += check_url("http://titi:pass@www.toto.com:8080/test3.asx", 1); diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 61ea118c2..0b7f854e2 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * - * Compact Disc Digital Audio (CDDA) Input Plugin + * Compact Disc Digital Audio (CDDA) Input Plugin * by Mike Melanson (melanson@pcisys.net) */ @@ -140,7 +140,7 @@ typedef struct { int enabled; char *server; int port; - + char *cdiscid; char *disc_title; char *disc_year; @@ -188,7 +188,7 @@ typedef struct { char *cdda_device; int cddb_error; - + cdda_input_plugin_t *ip; int show_hidden_files; @@ -196,7 +196,7 @@ typedef struct { int mrls_allocated_entries; xine_mrl_t **mrls; - + char *autoplaylist[MAX_TRACKS]; } cdda_input_class_t; @@ -328,54 +328,54 @@ struct SRB_ExecSCSICmd #ifdef LOG static void print_cdrom_toc(cdrom_toc *toc) { - + int i; int time1; int time2; int timediff; - + printf("\ntoc:\n"); printf("\tfirst track = %d\n", toc->first_track); printf("\tlast track = %d\n", toc->last_track); printf("\ttotal tracks = %d\n", toc->total_tracks); printf("\ntoc entries:\n"); - - + + printf("leadout track: Control: %d MSF: %02d:%02d:%04d, first frame = %d\n", toc->leadout_track.track_mode, toc->leadout_track.first_frame_minute, toc->leadout_track.first_frame_second, toc->leadout_track.first_frame_frame, toc->leadout_track.first_frame); - + /* fetch each toc entry */ - if (toc->first_track > 0) { - for (i = toc->first_track; i <= toc->last_track; i++) { + if (toc->first_track > 0) { + for (i = toc->first_track; i <= toc->last_track; i++) { printf("\ttrack mode = %d", toc->toc_entries[i-1].track_mode); - printf("\ttrack %d, audio, MSF: %02d:%02d:%02d, first frame = %d\n", - i, + printf("\ttrack %d, audio, MSF: %02d:%02d:%02d, first frame = %d\n", + i, toc->toc_entries[i-1].first_frame_minute, toc->toc_entries[i-1].first_frame_second, toc->toc_entries[i-1].first_frame_frame, toc->toc_entries[i-1].first_frame); - - time1 = ((toc->toc_entries[i-1].first_frame_minute * 60) + + + time1 = ((toc->toc_entries[i-1].first_frame_minute * 60) + toc->toc_entries[i-1].first_frame_second); - + if (i == toc->last_track) { time2 = ((toc->leadout_track.first_frame_minute * 60) + toc->leadout_track.first_frame_second); } else { - time2 = ((toc->toc_entries[i].first_frame_minute * 60) + + time2 = ((toc->toc_entries[i].first_frame_minute * 60) + toc->toc_entries[i].first_frame_second); } - + timediff = time2 - time1; - + printf("\t time: %02d:%02d\n", timediff/60, timediff%60); } - } + } } #endif @@ -429,7 +429,7 @@ static int read_cdrom_toc(int fd, cdrom_toc *toc) { toc->ignore_last_track = 0; } toc->total_tracks = toc->last_track - toc->first_track + 1; - + /* allocate space for the toc entries */ toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry)); if (!toc->toc_entries) { @@ -800,7 +800,7 @@ static int read_cdrom_frames(cdda_input_plugin_t *this_gen, int frame, int num_f return -1; } #endif - + data += CD_RAW_FRAME_SIZE; frame++; num_frames--; @@ -817,44 +817,44 @@ static int read_cdrom_toc(cdda_input_plugin_t *this_gen, cdrom_toc *toc) { /* This is for ASPI which obviously isn't supported! */ lprintf("Windows ASPI support is not complete yet!\n"); return -1; - + } else { DWORD dwBytesReturned; CDROM_TOC cdrom_toc; int i; - + if( DeviceIoControl( this_gen->h_device_handle, IOCTL_CDROM_READ_TOC, NULL, 0, &cdrom_toc, sizeof(CDROM_TOC), &dwBytesReturned, NULL ) == 0 ) { #ifdef LOG - DWORD dw; + DWORD dw; printf( "input_cdda: could not read TOCHDR\n" ); dw = GetLastError(); - printf("GetLastError returned %u\n", dw); + printf("GetLastError returned %u\n", dw); #endif return -1; } - + toc->first_track = cdrom_toc.FirstTrack; toc->last_track = cdrom_toc.LastTrack; toc->total_tracks = toc->last_track - toc->first_track + 1; - + /* allocate space for the toc entries */ toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry)); if (!toc->toc_entries) { perror("calloc"); return -1; } - + /* fetch each toc entry */ for (i = toc->first_track; i <= toc->last_track; i++) { - + toc->toc_entries[i-1].track_mode = (cdrom_toc.TrackData[i-1].Control & 0x04) ? 1 : 0; toc->toc_entries[i-1].first_frame_minute = cdrom_toc.TrackData[i-1].Address[1]; toc->toc_entries[i-1].first_frame_second = cdrom_toc.TrackData[i-1].Address[2]; @@ -876,7 +876,7 @@ static int read_cdrom_toc(cdda_input_plugin_t *this_gen, cdrom_toc *toc) { (toc->leadout_track.first_frame_minute * CD_SECONDS_PER_MINUTE * CD_FRAMES_PER_SECOND) + (toc->leadout_track.first_frame_second * CD_FRAMES_PER_SECOND) + toc->leadout_track.first_frame_frame; - } + } return 0; } @@ -893,37 +893,37 @@ static int read_cdrom_frames(cdda_input_plugin_t *this_gen, int frame, int num_f /* This is for ASPI which obviously isn't supported! */ lprintf("Windows ASPI support is not complete yet!\n"); return -1; - + } else { memset(data, 0, CD_RAW_FRAME_SIZE * num_frames); - + while( num_frames ) { - + #ifdef LOG /*printf("\t Raw read frame %d\n", frame);*/ #endif raw_read_info.DiskOffset.QuadPart = frame * CD_SECTOR_SIZE; raw_read_info.SectorCount = 1; raw_read_info.TrackMode = CDDA; - + /* read a frame */ if( DeviceIoControl( this_gen->h_device_handle, IOCTL_CDROM_RAW_READ, - &raw_read_info, sizeof(RAW_READ_INFO), data, + &raw_read_info, sizeof(RAW_READ_INFO), data, CD_RAW_FRAME_SIZE, &dwBytesReturned, NULL ) == 0 ) { #ifdef LOG - DWORD dw; + DWORD dw; printf( "input_cdda: could not read frame\n" ); dw = GetLastError(); - printf("GetLastError returned %u\n", dw); + printf("GetLastError returned %u\n", dw); #endif return -1; } - + data += CD_RAW_FRAME_SIZE; frame++; num_frames--; @@ -1029,7 +1029,7 @@ network_command( xine_stream_t *stream, int socket, void *data_buf, const char * if( n ) { if( !data_buf ) { if (stream) - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: protocol error, data returned but no buffer provided.\n"); return -1; } @@ -1154,12 +1154,12 @@ static int network_read_cdrom_frames(xine_stream_t *stream, int fd, int first_fr */ static void cdda_device_cb(void *data, xine_cfg_entry_t *cfg) { cdda_input_class_t *class = (cdda_input_class_t *) data; - + class->cdda_device = cfg->str_value; } static void enable_cddb_changed_cb(void *data, xine_cfg_entry_t *cfg) { cdda_input_class_t *class = (cdda_input_class_t *) data; - + if(class->ip) { cdda_input_plugin_t *this = class->ip; @@ -1170,7 +1170,7 @@ static void enable_cddb_changed_cb(void *data, xine_cfg_entry_t *cfg) { } static void server_changed_cb(void *data, xine_cfg_entry_t *cfg) { cdda_input_class_t *class = (cdda_input_class_t *) data; - + if(class->ip) { cdda_input_plugin_t *this = class->ip; @@ -1181,7 +1181,7 @@ static void server_changed_cb(void *data, xine_cfg_entry_t *cfg) { } static void port_changed_cb(void *data, xine_cfg_entry_t *cfg) { cdda_input_class_t *class = (cdda_input_class_t *) data; - + if(class->ip) { cdda_input_plugin_t *this = class->ip; @@ -1193,7 +1193,7 @@ static void port_changed_cb(void *data, xine_cfg_entry_t *cfg) { #ifdef CDROM_SELECT_SPEED static void speed_changed_cb(void *data, xine_cfg_entry_t *cfg) { cdda_input_class_t *class = (cdda_input_class_t *) data; - + if (class->ip) { cdda_input_plugin_t *this = class->ip; if (this->fd != -1) @@ -1210,21 +1210,21 @@ static void speed_changed_cb(void *data, xine_cfg_entry_t *cfg) { static int _cdda_is_cd_changed(cdda_input_plugin_t *this) { #ifdef CDROM_MEDIA_CHANGED int err, cd_changed=0; - + if(this == NULL || this->fd < 0) return -1; - + if((err = ioctl(this->fd, CDROM_MEDIA_CHANGED, cd_changed)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: ioctl(CDROM_MEDIA_CHANGED) failed: %s.\n", strerror(errno)); return -1; } - + switch(err) { case 1: return 1; break; - + default: return 0; break; @@ -1234,7 +1234,7 @@ static int _cdda_is_cd_changed(cdda_input_plugin_t *this) { #else /* * At least on solaris, CDROM_MEDIA_CHANGED does not exist. Just return an - * error for now + * error for now */ return -1; #endif @@ -1244,18 +1244,18 @@ static int _cdda_is_cd_changed(cdda_input_plugin_t *this) { * create a directory, in safe mode */ static void _cdda_mkdir_safe(xine_t *xine, char *path) { - + if(path == NULL) return; - + #ifndef WIN32 { struct stat pstat; - + if((stat(path, &pstat)) < 0) { /* file or directory no exist, create it */ if(mkdir(path, 0755) < 0) { - xprintf(xine, XINE_VERBOSITY_DEBUG, + xprintf(xine, XINE_VERBOSITY_DEBUG, "input_cdda: mkdir(%s) failed: %s.\n", path, strerror(errno)); return; } @@ -1272,10 +1272,10 @@ static void _cdda_mkdir_safe(xine_t *xine, char *path) { HANDLE hList; TCHAR szDir[MAX_PATH+3]; WIN32_FIND_DATA FileData; - + // Get the proper directory path sprintf(szDir, "%s\\*", path); - + // Get the first file hList = FindFirstFile(szDir, &FileData); if (hList == INVALID_HANDLE_VALUE) @@ -1283,9 +1283,9 @@ static void _cdda_mkdir_safe(xine_t *xine, char *path) { if(_mkdir(path) != 0) { xprintf(xine, XINE_VERBOSITY_DEBUG, "input_cdda: mkdir(%s) failed.\n", path); return; - } + } } - + FindClose(hList); } #endif /* WIN32 */ @@ -1331,12 +1331,12 @@ static int _cdda_cddb_socket_read(cdda_input_plugin_t *this, char *str, int size * Send a command to socket */ static int _cdda_cddb_send_command(cdda_input_plugin_t *this, char *cmd) { - + if((this == NULL) || (this->cddb.fd < 0) || (cmd == NULL)) return -1; xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, ">>> %s\n", cmd); - + return (int)_x_io_tcp_write(this->stream, this->cddb.fd, cmd, strlen(cmd)); } @@ -1406,7 +1406,7 @@ static int _cdda_cddb_handle_code(char *buf) { break; } } - + return err; } @@ -1487,22 +1487,22 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { if(this == NULL) return 0; - + const size_t cdir_size = strlen(xdg_cache_home) + sizeof("/"PACKAGE"/cddb") + 10 + 1; char *const cdir = alloca(cdir_size); sprintf(cdir, "%s/" PACKAGE "/cddb", xdg_cache_home); if((dir = opendir(cdir)) != NULL) { struct dirent *pdir; - + while((pdir = readdir(dir)) != NULL) { char discid[9]; - + snprintf(discid, sizeof(discid), "%08" PRIx32, this->cddb.disc_id); - + if(!strcasecmp(pdir->d_name, discid)) { FILE *fd; - + snprintf(cdir + cdir_size - 12, 10, "/%s", discid); if((fd = fopen(cdir, "r")) == NULL) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, @@ -1513,7 +1513,7 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { else { char buffer[2048], *ln; char *dtitle = NULL; - + while ((ln = fgets(buffer, sizeof (buffer) - 1, fd)) != NULL) { int length = strlen (buffer); @@ -1525,7 +1525,7 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { fclose(fd); free(dtitle); } - + closedir(dir); return 1; } @@ -1534,7 +1534,7 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { "input_cdda: cached entry for disc ID %08" PRIx32 " not found.\n", this->cddb.disc_id); closedir(dir); } - + return 0; } @@ -1549,7 +1549,7 @@ static void _cdda_save_cached_cddb_infos(cdda_input_plugin_t *this, char *fileco if((this == NULL) || (filecontent == NULL)) return; - + /* the filename is always 8 characters */ cfile = alloca(strlen(xdg_cache_home) + sizeof("/"PACKAGE"/cddb") + 9); strcpy(cfile, xdg_cache_home); @@ -1557,9 +1557,9 @@ static void _cdda_save_cached_cddb_infos(cdda_input_plugin_t *this, char *fileco /* Ensure the cache directory exists */ _cdda_mkdir_recursive_safe(this->stream->xine, cfile); - + sprintf(cfile, "%s/%08" PRIx32, cfile, this->cddb.disc_id); - + if((fd = fopen(cfile, "w")) == NULL) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: fopen(%s) failed: %s.\n", cfile, strerror(errno)); @@ -1569,7 +1569,7 @@ static void _cdda_save_cached_cddb_infos(cdda_input_plugin_t *this, char *fileco fprintf(fd, "%s", filecontent); fclose(fd); } - + } /* @@ -1597,7 +1597,7 @@ static int _cdda_cddb_socket_open(cdda_input_plugin_t *this) { * Close the socket */ static void _cdda_cddb_socket_close(cdda_input_plugin_t *this) { - + if((this == NULL) || (this->cddb.fd < 0)) return; @@ -1617,7 +1617,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { if(this == NULL) { return 0; } - + if(_cdda_load_cached_cddb_infos(this)) { this->cddb.have_cddb_info = 1; return 1; @@ -1706,7 +1706,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: error while sending cddb query command.\n"); _cdda_cddb_socket_close(this); - return 0; + return 0; } memset(&buffer, 0, sizeof(buffer)); @@ -1731,7 +1731,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { i++; } } - + if ((err == 210) || (err == 211)) { memset(&buffer, 0, sizeof(buffer)); err = _cdda_cddb_socket_read(this, buffer, sizeof(buffer) - 1); @@ -1762,7 +1762,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { return 0; } } - } + } /* Send read command */ memset(&buffer, 0, sizeof(buffer)); snprintf(buffer, sizeof(buffer), "cddb read %s %s\n", this->cddb.disc_category, this->cddb.cdiscid); @@ -1781,7 +1781,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { _cdda_cddb_socket_close(this); return 0; } - + this->cddb.have_cddb_info = 1; memset(&buffercache, 0, sizeof(buffercache)); @@ -1795,7 +1795,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { _cdda_parse_cddb_info (this, buffer, &dtitle); } free(dtitle); - + /* Save cddb info and close socket */ _cdda_save_cached_cddb_infos(this, buffercache); _cdda_cddb_socket_close(this); @@ -1811,7 +1811,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { */ static unsigned int _cdda_cddb_sum(int n) { unsigned int ret = 0; - + while(n > 0) { ret += (n % 10); n /= 10; @@ -1820,15 +1820,15 @@ static unsigned int _cdda_cddb_sum(int n) { } static uint32_t _cdda_calc_cddb_id(cdda_input_plugin_t *this) { int i, tsum = 0; - + if(this == NULL || (this->cddb.num_tracks <= 0)) return 0; - + for(i = 0; i < this->cddb.num_tracks; i++) tsum += _cdda_cddb_sum((this->cddb.track[i].start / CD_FRAMES_PER_SECOND)); - + return ((tsum % 0xff) << 24 - | (this->cddb.disc_length - (this->cddb.track[0].start / CD_FRAMES_PER_SECOND)) << 8 + | (this->cddb.disc_length - (this->cddb.track[0].start / CD_FRAMES_PER_SECOND)) << 8 | this->cddb.num_tracks); } @@ -1904,7 +1904,7 @@ static void _cdda_free_cddb_info(cdda_input_plugin_t *this) { free(this->cddb.disc_artist); free(this->cddb.disc_category); free(this->cddb.disc_year); - + } } /* @@ -1917,7 +1917,7 @@ static int cdda_open(cdda_input_plugin_t *this_gen, int fd = -1; if ( !cdda_device ) return -1; - + *fdd = -1; if (this_gen) @@ -1932,7 +1932,7 @@ static int cdda_open(cdda_input_plugin_t *this_gen, if (this_gen) this_gen->fd = fd; - + #ifdef CDROM_SELECT_SPEED if (this_gen->stream) { int speed; @@ -1962,17 +1962,17 @@ static int cdda_open(cdda_input_plugin_t *this_gen, else return -1; - /* We are going to assume that we are opening a + /* We are going to assume that we are opening a * device and not a file! */ if( WIN_NT ) { char psz_win32_drive[7]; - + lprintf( "using winNT/2K/XP ioctl layer" ); - + sprintf( psz_win32_drive, "\\\\.\\%c:", cdda_device[0] ); - + this_gen->h_device_handle = CreateFile( psz_win32_drive, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, @@ -1988,7 +1988,7 @@ static int cdda_open(cdda_input_plugin_t *this_gen, DWORD dwSupportInfo; int i, j, i_hostadapters; char c_drive = cdda_device[0]; - + hASPI = LoadLibrary( "wnaspi32.dll" ); if( hASPI != NULL ) { @@ -1997,80 +1997,80 @@ static int cdda_open(cdda_input_plugin_t *this_gen, lpSendCommand = GetProcAddress( hASPI, "SendASPI32Command" ); } - + if( hASPI == NULL || lpGetSupport == NULL || lpSendCommand == NULL ) { lprintf( "unable to load aspi or get aspi function pointers" ); - + if( hASPI ) FreeLibrary( hASPI ); return -1; } - + /* ASPI support seems to be there */ - + dwSupportInfo = lpGetSupport(); - + if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) { lprintf( "no host adapters found (aspi)" ); FreeLibrary( hASPI ); return -1; } - + if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) { lprintf( "unable to initalize aspi layer" ); - + FreeLibrary( hASPI ); return -1; } - + i_hostadapters = LOBYTE( LOWORD( dwSupportInfo ) ); if( i_hostadapters == 0 ) { FreeLibrary( hASPI ); return -1; } - + c_drive = c_drive > 'Z' ? c_drive - 'a' : c_drive - 'A'; - + for( i = 0; i < i_hostadapters; i++ ) { for( j = 0; j < 15; j++ ) { struct SRB_GetDiskInfo srbDiskInfo; - + srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO; srbDiskInfo.SRB_HaId = i; srbDiskInfo.SRB_Flags = 0; srbDiskInfo.SRB_Hdr_Rsvd = 0; srbDiskInfo.SRB_Target = j; srbDiskInfo.SRB_Lun = 0; - + lpSendCommand( (void*) &srbDiskInfo ); - + if( (srbDiskInfo.SRB_Status == SS_COMP) && (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) ) { /* Make sure this is a cdrom device */ struct SRB_GDEVBlock srbGDEVBlock; - + memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) ); srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE; srbGDEVBlock.SRB_HaId = i; srbGDEVBlock.SRB_Target = j; - + lpSendCommand( (void*) &srbGDEVBlock ); - + if( ( srbGDEVBlock.SRB_Status == SS_COMP ) && ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) ) { this_gen->i_sid = MAKEWORD( i, j ); this_gen->hASPI = (long)hASPI; this_gen->lpSendCommand = lpSendCommand; - + lprintf( "using aspi layer" ); - + return 0; } else @@ -2082,12 +2082,12 @@ static int cdda_open(cdda_input_plugin_t *this_gen, } } } - + FreeLibrary( hASPI ); - + lprintf( "unable to get haid and target (aspi)" ); } - + #endif /* WIN32 */ return -1; @@ -2158,9 +2158,9 @@ static off_t cdda_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { this->cache_last = this->current_frame + CACHED_FRAMES - 1; if( this->cache_last > this->last_frame ) this->cache_last = this->last_frame; - -#ifndef WIN32 - if ( this->fd != -1 ) + +#ifndef WIN32 + if ( this->fd != -1 ) #else if ( this->h_device_handle ) #endif /* WIN32 */ @@ -2176,7 +2176,7 @@ static off_t cdda_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { if( err < 0 ) return 0; - + memcpy(buf, this->cache[this->current_frame-this->cache_first], CD_RAW_FRAME_SIZE); this->current_frame++; @@ -2274,7 +2274,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { int fd = -1; char *cdda_device; int err = -1; - + lprintf("cdda_plugin_open\n"); /* get the CD TOC */ @@ -2285,7 +2285,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { else cdda_device = class->cdda_device; -#ifndef WIN32 +#ifndef WIN32 if( strchr(cdda_device,':') ) { fd = network_connect(this->stream, cdda_device); if( fd != -1 ) { @@ -2303,7 +2303,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { return 0; } -#ifndef WIN32 +#ifndef WIN32 err = read_cdrom_toc(this->fd, toc); #else err = read_cdrom_toc(this, toc); @@ -2315,18 +2315,18 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { } - - if ( (err < 0) || (toc->first_track > (this->track + 1)) || + + if ( (err < 0) || (toc->first_track > (this->track + 1)) || (toc->last_track < (this->track + 1))) { cdda_close(this); - + free_cdrom_toc(toc); return 0; } /* set up the frame boundaries for this particular track */ - this->first_frame = this->current_frame = + this->first_frame = this->current_frame = toc->toc_entries[this->track].first_frame; if (this->track + 1 == toc->last_track) this->last_frame = toc->leadout_track.first_frame - 1; @@ -2337,8 +2337,8 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { this->cache_first = this->cache_last = -1; /* get the Musicbrainz CDIndex */ - _cdda_cdindex (this, toc); - + _cdda_cdindex (this, toc); + /* * CDDB */ @@ -2352,23 +2352,23 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { this->cddb.track = (trackinfo_t *) calloc(this->cddb.num_tracks, sizeof(trackinfo_t)); for(t = 0; t < this->cddb.num_tracks; t++) { - int length = (toc->toc_entries[t].first_frame_minute * CD_SECONDS_PER_MINUTE + + int length = (toc->toc_entries[t].first_frame_minute * CD_SECONDS_PER_MINUTE + toc->toc_entries[t].first_frame_second); - - this->cddb.track[t].start = (length * CD_FRAMES_PER_SECOND + + + this->cddb.track[t].start = (length * CD_FRAMES_PER_SECOND + toc->toc_entries[t].first_frame_frame); this->cddb.track[t].title = NULL; } - + } - this->cddb.disc_length = (toc->leadout_track.first_frame_minute * CD_SECONDS_PER_MINUTE + + this->cddb.disc_length = (toc->leadout_track.first_frame_minute * CD_SECONDS_PER_MINUTE + toc->leadout_track.first_frame_second); this->cddb.disc_id = _cdda_get_cddb_id(this); if((this->cddb.have_cddb_info == 0) || (_cdda_is_cd_changed(this) == 1)) _cdda_cddb_retrieve(this); - + if(this->cddb.disc_title) { lprintf("Disc Title: %s\n", this->cddb.disc_title); @@ -2376,7 +2376,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { } if(this->cddb.track[this->track].title) { - /* Check for track 'titles' of the form <artist> / <title>. */ + /* Check for track 'titles' of the form <artist> / <title>. */ char *pt; pt = strstr(this->cddb.track[this->track].title, " / "); if (pt != NULL) { @@ -2392,10 +2392,10 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { else { if(this->cddb.disc_artist) { lprintf("Disc Artist: %s\n", this->cddb.disc_artist); - + _x_meta_info_set_utf8(this->stream, XINE_META_INFO_ARTIST, this->cddb.disc_artist); } - + pt = this->cddb.track[this->track].title; } lprintf("Track %d Title: %s\n", this->track+1, pt); @@ -2405,7 +2405,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { _x_meta_info_set_utf8(this->stream, XINE_META_INFO_TRACK_NUMBER, tracknum); _x_meta_info_set_utf8(this->stream, XINE_META_INFO_TITLE, pt); } - + if(this->cddb.disc_category) { lprintf("Disc Category: %s\n", this->cddb.disc_category); @@ -2423,7 +2423,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { return 1; } -static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, +static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, int *num_files) { cdda_input_class_t *this = (cdda_input_class_t *) this_gen; @@ -2437,8 +2437,8 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, /* free old playlist */ for( i = 0; this->autoplaylist[i]; i++ ) { free( this->autoplaylist[i] ); - this->autoplaylist[i] = NULL; - } + this->autoplaylist[i] = NULL; + } /* get the CD TOC */ toc = init_cdrom_toc(); @@ -2484,13 +2484,13 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, print_cdrom_toc(toc); #endif - cdda_close(ip); - + cdda_close(ip); + if ( err < 0 ) { if (ip != this->ip) free(ip); return NULL; } - + num_tracks = toc->last_track - toc->first_track; if (toc->ignore_last_track) num_tracks--; @@ -2550,19 +2550,19 @@ static input_plugin_t *cdda_class_get_instance (input_class_t *cls_gen, xine_str return NULL; this = calloc(1, sizeof (cdda_input_plugin_t)); - + class->ip = this; this->stream = stream; this->mrl = strdup(mrl); this->cdda_device = cdda_device; - + /* CD tracks start from 1; internal data structure indexes from 0 */ this->track = track - 1; this->cddb.track = NULL; this->fd = -1; this->net_fd = -1; this->class = (input_class_t *) class; - + this->input_plugin.open = cdda_plugin_open; this->input_plugin.get_capabilities = cdda_plugin_get_capabilities; this->input_plugin.read = cdda_plugin_read; @@ -2575,20 +2575,20 @@ static input_plugin_t *cdda_class_get_instance (input_class_t *cls_gen, xine_str this->input_plugin.get_optional_data = cdda_plugin_get_optional_data; this->input_plugin.dispose = cdda_plugin_dispose; this->input_plugin.input_class = cls_gen; - + /* * Lookup config entries. */ - if(xine_config_lookup_entry(this->stream->xine, "media.audio_cd.use_cddb", - &enable_entry)) + if(xine_config_lookup_entry(this->stream->xine, "media.audio_cd.use_cddb", + &enable_entry)) enable_cddb_changed_cb(class, &enable_entry); - if(xine_config_lookup_entry(this->stream->xine, "media.audio_cd.cddb_server", - &server_entry)) + if(xine_config_lookup_entry(this->stream->xine, "media.audio_cd.cddb_server", + &server_entry)) server_changed_cb(class, &server_entry); - - if(xine_config_lookup_entry(this->stream->xine, "media.audio_cd.cddb_port", - &port_entry)) + + if(xine_config_lookup_entry(this->stream->xine, "media.audio_cd.cddb_port", + &port_entry)) port_changed_cb(class, &port_entry); class->cddb_error = cddb_error; @@ -2643,15 +2643,15 @@ static void *init_plugin (xine_t *xine, void *data) { this->mrls = NULL; this->mrls_allocated_entries = 0; this->ip = NULL; - - this->cdda_device = config->register_filename(config, "media.audio_cd.device", + + this->cdda_device = config->register_filename(config, "media.audio_cd.device", DEFAULT_CDDA_DEVICE, XINE_CONFIG_STRING_IS_DEVICE_NAME, _("device used for CD audio"), _("The path to the device, usually a " "CD or DVD drive, which you intend to use " "for playing audio CDs."), 10, cdda_device_cb, (void *) this); - + config->register_bool(config, "media.audio_cd.use_cddb", 1, _("query CDDB"), _("Enables CDDB queries, which will give you " "convenient title and track names for your audio CDs.\n" @@ -2659,7 +2659,7 @@ static void *init_plugin (xine_t *xine, void *data) { "is retrieved from an internet server which might collect a profile " "of your listening habits."), 10, enable_cddb_changed_cb, (void *) this); - + config->register_string(config, "media.audio_cd.cddb_server", CDDB_SERVER, _("CDDB server name"), _("The CDDB server used to retrieve the " "title and track information from.\nThis setting is security critical, " @@ -2667,12 +2667,12 @@ static void *init_plugin (xine_t *xine, void *data) { "and could answer the queries with malicious replies. Be sure to enter " "a server you can trust."), XINE_CONFIG_SECURITY, server_changed_cb, (void *) this); - + config->register_num(config, "media.audio_cd.cddb_port", CDDB_PORT, _("CDDB server port"), _("The server port used to retrieve the " "title and track information from."), XINE_CONFIG_SECURITY, port_changed_cb, (void *) this); - + #ifdef CDROM_SELECT_SPEED config->register_num(config, "media.audio_cd.drive_slowdown", 4, _("slow down disc drive to this speed factor"), diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index 164ac2bc9..5b8afef92 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -30,7 +30,7 @@ * 01-Feb-2005 Pekka Jääskeläinen <poj@iki.fi> * * - This history log started. - * - Disabled the automatic EPG updater thread until EPG demuxer + * - Disabled the automatic EPG updater thread until EPG demuxer * is done (it caused pausing of video stream), now EPG is * updated only on demand when the EPG OSD is displayed and * no data is in cache. @@ -39,10 +39,10 @@ * - Now tuning to an erroneus channel shouldn't hang but stop * the playback and output a log describing the error. * - Style cleanups here and there. - * + * * 06-Apr-2006 Jack Steven Kelliher * - Add ATSC support - * + * * TODO/Wishlist: (not in any order) * - Parse all Administrative PIDs - NIT,SDT,CAT etc * - As per James' suggestion, we need a way for the demuxer @@ -52,7 +52,7 @@ * Alevtd can read it. * - Allow the user to view one set of PIDs (channel) while * recording another on the same transponder - this will require either remuxing or - * perhaps bypassing the TS demuxer completely - we could easily have access to the + * perhaps bypassing the TS demuxer completely - we could easily have access to the * individual audio/video streams via seperate read calls, so send them to the decoders * and save the TS output to disk instead of passing it to the demuxer. * This also gives us full control over the streams being played..hmm..control... @@ -60,7 +60,7 @@ * - Allow the user to find and tune new stations from within xine, and * do away with the need for dvbscan & channels.conf file. * - Enable use of Conditional Access devices for scrambled content. - * - if multiple cards are available, optionally use these to record/gather si info, + * - if multiple cards are available, optionally use these to record/gather si info, * and leave primary card for viewing. * - allow for handing off of EPG data to specialised frontends, instead of displaying via * OSD - this will allow for filtering/searching of epg data - useful for automatic recording :) @@ -71,7 +71,7 @@ #endif /* pthread.h must be included first so rest of the headers are imported - thread safely (on some systems). + thread safely (on some systems). However, including it before config.h causes problems with asprintf not being declared (glibc 2.3.6) */ @@ -128,7 +128,7 @@ #define DVB_NOPID 0xffff -/* define stream types +/* define stream types * administrative/system PIDs first */ #define INTERNAL_FILTER 0 #define PATFILTER 1 @@ -201,7 +201,7 @@ #define EPG_PIXELS_BETWEEN_TEXT_ROWS 2 #define EPG_PIXELS_BETWEEN_PROGRAM_ENTRIES 2 -/* How many pixels the background of the OSD is bigger than the text area? +/* How many pixels the background of the OSD is bigger than the text area? The margin is for each side of the background box. */ #define EPG_BACKGROUND_MARGIN 5 @@ -212,10 +212,10 @@ /* How many seconds an EPG entry with the running flag on can be "late" according to the system time before discarding it as an old program? - - This margin is needed because in channel list OSD some EPG entries of + + This margin is needed because in channel list OSD some EPG entries of some channels may be updated a very long ago (if user has watched another - channel in different mux) so we have to resort to system clock for + channel in different mux) so we have to resort to system clock for figuring out the current program. */ #define MAX_EPG_ENTRY_LATENESS 5*60.0 @@ -237,12 +237,12 @@ typedef struct { int fd_subfilter[MAX_SUBTITLES]; struct dvb_frontend_info feinfo; - + int adapter_num; - char *dvr_device; + char *dvr_device; char *demux_device; - + struct dmx_pes_filter_params pesFilterParams[MAX_FILTERS]; struct dmx_pes_filter_params subFilterParams[MAX_SUBTITLES]; struct dmx_sct_filter_params sectFilterParams[MAX_FILTERS]; @@ -254,16 +254,16 @@ typedef struct { typedef struct { /* Program's name. */ - char *progname; + char *progname; /* Textual description of the program. */ char *description; /* The content type string. */ - char *content; + char *content; /* Age recommendation. 0 if not available. */ - int rating; + int rating; time_t starttime; @@ -272,7 +272,7 @@ typedef struct { char duration_minutes; /* Is this program running currently according to EPG data? */ - char running; + char running; } epg_entry_t; @@ -298,7 +298,7 @@ typedef struct { const char *mrls[6]; - int numchannels; + int numchannels; char *autoplaylist[MAX_AUTOCHANNELS]; @@ -332,12 +332,12 @@ typedef struct { osd_object_t *rec_osd; osd_object_t *name_osd; osd_object_t *paused_osd; - osd_object_t *proginfo_osd; + osd_object_t *proginfo_osd; osd_object_t *channel_osd; osd_object_t *background; - + xine_event_queue_t *event_queue; - + /* scratch buffer for forward seeking */ char seek_buf[BUFSIZE]; @@ -347,7 +347,7 @@ typedef struct { int record_fd; int record_paused; /* centre cutout zoom */ - int zoom_ok; + int zoom_ok; /* Is EPG displaying? */ int epg_displaying; @@ -356,8 +356,8 @@ typedef struct { pthread_t epg_updater_thread; /* buffer for EIT data */ - /*char *eitbuffer;*/ - int num_streams_in_this_ts; + /*char *eitbuffer;*/ + int num_streams_in_this_ts; /* number of timedout reads in plugin_read */ int read_failcount; #ifdef DVB_NO_BUFFERING @@ -474,7 +474,7 @@ static unsigned int getbits(unsigned char *buffer, unsigned int bitpos, unsigned } -static int find_descriptor(uint8_t tag, const unsigned char *buf, int descriptors_loop_len, +static int find_descriptor(uint8_t tag, const unsigned char *buf, int descriptors_loop_len, const unsigned char **desc, int *desc_len) { @@ -512,7 +512,7 @@ static time_t dvb_mjdtime (uint8_t *buf) time_t t; _x_assert(tma != NULL); - + mjd = (unsigned int)(buf[0] & 0xff) << 8; mjd +=(unsigned int)(buf[1] & 0xff); hour =(unsigned char)bcdtoint(buf[2] & 0xff); @@ -521,14 +521,14 @@ static time_t dvb_mjdtime (uint8_t *buf) year =(unsigned long)((mjd - 15078.2)/365.25); month=(unsigned long)((mjd - 14956.1 - (unsigned long)(year * 365.25))/30.6001); day = mjd - 14956 - (unsigned long)(year * 365.25) - (unsigned long)(month * 30.6001); - + if (month == 14 || month == 15) i = 1; else i = 0; year += i; month = month - 1 - i * 12; - + tma->tm_sec=sec; tma->tm_min=min; tma->tm_hour=hour; @@ -538,7 +538,7 @@ static time_t dvb_mjdtime (uint8_t *buf) t = timegm(tma); - + free(tma); return t; } @@ -586,7 +586,7 @@ static tuner_t *XINE_MALLOC tuner_init(xine_t * xine, int adapter) this->xine = xine; this->adapter_num = adapter; - + asprintf(&this->demux_device,"/dev/dvb/adapter%i/demux0",this->adapter_num); asprintf(&this->dvr_device,"/dev/dvb/adapter%i/dvr0",this->adapter_num); asprintf(&video_device,"/dev/dvb/adapter%i/video0",this->adapter_num); @@ -631,7 +631,7 @@ static tuner_t *XINE_MALLOC tuner_init(xine_t * xine, int adapter) xprintf(this->xine,XINE_VERBOSITY_DEBUG,"input_dvb: couldn't set INTERNAL to nonblock: %s\n",strerror(errno)); /* and the frontend */ fcntl(this->fd_frontend, F_SETFL, O_NONBLOCK); - + xprintf(this->xine,XINE_VERBOSITY_DEBUG,"input_dvb: Frontend is <%s> ",this->feinfo.name); if(this->feinfo.type==FE_QPSK) xprintf(this->xine,XINE_VERBOSITY_DEBUG,"SAT Card\n"); if(this->feinfo.type==FE_QAM) xprintf(this->xine,XINE_VERBOSITY_DEBUG,"CAB Card\n"); @@ -648,7 +648,7 @@ static tuner_t *XINE_MALLOC tuner_init(xine_t * xine, int adapter) exit: free(video_device); free(frontend_device); - + return this; } @@ -660,7 +660,7 @@ static int dvb_set_pidfilter(dvb_input_plugin_t * this, int filter, ushort pid, if(this->channels[this->channel].pid [filter] !=DVB_NOPID) { ioctl(tuner->fd_pidfilter[filter], DMX_STOP); } - + this->channels[this->channel].pid [filter] = pid; tuner->pesFilterParams[filter].pid = pid; tuner->pesFilterParams[filter].input = DMX_IN_FRONTEND; @@ -683,7 +683,7 @@ static int dvb_set_sectfilter(dvb_input_plugin_t * this, int filter, ushort pid, if(this->channels[this->channel].pid [filter] !=DVB_NOPID) { ioctl(tuner->fd_pidfilter[filter], DMX_STOP); } - + this->channels[this->channel].pid [filter] = pid; tuner->sectFilterParams[filter].pid = pid; memset(&tuner->sectFilterParams[filter].filter.filter,0,DMX_FILTER_SIZE); @@ -717,14 +717,14 @@ static int extract_channel_from_string_internal(channel_t * channel,char * str,f <bw>:<fec_hp>:<fec_lp>:<qam>: <transmissionm>:<guardlist>:<hierarchinfo>:<vpid>:<apid> (DVBA) ATSC: <channel name>:<frequency>:<qam>:<vpid>:<apid> - + <channel name> = any string not containing ':' <frequency> = unsigned long <polarisation> = 'v' or 'h' <sat_no> = unsigned long, usually 0 :D <sym_rate> = symbol rate in MSyms/sec - - + + <inversion> = INVERSION_ON | INVERSION_OFF | INVERSION_AUTO <fec> = FEC_1_2, FEC_2_3, FEC_3_4 .... FEC_AUTO ... FEC_NONE <qam> = QPSK, QAM_128, QAM_16, ATSC ... @@ -741,7 +741,7 @@ static int extract_channel_from_string_internal(channel_t * channel,char * str,f char *field, *tmp; tmp = str; - + /* find the channel name */ if(!(field = strsep(&tmp,":")))return -1; channel->name = strdup(field); @@ -762,8 +762,8 @@ static int extract_channel_from_string_internal(channel_t * channel,char * str,f channel->tone = 0; } channel->front_param.inversion = INVERSION_AUTO; - - /* find out the polarisation */ + + /* find out the polarisation */ if(!(field = strsep(&tmp, ":")))return -1; channel->pol = (field[0] == 'h' ? 0 : 1); @@ -779,7 +779,7 @@ static int extract_channel_from_string_internal(channel_t * channel,char * str,f break; case FE_QAM: channel->front_param.frequency = freq; - + /* find out the inversion */ if(!(field = strsep(&tmp, ":")))return -1; channel->front_param.inversion = find_param(inversion_list, field); @@ -797,10 +797,10 @@ static int extract_channel_from_string_internal(channel_t * channel,char * str,f channel->front_param.u.qam.modulation = find_param(qam_list, field); break; case FE_OFDM: - /* DVB-T frequency is in kHz - workaround broken channels.confs */ - if (freq < 1000000) - freq*=1000; - + /* DVB-T frequency is in kHz - workaround broken channels.confs */ + if (freq < 1000000) + freq*=1000; + channel->front_param.frequency = freq; /* find out the inversion */ @@ -836,7 +836,7 @@ static int extract_channel_from_string_internal(channel_t * channel,char * str,f break; case FE_ATSC: channel->front_param.frequency = freq; - + /* find out the qam */ if(!(field = strsep(&tmp, ":")))return -1; channel->front_param.u.vsb.modulation = find_param(atsc_list, field); @@ -862,9 +862,9 @@ static int extract_channel_from_string_internal(channel_t * channel,char * str,f /* some channel.conf files are generated with the service ID 1 to the right this needs investigation */ if ((field = strsep(&tmp, ":"))) - if(strtoul(field,NULL,0)>0) + if(strtoul(field,NULL,0)>0) channel->service_id = strtoul(field, NULL, 0); - + return 0; } @@ -903,7 +903,7 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch } /* - * load channel list + * load channel list */ while ( fgets (str, BUFSIZE, f)) { @@ -917,7 +917,7 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch continue; str[i] = 0; - if (extract_channel_from_string(&channel,str,fe_type) < 0) + if (extract_channel_from_string(&channel,str,fe_type) < 0) continue; if (num_channels >= num_alloc) { @@ -941,14 +941,14 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch /* free any trailing unused entries */ channels = realloc (channels, num_channels * sizeof (channel_t)); - if(num_channels > 0) + if(num_channels > 0) xprintf (xine, XINE_VERBOSITY_DEBUG, "input_dvb: found %d channels...\n", num_channels); else { xprintf (xine, XINE_VERBOSITY_DEBUG, "input_dvb: no channels found in the file: giving up.\n"); free(channels); return NULL; } - + *num_ch = num_channels; return channels; } @@ -1042,7 +1042,7 @@ static int tuner_tune_it (tuner_t *this, struct dvb_frontend_parameters } xprintf(this->xine, XINE_VERBOSITY_DEBUG, "input_dvb: tuner_tune_it - waiting for lock...\n" ); - + do { status = 0; if (ioctl(this->fd_frontend, FE_READ_STATUS, &status) < 0) { @@ -1069,25 +1069,25 @@ static int tuner_tune_it (tuner_t *this, struct dvb_frontend_parameters usleep(10000); xprintf(this->xine, XINE_VERBOSITY_DEBUG, "Trying to get lock..."); } while (!(status & FE_TIMEDOUT)); - - /* inform the user of frontend status */ + + /* inform the user of frontend status */ xprintf(this->xine,XINE_VERBOSITY_LOG,"input_dvb: Tuner status: "); /* if (ioctl(this->fd_frontend, FE_READ_STATUS, &status) >= 0){ */ - if (status & FE_HAS_SIGNAL) + if (status & FE_HAS_SIGNAL) xprintf(this->xine,XINE_VERBOSITY_LOG," FE_HAS_SIGNAL"); - if (status & FE_TIMEDOUT) + if (status & FE_TIMEDOUT) xprintf(this->xine,XINE_VERBOSITY_LOG," FE_TIMEDOUT"); - if (status & FE_HAS_LOCK) + if (status & FE_HAS_LOCK) xprintf(this->xine,XINE_VERBOSITY_LOG," FE_HAS_LOCK"); - if (status & FE_HAS_CARRIER) + if (status & FE_HAS_CARRIER) xprintf(this->xine,XINE_VERBOSITY_LOG," FE_HAS_CARRIER"); - if (status & FE_HAS_VITERBI) + if (status & FE_HAS_VITERBI) xprintf(this->xine,XINE_VERBOSITY_LOG," FE_HAS_VITERBI"); - if (status & FE_HAS_SYNC) + if (status & FE_HAS_SYNC) xprintf(this->xine,XINE_VERBOSITY_LOG," FE_HAS_SYNC"); /* } */ xprintf(this->xine,XINE_VERBOSITY_LOG,"\n"); - + strength=0; if(ioctl(this->fd_frontend,FE_READ_BER,&strength) >= 0) xprintf(this->xine,XINE_VERBOSITY_LOG,"input_dvb: Bit error rate: %i\n",strength); @@ -1099,9 +1099,9 @@ static int tuner_tune_it (tuner_t *this, struct dvb_frontend_parameters strength=0; if(ioctl(this->fd_frontend,FE_READ_SNR,&strength) >= 0) xprintf(this->xine,XINE_VERBOSITY_LOG,"input_dvb: Signal/Noise Ratio: %u\n",strength); - + if (status & FE_HAS_LOCK && !(status & FE_TIMEDOUT)) { - xprintf(this->xine,XINE_VERBOSITY_LOG,"input_dvb: Lock achieved at %lu Hz\n",(unsigned long)front_param->frequency); + xprintf(this->xine,XINE_VERBOSITY_LOG,"input_dvb: Lock achieved at %lu Hz\n",(unsigned long)front_param->frequency); return 1; } else { xprintf(this->xine,XINE_VERBOSITY_LOG,"input_dvb: Unable to achieve lock at %lu Hz\n",(unsigned long)front_param->frequency); @@ -1110,13 +1110,13 @@ static int tuner_tune_it (tuner_t *this, struct dvb_frontend_parameters } -/* Parse the PMT, and add filters for all stream types associated with - * the 'channel'. We leave it to the demuxer to sort out which PIDs to +/* Parse the PMT, and add filters for all stream types associated with + * the 'channel'. We leave it to the demuxer to sort out which PIDs to * use. to simplify things slightly, (and because the demuxer can't handle it) * allow only one of each media type */ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int section_length) { - + int program_info_len; int pcr_pid; int has_video=0; @@ -1146,9 +1146,9 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se xprintf(this->stream->xine,XINE_VERBOSITY_LOG,"input_dvb: Adding VIDEO : PID 0x%04x\n", elementary_pid); dvb_set_pidfilter(this, VIDFILTER, elementary_pid, DMX_PES_VIDEO, DMX_OUT_TS_TAP); has_video=1; - } + } break; - + case 0x03: case 0x04: if(!has_audio) { @@ -1157,14 +1157,14 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se has_audio=1; } break; - + case 0x06: if (find_descriptor(0x56, buf + 5, descriptor_len, NULL, NULL)) { if(!has_text) { xprintf(this->stream->xine,XINE_VERBOSITY_LOG,"input_dvb: Adding TELETEXT : PID 0x%04x\n", elementary_pid); dvb_set_pidfilter(this,TXTFILTER, elementary_pid, DMX_PES_OTHER,DMX_OUT_TS_TAP); has_text=1; - } + } break; } else if (find_descriptor (0x59, buf + 5, descriptor_len, NULL, NULL)) { /* Note: The subtitling descriptor can also signal @@ -1185,7 +1185,7 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se this->tuner->subFilterParams[has_subs].flags = DMX_IMMEDIATE_START; if (ioctl(this->tuner->fd_subfilter[has_subs], DMX_SET_PES_FILTER, &this->tuner->subFilterParams[has_subs]) < 0) { - xprintf(this->tuner->xine, XINE_VERBOSITY_DEBUG, "input_dvb: set_pid: %s\n", strerror(errno)); + xprintf(this->tuner->xine, XINE_VERBOSITY_DEBUG, "input_dvb: set_pid: %s\n", strerror(errno)); break; } has_subs++; @@ -1193,7 +1193,7 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se break; } else if (find_descriptor (0x6a, buf + 5, descriptor_len, NULL, NULL)) { if(!has_ac3) { - dvb_set_pidfilter(this, AC3FILTER, elementary_pid, DMX_PES_OTHER,DMX_OUT_TS_TAP); + dvb_set_pidfilter(this, AC3FILTER, elementary_pid, DMX_PES_OTHER,DMX_OUT_TS_TAP); xprintf(this->stream->xine,XINE_VERBOSITY_LOG,"input_dvb: Adding AC3 : PID 0x%04x\n", elementary_pid); has_ac3=1; } @@ -1201,7 +1201,7 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se } break; case 0x81: /* AC3 audio */ - fprintf(stderr, " pid type 0x%x, has audio %d\n",buf[0],has_audio); + fprintf(stderr, " pid type 0x%x, has audio %d\n",buf[0],has_audio); if(!has_audio) { xprintf(this->stream->xine,XINE_VERBOSITY_LOG,"input_dvb: Adding AUDIO : PID 0x%04x\n", elementary_pid); dvb_set_pidfilter(this, AUDFILTER, elementary_pid, DMX_PES_AUDIO, DMX_OUT_TS_TAP); @@ -1209,7 +1209,7 @@ static void parse_pmt(dvb_input_plugin_t *this, const unsigned char *buf, int se } break; - }; + }; buf += descriptor_len + 5; section_length -= descriptor_len + 5; @@ -1220,12 +1220,12 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { uint8_t *tmpbuffer; uint8_t *bufptr; - int service_id; + int service_id; int result; - int section_len; - int x; + int section_len; + int x; struct pollfd pfd; - + tuner_t *tuner = this->tuner; tmpbuffer = calloc(1, 8192); @@ -1239,8 +1239,8 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { xprintf(this->stream->xine,XINE_VERBOSITY_DEBUG,"input_dvb: Setting up Internal PAT filter\n"); xine_usec_sleep(500000); - - /* first - the PAT. retrieve the entire section...*/ + + /* first - the PAT. retrieve the entire section...*/ dvb_set_sectfilter(this, INTERNAL_FILTER, 0, DMX_PES_OTHER, 0, 0xff); /* wait for up to 15 seconds */ @@ -1253,13 +1253,13 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { return; } result = read (tuner->fd_pidfilter[INTERNAL_FILTER], tmpbuffer, 3); - + if(result!=3) xprintf(this->stream->xine,XINE_VERBOSITY_DEBUG,"input_dvb: error reading PAT table - no data!\n"); section_len = getbits(tmpbuffer,12,12); result = read (tuner->fd_pidfilter[INTERNAL_FILTER], tmpbuffer+5,section_len); - + if(result!=section_len) xprintf(this->stream->xine,XINE_VERBOSITY_DEBUG,"input_dvb: error reading in the PAT table\n"); @@ -1267,7 +1267,7 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { bufptr+=10; this->num_streams_in_this_ts=0; - section_len-=5; + section_len-=5; while(section_len>4){ service_id = getbits (bufptr,0,16); @@ -1279,7 +1279,7 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { section_len-=4; bufptr+=4; if(service_id>0) /* ignore NIT table for now */ - this->num_streams_in_this_ts++; + this->num_streams_in_this_ts++; } bufptr = tmpbuffer; @@ -1304,7 +1304,7 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { ioctl(tuner->fd_pidfilter[INTERNAL_FILTER], DMX_STOP); parse_pmt(this,tmpbuffer+8,section_len); - + /* dvb_set_pidfilter(this, TSDTFILTER, 0x02,DMX_PES_OTHER,DMX_OUT_TS_TAP); dvb_set_pidfilter(this, RSTFILTER, 0x13,DMX_PES_OTHER,DMX_OUT_TS_TAP); @@ -1317,8 +1317,8 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { /* we use the section filter for EIT because we are guarenteed a complete section */ if(ioctl(tuner->fd_pidfilter[EITFILTER],DMX_SET_BUFFER_SIZE,8192*this->num_streams_in_this_ts)<0) - xprintf(this->stream->xine,XINE_VERBOSITY_DEBUG,"input_dvb: couldn't increase buffer size for EIT: %s \n",strerror(errno)); - dvb_set_sectfilter(this, EITFILTER, 0x12,DMX_PES_OTHER,0x4e, 0xff); + xprintf(this->stream->xine,XINE_VERBOSITY_DEBUG,"input_dvb: couldn't increase buffer size for EIT: %s \n",strerror(errno)); + dvb_set_sectfilter(this, EITFILTER, 0x12,DMX_PES_OTHER,0x4e, 0xff); xprintf(this->stream->xine,XINE_VERBOSITY_DEBUG,"input_dvb: Setup of PID filters complete\n"); @@ -1330,7 +1330,7 @@ static void dvb_parse_si(dvb_input_plugin_t *this) { static int channel_index(dvb_input_plugin_t* this, int service_id) { int n; for (n=0; n < this->num_channels; n++) - if (this->channels[n].service_id == service_id) + if (this->channels[n].service_id == service_id) return n; return -1; @@ -1345,7 +1345,7 @@ static int compare_epg_by_starttime(const void* a, const void* b) { return -1; } else if ((*epg_a)->starttime > (*epg_b)->starttime) { return 1; - } + } return 0; } @@ -1368,7 +1368,7 @@ static void pthread_sleep(int seconds) { struct timespec timeout; /* Create a dummy mutex which doesn't unlock for sure while waiting. */ - pthread_mutex_init(&dummy_mutex, NULL); + pthread_mutex_init(&dummy_mutex, NULL); pthread_mutex_lock(&dummy_mutex); /* Create a dummy condition variable. */ @@ -1408,7 +1408,7 @@ static void* epg_data_updater(void *t) { } #endif -/* This function parses the EIT table and saves the data used in +/* This function parses the EIT table and saves the data used in EPG OSD of all channels found in the currently tuned stream. */ static void load_epg_data(dvb_input_plugin_t *this) { @@ -1417,7 +1417,7 @@ static void load_epg_data(dvb_input_plugin_t *this) int descriptor_id; int section_len = 0; unsigned int service_id=-1; - int n; + int n; uint8_t *eit = NULL; uint8_t *foo = NULL; char *seen_channels = NULL; @@ -1432,8 +1432,8 @@ static void load_epg_data(dvb_input_plugin_t *this) pthread_mutex_lock(&this->channel_change_mutex); /* seen_channels array is used to store information of channels that were - already "found" in the stream. This information is used to initialize the - channel's EPG structs when the EPG information for the channel is seen in + already "found" in the stream. This information is used to initialize the + channel's EPG structs when the EPG information for the channel is seen in the stream the first time. */ seen_channels = calloc(this->num_channels, sizeof(char)); _x_assert(seen_channels != NULL); @@ -1443,7 +1443,7 @@ static void load_epg_data(dvb_input_plugin_t *this) fd.fd = this->tuner->fd_pidfilter[EITFILTER]; fd.events = POLLPRI; - + for (loops = 0; loops <= this->num_streams_in_this_ts*2; loops++) { eit = foo; @@ -1452,7 +1452,7 @@ static void load_epg_data(dvb_input_plugin_t *this) pthread_mutex_unlock(&this->channel_change_mutex); free(seen_channels); free(foo); - return; + return; } n = read(this->tuner->fd_pidfilter[EITFILTER], eit, 3); table_id = getbits(eit, 0, 8); @@ -1465,8 +1465,8 @@ static void load_epg_data(dvb_input_plugin_t *this) xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,"input_dvb: load_epg_data(): unknown service_id: %d!\n", service_id); continue; } - - + + if (section_len > 15) { current_channel = &this->channels[current_channel_index]; @@ -1484,14 +1484,14 @@ static void load_epg_data(dvb_input_plugin_t *this) continue; } - /* Initialize the EPG struct if there's not one we can reuse. + /* Initialize the EPG struct if there's not one we can reuse. Allocate space for the strings. */ if (current_channel->epg[current_channel->epg_count] == NULL) { current_channel->epg[current_channel->epg_count] = calloc(1, sizeof(epg_entry_t)); _x_assert(current_channel->epg[current_channel->epg_count] != NULL); - current_channel->epg[current_channel->epg_count]->progname = + current_channel->epg[current_channel->epg_count]->progname = malloc(MAX_EPG_PROGRAM_NAME_LENGTH + 1); _x_assert(current_channel->epg[current_channel->epg_count]->progname != NULL); @@ -1499,7 +1499,7 @@ static void load_epg_data(dvb_input_plugin_t *this) malloc(MAX_EPG_PROGRAM_DESCRIPTION_LENGTH + 1); _x_assert(current_channel->epg[current_channel->epg_count]->description != NULL); - current_channel->epg[current_channel->epg_count]->content = + current_channel->epg[current_channel->epg_count]->content = malloc(MAX_EPG_CONTENT_TYPE_LENGTH + 1); _x_assert(current_channel->epg[current_channel->epg_count]->content != NULL); current_channel->epg[current_channel->epg_count]->running = 0; @@ -1514,12 +1514,12 @@ static void load_epg_data(dvb_input_plugin_t *this) 1 not running 2 starts in a few seconds 3 pausing - 4 running + 4 running */ if (getbits(foo,192,3) == 4){ - current_epg->running = 1; + current_epg->running = 1; } else { - current_epg->running = 0; + current_epg->running = 0; } @@ -1532,7 +1532,7 @@ static void load_epg_data(dvb_input_plugin_t *this) current_epg->duration_minutes = (char)bcdtoint(eit[22] & 0xff); descriptor_id = eit[26]; - eit += 27; + eit += 27; section_len -= 27; /* run the descriptor loop for the length of section_len */ while (section_len > 1) @@ -1545,23 +1545,23 @@ static void load_epg_data(dvb_input_plugin_t *this) desc_len = getbits(eit, 0, 8); - /* Let's get the EPG data only in the wanted language. */ + /* Let's get the EPG data only in the wanted language. */ if (xine_config_lookup_entry( - this->stream->xine, + this->stream->xine, "media.dvd.language", &language) && - language.str_value && strlen(language.str_value) >= 2 && + language.str_value && strlen(language.str_value) >= 2 && strncasecmp(language.str_value, &eit[1], 2)) { - + #ifdef DEBUG_EPG printf("input_dvb: EPG Skipping language: %C%C%C\n", - eit[1],eit[2],eit[3]); - printf("input_dvb: EPG language.str_value: %s\n", + eit[1],eit[2],eit[3]); + printf("input_dvb: EPG language.str_value: %s\n", language.str_value); -#endif +#endif break; - } + } /* program name */ name_len = (unsigned char)eit[4]; @@ -1570,20 +1570,20 @@ static void load_epg_data(dvb_input_plugin_t *this) break; } - /* the first char of the string contains sometimes the character + /* the first char of the string contains sometimes the character encoding information, which should not be copied to the string. (FIXME - we ought to be using this byte to change charsets)*/ - + if (!isalnum(*(eit + 5))) skip_byte = 1; else skip_byte = 0; - memcpy(current_epg->progname, eit + 5 + skip_byte, - name_len - skip_byte); + memcpy(current_epg->progname, eit + 5 + skip_byte, + name_len - skip_byte); current_epg->progname[name_len - skip_byte] = '\0'; - /* detailed program information (max 256 chars)*/ + /* detailed program information (max 256 chars)*/ text_len = (unsigned char)eit[5 + name_len]; if (text_len == 0) { current_epg->description[0] = '\0'; @@ -1595,7 +1595,7 @@ static void load_epg_data(dvb_input_plugin_t *this) else skip_byte = 0; - memcpy(current_epg->description, eit + 6 + name_len + skip_byte, + memcpy(current_epg->description, eit + 6 + name_len + skip_byte, text_len - skip_byte); current_epg->description[text_len - skip_byte] = '\0'; } @@ -1611,7 +1611,7 @@ static void load_epg_data(dvb_input_plugin_t *this) snprintf(current_epg->content, MAX_EPG_CONTENT_TYPE_LENGTH, "%s", content[content_bits]); } break; - case 0x55: { /* Parental Rating descriptor describes minimum recommened age -3 */ + case 0x55: { /* Parental Rating descriptor describes minimum recommened age -3 */ /* A rating value of 0 means that there is no rating defined. Ratings greater than 0xF are "defined by broadcaster", which is not supported @@ -1621,7 +1621,7 @@ static void load_epg_data(dvb_input_plugin_t *this) else current_epg->rating = 0; } - break; + break; default: break; } @@ -1630,28 +1630,28 @@ static void load_epg_data(dvb_input_plugin_t *this) eit += getbits(eit, 0, 8); descriptor_id = eit[1]; eit += 2; - } + } /* Store the entry if we got enough data. */ - if (current_epg->progname && strlen(current_epg->progname)) + if (current_epg->progname && strlen(current_epg->progname)) current_channel->epg_count++; } } /* Sort the EPG arrays by starttime. */ for (i = 0; i < this->num_channels; ++i) { - if (!seen_channels[i]) + if (!seen_channels[i]) continue; - qsort(this->channels[i].epg, this->channels[i].epg_count, + qsort(this->channels[i].epg, this->channels[i].epg_count, sizeof(epg_entry_t*), compare_epg_by_starttime); } free(seen_channels); - free(foo); + free(foo); pthread_mutex_unlock(&this->channel_change_mutex); } /* Prints text to an area, tries to cut the lines in between words. */ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, const char* text, - int x, int y, int row_space, + int x, int y, int row_space, int max_x, int max_y, int* height, int color_base) { /* The position of the text to be printed. */ @@ -1663,7 +1663,7 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, const int text_width, text_height; size_t old_line_length, line_cursor; const char* bound, *old_bound; - + *height = 0; while (cursor < text_end) { bound = cursor; @@ -1677,12 +1677,12 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, const line_cursor = old_line_length; /* Strip leading white space. */ - while (isspace(*bound)) + while (isspace(*bound)) bound++; - + /* Copy text to the text_line until end of word or end of string. */ while (!isspace(*bound) && *bound != '\0') { - text_line[line_cursor] = *bound; + text_line[line_cursor] = *bound; bound++; line_cursor++; } @@ -1695,13 +1695,13 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, const if (x + text_width > max_x) { /* It didn't fit, restore the old line and stop trying to fit more.*/ text_line[old_line_length] = '\0'; - + /* If no words did fit to the line, fit as many characters as possible in it. */ if (old_line_length == 0) { text_width = 0; bound = bound - line_cursor + 1; /* rewind to the beginning of the word */ line_cursor = 0; - while (!isspace(*bound) && + while (!isspace(*bound) && *bound != '\0') { text_line[line_cursor++] = *bound++; text_line[line_cursor] = '\0'; @@ -1720,10 +1720,10 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, const bound = old_bound; break; } - + /* OK, it did fit, let's try to fit some more. */ } while (bound < text_end); - + if (y + text_height + row_space > max_y) { break; } @@ -1734,7 +1734,7 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, const } } -/* Finds the EPG of the ith next program. 0 means the current program, 1 next. +/* Finds the EPG of the ith next program. 0 means the current program, 1 next. If not found, returns NULL. All these functions expect the EPG entries are sorted by starting time. */ static epg_entry_t* ith_next_epg(channel_t* channel, int count) { @@ -1742,14 +1742,14 @@ static epg_entry_t* ith_next_epg(channel_t* channel, int count) { int counter = 0; /* Discard the entries of past programs. */ - while (counter + 1 < channel->epg_count && + while (counter + 1 < channel->epg_count && difftime(channel->epg[counter + 1]->starttime, current_time) < 0.0) counter++; /* Check whether the previous program has still the running bit on, and if it's not more late than the given margin, assume it's still running. */ - if (counter >= 1 && channel->epg[counter - 1]->running && + if (counter >= 1 && channel->epg[counter - 1]->running && difftime(current_time, channel->epg[counter]->starttime) < MAX_EPG_ENTRY_LATENESS) { counter--; } @@ -1764,13 +1764,13 @@ static epg_entry_t* ith_next_epg(channel_t* channel, int count) { ago. In that case do not return any EPG. This fixes the "very last program of the day sticking until morning" bug. */ if (counter == channel->epg_count - 1) { - if (difftime(current_time, - channel->epg[counter]->starttime + + if (difftime(current_time, + channel->epg[counter]->starttime + channel->epg[counter]->duration_hours*60*60 + channel->epg[counter]->duration_minutes*60) > MAX_EPG_ENTRY_LATENESS) { return NULL; } - } + } return channel->epg[counter]; } @@ -1781,7 +1781,7 @@ static epg_entry_t* current_epg(channel_t* channel) { #ifdef DEBUG_EPG if (next != NULL) printf("input_dvb: EPG current: %s (%d)\n", next->progname, next->running); -#endif +#endif return next; } @@ -1791,13 +1791,13 @@ static epg_entry_t* next_epg(channel_t* channel) { #ifdef DEBUG_EPG if (next != NULL) printf("input_dvb: EPG next: %s (%d)\n", next->progname, next->running); -#endif +#endif return next; } /* Displays the program info of an EPG entry in OSD. - + x,y The upper left coordinates of the program information area. max_x, max_y The maximum right coordinate of the program information area. last_y The position of y after printing the entry. @@ -1806,7 +1806,7 @@ static epg_entry_t* next_epg(channel_t* channel) { Returns the height of the entry in the OSD in pixels. */ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y, - epg_entry_t* epg_data, osd_renderer_t* renderer, + epg_entry_t* epg_data, osd_renderer_t* renderer, osd_object_t* osd) { char* buffer; int time_width, text_width, dummy; @@ -1845,7 +1845,7 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y, snprintf(buffer + strlen(buffer), 7, " (%i+)", prog_rating); } if (!renderer->set_font(osd, "sans", EPG_CONTENT_FONT_SIZE)) { - print_error("Setting content type font failed."); + print_error("Setting content type font failed."); } renderer->get_text_size(osd, buffer, &content_width, &dummy); renderer->render_text(osd, max_x - 2 - content_width, y, buffer, OSD_TEXT3); @@ -1853,14 +1853,14 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y, text_width = max_x - x - time_width - content_width - 2; - renderer->set_font(osd, "sans", EPG_TITLE_FONT_SIZE); + renderer->set_font(osd, "sans", EPG_TITLE_FONT_SIZE); render_text_area(renderer, osd, epg_data->progname, - x + time_width, y, EPG_PIXELS_BETWEEN_TEXT_ROWS, - x + text_width + time_width, max_y, &text_height, + x + time_width, y, EPG_PIXELS_BETWEEN_TEXT_ROWS, + x + text_width + time_width, max_y, &text_height, OSD_TEXT4); - if (text_height == 0) + if (text_height == 0) *last_y = y + time_height; else *last_y = y + text_height; @@ -1879,15 +1879,15 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y, /* If duration_hours is zero, do not print them. */ if (epg_data->duration_hours > 0) - sprintf(buffer + strlen(buffer), " (%dh%02dmin)", + sprintf(buffer + strlen(buffer), " (%dh%02dmin)", epg_data->duration_hours, epg_data->duration_minutes); else if (epg_data->duration_minutes > 0) - sprintf(buffer + strlen(buffer), " (%dmin)", + sprintf(buffer + strlen(buffer), " (%dmin)", epg_data->duration_minutes); - render_text_area(renderer, osd, buffer, x + time_width, - *last_y + EPG_PIXELS_BETWEEN_TEXT_ROWS, - EPG_PIXELS_BETWEEN_TEXT_ROWS, + render_text_area(renderer, osd, buffer, x + time_width, + *last_y + EPG_PIXELS_BETWEEN_TEXT_ROWS, + EPG_PIXELS_BETWEEN_TEXT_ROWS, max_x, max_y, &text_height, OSD_TEXT3); *last_y += EPG_PIXELS_BETWEEN_TEXT_ROWS + text_height; @@ -1909,7 +1909,7 @@ static void show_eit(dvb_input_plugin_t *this) { if (!this->epg_displaying) { #ifndef EPG_UPDATE_IN_BACKGROUND - if (current_epg(&this->channels[this->channel]) == NULL || + if (current_epg(&this->channels[this->channel]) == NULL || next_epg(&this->channels[this->channel]) == NULL) { load_epg_data(this); } @@ -1919,12 +1919,12 @@ static void show_eit(dvb_input_plugin_t *this) { this->stream->osd_renderer->hide(this->proginfo_osd, 0); this->stream->osd_renderer->clear(this->proginfo_osd); - /* Channel Name */ + /* Channel Name */ if (!this->stream->osd_renderer->set_font( this->proginfo_osd, "sans", EPG_CHANNEL_FONT_SIZE)) { print_error("Error setting channel name font."); } - + this->stream->osd_renderer->render_text( this->proginfo_osd, 0, 0, this->channels[this->channel].name, OSD_TEXT4); @@ -1942,11 +1942,11 @@ static void show_eit(dvb_input_plugin_t *this) { this->proginfo_osd, this->channels[this->channel].name, &temp1, &temp2); this->stream->osd_renderer->render_text( - this->proginfo_osd, EPG_WIDTH - 45, + this->proginfo_osd, EPG_WIDTH - 45, EPG_CHANNEL_FONT_SIZE - EPG_CLOCK_FONT_SIZE, clock, OSD_TEXT4); - + show_program_info(0, EPG_CHANNEL_FONT_SIZE + 2, EPG_WIDTH, EPG_HEIGHT, &y_pos, - current_epg(&this->channels[this->channel]), + current_epg(&this->channels[this->channel]), this->stream->osd_renderer, this->proginfo_osd); y = y_pos; @@ -1957,11 +1957,11 @@ static void show_eit(dvb_input_plugin_t *this) { this->proginfo_osd); y = y_pos; - window_width = + window_width = this->stream->video_out->get_property( this->stream->video_out, VO_PROP_WINDOW_WIDTH); - window_height = + window_height = this->stream->video_out->get_property( this->stream->video_out, VO_PROP_WINDOW_HEIGHT); @@ -1978,8 +1978,8 @@ static void show_eit(dvb_input_plugin_t *this) { this->stream->osd_renderer->set_text_palette( this->background, XINE_TEXTPALETTE_YELLOW_BLACK_TRANSPARENT, OSD_TEXT3); this->stream->osd_renderer->filled_rect( - this->background, 0, 0, - EPG_WIDTH + EPG_BACKGROUND_MARGIN*2, + this->background, 0, 0, + EPG_WIDTH + EPG_BACKGROUND_MARGIN*2, y + EPG_BACKGROUND_MARGIN*2, 4); /* In case video is downscaled and the EPG fits, show it unscaled to make it @@ -1993,8 +1993,8 @@ static void show_eit(dvb_input_plugin_t *this) { centered_y = (centered_y > 0)?(centered_y):(EPG_TOP); this->stream->osd_renderer->set_position( - this->proginfo_osd, - centered_x + EPG_BACKGROUND_MARGIN, + this->proginfo_osd, + centered_x + EPG_BACKGROUND_MARGIN, centered_y + EPG_BACKGROUND_MARGIN); this->stream->osd_renderer->set_position(this->background, centered_x, centered_y); @@ -2010,15 +2010,15 @@ static void show_eit(dvb_input_plugin_t *this) { /* Center the OSD to stream. */ this->stream->osd_renderer->set_position( - this->proginfo_osd, - centered_x + EPG_BACKGROUND_MARGIN, + this->proginfo_osd, + centered_x + EPG_BACKGROUND_MARGIN, centered_y + EPG_BACKGROUND_MARGIN); this->stream->osd_renderer->set_position(this->background, centered_x, centered_y); this->stream->osd_renderer->show(this->background, 0); this->stream->osd_renderer->show(this->proginfo_osd, 0); } - + } else { this->epg_displaying = 0; this->stream->osd_renderer->hide (this->proginfo_osd,0); @@ -2048,7 +2048,7 @@ static int tuner_set_channel (dvb_input_plugin_t *this, channel_t *c) { if (lastchannel.num_value){ /* Remember last watched channel. never show this entry*/ config->update_num(config, "media.dvb.last_channel", this->channel+1); - } + } #ifdef DVB_NO_BUFFERING this->newchannel=1; #endif @@ -2078,14 +2078,14 @@ static void osd_show_channel (dvb_input_plugin_t *this, int channel) { this->channel_osd, 110, 10+i*35, this->channels[channel_to_print].name, (channel_to_print == channel)?(OSD_TEXT4):(OSD_TEXT3)); - + if ((current_program = current_epg(&this->channels[channel_to_print])) && current_program->progname && strlen(current_program->progname) > 0) { this->stream->osd_renderer->set_font(this->channel_osd, "sans", 16); render_text_area(this->stream->osd_renderer, this->channel_osd, - current_program->progname, 400, 10+i*35, + current_program->progname, 400, 10+i*35, -5, CHSEL_WIDTH, 10+i*35+CHSEL_CHANNEL_FONT_SIZE+2, &temp, (channel_to_print == channel)?(OSD_TEXT4):(OSD_TEXT3)); } @@ -2108,19 +2108,19 @@ static void osd_show_channel (dvb_input_plugin_t *this, int channel) { } static int switch_channel(dvb_input_plugin_t *this, int channel) { - + int x; xine_event_t event; xine_pids_data_t data; xine_ui_data_t ui_data; - - /* control_nop appears to stop an occasional (quite long) pause between + + /* control_nop appears to stop an occasional (quite long) pause between channel-changes, which the user may see as a lockup. */ _x_demux_control_nop(this->stream, BUF_FLAG_END_STREAM); - _x_demux_flush_engine(this->stream); + _x_demux_flush_engine(this->stream); pthread_mutex_lock (&this->channel_change_mutex); - + close (this->fd); this->tuned_in = 0; @@ -2128,9 +2128,9 @@ static int switch_channel(dvb_input_plugin_t *this, int channel) { close(this->tuner->fd_pidfilter[x]); this->tuner->fd_pidfilter[x] = open(this->tuner->demux_device, O_RDWR); } - + if (!tuner_set_channel (this, &this->channels[channel])) { - xprintf (this->class->xine, XINE_VERBOSITY_LOG, + xprintf (this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: tuner_set_channel failed\n")); pthread_mutex_unlock (&this->channel_change_mutex); return 0; @@ -2164,7 +2164,7 @@ static int switch_channel(dvb_input_plugin_t *this, int channel) { this->tuned_in = 1; pthread_mutex_unlock (&this->channel_change_mutex); - + /* now read the pat, find all accociated PIDs and add them to the stream */ dvb_parse_si(this); @@ -2176,7 +2176,7 @@ static int switch_channel(dvb_input_plugin_t *this, int channel) { /* show eit for this channel if necessary */ if (this->epg_displaying==1){ - this->epg_displaying=0; + this->epg_displaying=0; show_eit(this); } return 1; @@ -2185,7 +2185,7 @@ static int switch_channel(dvb_input_plugin_t *this, int channel) { static void do_record (dvb_input_plugin_t *this) { struct tm *tma; - time_t *t; + time_t *t; char filename [256]; char dates[64]; int x=0; @@ -2211,7 +2211,7 @@ static void do_record (dvb_input_plugin_t *this) { free(t); t = NULL; strftime(dates,63,"%Y-%m-%d_%H%M",tma); - + if (xine_config_lookup_entry(this->stream->xine, "media.capture.save_dir", &savedir)){ if(strlen(savedir.str_value)>1){ if((dir = opendir(savedir.str_value))==NULL){ @@ -2237,7 +2237,7 @@ static void do_record (dvb_input_plugin_t *this) { this->record_fd = open (filename, O_CREAT | O_APPEND | O_WRONLY, 0644); this->stream->osd_renderer->clear (this->rec_osd); - + this->stream->osd_renderer->render_text (this->rec_osd, 10, 10, "Recording to:", OSD_TEXT3); @@ -2253,7 +2253,7 @@ static void dvb_event_handler (dvb_input_plugin_t *this) { xine_event_t *event; static int channel_menu_visible = 0; - static int next_channel = -1; + static int next_channel = -1; while ((event = xine_event_get (this->event_queue))) { @@ -2279,7 +2279,7 @@ static void dvb_event_handler (dvb_input_plugin_t *this) { } else this->stream->osd_renderer->hide(this->channel_osd, 0); - } + } #ifdef LEFT_MOUSE_DOES_EPG else { /* show EPG on left click of videowindow */ show_eit(this); @@ -2438,27 +2438,27 @@ static void dvb_event_handler (dvb_input_plugin_t *this) { static void ts_rewrite_packets (dvb_input_plugin_t *this, unsigned char * originalPkt, int len) { #define PKT_SIZE 188 -#define BODY_SIZE (188-4) +#define BODY_SIZE (188-4) unsigned int sync_byte; unsigned int data_offset; unsigned int data_len; - unsigned int pid; + unsigned int pid; while(len>0){ - + sync_byte = originalPkt[0]; pid = ((originalPkt[1] << 8) | originalPkt[2]) & 0x1fff; - + /* * Discard packets that are obviously bad. */ data_offset = 4; originalPkt+=data_offset; - + if (pid == 0 && sync_byte==0x47) { unsigned long crc; - + originalPkt[3]=13; /* section length including CRC - first 3 bytes */ originalPkt[2]=0x80; originalPkt[7]=0; /* section number */ @@ -2469,13 +2469,13 @@ static void ts_rewrite_packets (dvb_input_plugin_t *this, unsigned char * origin originalPkt[12]=this->channels[this->channel].pmtpid & 0xff; crc = av_crc(this->class->av_crc, 0xffffffff, originalPkt+1, 12); - + originalPkt[13]=(crc>>24) & 0xff; originalPkt[14]=(crc>>16) & 0xff; originalPkt[15]=(crc>>8) & 0xff; originalPkt[16]=crc & 0xff; memset(originalPkt+17,0xFF,PKT_SIZE-21); /* stuff the remainder */ - + } data_len = PKT_SIZE - data_offset; @@ -2489,7 +2489,7 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { dvb_input_plugin_t *this = (dvb_input_plugin_t *) this_gen; uint8_t *buf = buf_gen; - + off_t n=0, total=0; int have_mutex=0; struct pollfd pfd; @@ -2506,32 +2506,32 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen, /* protect against channel changes */ have_mutex = pthread_mutex_lock(&this->channel_change_mutex); total=0; - - while (total<len){ + + while (total<len){ pfd.fd = this->fd; pfd.events = POLLPRI | POLLIN | POLLERR; pfd.revents = 0; - + if (!this->tuned_in) { pthread_mutex_unlock( &this->channel_change_mutex ); xprintf(this->class->xine, XINE_VERBOSITY_LOG, "input_dvb: Channel \"%s\" could not be tuned in. " "Possibly erroneus settings in channels.conf " - "(frequency changed?).\n", + "(frequency changed?).\n", this->channels[this->channel].name); return 0; } - - if (poll(&pfd, 1, 1500) < 1) { + + if (poll(&pfd, 1, 1500) < 1) { xprintf(this->class->xine, XINE_VERBOSITY_LOG, "input_dvb: No data available. Signal Lost?? \n"); - _x_demux_control_end(this->stream, BUF_FLAG_END_USER); + _x_demux_control_end(this->stream, BUF_FLAG_END_USER); this->read_failcount++; break; } - if (this->read_failcount) { - /* signal/stream regained after loss - + if (this->read_failcount) { + /* signal/stream regained after loss - kick the net_buf_control layer. */ this->read_failcount=0; xprintf(this->class->xine,XINE_VERBOSITY_LOG, @@ -2541,22 +2541,22 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen, if (pfd.revents & POLLPRI || pfd.revents & POLLIN) { n = read (this->fd, &buf[total], len-total); - } else + } else if (pfd.revents & POLLERR) { xprintf(this->class->xine, XINE_VERBOSITY_LOG, "input_dvb: No data available. Signal Lost?? \n"); - _x_demux_control_end(this->stream, BUF_FLAG_END_USER); + _x_demux_control_end(this->stream, BUF_FLAG_END_USER); this->read_failcount++; break; - } + } #ifdef LOG_READS xprintf(this->class->xine,XINE_VERBOSITY_DEBUG, - "input_dvb: got %" PRIdMAX " bytes (%" PRIdMAX "/%" PRIdMAX " bytes read)\n", + "input_dvb: got %" PRIdMAX " bytes (%" PRIdMAX "/%" PRIdMAX " bytes read)\n", (intmax_t)n, (intmax_t)total, (intmax_t)len); #endif - - if (n > 0){ + + if (n > 0){ this->curpos += n; total += n; } else if (n < 0 && errno!=EAGAIN) { @@ -2573,7 +2573,7 @@ static off_t dvb_plugin_read (input_plugin_t *this_gen, /* no data for several seconds - tell the user a possible reason */ if(this->read_failcount==5){ - _x_message(this->stream,1,"DVB Signal Lost. Please check connections.", NULL); + _x_message(this->stream,1,"DVB Signal Lost. Please check connections.", NULL); } #ifdef DVB_NO_BUFFERING if(this->newchannel){ @@ -2661,7 +2661,7 @@ static void dvb_plugin_dispose (input_plugin_t *this_gen) { } if (this->nbc) { - nbc_close (this->nbc); + nbc_close (this->nbc); this->nbc = NULL; } @@ -2786,7 +2786,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) * and assume that its format is valid for our tuner type */ - if (!(channels = load_channels(this->class->xine, this->stream, &num_channels, tuner->feinfo.type))) + if (!(channels = load_channels(this->class->xine, this->stream, &num_channels, tuner->feinfo.type))) { /* failed to load the channels */ tuner_dispose(tuner); @@ -2822,7 +2822,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) } else { /* * try a partial match too - * be smart and compare starting from the first char, then from + * be smart and compare starting from the first char, then from * the second etc.. * Yes, this is expensive, but it happens really often * that the channels have really ugly names, sometimes prefixed @@ -2840,7 +2840,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) if (strlen(channels[idx].name) > offset) { if (strncasecmp(channels[idx].name + offset, channame, chanlen) == 0) { xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: found matching channel %s\n"), channels[idx].name); - break; + break; } } idx++; @@ -2913,12 +2913,12 @@ static int dvb_plugin_open(input_plugin_t * this_gen) return 0; } this->channel = 0; - } else if (strncasecmp(this->mrl, "dvbc://", 7) == 0) + } else if (strncasecmp(this->mrl, "dvbc://", 7) == 0) { /* * This is dvbc://<channel name>:<qam tuning parameters> */ - if (tuner->feinfo.type != FE_QAM) + if (tuner->feinfo.type != FE_QAM) { xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: dvbc mrl specified but the tuner doesn't appear to be QAM (DVB-C)\n")); @@ -2937,15 +2937,15 @@ static int dvb_plugin_open(input_plugin_t * this_gen) return 0; } this->channel = 0; - } else if (strncasecmp(this->mrl, "dvba://", 7) == 0) + } else if (strncasecmp(this->mrl, "dvba://", 7) == 0) { - fprintf(stderr,"input_dvb: 2a %x\n",tuner->feinfo.type); + fprintf(stderr,"input_dvb: 2a %x\n",tuner->feinfo.type); /* * This is dvba://<channel name>:<atsc tuning parameters> */ - if (tuner->feinfo.type != FE_ATSC) + if (tuner->feinfo.type != FE_ATSC) { - fprintf(stderr,"input_dvb: FAILED 1\n"); + fprintf(stderr,"input_dvb: FAILED 1\n"); xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: dvba mrl specified but the tuner doesn't appear to be ATSC (DVB-A)\n")); tuner_dispose(tuner); @@ -2957,7 +2957,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) _x_assert(channels != NULL); if (extract_channel_from_string(channels, ptr, tuner->feinfo.type) < 0) { - fprintf(stderr,"input_dvb: FAILED 2\n"); + fprintf(stderr,"input_dvb: FAILED 2\n"); free(channels); channels = NULL; tuner_dispose(tuner); @@ -2973,7 +2973,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) this->tuner = tuner; this->channels = channels; this->num_channels = num_channels; - + if (!tuner_set_channel(this, &this->channels[this->channel])) { xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: tuner_set_channel failed\n")); @@ -2986,7 +2986,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) return 0; } this->tuned_in = 1; - + /* now read the pat, find all accociated PIDs and add them to the stream */ dvb_parse_si(this); @@ -3001,14 +3001,14 @@ static int dvb_plugin_open(input_plugin_t * this_gen) if (this->dvb_gui_enabled) { /* Start the EPG updater thread. */ this->epg_updater_stop = 0; - if (pthread_create(&this->epg_updater_thread, NULL, + if (pthread_create(&this->epg_updater_thread, NULL, epg_data_updater, this) != 0) { xprintf( this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: cannot create EPG updater thread\n")); return 0; } - } + } #endif /* * this osd is used to draw the "recording" sign @@ -3027,8 +3027,8 @@ static int dvb_plugin_open(input_plugin_t * this_gen) this->stream->osd_renderer->set_position(this->channel_osd, 20, 10); this->stream->osd_renderer->set_encoding(this->channel_osd, NULL); - /* - * this osd is for displaying currently shown channel name + /* + * this osd is for displaying currently shown channel name */ this->name_osd = this->stream->osd_renderer->new_object(this->stream->osd_renderer, 301, 61); this->stream->osd_renderer->set_position(this->name_osd, 20, 10); @@ -3036,8 +3036,8 @@ static int dvb_plugin_open(input_plugin_t * this_gen) this->stream->osd_renderer->set_encoding(this->name_osd, NULL); this->stream->osd_renderer->set_text_palette(this->name_osd, XINE_TEXTPALETTE_YELLOW_BLACK_TRANSPARENT, OSD_TEXT3); - /* - * this osd is for displaying Recording Paused + /* + * this osd is for displaying Recording Paused */ this->paused_osd = this->stream->osd_renderer->new_object(this->stream->osd_renderer, 301, 161); this->stream->osd_renderer->set_position(this->paused_osd, 10, 50); @@ -3045,10 +3045,10 @@ static int dvb_plugin_open(input_plugin_t * this_gen) this->stream->osd_renderer->set_encoding(this->paused_osd, NULL); this->stream->osd_renderer->set_text_palette(this->paused_osd, XINE_TEXTPALETTE_YELLOW_BLACK_TRANSPARENT, OSD_TEXT3); - /* + /* * This osd is for displaying Program Information (EIT), i.e., EPG. */ - this->proginfo_osd = + this->proginfo_osd = this->stream->osd_renderer->new_object( this->stream->osd_renderer, EPG_WIDTH, EPG_HEIGHT); @@ -3057,10 +3057,10 @@ static int dvb_plugin_open(input_plugin_t * this_gen) this->stream->osd_renderer->set_text_palette(this->proginfo_osd, XINE_TEXTPALETTE_WHITE_NONE_TRANSLUCID, OSD_TEXT3); this->stream->osd_renderer->set_text_palette(this->proginfo_osd, XINE_TEXTPALETTE_YELLOW_BLACK_TRANSPARENT, OSD_TEXT4); - this->background = + this->background = this->stream->osd_renderer->new_object( - this->stream->osd_renderer, - EPG_WIDTH + EPG_BACKGROUND_MARGIN*2, + this->stream->osd_renderer, + EPG_WIDTH + EPG_BACKGROUND_MARGIN*2, EPG_HEIGHT + EPG_BACKGROUND_MARGIN*2); this->epg_displaying = 0; @@ -3092,7 +3092,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) /* Clear all pids, the pmt will tell us which to use */ for (x = 0; x < MAX_FILTERS; x++){ this->channels[this->channel].pid[x] = DVB_NOPID; - } + } return 1; @@ -3128,16 +3128,16 @@ static input_plugin_t *dvb_class_get_instance (input_class_t *class_gen, this->fd = -1; this->tuned_in = 0; #ifndef DVB_NO_BUFFERING - this->nbc = nbc_init (this->stream); + this->nbc = nbc_init (this->stream); #else - this->nbc = NULL; + this->nbc = NULL; #endif this->osd = NULL; this->event_queue = NULL; this->record_fd = -1; this->read_failcount = 0; this->epg_updater_stop = 0; - + this->input_plugin.open = dvb_plugin_open; this->input_plugin.get_capabilities = dvb_plugin_get_capabilities; this->input_plugin.read = dvb_plugin_read; @@ -3162,7 +3162,7 @@ static void dvb_class_dispose(input_class_t * this_gen) { dvb_input_class_t *class = (dvb_input_class_t *) this_gen; int x; - + for(x=0;x<class->numchannels;x++) free(class->autoplaylist[x]); @@ -3208,7 +3208,7 @@ static char **dvb_class_get_autoplay_list(input_class_t * this_gen, tuner_dispose(tuner); return class->mrls; } - + tuner_dispose(tuner); if (xine_config_lookup_entry(class->xine, "media.dvb.remember_channel", &lastchannel_enable) @@ -3311,7 +3311,7 @@ static void *init_class (xine_t *xine, void *data) { "really have more than 1 card " "in your system."), 0, NULL, (void *) this); - + return this; } diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 86c5f44dd..e58498abd 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -1,26 +1,26 @@ -/* - * Copyright (C) 2000-2005 the xine project, +/* + * Copyright (C) 2000-2005 the xine project, * Rich Wareham <richwareham@users.sourceforge.net> - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ /* This file was origninally part of the xine-dvdnav project - * at http://dvd.sf.net/. + * at http://dvd.sf.net/. */ /* TODO: @@ -123,7 +123,7 @@ #else #define DVD_PATH "/dev/dvd" #define RDVD_PATH "/dev/rdvd" -#endif +#endif /* Some misc. defines */ #ifdef DVD_VIDEO_LB_LEN @@ -153,7 +153,7 @@ /* Array to hold MRLs returned by get_autoplay_list */ #define MAX_DIR_ENTRIES 1250 -#define MAX_STR_LEN 255 +#define MAX_STR_LEN 255 #if defined (__FreeBSD__) # define off64_t off_t @@ -176,7 +176,7 @@ typedef struct { xine_stream_t *stream; xine_event_queue_t *event_queue; - + int pause_timer; /* Cell still-time timer */ int pause_counter; time_t pause_end_time; @@ -186,7 +186,7 @@ typedef struct { int64_t pg_start; int32_t buttonN; int typed_buttonN;/* for XINE_EVENT_INPUT_NUMBER_* */ - + int32_t mouse_buttonN; int mouse_in; @@ -195,13 +195,13 @@ typedef struct { int seekable; /* are we seekable? */ int mode; /* MODE_NAVIGATE / MODE_TITLE */ int tt, pr; /* title / chapter */ - + /* xine specific variables */ const char *current_dvd_device; /* DVD device currently open */ char *mrl; /* Current MRL */ dvdnav_t *dvdnav; /* Handle for libdvdnav */ const char *dvd_name; - + /* special buffer handling for libdvdnav caching */ pthread_mutex_t buf_mutex; void *source; @@ -240,16 +240,16 @@ static void xine_dvd_send_button_update(dvd_input_plugin_t *this, int mode); /* Callback on device name change */ static void device_change_cb(void *data, xine_cfg_entry_t *cfg) { dvd_input_class_t *class = (dvd_input_class_t *) data; - + class->dvd_device = cfg->str_value; } static uint32_t dvd_plugin_get_capabilities (input_plugin_t *this_gen) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; - + trace_print("Called\n"); - return INPUT_CAP_BLOCK | + return INPUT_CAP_BLOCK | /* TODO: figure out if there is any "allow copying" flag on DVD. * maybe set INPUT_CAP_RIP_FORBIDDEN only for encrypted media? */ @@ -257,7 +257,7 @@ static uint32_t dvd_plugin_get_capabilities (input_plugin_t *this_gen) { #if CAN_SEEK (this->seekable ? INPUT_CAP_SEEKABLE : 0) | #endif - INPUT_CAP_AUDIOLANG | INPUT_CAP_SPULANG | INPUT_CAP_CHAPTERS; + INPUT_CAP_AUDIOLANG | INPUT_CAP_SPULANG | INPUT_CAP_CHAPTERS; } static void read_ahead_cb(void *this_gen, xine_cfg_entry_t *entry) { @@ -274,7 +274,7 @@ static void read_ahead_cb(void *this_gen, xine_cfg_entry_t *entry) { dvdnav_set_readahead_flag(this->dvdnav, entry->num_value); } } - + static void seek_mode_cb(void *this_gen, xine_cfg_entry_t *entry) { dvd_input_class_t *class = (dvd_input_class_t*)this_gen; @@ -289,7 +289,7 @@ static void seek_mode_cb(void *this_gen, xine_cfg_entry_t *entry) { dvdnav_set_PGC_positioning_flag(this->dvdnav, !entry->num_value); } } - + static void region_changed_cb (void *this_gen, xine_cfg_entry_t *entry) { dvd_input_class_t *class = (dvd_input_class_t*)this_gen; @@ -312,10 +312,10 @@ static void language_changed_cb(void *this_gen, xine_cfg_entry_t *entry) { return; class->language = entry->str_value[0] << 8 | entry->str_value[1]; - + if(class->ip) { dvd_input_plugin_t *this = class->ip; - + dvdnav_menu_language_select(this->dvdnav, entry->str_value); dvdnav_audio_language_select(this->dvdnav, entry->str_value); dvdnav_spu_language_select(this->dvdnav, entry->str_value); @@ -347,14 +347,14 @@ static void send_mouse_enter_leave_event(dvd_input_plugin_t *this, int direction event.data = &spu_event; event.data_length = sizeof(spu_event); xine_event_send(this->stream, &event); - + this->mouse_in = direction; } if(!direction) this->mouse_buttonN = -1; } - + static int update_title_display(dvd_input_plugin_t *this) { xine_ui_data_t data; xine_event_t uevent = { @@ -366,7 +366,7 @@ static int update_title_display(dvd_input_plugin_t *this) { int tt=-1, pr=-1; int num_tt = 0; - if(!this || !(this->stream)) + if(!this || !(this->stream)) return 0; /* Set title/chapter display */ @@ -384,22 +384,22 @@ static int update_title_display(dvd_input_plugin_t *this) { dvdnav_get_number_of_titles(this->dvdnav, &num_tt ); - - if(tt >= 1) { + + if(tt >= 1) { int num_angle = 0, cur_angle = 0; int num_part = 0; - /* no menu here */ + /* no menu here */ /* Reflect angle info if appropriate */ dvdnav_get_number_of_parts(this->dvdnav, tt, &num_part); dvdnav_get_angle_info(this->dvdnav, &cur_angle, &num_angle); if(num_angle > 1) { data.str_len = snprintf(data.str, sizeof(data.str), "Title %i, Chapter %i, Angle %i of %i", - tt,pr,cur_angle, num_angle); + tt,pr,cur_angle, num_angle); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,cur_angle); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,num_angle); } else { - data.str_len = snprintf(data.str, sizeof(data.str), + data.str_len = snprintf(data.str, sizeof(data.str), "Title %i, Chapter %i", tt,pr); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0); @@ -429,10 +429,10 @@ static int update_title_display(dvd_input_plugin_t *this) { _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0); } - + if (this->dvd_name && this->dvd_name[0] && (data.str_len + strlen(this->dvd_name) < sizeof(data.str))) { - data.str_len += snprintf(data.str+data.str_len, sizeof(data.str) - data.str_len, + data.str_len += snprintf(data.str+data.str_len, sizeof(data.str) - data.str_len, ", %s", this->dvd_name); } #ifdef INPUT_DEBUG @@ -445,16 +445,16 @@ static int update_title_display(dvd_input_plugin_t *this) { static void dvd_plugin_dispose (input_plugin_t *this_gen) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; - + trace_print("Called\n"); - + if (this->event_queue) xine_event_dispose_queue (this->event_queue); - + ((dvd_input_class_t *)this_gen->input_class)->ip = NULL; if (this->dvdnav) dvdnav_close(this->dvdnav); - + pthread_mutex_lock(&this->buf_mutex); if (this->mem_stack) { /* raise the freeing flag, so that the plugin will be freed as soon @@ -488,11 +488,11 @@ static void dvd_build_mrl_list(dvd_input_plugin_t *this) { this->class->num_mrls = 0; } - if (dvdnav_open(&(this->dvdnav), + if (dvdnav_open(&(this->dvdnav), this->dvd_device) == DVDNAV_STATUS_ERR) { return; } - + this->current_dvd_device = this->dvd_device; this->opened = 1; @@ -514,7 +514,7 @@ static void dvd_build_mrl_list(dvd_input_plugin_t *this) { /* allocate enough memory for: * - a list of pointers to mrls sizeof(xine_mrl_t *) * (num_mrls+1) - * - possible alignment of the mrl array + * - possible alignment of the mrl array * - an array of mrl structures sizeof(xine_mrl_t) * num_mrls * - enough chars for every filename sizeof(char)*25 * num_mrls * - "dvd:/000000.000000\0" = 25 chars @@ -522,7 +522,7 @@ static void dvd_build_mrl_list(dvd_input_plugin_t *this) { if ((this->mrls = (xine_mrl_t **) malloc(sizeof(xine_mrl_t *) + num_mrls * (sizeof(xine_mrl_t*) + sizeof(xine_mrl_t) + 25*sizeof(char)) + xine_mrl_alignment))) { - + /* the first mrl struct comes after the pointer list */ xine_mrl_t *mrl = PTR_ALIGN(&this->mrls[num_mrls+1], xine_mrl_alignment); @@ -555,7 +555,7 @@ static void dvd_build_mrl_list(dvd_input_plugin_t *this) { static void dvd_plugin_free_buffer(buf_element_t *buf) { dvd_input_plugin_t *this = buf->source; - + pthread_mutex_lock(&this->buf_mutex); /* give this buffer back to libdvdnav */ dvdnav_free_cache_block(this->dvdnav, buf->mem); @@ -575,7 +575,7 @@ static void dvd_plugin_free_buffer(buf_element_t *buf) { } } -static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, +static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t nlen) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; buf_element_t *buf; @@ -596,7 +596,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, while(!finished) { dvd_handle_events(this); - + if (block != buf->mem) { /* if we already have a dvdnav cache block, give it back first */ dvdnav_free_cache_block(this->dvdnav, block); @@ -614,17 +614,17 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, } switch(event) { - case DVDNAV_BLOCK_OK: + case DVDNAV_BLOCK_OK: { buf->content = block; buf->type = BUF_DEMUX_BLOCK; /* Make sure we don't think we are still paused */ this->pause_timer = 0; - + /* we got a block, so we might be seekable here */ this->seekable = 1; - + finished = 1; } break; @@ -636,7 +636,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, (dvdnav_still_event_t*)block; buf->type = BUF_CONTROL_NOP; finished = 1; - + /* stills are not seekable */ this->seekable = 0; @@ -657,7 +657,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, xine_usec_sleep(50000); break; } - if ((this->pause_timer != 0xff) && + if ((this->pause_timer != 0xff) && (time(NULL) >= this->pause_end_time)) { this->pause_timer = 0; this->pause_end_time = 0; @@ -677,7 +677,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, break; case DVDNAV_SPU_STREAM_CHANGE: { - dvdnav_spu_stream_change_event_t *stream_event = + dvdnav_spu_stream_change_event_t *stream_event = (dvdnav_spu_stream_change_event_t*) (block); buf->content = block; buf->type = BUF_CONTROL_SPU_CHANNEL; @@ -695,7 +695,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, break; case DVDNAV_AUDIO_STREAM_CHANGE: { - dvdnav_audio_stream_change_event_t *stream_event = + dvdnav_audio_stream_change_event_t *stream_event = (dvdnav_audio_stream_change_event_t*) (block); buf->content = block; buf->type = BUF_CONTROL_AUDIO_CHANNEL; @@ -729,7 +729,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, break; case DVDNAV_CELL_CHANGE: { - dvdnav_cell_change_event_t *cell_event = + dvdnav_cell_change_event_t *cell_event = (dvdnav_cell_change_event_t*) (block); /* Tell xine to update the UI */ @@ -740,14 +740,14 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, .data_length = 0 }; xine_event_send(this->stream, &event); - + if( !update_title_display(this) ) { if (buf->mem != block) dvdnav_free_cache_block(this->dvdnav, block); buf->free_buffer(buf); /* return NULL to indicate end of stream */ return NULL; } - + this->pg_length = cell_event->pg_length; this->pgc_length = cell_event->pgc_length; this->cell_start = cell_event->cell_start; @@ -799,7 +799,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, break; } } - + if (block != buf->mem) { /* we have received a buffer from the libdvdnav cache, store all * necessary values to reconstruct xine's buffer and modify it according to @@ -835,7 +835,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, } pthread_mutex_unlock(&this->buf_mutex); } - + if (this->pg_length && this->pgc_length) { switch (((dvd_input_class_t *)this->input_plugin.input_class)->seek_mode) { case 0: /* PGC based seeking */ @@ -848,7 +848,7 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, break; } } - + return buf; } @@ -866,7 +866,7 @@ static off_t dvd_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len ch_buf[3] = 0xba; return 1; } - + static off_t dvd_plugin_get_current_pos (input_plugin_t *this_gen){ dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; uint32_t pos=0; @@ -883,28 +883,28 @@ static off_t dvd_plugin_get_current_pos (input_plugin_t *this_gen){ static off_t dvd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; - + trace_print("Called\n"); if(!this || !this->dvdnav) { return -1; } - + dvdnav_sector_search(this->dvdnav, offset / DVD_BLOCK_SIZE , origin); return dvd_plugin_get_current_pos(this_gen); } static off_t dvd_plugin_seek_time (input_plugin_t *this_gen, int time_offset, int origin) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; - + trace_print("Called\n"); - + if(!this || !this->dvdnav || origin != SEEK_SET) { return -1; } - + dvdnav_time_search(this->dvdnav, time_offset * 90); - + return dvd_plugin_get_current_pos(this_gen); } @@ -913,7 +913,7 @@ static off_t dvd_plugin_get_length (input_plugin_t *this_gen) { uint32_t pos=0; uint32_t length=1; dvdnav_status_t result; - + trace_print("Called\n"); if(!this || !this->dvdnav) { @@ -931,7 +931,7 @@ static uint32_t dvd_plugin_get_blocksize (input_plugin_t *this_gen) { static const char* dvd_plugin_get_mrl (input_plugin_t *this_gen) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; - + trace_print("Called\n"); return this->mrl; @@ -943,17 +943,17 @@ static void xine_dvd_send_button_update(dvd_input_plugin_t *this, int mode) { if (!this || !this->stream || _x_stream_info_get(this->stream,XINE_STREAM_INFO_IGNORE_SPU)) return; - + if (!this->stream->spu_decoder_plugin || this->stream->spu_decoder_streamtype != ((BUF_SPU_DVD >> 16) & 0xFF)) { /* the proper SPU decoder has not been initialized yet, * so we send a dummy buffer to trigger this */ buf_element_t *buf = this->stream->video_fifo->buffer_pool_alloc(this->stream->video_fifo); - + buf->size = 0; buf->type = BUF_SPU_DVD; this->stream->video_fifo->insert(this->stream->video_fifo, buf); - + while (!this->stream->spu_decoder_plugin || this->stream->spu_decoder_streamtype != ((BUF_SPU_DVD >> 16) & 0xFF)) xine_usec_sleep(50000); @@ -962,7 +962,7 @@ static void xine_dvd_send_button_update(dvd_input_plugin_t *this, int mode) { dvdnav_get_current_highlight(this->dvdnav, &button); if (button == this->buttonN && (mode == 0) ) return; - + this->buttonN = button; /* Avoid duplicate sending of button info */ #ifdef INPUT_DEBUG @@ -977,11 +977,11 @@ static void xine_dvd_send_button_update(dvd_input_plugin_t *this, int mode) { static void dvd_handle_events(dvd_input_plugin_t *this) { dvd_input_class_t *class = (dvd_input_class_t*)this->input_plugin.input_class; - config_values_t *config = class->config; /* Pointer to XineRC config file */ + config_values_t *config = class->config; /* Pointer to XineRC config file */ xine_event_t *event; while ((event = xine_event_get(this->event_queue))) { - + if(!this->dvdnav) { xine_event_free(event); return; @@ -1055,7 +1055,7 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { } } break; - case XINE_EVENT_INPUT_ANGLE_NEXT: + case XINE_EVENT_INPUT_ANGLE_NEXT: { int num = 0, current = 0; dvdnav_get_angle_info(this->dvdnav, ¤t, &num); @@ -1072,7 +1072,7 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { update_title_display(this); } break; - case XINE_EVENT_INPUT_ANGLE_PREVIOUS: + case XINE_EVENT_INPUT_ANGLE_PREVIOUS: { int num = 0, current = 0; dvdnav_get_angle_info(this->dvdnav, ¤t, &num); @@ -1101,7 +1101,7 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { } } break; - case XINE_EVENT_INPUT_MOUSE_BUTTON: + case XINE_EVENT_INPUT_MOUSE_BUTTON: { pci_t nav_pci; if(!this->stream || !this->stream->spu_decoder_plugin) { @@ -1109,7 +1109,7 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { } if (this->stream->spu_decoder_plugin->get_interact_info(this->stream->spu_decoder_plugin, &nav_pci) ) { xine_input_data_t *input = event->data; - if((input->button == 1) && dvdnav_mouse_activate(this->dvdnav, + if((input->button == 1) && dvdnav_mouse_activate(this->dvdnav, &nav_pci, input->x, input->y) == DVDNAV_STATUS_OK) { xine_dvd_send_button_update(this, 1); @@ -1135,7 +1135,7 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { dvdnav_button_select(this->dvdnav, &nav_pci, *but); } break; - case XINE_EVENT_INPUT_MOUSE_MOVE: + case XINE_EVENT_INPUT_MOUSE_MOVE: { pci_t nav_pci; if(!this->stream || !this->stream->spu_decoder_plugin) @@ -1145,19 +1145,19 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { /* printf("input_dvd: Mouse move (x,y) = (%i,%i)\n", input->x, input->y); */ if(dvdnav_mouse_select(this->dvdnav, &nav_pci, input->x, input->y) == DVDNAV_STATUS_OK) { int32_t button; - + dvdnav_get_current_highlight(this->dvdnav, &button); - + if(this->mouse_buttonN != button) { this->mouse_buttonN = button; send_mouse_enter_leave_event(this, 1); } - + } else { if(this->mouse_in) send_mouse_enter_leave_event(this, 0); - + } } } @@ -1237,14 +1237,14 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { case XINE_EVENT_INPUT_NUMBER_1: this->typed_buttonN++; case XINE_EVENT_INPUT_NUMBER_0: - { + { pci_t nav_pci; if(!this->stream || !this->stream->spu_decoder_plugin) return; if (this->stream->spu_decoder_plugin->get_interact_info(this->stream->spu_decoder_plugin, &nav_pci) ) { if (dvdnav_button_select_and_activate(this->dvdnav, &nav_pci, this->typed_buttonN) == DVDNAV_STATUS_OK) { xine_dvd_send_button_update(this, 1); - + if(this->mouse_in) send_mouse_enter_leave_event(this, 0); } @@ -1256,23 +1256,23 @@ static void dvd_handle_events(dvd_input_plugin_t *this) { case XINE_EVENT_INPUT_NUMBER_10_ADD: this->typed_buttonN += 10; } - + xine_event_free(event); } return; } -static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, +static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { - dvd_input_plugin_t *this = (dvd_input_plugin_t *) this_gen; - + dvd_input_plugin_t *this = (dvd_input_plugin_t *) this_gen; + switch(data_type) { case INPUT_OPTIONAL_DATA_AUDIOLANG: { uint16_t lang; int channel = *((int *)data); int8_t dvd_channel; - + /* Be paranoid */ if(this && this->stream && this->dvdnav) { @@ -1283,7 +1283,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, else return INPUT_OPTIONAL_UNSUPPORTED; } - + if (channel == -1) dvd_channel = dvdnav_get_audio_logical_stream(this->dvdnav, this->stream->audio_channel_auto); else @@ -1291,7 +1291,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, if(dvd_channel != -1) { lang = dvdnav_audio_stream_to_lang(this->dvdnav, dvd_channel); - + if(lang != 0xffff) sprintf(data, " %c%c", lang >> 8, lang & 0xff); /* TODO: provide long version in XINE_META_INFO_FULL_LANG */ @@ -1304,7 +1304,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_SUCCESS; } } - } + } return INPUT_OPTIONAL_UNSUPPORTED; } break; @@ -1314,7 +1314,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, uint16_t lang; int channel = *((int *)data); int8_t dvd_channel; - + /* Be paranoid */ if(this && this->stream && this->dvdnav) { @@ -1350,14 +1350,14 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen, return INPUT_OPTIONAL_UNSUPPORTED; } break; - + } - + return INPUT_OPTIONAL_UNSUPPORTED; } #ifdef __sun -/* +/* * Check the environment, if we're running under sun's * vold/rmmount control. */ @@ -1389,7 +1389,7 @@ check_solaris_vold_device(dvd_input_class_t *this) static int dvd_parse_try_open(dvd_input_plugin_t *this, const char *locator) { const char *intended_dvd_device; - + /* FIXME: we temporarily special-case "dvd:/" for compatibility; * actually "dvd:/" should play a DVD image stored in /, but for * now we have it use the default device */ @@ -1411,7 +1411,7 @@ static int dvd_parse_try_open(dvd_input_plugin_t *this, const char *locator) xine_setenv("DVDCSS_RAW_DEVICE", raw_device.str_value, 1); intended_dvd_device = class->dvd_device; } - + /* attempt to open DVD */ if (this->opened) { if (intended_dvd_device == this->current_dvd_device) { @@ -1421,7 +1421,7 @@ static int dvd_parse_try_open(dvd_input_plugin_t *this, const char *locator) /* Changing DVD device */ dvdnav_close(this->dvdnav); this->dvdnav = NULL; - this->opened = 0; + this->opened = 0; } } if (!this->opened) { @@ -1430,14 +1430,14 @@ static int dvd_parse_try_open(dvd_input_plugin_t *this, const char *locator) this->current_dvd_device = intended_dvd_device; } } - + return this->opened; } static int dvd_parse_mrl(dvd_input_plugin_t *this, char **locator, char **title_part) { *title_part = NULL; - + if (dvd_parse_try_open(this, *locator)) { return MODE_NAVIGATE; } else { @@ -1462,7 +1462,7 @@ static int dvd_parse_mrl(dvd_input_plugin_t *this, char **locator, char **title_ *locator = ""; } else return MODE_FAIL; - + if (dvd_parse_try_open(this, *locator)) if (strlen(*title_part)) return MODE_TITLE; @@ -1476,24 +1476,24 @@ static int dvd_parse_mrl(dvd_input_plugin_t *this, char **locator, char **title_ static int dvd_plugin_open (input_plugin_t *this_gen) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; dvd_input_class_t *class = (dvd_input_class_t*)this_gen->input_class; - + char *locator, *locator_orig; char *title_part; xine_cfg_entry_t region_entry, lang_entry, cfg_entry; - + trace_print("Called\n"); /* we already checked the "dvd:/" MRL before */ locator_orig = locator = strdup (this->mrl + (sizeof("dvd:") - 1)); /* FIXME: call a generic xine-lib MRL parser here to pre-parse - * the MRL for ?title=<title>&part=<part> stuff and to expand + * the MRL for ?title=<title>&part=<part> stuff and to expand * escaped characters properly */ _x_mrl_unescape (locator); this->mode = dvd_parse_mrl(this, &locator, &title_part); - + if (this->mode == MODE_FAIL) { /* opening failed and we have nothing left to try */ xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("input_dvd: Error opening DVD device\n")); @@ -1507,26 +1507,26 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { dvdnav_get_title_string(this->dvdnav, &this->dvd_name); if(this->dvd_name) _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, this->dvd_name); - + /* Set region code */ - if (xine_config_lookup_entry (this->stream->xine, "media.dvd.region", - ®ion_entry)) + if (xine_config_lookup_entry (this->stream->xine, "media.dvd.region", + ®ion_entry)) region_changed_cb (class, ®ion_entry); - + /* Set languages */ if (xine_config_lookup_entry (this->stream->xine, "media.dvd.language", - &lang_entry)) + &lang_entry)) language_changed_cb (class, &lang_entry); - + /* Set cache usage */ if (xine_config_lookup_entry(this->stream->xine, "media.dvd.readahead", &cfg_entry)) read_ahead_cb(class, &cfg_entry); - + /* Set seek mode */ if (xine_config_lookup_entry(this->stream->xine, "media.dvd.seek_behaviour", &cfg_entry)) - seek_mode_cb(class, &cfg_entry); + seek_mode_cb(class, &cfg_entry); /* Set single chapter mode */ if (xine_config_lookup_entry(this->stream->xine, "media.dvd.play_single_chapter", @@ -1537,7 +1537,7 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { char *delimiter; int tt, pr; int titles, parts; - + /* a <title>.<part> was specified -> resume parsing */ /* See if there is a period. */ @@ -1547,7 +1547,7 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { tt = strtol(title_part, NULL, 10); dvdnav_get_number_of_titles(this->dvdnav, &titles); if((tt < 0) || (tt > titles)) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_dvd: Title %i is out of range (1 to %i).\n", tt, titles); dvdnav_close(this->dvdnav); this->dvdnav = NULL; @@ -1561,7 +1561,7 @@ static int dvd_plugin_open (input_plugin_t *this_gen) { pr = strtol(delimiter+1, NULL, 10); dvdnav_get_number_of_parts(this->dvdnav, tt, &parts); if ((pr < 0) || (pr > parts)) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_dvd: Part %i is out of range (1 to %i).\n", pr, parts); dvdnav_close(this->dvdnav); this->dvdnav = NULL; @@ -1625,7 +1625,7 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st static const char handled_mrl[] = "dvd:/"; trace_print("Called\n"); - + /* Check we can handle this MRL */ if (strncasecmp (data, handled_mrl, sizeof(handled_mrl)-1 ) != 0) return NULL; @@ -1675,9 +1675,9 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st pthread_mutex_init(&this->buf_mutex, NULL); this->freeing = 0; - + this->event_queue = xine_event_new_queue (this->stream); - + /* config callbacks may react now */ class->ip = this; @@ -1686,7 +1686,7 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st /* FIXME: adapt to new api. */ #if 0 -static xine_mrl_t **dvd_class_get_dir (input_class_t *this_gen, +static xine_mrl_t **dvd_class_get_dir (input_class_t *this_gen, const char *filename, int *nFiles) { dvd_input_class_t *this = (dvd_input_class_t*)this_gen; @@ -1703,11 +1703,11 @@ static xine_mrl_t **dvd_class_get_dir (input_class_t *this_gen, } #endif -static char **dvd_class_get_autoplay_list (input_class_t *this_gen, +static char **dvd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) { dvd_input_class_t *this = (dvd_input_class_t *) this_gen; - trace_print("get_autoplay_list entered\n"); + trace_print("get_autoplay_list entered\n"); this->filelist[0] = "dvd:/"; this->filelist[1] = NULL; @@ -1754,7 +1754,7 @@ static void *init_class (xine_t *xine, void *data) { this = (dvd_input_class_t *) calloc(1, sizeof (dvd_input_class_t)); if (!this) return NULL; - + this->input_class.get_instance = dvd_class_get_instance; this->input_class.identifier = "DVD"; this->input_class.description = N_("DVD Navigator"); @@ -1765,7 +1765,7 @@ static void *init_class (xine_t *xine, void *data) { this->input_class.get_autoplay_list = dvd_class_get_autoplay_list; this->input_class.dispose = dvd_class_dispose; this->input_class.eject_media = dvd_class_eject_media; - + this->config = config; this->xine = xine; @@ -1789,7 +1789,7 @@ static void *init_class (xine_t *xine, void *data) { char *raw_device; static const char *const decrypt_modes[] = { "key", "disc", "title", NULL }; int mode; - + raw_device = config->register_filename(config, "media.dvd.raw_device", RDVD_PATH, XINE_CONFIG_STRING_IS_DEVICE_NAME, _("raw device set up for DVD access"), @@ -1804,14 +1804,14 @@ static void *init_class (xine_t *xine, void *data) { "(man raw) for further information."), 10, NULL, NULL); if (raw_device) xine_setenv("DVDCSS_RAW_DEVICE", raw_device, 0); - + mode = config->register_enum(config, "media.dvd.css_decryption_method", 0, decrypt_modes, _("CSS decryption method"), _("Selects the decryption method libdvdcss will use to descramble " "copy protected DVDs. Try the various methods, if you have problems " "playing scrambled DVDs."), 20, NULL, NULL); xine_setenv("DVDCSS_METHOD", decrypt_modes[mode], 0); - + if(xine->verbosity > XINE_VERBOSITY_NONE) xine_setenv("DVDCSS_VERBOSE", "2", 0); else @@ -1819,7 +1819,7 @@ static void *init_class (xine_t *xine, void *data) { dlclose(dvdcss); } - + config->register_num(config, "media.dvd.region", 1, _("region the DVD player claims to be in (1 to 8)"), @@ -1891,7 +1891,7 @@ static void *init_class (xine_t *xine, void *data) { const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "DVD", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_file.c b/src/input/input_file.c index 26874db7c..29e8f74ca 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2005 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -63,18 +63,18 @@ typedef struct { xine_t *xine; config_values_t *config; - + char *origin_path; int show_hidden_files; int mrls_allocated_entries; xine_mrl_t **mrls; - + } file_input_class_t; typedef struct { input_plugin_t input_plugin; - + xine_stream_t *stream; int fh; @@ -153,10 +153,10 @@ static off_t file_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { off_t l = len; if ( (this->mmap_curr + len) > (this->mmap_base + this->mmap_len) ) l = (this->mmap_base + this->mmap_len) - this->mmap_curr; - + memcpy(buf, this->mmap_curr, l); this->mmap_curr += l; - + return l; } #endif @@ -191,7 +191,7 @@ static buf_element_t *file_plugin_read_block (input_plugin_t *this_gen, fifo_buf /* FIXME: it's completely illegal to free buffer->mem here * - buffer->mem has not been allocated by malloc - * - demuxers expect buffer->mem != NULL + * - demuxers expect buffer->mem != NULL */ /* free(buf->mem); buf->mem = NULL; */ @@ -200,7 +200,7 @@ static buf_element_t *file_plugin_read_block (input_plugin_t *this_gen, fifo_buf #endif { off_t num_bytes, total_bytes = 0; - + buf->content = buf->mem; while (total_bytes < todo) { @@ -218,11 +218,11 @@ static buf_element_t *file_plugin_read_block (input_plugin_t *this_gen, fifo_buf } total_bytes += num_bytes; } - + if( buf != NULL ) buf->size = total_bytes; } - + return buf; } @@ -296,7 +296,7 @@ static uint32_t file_plugin_get_blocksize (input_plugin_t *this_gen) { */ static int is_a_dir(char *filepathname) { struct stat pstat; - + stat(filepathname, &pstat); return (S_ISDIR(pstat.st_mode)); @@ -308,9 +308,9 @@ static const char* file_plugin_get_mrl (input_plugin_t *this_gen) { return this->mrl; } -static int file_plugin_get_optional_data (input_plugin_t *this_gen, +static int file_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { - + return INPUT_OPTIONAL_UNSUPPORTED; } @@ -416,7 +416,7 @@ static int file_plugin_open (input_plugin_t *this_gen ) { return 1; } -static input_plugin_t *file_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, +static input_plugin_t *file_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data) { /* file_input_class_t *cls = (file_input_class_t *) cls_gen; */ @@ -483,12 +483,12 @@ static input_plugin_t *file_class_get_instance (input_class_t *cls_gen, xine_str */ static void hidden_bool_cb(void *data, xine_cfg_entry_t *cfg) { file_input_class_t *this = (file_input_class_t *) data; - + this->show_hidden_files = cfg->num_value; } static void origin_change_cb(void *data, xine_cfg_entry_t *cfg) { file_input_class_t *this = (file_input_class_t *) data; - + this->origin_path = cfg->str_value; } @@ -539,20 +539,20 @@ static int _strverscmp(const char *s1, const char *s2) { c2 = *p2++; state |= (c1 == '0') + (ISDIGIT(c1) != 0); } - + state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT(c2) != 0))]; - + switch(state) { case CMP: return diff; - + case LEN: while(ISDIGIT(*p1++)) if(!ISDIGIT(*p2++)) return 1; - + return ISDIGIT(*p2) ? -1 : diff; - + default: return state; } @@ -582,11 +582,11 @@ static uint32_t get_file_type(char *filepathname, char *origin, xine_t *xine) { return file_type; } } - + file_type |= mrl_file; - + mode = pstat.st_mode; - + if(S_ISLNK(mode)) file_type |= mrl_file_symlink; else if(S_ISDIR(mode)) @@ -606,10 +606,10 @@ static uint32_t get_file_type(char *filepathname, char *origin, xine_t *xine) { if(mode & S_IXUGO) file_type |= mrl_file_exec; } - + if(filepathname[strlen(filepathname) - 1] == '~') file_type |= mrl_file_backup; - + return file_type; } @@ -629,7 +629,7 @@ static off_t get_file_size(char *filepathname, char *origin) { return pstat.st_size; } -static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, +static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, const char *filename, int *nFiles) { /* FIXME: this code needs cleanup badly */ @@ -651,7 +651,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, *nFiles = 0; memset(current_dir, 0, sizeof(current_dir)); - /* + /* * No origin location, so got the content of the current directory */ if(!filename) { @@ -659,7 +659,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, } else { snprintf(current_dir, XINE_PATH_MAX, "%s", filename); - + /* Remove exceed '/' */ while((current_dir[strlen(current_dir) - 1] == '/') && strlen(current_dir) > 1) current_dir[strlen(current_dir) - 1] = '\0'; @@ -667,14 +667,14 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, /* Store new origin path */ try_again_from_home: - + this->config->update_string(this->config, "media.files.origin_path", current_dir); if(strcasecmp(current_dir, "/")) snprintf(current_dir_slashed, sizeof(current_dir_slashed), "%s/", current_dir); else sprintf(current_dir_slashed, "/"); - + /* * Ooch! */ @@ -689,28 +689,28 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, return NULL; } - + dir_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); hide_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); norm_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); - + while((pdirent = readdir(pdir)) != NULL) { - + memset(fullfilename, 0, sizeof(fullfilename)); snprintf(fullfilename, sizeof(fullfilename), "%s/%s", current_dir, pdirent->d_name); - + if(is_a_dir(fullfilename)) { - + /* if user don't want to see hidden files, ignore them */ - if(this->show_hidden_files == 0 && + if(this->show_hidden_files == 0 && ((strlen(pdirent->d_name) > 1) && (pdirent->d_name[0] == '.' && pdirent->d_name[1] != '.'))) { ; } else { - + dir_files[num_dir_files].origin = strdup(current_dir); - asprintf(&(dir_files[num_dir_files].mrl), "%s%s", + asprintf(&(dir_files[num_dir_files].mrl), "%s%s", current_dir_slashed, pdirent->d_name); dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = get_file_type(fullfilename, current_dir, this->xine); @@ -720,11 +720,11 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, if(dir_files[num_dir_files].type & mrl_file_symlink) { char linkbuf[XINE_PATH_MAX + XINE_NAME_MAX + 1]; int linksize; - + memset(linkbuf, 0, sizeof(linkbuf)); linksize = readlink(fullfilename, linkbuf, XINE_PATH_MAX + XINE_NAME_MAX); - - if(linksize < 0) + + if(linksize < 0) xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_file: readlink() failed: %s\n", strerror(errno)); else { @@ -734,7 +734,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, dir_files[num_dir_files].type |= get_file_type(dir_files[num_dir_files].link, current_dir, this->xine); } } - + num_dir_files++; } @@ -746,20 +746,20 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, if(this->show_hidden_files) { hide_files[num_hide_files].origin = strdup(current_dir); - asprintf(&(hide_files[num_hide_files].mrl), "%s%s", + asprintf(&(hide_files[num_hide_files].mrl), "%s%s", current_dir_slashed, pdirent->d_name); hide_files[num_hide_files].link = NULL; hide_files[num_hide_files].type = get_file_type(fullfilename, current_dir, this->xine); hide_files[num_hide_files].size = get_file_size(fullfilename, current_dir); - + /* The file is a link, follow it */ if(hide_files[num_hide_files].type & mrl_file_symlink) { char linkbuf[XINE_PATH_MAX + XINE_NAME_MAX + 1]; int linksize; - + memset(linkbuf, 0, sizeof(linkbuf)); linksize = readlink(fullfilename, linkbuf, XINE_PATH_MAX + XINE_NAME_MAX); - + if(linksize < 0) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_file: readlink() failed: %s\n", strerror(errno)); @@ -770,7 +770,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, hide_files[num_hide_files].type |= get_file_type(hide_files[num_hide_files].link, current_dir, this->xine); } } - + num_hide_files++; } @@ -778,39 +778,39 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, else { norm_files[num_norm_files].origin = strdup(current_dir); - asprintf(&(norm_files[num_norm_files].mrl), "%s%s", + asprintf(&(norm_files[num_norm_files].mrl), "%s%s", current_dir_slashed, pdirent->d_name); norm_files[num_norm_files].link = NULL; norm_files[num_norm_files].type = get_file_type(fullfilename, current_dir, this->xine); norm_files[num_norm_files].size = get_file_size(fullfilename, current_dir); - + /* The file is a link, follow it */ if(norm_files[num_norm_files].type & mrl_file_symlink) { char linkbuf[XINE_PATH_MAX + XINE_NAME_MAX + 1]; int linksize; - + memset(linkbuf, 0, sizeof(linkbuf)); linksize = readlink(fullfilename, linkbuf, XINE_PATH_MAX + XINE_NAME_MAX); - + if(linksize < 0) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_file: readlink() failed: %s\n", strerror(errno)); } else { - norm_files[num_norm_files].link = + norm_files[num_norm_files].link = strndup(linkbuf, linksize); norm_files[num_norm_files].type |= get_file_type(norm_files[num_norm_files].link, current_dir, this->xine); } } - + num_norm_files++; } - + num_files++; } - + closedir(pdir); - + /* * Ok, there are some files here, so sort * them then store them into global mrls array. @@ -825,18 +825,18 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, */ if(num_dir_files) qsort(dir_files, num_dir_files, sizeof(xine_mrl_t), func); - + if(num_hide_files) qsort(hide_files, num_hide_files, sizeof(xine_mrl_t), func); - + if(num_norm_files) qsort(norm_files, num_norm_files, sizeof(xine_mrl_t), func); - + /* * Add directories entries */ for(i = 0; i < num_dir_files; i++) { - + if(num_files >= this->mrls_allocated_entries) { ++this->mrls_allocated_entries; this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*)); @@ -844,8 +844,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, } else memset(this->mrls[num_files], 0, sizeof(xine_mrl_t)); - - MRL_DUPLICATE(&dir_files[i], this->mrls[num_files]); + + MRL_DUPLICATE(&dir_files[i], this->mrls[num_files]); num_files++; } @@ -854,7 +854,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, * Add hidden files entries */ for(i = 0; i < num_hide_files; i++) { - + if(num_files >= this->mrls_allocated_entries) { ++this->mrls_allocated_entries; this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*)); @@ -862,13 +862,13 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, } else memset(this->mrls[num_files], 0, sizeof(xine_mrl_t)); - - MRL_DUPLICATE(&hide_files[i], this->mrls[num_files]); + + MRL_DUPLICATE(&hide_files[i], this->mrls[num_files]); num_files++; } - - /* + + /* * Add other files entries */ for(i = 0; i < num_norm_files; i++) { @@ -881,24 +881,24 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, else memset(this->mrls[num_files], 0, sizeof(xine_mrl_t)); - MRL_DUPLICATE(&norm_files[i], this->mrls[num_files]); + MRL_DUPLICATE(&norm_files[i], this->mrls[num_files]); num_files++; } - + /* Some cleanups before leaving */ for(i = num_dir_files; i == 0; i--) MRL_ZERO(&dir_files[i]); free(dir_files); - + for(i = num_hide_files; i == 0; i--) MRL_ZERO(&hide_files[i]); free(hide_files); - + for(i = num_norm_files; i == 0; i--) MRL_ZERO(&norm_files[i]); free(norm_files); - + } else { free(hide_files); @@ -906,12 +906,12 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, free(norm_files); return NULL; } - + /* * Inform caller about files found number. */ *nFiles = num_files; - + /* * Freeing exceeded mrls if exists. */ @@ -919,7 +919,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]); free(this->mrls[this->mrls_allocated_entries--]); } - + /* * This is useful to let UI know where it should stops ;-). */ @@ -961,7 +961,7 @@ static void *init_plugin (xine_t *xine, void *data) { this->xine = xine; this->config = xine->config; config = xine->config; - + this->input_class.get_instance = file_class_get_instance; this->input_class.identifier = "file"; this->input_class.description = N_("file input plugin"); @@ -975,7 +975,7 @@ static void *init_plugin (xine_t *xine, void *data) { { char current_dir[XINE_PATH_MAX + 1]; - + if(getcwd(current_dir, sizeof(current_dir)) == NULL) strcpy(current_dir, "."); @@ -986,14 +986,14 @@ static void *init_plugin (xine_t *xine, void *data) { "start at this location."), 0, origin_change_cb, (void *) this); } - - this->show_hidden_files = config->register_bool(config, - "media.files.show_hidden_files", + + this->show_hidden_files = config->register_bool(config, + "media.files.show_hidden_files", 0, _("list hidden files"), _("If enabled, the browser to select the file to " "play will also show hidden files."), 10, hidden_bool_cb, (void *) this); - + return this; } @@ -1002,7 +1002,7 @@ static void *init_plugin (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "FILE", XINE_VERSION_CODE, NULL, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_gnome_vfs.c b/src/input/input_gnome_vfs.c index acb63dcf6..b65530912 100644 --- a/src/input/input_gnome_vfs.c +++ b/src/input/input_gnome_vfs.c @@ -1,19 +1,19 @@ /* * Copyright (C) 2000-2003 the xine project * 2002 Bastien Nocera <hadess@hadess.net> - * + * * This file is part of totem, - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -219,7 +219,7 @@ gnomevfs_plugin_get_mrl (input_plugin_t *this_gen) } static int -gnomevfs_plugin_get_optional_data (input_plugin_t *this_gen, +gnomevfs_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { D ("input_gnomevfs: get optional data, type %08x\n", data_type); diff --git a/src/input/input_http.c b/src/input/input_http.c index fdd7d74f8..d4a1b4de6 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -74,14 +74,14 @@ typedef struct { input_plugin_t input_plugin; xine_stream_t *stream; - + char *mrl; - nbc_t *nbc; + nbc_t *nbc; off_t curpos; off_t contentlength; - + char buf[BUFSIZE]; char preview[MAX_PREVIEW_SIZE]; @@ -113,7 +113,7 @@ typedef struct { /* scratch buffer for forward seeking */ char seek_buf[BUFSIZE]; - + } http_input_plugin_t; typedef struct { @@ -141,7 +141,7 @@ static void proxy_host_change_cb (void *this_gen, xine_cfg_entry_t *cfg) { static void proxy_port_change_cb(void *this_gen, xine_cfg_entry_t *cfg) { http_input_class_t *this = (http_input_class_t *)this_gen; - + this->proxyport = cfg->num_value; } @@ -173,17 +173,17 @@ static int _x_use_proxy(http_input_class_t *this, const char *host) { struct hostent *info; size_t i = 0, host_len, noprox_len; - /* - * get full host name + /* + * get full host name */ if ((info = gethostbyname(host)) == NULL) { - xine_log(this->xine, XINE_LOG_MSG, + xine_log(this->xine, XINE_LOG_MSG, _("input_http: gethostbyname(%s) failed: %s\n"), host, hstrerror(h_errno)); return 1; } if (!info->h_name) return 1; - + if ( info->h_addr_list[0] ) { /* \177\0\0\1 is the *octal* representation of 127.0.0.1 */ if ( info->h_addrtype == AF_INET && !memcmp(info->h_addr_list[0], "\177\0\0\1", 4) ) { @@ -247,7 +247,7 @@ static void http_plugin_basicauth (const char *user, const char *password, char* } static int http_plugin_read_metainf (http_input_plugin_t *this) { - + char metadata_buf[255 * 16]; unsigned char len = 0; char *title_end; @@ -255,19 +255,19 @@ static int http_plugin_read_metainf (http_input_plugin_t *this) { const char *radio; xine_event_t uevent; xine_ui_data_t data; - + /* get the length of the metadata */ if (_x_io_tcp_read (this->stream, this->fh, (char*)&len, 1) != 1) return 0; lprintf ("http_plugin_read_metainf: len=%d\n", len); - + if (len > 0) { if (_x_io_tcp_read (this->stream, this->fh, metadata_buf, len * 16) != (len * 16)) return 0; - + metadata_buf[len * 16] = '\0'; - + lprintf ("http_plugin_read_metainf: %s\n", metadata_buf); /* Extract the title of the current song */ @@ -280,13 +280,13 @@ static int http_plugin_read_metainf (http_input_plugin_t *this) { } if ((title_end = strstr(songtitle, terminator))) { *title_end = '\0'; - + if ((!this->shoutcast_songtitle || (strcmp(songtitle, this->shoutcast_songtitle))) && (strlen(songtitle) > 0)) { - + lprintf ("http_plugin_read_metainf: songtitle: %s\n", songtitle); - + if (this->shoutcast_songtitle) free(this->shoutcast_songtitle); this->shoutcast_songtitle = strdup(songtitle); @@ -323,7 +323,7 @@ static off_t http_plugin_read_int (http_input_plugin_t *this, char *buf, off_t total) { int read_bytes = 0; int nlen; - + lprintf("total=%"PRId64"\n", total); while (total) { nlen = total; @@ -338,7 +338,7 @@ static off_t http_plugin_read_int (http_input_plugin_t *this, if (!http_plugin_read_metainf(this)) goto error; this->shoutcast_pos = 0; - + } else { nlen = _x_io_tcp_read (this->stream, this->fh, &buf[read_bytes], nlen); if (nlen < 0) @@ -365,7 +365,7 @@ static off_t http_plugin_read_int (http_input_plugin_t *this, this->shoutcast_pos += nlen; } - + /* end of file */ if (nlen == 0) return read_bytes; @@ -373,9 +373,9 @@ static off_t http_plugin_read_int (http_input_plugin_t *this, total -= nlen; } return read_bytes; - + error: - if (!_x_action_pending(this->stream)) + if (!_x_action_pending(this->stream)) _x_message (this->stream, XINE_MSG_READ_ERROR, this->host, NULL); xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: read error %d\n"), errno); return read_bytes; @@ -411,7 +411,7 @@ static off_t http_plugin_read (input_plugin_t *this_gen, if (n > 0) { int read_bytes; read_bytes = http_plugin_read_int (this, &buf[num_bytes], n); - + if (read_bytes < 0) return read_bytes; @@ -429,7 +429,7 @@ static int resync_nsv(http_input_plugin_t *this) { lprintf("resyncing NSV stream\n"); while ((pos < 3) && (read_bytes < (1024*1024))) { - + if (http_plugin_read_int(this, (char*)&c, 1) != 1) return 1; @@ -461,7 +461,7 @@ static int resync_nsv(http_input_plugin_t *this) { if (pos == 3) { lprintf("NSV stream resynced\n"); } else { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "http: cannot resync NSV stream!\n"); return 0; } @@ -546,10 +546,10 @@ static off_t http_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin if( this->curpos <= this->preview_size ) this->curpos = offset; else - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "http: cannot seek back! (%" PRIdMAX " > %" PRIdMAX ")\n", (intmax_t)this->curpos, (intmax_t)offset); - + } else { offset -= this->curpos; @@ -598,7 +598,7 @@ static void http_plugin_dispose (input_plugin_t *this_gen ) { close(this->fh); this->fh = -1; } - + if (this->nbc) { nbc_close (this->nbc); this->nbc = NULL; @@ -617,7 +617,7 @@ static void report_progress (xine_stream_t *stream, int p) { xine_event_t event; xine_progress_data_t prg; - + prg.description = _("Connecting HTTP server..."); prg.percent = p; @@ -642,7 +642,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { mime_type[0] = 0; use_proxy = this_class->proxyhost && strlen(this_class->proxyhost); - + if (!_x_parse_url(this->mrl, &this->proto, &this->host, &this->port, &this->user, &this->password, &this->uri, &this->user_agent)) { @@ -653,7 +653,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { if (this->port == 0) this->port = DEFAULT_HTTP_PORT; - + if (this_class->proxyport == 0) proxyport = DEFAULT_HTTP_PORT; else @@ -667,10 +667,10 @@ static int http_plugin_open (input_plugin_t *this_gen ) { printf ("input_http: password : >%s<\n", this->password); printf ("input_http: path : >%s<\n", this->uri); - + if (use_proxy) printf (" via proxy >%s:%d<", this_class->proxyhost, proxyport); - + printf ("\n"); } @@ -680,13 +680,13 @@ static int http_plugin_open (input_plugin_t *this_gen ) { this->fh = _x_io_tcp_connect (this->stream, this_class->proxyhost, proxyport); else this->fh = _x_io_tcp_connect (this->stream, this->host, this->port); - + this->curpos = 0; - + if (this->fh == -1) return -2; - { + { uint32_t timeout, progress; xine_cfg_entry_t cfgentry; if (xine_config_lookup_entry (this->stream->xine, "media.network.timeout", &cfgentry)) { @@ -716,10 +716,10 @@ static int http_plugin_open (input_plugin_t *this_gen ) { snprintf (this->buf, BUFSIZE, "GET http://%s%s HTTP/1.0\015\012", this->host, this->uri); } - } + } else snprintf (this->buf, BUFSIZE, "GET %s HTTP/1.0\015\012", this->uri); - + buflen = strlen(this->buf); if (this->port != DEFAULT_HTTP_PORT) snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s:%d\015\012", @@ -727,7 +727,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { else snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s\015\012", this->host); - + buflen = strlen(this->buf); if (use_proxy && this_class->proxyuser && strlen(this_class->proxyuser)) { char *proxyauth; @@ -748,7 +748,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { buflen = strlen(this->buf); free(auth); } - + snprintf(this->buf + buflen, BUFSIZE - buflen, "User-Agent: %s%sxine/%s\015\012" "Accept: */*\015\012" @@ -781,14 +781,14 @@ static int http_plugin_open (input_plugin_t *this_gen ) { this->buf[len] = '\0'; len--; - + if (len >= 0 && this->buf[len] == '\015') { this->buf[len] = '\0'; len--; } linenum++; - + lprintf ("answer: >%s<\n", this->buf); if (linenum == 1) { @@ -804,13 +804,13 @@ static int http_plugin_open (input_plugin_t *this_gen ) { &httpcode, httpstatus) != 2) ) { _x_message(this->stream, XINE_MSG_CONNECTION_REFUSED, "invalid http answer", NULL); - xine_log (this->stream->xine, XINE_LOG_MSG, + xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: invalid http answer\n")); return -6; } if (httpcode >= 300 && httpcode < 400) { - xine_log (this->stream->xine, XINE_LOG_MSG, + xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: 3xx redirection: >%d %s<\n"), httpcode, httpstatus); } else if (httpcode == 404) { @@ -833,7 +833,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { } else if (httpcode < 200 || httpcode >= 300) { _x_message(this->stream, XINE_MSG_CONNECTION_REFUSED, "http status not 2xx: ", httpstatus, NULL); - xine_log (this->stream->xine, XINE_LOG_MSG, + xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: http status not 2xx: >%d %s<\n"), httpcode, httpstatus); return -9; @@ -841,18 +841,18 @@ static int http_plugin_open (input_plugin_t *this_gen ) { } else { if (this->contentlength == 0) { intmax_t contentlength; - + if (sscanf(this->buf, "Content-Length: %" SCNdMAX , &contentlength) == 1) { - xine_log (this->stream->xine, XINE_LOG_MSG, + xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: content length = %" PRIdMAX " bytes\n"), contentlength); this->contentlength = (off_t)contentlength; } } - + if (!strncasecmp(this->buf, "Location: ", 10)) { char *href = (this->buf + 10); - + lprintf ("trying to open target of redirection: >%s<\n", href); href = _x_canonicalise_url (this->mrl, href); @@ -883,13 +883,13 @@ static int http_plugin_open (input_plugin_t *this_gen ) { (this->buf + sizeof(TAG_ICY_NAME) - 1 + (*(this->buf + sizeof(TAG_ICY_NAME) - 1) == ' '))); } - + if (!strncasecmp(this->buf, TAG_ICY_GENRE, sizeof(TAG_ICY_GENRE) - 1)) { _x_meta_info_set(this->stream, XINE_META_INFO_GENRE, (this->buf + sizeof(TAG_ICY_GENRE) - 1 + (*(this->buf + sizeof(TAG_ICY_GENRE) - 1) == ' '))); } - + /* icy-notice1 is always the same */ if (!strncasecmp(this->buf, TAG_ICY_NOTICE2, sizeof(TAG_ICY_NOTICE2) - 1)) { char *end; @@ -900,14 +900,14 @@ static int http_plugin_open (input_plugin_t *this_gen ) { (this->buf + sizeof(TAG_ICY_NOTICE2) - 1 + (*(this->buf + sizeof(TAG_ICY_NOTICE2) - 1) == ' '))); } - + /* metadata interval (in byte) */ if (sscanf(this->buf, TAG_ICY_METAINT"%d", &this->shoutcast_metaint) == 1) { lprintf("shoutcast_metaint: %d\n", this->shoutcast_metaint); this->shoutcast_mode = 1; this->shoutcast_pos = 0; } - + /* content type */ if (!strncasecmp(this->buf, TAG_CONTENT_TYPE, sizeof(TAG_CONTENT_TYPE) - 1)) { const char *type = this->buf + sizeof (TAG_CONTENT_TYPE) - 1; @@ -924,7 +924,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { this->is_lastfm = 1; } } - + if (len == -1) done = 1; else @@ -961,7 +961,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { *newline = '\0'; lprintf("mpegurl pointing to %s\n", buf); - + href = _x_canonicalise_url (this->mrl, buf); free(this->mrl); this->mrl = href; @@ -976,7 +976,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { if (this->is_nsv) { if (!resync_nsv(this)) return -11; - + /* the first 3 chars are "NSV" */ this->preview_size = http_plugin_read_int (this, this->preview + 3, MAX_PREVIEW_SIZE - 3); } else { @@ -987,12 +987,12 @@ static int http_plugin_open (input_plugin_t *this_gen ) { xine_log (this->stream->xine, XINE_LOG_MSG, _("input_http: read error %d\n"), errno); return -12; } - + lprintf("preview_size=%"PRId64"\n", this->preview_size); this->curpos = 0; if (*mime_type) this->mime_type = strdup (mime_type); - + return 1; } @@ -1003,8 +1003,8 @@ static input_plugin_t *http_class_get_instance (input_class_t *cls_gen, xine_str const char *mrl) { /* http_input_class_t *cls = (http_input_class_t *) cls_gen;*/ http_input_plugin_t *this; - - if (strncasecmp (mrl, "http://", 7) && + + if (strncasecmp (mrl, "http://", 7) && strncasecmp (mrl, "unsv://", 7) && strncasecmp (mrl, "peercast://pls/", 15) && !_x_url_user_agent (mrl) /* user agent hacks */) { @@ -1014,14 +1014,14 @@ static input_plugin_t *http_class_get_instance (input_class_t *cls_gen, xine_str if (!strncasecmp (mrl, "peercast://pls/", 15)) { asprintf (&this->mrl, "http://127.0.0.1:7144/stream/%s", mrl+15); - } else { + } else { this->mrl = strdup (mrl); } - + this->stream = stream; this->fh = -1; this->nbc = nbc_init (this->stream); - + this->input_plugin.open = http_plugin_open; this->input_plugin.get_capabilities = http_plugin_get_capabilities; this->input_plugin.read = http_plugin_read; @@ -1040,7 +1040,7 @@ static input_plugin_t *http_class_get_instance (input_class_t *cls_gen, xine_str static void http_class_dispose (input_class_t *this_gen) { http_input_class_t *this = (http_input_class_t *) this_gen; - + free(this->proxyhost_env); free (this); @@ -1065,23 +1065,23 @@ static void *init_class (xine_t *xine, void *data) { this->input_class.dispose = http_class_dispose; this->input_class.eject_media = NULL; - /* - * honour http_proxy envvar + /* + * honour http_proxy envvar */ if((proxy_env = getenv("http_proxy")) && *proxy_env) { int proxy_port = DEFAULT_HTTP_PORT; char *p; - + if(!strncmp(proxy_env, "http://", 7)) proxy_env += 7; this->proxyhost_env = strdup(proxy_env); - + if((p = strrchr(this->proxyhost_env, ':')) && (strlen(p) > 1)) { *p++ = '\0'; proxy_port = (int) strtol(p, &p, 10); } - + this->proxyport_env = proxy_port; } else @@ -1090,7 +1090,7 @@ static void *init_class (xine_t *xine, void *data) { /* * proxy settings */ - this->proxyhost = config->register_string(config, + this->proxyhost = config->register_string(config, "media.network.http_proxy_host", proxy_env ? this->proxyhost_env : "", _("HTTP proxy host"), _("The hostname of the HTTP proxy."), 10, proxy_host_change_cb, (void *) this); @@ -1098,13 +1098,13 @@ static void *init_class (xine_t *xine, void *data) { "media.network.http_proxy_port", proxy_env ? this->proxyport_env : DEFAULT_HTTP_PORT, _("HTTP proxy port"), _("The port number of the HTTP proxy."), 10, proxy_port_change_cb, (void *) this); - + /* registered entries could be empty. Don't ignore envvar */ if(!strlen(this->proxyhost) && (proxy_env && strlen(proxy_env))) { config->update_string(config, "media.network.http_proxy_host", this->proxyhost_env); config->update_num(config, "media.network.http_proxy_port", this->proxyport_env); } - + this->proxyuser = config->register_string(config, "media.network.http_proxy_user", "", _("HTTP proxy username"), _("The user name for the HTTP proxy."), 10, @@ -1117,7 +1117,7 @@ static void *init_class (xine_t *xine, void *data) { "media.network.http_no_proxy", "", _("Domains for which to ignore the HTTP proxy"), _("A comma-separated list of domain names for which the proxy is to be ignored.\nIf a domain name is prefixed with '=' then it is treated as a host name only (full match required)."), 10, no_proxy_list_change_cb, (void *) this); - + return this; } @@ -1126,7 +1126,7 @@ static void *init_class (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "http", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_mms.c b/src/input/input_mms.c index 191d1aed0..ec921e106 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2002-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -76,26 +76,26 @@ typedef struct { char *mrl; - nbc_t *nbc; + nbc_t *nbc; char scratch[1025]; int bandwidth; int protocol; /* mmst or mmsh */ - + } mms_input_plugin_t; typedef struct { input_class_t input_class; - + mms_input_plugin_t *ip; int protocol; /* autoprobe, mmst or mmsh */ xine_t *xine; } mms_input_class_t; -static off_t mms_plugin_read (input_plugin_t *this_gen, +static off_t mms_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; char *buf = (char *)buf_gen; @@ -132,7 +132,7 @@ static buf_element_t *mms_plugin_read_block (input_plugin_t *this_gen, buf->content = buf->mem; buf->type = BUF_DEMUX_BLOCK; - + total_bytes = mms_plugin_read (this_gen, (char*)buf->content, todo); if (total_bytes != todo) { @@ -146,7 +146,7 @@ static buf_element_t *mms_plugin_read_block (input_plugin_t *this_gen, } static off_t mms_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { - mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; + mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; off_t dest = 0; off_t curpos = 0; @@ -161,7 +161,7 @@ static off_t mms_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin curpos = mmsh_get_current_pos (this->mmsh); break; } - + switch (origin) { case SEEK_SET: dest = offset; @@ -178,7 +178,7 @@ static off_t mms_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin printf ("input_mms: cannot seek back!\n"); return curpos; } - + while (curpos < dest) { int n = 0; int diff; @@ -196,7 +196,7 @@ static off_t mms_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin n = mmsh_read (this->mmsh, this->scratch, diff); break; } - + curpos += n; if (n < diff) @@ -212,7 +212,7 @@ static off_t mms_plugin_seek_time (input_plugin_t *this_gen, int time_offset, in off_t curpos = 0; lprintf ("seek_time %d msec, origin %d\n", time_offset, origin); - + switch (this->protocol) { case PROTOCOL_MMST: if (origin == SEEK_SET) @@ -225,12 +225,12 @@ static off_t mms_plugin_seek_time (input_plugin_t *this_gen, int time_offset, in curpos = mmsh_get_current_pos (this->mmsh); break; } - + return curpos; } static off_t mms_plugin_get_length (input_plugin_t *this_gen) { - mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; + mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; off_t length = 0; if (!this->mms) @@ -262,7 +262,7 @@ static uint32_t mms_plugin_get_blocksize (input_plugin_t *this_gen) { static off_t mms_plugin_get_current_pos (input_plugin_t *this_gen){ mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; off_t curpos = 0; - + switch (this->protocol) { case PROTOCOL_MMST: curpos = mms_get_current_pos(this->mms); @@ -280,10 +280,10 @@ static void mms_plugin_dispose (input_plugin_t *this_gen) { if (this->mms) mms_close (this->mms); - + if (this->mmsh) mmsh_close (this->mmsh); - + this->mms = NULL; this->mmsh = NULL; @@ -291,7 +291,7 @@ static void mms_plugin_dispose (input_plugin_t *this_gen) { nbc_close (this->nbc); this->nbc = NULL; } - + free(this->mrl); free (this); } @@ -302,7 +302,7 @@ static const char* mms_plugin_get_mrl (input_plugin_t *this_gen) { return this->mrl; } -static int mms_plugin_get_optional_data (input_plugin_t *this_gen, +static int mms_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; @@ -318,7 +318,7 @@ static int mms_plugin_get_optional_data (input_plugin_t *this_gen, break; } break; - + default: return INPUT_OPTIONAL_UNSUPPORTED; break; @@ -356,7 +356,7 @@ static int mms_plugin_open (input_plugin_t *this_gen) { mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; mms_t *mms = NULL; mmsh_t *mmsh = NULL; - + switch (this->protocol) { case PROTOCOL_UNDEFINED: mms = mms_connect (this->stream, this->mrl, this->bandwidth); @@ -374,18 +374,18 @@ static int mms_plugin_open (input_plugin_t *this_gen) { mmsh = mmsh_connect (this->stream, this->mrl, this->bandwidth); break; } - + if (!mms && !mmsh) { return 0; } - + this->mms = mms; this->mmsh = mmsh; - + return 1; } -static input_plugin_t *mms_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, +static input_plugin_t *mms_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data) { mms_input_class_t *cls = (mms_input_class_t *) cls_gen; @@ -393,7 +393,7 @@ static input_plugin_t *mms_class_get_instance (input_class_t *cls_gen, xine_stre char *mrl = strdup(data); xine_cfg_entry_t bandwidth_entry; int protocol; - + lprintf ("trying to open '%s'\n", mrl); if (!strncasecmp (mrl, "mms://", 6)) { @@ -413,10 +413,10 @@ static input_plugin_t *mms_class_get_instance (input_class_t *cls_gen, xine_stre this->mms = NULL; this->mmsh = NULL; this->protocol = protocol; - this->mrl = mrl; + this->mrl = mrl; this->nbc = nbc_init (this->stream); - if (xine_config_lookup_entry (stream->xine, "media.network.bandwidth", + if (xine_config_lookup_entry (stream->xine, "media.network.bandwidth", &bandwidth_entry)) { bandwidth_changed_cb(cls, &bandwidth_entry); } @@ -435,7 +435,7 @@ static input_plugin_t *mms_class_get_instance (input_class_t *cls_gen, xine_stre this->input_plugin.get_optional_data = mms_plugin_get_optional_data; this->input_plugin.input_class = cls_gen; - + return &this->input_plugin; } @@ -447,7 +447,7 @@ static void mms_class_dispose (input_class_t *this_gen) { mms_input_class_t *this = (mms_input_class_t *) this_gen; this->xine->config->unregister_callback(this->xine->config, - "media.network.bandwidth"); + "media.network.bandwidth"); this->xine->config->unregister_callback(this->xine->config, "media.network.mms_protocol"); free (this); @@ -479,12 +479,12 @@ static void *init_class (xine_t *xine, void *data) { 0, bandwidth_changed_cb, (void*) this); this->protocol = xine->config->register_enum(xine->config, - "media.network.mms_protocol", - 0, - mms_protocol_strs, + "media.network.mms_protocol", + 0, + mms_protocol_strs, _("MMS protocol"), _("Select the protocol to encapsulate MMS.\nTCP is better but you may need HTTP behind a firewall."), - 20, + 20, protocol_changed_cb, (void*)this); return this; @@ -495,7 +495,7 @@ static void *init_class (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "mms", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_net.c b/src/input/input_net.c index a052d5650..5007b58a3 100644 --- a/src/input/input_net.c +++ b/src/input/input_net.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -21,9 +21,9 @@ * other end and you can watch tv anywhere in the house ..) * * how to set up mp1e for use with this plugin: - * + * * use mp1 to capture the live stream, e.g. - * mp1e -b 1200 -R 4,32 -a 0 -B 160 -v >live.mpg + * mp1e -b 1200 -R 4,32 -a 0 -B 160 -v >live.mpg * * add an extra service "xine" to /etc/services and /etc/inetd.conf, e.g.: * /etc/services: @@ -78,11 +78,11 @@ typedef struct { input_plugin_t input_plugin; xine_stream_t *stream; - + int fh; char *mrl; char *host_port; - + char preview[MAX_PREVIEW_SIZE]; off_t preview_size; @@ -122,21 +122,21 @@ static int host_connect_attempt_ipv4(struct in_addr ia, int port, xine_t *xine) return -1; } - sin.sin_family = AF_INET; + sin.sin_family = AF_INET; sin.sin_addr = ia; sin.sin_port = htons(port); - + #ifndef WIN32 - if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && errno != EINPROGRESS) + if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && errno != EINPROGRESS) #else - if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && WSAGetLastError() != WSAEINPROGRESS) + if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && WSAGetLastError() != WSAEINPROGRESS) #endif { xine_log(xine, XINE_LOG_MSG, _("input_net: connect(): %s\n"), strerror(errno)); close(s); return -1; - } + } return s; } @@ -144,7 +144,7 @@ static int host_connect_attempt_ipv4(struct in_addr ia, int port, xine_t *xine) static int host_connect_attempt(int family, struct sockaddr* sin, int addrlen, xine_t *xine) { int s; - + s = socket(family, SOCK_STREAM, IPPROTO_TCP); if (s==-1) { xine_log(xine, XINE_LOG_MSG, @@ -153,16 +153,16 @@ static int host_connect_attempt(int family, struct sockaddr* sin, int addrlen, x } #ifndef WIN32 - if (connect(s, sin, addrlen)==-1 && errno != EINPROGRESS) + if (connect(s, sin, addrlen)==-1 && errno != EINPROGRESS) #else - if (connect(s, sin, addrlen)==-1 && WSAGetLastError() != WSAEINPROGRESS) + if (connect(s, sin, addrlen)==-1 && WSAGetLastError() != WSAEINPROGRESS) #endif { xine_log(xine, XINE_LOG_MSG, _("input_net: connect(): %s\n"), strerror(errno)); close(s); return -1; - } + } return s; } @@ -173,14 +173,14 @@ static int host_connect_ipv4(const char *host, int port, xine_t *xine) { struct hostent *h; int i; int s; - + h = gethostbyname(host); if (h==NULL) { xine_log(xine, XINE_LOG_MSG, _("input_net: unable to resolve '%s'.\n"), host); return -1; } - + for (i=0; h->h_addr_list[i]; i++) { struct in_addr ia; memcpy (&ia, h->h_addr_list[i],4); @@ -205,36 +205,36 @@ static int host_connect(const char *host, int port, xine_t *xine) { int error; char strport[16]; int s; - + memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; - hints.ai_family = PF_UNSPEC; - + hints.ai_family = PF_UNSPEC; + snprintf(strport, sizeof(strport), "%d", port); lprintf("Resolving host '%s' at port '%s'\n", host, strport); error = getaddrinfo(host, strport, &hints, &res); - + if (error) { - + xine_log(xine, XINE_LOG_MSG, _("input_net: unable to resolve '%s'.\n"), host); return -1; } - + /* We loop over all addresses and try to connect */ tmpaddr = res; while (tmpaddr) { - - s = host_connect_attempt (tmpaddr->ai_family, + + s = host_connect_attempt (tmpaddr->ai_family, tmpaddr->ai_addr, tmpaddr->ai_addrlen, xine); if (s != -1) return s; tmpaddr = tmpaddr->ai_next; } - + xine_log(xine, XINE_LOG_MSG, _("input_net: unable to connect to '%s'.\n"), host); return -1; @@ -246,7 +246,7 @@ static int host_connect(const char *host, int port, xine_t *xine) { #define LOW_WATER_MARK 50 #define HIGH_WATER_MARK 100 -static off_t net_plugin_read (input_plugin_t *this_gen, +static off_t net_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { net_input_plugin_t *this = (net_input_plugin_t *) this_gen; char *buf = (char *)buf_gen; @@ -274,7 +274,7 @@ static off_t net_plugin_read (input_plugin_t *this_gen, n = _x_read_abort (this->stream, this->fh, &buf[total], len-total); xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_net: got %" PRIdMAX " bytes (%" PRIdMAX "/%" PRIdMAX " bytes read)\n", (intmax_t)n, (intmax_t)total, (intmax_t)len); - + if (n < 0) { _x_message(this->stream, XINE_MSG_READ_ERROR, this->host_port, NULL); return 0; @@ -286,7 +286,7 @@ static off_t net_plugin_read (input_plugin_t *this_gen, return total; } -static buf_element_t *net_plugin_read_block (input_plugin_t *this_gen, +static buf_element_t *net_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo) { /* net_input_plugin_t *this = (net_input_plugin_t *) this_gen; */ buf_element_t *buf = fifo->buffer_pool_alloc (fifo); @@ -301,7 +301,7 @@ static buf_element_t *net_plugin_read_block (input_plugin_t *this_gen, buf->content = buf->mem; buf->type = BUF_DEMUX_BLOCK; - + total_bytes = net_plugin_read (this_gen, (char*)buf->content, todo); if (total_bytes != todo) { @@ -382,7 +382,7 @@ static const char* net_plugin_get_mrl (input_plugin_t *this_gen) { return this->mrl; } -static int net_plugin_get_optional_data (input_plugin_t *this_gen, +static int net_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { net_input_plugin_t *this = (net_input_plugin_t *) this_gen; @@ -405,10 +405,10 @@ static void net_plugin_dispose (input_plugin_t *this_gen ) { close(this->fh); this->fh = -1; } - + free (this->mrl); free (this->host_port); - + if (this->nbc) { nbc_close (this->nbc); this->nbc = NULL; @@ -465,28 +465,28 @@ static input_plugin_t *net_class_get_instance (input_class_t *cls_gen, xine_stre if (!strncasecmp (mrl, "tcp://", 6)) { filename = (char *) &mrl[6]; - + if((!filename) || (strlen(filename) == 0)) { return NULL; } - + nbc = nbc_init (stream); - + } else if (!strncasecmp (mrl, "slave://", 8)) { - + filename = (char *) &mrl[8]; - + if((!filename) || (strlen(filename) == 0)) { return NULL; } - + /* the only difference for slave:// is that network buffering control * is not used. otherwise, dvd still menus are not displayed (it freezes * with "buffering..." all the time) */ - + nbc = NULL; - + } else { return NULL; } @@ -520,7 +520,7 @@ static input_plugin_t *net_class_get_instance (input_class_t *cls_gen, xine_stre /* * net plugin class */ - + static void *init_class (xine_t *xine, void *data) { net_input_class_t *this; @@ -545,7 +545,7 @@ static void *init_class (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT, 18, "tcp", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c index 718473819..2ee46768b 100644 --- a/src/input/input_pnm.c +++ b/src/input/input_pnm.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2002-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -61,21 +61,21 @@ typedef struct { input_plugin_t input_plugin; xine_stream_t *stream; - + pnm_t *pnm; char *mrl; off_t curpos; - nbc_t *nbc; + nbc_t *nbc; char scratch[BUFSIZE]; } pnm_input_plugin_t; -static off_t pnm_plugin_read (input_plugin_t *this_gen, +static off_t pnm_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen; char *buf = (char *)buf_gen; @@ -90,7 +90,7 @@ static off_t pnm_plugin_read (input_plugin_t *this_gen, return n; } -static buf_element_t *pnm_plugin_read_block (input_plugin_t *this_gen, +static buf_element_t *pnm_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo) { /*pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen; */ buf_element_t *buf = fifo->buffer_pool_alloc (fifo); @@ -107,7 +107,7 @@ static buf_element_t *pnm_plugin_read_block (input_plugin_t *this_gen, buf->content = buf->mem; buf->type = BUF_DEMUX_BLOCK; - + total_bytes = pnm_plugin_read (this_gen, (char*)buf->content, todo); if (total_bytes != todo) { @@ -150,7 +150,7 @@ static off_t pnm_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin static off_t pnm_plugin_get_length (input_plugin_t *this_gen) { /* - pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen; + pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen; off_t length; */ @@ -187,10 +187,10 @@ static void pnm_plugin_dispose (input_plugin_t *this_gen) { nbc_close (this->nbc); this->nbc = NULL; } - + if(this->mrl) free(this->mrl); - + free (this); } @@ -200,7 +200,7 @@ static const char* pnm_plugin_get_mrl (input_plugin_t *this_gen) { return this->mrl; } -static int pnm_plugin_get_optional_data (input_plugin_t *this_gen, +static int pnm_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen; @@ -228,11 +228,11 @@ static int pnm_plugin_open (input_plugin_t *this_gen) { } this->pnm = pnm; - + return 1; } -static input_plugin_t *pnm_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, +static input_plugin_t *pnm_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data) { /* pnm_input_class_t *cls = (pnm_input_class_t *) cls_gen; */ @@ -248,9 +248,9 @@ static input_plugin_t *pnm_class_get_instance (input_class_t *cls_gen, xine_stre this->stream = stream; this->pnm = NULL; - this->mrl = mrl; + this->mrl = mrl; this->nbc = nbc_init (this->stream); - + this->input_plugin.open = pnm_plugin_open; this->input_plugin.get_capabilities = pnm_plugin_get_capabilities; this->input_plugin.read = pnm_plugin_read; @@ -263,7 +263,7 @@ static input_plugin_t *pnm_class_get_instance (input_class_t *cls_gen, xine_stre this->input_plugin.dispose = pnm_plugin_dispose; this->input_plugin.get_optional_data = pnm_plugin_get_optional_data; this->input_plugin.input_class = cls_gen; - + return &this->input_plugin; } @@ -295,7 +295,7 @@ static void *init_class (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT, 18, "pnm", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c index 07f5d955d..813ec4c1e 100644 --- a/src/input/input_pvr.c +++ b/src/input/input_pvr.c @@ -4,17 +4,17 @@ * This plugin was sponsored by 1Control * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -32,26 +32,26 @@ * - audio.synchronization.av_sync_method=resample * - ivtv driver (01 Jul 2003 cvs is known to work) * - * MRL: + * MRL: * pvr:/<prefix_to_tmp_files>!<prefix_to_saved_files>!<max_page_age> * - * usage: + * usage: * xine pvr:/<prefix_to_tmp_files>\!<prefix_to_saved_files>\!<max_page_age> */ /************************************************************************** - + Programmer's note (or how to write your PVR frontend): - + - in order to use live pause functionality you must capture data to disk. this is done using XINE_EVENT_SET_V4L2 event. it is important to set the inputs/channel/frequency you want to capture data from. - + comments: 1) session_id must be set: it is used to create the temporary filenames. - + 2) if session_id = -1 no data will be recorded to disk (no pause/replay) - + 3) if session_id is the same as previous value it will just set the "sync point". sync point (show_page) may be used by the PVR frontend to tell that a new show has began. of course, the PVR frontend should be aware @@ -60,18 +60,18 @@ - when user wants to start recording (that is: temporary data will be made permanent) it should issue a XINE_EVENT_PVR_SAVE. mode can be one of the following: - + -1 = do nothing, just set the name (see below) 0 = truncate current session and save from now on 1 = save from last sync point 2 = save everything on current session - + saving actually means just marking the current pages as not temporary. when a session is finished, instead of erasing the files they will be renamed using the save file prefix. - the permanent name can be set in two ways: - + 1) passing a name with the XINE_EVENT_PVR_SAVE before closing the current session. (id = -1) 2) when a saved session is closed without setting the name, it will be @@ -81,7 +81,7 @@ pass back a XINE_EVENT_PVR_SAVE with id set. pvr plugin will rename the files again. -***************************************************************************/ +***************************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -167,7 +167,7 @@ typedef struct { config_values_t *config; char *devname; - + } pvr_input_class_t; @@ -175,18 +175,18 @@ typedef struct { input_plugin_t input_plugin; pvr_input_class_t *class; - + xine_stream_t *stream; - + xine_event_queue_t *event_queue; - + pvrscr_t *scr; int scr_tunning; int speed_before_pause; - + uint32_t session; /* session number used to identify the pvr file */ int new_session; /* force going to realtime for new sessions */ - + int dev_fd; /* fd of the mpeg2 encoder device */ int rec_fd; /* fd of the current recording file (session/page) */ int play_fd; /* fd of the current playback (-1 when realtime) */ @@ -200,22 +200,22 @@ typedef struct { uint32_t show_page; /* first page of current show */ uint32_t save_page; /* first page to save */ uint32_t page_block[MAX_PAGES]; /* first block of each page */ - + char *mrl; char *tmp_prefix; char *save_prefix; char *save_name; xine_list_t *saved_shows; int saved_id; - + time_t start_time; /* time when recording started */ time_t show_time; /* time when current show started */ - + /* buffer to pass data from pvr thread to xine */ uint8_t data[PVR_BLOCK_SIZE]; int valid_data; int want_data; - + pthread_mutex_t lock; pthread_mutex_t dev_lock; pthread_cond_t has_valid_data; @@ -224,14 +224,14 @@ typedef struct { int pvr_running; int pvr_playing; int pvr_play_paused; - + int preview_buffers; - + /* device properties */ int input; int channel; - uint32_t frequency; - + uint32_t frequency; + } pvr_input_plugin_t; typedef struct { @@ -245,7 +245,7 @@ typedef struct { * unix System Clock Reference + fine tunning * * on an ideal world we would be using scr from mpeg2 - * encoder just like dxr3 does. + * encoder just like dxr3 does. * unfortunately it is not supported by ivtv driver, * and perhaps not even possible with wintv cards. * @@ -279,19 +279,19 @@ static void pvrscr_set_pivot (pvrscr_t *this) { struct timeval tv; int64_t pts; - double pts_calc; + double pts_calc; xine_monotonic_clock(&tv, NULL); pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; pts = this->cur_pts + pts_calc; -/* This next part introduces a one off inaccuracy - * to the scr due to rounding tv to pts. +/* This next part introduces a one off inaccuracy + * to the scr due to rounding tv to pts. */ this->cur_time.tv_sec=tv.tv_sec; this->cur_time.tv_usec=tv.tv_usec; - this->cur_pts=pts; + this->cur_pts=pts; return ; } @@ -303,7 +303,7 @@ static int pvrscr_set_speed (scr_plugin_t *scr, int speed) { pvrscr_set_pivot( this ); this->xine_speed = speed; - this->speed_factor = (double) speed * 90000.0 / XINE_FINE_SPEED_NORMAL * + this->speed_factor = (double) speed * 90000.0 / XINE_FINE_SPEED_NORMAL * this->speed_tunning; pthread_mutex_unlock (&this->lock); @@ -316,7 +316,7 @@ static void pvrscr_speed_tunning (pvrscr_t *this, double factor) { pvrscr_set_pivot( this ); this->speed_tunning = factor; - this->speed_factor = (double) this->xine_speed * 90000.0 / XINE_FINE_SPEED_NORMAL * + this->speed_factor = (double) this->xine_speed * 90000.0 / XINE_FINE_SPEED_NORMAL * this->speed_tunning; pthread_mutex_unlock (&this->lock); @@ -345,7 +345,7 @@ static void pvrscr_start (scr_plugin_t *scr, int64_t start_vpts) { this->cur_pts = start_vpts; pthread_mutex_unlock (&this->lock); - + pvrscr_set_speed (&this->scr, XINE_FINE_SPEED_NORMAL); } @@ -354,16 +354,16 @@ static int64_t pvrscr_get_current (scr_plugin_t *scr) { struct timeval tv; int64_t pts; - double pts_calc; + double pts_calc; pthread_mutex_lock (&this->lock); xine_monotonic_clock(&tv, NULL); - + pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; pts = this->cur_pts + pts_calc; - + pthread_mutex_unlock (&this->lock); return pts; @@ -388,9 +388,9 @@ static pvrscr_t *XINE_MALLOC pvrscr_init (void) { this->scr.start = pvrscr_start; this->scr.get_current = pvrscr_get_current; this->scr.exit = pvrscr_exit; - + pthread_mutex_init (&this->lock, NULL); - + pvrscr_speed_tunning(this, 1.0 ); pvrscr_set_speed (&this->scr, XINE_SPEED_PAUSE); #ifdef SCRLOG @@ -405,10 +405,10 @@ static pvrscr_t *XINE_MALLOC pvrscr_init (void) { static uint32_t block_to_page(pvr_input_plugin_t *this, uint32_t block) { uint32_t page; - + for( page = 0; page < this->rec_page; page++ ) { if( block < this->page_block[page+1] ) - break; + break; } return page; } @@ -437,7 +437,7 @@ static off_t pvr_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len } -/* +/* * this function will adjust playback speed to control buffer utilization. * we must avoid: * - overflow: buffer runs full. no data is read from the mpeg2 card so it will discard @@ -448,15 +448,15 @@ static off_t pvr_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len * OBS: use with audio.synchronization.av_sync_method=resample */ static void pvr_adjust_realtime_speed(pvr_input_plugin_t *this, fifo_buffer_t *fifo, int speed ) { - + int num_used, num_free; int scr_tunning = this->scr_tunning; - + num_used = fifo->size(fifo); num_free = fifo->num_free(fifo); - + if( num_used == 0 && scr_tunning != -2 ) { - + /* buffer is empty. pause it for a while */ this->scr_tunning = -2; /* marked as paused */ pvrscr_speed_tunning(this->scr, 1.0); @@ -465,44 +465,44 @@ static void pvr_adjust_realtime_speed(pvr_input_plugin_t *this, fifo_buffer_t *f #ifdef SCRLOG printf("input_pvr: buffer empty, pausing playback\n" ); #endif - + } else if( scr_tunning == -2 ) { - + /* currently paused, revert to normal if 1/3 full */ if( 2*num_used > num_free ) { this->scr_tunning = 0; - + pvrscr_speed_tunning(this->scr, 1.0 ); _x_set_speed(this->stream, this->speed_before_pause); #ifdef SCRLOG printf("input_pvr: resuming playback\n" ); #endif } - + } else if( speed == XINE_SPEED_NORMAL && this->play_fd == -1 ) { - + /* when playing realtime, adjust the scr to make xine buffers half full */ if( num_used > 2*num_free ) - scr_tunning = +1; /* play faster */ + scr_tunning = +1; /* play faster */ else if( num_free > 2*num_used ) scr_tunning = -1; /* play slower */ else if( (scr_tunning > 0 && num_free > num_used) || (scr_tunning < 0 && num_used > num_free) ) scr_tunning = 0; - + if( scr_tunning != this->scr_tunning ) { this->scr_tunning = scr_tunning; #ifdef SCRLOG printf("input_pvr: scr_tunning = %d (used: %d free: %d)\n", scr_tunning, num_used, num_free ); #endif - + /* make it play .5% faster or slower */ pvrscr_speed_tunning(this->scr, 1.0 + (0.005 * scr_tunning) ); } - + } else if( this->scr_tunning ) { this->scr_tunning = 0; - + pvrscr_speed_tunning(this->scr, 1.0 ); } } @@ -511,21 +511,21 @@ static void pvr_adjust_realtime_speed(pvr_input_plugin_t *this, fifo_buffer_t *f static char *make_temp_name(pvr_input_plugin_t *this, int page) { char *filename; - + asprintf(&filename, PVR_FILENAME, this->tmp_prefix, this->session, page); - + return filename; } - + #define SAVE_BASE_FILENAME "ch%03d %02d-%02d-%04d %02d:%02d:%02d" - + static char *make_base_save_name(int channel, time_t tm) { struct tm rec_time; char *filename; - + localtime_r(&tm, &rec_time); - - asprintf(&filename, SAVE_BASE_FILENAME, + + asprintf(&filename, SAVE_BASE_FILENAME, channel, rec_time.tm_mon+1, rec_time.tm_mday, rec_time.tm_year+1900, rec_time.tm_hour, rec_time.tm_min, rec_time.tm_sec); @@ -536,9 +536,9 @@ static char *make_base_save_name(int channel, time_t tm) { static char *make_save_name(pvr_input_plugin_t *this, char *base, int page) { char *filename; - + asprintf(&filename, SAVE_FILENAME, this->save_prefix, base, page); - + return filename; } @@ -563,27 +563,27 @@ static void pvr_report_realtime (pvr_input_plugin_t *this, int mode) { * close current recording page and open a new one */ static int pvr_break_rec_page (pvr_input_plugin_t *this) { - + char *filename; - + if( this->session == (unsigned)-1 ) /* not recording */ return 1; - + if( this->rec_fd != -1 && this->rec_fd != this->play_fd ) { - close(this->rec_fd); + close(this->rec_fd); } - + if( this->rec_fd == -1 ) this->rec_page = 0; else this->rec_page++; - + this->page_block[this->rec_page] = this->rec_blk; - + filename = make_temp_name(this, this->rec_page); - + lprintf("opening pvr file for writing (%s)\n", filename); - + this->rec_fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0666 ); if( this->rec_fd == -1 ) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, @@ -592,39 +592,39 @@ static int pvr_break_rec_page (pvr_input_plugin_t *this) { return 0; } free(filename); - + /* erase first_page if old and not to be saved */ - if( this->max_page_age != (unsigned)-1 && + if( this->max_page_age != (unsigned)-1 && this->rec_page - this->max_page_age == this->first_page && (this->save_page == (unsigned)-1 || this->first_page < this->save_page) ) { - + filename = make_temp_name(this, this->first_page); lprintf("erasing old pvr file (%s)\n", filename); - + this->first_page++; if(this->play_fd != -1 && this->play_page < this->first_page) { this->play_blk = this->page_block[this->first_page]; close(this->play_fd); this->play_fd = -1; } - + remove(filename); free(filename); - } + } return 1; } /* - * check the status of recording file, open new one as needed and write the current data. + * check the status of recording file, open new one as needed and write the current data. */ static int pvr_rec_file(pvr_input_plugin_t *this) { - + off_t pos; if( this->session == (unsigned)-1 ) /* not recording */ return 1; - + /* check if it's time to change page/file */ if( this->rec_fd == -1 || (this->rec_blk - this->page_block[this->rec_page]) >= BLOCKS_PER_PAGE ) { if( !pvr_break_rec_page(this) ) @@ -632,61 +632,61 @@ static int pvr_rec_file(pvr_input_plugin_t *this) { } pos = (off_t)(this->rec_blk - this->page_block[this->rec_page]) * PVR_BLOCK_SIZE; if( lseek (this->rec_fd, pos, SEEK_SET) != pos ) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: error setting position for writing %" PRIdMAX "\n", (intmax_t)pos); return 0; } if( this->rec_fd != -1 ) { if( write(this->rec_fd, this->data, PVR_BLOCK_SIZE) < PVR_BLOCK_SIZE ) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: short write to pvr file (out of disk space?)\n"); return 0; } this->rec_blk++; } - + return 1; } -/* +/* * check for playback mode, switching realtime <-> non-realtime. * gets data from file in non-realtime mode. */ static int pvr_play_file(pvr_input_plugin_t *this, fifo_buffer_t *fifo, uint8_t *buffer, int speed) { - + off_t pos; - + /* check for realtime. don't switch back unless enough buffers are * free to not block the pvr thread */ if( this->new_session || (this->play_blk+1 >= this->rec_blk && speed >= XINE_SPEED_NORMAL && (this->play_fd == -1 || fifo->size(fifo) < fifo->num_free(fifo))) ) { - + this->play_blk = (this->rec_blk) ? (this->rec_blk-1) : 0; - + if( speed > XINE_SPEED_NORMAL ) _x_set_speed(this->stream, XINE_SPEED_NORMAL); - + if( this->play_fd != -1 ) { if(this->play_fd != this->rec_fd ) - close(this->play_fd); + close(this->play_fd); this->play_fd = -1; - + lprintf("switching back to realtime\n"); pvr_report_realtime(this,1); - + } else if (this->new_session) { lprintf("starting new session in realtime\n"); pvr_report_realtime(this,1); } - + this->want_data = 1; this->new_session = 0; - + } else { - if( this->rec_fd == -1 ) + if( this->rec_fd == -1 ) return 1; if(speed != XINE_SPEED_PAUSE) { @@ -700,30 +700,30 @@ static int pvr_play_file(pvr_input_plugin_t *this, fifo_buffer_t *fifo, uint8_t } } - if( this->play_fd == -1 || + if( this->play_fd == -1 || ((this->play_blk - this->page_block[this->play_page]) >= BLOCKS_PER_PAGE) || (this->rec_page > this->play_page && this->play_blk >= this->page_block[this->play_page+1]) ) { - + if(this->play_fd == -1) { lprintf("switching to non-realtime\n"); pvr_report_realtime(this,0); } - + if( this->play_fd != -1 && this->play_fd != this->rec_fd ) { - close(this->play_fd); + close(this->play_fd); } - + if( this->play_fd == -1 ) this->play_page = block_to_page(this, this->play_blk); else this->play_page++; - + if( this->play_page < this->first_page ) { this->play_page = this->first_page; this->play_blk = this->page_block[this->play_page]; } - + /* should be impossible */ if( this->play_page > this->rec_page || this->play_blk > this->rec_blk ) { @@ -736,11 +736,11 @@ static int pvr_play_file(pvr_input_plugin_t *this, fifo_buffer_t *fifo, uint8_t this->play_fd = this->rec_fd; } else { char *filename; - + filename = make_temp_name(this, this->play_page); lprintf("opening pvr file for reading (%s)\n", filename); - + this->play_fd = open(filename, O_RDONLY ); if( this->play_fd == -1 ) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, @@ -753,7 +753,7 @@ static int pvr_play_file(pvr_input_plugin_t *this, fifo_buffer_t *fifo, uint8_t this->want_data = 0; pthread_cond_signal (&this->wake_pvr); } - + if(speed != XINE_SPEED_PAUSE) { pos = (off_t)(this->play_blk - this->page_block[this->play_page]) * PVR_BLOCK_SIZE; @@ -804,29 +804,29 @@ static void *pvr_loop (void *this_gen) { int lost_sync; while( this->pvr_running ) { - + pthread_mutex_lock(&this->lock); this->valid_data = 0; pthread_mutex_unlock(&this->lock); - + total_bytes = 0; do { - + lost_sync = 0; - + pthread_mutex_lock(&this->dev_lock); while (total_bytes < PVR_BLOCK_SIZE) { num_bytes = read (this->dev_fd, this->data + total_bytes, PVR_BLOCK_SIZE-total_bytes); if (num_bytes <= 0) { - if (num_bytes < 0) + if (num_bytes < 0) xprintf (this->stream->xine, XINE_VERBOSITY_LOG, _("input_pvr: read error (%s)\n"), strerror(errno)); - this->pvr_running = 0; + this->pvr_running = 0; break; } total_bytes += num_bytes; } - + if( this->data[0] || this->data[1] || this->data[2] != 1 || this->data[3] != 0xba ) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "resyncing mpeg stream\n"); @@ -837,28 +837,28 @@ static void *pvr_loop (void *this_gen) { this->data[0] = 0; this->data[1] = 0; this->data[2] = 1; this->data[3] = 0xba; total_bytes = 4; } - } + } pthread_mutex_unlock(&this->dev_lock); - - } while( lost_sync ); - + + } while( lost_sync ); + pthread_mutex_lock(&this->lock); - + if( !pvr_rec_file(this) ) { - this->pvr_running = 0; + this->pvr_running = 0; } - + this->valid_data = 1; pthread_cond_signal (&this->has_valid_data); - while(this->valid_data && this->play_fd == -1 && + while(this->valid_data && this->play_fd == -1 && this->want_data && this->pvr_playing) { pthread_cond_wait (&this->wake_pvr, &this->lock); } - + pthread_mutex_unlock(&this->lock); } - + pthread_exit(NULL); } @@ -869,7 +869,7 @@ static void *pvr_loop (void *this_gen) { * name (save_name) or a default one using channel and time. */ static void pvr_finish_recording (pvr_input_plugin_t *this) { - + char *src_filename; char *save_base; char *dst_filename; @@ -878,31 +878,31 @@ static void pvr_finish_recording (pvr_input_plugin_t *this) { lprintf("finish_recording\n"); if( this->rec_fd != -1 ) { - close(this->rec_fd); - + close(this->rec_fd); + if( this->play_fd != -1 && this->play_fd != this->rec_fd ) close(this->play_fd); - + this->rec_fd = this->play_fd = -1; - + if( this->save_page == this->show_page ) save_base = make_base_save_name(this->channel, this->show_time); else save_base = make_base_save_name(this->channel, this->start_time); - + for( i = this->first_page; i <= this->rec_page; i++ ) { - + src_filename = make_temp_name(this, i); - + if( this->save_page == (unsigned)-1 || i < this->save_page ) { lprintf("erasing old pvr file (%s)\n", src_filename); remove(src_filename); } else { - + if( !this->save_name || !strlen(this->save_name) ) dst_filename = make_save_name(this, save_base, i-this->save_page+1); - else + else dst_filename = make_save_name(this, this->save_name, i-this->save_page+1); lprintf("moving (%s) to (%s)\n", src_filename, dst_filename); @@ -912,17 +912,17 @@ static void pvr_finish_recording (pvr_input_plugin_t *this) { } free(src_filename); } - + if( this->save_page != (unsigned)-1 && (!this->save_name || !strlen(this->save_name)) ) { saved_show_t *show = malloc(sizeof(saved_show_t)); xine_event_t event; xine_pvr_save_data_t data; - + show->base_name = save_base; show->id = ++this->saved_id; show->pages = this->rec_page - this->save_page + 1; xine_list_push_back (this->saved_shows, show); - + lprintf("sending event with base name [%s]\n", show->base_name); /* tell frontend the name of the saved show */ @@ -931,18 +931,18 @@ static void pvr_finish_recording (pvr_input_plugin_t *this) { event.data = &data; event.data_length = sizeof(data); gettimeofday(&event.tv, NULL); - + data.mode = 0; data.id = show->id; strncpy(data.name, show->base_name, sizeof(data.name)); data.name[sizeof(data.name) - 1] = '\0'; - + xine_event_send(this->stream, &event); } else { free(save_base); } } - + this->first_page = 0; this->show_page = 0; this->save_page = -1; @@ -1017,13 +1017,13 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { if( ioctl(this->dev_fd, VIDIOC_S_INPUT, &this->input) == 0 ) { lprintf("Tuner Input set to:%d\n", v4l2_data->input); } else { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: error setting v4l2 input\n"); } } } - /* change channel */ + /* change channel */ if (v4l2_data->channel != -1 && v4l2_data->channel != this->channel) { lprintf("change channel to:%d\n", v4l2_data->channel); this->channel = v4l2_data->channel; @@ -1058,13 +1058,13 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { } pthread_mutex_unlock(&this->dev_lock); - + /* FIXME: also flush the device */ /* _x_demux_flush_engine(this->stream); */ break; - - + + case XINE_EVENT_PVR_SAVE: if( this->session != -1 ) { switch( save_data->mode ) { @@ -1097,11 +1097,11 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { if( this->save_name ) free( this->save_name ); this->save_name = NULL; - + if( save_data->id < 0 ) { /* no id: set name for current recording */ this->save_name = strdup(save_data->name); - + } else { /* search for the ID of saved shows and rename it * to the given name. */ @@ -1109,17 +1109,17 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { char *dst_filename; saved_show_t *show; xine_list_iterator_t ite; - + pthread_mutex_lock(&this->lock); - + ite = xine_list_front (this->saved_shows); while (ite) { show = xine_list_get_value(this->saved_shows, ite); if( show->id == save_data->id ) { int i; - + for( i = 0; i < show->pages; i++ ) { - + src_filename = make_save_name(this, show->base_name, i+1); dst_filename = make_save_name(this, save_data->name, i+1); @@ -1151,7 +1151,7 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { case XINE_EVENT_SET_MPEG_DATA: { struct ivtv_ioctl_codec codec; - + pthread_mutex_lock(&this->dev_lock); /* how lame. we must close and reopen to change bitrate. */ @@ -1162,9 +1162,9 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { _("input_pvr: error opening device %s\n"), this->class->devname ); return; } - + if (ioctl(this->dev_fd, IVTV_IOC_G_CODEC, &codec) < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("input_pvr: IVTV_IOC_G_CODEC failed, maybe API changed?\n")); } else { codec.bitrate = mpeg_data->bitrate_mean; @@ -1179,7 +1179,7 @@ static void pvr_event_handler (pvr_input_plugin_t *this) { pthread_mutex_unlock(&this->dev_lock); } break; - + #if 0 default: printf ("input_pvr: got an event, type 0x%08x\n", event->type); @@ -1205,7 +1205,7 @@ static buf_element_t *pvr_plugin_read_block (input_plugin_t *this_gen, fifo_buff if( !this->pvr_running ) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: thread died, aborting\n"); - return NULL; + return NULL; } buf = fifo->buffer_pool_alloc (fifo); @@ -1221,7 +1221,7 @@ static buf_element_t *pvr_plugin_read_block (input_plugin_t *this_gen, fifo_buff if( this->pvr_play_paused ) speed = XINE_SPEED_PAUSE; - + if( this->pvr_playing && _x_stream_info_get(this->stream, XINE_STREAM_INFO_IGNORE_VIDEO) ) { /* video decoding has being disabled. avoid tweaking the clock */ this->pvr_playing = 0; @@ -1233,55 +1233,55 @@ static buf_element_t *pvr_plugin_read_block (input_plugin_t *this_gen, fifo_buff this->pvr_playing = 1; this->play_blk = this->rec_blk; } - + if( this->pvr_playing ) pvr_adjust_realtime_speed(this, fifo, speed); pvr_event_handler(this); - + buf->content = buf->mem; - + pthread_mutex_lock(&this->lock); - + if( this->pvr_playing ) if( !pvr_play_file(this, fifo, buf->content, speed) ) { buf->free_buffer(buf); pthread_mutex_unlock(&this->lock); return NULL; } - + if( todo == PVR_BLOCK_SIZE && speed != XINE_SPEED_PAUSE && this->pvr_playing ) { buf->type = BUF_DEMUX_BLOCK; buf->size = PVR_BLOCK_SIZE; - + if(this->play_fd == -1) { - + /* realtime mode: wait for valid data from pvr thread */ this->want_data = 1; while(!this->valid_data && this->pvr_running) pthread_cond_wait (&this->has_valid_data, &this->lock); - + this->play_blk = this->rec_blk; xine_fast_memcpy(buf->content, this->data, PVR_BLOCK_SIZE); - + this->valid_data = 0; pthread_cond_signal (&this->wake_pvr); } pthread_mutex_unlock(&this->lock); - + } else { pthread_mutex_unlock(&this->lock); - + buf->type = BUF_CONTROL_NOP; - buf->size = 0; - + buf->size = 0; + if(this->preview_buffers) this->preview_buffers--; else xine_usec_sleep (20000); } - + return buf; } @@ -1290,7 +1290,7 @@ static off_t pvr_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin pvr_input_plugin_t *this = (pvr_input_plugin_t *) this_gen; pthread_mutex_lock(&this->lock); - + switch( origin ) { case SEEK_SET: this->play_blk = (offset / PVR_BLOCK_SIZE) + this->page_block[this->first_page]; @@ -1302,18 +1302,18 @@ static off_t pvr_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin this->play_blk = this->rec_blk + (offset / PVR_BLOCK_SIZE); break; } - + /* invalidate the fd if needed */ if( this->play_fd != -1 && block_to_page(this,this->play_blk) != this->play_page ) { if( this->play_fd != this->rec_fd ) - close(this->play_fd); + close(this->play_fd); this->play_fd = -1; if( this->play_blk >= this->rec_blk ) pvr_report_realtime(this,1); } pthread_mutex_unlock(&this->lock); - + return (off_t) (this->play_blk - this->page_block[this->first_page]) * PVR_BLOCK_SIZE; } @@ -1340,9 +1340,9 @@ static const char* pvr_plugin_get_mrl (input_plugin_t *this_gen) { return this->mrl; } -static int pvr_plugin_get_optional_data (input_plugin_t *this_gen, +static int pvr_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { - + return INPUT_OPTIONAL_UNSUPPORTED; } @@ -1360,11 +1360,11 @@ static void pvr_plugin_dispose (input_plugin_t *this_gen ) { this->want_data = 0; pthread_cond_signal (&this->wake_pvr); pthread_mutex_unlock(&this->lock); - pthread_join (this->pvr_thread, &p); + pthread_join (this->pvr_thread, &p); lprintf("pvr thread joined\n"); } - + if (this->scr) { this->stream->xine->clock->unregister_scr(this->stream->xine->clock, &this->scr->scr); this->scr->scr.exit(&this->scr->scr); @@ -1377,15 +1377,15 @@ static void pvr_plugin_dispose (input_plugin_t *this_gen ) { close(this->dev_fd); pvr_finish_recording(this); - + free (this->mrl); - + if (this->tmp_prefix) free (this->tmp_prefix); - + if (this->save_prefix) free (this->save_prefix); - + ite = xine_list_front (this->saved_shows); while (ite) { show = xine_list_get_value(this->saved_shows, ite); @@ -1402,7 +1402,7 @@ static int pvr_plugin_open (input_plugin_t *this_gen ) { int64_t time; int err; struct ivtv_ioctl_codec codec; - + this->session = 0; this->rec_fd = -1; this->play_fd = -1; @@ -1418,7 +1418,7 @@ static int pvr_plugin_open (input_plugin_t *this_gen ) { this->dev_fd = open (this->class->devname, O_RDWR); if (this->dev_fd == -1) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("input_pvr: error opening device %s\n"), this->class->devname ); return 0; } @@ -1437,42 +1437,42 @@ static int pvr_plugin_open (input_plugin_t *this_gen ) { _("input_pvr: IVTV_IOC_S_CODEC failed, maybe API changed?\n")); } } - - /* register our own scr provider */ + + /* register our own scr provider */ time = this->stream->xine->clock->get_current_time(this->stream->xine->clock); this->scr = pvrscr_init(); this->scr->scr.start(&this->scr->scr, time); this->stream->xine->clock->register_scr(this->stream->xine->clock, &this->scr->scr); this->scr_tunning = 0; - + this->event_queue = xine_event_new_queue (this->stream); - + /* enable resample method */ this->stream->xine->config->update_num(this->stream->xine->config,"audio.synchronization.av_sync_method",1); - + this->pvr_running = 1; - + if ((err = pthread_create (&this->pvr_thread, NULL, pvr_loop, this)) != 0) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "input_pvr: can't create new thread (%s)\n", strerror(err)); _x_abort(); } - + return 1; } -static input_plugin_t *pvr_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, +static input_plugin_t *pvr_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data) { pvr_input_class_t *cls = (pvr_input_class_t *) cls_gen; pvr_input_plugin_t *this; char *mrl; char *aux; - - if (strncasecmp (data, "pvr:/", 5)) + + if (strncasecmp (data, "pvr:/", 5)) return NULL; - + mrl = strdup(data); aux = &mrl[5]; @@ -1486,14 +1486,14 @@ static input_plugin_t *pvr_class_get_instance (input_class_t *cls_gen, xine_stre /* decode configuration options from mrl */ if( strlen(aux) ) { this->tmp_prefix = strdup(aux); - + aux = strchr(this->tmp_prefix,'!'); if( aux ) { aux[0] = '\0'; this->save_prefix = strdup(aux+1); aux = strchr(this->save_prefix, '!'); - if( aux ) { + if( aux ) { aux[0] = '\0'; if( atoi(aux+1) ) this->max_page_age = atoi(aux+1); @@ -1505,11 +1505,11 @@ static input_plugin_t *pvr_class_get_instance (input_class_t *cls_gen, xine_stre this->tmp_prefix=strdup("./"); this->save_prefix=strdup("./"); } - + lprintf("tmp_prefix=%s\n", this->tmp_prefix); lprintf("save_prefix=%s\n", this->save_prefix); lprintf("max_page_age=%d\n", this->max_page_age); - + this->input_plugin.open = pvr_plugin_open; this->input_plugin.get_capabilities = pvr_plugin_get_capabilities; this->input_plugin.read = pvr_plugin_read; @@ -1527,12 +1527,12 @@ static input_plugin_t *pvr_class_get_instance (input_class_t *cls_gen, xine_stre this->event_queue = NULL; this->save_name = NULL; this->saved_shows = xine_list_new(); - + pthread_mutex_init (&this->lock, NULL); pthread_mutex_init (&this->dev_lock, NULL); pthread_cond_init (&this->has_valid_data,NULL); pthread_cond_init (&this->wake_pvr,NULL); - + return &this->input_plugin; } @@ -1573,7 +1573,7 @@ static void *init_plugin (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "pvr", XINE_VERSION_CODE, NULL, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c index d8822a3e1..175c61b41 100644 --- a/src/input/input_rtp.c +++ b/src/input/input_rtp.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -114,7 +114,7 @@ typedef struct { input_plugin_t input_plugin; xine_stream_t *stream; - + char *mrl; config_values_t *config; @@ -122,16 +122,16 @@ typedef struct { int port; char *interface; /* For multicast, eth0, eth1 etc */ int is_rtp; - + int fh; - + unsigned char *buffer; /* circular buffer */ unsigned char *buffer_get_ptr; /* get pointer used by reader */ unsigned char *buffer_put_ptr; /* put pointer used by writer */ long buffer_count; /* number of bytes in the buffer */ unsigned char packet_buffer[65536]; - + int last_input_error; int input_eof; @@ -184,7 +184,7 @@ static int host_connect_attempt(struct in_addr ia, int port, return -1; } - saddr.in.sin_family = AF_INET; + saddr.in.sin_family = AF_INET; saddr.in.sin_addr = ia; saddr.in.sin_port = htons(port); @@ -193,8 +193,8 @@ static int host_connect_attempt(struct in_addr ia, int port, LOG_MSG(xine, _("IP address specified is multicast\n")); multicast = 1; /* boolean true */ } - - + + /* Try to increase receive buffer to 1MB to avoid dropping packets */ optval = BUFFER_SIZE; if ((setsockopt(s, SOL_SOCKET, SO_RCVBUF, @@ -217,7 +217,7 @@ static int host_connect_attempt(struct in_addr ia, int port, LOG_MSG(xine, _("bind(): %s.\n"), strerror(errno)); return -1; } - + /* multicast ? */ if (multicast) { @@ -250,14 +250,14 @@ static int host_connect_attempt(struct in_addr ia, int port, &((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr, sizeof(struct in_addr)); } - + if (setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))) { LOG_MSG(xine, _("setsockopt(IP_ADD_MEMBERSHIP) failed (multicast kernel?): %s.\n"), strerror(errno)); return -1; } } - + return s; } @@ -271,13 +271,13 @@ static int host_connect(const char *host, int port, struct hostent *h; int i; int s; - + h=gethostbyname(host); if(h==NULL) { LOG_MSG(xine, _("unable to resolve '%s'.\n"), host); return -1; } - + for(i=0; h->h_addr_list[i]; i++) { struct in_addr ia; memcpy(&ia, h->h_addr_list[i],4); @@ -299,7 +299,7 @@ static void * input_plugin_read_loop(void *arg) { fd_set read_fds; while (1) { - + /* System calls are not a thread cancellation point in Linux * pthreads. However, the RT signal sent to cancel the thread * will cause recv() to return with EINTR, and we can manually @@ -339,11 +339,11 @@ static void * input_plugin_read_loop(void *arg) { } else { data = this->packet_buffer; - + if (this->is_rtp) { int pad, ext; int csrc; - + /* Do minimal RTP parsing to extract payload. See * http://www.faqs.org/rfcs/rfc1889.html for header format. * @@ -351,7 +351,7 @@ static void * input_plugin_read_loop(void *arg) { */ if (length < 12) continue; - + pad = data[0] & 0x20; ext = data[0] & 0x10; csrc = data[0] & 0x0f; @@ -361,7 +361,7 @@ static void * input_plugin_read_loop(void *arg) { if (ext) { long hlen; - + if (length < 4) continue; hlen = (data[2] << 8) | data[3]; @@ -382,12 +382,12 @@ static void * input_plugin_read_loop(void *arg) { /* insert data into cyclic buffer */ if (length > 0) { - - /* + + /* * if the buffer is full, wait for the reader - * to signal - */ - + * to signal + */ + pthread_mutex_lock(&this->buffer_ring_mut); /* wait for enough space to write the whole of the recv'ed data */ while( (BUFFER_SIZE - this->buffer_count) < length ) @@ -399,23 +399,23 @@ static void * input_plugin_read_loop(void *arg) { timeout.tv_nsec = tv.tv_usec * 1000; timeout.tv_sec = tv.tv_sec + 2; - + if( pthread_cond_timedwait(&this->writer_cond, &this->buffer_ring_mut, &timeout) != 0 ) { fprintf( stdout, "input_rtp: buffer ring not read within 2 seconds!\n" ); } } - + /* Now there's enough space to write some bytes into the buffer * determine how many bytes can be written. If the buffer wraps * around, write in two pieces: from the head pointer to the - * end of the buffer and from the base to the remaining number + * end of the buffer and from the base to the remaining number * of bytes. */ { long buffer_space_remaining = BUFFER_SIZE - (this->buffer_put_ptr - this->buffer); - + if( buffer_space_remaining >= length ) { /* data fits inside the buffer */ @@ -445,15 +445,15 @@ static void * input_plugin_read_loop(void *arg) { /* END OF PRIVATES */ /* ***************************************************************** */ -static off_t rtp_plugin_read (input_plugin_t *this_gen, +static off_t rtp_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t length) { rtp_input_plugin_t *this = (rtp_input_plugin_t *) this_gen; char *buf = (char *)buf_gen; struct timeval tv; struct timespec timeout; - off_t copied = 0; - + off_t copied = 0; + if (length < 0) return -1; @@ -473,7 +473,7 @@ static off_t rtp_plugin_read (input_plugin_t *this_gen, gettimeofday(&tv, NULL); timeout.tv_nsec = tv.tv_usec * 1000; timeout.tv_sec = tv.tv_sec + 5; - + if(pthread_cond_timedwait(&this->reader_cond, &this->buffer_ring_mut, &timeout) != 0) { /* we timed out, no data available */ @@ -484,9 +484,9 @@ static off_t rtp_plugin_read (input_plugin_t *this_gen, /* Now determine how many bytes can be read. If the buffer * will wrap the buffer is read in two pieces, first read - * to the end of the buffer, wrap the tail pointer and + * to the end of the buffer, wrap the tail pointer and * update the buffer count. Finally read the second piece - * from the base to the remaining count + * from the base to the remaining count */ if(length > this->buffer_count) { n = this->buffer_count; @@ -494,26 +494,26 @@ static off_t rtp_plugin_read (input_plugin_t *this_gen, else { n = length; } - + if(((this->buffer_get_ptr - this->buffer) + n) > BUFFER_SIZE) { n = BUFFER_SIZE - (this->buffer_get_ptr - this->buffer); } - + /* the actual read */ memcpy(buf, this->buffer_get_ptr, n); buf += n; copied += n; length -= n; - + /* update the tail pointer, watch for wrap arounds */ this->buffer_get_ptr += n; if(this->buffer_get_ptr - this->buffer >= BUFFER_SIZE) this->buffer_get_ptr = this->buffer; - + this->buffer_count -= n; - - /* signal the writer that there's space in the buffer again */ + + /* signal the writer that there's space in the buffer again */ pthread_cond_signal(&this->writer_cond); pthread_mutex_unlock(&this->buffer_ring_mut); } @@ -555,7 +555,7 @@ static buf_element_t *rtp_plugin_read_block (input_plugin_t *this_gen, */ static off_t rtp_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { - + return -1; } @@ -572,7 +572,7 @@ static off_t rtp_plugin_get_length (input_plugin_t *this_gen) { */ static off_t rtp_plugin_get_current_pos (input_plugin_t *this_gen){ rtp_input_plugin_t *this = (rtp_input_plugin_t *) this_gen; - + return this->curpos; } @@ -580,7 +580,7 @@ static off_t rtp_plugin_get_current_pos (input_plugin_t *this_gen){ * */ static uint32_t rtp_plugin_get_capabilities (input_plugin_t *this_gen) { - + return INPUT_CAP_PREVIEW; } @@ -588,7 +588,7 @@ static uint32_t rtp_plugin_get_capabilities (input_plugin_t *this_gen) { * */ static uint32_t rtp_plugin_get_blocksize (input_plugin_t *this_gen) { - + return 0; } @@ -597,14 +597,14 @@ static uint32_t rtp_plugin_get_blocksize (input_plugin_t *this_gen) { */ static const char* rtp_plugin_get_mrl (input_plugin_t *this_gen) { rtp_input_plugin_t *this = (rtp_input_plugin_t *) this_gen; - + return this->mrl; } /* * */ -static int rtp_plugin_get_optional_data (input_plugin_t *this_gen, +static int rtp_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { rtp_input_plugin_t *this = (rtp_input_plugin_t *) this_gen; @@ -636,16 +636,16 @@ static int rtp_plugin_get_optional_data (input_plugin_t *this_gen, static void rtp_plugin_dispose (input_plugin_t *this_gen ) { rtp_input_plugin_t *this = (rtp_input_plugin_t *) this_gen; - + if (this->nbc) nbc_close(this->nbc); - + if (this->rtp_running) { LOG_MSG(this->stream->xine, _("RTP: stopping reading thread...\n")); pthread_cancel(this->reader_thread); pthread_join(this->reader_thread, NULL); LOG_MSG(this->stream->xine, _("RTP: reading thread terminated\n")); } - + if (this->fh != -1) close(this->fh); free(this->buffer); @@ -662,7 +662,7 @@ static int rtp_plugin_open (input_plugin_t *this_gen ) { this->filename, this->port, this->interface); - + this->fh = host_connect(this->filename, this->port, this->interface, this->stream->xine); @@ -673,12 +673,12 @@ static int rtp_plugin_open (input_plugin_t *this_gen ) { this->curpos = 0; this->rtp_running = 1; - if ((err = pthread_create(&this->reader_thread, NULL, + if ((err = pthread_create(&this->reader_thread, NULL, input_plugin_read_loop, (void *)this)) != 0) { LOG_MSG(this->stream->xine, _("input_rtp: can't create new thread (%s)\n"), strerror(err)); _x_abort(); } - + return 1; } @@ -692,7 +692,7 @@ static input_plugin_t *rtp_class_get_instance (input_class_t *cls_gen, char *mrl; int is_rtp = 0; int port = 7658; - + mrl = strdup(data); if (!strncasecmp (mrl, "rtp://", 6)) { @@ -703,12 +703,12 @@ static input_plugin_t *rtp_class_get_instance (input_class_t *cls_gen, filename = &mrl[6]; is_rtp = 0; } - + if (filename == NULL || strlen(filename) == 0) { free(mrl); return NULL; } - + /* Locate the port number */ pptr=strchr(filename, ':'); iptr = NULL; @@ -729,7 +729,7 @@ static input_plugin_t *rtp_class_get_instance (input_class_t *cls_gen, } } } - + this = calloc(1, sizeof(rtp_input_plugin_t)); this->stream = stream; this->mrl = mrl; @@ -766,8 +766,8 @@ static input_plugin_t *rtp_class_get_instance (input_class_t *cls_gen, this->input_plugin.get_optional_data = rtp_plugin_get_optional_data; this->input_plugin.dispose = rtp_plugin_dispose; this->input_plugin.input_class = cls_gen; - - this->nbc = NULL; + + this->nbc = NULL; this->nbc = nbc_init(this->stream); return &this->input_plugin; @@ -781,7 +781,7 @@ static void *init_class (xine_t *xine, void *data) { rtp_input_class_t *this; - + this = calloc(1, sizeof(rtp_input_class_t)); this->config = xine->config; this->xine = xine; @@ -802,7 +802,7 @@ static void *init_class (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT, 18, "rtp", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index 0e5af6043..e8c1a1ce7 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2002-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -69,14 +69,14 @@ typedef struct { off_t curpos; - nbc_t *nbc; + nbc_t *nbc; char scratch[BUFSIZE]; } rtsp_input_plugin_t; -static off_t rtsp_plugin_read (input_plugin_t *this_gen, +static off_t rtsp_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; off_t n; @@ -90,7 +90,7 @@ static off_t rtsp_plugin_read (input_plugin_t *this_gen, return n; } -static buf_element_t *rtsp_plugin_read_block (input_plugin_t *this_gen, +static buf_element_t *rtsp_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo) { /*rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; */ buf_element_t *buf = fifo->buffer_pool_alloc (fifo); @@ -107,7 +107,7 @@ static buf_element_t *rtsp_plugin_read_block (input_plugin_t *this_gen, buf->content = buf->mem; buf->type = BUF_DEMUX_BLOCK; - + total_bytes = rtsp_plugin_read (this_gen, (char*)buf->content, todo); if (total_bytes != todo) { @@ -151,17 +151,17 @@ static off_t rtsp_plugin_seek_time (input_plugin_t *this_gen, int time_offset, i rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; lprintf ("seek_time %d msec, origin %d\n", time_offset, origin); - + if (origin == SEEK_SET) rtsp_session_set_start_time (this->rtsp, time_offset); - + return this->curpos; } static off_t rtsp_plugin_get_length (input_plugin_t *this_gen) { /* - rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; + rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; off_t length; */ @@ -198,13 +198,13 @@ static void rtsp_plugin_dispose (input_plugin_t *this_gen) { nbc_close (this->nbc); this->nbc = NULL; } - + if(this->mrl) free(this->mrl); - + if(this->public_mrl) free(this->public_mrl); - + free (this); } @@ -214,7 +214,7 @@ static const char* rtsp_plugin_get_mrl (input_plugin_t *this_gen) { return this->public_mrl; } -static int rtsp_plugin_get_optional_data (input_plugin_t *this_gen, +static int rtsp_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; @@ -245,11 +245,11 @@ static int rtsp_plugin_open (input_plugin_t *this_gen) { } this->rtsp = rtsp; - + return 1; } -static input_plugin_t *rtsp_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, +static input_plugin_t *rtsp_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *mrl) { /* rtsp_input_class_t *cls = (rtsp_input_class_t *) cls_gen; */ @@ -267,7 +267,7 @@ static input_plugin_t *rtsp_class_get_instance (input_class_t *cls_gen, xine_str * an .rm extention to force handling by demux_real. */ asprintf(&this->public_mrl, "%s.rm", this->mrl); - + this->nbc = nbc_init (stream); this->input_plugin.open = rtsp_plugin_open; @@ -283,7 +283,7 @@ static input_plugin_t *rtsp_class_get_instance (input_class_t *cls_gen, xine_str this->input_plugin.dispose = rtsp_plugin_dispose; this->input_plugin.get_optional_data = rtsp_plugin_get_optional_data; this->input_plugin.input_class = cls_gen; - + return &this->input_plugin; } @@ -314,7 +314,7 @@ static void *init_class (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT, 18, "rtsp", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_smb.c b/src/input/input_smb.c index 3c2086cc3..6e857259b 100644 --- a/src/input/input_smb.c +++ b/src/input/input_smb.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -41,7 +41,7 @@ typedef struct { input_class_t input_class; xine_t *xine; - + int mrls_allocated_entries; xine_mrl_t **mrls; } smb_input_class_t; @@ -139,7 +139,7 @@ smb_plugin_get_length (input_plugin_t *this_gen) int e; struct stat st; - + if (this->fd>=0) e = smbc_fstat(this->fd,&st); else e = smbc_stat(this->mrl,&st); @@ -207,20 +207,20 @@ static int _strverscmp(const char *s1, const char *s2) { c2 = *p2++; state |= (c1 == '0') + (ISDIGIT(c1) != 0); } - + state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT(c2) != 0))]; - + switch(state) { case CMP: return diff; - + case LEN: while(ISDIGIT(*p1++)) if(!ISDIGIT(*p2++)) return 1; - + return ISDIGIT(*p2) ? -1 : diff; - + default: return state; } @@ -234,9 +234,9 @@ static int _sortfiles_default(const xine_mrl_t *s1, const xine_mrl_t *s2) { } -static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, +static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, const char *filename, int *nFiles) { - + smb_input_class_t *this = (smb_input_class_t *) this_gen; int (*func) () = _sortfiles_default; int dir; @@ -252,11 +252,11 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, snprintf(current_path, XINE_PATH_MAX, "smb:/"); snprintf(current_path_smb, XINE_PATH_MAX, "smb://"); } - + if ((dir = smbc_opendir(current_path_smb)) >= 0){ xine_mrl_t *dir_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); xine_mrl_t *norm_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); - int num_dir_files=0; + int num_dir_files=0; int num_norm_files=0; while ((pdirent = smbc_readdir(dir)) != NULL){ if (pdirent->smbc_type == SMBC_WORKGROUP){ @@ -266,7 +266,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; - }else if (pdirent->smbc_type == SMBC_SERVER){ + }else if (pdirent->smbc_type == SMBC_SERVER){ if (num_dir_files == 0) { dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; @@ -298,7 +298,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; - } + } } else if (pdirent->smbc_type == SMBC_DIR){ dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; @@ -331,49 +331,49 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, */ if(num_dir_files) qsort(dir_files, num_dir_files, sizeof(xine_mrl_t), func); - + if(num_norm_files) qsort(norm_files, num_norm_files, sizeof(xine_mrl_t), func); - + /* * Add directories entries */ for(i = 0; i < num_dir_files; i++) { if (num_files >= this->mrls_allocated_entries) { ++this->mrls_allocated_entries; - this->mrls = realloc(this->mrls, + this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*)); this->mrls[num_files] = calloc(1, sizeof(xine_mrl_t)); }else memset(this->mrls[num_files], 0, sizeof(xine_mrl_t)); - - MRL_DUPLICATE(&dir_files[i], this->mrls[num_files]); + + MRL_DUPLICATE(&dir_files[i], this->mrls[num_files]); num_files++; } - - /* + + /* * Add other files entries */ for(i = 0; i < num_norm_files; i++) { if(num_files >= this->mrls_allocated_entries) { ++this->mrls_allocated_entries; - this->mrls = realloc(this->mrls, + this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*)); this->mrls[num_files] = calloc(1, sizeof(xine_mrl_t)); }else memset(this->mrls[num_files], 0, sizeof(xine_mrl_t)); - MRL_DUPLICATE(&norm_files[i], this->mrls[num_files]); + MRL_DUPLICATE(&norm_files[i], this->mrls[num_files]); num_files++; } - + /* Some cleanups before leaving */ for(i = num_dir_files; i == 0; i--) MRL_ZERO(&dir_files[i]); free(dir_files); - + for(i = num_norm_files; i == 0; i--) MRL_ZERO(&norm_files[i]); free(norm_files); @@ -383,13 +383,13 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, current_path, errno, strerror(errno)); *nFiles = 0; return NULL; - } - + } + /* * Inform caller about files found number. */ *nFiles = num_files; - + /* * Freeing exceeded mrls if exists. */ @@ -397,7 +397,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]); free(this->mrls[this->mrls_allocated_entries--]); } - + /* * This is useful to let UI know where it should stops ;-). */ @@ -407,7 +407,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, } static int -smb_plugin_get_optional_data (input_plugin_t *this_gen, +smb_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { return INPUT_OPTIONAL_UNSUPPORTED; @@ -432,8 +432,8 @@ smb_plugin_open (input_plugin_t *this_gen ) smb_input_class_t *class = (smb_input_class_t *) this_gen->input_class; this->fd = smbc_open(this->mrl,O_RDONLY,0); - xprintf(class->xine, XINE_VERBOSITY_DEBUG, - "input_smb: open failed for %s: %s\n", + xprintf(class->xine, XINE_VERBOSITY_DEBUG, + "input_smb: open failed for %s: %s\n", this->mrl, strerror(errno)); if (this->fd<0) return 0; @@ -445,7 +445,7 @@ smb_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, const char *mrl) { smb_input_t *this; - + if (mrl == NULL) return NULL; if (strncmp (mrl, "smb://",6)) @@ -489,7 +489,7 @@ static void if (smbc_init(smb_auth,(xine->verbosity >= XINE_VERBOSITY_DEBUG))) goto _exit_error; - + this = calloc(1, sizeof(smb_input_class_t)); this->xine = xine; @@ -507,7 +507,7 @@ static void setlocale(LC_MESSAGES, lcl); free(lcl); #endif - + return (input_class_t *) this; } diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c index 55ac18a42..9d6f7059f 100644 --- a/src/input/input_stdin_fifo.c +++ b/src/input/input_stdin_fifo.c @@ -2,17 +2,17 @@ * Copyright (C) 2000-2003 the xine project * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -78,7 +78,7 @@ static off_t stdin_plugin_get_current_pos (input_plugin_t *this_gen); -static off_t stdin_plugin_read (input_plugin_t *this_gen, +static off_t stdin_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { stdin_input_plugin_t *this = (stdin_input_plugin_t *) this_gen; @@ -105,7 +105,7 @@ static off_t stdin_plugin_read (input_plugin_t *this_gen, n = _x_io_file_read (this->stream, this->fh, &buf[total], len - total); lprintf ("got %"PRId64" bytes (%"PRId64"/%"PRId64" bytes read)\n", n,total,len); - + if (n < 0) { _x_message(this->stream, XINE_MSG_READ_ERROR, NULL); return 0; @@ -117,7 +117,7 @@ static off_t stdin_plugin_read (input_plugin_t *this_gen, return total; } -static buf_element_t *stdin_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, +static buf_element_t *stdin_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo) { off_t total_bytes; @@ -167,11 +167,11 @@ static off_t stdin_plugin_seek (input_plugin_t *this_gen, off_t offset, int orig if (offset < this->curpos) { - if( this->curpos <= this->preview_size ) + if( this->curpos <= this->preview_size ) this->curpos = offset; else - xprintf (this->xine, XINE_VERBOSITY_LOG, - _("stdin: cannot seek back! (%" PRIdMAX " > %" PRIdMAX ")\n"), + xprintf (this->xine, XINE_VERBOSITY_LOG, + _("stdin: cannot seek back! (%" PRIdMAX " > %" PRIdMAX ")\n"), (intmax_t)this->curpos, (intmax_t)offset); } else { @@ -195,7 +195,7 @@ static off_t stdin_plugin_get_length(input_plugin_t *this_gen) { } static uint32_t stdin_plugin_get_capabilities(input_plugin_t *this_gen) { - + return INPUT_CAP_PREVIEW; } @@ -219,17 +219,17 @@ static const char* stdin_plugin_get_mrl (input_plugin_t *this_gen) { static void stdin_plugin_dispose (input_plugin_t *this_gen ) { stdin_input_plugin_t *this = (stdin_input_plugin_t *) this_gen; - if (this->nbc) + if (this->nbc) nbc_close (this->nbc); if ((this->fh != STDIN_FILENO) && (this->fh != -1)) close(this->fh); - + free (this->mrl); free (this); } -static int stdin_plugin_get_optional_data (input_plugin_t *this_gen, +static int stdin_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { stdin_input_plugin_t *this = (stdin_input_plugin_t *) this_gen; @@ -288,7 +288,7 @@ static int stdin_plugin_open (input_plugin_t *this_gen ) { } -static input_plugin_t *stdin_class_get_instance (input_class_t *class_gen, +static input_plugin_t *stdin_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, const char *data) { stdin_input_class_t *class = (stdin_input_class_t *) class_gen; diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index c89653050..5d38cb4e4 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -1,19 +1,19 @@ /* * Copyright (C) 2003-2008 the xine project * Copyright (C) 2003 J.Asselman <j.asselman@itsec-ps.nl> - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -65,7 +65,7 @@ /* #define LOG_MODULE "input_v4l" */ #define LOG_VERBOSE /* -#define LOG +#define LOG */ #ifdef LOG @@ -133,7 +133,7 @@ typedef struct { typedef struct { input_plugin_t input_plugin; - + xine_stream_t *stream; char *mrl; @@ -147,7 +147,7 @@ typedef struct { buf_element_t *frames_base; void *audio_content_base; void *video_content_base; - + /* Audio */ buf_element_t *aud_frames; pthread_mutex_t aud_frames_lock; @@ -156,32 +156,32 @@ typedef struct { #ifdef HAVE_ALSA /* Handle for the PCM device */ snd_pcm_t *pcm_handle; - + /* Record stream (via line 1) */ snd_pcm_stream_t pcm_stream; - + /* Information and configuration for the PCM stream */ snd_pcm_hw_params_t *pcm_hwparams; /* Name of the PCM device, plughw:0,0?=>soundcard,device*/ - char *pcm_name; - + char *pcm_name; + /* Use alsa to capture the sound (for a/v sync) */ char audio_capture; - + int exact_rate; /* Actual sample rate sndpcm_hw_params_set_rate_near */ int dir; /* exact rate == rate --> dir = 0 exact rate < rate --> dir = -1 exact rate > rate --> dir = 1 */ - + unsigned char *pcm_data; - + int64_t pts_aud_start; #endif int audio_header_sent; - + int rate; /* Sample rate */ int periods; /* Number of periods */ int periodsize; /* Periodsize in bytes */ @@ -210,9 +210,9 @@ typedef struct { struct video_audio audio; struct video_audio audio_saved; struct video_mbuf gb_buffers; - + int video_header_sent; - + int frame_format; const resolution_t *resolution; int frame_size; @@ -249,13 +249,13 @@ typedef struct { struct pvrscr_s { scr_plugin_t scr; - + struct timeval cur_time; int64_t cur_pts; int xine_speed; double speed_factor; double speed_tuning; - + pthread_mutex_t lock; }; @@ -270,47 +270,47 @@ static void pvrscr_set_pivot(pvrscr_t *this) struct timeval tv; int64_t pts; double pts_calc; - + xine_monotonic_clock(&tv, NULL); pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; pts = this->cur_pts + pts_calc; - + /* This next part introduces a one off inaccuracy * to the scr due to rounding tv to pts. */ this->cur_time.tv_sec = tv.tv_sec; this->cur_time.tv_usec = tv.tv_usec; this->cur_pts = pts; - + return; } static int pvrscr_set_fine_speed (scr_plugin_t *scr, int speed) { pvrscr_t *this = (pvrscr_t*) scr; - + pthread_mutex_lock (&this->lock); - + pvrscr_set_pivot( this ); this->xine_speed = speed; this->speed_factor = (double) speed * 90000.0 / XINE_FINE_SPEED_NORMAL * this->speed_tuning; - + pthread_mutex_unlock (&this->lock); - + return speed; } static void pvrscr_speed_tuning (pvrscr_t *this, double factor) { pthread_mutex_lock (&this->lock); - + pvrscr_set_pivot( this ); this->speed_tuning = factor; this->speed_factor = (double) this->xine_speed * 90000.0 / XINE_FINE_SPEED_NORMAL * this->speed_tuning; - + pthread_mutex_unlock (&this->lock); } @@ -318,28 +318,28 @@ static void pvrscr_adjust (scr_plugin_t *scr, int64_t vpts) { pvrscr_t *this = (pvrscr_t*) scr; struct timeval tv; - + pthread_mutex_lock (&this->lock); - + xine_monotonic_clock(&tv, NULL); this->cur_time.tv_sec = tv.tv_sec; this->cur_time.tv_usec = tv.tv_usec; this->cur_pts = vpts; - + pthread_mutex_unlock (&this->lock); } static void pvrscr_start (scr_plugin_t *scr, int64_t start_vpts) { pvrscr_t *this = (pvrscr_t*) scr; - + pthread_mutex_lock (&this->lock); - + xine_monotonic_clock(&this->cur_time, NULL); this->cur_pts = start_vpts; pthread_mutex_unlock (&this->lock); - + pvrscr_set_fine_speed (&this->scr, XINE_FINE_SPEED_NORMAL); } @@ -349,17 +349,17 @@ static int64_t pvrscr_get_current (scr_plugin_t *scr) struct timeval tv; int64_t pts; double pts_calc; - + pthread_mutex_lock (&this->lock); - + xine_monotonic_clock(&tv, NULL); - + pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; pts = this->cur_pts + pts_calc; - + pthread_mutex_unlock (&this->lock); - + /*printf("returning pts %lld\n", pts);*/ return pts; } @@ -367,7 +367,7 @@ static int64_t pvrscr_get_current (scr_plugin_t *scr) static void pvrscr_exit (scr_plugin_t *scr) { pvrscr_t *this = (pvrscr_t*) scr; - + pthread_mutex_destroy (&this->lock); free(this); } @@ -375,9 +375,9 @@ static void pvrscr_exit (scr_plugin_t *scr) static pvrscr_t *XINE_MALLOC pvrscr_init (void) { pvrscr_t *this; - + this = calloc(1, sizeof(pvrscr_t)); - + this->scr.interface_version = 3; this->scr.get_priority = pvrscr_get_priority; this->scr.set_fine_speed = pvrscr_set_fine_speed; @@ -385,7 +385,7 @@ static pvrscr_t *XINE_MALLOC pvrscr_init (void) this->scr.start = pvrscr_start; this->scr.get_current = pvrscr_get_current; this->scr.exit = pvrscr_exit; - + pthread_mutex_init (&this->lock, NULL); pvrscr_speed_tuning(this, 1.0 ); @@ -393,7 +393,7 @@ static pvrscr_t *XINE_MALLOC pvrscr_init (void) #ifdef SCRLOG printf("input_v4l: scr init complete\n"); #endif - + return this; } @@ -404,7 +404,7 @@ static void report_progress (xine_stream_t *stream, int p) { xine_event_t event; xine_progress_data_t prg; - + if (p == SCR_PAUSED) { prg.description = _("Buffer underrun..."); p = 0; @@ -414,13 +414,13 @@ static void report_progress (xine_stream_t *stream, int p) p = 100; } else prg.description = _("Adjusting..."); - + prg.percent = (p>100)?100:p; - + event.type = XINE_EVENT_PROGRESS; event.data = &prg; event.data_length = sizeof (xine_progress_data_t); - + xine_event_send (stream, &event); } @@ -436,25 +436,25 @@ static void v4l_event_handler(v4l_input_plugin_t *this); inline static buf_element_t *alloc_aud_frame (v4l_input_plugin_t *this) { buf_element_t *frame; - + lprintf("alloc_aud_frame. trying to get lock...\n"); pthread_mutex_lock (&this->aud_frames_lock) ; - + lprintf("got the lock\n"); - + while (!this->aud_frames) { lprintf("no audio frame available...\n"); pthread_cond_wait (&this->aud_frame_freed, &this->aud_frames_lock); } - + frame = this->aud_frames; this->aud_frames = this->aud_frames->next; - + pthread_mutex_unlock (&this->aud_frames_lock); - + lprintf("alloc_aud_frame done\n"); - + return frame; } @@ -468,10 +468,10 @@ static void store_aud_frame (buf_element_t *frame) lprintf("store_aud_frame\n"); pthread_mutex_lock (&this->aud_frames_lock) ; - + frame->next = this->aud_frames; this->aud_frames = frame; - + pthread_cond_signal (&this->aud_frame_freed); pthread_mutex_unlock (&this->aud_frames_lock); } @@ -488,19 +488,19 @@ inline static buf_element_t *alloc_vid_frame (v4l_input_plugin_t *this) pthread_mutex_lock (&this->vid_frames_lock) ; lprintf("got the lock\n"); - + while (!this->vid_frames) { lprintf("no video frame available...\n"); pthread_cond_wait (&this->vid_frame_freed, &this->vid_frames_lock); } - + frame = this->vid_frames; this->vid_frames = this->vid_frames->next; - + pthread_mutex_unlock (&this->vid_frames_lock); - + lprintf("alloc_vid_frame done\n"); - + return frame; } @@ -511,50 +511,50 @@ static void store_vid_frame (buf_element_t *frame) { v4l_input_plugin_t *this = (v4l_input_plugin_t *) frame->source; - + lprintf("store_vid_frame\n"); - + pthread_mutex_lock (&this->vid_frames_lock) ; frame->next = this->vid_frames; this->vid_frames = frame; - + pthread_cond_signal (&this->vid_frame_freed); pthread_mutex_unlock (&this->vid_frames_lock); } -static int extract_mrl(v4l_input_plugin_t *this, char *mrl) +static int extract_mrl(v4l_input_plugin_t *this, char *mrl) { char *tuner_name = NULL; int frequency = 0; char *locator = NULL; char *begin = NULL; - + if (mrl == NULL) { lprintf("Someone passed an empty mrl\n"); return 0; } - + for (locator = mrl; *locator != '\0' && *locator != '/' ; locator++); - + /* Get tuner name */ if (*locator == '/') { begin = ++locator; - + for (; *locator != '\0' && *locator != '/' ; locator++); - + tuner_name = (char *) strndup(begin, locator - begin); - - /* Get frequency, if available */ + + /* Get frequency, if available */ sscanf(locator, "/%d", &frequency); - + /* cannot use xprintf to log in this routine */ lprintf("input_v4l: Tuner name: %s frequency %d\n", tuner_name, frequency ); } - + this->frequency = frequency; this->tuner_name = tuner_name; - + return 1; } @@ -562,12 +562,12 @@ static int set_frequency(v4l_input_plugin_t *this, unsigned long frequency) { int ret = 0; int fd; - + if (this->video_fd > 0) fd = this->video_fd; else fd = this->radio_fd; - + if (frequency != 0) { /* FIXME: Don't assume tuner 0 ? */ this->tuner = 0; @@ -580,19 +580,19 @@ static int set_frequency(v4l_input_plugin_t *this, unsigned long frequency) } else { this->calc_frequency = (frequency * 16) / 1000; } - + ret = ioctl(fd, VIDIOCSFREQ, &this->calc_frequency); - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: set frequency (%ld) returned: %d\n", frequency, ret); } else { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: No frequency given. Expected syntax: v4l:/tuner/frequency\n" "input_v4l: Using currently tuned settings\n"); } - + this->frequency = frequency; - + if (ret < 0) return ret; else @@ -602,11 +602,11 @@ static int set_frequency(v4l_input_plugin_t *this, unsigned long frequency) static int set_input_source(v4l_input_plugin_t *this, char *input_source) { int ret = 0; - + if ((ret = search_by_channel(this, input_source)) != 1) { ret = search_by_tuner(this, input_source); } - + return ret; } @@ -615,23 +615,23 @@ static int search_by_tuner(v4l_input_plugin_t *this, char *input_source) int ret = 0; int fd = 0; int cur_tuner = 0; - + if (this->video_fd > 0) fd = this->video_fd; else fd = this->radio_fd; - + this->video_tuner.tuner = cur_tuner; ioctl(fd, VIDIOCGCAP, &this->video_cap); - + lprintf("This device has %d channel(s)\n", this->video_cap.channels); - + for (ret = ioctl(fd, VIDIOCGTUNER, &this->video_tuner); ret == 0 && this->video_cap.channels > cur_tuner && strstr(this->video_tuner.name, input_source) == NULL; cur_tuner++) { - + this->video_tuner.tuner = cur_tuner; - + lprintf("(%d) V4L device currently set to: \n", ret); lprintf("Tuner: %d\n", this->video_tuner.tuner); lprintf("Name: %s\n", this->video_tuner.name); @@ -641,7 +641,7 @@ static int search_by_tuner(v4l_input_plugin_t *this, char *input_source) lprintf("Range: %ld - %ld\n", this->video_tuner.rangelow * 1000 / 16, this->video_tuner.rangehigh * 1000 / 16); } } - + lprintf("(%d) V4L device final: \n", ret); lprintf("Tuner: %d\n", this->video_tuner.tuner); lprintf("Name: %s\n", this->video_tuner.name); @@ -650,10 +650,10 @@ static int search_by_tuner(v4l_input_plugin_t *this, char *input_source) } else { lprintf("Range: %ld - %ld\n", this->video_tuner.rangelow * 1000 / 16, this->video_tuner.rangehigh * 1000 / 16); } - + if (strstr(this->video_tuner.name, input_source) == NULL) return -1; - + return 1; } @@ -664,20 +664,20 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source) cfg_entry_t *tv_standard_entry; lprintf("input_source: %s\n", input_source); - + this->input = 0; - + if (this->video_fd > 0) fd = this->video_fd; else fd = this->radio_fd; - + /* Tune into channel */ if (strlen(input_source) > 0) { for( this->video_channel.channel = 0; ioctl(fd, VIDIOCGCHAN, &this->video_channel) == 0; this->video_channel.channel++ ) { - + lprintf("V4L device currently set to:\n"); lprintf("Channel: %d\n", this->video_channel.channel); lprintf("Name: %s\n", this->video_channel.name); @@ -691,33 +691,33 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source) break; } } - + if (strstr(this->video_channel.name, input_source) == NULL) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("Tuner name not found\n")); return -1; } - + tv_standard_entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, "media.video4linux.tv_standard"); this->tuner_name = input_source; if (tv_standard_entry->num_value != 0) { this->video_channel.norm = tv_standard_values[ tv_standard_entry->num_value ]; xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "input_v4l: TV Standard configured as STD %s (%d)\n", + "input_v4l: TV Standard configured as STD %s (%d)\n", tv_standard_names[ tv_standard_entry->num_value ], this->video_channel.norm ); ret = ioctl(fd, VIDIOCSCHAN, &this->video_channel); } else ret = ioctl(fd, VIDIOCSCHAN, &this->input); - + lprintf("(%d) Set channel to %d\n", ret, this->input); } else { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Not setting video source. No source given\n"); } ret = ioctl(fd, VIDIOCGTUNER, &this->video_tuner); lprintf("(%d) Flags %d\n", ret, this->video_tuner.flags); - + lprintf("VIDEO_TUNER_PAL %s set\n", this->video_tuner.flags & VIDEO_TUNER_PAL ? "" : "not"); lprintf("VIDEO_TUNER_NTSC %s set\n", this->video_tuner.flags & VIDEO_TUNER_NTSC ? "" : "not"); lprintf("VIDEO_TUNER_SECAM %s set\n", this->video_tuner.flags & VIDEO_TUNER_SECAM ? "" : "not"); @@ -726,7 +726,7 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source) lprintf("VIDEO_TUNER_STEREO_ON %s set\n", this->video_tuner.flags & VIDEO_TUNER_STEREO_ON ? "" : "not"); lprintf("VIDEO_TUNER_RDS_ON %s set\n", this->video_tuner.flags & VIDEO_TUNER_RDS_ON ? "" : "not"); lprintf("VIDEO_TUNER_MBS_ON %s set\n", this->video_tuner.flags & VIDEO_TUNER_MBS_ON ? "" : "not"); - + switch (this->video_tuner.mode) { case VIDEO_MODE_PAL: lprintf("The tuner is in PAL mode\n"); @@ -742,7 +742,7 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source) break; } - return 1; + return 1; } static void allocate_frames(v4l_input_plugin_t *this, unsigned dovideo) @@ -768,7 +768,7 @@ static void allocate_frames(v4l_input_plugin_t *this, unsigned dovideo) frames[i].source = this; frames[i].free_buffer = store_aud_frame; frames[i].extra_info = &infos[i]; - + audio_content += this->periodsize; store_aud_frame(&frames[i]); } @@ -797,12 +797,12 @@ static void unmute_audio(v4l_input_plugin_t *this) int fd; lprintf("unmute_audio\n"); - + if (this->video_fd > 0) fd = this->video_fd; else fd = this->radio_fd; - + ioctl(fd, VIDIOCGAUDIO, &this->audio); memcpy(&this->audio_saved, &this->audio, sizeof(this->audio)); @@ -811,43 +811,43 @@ static void unmute_audio(v4l_input_plugin_t *this) ioctl(fd, VIDIOCSAUDIO, &this->audio); } - + static int open_radio_capture_device(v4l_input_plugin_t *this) { int tuner_found = 0; cfg_entry_t *entry; - + lprintf("open_radio_capture_device\n"); - + entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, "media.video4linux.radio_device"); - + if((this->radio_fd = open(entry->str_value, O_RDWR)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "input_v4l: error opening v4l device (%s): %s\n", + "input_v4l: error opening v4l device (%s): %s\n", entry->str_value, strerror(errno)); return 0; } - + lprintf("Device opened, radio %d\n", this->radio_fd); - + if (set_input_source(this, this->tuner_name) > 0) tuner_found = 1; - + _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 0); - + /* Pre-allocate some frames for audio so it doesn't have to be done during * capture */ allocate_frames(this, 0); - + this->audio_only = 1; - + /* Unmute audio off video capture device */ unmute_audio(this); - - set_frequency(this, this->frequency); - + + set_frequency(this, this->frequency); + if (tuner_found) return 1; else @@ -868,20 +868,20 @@ static int open_video_capture_device(v4l_input_plugin_t *this) int ret; unsigned int j; cfg_entry_t *entry; - + lprintf("open_video_capture_device\n"); - - entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, + + entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, "media.video4linux.video_device"); /* Try to open the video device */ if((this->video_fd = open(entry->str_value, O_RDWR)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "input_v4l: error opening v4l device (%s): %s\n", + "input_v4l: error opening v4l device (%s): %s\n", entry->str_value, strerror(errno)); return 0; } - + lprintf("Device opened, tv %d\n", this->video_fd); /* figure out the resolution */ @@ -895,7 +895,7 @@ static int open_video_capture_device(v4l_input_plugin_t *this) break; } } - + if (found == 0 || resolutions[j].width < this->video_cap.minwidth || resolutions[j].height < this->video_cap.minheight) { @@ -903,19 +903,19 @@ static int open_video_capture_device(v4l_input_plugin_t *this) lprintf("Grab device does not support any preset resolutions"); return 0; } - + this->resolution = &resolutions[j]; - + _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); - - /* Pre-allocate some frames for audio and video so it doesn't have to be + + /* Pre-allocate some frames for audio and video so it doesn't have to be * done during capture */ allocate_frames(this, 1); - + /* Unmute audio off video capture device */ unmute_audio(this); - + if (strlen(this->tuner_name) > 0) { /* Tune into source and given frequency */ if (set_input_source(this, this->tuner_name) <= 0) @@ -923,20 +923,20 @@ static int open_video_capture_device(v4l_input_plugin_t *this) else tuner_found = 1; } - - set_frequency(this, this->frequency); - + + set_frequency(this, this->frequency); + /* Test for mmap video access */ ret = ioctl(this->video_fd,VIDIOCGMBUF, &this->gb_buffers); - + if (ret < 0) { /* Device driver does not support mmap */ /* try to use read based access */ struct video_picture pict; int val; - + ioctl(this->video_fd, VIDIOCGPICT, &pict); - + /* try to choose a suitable video format */ pict.palette = VIDEO_PALETTE_YUV420P; ret = ioctl(this->video_fd, VIDIOCSPICT, &pict); @@ -954,13 +954,13 @@ static int open_video_capture_device(v4l_input_plugin_t *this) } else lprintf("Grab: format YUV 4:2:0\n"); - + this->frame_format = pict.palette; val = 1; ioctl(this->video_fd, VIDIOCCAPTURE, &val); - + this->use_mmap = 0; - + } else { /* Good, device driver support mmap. Mmap the memory */ lprintf("using mmap, size %d\n", this->gb_buffers.size); @@ -974,23 +974,23 @@ static int open_video_capture_device(v4l_input_plugin_t *this) return 0; } this->gb_frame = 0; - + /* start to grab the first frame */ this->gb_buf.frame = (this->gb_frame + 1) % this->gb_buffers.frames; this->gb_buf.height = resolutions[j].height; this->gb_buf.width = resolutions[j].width; this->gb_buf.format = VIDEO_PALETTE_YUV420P; - + ret = ioctl(this->video_fd, VIDIOCMCAPTURE, &this->gb_buf); if (ret < 0 && errno != EAGAIN) { /* try YUV422 */ this->gb_buf.format = VIDEO_PALETTE_YUV422; - + ret = ioctl(this->video_fd, VIDIOCMCAPTURE, &this->gb_buf); } else lprintf("(%d) YUV420 should work\n", ret); - + if (ret < 0) { if (errno != EAGAIN) { lprintf("grab device does not support suitable format\n"); @@ -1003,7 +1003,7 @@ static int open_video_capture_device(v4l_input_plugin_t *this) this->frame_format = this->gb_buf.format; this->use_mmap = 1; } - + switch(this->frame_format) { case VIDEO_PALETTE_YUV420P: this->frame_format = BUF_VIDEO_I420; @@ -1014,19 +1014,19 @@ static int open_video_capture_device(v4l_input_plugin_t *this) this->frame_size = resolutions[j].width * resolutions[j].height * 2; break; } - - /* Strip the vbi / sync signal from the image by zooming in */ + + /* Strip the vbi / sync signal from the image by zooming in */ this->old_zoomx = xine_get_param(this->stream, XINE_PARAM_VO_ZOOM_X); this->old_zoomy = xine_get_param(this->stream, XINE_PARAM_VO_ZOOM_Y); - + xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_X, 103); xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_Y, 103); - /* Pre-allocate some frames for audio and video so it doesn't have to be + /* Pre-allocate some frames for audio and video so it doesn't have to be * done during capture */ allocate_frames(this, 1); - /* If we made it here, everything went ok */ + /* If we made it here, everything went ok */ this->audio_only = 0; if (tuner_found) return 1; @@ -1050,98 +1050,98 @@ static int open_audio_capture_device(v4l_input_plugin_t *this) /* Allocate the snd_pcm_hw_params_t structure on the stack. */ snd_pcm_hw_params_alloca(&this->pcm_hwparams); - + /* If we are not capturing video, open the sound device in blocking mode, * otherwise xine gets too many NULL bufs and doesn't seem to handle them * correctly. If we are capturing video, open the sound device in non- * blocking mode, otherwise we will loose video frames while waiting */ if(!this->audio_only) mode = SND_PCM_NONBLOCK; - + /* Open the PCM device. */ if(snd_pcm_open(&this->pcm_handle, this->pcm_name, this->pcm_stream, mode) < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error opening PCM device: %s\n", this->pcm_name); this->audio_capture = 0; } - + /* Get parameters */ if (this->audio_capture && (snd_pcm_hw_params_any(this->pcm_handle, this->pcm_hwparams) < 0)) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Broken configuration for PCM device: No configurations available\n"); this->audio_capture = 0; } - + /* Set access type */ if (this->audio_capture && (snd_pcm_hw_params_set_access(this->pcm_handle, this->pcm_hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0)) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error setting SND_PCM_ACCESS_RW_INTERLEAVED\n"); this->audio_capture = 0; } - + /* Set sample format */ if (this->audio_capture && - (snd_pcm_hw_params_set_format(this->pcm_handle, + (snd_pcm_hw_params_set_format(this->pcm_handle, this->pcm_hwparams, SND_PCM_FORMAT_S16_LE) < 0)) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error setting SND_PCM_FORMAT_S16_LE\n"); this->audio_capture = 0; } - + /* Set sample rate */ this->exact_rate = this->rate; if (this->audio_capture && - (snd_pcm_hw_params_set_rate_near(this->pcm_handle, this->pcm_hwparams, + (snd_pcm_hw_params_set_rate_near(this->pcm_handle, this->pcm_hwparams, &this->exact_rate, &this->dir) < 0)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error setting samplerate\n"); this->audio_capture = 0; } if (this->audio_capture && this->dir != 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Samplerate %d Hz is not supported by your hardware\n", this->rate); - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Using %d instead\n", this->exact_rate); } - + /* Set number of channels */ if (this->audio_capture && (snd_pcm_hw_params_set_channels(this->pcm_handle, this->pcm_hwparams, 2) < 0)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error setting PCM channels\n"); this->audio_capture = 0; } - + if (this->audio_capture && (snd_pcm_hw_params_set_periods(this->pcm_handle, this->pcm_hwparams, this->periods, 0) < 0)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error setting PCM periods\n"); this->audio_capture = 0; } - + /* Set buffersize */ if (this->audio_capture && - (snd_pcm_hw_params_set_buffer_size_near(this->pcm_handle, + (snd_pcm_hw_params_set_buffer_size_near(this->pcm_handle, this->pcm_hwparams, &buf_size) < 0)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error setting PCM buffer size to %d\n", (int)buf_size ); this->audio_capture = 0; } - + /* Apply HW parameter settings */ if (this->audio_capture && (snd_pcm_hw_params(this->pcm_handle, this->pcm_hwparams) < 0)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error Setting PCM HW params\n"); this->audio_capture = 0; } - + if (this->audio_capture) { lprintf("Allocating memory for PCM capture :%d\n", this->periodsize); this->pcm_data = (unsigned char*) malloc(this->periodsize); } else - this->pcm_data = NULL; - + this->pcm_data = NULL; + lprintf("Audio device succesfully configured\n"); #endif return 0; @@ -1157,30 +1157,30 @@ static int v4l_adjust_realtime_speed(v4l_input_plugin_t *this, fifo_buffer_t *fi { int num_used, num_free; int scr_tuning = this->scr_tuning; - + if (fifo == NULL) return 0; - + num_used = fifo->size(fifo); num_free = NUM_FRAMES - num_used; - + if (!this->audio_only && num_used == 0 && scr_tuning != SCR_PAUSED) { /* Buffer is empty, and we did not pause playback */ report_progress(this->stream, SCR_PAUSED); - - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_v4l: Buffer empty, pausing playback (used: %d, num_free: %d)\n", num_used, num_free); - + _x_set_speed(this->stream, XINE_SPEED_PAUSE); this->stream->xine->clock->set_option (this->stream->xine->clock, CLOCK_SCR_ADJUSTABLE, 0); - + this->scr_tuning = SCR_PAUSED; /* pvrscr_speed_tuning(this->scr, 0.0); */ - + } else if (num_free <= 1 && scr_tuning != SCR_SKIP) { this->scr_tuning = SCR_SKIP; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_v4l: Buffer full, skipping (used: %d, free: %d)\n", num_used, num_free); return 0; } else if (scr_tuning == SCR_PAUSED) { @@ -1188,11 +1188,11 @@ static int v4l_adjust_realtime_speed(v4l_input_plugin_t *this, fifo_buffer_t *fi /* Playback was paused, but we have normal buffer usage again */ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_v4l: Resuming from paused (used: %d, free: %d)\n", num_used, num_free); - + this->scr_tuning = 0; - + pvrscr_speed_tuning(this->scr, 1.0); - + _x_set_speed(this->stream, XINE_SPEED_NORMAL); this->stream->xine->clock->set_option (this->stream->xine->clock, CLOCK_SCR_ADJUSTABLE, 1); } @@ -1217,12 +1217,12 @@ static int v4l_adjust_realtime_speed(v4l_input_plugin_t *this, fifo_buffer_t *fi (scr_tuning < 0 && num_used > num_free)) /* Buffer usage is ok again. Set playback speed to normal */ scr_tuning = 0; - - /* Check if speed adjustment should be changed */ + + /* Check if speed adjustment should be changed */ if (scr_tuning != this->scr_tuning) { this->scr_tuning = scr_tuning; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "input_v4l: scr tuning = %d (used: %d, free: %d)\n", + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "input_v4l: scr tuning = %d (used: %d, free: %d)\n", scr_tuning, num_used, num_free); pvrscr_speed_tuning(this->scr, 1.0 + (0.01 * scr_tuning)); } @@ -1232,13 +1232,13 @@ static int v4l_adjust_realtime_speed(v4l_input_plugin_t *this, fifo_buffer_t *fi * speed */ this->scr_tuning = 0; - + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_v4l: scr tuning resetting (used: %d, free: %d\n", num_used, num_free); - + pvrscr_speed_tuning(this->scr, 1.0); } - + return 1; } @@ -1275,15 +1275,15 @@ static buf_element_t *v4l_plugin_read_block (input_plugin_t *this_gen, fifo_buff uint8_t *ptr; static char video = 0; int speed = _x_get_speed(this->stream); - - v4l_event_handler(this); - + + v4l_event_handler(this); + #ifdef HAVE_ALSA if (!this->audio_header_sent) { lprintf("sending audio header\n"); - + buf = alloc_aud_frame (this); - + buf->size = 0; buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END; @@ -1291,60 +1291,60 @@ static buf_element_t *v4l_plugin_read_block (input_plugin_t *this_gen, fifo_buff buf->decoder_info[1] = this->exact_rate; buf->decoder_info[2] = this->bits; buf->decoder_info[3] = 2; - + this->audio_header_sent = 1; - + return buf; } -#endif - +#endif + if (!this->audio_only && !this->video_header_sent) { xine_bmiheader bih; - + lprintf("sending video header"); - + bih.biSize = sizeof(xine_bmiheader); bih.biWidth = this->resolution->width; bih.biHeight = this->resolution->height; - + buf = alloc_vid_frame (this); - + buf->size = sizeof(xine_bmiheader); buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END; memcpy(buf->content, &bih, sizeof(xine_bmiheader)); - + this->video_header_sent = 1; - - return buf; + + return buf; } - + if (!this->audio_only) { if (!v4l_adjust_realtime_speed(this, fifo, speed)) { return NULL; } } - - if (!this->audio_only) + + if (!this->audio_only) video = !video; else video = 0; - + lprintf("%lld bytes...\n", todo); - - if (this->start_time == 0) + + if (this->start_time == 0) /* Create a start pts value */ this->start_time = get_time(); /* this->stream->xine->clock->get_current_time(this->stream->xine->clock); */ - + if (video) { /* Capture video */ buf = alloc_vid_frame (this); buf->decoder_flags = BUF_FLAG_FRAME_START|BUF_FLAG_FRAME_END; - + this->gb_buf.frame = this->gb_frame; - + lprintf("VIDIOCMCAPTURE\n"); - + while (ioctl(this->video_fd, VIDIOCMCAPTURE, &this->gb_buf) < 0) { lprintf("Upper while loop\n"); if (errno == EAGAIN) { @@ -1356,92 +1356,92 @@ static buf_element_t *v4l_plugin_read_block (input_plugin_t *this_gen, fifo_buff return NULL; } } - + this->gb_frame = (this->gb_frame + 1) % this->gb_buffers.frames; - + while (ioctl(this->video_fd, VIDIOCSYNC, &this->gb_frame) < 0 && (errno == EAGAIN || errno == EINTR)) { lprintf("Waiting for videosync\n"); } - + /* printf ("grabbing frame #%d\n", frame_num); */ - + ptr = this->video_buf + this->gb_buffers.offsets[this->gb_frame]; buf->pts = get_time(); /* this->stream->xine->clock->get_current_time(this->stream->xine->clock); */ - xine_fast_memcpy (buf->content, ptr, this->frame_size); + xine_fast_memcpy (buf->content, ptr, this->frame_size); } #ifdef HAVE_ALSA else if (this->audio_capture) { /* Record audio */ int pcmreturn; - - if ((pcmreturn = snd_pcm_readi(this->pcm_handle, this->pcm_data, (this->periodsize)>> 2)) < 0) { + + if ((pcmreturn = snd_pcm_readi(this->pcm_handle, this->pcm_data, (this->periodsize)>> 2)) < 0) { switch (pcmreturn) { case -EAGAIN: /* No data available at the moment */ break; case -EBADFD: /* PCM device in wrong state */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: PCM is not in the right state\n"); break; case -EPIPE: /* Buffer overrun */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: PCM buffer Overrun (lost some samples)\n"); /* On buffer overrun we need to re prepare the capturing pcm device */ snd_pcm_prepare(this->pcm_handle); break; case -ESTRPIPE: /* Suspend event */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: PCM suspend event occured\n"); break; default: /* Unknown */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Unknown PCM error code: %d\n", pcmreturn); snd_pcm_prepare(this->pcm_handle); } } else { /* Succesfully read audio data */ - + if (this->pts_aud_start) { buf = alloc_aud_frame (this); buf->decoder_flags = 0; } - + /* We want the pts on the start of the sample. As the soundcard starts * sampling a new sample as soon as the read function returned with a - * success we will save the current pts and assign the current pts to + * success we will save the current pts and assign the current pts to * that sample when we read it */ - + /* Assign start pts to sample */ if (buf) buf->pts = this->pts_aud_start; - + /* Save start pts */ this->pts_aud_start = get_time(); /* this->stream->xine->clock->get_current_time(this->stream->xine->clock); */ - + if (!buf) /* Skip first sample as we don't have a good pts for this one */ return NULL; - + lprintf("Audio: Data read: %d [%d, %d]. Pos: %d\n", pcmreturn, (int) (*this->pcm_data), (int) (*(this->pcm_data + this->periodsize - 3)), (int) this->curpos); - - + + /* Tell decoder the number of bytes we have read */ - buf->size = pcmreturn<<2; - + buf->size = pcmreturn<<2; + this->curpos++; - + xine_fast_memcpy(buf->content, this->pcm_data, buf->size); } } #endif - + lprintf("read block done\n"); - + return buf; } @@ -1451,7 +1451,7 @@ static buf_element_t *v4l_plugin_read_block (input_plugin_t *this_gen, fifo_buff */ static off_t v4l_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; - + lprintf("seek %lld bytes, origin %d\n", offset, origin); return this->curpos; } @@ -1462,10 +1462,10 @@ static off_t v4l_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin */ static off_t v4l_plugin_get_length (input_plugin_t *this_gen) { /* - v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; + v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; off_t length; */ - + return -1; } @@ -1475,8 +1475,8 @@ static off_t v4l_plugin_get_length (input_plugin_t *this_gen) { */ static uint32_t v4l_plugin_get_capabilities (input_plugin_t *this_gen) { - v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; - + v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; + if (this->audio_only) return 0x10; else @@ -1498,26 +1498,26 @@ static uint32_t v4l_plugin_get_blocksize (input_plugin_t *this_gen) */ static off_t v4l_plugin_get_current_pos (input_plugin_t *this_gen){ v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; - + /* printf ("current pos is %lld\n", this->curpos); */ - + return this->curpos; } /** * Event handler. - * + * * Processes events from a frontend. This way frequencies can be changed * without closing the v4l plugin. */ static void v4l_event_handler (v4l_input_plugin_t *this) { xine_event_t *event; - + while ((event = xine_event_get (this->event_queue))) { xine_set_v4l2_data_t *v4l2_data = event->data; - + switch (event->type) { case XINE_EVENT_SET_V4L2: if( v4l2_data->input != this->input || @@ -1527,25 +1527,25 @@ static void v4l_event_handler (v4l_input_plugin_t *this) { this->input = v4l2_data->input; this->channel = v4l2_data->channel; this->frequency = v4l2_data->frequency; - + lprintf("Switching to input:%d chan:%d freq:%.2f\n", v4l2_data->input, v4l2_data->channel, (float)v4l2_data->frequency); set_frequency(this, this->frequency); - _x_demux_flush_engine(this->stream); + _x_demux_flush_engine(this->stream); } break; /* default: - + lprintf("Got an event, type 0x%08x\n", event->type); */ } - + xine_event_free (event); } -} +} /** * Dispose plugin. @@ -1555,69 +1555,69 @@ static void v4l_event_handler (v4l_input_plugin_t *this) { */ static void v4l_plugin_dispose (input_plugin_t *this_gen) { v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; - + if(this->mrl) free(this->mrl); - + if (this->scr) { this->stream->xine->clock->unregister_scr(this->stream->xine->clock, &this->scr->scr); this->scr->scr.exit(&this->scr->scr); } - + /* Close and free video device */ if (this->tuner_name) free(this->tuner_name); - + /* Close video device only if device was openend */ if (this->video_fd > 0) { - + /* Restore v4l audio volume */ - lprintf("Restoring v4l audio volume %d\n", + lprintf("Restoring v4l audio volume %d\n", ioctl(this->video_fd, VIDIOCSAUDIO, &this->audio_saved)); ioctl(this->video_fd, VIDIOCSAUDIO, &this->audio_saved); - + /* Unmap memory */ - if (this->video_buf != NULL && + if (this->video_buf != NULL && munmap(this->video_buf, this->gb_buffers.size) != 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Could not unmap video memory: %s\n", strerror(errno)); } else lprintf("Succesfully unmapped video memory (size %d)\n", this->gb_buffers.size); - + lprintf("Closing video filehandler %d\n", this->video_fd); - + /* Now close the video device */ if (close(this->video_fd) != 0) - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Error while closing video file handler: %s\n", strerror(errno)); else lprintf("Video device succesfully closed\n"); - - /* Restore zoom setting */ + + /* Restore zoom setting */ xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_X, this->old_zoomx); xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_Y, this->old_zoomy); } - + if (this->radio_fd > 0) { close(this->radio_fd); } - + #ifdef HAVE_ALSA /* Close audio device */ if (this->pcm_handle) { snd_pcm_drop(this->pcm_handle); snd_pcm_close(this->pcm_handle); } - + if (this->pcm_data) { free(this->pcm_data); } - + if (this->pcm_name) { free(this->pcm_name); } #endif - + if (this->event_queue) xine_event_dispose_queue (this->event_queue); @@ -1636,9 +1636,9 @@ static void v4l_plugin_dispose (input_plugin_t *this_gen) { #ifdef LOG printf("\n"); #endif - + free (this); - + lprintf("plugin Bye bye! \n"); } @@ -1649,11 +1649,11 @@ static void v4l_plugin_dispose (input_plugin_t *this_gen) { */ static const char* v4l_plugin_get_mrl (input_plugin_t *this_gen) { v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; - + return this->mrl; } -static int v4l_plugin_get_optional_data (input_plugin_t *this_gen, +static int v4l_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { /* v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; */ @@ -1663,19 +1663,19 @@ static int v4l_plugin_get_optional_data (input_plugin_t *this_gen, static int v4l_plugin_radio_open (input_plugin_t *this_gen) { v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; - + if(open_radio_capture_device(this) != 1) return 0; - + open_audio_capture_device(this); - + #ifdef HAVE_ALSA this->start_time = 0; this->pts_aud_start = 0; this->curpos = 0; this->event_queue = xine_event_new_queue (this->stream); -#endif - +#endif + return 1; } @@ -1684,30 +1684,30 @@ static int v4l_plugin_video_open (input_plugin_t *this_gen) { v4l_input_plugin_t *this = (v4l_input_plugin_t *) this_gen; int64_t time; - + if(!open_video_capture_device(this)) return 0; - + open_audio_capture_device(this); - + #ifdef HAVE_ALSA this->pts_aud_start = 0; #endif this->start_time = 0; this->curpos = 0; - + /* Register our own scr provider */ time = this->stream->xine->clock->get_current_time(this->stream->xine->clock); this->scr = pvrscr_init(); this->scr->scr.start(&this->scr->scr, time); this->stream->xine->clock->register_scr(this->stream->xine->clock, &this->scr->scr); this->scr_tuning = 0; - + /* enable resample method */ this->stream->xine->config->update_num(this->stream->xine->config, "audio.synchronization.av_sync_method", 1); - + this->event_queue = xine_event_new_queue (this->stream); - + return 1; } @@ -1726,19 +1726,19 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen, cfg_entry_t *entry; #endif char *mrl = strdup(data); - + /* Example mrl: v4l:/Television/62500 */ if(!mrl || strncasecmp(mrl, "v4l:/", 5)) { free(mrl); return NULL; } - + this = calloc(1, sizeof (v4l_input_plugin_t)); - + extract_mrl(this, mrl); - - this->stream = stream; - this->mrl = mrl; + + this->stream = stream; + this->mrl = mrl; this->video_buf = NULL; this->video_fd = -1; this->radio_fd = -1; @@ -1747,7 +1747,7 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen, #ifdef HAVE_ALSA this->pcm_data = NULL; this->pcm_hwparams = NULL; - + /* Audio */ this->pcm_stream = SND_PCM_STREAM_CAPTURE; entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, @@ -1759,13 +1759,13 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen, this->periods = 2; this->periodsize = 2 * 8192; this->bits = 16; - + pthread_mutex_init (&this->aud_frames_lock, NULL); pthread_cond_init (&this->aud_frame_freed, NULL); - + pthread_mutex_init (&this->vid_frames_lock, NULL); pthread_cond_init (&this->vid_frame_freed, NULL); - + this->input_plugin.get_capabilities = v4l_plugin_get_capabilities; this->input_plugin.read = v4l_plugin_read; this->input_plugin.read_block = v4l_plugin_read_block; @@ -1777,7 +1777,7 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen, this->input_plugin.dispose = v4l_plugin_dispose; this->input_plugin.get_optional_data = v4l_plugin_get_optional_data; this->input_plugin.input_class = cls_gen; - + return &this->input_plugin; } @@ -1787,57 +1787,57 @@ static input_plugin_t *v4l_class_get_video_instance (input_class_t *cls_gen, v4l_input_plugin_t *this = NULL; int is_ok = 1; cfg_entry_t *entry; - + this = (v4l_input_plugin_t *) v4l_class_get_instance (cls_gen, stream, data); - + if (this) this->input_plugin.open = v4l_plugin_video_open; else return NULL; - - entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, + + entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, "media.video4linux.video_device"); - + /* Try to open the video device */ if((this->video_fd = open(entry->str_value, O_RDWR)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "input_v4l: error opening v4l device (%s): %s\n", + "input_v4l: error opening v4l device (%s): %s\n", entry->str_value, strerror(errno)); is_ok = 0; } else lprintf("Device opened, tv %d\n", this->video_fd); - + /* Get capabilities */ if (is_ok && ioctl(this->video_fd, VIDIOCGCAP, &this->video_cap) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: v4l card doesn't support some features needed by xine\n"); is_ok = 0;; } - + if (is_ok && !(this->video_cap.type & VID_TYPE_CAPTURE)) { /* Capture is not supported by the device. This is a must though! */ xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: v4l card doesn't support frame grabbing\n"); is_ok = 0; } - + if (is_ok && set_input_source(this, this->tuner_name) <= 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: unable to locate the tuner name (%s) on your v4l card\n", this->tuner_name); is_ok = 0; } - + if (this->video_fd > 0) { close(this->video_fd); this->video_fd = -1; } - + if (!is_ok) { v4l_plugin_dispose((input_plugin_t *) this); return NULL; } - + return &this->input_plugin; } @@ -1848,45 +1848,45 @@ static input_plugin_t *v4l_class_get_radio_instance (input_class_t *cls_gen, v4l_input_plugin_t *this = NULL; int is_ok = 1; cfg_entry_t *entry; - + if (strstr(data, "Radio") == NULL) return NULL; - + this = (v4l_input_plugin_t *) v4l_class_get_instance (cls_gen, stream, data); - + if (this) this->input_plugin.open = v4l_plugin_radio_open; else return NULL; - - entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, + + entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, "media.video4linux.radio_device"); - + if((this->radio_fd = open(entry->str_value, O_RDWR)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "input_v4l: error opening v4l device (%s): %s\n", + "input_v4l: error opening v4l device (%s): %s\n", entry->str_value, strerror(errno)); is_ok = 0; } else lprintf("Device opened, radio %d\n", this->radio_fd); - + if (is_ok && set_input_source(this, this->tuner_name) <= 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: unable to locate the tuner name (%s) on your v4l card\n", this->tuner_name); is_ok = 0; } - + if (this->radio_fd > 0) { close(this->radio_fd); this->radio_fd = -1; } - + if (!is_ok) { v4l_plugin_dispose((input_plugin_t *) this); return NULL; } - + return &this->input_plugin; } @@ -1898,11 +1898,11 @@ static void *init_video_class (xine_t *xine, void *data) { v4l_input_class_t *this; config_values_t *config = xine->config; - + this = calloc(1, sizeof (v4l_input_class_t)); - + this->xine = xine; - + this->input_class.get_instance = v4l_class_get_video_instance; this->input_class.identifier = "v4l"; this->input_class.description = N_("v4l tv input plugin"); @@ -1910,7 +1910,7 @@ static void *init_video_class (xine_t *xine, void *data) this->input_class.get_autoplay_list = NULL; this->input_class.dispose = default_input_class_dispose; this->input_class.eject_media = NULL; - + config->register_filename (config, "media.video4linux.video_device", VIDEO_DEV, XINE_CONFIG_STRING_IS_DEVICE_NAME, _("v4l video device"), @@ -1936,11 +1936,11 @@ static void *init_radio_class (xine_t *xine, void *data) { v4l_input_class_t *this; config_values_t *config = xine->config; - + this = calloc(1, sizeof (v4l_input_class_t)); - + this->xine = xine; - + this->input_class.get_instance = v4l_class_get_radio_instance; this->input_class.identifier = "v4l"; this->input_class.description = N_("v4l radio input plugin"); @@ -1948,13 +1948,13 @@ static void *init_radio_class (xine_t *xine, void *data) this->input_class.get_autoplay_list = NULL; this->input_class.dispose = default_input_class_dispose; this->input_class.eject_media = NULL; - + config->register_filename (config, "media.video4linux.radio_device", RADIO_DEV, XINE_CONFIG_STRING_IS_DEVICE_NAME, _("v4l radio device"), _("The path to your Video4Linux radio device."), 10, NULL, NULL); - + return this; } @@ -1963,12 +1963,12 @@ static void *init_radio_class (xine_t *xine, void *data) */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "v4l_radio", XINE_VERSION_CODE, NULL, init_radio_class }, { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "v4l_tv", XINE_VERSION_CODE, NULL, init_video_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; /* - * vim:sw=3:sts=3: + * vim:sw=3:sts=3: */ diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index ccc75a45a..8f780de29 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -105,11 +105,11 @@ typedef struct { typedef struct { input_plugin_t input_plugin; - + vcd_input_class_t *cls; - + xine_stream_t *stream; - + char *mrl; config_values_t *config; @@ -136,7 +136,7 @@ typedef struct { */ static void device_change_cb (void *data, xine_cfg_entry_t *cfg) { vcd_input_class_t *this = (vcd_input_class_t *) data; - + this->device = cfg->str_value; } @@ -146,7 +146,7 @@ static int input_vcd_read_toc (vcd_input_class_t *this, int fd) { /* read TOC header */ if ( ioctl(fd, CDROMREADTOCHDR, &this->tochdr) == -1 ) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_vcd : error in ioctl CDROMREADTOCHDR\n"); return -1; } @@ -156,7 +156,7 @@ static int input_vcd_read_toc (vcd_input_class_t *this, int fd) { this->tocent[i-1].cdte_track = i; this->tocent[i-1].cdte_format = CDROM_MSF; if ( ioctl(fd, CDROMREADTOCENTRY, &this->tocent[i-1]) == -1 ) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_vcd: error in ioctl CDROMREADTOCENTRY for track %d\n", i); return -1; } @@ -166,9 +166,9 @@ static int input_vcd_read_toc (vcd_input_class_t *this, int fd) { this->tocent[this->tochdr.cdth_trk1].cdte_track = CDROM_LEADOUT; this->tocent[this->tochdr.cdth_trk1].cdte_format = CDROM_MSF; - if (ioctl(fd, CDROMREADTOCENTRY, + if (ioctl(fd, CDROMREADTOCENTRY, &this->tocent[this->tochdr.cdth_trk1]) == -1 ) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_vcd: error in ioctl CDROMREADTOCENTRY for lead-out\n"); return -1; } @@ -185,23 +185,23 @@ static int input_vcd_read_toc (vcd_input_class_t *this, int fd) { /* read TOC header */ if ( ioctl(fd, CDIOREADTOCHEADER, &this->tochdr) == -1 ) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_vcd : error in ioctl CDROMREADTOCHDR\n"); return -1; } - ntracks = this->tochdr.ending_track + ntracks = this->tochdr.ending_track - this->tochdr.starting_track + 2; this->tocent = (struct cd_toc_entry *) xine_xmalloc(sizeof(*this->tocent) * ntracks); - + te.address_format = CD_LBA_FORMAT; te.starting_track = 0; te.data_len = ntracks * sizeof(struct cd_toc_entry); te.data = this->tocent; - + if ( ioctl(fd, CDIOREADTOCENTRYS, &te) == -1 ){ - xprintf (this->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_vcd: error in ioctl CDROMREADTOCENTRY\n"); return -1; } @@ -232,11 +232,11 @@ static int sun_vcd_read(vcd_input_plugin_t *this, long lba, cdsector_t *data) */ if (this->controller_type == 0) { if ( ioctl(this->fd, DKIOCINFO, &cinfo) == 0 - && ((strcmp(cinfo.dki_cname, "ide") == 0) + && ((strcmp(cinfo.dki_cname, "ide") == 0) || (strncmp(cinfo.dki_cname, "pci", 3) == 0)) ) this->controller_type = SUN_CTRL_ATAPI; else - this->controller_type = SUN_CTRL_SCSI; + this->controller_type = SUN_CTRL_SCSI; } switch (this->controller_type) { case SUN_CTRL_SCSI: @@ -247,7 +247,7 @@ static int sun_vcd_read(vcd_input_plugin_t *this, long lba, cdsector_t *data) cdxa.cdxa_length = 1; cdxa.cdxa_data = data->subheader; cdxa.cdxa_format = CDROM_XA_SECTOR_DATA; - + if(ioctl(this->fd,CDROMCDXA,&cdxa)==-1) { xprintf(this->cls->xine, XINE_VERBOSITY_DEBUG, "CDROMCDXA: %s\n", strerror(errno)); return -1; @@ -304,12 +304,12 @@ static int sun_vcd_read(vcd_input_plugin_t *this, long lba, cdsector_t *data) cdb.cdb_opaque[7] = (blocks >> 8) & 0xff; cdb.cdb_opaque[8] = blocks & 0xff; cdb.cdb_opaque[9] = (sync << 7) | - (header_code << 5) | - (user_data << 4) | - (edc_ecc << 3) | - (error_field << 1); + (header_code << 5) | + (user_data << 4) | + (edc_ecc << 3) | + (error_field << 1); cdb.cdb_opaque[10] = sub_channel; - + sc.uscsi_cdb = (caddr_t)&cdb; sc.uscsi_cdblen = 12; sc.uscsi_bufaddr = (caddr_t)data->subheader; @@ -321,7 +321,7 @@ static int sun_vcd_read(vcd_input_plugin_t *this, long lba, cdsector_t *data) return -1; } if (sc.uscsi_status) { - xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, "scsi command failed with status %d\n", sc.uscsi_status); return -1; } @@ -336,9 +336,9 @@ static int sun_vcd_read(vcd_input_plugin_t *this, long lba, cdsector_t *data) /* ***************************************************************** */ #if defined (__linux__) -static off_t vcd_plugin_read (input_plugin_t *this_gen, +static off_t vcd_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t nlen) { - + vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; char *buf = (char *)buf_gen; static struct cdrom_msf msf ; @@ -349,14 +349,14 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, return 0; do - { + { end_msf = (struct cdrom_msf0 *) &this->cls->tocent[this->cur_track+1].cdte_addr.msf; /* printf ("cur: %02d:%02d:%02d end: %02d:%02d:%02d\n", - this->cur_min, this->cur_sec, this->cur_frame, - end_msf->minute, end_msf->second, end_msf->frame); + this->cur_min, this->cur_sec, this->cur_frame, + end_msf->minute, end_msf->second, end_msf->frame); */ if ( (this->cur_min>=end_msf->minute) && (this->cur_sec>=end_msf->second) @@ -370,7 +370,7 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, memcpy (&data, &msf, sizeof (msf)); if (ioctl (this->fd, CDROMREADRAW, &data) == -1) { - xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, "input_vcd: error in CDROMREADRAW\n"); return 0; } @@ -385,17 +385,17 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, this->cur_min++; } } - + /* Header ID check for padding sector. VCD uses this to keep constant bitrate so the CD doesn't stop/start */ } while((data.subheader[2]&~0x01)==0x60); - + memcpy (buf, data.data, VCDSECTORSIZE); /* FIXME */ return VCDSECTORSIZE; } #elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) -static off_t vcd_plugin_read (input_plugin_t *this_gen, +static off_t vcd_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t nlen) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; char *buf = (char *)buf_gen; @@ -420,9 +420,9 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, return VCDSECTORSIZE; } #elif defined (__sun) -static off_t vcd_plugin_read (input_plugin_t *this_gen, +static off_t vcd_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t nlen) { - + vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; char *buf = (char *)buf_gen; static cdsector_t data; @@ -433,14 +433,14 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, return 0; do - { - end_msf = (struct cdrom_msf0 *) + { + end_msf = (struct cdrom_msf0 *) &this->cls->tocent[this->cur_track+1].cdte_addr.msf; /* printf ("cur: %02d:%02d:%02d end: %02d:%02d:%02d\n", - this->cur_min, this->cur_sec, this->cur_frame, - end_msf->minute, end_msf->second, end_msf->frame); + this->cur_min, this->cur_sec, this->cur_frame, + end_msf->minute, end_msf->second, end_msf->frame); */ if ( (this->cur_min>=end_msf->minute) && (this->cur_sec>=end_msf->second) @@ -463,21 +463,21 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, this->cur_min++; } } - + /* Header ID check for padding sector. VCD uses this to keep constant bitrate so the CD doesn't stop/start */ } while((data.subheader[2]&~0x01)==0x60); - + memcpy (buf, data.data, VCDSECTORSIZE); /* FIXME */ return VCDSECTORSIZE; } #endif #if defined (__linux__) -static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, +static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t nlen) { - + vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; buf_element_t *buf; static struct cdrom_msf msf ; @@ -488,13 +488,13 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, return NULL; do - { + { end_msf = &this->cls->tocent[this->cur_track+1].cdte_addr.msf; /* printf ("cur: %02d:%02d:%02d end: %02d:%02d:%02d\n", - this->cur_min, this->cur_sec, this->cur_frame, - end_msf->minute, end_msf->second, end_msf->frame); + this->cur_min, this->cur_sec, this->cur_frame, + end_msf->minute, end_msf->second, end_msf->frame); */ if ( (this->cur_min>=end_msf->minute) && (this->cur_sec>=end_msf->second) @@ -522,12 +522,12 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, this->cur_min++; } } - + /* Header ID check for padding sector. VCD uses this to keep constant bitrate so the CD doesn't stop/start */ } while((data.subheader[2]&~0x01)==0x60); - + buf = fifo->buffer_pool_alloc (fifo); buf->content = buf->mem; buf->type = BUF_DEMUX_BLOCK; @@ -535,9 +535,9 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, return buf; } #elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) -static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, +static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t nlen) { - + vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; buf_element_t *buf; static cdsector_t data; @@ -565,9 +565,9 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, return buf; } #elif defined(__sun) -static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, +static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t nlen) { - + vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; buf_element_t *buf; static cdsector_t data; @@ -578,14 +578,14 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, return NULL; do - { - end_msf = (struct cdrom_msf0 *) + { + end_msf = (struct cdrom_msf0 *) &this->cls->tocent[this->cur_track+1].cdte_addr.msf; /* printf ("cur: %02d:%02d:%02d end: %02d:%02d:%02d\n", - this->cur_min, this->cur_sec, this->cur_frame, - end_msf->minute, end_msf->second, end_msf->frame); + this->cur_min, this->cur_sec, this->cur_frame, + end_msf->minute, end_msf->second, end_msf->frame); */ if ( (this->cur_min>=end_msf->minute) && (this->cur_sec>=end_msf->second) @@ -609,12 +609,12 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, this->cur_min++; } } - + /* Header ID check for padding sector. VCD uses this to keep constant bitrate so the CD doesn't stop/start */ } while((data.subheader[2]&~0x01)==0x60); - + buf = fifo->buffer_pool_alloc (fifo); buf->content = buf->mem; buf->type = BUF_DEMUX_BLOCK; @@ -628,17 +628,17 @@ static off_t vcd_time_to_offset (int min, int sec, int frame) { return min * 60 * 75 + sec * 75 + frame; } -static void vcd_offset_to_time (off_t offset, uint8_t *min, uint8_t *sec, +static void vcd_offset_to_time (off_t offset, uint8_t *min, uint8_t *sec, uint8_t *frame) { *min = offset / (60*75); offset %= (60*75); - *sec = offset / 75; - *frame = offset % 75; + *sec = offset / 75; + *frame = offset % 75; } -static off_t vcd_plugin_seek (input_plugin_t *this_gen, +static off_t vcd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; @@ -650,11 +650,11 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, switch (origin) { case SEEK_SET: - sector_pos = (offset / VCDSECTORSIZE) + sector_pos = (offset / VCDSECTORSIZE) + vcd_time_to_offset (start_msf->minute, start_msf->second, start_msf->frame); - + vcd_offset_to_time (sector_pos, &this->cur_min, &this->cur_sec, &this->cur_frame); @@ -666,8 +666,8 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, break; case SEEK_CUR: - if (offset) - xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, + if (offset) + xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, "input_vcd: SEEK_CUR not implemented for offset != 0\n"); /* @@ -686,7 +686,7 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, break; default: - xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, "input_vcd: error seek to origin %d not implemented!\n", origin); return 0; } @@ -694,7 +694,7 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, return offset ; /* FIXME */ } #elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) -static off_t vcd_plugin_seek (input_plugin_t *this_gen, +static off_t vcd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { @@ -703,11 +703,11 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, uint32_t dist ; off_t sector_pos; - start = + start = ntohl(this->cls->tocent [this->cur_track+1 - this->cls->tochdr.starting_track].addr.lba); - /* printf("seek: start sector:%lu, origin: %d, offset:%qu\n", + /* printf("seek: start sector:%lu, origin: %d, offset:%qu\n", start, origin, offset); */ @@ -718,7 +718,7 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, break; case SEEK_CUR: - if (offset) + if (offset) xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, "input_vcd: SEEK_CUR not implemented for offset != 0\n"); sector_pos = this->cur_sec; @@ -727,7 +727,7 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, break; default: - xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->cls->xine, XINE_VERBOSITY_DEBUG, "input_vcd: error seek to origin %d not implemented!\n", origin); return 0; } @@ -741,27 +741,27 @@ static off_t vcd_plugin_get_length (input_plugin_t *this_gen) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; struct cdrom_msf0 *end_msf, *start_msf; off_t len ; - + if(this->cls->total_tracks) { - + start_msf = (struct cdrom_msf0 *) &this->cls->tocent[this->cur_track].cdte_addr.msf; end_msf = (struct cdrom_msf0 *) &this->cls->tocent[this->cur_track+1].cdte_addr.msf; - + len = 75 - start_msf->frame; - + if (start_msf->second<60) len += (59 - start_msf->second) * 75; - + if (end_msf->minute > start_msf->minute) { len += (end_msf->minute - start_msf->minute-1) * 60 * 75; - + len += end_msf->second * 60; - + len += end_msf->frame ; } - + return len * VCDSECTORSIZE; } @@ -773,14 +773,14 @@ static off_t vcd_plugin_get_length (input_plugin_t *this_gen) { off_t len ; - len = + len = ntohl(this->cls->tocent - [this->cur_track+2 + [this->cur_track+2 - this->cls->tochdr.starting_track].addr.lba) - ntohl(this->cls->tocent - [this->cur_track+1 + [this->cur_track+1 - this->cls->tochdr.starting_track].addr.lba); - + return len * 2352; /*VCDSECTORSIZE;*/ } @@ -793,7 +793,7 @@ static off_t vcd_plugin_get_current_pos (input_plugin_t *this_gen){ } static uint32_t vcd_plugin_get_capabilities (input_plugin_t *this_gen) { - + return INPUT_CAP_SEEKABLE | INPUT_CAP_BLOCK ; } @@ -819,7 +819,7 @@ static const char* vcd_plugin_get_mrl (input_plugin_t *this_gen) { return this->mrl; } -static int vcd_plugin_get_optional_data (input_plugin_t *this_gen, +static int vcd_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { return INPUT_OPTIONAL_UNSUPPORTED; @@ -846,13 +846,13 @@ static int vcd_plugin_open (input_plugin_t *this_gen) { while (*filename == '/') filename++; if (sscanf (filename, "%d", &this->cur_track) != 1) { - xprintf (cls->xine, XINE_VERBOSITY_LOG, + xprintf (cls->xine, XINE_VERBOSITY_LOG, _("input_vcd: malformed MRL. Use vcdo:/<track #>\n")); return 0; } if (this->cur_track>=this->cls->total_tracks) { - xprintf (cls->xine, XINE_VERBOSITY_LOG, + xprintf (cls->xine, XINE_VERBOSITY_LOG, _("input_vcd: invalid track %d (valid range: 0 .. %d)\n"), this->cur_track, this->cls->total_tracks-1); return 0; @@ -873,21 +873,21 @@ static int vcd_plugin_open (input_plugin_t *this_gen) { xprintf (cls->xine, XINE_VERBOSITY_DEBUG, "input_vcd: error in CDRIOCSETBLOCKSIZE %d\n", errno); return 0; } - - this->cur_sec = + + this->cur_sec = ntohl(this->cls->tocent [this->cur_track+1 - this->cls->tochdr.starting_track].addr.lba); - + } #endif - + return 1; } -static input_plugin_t *vcd_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, +static input_plugin_t *vcd_class_get_instance (input_class_t *cls_gen, xine_stream_t *stream, const char *data) { - vcd_input_class_t *cls = (vcd_input_class_t *) cls_gen; + vcd_input_class_t *cls = (vcd_input_class_t *) cls_gen; vcd_input_plugin_t *this; char *mrl = strdup(data); @@ -895,7 +895,7 @@ static input_plugin_t *vcd_class_get_instance (input_class_t *cls_gen, xine_stre free (mrl); return 0; } - + this = calloc(1, sizeof(vcd_input_plugin_t)); this->stream = stream; @@ -953,7 +953,7 @@ static int vcd_class_eject_media (input_class_t *this_gen) { return media_eject_media (this->xine, this->device); } -static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *filename, +static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *filename, int *num_files) { vcd_input_class_t *this = (vcd_input_class_t *) this_gen; @@ -964,7 +964,7 @@ static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *file if (filename) return NULL; - + fd = open (this->device, O_RDONLY|O_EXCL); if (fd == -1) { @@ -998,9 +998,9 @@ static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *file else { memset(this->mrls[(i-1)], 0, sizeof(xine_mrl_t)); } - + asprintf(&(this->mrls[i-1]->mrl), "vcdo:/%d", i); - + this->mrls[i-1]->type = mrl_vcd; /* hack */ @@ -1017,13 +1017,13 @@ static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *file } this->mrls[*num_files] = NULL; - + return this->mrls; } static char ** vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) { - vcd_input_class_t *this = (vcd_input_class_t *) this_gen; + vcd_input_class_t *this = (vcd_input_class_t *) this_gen; int i, fd; @@ -1095,7 +1095,7 @@ static void *init_class (xine_t *xine, void *data) { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "VCDO", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/libreal/asmrp.c b/src/input/libreal/asmrp.c index 5eb25d7b4..070d9cb34 100644 --- a/src/input/libreal/asmrp.c +++ b/src/input/libreal/asmrp.c @@ -2,7 +2,7 @@ * Copyright (C) 2002-2004 the xine project * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -85,7 +85,7 @@ typedef struct { int sym; int num; - + char str[ASMRP_MAX_ID]; /* private part */ @@ -115,7 +115,7 @@ static void asmrp_dispose (asmrp_t *p) { int i; - for (i=0; i<p->sym_tab_num; i++) + for (i=0; i<p->sym_tab_num; i++) free (p->sym_tab[i].id); free (p); @@ -133,7 +133,7 @@ static void asmrp_init (asmrp_t *p, const char *str) { p->buf = strdup (str); p->pos = 0; - + asmrp_getch (p); } @@ -167,10 +167,10 @@ static void asmrp_string (asmrp_t *p) { asmrp_getch (p); } p->str[l]=0; - + if (p->ch=='"') asmrp_getch (p); - + p->sym = ASMRP_SYM_STRING; } @@ -189,7 +189,7 @@ static void asmrp_identifier (asmrp_t *p) { asmrp_getch (p); } p->str[l]=0; - + p->sym = ASMRP_SYM_ID; } @@ -387,10 +387,10 @@ static int asmrp_set_id (asmrp_t *p, char *s, int v) { lprintf ("new symbol '%s'\n", s); - } + } p->sym_tab[i].v = v; - + lprintf ("symbol '%s' assigned %d\n", s, v); return i; @@ -401,7 +401,7 @@ static int asmrp_condition (asmrp_t *p) ; static int asmrp_operand (asmrp_t *p) { int i, ret; - + lprintf ("operand\n"); ret = 0; @@ -411,7 +411,7 @@ static int asmrp_operand (asmrp_t *p) { case ASMRP_SYM_DOLLAR: asmrp_get_sym (p); - + if (p->sym != ASMRP_SYM_ID) { printf ("error: identifier expected.\n"); _x_abort(); @@ -453,7 +453,7 @@ static int asmrp_operand (asmrp_t *p) { } lprintf ("operand done, =%d\n", ret); - + return ret; } @@ -503,7 +503,7 @@ static int asmrp_comp_expression (asmrp_t *p) { } static int asmrp_condition (asmrp_t *p) { - + int a; lprintf ("condition\n"); @@ -542,7 +542,7 @@ static void asmrp_assignment (asmrp_t *p) { lprintf ("empty assignment\n"); return; } - + if (p->sym != ASMRP_SYM_ID) { printf ("error: identifier expected\n"); _x_abort (); @@ -555,7 +555,7 @@ static void asmrp_assignment (asmrp_t *p) { } asmrp_get_sym (p); - if ( (p->sym != ASMRP_SYM_NUM) && (p->sym != ASMRP_SYM_STRING) + if ( (p->sym != ASMRP_SYM_NUM) && (p->sym != ASMRP_SYM_STRING) && (p->sym != ASMRP_SYM_ID)) { printf ("error: number or string expected\n"); _x_abort (); @@ -566,22 +566,22 @@ static void asmrp_assignment (asmrp_t *p) { } static int asmrp_rule (asmrp_t *p) { - + int ret; lprintf ("rule\n"); ret = 1; - + if (p->sym == ASMRP_SYM_HASH) { asmrp_get_sym (p); ret = asmrp_condition (p); while (p->sym == ASMRP_SYM_COMMA) { - + asmrp_get_sym (p); - + asmrp_assignment (p); } diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index 7fa64cc15..7ce345717 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -55,20 +55,20 @@ static const unsigned char xor_table[] = { static void hash(char *field, char *param) { uint32_t a, b, c, d; - + /* fill variables */ a = _X_LE_32(field); b = _X_LE_32(field+4); c = _X_LE_32(field+8); d = _X_LE_32(field+12); - + lprintf("hash input: %x %x %x %x\n", a, b, c, d); lprintf("hash parameter:\n"); #ifdef LOG xine_hexdump(param, 64); #endif - + a = ((b & c) | (~b & d)) + _X_LE_32((param+0x00)) + a - 0x28955B88; a = ((a << 0x07) | (a >> 0x19)) + b; d = ((a & b) | (~a & c)) + _X_LE_32((param+0x04)) + d - 0x173848AA; @@ -101,7 +101,7 @@ static void hash(char *field, char *param) { c = ((c << 0x11) | (c >> 0x0f)) + d; b = ((c & d) | (~c & a)) + _X_LE_32((param+0x3c)) + b + 0x49B40821; b = ((b << 0x16) | (b >> 0x0a)) + c; - + a = ((b & d) | (~d & c)) + _X_LE_32((param+0x04)) + a - 0x09E1DA9E; a = ((a << 0x05) | (a >> 0x1b)) + b; d = ((a & c) | (~c & b)) + _X_LE_32((param+0x18)) + d - 0x3FBF4CC0; @@ -134,7 +134,7 @@ static void hash(char *field, char *param) { c = ((c << 0x0e) | (c >> 0x12)) + d; b = ((c & a) | (~a & d)) + _X_LE_32((param+0x30)) + b - 0x72D5B376; b = ((b << 0x14) | (b >> 0x0c)) + c; - + a = (b ^ c ^ d) + _X_LE_32((param+0x14)) + a - 0x0005C6BE; a = ((a << 0x04) | (a >> 0x1c)) + b; d = (a ^ b ^ c) + _X_LE_32((param+0x20)) + d - 0x788E097F; @@ -167,42 +167,42 @@ static void hash(char *field, char *param) { c = ((c << 0x10) | (c >> 0x10)) + d; b = (c ^ d ^ a) + _X_LE_32((param+0x08)) + b - 0x3B53A99B; b = ((b << 0x17) | (b >> 0x09)) + c; - + a = ((~d | b) ^ c) + _X_LE_32((param+0x00)) + a - 0x0BD6DDBC; - a = ((a << 0x06) | (a >> 0x1a)) + b; + a = ((a << 0x06) | (a >> 0x1a)) + b; d = ((~c | a) ^ b) + _X_LE_32((param+0x1c)) + d + 0x432AFF97; - d = ((d << 0x0a) | (d >> 0x16)) + a; + d = ((d << 0x0a) | (d >> 0x16)) + a; c = ((~b | d) ^ a) + _X_LE_32((param+0x38)) + c - 0x546BDC59; - c = ((c << 0x0f) | (c >> 0x11)) + d; + c = ((c << 0x0f) | (c >> 0x11)) + d; b = ((~a | c) ^ d) + _X_LE_32((param+0x14)) + b - 0x036C5FC7; - b = ((b << 0x15) | (b >> 0x0b)) + c; + b = ((b << 0x15) | (b >> 0x0b)) + c; a = ((~d | b) ^ c) + _X_LE_32((param+0x30)) + a + 0x655B59C3; - a = ((a << 0x06) | (a >> 0x1a)) + b; + a = ((a << 0x06) | (a >> 0x1a)) + b; d = ((~c | a) ^ b) + _X_LE_32((param+0x0C)) + d - 0x70F3336E; - d = ((d << 0x0a) | (d >> 0x16)) + a; + d = ((d << 0x0a) | (d >> 0x16)) + a; c = ((~b | d) ^ a) + _X_LE_32((param+0x28)) + c - 0x00100B83; - c = ((c << 0x0f) | (c >> 0x11)) + d; + c = ((c << 0x0f) | (c >> 0x11)) + d; b = ((~a | c) ^ d) + _X_LE_32((param+0x04)) + b - 0x7A7BA22F; - b = ((b << 0x15) | (b >> 0x0b)) + c; + b = ((b << 0x15) | (b >> 0x0b)) + c; a = ((~d | b) ^ c) + _X_LE_32((param+0x20)) + a + 0x6FA87E4F; - a = ((a << 0x06) | (a >> 0x1a)) + b; + a = ((a << 0x06) | (a >> 0x1a)) + b; d = ((~c | a) ^ b) + _X_LE_32((param+0x3c)) + d - 0x01D31920; - d = ((d << 0x0a) | (d >> 0x16)) + a; + d = ((d << 0x0a) | (d >> 0x16)) + a; c = ((~b | d) ^ a) + _X_LE_32((param+0x18)) + c - 0x5CFEBCEC; - c = ((c << 0x0f) | (c >> 0x11)) + d; + c = ((c << 0x0f) | (c >> 0x11)) + d; b = ((~a | c) ^ d) + _X_LE_32((param+0x34)) + b + 0x4E0811A1; - b = ((b << 0x15) | (b >> 0x0b)) + c; + b = ((b << 0x15) | (b >> 0x0b)) + c; a = ((~d | b) ^ c) + _X_LE_32((param+0x10)) + a - 0x08AC817E; - a = ((a << 0x06) | (a >> 0x1a)) + b; + a = ((a << 0x06) | (a >> 0x1a)) + b; d = ((~c | a) ^ b) + _X_LE_32((param+0x2c)) + d - 0x42C50DCB; - d = ((d << 0x0a) | (d >> 0x16)) + a; + d = ((d << 0x0a) | (d >> 0x16)) + a; c = ((~b | d) ^ a) + _X_LE_32((param+0x08)) + c + 0x2AD7D2BB; - c = ((c << 0x0f) | (c >> 0x11)) + d; + c = ((c << 0x0f) | (c >> 0x11)) + d; b = ((~a | c) ^ d) + _X_LE_32((param+0x24)) + b - 0x14792C6F; - b = ((b << 0x15) | (b >> 0x0b)) + c; + b = ((b << 0x15) | (b >> 0x0b)) + c; lprintf("hash output: %x %x %x %x\n", a, b, c, d); - + a += _X_LE_32(field); b += _X_LE_32(field+4); c += _X_LE_32(field+8); @@ -218,15 +218,15 @@ static void call_hash (char *key, char *challenge, unsigned int len) { char *ptr1, *ptr2; uint32_t a, b, c, d, tmp; - + ptr1=(key+16); ptr2=(key+20); - + a = _X_LE_32(ptr1); b = (a >> 3) & 0x3f; a += len * 8; _X_LE_32C(ptr1, a); - + if (a < (len << 3)) { lprintf("not verified: (len << 3) > a true\n"); @@ -236,7 +236,7 @@ static void call_hash (char *key, char *challenge, unsigned int len) { tmp = _X_LE_32(ptr2) + (len >> 0x1d); _X_LE_32C(ptr2, tmp); a = 64 - b; - c = 0; + c = 0; if (a <= len) { @@ -244,7 +244,7 @@ static void call_hash (char *key, char *challenge, unsigned int len) { hash(key, key+24); c = a; d = c + 0x3f; - + while ( d < len ) { lprintf("not verified: while ( d < len )\n"); hash(key, challenge+d-0x3f); @@ -253,7 +253,7 @@ static void call_hash (char *key, char *challenge, unsigned int len) { } b = 0; } - + memcpy(key+b+24, challenge+c, len-c); } @@ -265,11 +265,11 @@ static void calc_response (char *result, char *field) { memset (buf1, 0, 64); *buf1 = 128; - + memcpy (buf2, field+16, 8); - + i = ( _X_LE_32((buf2)) >> 3 ) & 0x3f; - + if (i < 56) { i = 56 - i; } else { @@ -286,7 +286,7 @@ static void calc_response (char *result, char *field) { static void calc_response_string (char *result, char *challenge) { - + char field[128] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, @@ -295,15 +295,15 @@ static void calc_response_string (char *result, char *challenge) { }; char zres[20]; int i; - + /* calculate response */ call_hash(field, challenge, 64); calc_response(zres,field); - + /* convert zres to ascii string */ for (i=0; i<16; i++ ) { char a, b; - + a = (zres[i] >> 4) & 15; b = zres[i] & 15; @@ -341,11 +341,11 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe ch_len=32; } if ( ch_len > 56 ) ch_len=56; - + /* copy challenge to buf */ memcpy(ptr, challenge, ch_len); } - + /* xor challenge bytewise with xor_table */ for (i=0; i<XOR_TABLE_LEN; i++) ptr[i] = ptr[i] ^ xor_table[i]; @@ -371,7 +371,7 @@ static int select_mlti_data(const char *mlti_chunk, int mlti_size, int selection int numrules, codec, size; int i; - + /* MLTI chunk should begin with MLTI */ if ((mlti_chunk[0] != 'M') @@ -409,13 +409,13 @@ static int select_mlti_data(const char *mlti_chunk, int mlti_size, int selection } mlti_chunk+=2; - + /* now seek to selected codec */ for (i=0; i<codec; i++) { size=_X_BE_32(mlti_chunk); mlti_chunk+=size+4; } - + size=_X_BE_32(mlti_chunk); #ifdef LOG @@ -440,14 +440,14 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt int max_packet_size=0; int avg_packet_size=0; int duration=0; - + if (!data) return NULL; desc=sdpplin_parse(data); if (!desc) return NULL; - + buf=xine_buffer_init(2048); header = calloc(1, sizeof(rmff_header_t)); @@ -483,7 +483,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt } else len=select_mlti_data(desc->stream[i]->mlti_data, desc->stream[i]->mlti_data_size, rulematches[0], &buf); - + header->streams[i]=rmff_new_mdpr( desc->stream[i]->stream_id, desc->stream[i]->max_bit_rate, @@ -507,7 +507,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt else avg_packet_size=desc->stream[i]->avg_packet_size; } - + if (*stream_rules && strlen(*stream_rules) && (*stream_rules)[strlen(*stream_rules)-1] == ',') (*stream_rules)[strlen(*stream_rules)-1]=0; /* delete last ',' in stream_rules */ @@ -576,12 +576,12 @@ int real_get_rdt_chunk(rtsp_t *rtsp_session, unsigned char **buffer) { n=rtsp_read_data(rtsp_session, header, 6); if (n<6) return 0; ts=_X_BE_32(header); - - lprintf("ts: %u size: %u, flags: 0x%02x, unknown values: %u 0x%02x 0x%02x\n", + + lprintf("ts: %u size: %u, flags: 0x%02x, unknown values: %u 0x%02x 0x%02x\n", ts, size, flags1, unknown1, header[4], header[5]); size+=2; - + ph.object_version=0; ph.length=size; ph.stream_number=(flags1>>1)&1; @@ -592,7 +592,7 @@ int real_get_rdt_chunk(rtsp_t *rtsp_session, unsigned char **buffer) { rmff_dump_pheader(&ph, *buffer); size-=12; n=rtsp_read_data(rtsp_session, (*buffer)+12, size); - + return (n <= 0) ? 0 : n+12; } @@ -611,11 +611,11 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid char *mrl=rtsp_get_mrl(rtsp_session); unsigned int size; int status; - + /* get challenge */ challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1")); lprintf("Challenge1: %s\n", challenge1); - + /* request stream description */ rtsp_schedule_field(rtsp_session, "Accept: application/sdp"); sprintf(buf, "Bandwidth: %u", bandwidth); @@ -657,7 +657,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid lprintf("real: got no ETag!\n"); else session_id=strdup(rtsp_search_answers(rtsp_session,"ETag")); - + lprintf("Stream description size: %i\n", size); description = malloc(size+1); @@ -681,7 +681,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid lprintf("Title: %s\nCopyright: %s\nAuthor: %s\nStreams: %i\n", h->cont->title, h->cont->copyright, h->cont->author, h->prop->num_streams); - + /* setup our streams */ real_calc_response_and_checksum (challenge2, checksum, challenge1); xine_buffer_ensure_size(buf, strlen(challenge2) + strlen(checksum) + 32); diff --git a/src/input/libreal/real.h b/src/input/libreal/real.h index edcd170f8..f299b909b 100644 --- a/src/input/libreal/real.h +++ b/src/input/libreal/real.h @@ -20,7 +20,7 @@ * special functions for real streams. * adopted from joschkas real tools. */ - + #ifndef HAVE_REAL_H #define HAVE_REAL_H diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c index d4b6ad2e1..f330e4844 100644 --- a/src/input/libreal/rmff.c +++ b/src/input/libreal/rmff.c @@ -51,7 +51,7 @@ static int rmff_dump_fileheader(rmff_fileheader_t *fileheader, uint8_t *buffer, fileheader->object_version=_X_BE_16(&fileheader->object_version); fileheader->file_version=_X_BE_32(&fileheader->file_version); fileheader->num_headers=_X_BE_32(&fileheader->num_headers); - + memcpy(buffer, fileheader, 8); memcpy(&buffer[8], &fileheader->object_version, 2); memcpy(&buffer[10], &fileheader->file_version, 8); @@ -92,7 +92,7 @@ static int rmff_dump_prop(rmff_prop_t *prop, uint8_t *buffer, int bufsize) { memcpy(&buffer[10], &prop->max_bit_rate, 36); memcpy(&buffer[46], &prop->num_streams, 2); memcpy(&buffer[48], &prop->flags, 2); - + prop->size=_X_BE_32(&prop->size); prop->object_version=_X_BE_16(&prop->object_version); prop->max_bit_rate=_X_BE_32(&prop->max_bit_rate); @@ -143,7 +143,7 @@ static int rmff_dump_mdpr(rmff_mdpr_t *mdpr, uint8_t *buffer, int bufsize) { memcpy(&buffer[41+s1], &mdpr->mime_type_size, 1); s2=mdpr->mime_type_size; memcpy(&buffer[42+s1], mdpr->mime_type, s2); - + mdpr->type_specific_len=_X_BE_32(&mdpr->type_specific_len); memcpy(&buffer[42+s1+s2], &mdpr->type_specific_len, 4); mdpr->type_specific_len=_X_BE_32(&mdpr->type_specific_len); @@ -180,7 +180,7 @@ static int rmff_dump_cont(rmff_cont_t *cont, uint8_t *buffer, int bufsize) { memcpy(buffer, cont, 8); memcpy(&buffer[8], &cont->object_version, 2); - + cont->title_len=_X_BE_16(&cont->title_len); memcpy(&buffer[10], &cont->title_len, 2); cont->title_len=_X_BE_16(&cont->title_len); @@ -228,7 +228,7 @@ static int rmff_dump_dataheader(rmff_data_t *data, uint8_t *buffer, int bufsize) memcpy(buffer, data, 8); memcpy(&buffer[8], &data->object_version, 2); memcpy(&buffer[10], &data->num_packets, 8); - + data->num_packets=_X_BE_32(&data->num_packets); data->next_data_header=_X_BE_32(&data->next_data_header); data->size=_X_BE_32(&data->size); @@ -267,7 +267,7 @@ int rmff_dump_header(rmff_header_t *h, void *buf_gen, int max) { stream++; } } - + if ((size=rmff_dump_dataheader(h->data, &buffer[written], max)) < 0) return -1; written+=size; @@ -355,28 +355,28 @@ static rmff_mdpr_t *rmff_scan_mdpr(const char *data) mdpr->start_time=_X_BE_32(&data[28]); mdpr->preroll=_X_BE_32(&data[32]); mdpr->duration=_X_BE_32(&data[36]); - + mdpr->stream_name_size=data[40]; if (mdpr->size < 46 + mdpr->stream_name_size) goto fail; mdpr->stream_name = xine_memdup0(&data[41], mdpr->stream_name_size); if (!mdpr->stream_name) goto fail; - + mdpr->mime_type_size=data[41+mdpr->stream_name_size]; if (mdpr->size < 46 + mdpr->stream_name_size + mdpr->mime_type_size) goto fail; mdpr->mime_type = xine_memdup0(&data[42+mdpr->stream_name_size], mdpr->mime_type_size); if (!mdpr->mime_type) goto fail; - + mdpr->type_specific_len=_X_BE_32(&data[42+mdpr->stream_name_size+mdpr->mime_type_size]); if (mdpr->size < 46 + mdpr->stream_name_size + mdpr->mime_type_size + mdpr->type_specific_data) goto fail; mdpr->type_specific_data = xine_memdup(&data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len); if (!mdpr->type_specific_data) goto fail; - + return mdpr; fail: @@ -431,7 +431,7 @@ static rmff_data_t *rmff_scan_dataheader(const char *data) { return dh; } - + rmff_header_t *rmff_scan_header(const char *data) { rmff_header_t *header = malloc(sizeof(rmff_header_t)); @@ -455,18 +455,18 @@ rmff_header_t *rmff_scan_header(const char *data) { } header->fileheader=rmff_scan_fileheader(ptr); ptr += header->fileheader->size; - + header->streams = calloc(header->fileheader->num_headers, sizeof(rmff_mdpr_t*)); - + for (i=1; i<header->fileheader->num_headers; i++) { chunk_type = _X_BE_32(ptr); - + if (ptr[0] == 0) { lprintf("rmff: warning: only %d of %d header found.\n", i, header->fileheader->num_headers); break; } - + chunk_size=1; switch (chunk_type) { case PROP_TAG: @@ -596,7 +596,7 @@ rmff_prop_t *rmff_new_prop ( prop->data_offset=data_offset; prop->num_streams=num_streams; prop->flags=flags; - + return prop; } @@ -615,7 +615,7 @@ rmff_mdpr_t *rmff_new_mdpr( const char *type_specific_data ) { rmff_mdpr_t *mdpr = malloc(sizeof(rmff_mdpr_t)); - + mdpr->object_id=MDPR_TAG; mdpr->object_version=0; @@ -640,7 +640,7 @@ rmff_mdpr_t *rmff_new_mdpr( mdpr->type_specific_len=type_specific_len; mdpr->type_specific_data = xine_memdup(type_specific_data,type_specific_len); mdpr->mlti_data=NULL; - + mdpr->size=mdpr->stream_name_size+mdpr->mime_type_size+mdpr->type_specific_len+46; return mdpr; @@ -657,7 +657,7 @@ rmff_cont_t *rmff_new_cont(const char *title, const char *author, const char *co cont->author=NULL; cont->copyright=NULL; cont->comment=NULL; - + cont->title_len=0; cont->author_len=0; cont->copyright_len=0; @@ -696,12 +696,12 @@ rmff_data_t *rmff_new_dataheader(uint32_t num_packets, uint32_t next_data_header return data; } - + #if 0 void rmff_print_header(rmff_header_t *h) { rmff_mdpr_t **stream; - + if(!h) { printf("rmff_print_header: NULL given\n"); return; @@ -762,7 +762,7 @@ void rmff_print_header(rmff_header_t *h) { printf("size : %i\n", h->data->size); printf("packets : %i\n", h->data->num_packets); printf("next DATA : 0x%08x\n", h->data->next_data_header); - } + } } #endif @@ -791,7 +791,7 @@ void rmff_fix_header(rmff_header_t *h) { streams++; } } - + if (h->prop) { if (h->prop->size != 50) { @@ -828,7 +828,7 @@ void rmff_fix_header(rmff_header_t *h) { } num_headers++; - + if (!h->fileheader) { lprintf("rmff_fix_header: no fileheader, creating one"); @@ -843,31 +843,31 @@ void rmff_fix_header(rmff_header_t *h) { num_headers++; if(h->fileheader->num_headers != num_headers) { - lprintf("rmff_fix_header: setting num_headers from %i to %i\n", h->fileheader->num_headers, num_headers); + lprintf("rmff_fix_header: setting num_headers from %i to %i\n", h->fileheader->num_headers, num_headers); h->fileheader->num_headers=num_headers; } if(h->prop) { if (h->prop->data_offset != header_size) { - lprintf("rmff_fix_header: setting prop.data_offset from %i to %i\n", h->prop->data_offset, header_size); + lprintf("rmff_fix_header: setting prop.data_offset from %i to %i\n", h->prop->data_offset, header_size); h->prop->data_offset=header_size; } if (h->prop->num_packets == 0) { int p=(int)(h->prop->avg_bit_rate/8.0*(h->prop->duration/1000.0)/h->prop->avg_packet_size); - lprintf("rmff_fix_header: assuming prop.num_packets=%i\n", p); + lprintf("rmff_fix_header: assuming prop.num_packets=%i\n", p); h->prop->num_packets=p; } if (h->data->num_packets == 0) { - lprintf("rmff_fix_header: assuming data.num_packets=%i\n", h->prop->num_packets); + lprintf("rmff_fix_header: assuming data.num_packets=%i\n", h->prop->num_packets); h->data->num_packets=h->prop->num_packets; } - - lprintf("rmff_fix_header: assuming data.size=%i\n", h->prop->num_packets*h->prop->avg_packet_size); + + lprintf("rmff_fix_header: assuming data.size=%i\n", h->prop->num_packets*h->prop->avg_packet_size); h->data->size=h->prop->num_packets*h->prop->avg_packet_size; } @@ -880,7 +880,7 @@ int rmff_get_header_size(rmff_header_t *h) { if (!h->prop) return -1; return h->prop->data_offset+18; - + } void rmff_free_header(rmff_header_t *h) { diff --git a/src/input/libreal/rmff.h b/src/input/libreal/rmff.h index 285d8c978..996adc77d 100644 --- a/src/input/libreal/rmff.h +++ b/src/input/libreal/rmff.h @@ -98,7 +98,7 @@ typedef struct { uint32_t data_offset; uint16_t num_streams; uint16_t flags; - + } rmff_prop_t; typedef struct { @@ -141,11 +141,11 @@ typedef struct { char *copyright; uint16_t comment_len; char *comment; - + } rmff_cont_t; typedef struct { - + uint32_t object_id; uint32_t size; uint16_t object_version; @@ -178,7 +178,7 @@ typedef struct { /* * constructors for header structs */ - + rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers); rmff_prop_t *rmff_new_prop ( @@ -251,7 +251,7 @@ void rmff_fix_header(rmff_header_t *h); */ int rmff_get_header_size(rmff_header_t *h); #endif - + /* * dumps the header <h> to <buffer>. <max> is the size of <buffer> */ diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c index 0ca20b04d..c9f5afa93 100644 --- a/src/input/libreal/sdpplin.c +++ b/src/input/libreal/sdpplin.c @@ -23,7 +23,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif - + #define LOG_MODULE "sdpplin" #define LOG_VERBOSE /* @@ -51,10 +51,10 @@ static int filter(const char *in, const char *filter, char **out) { size_t flen=strlen(filter); size_t len; - + if (!in) return 0; - + len = (strchr(in,'\n')) ? (size_t)(strchr(in,'\n')-in) : strlen(in); if (!strncmp(in,filter,flen)) @@ -67,7 +67,7 @@ static int filter(const char *in, const char *filter, char **out) { return len-flen; } - + return 0; } static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) { @@ -75,7 +75,7 @@ static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) { sdpplin_stream_t *desc = calloc(1, sizeof(sdpplin_stream_t)); char *buf=xine_buffer_init(32); int handled; - + if (filter(*data, "m=", &buf)) { desc->id = strdup(buf); } else @@ -90,7 +90,7 @@ static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) { while (*data && **data && *data[0]!='m') { handled=0; - + if(filter(*data,"a=control:streamid=",&buf)) { /* This way negative values are mapped to unfeasibly high * values, and will be discarded afterward @@ -119,7 +119,7 @@ static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) { handled=1; *data=nl(*data); } - + if(filter(*data,"a=StartTime:integer;",&buf)) { desc->start_time=atoi(buf); handled=1; @@ -162,7 +162,7 @@ static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) { lprintf("mlti_data_size: %i\n", desc->mlti_data_size); } } - + if(filter(*data,"a=ASMRuleBook:string;",&buf)) { desc->asm_rule_book=strdup(buf); handled=1; @@ -181,7 +181,7 @@ static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) { } xine_buffer_free(buf); - + return desc; } @@ -199,7 +199,7 @@ sdpplin_t *sdpplin_parse(char *data) { while (data && *data) { handled=0; - + if (filter(data, "m=", &buf)) { if ( ! desc->stream ) { fprintf(stderr, "sdpplin.c: stream identifier found before stream count, skipping."); @@ -222,7 +222,7 @@ sdpplin_t *sdpplin_parse(char *data) { data=nl(data); } } - + if(filter(data,"a=Author:buffer;",&buf)) { len = av_base64_decode(decoded, buf, 32); if ( len > 0 ) { @@ -231,7 +231,7 @@ sdpplin_t *sdpplin_parse(char *data) { data=nl(data); } } - + if(filter(data,"a=Copyright:buffer;",&buf)) { len = av_base64_decode(decoded, buf, 32); if ( len > 0 ) { @@ -240,7 +240,7 @@ sdpplin_t *sdpplin_parse(char *data) { data=nl(data); } } - + if(filter(data,"a=Abstract:buffer;",&buf)) { len = av_base64_decode(decoded, buf, 32); if ( len > 0 ) { @@ -249,7 +249,7 @@ sdpplin_t *sdpplin_parse(char *data) { data=nl(data); } } - + if(filter(data,"a=StreamCount:integer;",&buf)) { /* This way negative values are mapped to unfeasibly high * values, and will be discarded afterward @@ -282,7 +282,7 @@ sdpplin_t *sdpplin_parse(char *data) { } xine_buffer_free(buf); - + return desc; } diff --git a/src/input/libreal/sdpplin.h b/src/input/libreal/sdpplin.h index 1604ee38c..2296c31e7 100644 --- a/src/input/libreal/sdpplin.h +++ b/src/input/libreal/sdpplin.h @@ -19,7 +19,7 @@ * * sdp/sdpplin parser. */ - + #ifndef HAVE_SDPPLIN_H #define HAVE_SDPPLIN_H @@ -98,7 +98,7 @@ typedef struct { int duration; sdpplin_stream_t **stream; - + } sdpplin_t; sdpplin_t *sdpplin_parse(char *data) XINE_MALLOC; diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index 710ab8711..c8c5c4126 100644 --- a/src/input/librtsp/rtsp.c +++ b/src/input/librtsp/rtsp.c @@ -46,7 +46,7 @@ #define LOG_VERBOSE /* #define LOG -*/ +*/ #include "rtsp.h" #include <xine/io_helper.h> @@ -71,7 +71,7 @@ struct rtsp_s { char *server; unsigned int server_state; uint32_t server_caps; - + unsigned int cseq; char *session; @@ -107,16 +107,16 @@ static const char rtsp_protocol_version[]="RTSP/1.0"; * rtsp_get gets a line from stream * and returns a null terminated string (must be freed). */ - + static char *rtsp_get(rtsp_t *s) { char buffer[BUF_SIZE]; char *string = NULL; - + if ( _x_io_tcp_read_line(s->stream, s->s, buffer, BUF_SIZE) >= 0 ) { lprintf("<< '%s'\n", buffer); string = strdup( buffer ); } - + return string; } @@ -124,7 +124,7 @@ static char *rtsp_get(rtsp_t *s) { /* * rtsp_put puts a line on stream */ - + static void rtsp_put(rtsp_t *s, const char *string) { size_t len=strlen(string); @@ -137,7 +137,7 @@ static void rtsp_put(rtsp_t *s, const char *string) { buf[len+1]=0x0a; _x_io_tcp_write(s->stream, s->s, buf, len+2); - + lprintf("done.\n"); } @@ -149,7 +149,7 @@ static int rtsp_get_code(rtsp_t *s, const char *string) { char buf[4]; int code=0; - + if (!strncmp(string, rtsp_protocol_version, strlen(rtsp_protocol_version))) { memcpy(buf, string+strlen(rtsp_protocol_version)+1, 3); @@ -160,7 +160,7 @@ static int rtsp_get_code(rtsp_t *s, const char *string) { return RTSP_STATUS_SET_PARAMETER; } - if(code != 200) + if(code != 200) xprintf(s->stream->xine, XINE_VERBOSITY_DEBUG, "librtsp: server responds: '%s'\n", string); return code; @@ -174,7 +174,7 @@ static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) { char **payload=s->scheduled; char *buf; - + asprintf(&buf,"%s %s %s",type, what, rtsp_protocol_version); rtsp_put(s,buf); @@ -194,10 +194,10 @@ static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) { static void rtsp_schedule_standard(rtsp_t *s) { char tmp[17]; - + sprintf(tmp, "Cseq: %u", s->cseq); rtsp_schedule_field(s, tmp); - + if (s->session) { char *buf; asprintf(&buf, "Session: %s", s->session); @@ -207,7 +207,7 @@ static void rtsp_schedule_standard(rtsp_t *s) { /* * get the answers, if server responses with something != 200, return NULL */ - + static int rtsp_get_answers(rtsp_t *s) { char *answer=NULL; @@ -215,7 +215,7 @@ static int rtsp_get_answers(rtsp_t *s) { char **answer_ptr=s->answers; int code; int ans_count = 0; - + answer=rtsp_get(s); if (!answer) return 0; @@ -223,13 +223,13 @@ static int rtsp_get_answers(rtsp_t *s) { free(answer); rtsp_free_answers(s); - + do { /* while we get answer lines */ - + answer=rtsp_get(s); if (!answer) return 0; - + if (!strncasecmp(answer,"Cseq: ",6)) { sscanf(answer+6,"%u",&answer_seq); if (s->cseq != answer_seq) { @@ -246,7 +246,7 @@ static int rtsp_get_answers(rtsp_t *s) { char *tmp = answer + 9; if (s->session) { if (strcmp(tmp, s->session)) { - xprintf(s->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(s->stream->xine, XINE_VERBOSITY_DEBUG, "rtsp: warning: setting NEW session: %s\n", tmp); s->session=strdup(tmp); } @@ -260,12 +260,12 @@ static int rtsp_get_answers(rtsp_t *s) { *answer_ptr=answer; answer_ptr++; } while ((strlen(answer)!=0) && (++ans_count < MAX_FIELDS)); - + s->cseq++; - + *answer_ptr=NULL; rtsp_schedule_standard(s); - + return code; } @@ -275,7 +275,7 @@ static int rtsp_get_answers(rtsp_t *s) { int rtsp_send_ok(rtsp_t *s) { char cseq[16]; - + rtsp_put(s, "RTSP/1.0 200 OK"); sprintf(cseq,"CSeq: %u", s->cseq); rtsp_put(s, cseq); @@ -316,14 +316,14 @@ int rtsp_request_describe(rtsp_t *s, const char *what) { } rtsp_send_request(s,"DESCRIBE",buf); free(buf); - + return rtsp_get_answers(s); } int rtsp_request_setup(rtsp_t *s, const char *what) { rtsp_send_request(s,"SETUP",what); - + return rtsp_get_answers(s); } @@ -339,7 +339,7 @@ int rtsp_request_setparameter(rtsp_t *s, const char *what) { } rtsp_send_request(s,"SET_PARAMETER",buf); free(buf); - + return rtsp_get_answers(s); } @@ -355,7 +355,7 @@ int rtsp_request_play(rtsp_t *s, const char *what) { } rtsp_send_request(s,"PLAY",buf); free(buf); - + return rtsp_get_answers(s); } @@ -363,7 +363,7 @@ int rtsp_request_play(rtsp_t *s, const char *what) { int rtsp_request_tearoff(rtsp_t *s, const char *what) { rtsp_send_request(s,"TEAROFF",what); - + return rtsp_get_answers(s); } #endif @@ -384,7 +384,7 @@ int rtsp_read_data(rtsp_t *s, void *buffer_gen, unsigned int size) { char *rest=rtsp_get(s); if (!rest) return -1; - + seq=-1; do { free(rest); @@ -431,14 +431,14 @@ rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_ag char *slash, *colon; int hostend, i; size_t pathbegin; - + if (strncmp(mrl,"rtsp://",7)) { xprintf(stream->xine, XINE_VERBOSITY_LOG, _("rtsp: bad mrl: %s\n"), mrl); free(s); return NULL; } - + mrl_ptr+=7; for (i=0; i<MAX_FIELDS; i++) { @@ -452,14 +452,14 @@ rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_ag s->path=NULL; s->mrl=NULL; s->mrl=strdup(mrl); - + s->server=NULL; s->server_state=0; s->server_caps=0; - + s->cseq=0; s->session=NULL; - + if (user_agent) s->user_agent=strdup(user_agent); else @@ -469,7 +469,7 @@ rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_ag colon=strchr(mrl_ptr,':'); if(!slash) slash=mrl_ptr+strlen(mrl_ptr)+1; - if(!colon) colon=slash; + if(!colon) colon=slash; if(colon > slash) colon=slash; pathbegin=slash-mrl_ptr; @@ -480,7 +480,7 @@ rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_ag if (pathbegin < strlen(mrl_ptr)) s->path=strdup(mrl_ptr+pathbegin+1); if (colon != slash) { char buffer[pathbegin-hostend]; - + strncpy(buffer,mrl_ptr+hostend+1, pathbegin-hostend-1); buffer[pathbegin-hostend-1]=0; s->port=atoi(buffer); @@ -516,7 +516,7 @@ rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_ag /* - * closes an rtsp connection + * closes an rtsp connection */ void rtsp_close(rtsp_t *s) { @@ -529,7 +529,7 @@ void rtsp_close(rtsp_t *s) { if (s->user_agent) free(s->user_agent); rtsp_free_answers(s); rtsp_unschedule_all(s); - free(s); + free(s); } /* @@ -541,7 +541,7 @@ char *rtsp_search_answers(rtsp_t *s, const char *tag) { char **answer; char *ptr; - + if (!s->answers) return NULL; answer=s->answers; @@ -592,7 +592,7 @@ char *rtsp_get_mrl(rtsp_t *s) { void rtsp_schedule_field(rtsp_t *s, const char *string) { int i=0; - + if (!string) return; while(s->scheduled[i]) { @@ -603,13 +603,13 @@ void rtsp_schedule_field(rtsp_t *s, const char *string) { #if 0 /* - * removes the first scheduled field which prefix matches string. + * removes the first scheduled field which prefix matches string. */ void rtsp_unschedule_field(rtsp_t *s, const char *string) { char **ptr=s->scheduled; - + if (!string) return; while(*ptr) { @@ -631,7 +631,7 @@ void rtsp_unschedule_field(rtsp_t *s, const char *string) { void rtsp_unschedule_all(rtsp_t *s) { char **ptr; - + if (!s->scheduled) return; ptr=s->scheduled; @@ -648,7 +648,7 @@ void rtsp_unschedule_all(rtsp_t *s) { void rtsp_free_answers(rtsp_t *s) { char **answer; - + if (!s->answers) return; answer=s->answers; diff --git a/src/input/librtsp/rtsp.h b/src/input/librtsp/rtsp.h index 8aee8e049..98a87fb80 100644 --- a/src/input/librtsp/rtsp.h +++ b/src/input/librtsp/rtsp.h @@ -20,7 +20,7 @@ * a minimalistic implementation of rtsp protocol, * *not* RFC 2326 compilant yet. */ - + #ifndef HAVE_RTSP_H #define HAVE_RTSP_H diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c index 0194af3fd..a4b4c83c4 100644 --- a/src/input/librtsp/rtsp_session.c +++ b/src/input/librtsp/rtsp_session.c @@ -89,7 +89,7 @@ rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) { rmff_header_t *h; int bandwidth_id; uint32_t bandwidth; - + bandwidth_id = xine->config->register_enum(xine->config, "media.network.bandwidth", 10, rtsp_bandwidth_strs, _("network bandwidth"), @@ -100,7 +100,7 @@ rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) { bandwidth = rtsp_bandwidths[bandwidth_id]; rtsp_session->recv = xine_buffer_init(BUF_SIZE); - + connect: /* connect to server */ @@ -149,8 +149,8 @@ connect: return NULL; } } - - rtsp_session->header_left = + + rtsp_session->header_left = rtsp_session->header_len = rmff_dump_header(h,rtsp_session->header,HEADER_SIZE); if (rtsp_session->header_len < 0) { xprintf (stream->xine, XINE_VERBOSITY_LOG, @@ -161,7 +161,7 @@ connect: xine_buffer_copyin(rtsp_session->recv, 0, rtsp_session->header, rtsp_session->header_len); rtsp_session->recv_size = rtsp_session->header_len; rtsp_session->recv_read = 0; - + } else { xprintf(stream->xine, XINE_VERBOSITY_LOG, @@ -174,29 +174,29 @@ connect: return NULL; } free(server); - + return rtsp_session; } void rtsp_session_set_start_time (rtsp_session_t *this, int start_time) { - + if (start_time >= 0) this->start_time = start_time; } static void rtsp_session_play (rtsp_session_t *this) { - + char buf[256]; - - snprintf (buf, sizeof(buf), "Range: npt=%d.%03d-", + + snprintf (buf, sizeof(buf), "Range: npt=%d.%03d-", this->start_time/1000, this->start_time%1000); - + rtsp_schedule_field (this->s, buf); rtsp_request_play (this->s,NULL); } int rtsp_session_read (rtsp_session_t *this, char *data, int len) { - + int to_copy; char *dest=data; uint8_t *source=this->recv + this->recv_read; @@ -204,22 +204,22 @@ int rtsp_session_read (rtsp_session_t *this, char *data, int len) { if (len < 0) return 0; - + if (this->header_left) { if (len > this->header_left) len = this->header_left; - + this->header_left -= len; } - + to_copy = len; while (to_copy > fill) { - + if (!this->playing) { rtsp_session_play (this); this->playing = 1; } - + memcpy(dest, source, fill); to_copy -= fill; dest += fill; @@ -234,7 +234,7 @@ int rtsp_session_read (rtsp_session_t *this, char *data, int len) { return len-to_copy; } } - + memcpy(dest, source, to_copy); this->recv_read += to_copy; diff --git a/src/input/media_helper.c b/src/input/media_helper.c index 288ed4205..e19ca63e6 100644 --- a/src/input/media_helper.c +++ b/src/input/media_helper.c @@ -1,18 +1,18 @@ -/* - * Copyright (C) 2000-2003 the xine project, - * +/* + * Copyright (C) 2000-2003 the xine project, + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -66,14 +66,14 @@ static int media_umount_media(const char *device) if(waitpid(pid, &status, 0) == -1) { if (errno != EINTR) return -1; - } + } else { return WEXITSTATUS(status); } } while(1); - + return -1; -} +} #endif int media_eject_media (xine_t *xine, const char *device) @@ -91,7 +91,7 @@ int media_eject_media (xine_t *xine, const char *device) return 0; -#else +#else int fd; @@ -109,14 +109,14 @@ int media_eject_media (xine_t *xine, const char *device) case CDS_TRAY_OPEN: if((ret = ioctl(fd, CDROMCLOSETRAY)) != 0) { #ifdef LOG_MEDIA_EJECT - printf("input_dvd: CDROMCLOSETRAY failed: %s\n", strerror(errno)); + printf("input_dvd: CDROMCLOSETRAY failed: %s\n", strerror(errno)); #endif } break; case CDS_DISC_OK: if((ret = ioctl(fd, CDROMEJECT)) != 0) { #ifdef LOG_MEDIA_EJECT - printf("input_dvd: CDROMEJECT failed: %s\n", strerror(errno)); + printf("input_dvd: CDROMEJECT failed: %s\n", strerror(errno)); #endif } break; diff --git a/src/input/mms.c b/src/input/mms.c index b94d986d3..67f8775a7 100644 --- a/src/input/mms.c +++ b/src/input/mms.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2002-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -54,7 +54,7 @@ #define LOG_MODULE "mms" #define LOG_VERBOSE /* -#define LOG +#define LOG */ #include <xine/xine_internal.h> #include <xine/xineutils.h> @@ -65,8 +65,8 @@ #include "../demuxers/asfheader.h" -/* - * mms specific types +/* + * mms specific types */ #define MMST_PORT 1755 @@ -107,9 +107,9 @@ struct mms_packet_header_s { struct mms_s { xine_stream_t *stream; - + int s; - + /* url parsing */ char *url; char *proto; @@ -123,12 +123,12 @@ struct mms_s { char scmd[CMD_HEADER_LEN + CMD_BODY_LEN]; char *scmd_body; /* pointer to &scmd[CMD_HEADER_LEN] */ int scmd_len; /* num bytes written in header */ - + /* receive buffer */ uint8_t buf[BUF_SIZE]; int buf_size; int buf_read; - + asf_header_t *asf_header; uint8_t asf_header_buffer[ASF_HEADER_LEN]; uint32_t asf_header_len; @@ -137,13 +137,13 @@ struct mms_s { int seq_num; char guid[37]; int bandwidth; - + off_t current_pos; int eos; uint8_t live_flag; - - uint8_t playing; + + uint8_t playing; double start_time; }; @@ -230,12 +230,12 @@ static void print_command (char *data, int len) { for (i = (CMD_HEADER_LEN + CMD_PREFIX_LEN); i < (CMD_HEADER_LEN + CMD_PREFIX_LEN + len); i += 1) { unsigned char c = data[i]; - + if ((c >= 32) && (c < 128)) printf ("%c", c); else printf (" %02x ", c); - + } if (len > CMD_HEADER_LEN) printf ("\n"); @@ -271,7 +271,7 @@ static int send_command (mms_t *this, int command, mms_buffer_put_32 (&command_buffer, len8 + 2); mms_buffer_put_32 (&command_buffer, 0x00030000 | command); /* dir | command */ /* end of the 40 byte command header */ - + mms_buffer_put_32 (&command_buffer, prefix1); mms_buffer_put_32 (&command_buffer, prefix2); @@ -354,14 +354,14 @@ static int get_packet_header (mms_t *this, mms_packet_header_t *header) { len = _x_io_tcp_read (this->stream, this->s, (char*)this->buf, 8); if (len != 8) goto error; - + if (_X_LE_32(this->buf + 4) == 0xb00bface) { /* command packet */ header->flags = this->buf[3]; len = _x_io_tcp_read (this->stream, this->s, (char*)(this->buf + 8), 4); if (len != 4) goto error; - + header->packet_len = _X_LE_32(this->buf + 8) + 4; if (header->packet_len > BUF_SIZE - 12) { header->packet_len = 0; @@ -383,7 +383,7 @@ static int get_packet_header (mms_t *this, mms_packet_header_t *header) { } } return packet_type; - + error: lprintf("read error, len=%zd\n", len); return MMS_PACKET_ERR; @@ -395,7 +395,7 @@ static int get_packet_command (mms_t *this, uint32_t packet_len) { int command = 0; size_t len; - + /* always enter this loop */ lprintf("packet_len: %d bytes\n", packet_len); @@ -405,18 +405,18 @@ static int get_packet_command (mms_t *this, uint32_t packet_len) { } print_command ((char*)this->buf, len); - + /* check protocol type ("MMS ") */ if (_X_LE_32(this->buf + 12) != 0x20534D4D) { lprintf("unknown protocol type: %c%c%c%c (0x%08X)\n", this->buf[12], this->buf[13], this->buf[14], this->buf[15], - _X_LE_32(this->buf + 12)); + _X_LE_32(this->buf + 12)); return 0; } command = _X_LE_32 (this->buf + 36) & 0xFFFF; lprintf("command = 0x%2x\n", command); - + return command; } @@ -431,9 +431,9 @@ static int get_answer (mms_t *this) { break; case MMS_PACKET_COMMAND: command = get_packet_command (this, header.packet_len); - + if (command == 0x1b) { - + if (!send_command (this, 0x1b, 0, 0, 0)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "libmms: failed to send command\n"); @@ -452,7 +452,7 @@ static int get_answer (mms_t *this) { "libmms: unexpected asf packet\n"); break; } - + return command; } @@ -461,7 +461,7 @@ static int get_asf_header (mms_t *this) { off_t len; int stop = 0; - + this->asf_header_read = 0; this->asf_header_len = 0; @@ -477,9 +477,9 @@ static int get_asf_header (mms_t *this) { break; case MMS_PACKET_COMMAND: command = get_packet_command (this, header.packet_len); - + if (command == 0x1b) { - + if (!send_command (this, 0x1b, 0, 0, 0)) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "libmms: failed to send command\n"); @@ -560,11 +560,11 @@ static void report_progress (xine_stream_t *stream, int p) { prg.description = _("Connecting MMS server (over tcp)..."); prg.percent = p; - + event.type = XINE_EVENT_PROGRESS; event.data = &prg; event.data_length = sizeof (xine_progress_data_t); - + xine_event_send (stream, &event); } @@ -574,11 +574,11 @@ static void report_progress (xine_stream_t *stream, int p) { */ static int mms_tcp_connect(mms_t *this) { int progress, res; - + if (!this->port) this->port = MMST_PORT; - /* - * try to connect + /* + * try to connect */ lprintf("try to connect to %s on port %d \n", this->host, this->port); this->s = _x_io_tcp_connect (this->stream, this->host, this->port); @@ -626,7 +626,7 @@ static int mms_choose_best_streams(mms_t *this) { /* choose the best quality for the audio stream */ asf_header_choose_streams (this->asf_header, this->bandwidth, &video_stream, &audio_stream); - + lprintf("selected streams: audio %d, video %d\n", audio_stream, video_stream); lprintf("disabling other streams\n"); memset (this->scmd_body, 0, 40); @@ -647,8 +647,8 @@ static int mms_choose_best_streams(mms_t *this) { } /* command 0x33 */ - if (!send_command (this, 0x33, this->asf_header->stream_count, - 0xFFFF | this->asf_header->streams[0]->stream_number << 16, + if (!send_command (this, 0x33, this->asf_header->stream_count, + 0xFFFF | this->asf_header->streams[0]->stream_number << 16, this->asf_header->stream_count * 6 + 2)) { xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "libmms: mms_choose_best_streams failed\n"); @@ -676,7 +676,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { mms_t *this; char str[1024]; int res; - + if (!url) return NULL; @@ -696,23 +696,23 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { this->eos = 0; report_progress (stream, 0); - + if (!_x_parse_url (this->url, &this->proto, &this->host, &this->port, &this->user, &this->password, &this->uri, NULL)) { lprintf ("invalid url\n"); goto fail; } - + if (!mmst_valid_proto(this->proto)) { lprintf ("unsupported protocol\n"); goto fail; } - + if (mms_tcp_connect(this)) { goto fail; } report_progress (stream, 30); - + #ifdef USE_ICONV url_conv = string_utf16_open(); #endif @@ -732,13 +732,13 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { "libmms: failed to send command 0x01\n"); goto fail; } - + if ((res = get_answer (this)) != 0x01) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "libmms: unexpected response: %02x (0x01)\n", res); goto fail; } - + report_progress (stream, 40); /* TODO: insert network timing request here */ @@ -786,7 +786,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { path++; pathlen--; } - + lprintf("send command 0x05\n"); mms_buffer_init(&command_buffer, this->scmd_body); mms_buffer_put_32 (&command_buffer, 0x00000000); /* ?? */ @@ -796,13 +796,13 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { if (!send_command (this, 5, 1, 0xffffffff, pathlen * 2 + 12)) goto fail; } - + switch (res = get_answer (this)) { case 0x06: { int xx, yy; /* no authentication required */ - + /* Warning: sdp is not right here */ xx = this->buf[62]; yy = this->buf[63]; @@ -845,7 +845,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { goto fail; } } - + if ((res = get_answer (this)) != 0x11) { xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "libmms: unexpected response: %02x (0x11)\n", res); @@ -898,7 +898,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { #endif lprintf("mms_connect: passed\n" ); - + return this; fail: @@ -924,19 +924,19 @@ fail: static int get_media_packet (mms_t *this) { mms_packet_header_t header; off_t len; - + switch (get_packet_header (this, &header)) { case MMS_PACKET_ERR: xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "libmms: failed to read mms packet header\n"); return 0; break; - + case MMS_PACKET_COMMAND: { int command; command = get_packet_command (this, header.packet_len); - + switch (command) { case 0x1e: { @@ -950,10 +950,10 @@ static int get_media_packet (mms_t *this) { this->eos = 1; return 0; } - + } break; - + case 0x20: { lprintf ("new stream.\n"); @@ -976,7 +976,7 @@ static int get_media_packet (mms_t *this) { mms_buffer_t command_buffer; mms_buffer_init(&command_buffer, this->scmd_body); mms_buffer_put_32 (&command_buffer, 0x00000000); /* 64 byte float timestamp */ - mms_buffer_put_32 (&command_buffer, 0x00000000); + mms_buffer_put_32 (&command_buffer, 0x00000000); mms_buffer_put_32 (&command_buffer, 0xFFFFFFFF); /* ?? */ mms_buffer_put_32 (&command_buffer, 0xFFFFFFFF); /* first packet sequence */ mms_buffer_put_8 (&command_buffer, 0xFF); /* max stream time limit (3 bytes) */ @@ -1003,10 +1003,10 @@ static int get_media_packet (mms_t *this) { } } break; - + case 0x05: break; - + default: xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "unexpected mms command %02x\n", command); @@ -1047,7 +1047,7 @@ static int get_media_packet (mms_t *this) { } break; } - + lprintf ("get media packet succ\n"); return 1; @@ -1085,13 +1085,13 @@ int mms_read (mms_t *this, char *data, int len) { this->asf_header_read += n; total += n; this->current_pos += n; - + if (this->asf_header_read == this->asf_header_len) break; } else { int n, bytes_left ; - + if (!this->playing) { /* send command 0x07 with initial timestamp */ mms_buffer_t command_buffer; diff --git a/src/input/mms.h b/src/input/mms.h index 67ea5ba0b..2fdfdac9b 100644 --- a/src/input/mms.h +++ b/src/input/mms.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2002-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA diff --git a/src/input/mmsh.c b/src/input/mmsh.c index 95ab64d10..2a65dd7d3 100644 --- a/src/input/mmsh.c +++ b/src/input/mmsh.c @@ -138,8 +138,8 @@ #endif -/* - * mmsh specific types +/* + * mmsh specific types */ @@ -161,10 +161,10 @@ struct mmsh_s { char str[SCRATCH_SIZE]; /* scratch buffer to built strings */ asf_header_t *asf_header; - int stream_type; + int stream_type; /* receive buffer */ - + /* chunk */ uint16_t chunk_type; uint16_t chunk_length; @@ -178,13 +178,13 @@ struct mmsh_s { uint32_t asf_header_len; uint32_t asf_header_read; int seq_num; - + int video_stream; int audio_stream; off_t current_pos; int user_bandwidth; - + int playing; unsigned int start_time; }; @@ -201,7 +201,7 @@ static int send_command (mmsh_t *this, char *cmd) { } static int get_answer (mmsh_t *this) { - + int done, len, linenum; char *features; @@ -222,14 +222,14 @@ static int get_answer (mmsh_t *this) { this->buf[len] = '\0'; len--; - + if ((len >= 0) && (this->buf[len] == '\015')) { this->buf[len] = '\0'; len--; } linenum++; - + lprintf ("answer: >%s<\n", this->buf); if (linenum == 1) { @@ -263,7 +263,7 @@ static int get_answer (mmsh_t *this) { _("libmmsh: Location redirection not implemented\n")); return 0; } - + if (!strncasecmp((char*)this->buf, "Pragma:", 7)) { features = strstr((char*)(this->buf + 7), "features="); if (features) { @@ -279,7 +279,7 @@ static int get_answer (mmsh_t *this) { } } } - + if (len == -1) { done = 1; } else { @@ -314,7 +314,7 @@ static int get_chunk_header (mmsh_t *this) { } this->chunk_type = _X_LE_16 (&chunk_header[0]); this->chunk_length = _X_LE_16 (&chunk_header[2]); - + switch (this->chunk_type) { case CHUNK_TYPE_DATA: ext_header_len = 8; @@ -340,7 +340,7 @@ static int get_chunk_header (mmsh_t *this) { return 0; } } - + switch (this->chunk_type) { case CHUNK_TYPE_DATA: this->chunk_seq_number = _X_LE_32 (&ext_header[0]); @@ -384,7 +384,7 @@ static int get_header (mmsh_t *this) { lprintf("get_header\n"); this->asf_header_len = 0; - + /* read chunk */ while (1) { if (get_chunk_header(this)) { @@ -484,11 +484,11 @@ static void report_progress (xine_stream_t *stream, int p) { */ static int mmsh_tcp_connect(mmsh_t *this) { int progress, res; - + if (!this->port) this->port = MMSH_PORT; - - /* - * try to connect + + /* + * try to connect */ lprintf("try to connect to %s on port %d \n", this->host, this->port); @@ -522,24 +522,24 @@ static int mmsh_connect_int(mmsh_t *this, int bandwidth) { /* * let the negotiations begin... */ - + /* first request */ lprintf("first http request\n"); - + snprintf (this->str, SCRATCH_SIZE, mmsh_FirstRequest, this->uri, this->host, this->port, 1); if (!send_command (this, this->str)) return 0; - if (!get_answer (this)) + if (!get_answer (this)) return 0; get_header (this); /* FIXME: it returns 0 */ if (!interp_header (this)) return 0; - + close (this->s); report_progress (this->stream, 20); @@ -548,13 +548,13 @@ static int mmsh_connect_int(mmsh_t *this, int bandwidth) { lprintf("audio stream %d, video stream %d\n", this->audio_stream, this->video_stream); - + asf_header_disable_streams (this->asf_header, this->video_stream, this->audio_stream); - + if (mmsh_tcp_connect(this)) return 0; - + return 1; } @@ -565,7 +565,7 @@ static int mmsh_connect_int2(mmsh_t *this, int bandwidth) { int i; char stream_selection[10 * ASF_MAX_NUM_STREAMS]; /* 10 chars per stream */ int offset; - + /* second request */ lprintf("second http request\n"); @@ -606,7 +606,7 @@ static int mmsh_connect_int2(mmsh_t *this, int bandwidth) { if (!send_command (this, this->str)) return 0; - + lprintf("before read \n"); if (!get_answer (this)) @@ -614,11 +614,11 @@ static int mmsh_connect_int2(mmsh_t *this, int bandwidth) { if (!get_header (this)) return 0; - + #if 0 if (!interp_header (this)) return 0; - + asf_header_disable_streams (this->asf_header, this->video_stream, this->audio_stream); #endif @@ -628,7 +628,7 @@ static int mmsh_connect_int2(mmsh_t *this, int bandwidth) { mmsh_t *mmsh_connect (xine_stream_t *stream, const char *url, int bandwidth) { mmsh_t *this; - + if (!url) return NULL; @@ -647,28 +647,28 @@ mmsh_t *mmsh_connect (xine_stream_t *stream, const char *url, int bandwidth) { this->user_bandwidth = bandwidth; report_progress (stream, 0); - + if (!_x_parse_url (this->url, &this->proto, &this->host, &this->port, &this->user, &this->password, &this->uri, NULL)) { xine_log (this->stream->xine, XINE_LOG_MSG, _("invalid url\n")); goto fail; } - + if (!mmsh_valid_proto(this->proto)) { xine_log (this->stream->xine, XINE_LOG_MSG, _("unsupported protocol\n")); goto fail; } - + if (mmsh_tcp_connect(this)) goto fail; - + report_progress (stream, 30); if (!mmsh_connect_int(this, this->user_bandwidth)) goto fail; report_progress (stream, 100); - + lprintf("mmsh_connect: passed\n" ); return this; @@ -717,7 +717,7 @@ static int get_media_packet (mmsh_t *this) { */ if (this->chunk_seq_number == 0) return 0; - + close(this->s); if (mmsh_tcp_connect(this)) @@ -725,20 +725,20 @@ static int get_media_packet (mmsh_t *this) { if (!mmsh_connect_int(this, this->user_bandwidth)) return 0; - + this->playing = 0; /* mmsh_connect_int reads the first data packet */ - /* this->buf_size is set by mmsh_connect_int */ + /* this->buf_size is set by mmsh_connect_int */ return 2; case CHUNK_TYPE_DATA: /* nothing to do */ break; - + case CHUNK_TYPE_RESET: /* next chunk is an ASF header */ - + if (this->chunk_length != 0) { /* that's strange, don't know what to do */ return 0; @@ -747,7 +747,7 @@ static int get_media_packet (mmsh_t *this) { return 0; interp_header(this); return 2; - + default: xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "libmmsh: unexpected chunk type\n"); @@ -755,7 +755,7 @@ static int get_media_packet (mmsh_t *this) { } len = _x_io_tcp_read (this->stream, this->s, (char*)this->buf, this->chunk_length); - + if (len == this->chunk_length) { /* explicit padding with 0 */ if (this->chunk_length > this->asf_header->file->packet_size) { @@ -812,13 +812,13 @@ int mmsh_read (mmsh_t *this, char *data, int len) { this->asf_header_read += n; total += n; this->current_pos += n; - + if (this->asf_header_read == this->asf_header_len) - break; + break; } else { int n, bytes_left ; - + if (!this->playing) { if (!mmsh_connect_int2 (this, this->user_bandwidth)) break; diff --git a/src/input/mmsh.h b/src/input/mmsh.h index eeceb030b..1e337a2d5 100644 --- a/src/input/mmsh.h +++ b/src/input/mmsh.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2002-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index 1883a9462..e14897699 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -116,7 +116,7 @@ static void nbc_set_speed_normal (nbc_t *this) { static void display_stats (nbc_t *this) { static const char buffering[2][4] = {" ", "buf"}; static const char enabled[2][4] = {"off", "on "}; - + printf("bufing: %d, enb: %d\n", this->buffering, this->enabled); printf("net_buf_ctrl: vid %3d%% %4.1fs %4" PRId64 "kbps %1d, "\ "aud %3d%% %4.1fs %4" PRId64 "kbps %1d, %s %s\r", @@ -164,7 +164,7 @@ static void nbc_compute_fifo_length(nbc_t *this, this->video_fifo_free = fifo_free; this->video_fifo_fill = (100 * fifo_fill) / fifo_div; this->video_fifo_size = fifo->fifo_data_size; - + if (buf->pts && (this->video_in_disc == 0)) { if (action == FIFO_PUT) { this->video_last_pts = buf->pts; @@ -176,7 +176,7 @@ static void nbc_compute_fifo_length(nbc_t *this, this->video_first_pts = buf->pts; } } - + if (video_br) { this->video_br = video_br; this->video_fifo_length_int = (8000 * this->video_fifo_size) / this->video_br; @@ -197,7 +197,7 @@ static void nbc_compute_fifo_length(nbc_t *this, this->audio_fifo_free = fifo_free; this->audio_fifo_fill = (100 * fifo_fill) / fifo_div; this->audio_fifo_size = fifo->fifo_data_size; - + if (buf->pts && (this->audio_in_disc == 0)) { if (action == FIFO_PUT) { this->audio_last_pts = buf->pts; @@ -209,7 +209,7 @@ static void nbc_compute_fifo_length(nbc_t *this, this->audio_first_pts = buf->pts; } } - + if (audio_br) { this->audio_br = audio_br; this->audio_fifo_length_int = (8000 * this->audio_fifo_size) / this->audio_br; @@ -226,7 +226,7 @@ static void nbc_compute_fifo_length(nbc_t *this, } } } - + /* decoder buffer compensation */ if (has_audio && has_video) { diff = this->video_first_pts - this->audio_first_pts; @@ -267,7 +267,7 @@ static void nbc_alloc_cb (fifo_buffer_t *fifo, void *this_gen) { /* Put callback * the fifo mutex is locked */ -static void nbc_put_cb (fifo_buffer_t *fifo, +static void nbc_put_cb (fifo_buffer_t *fifo, buf_element_t *buf, void *this_gen) { nbc_t *this = (nbc_t*)this_gen; int64_t progress = 0; @@ -281,7 +281,7 @@ static void nbc_put_cb (fifo_buffer_t *fifo, if ((buf->type & BUF_MAJOR_MASK) != BUF_CONTROL_BASE) { if (this->enabled) { - + nbc_compute_fifo_length(this, fifo, buf, FIFO_PUT); if (this->buffering) { @@ -307,8 +307,8 @@ static void nbc_put_cb (fifo_buffer_t *fifo, xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "\nnet_buf_ctrl: nbc_put_cb: stops buffering\n"); nbc_set_speed_normal(this); - - this->high_water_mark += this->high_water_mark / 2; + + this->high_water_mark += this->high_water_mark / 2; } else { /* compute the buffering progress @@ -435,7 +435,7 @@ static void nbc_get_cb (fifo_buffer_t *fifo, if (this->enabled) { nbc_compute_fifo_length(this, fifo, buf, FIFO_GET); - + if (!this->buffering) { /* start buffering if one fifo is empty */ @@ -450,7 +450,7 @@ static void nbc_get_cb (fifo_buffer_t *fifo, this->progress = 0; report_progress (this->stream, 0); - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "\nnet_buf_ctrl: nbc_get_cb: starts buffering, vid: %d, aud: %d\n", this->video_fifo_fill, this->audio_fifo_fill); nbc_set_speed_pause(this); @@ -491,7 +491,7 @@ static void nbc_get_cb (fifo_buffer_t *fifo, } nbc_t *nbc_init (xine_stream_t *stream) { - + nbc_t *this = calloc(1, sizeof (nbc_t)); fifo_buffer_t *video_fifo = stream->video_fifo; fifo_buffer_t *audio_fifo = stream->audio_fifo; @@ -504,7 +504,7 @@ nbc_t *nbc_init (xine_stream_t *stream) { this->stream = stream; this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; - + /* when the FIFO sizes are increased compared to the default configuration, * apply a factor to the high water mark */ entry = stream->xine->config->lookup_entry(stream->xine->config, "engine.buffers.video_num_buffers"); diff --git a/src/input/net_buf_ctrl.h b/src/input/net_buf_ctrl.h index e71cbedde..0e5ff3f70 100644 --- a/src/input/net_buf_ctrl.h +++ b/src/input/net_buf_ctrl.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA diff --git a/src/input/pnm.c b/src/input/pnm.c index 6e63b9f58..f44b7dcaa 100644 --- a/src/input/pnm.c +++ b/src/input/pnm.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * - * pnm protocol implementation + * pnm protocol implementation * based upon code from joschka */ @@ -146,26 +146,26 @@ static const unsigned char pnm_header[] = { #define PNM_CLIENT_CAPS_SIZE 126 static const unsigned char pnm_client_caps[] = { - 0x07, 0x8a, 'p','n','r','v', - 0, 0x90, 'p','n','r','v', - 0, 0x64, 'd','n','e','t', - 0, 0x46, 'p','n','r','v', - 0, 0x32, 'd','n','e','t', - 0, 0x2b, 'p','n','r','v', - 0, 0x28, 'd','n','e','t', - 0, 0x24, 'p','n','r','v', - 0, 0x19, 'd','n','e','t', - 0, 0x18, 'p','n','r','v', - 0, 0x14, 's','i','p','r', - 0, 0x14, 'd','n','e','t', - 0, 0x24, '2','8','_','8', - 0, 0x12, 'p','n','r','v', - 0, 0x0f, 'd','n','e','t', - 0, 0x0a, 's','i','p','r', - 0, 0x0a, 'd','n','e','t', - 0, 0x08, 's','i','p','r', - 0, 0x06, 's','i','p','r', - 0, 0x12, 'l','p','c','J', + 0x07, 0x8a, 'p','n','r','v', + 0, 0x90, 'p','n','r','v', + 0, 0x64, 'd','n','e','t', + 0, 0x46, 'p','n','r','v', + 0, 0x32, 'd','n','e','t', + 0, 0x2b, 'p','n','r','v', + 0, 0x28, 'd','n','e','t', + 0, 0x24, 'p','n','r','v', + 0, 0x19, 'd','n','e','t', + 0, 0x18, 'p','n','r','v', + 0, 0x14, 's','i','p','r', + 0, 0x14, 'd','n','e','t', + 0, 0x24, '2','8','_','8', + 0, 0x12, 'p','n','r','v', + 0, 0x0f, 'd','n','e','t', + 0, 0x0a, 's','i','p','r', + 0, 0x0a, 'd','n','e','t', + 0, 0x08, 's','i','p','r', + 0, 0x06, 's','i','p','r', + 0, 0x12, 'l','p','c','J', 0, 0x07, '0','5','_','6' }; static const uint32_t pnm_default_bandwidth=10485800; @@ -181,7 +181,7 @@ static const unsigned char pnm_twentyfour[]={ static const int after_chunks_length=6; static const unsigned char after_chunks[]={ 0x00, 0x00, /* mark */ - + 0x50, 0x84, /* seems to be fixated */ 0x1f, 0x3a /* varies on each request (checksum ?)*/ }; @@ -203,7 +203,7 @@ static const unsigned char after_chunks[]={ * if we have an PNA_TAG, we need a different parsing; see below. */ -static unsigned int pnm_get_chunk(pnm_t *p, +static unsigned int pnm_get_chunk(pnm_t *p, unsigned int max, unsigned int *chunk_type, char *data, int *need_response) { @@ -214,7 +214,7 @@ static unsigned int pnm_get_chunk(pnm_t *p, if( max < PREAMBLE_SIZE ) return -1; - + /* get first PREAMBLE_SIZE bytes and ignore checksum */ _x_io_tcp_read (p->stream, p->s, data, CHECKSUM_SIZE); if (data[0] == 0x72) @@ -223,7 +223,7 @@ static unsigned int pnm_get_chunk(pnm_t *p, _x_io_tcp_read (p->stream, p->s, data+CHECKSUM_SIZE, PREAMBLE_SIZE-CHECKSUM_SIZE); max -= PREAMBLE_SIZE; - + *chunk_type = be2me_32(*((uint32_t *)data)); chunk_size = be2me_32(*((uint32_t *)(data+4))); @@ -239,10 +239,10 @@ static unsigned int pnm_get_chunk(pnm_t *p, while(1) { /* The pna chunk is devided into subchunks. - * expecting following chunk format (in big endian): - * 0x4f - * uint8_t chunk_size - * uint8_t data[chunk_size] + * expecting following chunk format (in big endian): + * 0x4f + * uint8_t chunk_size + * uint8_t data[chunk_size] * * if first byte is 'X', we got a message from server * if first byte is 'F', we got an error @@ -252,7 +252,7 @@ static unsigned int pnm_get_chunk(pnm_t *p, return -1; _x_io_tcp_read (p->stream, p->s, ptr, 2); max -= 2; - + if (*ptr == 'X') /* checking for server message */ { xprintf(p->stream->xine, XINE_VERBOSITY_DEBUG, "input_pnm: got a message from server:\n"); @@ -275,7 +275,7 @@ static unsigned int pnm_get_chunk(pnm_t *p, xprintf(p->stream->xine, XINE_VERBOSITY_DEBUG, "%s\n", ptr+3); return -1; } - + if (*ptr == 'F') /* checking for server error */ { /* some error codes after 'F' were ignored */ @@ -321,7 +321,7 @@ static unsigned int pnm_get_chunk(pnm_t *p, break; default: *chunk_type = 0; - chunk_size = PREAMBLE_SIZE; + chunk_size = PREAMBLE_SIZE; break; } @@ -336,7 +336,7 @@ static unsigned int pnm_get_chunk(pnm_t *p, * uint8_t data[length] */ -static int pnm_write_chunk(uint16_t chunk_id, uint16_t length, +static int pnm_write_chunk(uint16_t chunk_id, uint16_t length, const char *chunk, char *data) { uint16_t be_id, be_len; @@ -347,7 +347,7 @@ static int pnm_write_chunk(uint16_t chunk_id, uint16_t length, memcpy(data , &be_id , 2); memcpy(data+2, &be_len, 2); memcpy(data+4, chunk , length); - + return length+4; } @@ -385,7 +385,7 @@ static void pnm_send_request(pnm_t *p, uint32_t bandwidth) { pnm_guid,&p->buffer[c]); c+=pnm_write_chunk(PNA_TWENTYFOUR,PNM_TWENTYFOUR_SIZE, (char*)pnm_twentyfour,&p->buffer[c]); - + /* data after chunks */ memcpy(&p->buffer[c],after_chunks,after_chunks_length); c+=after_chunks_length; @@ -408,7 +408,7 @@ static void pnm_send_request(pnm_t *p, uint32_t bandwidth) { /* some trailing bytes */ p->buffer[c]='y'; p->buffer[c+1]='B'; - + _x_io_tcp_write(p->stream,p->s,p->buffer,c+2); } @@ -478,7 +478,7 @@ static int pnm_get_headers(pnm_t *p, int *need_response) { xprintf(p->stream->xine, XINE_VERBOSITY_DEBUG, "input_pnm: error while parsing headers.\n"); return 0; } - + /* set data offset */ { uint32_t be_size; @@ -486,7 +486,7 @@ static int pnm_get_headers(pnm_t *p, int *need_response) { be_size = be2me_32(size-1); memcpy(prop_hdr+42, &be_size, 4); } - + /* read challenge */ memcpy (p->buffer, ptr, PREAMBLE_SIZE); _x_io_tcp_read (p->stream, p->s, &p->buffer[PREAMBLE_SIZE], 64); @@ -494,18 +494,18 @@ static int pnm_get_headers(pnm_t *p, int *need_response) { /* now write a data header */ memcpy(ptr, pnm_data_header, PNM_DATA_HEADER_SIZE); size+=PNM_DATA_HEADER_SIZE; -/* +/* h=rmff_scan_header(p->header); rmff_fix_header(h); p->header_len=rmff_get_header_size(h); rmff_dump_header(h, p->header, HEADER_SIZE); */ p->header_len=size; - + return 1; } -/* +/* * determine correct stream number by looking at indices * FIXME: this doesn't work with all streams! There must be * another way to determine correct stream numbers! @@ -571,7 +571,7 @@ static int pnm_calc_stream(pnm_t *p) { return 0; break; } - xprintf(p->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(p->stream->xine, XINE_VERBOSITY_DEBUG, "input_pnm: wow, something very nasty happened in pnm_calc_stream\n"); return 2; } @@ -588,7 +588,7 @@ static int pnm_get_stream_chunk(pnm_t *p) { /* send a keepalive */ /* realplayer seems to do that every 43th package */ - if ((p->packet%43) == 42) + if ((p->packet%43) == 42) { _x_io_tcp_write(p->stream,p->s,&keepalive,1); } @@ -598,10 +598,10 @@ static int pnm_get_stream_chunk(pnm_t *p) { * <i1> is a 16 bit index (big endian) * <i2> is a 8 bit index which counts from 0x10 to somewhere */ - + n = _x_io_tcp_read (p->stream, p->s, p->buffer, 8); if (n<8) return 0; - + /* skip 8 bytes if 0x62 is read */ if (p->buffer[0] == 0x62) { @@ -609,7 +609,7 @@ static int pnm_get_stream_chunk(pnm_t *p) { if (n<8) return 0; lprintf("had to seek 8 bytes on 0x62\n"); } - + /* a server message */ if (p->buffer[0] == 'X') { @@ -617,7 +617,7 @@ static int pnm_get_stream_chunk(pnm_t *p) { _x_io_tcp_read (p->stream, p->s, &p->buffer[8], size-5); p->buffer[size+3]=0; - xprintf(p->stream->xine, XINE_VERBOSITY_LOG, + xprintf(p->stream->xine, XINE_VERBOSITY_LOG, _("input_pnm: got message from server while reading stream:\n%s\n"), &p->buffer[3]); return 0; } @@ -657,14 +657,14 @@ static int pnm_get_stream_chunk(pnm_t *p) { fof2=be2me_16(*(uint16_t*)(&p->buffer[3])); if (fof1 != fof2) { - xprintf(p->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(p->stream->xine, XINE_VERBOSITY_DEBUG, "input_pnm: frame offsets are different: 0x%04x 0x%04x\n", fof1, fof2); return 0; } /* get first index */ p->seq_current[0]=be2me_16(*(uint16_t*)(&p->buffer[5])); - + /* now read the rest of stream chunk */ n = _x_io_tcp_read (p->stream, p->s, (char*)&p->recv[5], fof1-5); if (n<(fof1-5)) return 0; @@ -674,15 +674,15 @@ static int pnm_get_stream_chunk(pnm_t *p) { /* get timestamp */ p->ts_current=be2me_32(*(uint32_t*)(&p->recv[6])); - + /* get stream number */ stream=pnm_calc_stream(p); /* saving timestamp */ p->ts_last[stream]=p->ts_current; - + /* constructing a data packet header */ - + p->recv[0]=0; /* object version */ p->recv[1]=0; @@ -693,7 +693,7 @@ static int pnm_get_stream_chunk(pnm_t *p) { p->recv[4]=0; /* stream number */ p->recv[5]=stream; - + p->recv[10]=p->recv[10] & 0xfe; /* streambox seems to do that... */ p->packet++; @@ -704,19 +704,19 @@ static int pnm_get_stream_chunk(pnm_t *p) { } pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) { - + char *mrl_ptr=strdup(mrl); char *slash, *colon; size_t pathbegin, hostend; pnm_t *p; int fd; int need_response=0; - + if (strncmp(mrl,"pnm://",6)) { return NULL; } - + mrl_ptr+=6; p = calloc(1, sizeof(pnm_t)); @@ -729,7 +729,7 @@ pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) { colon=strchr(mrl_ptr,':'); if(!slash) slash=mrl_ptr+strlen(mrl_ptr)+1; - if(!colon) colon=slash; + if(!colon) colon=slash; if(colon > slash) colon=slash; pathbegin=slash-mrl_ptr; @@ -747,7 +747,7 @@ pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) { free(mrl_ptr-6); lprintf("got mrl: %s %i %s\n",p->host,p->port,p->path); - + fd = _x_io_tcp_connect (stream, p->host, p->port); if (fd == -1) { @@ -773,7 +773,7 @@ pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) { pnm_send_response(p, pnm_response); p->ts_last[0]=0; p->ts_last[1]=0; - + /* copy header to recv */ memcpy(p->recv, p->header, p->header_len); @@ -784,15 +784,15 @@ pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) { } int pnm_read (pnm_t *this, char *data, int len) { - + int to_copy=len; char *dest=data; char *source=(char*)(this->recv + this->recv_read); int fill=this->recv_size - this->recv_read; - + if (len < 0) return 0; while (to_copy > fill) { - + memcpy(dest, source, fill); to_copy -= fill; dest += fill; diff --git a/src/input/pnm.h b/src/input/pnm.h index bf3514bae..cf547f505 100644 --- a/src/input/pnm.h +++ b/src/input/pnm.h @@ -19,7 +19,7 @@ * * pnm util functions header by joschka */ - + #ifndef HAVE_PNM_H #define HAVE_PNM_H diff --git a/src/input/vcd/vcdio.c b/src/input/vcd/vcdio.c index b3194e281..993a9f9ff 100644 --- a/src/input/vcd/vcdio.c +++ b/src/input/vcd/vcdio.c @@ -1,22 +1,22 @@ /* $Id: vcdio.c,v 1.9 2007/03/23 21:47:31 dsalt Exp $ - + Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - + */ #ifdef HAVE_CONFIG_H @@ -63,30 +63,30 @@ #define FREE_AND_NULL(ptr) if (NULL != ptr) free(ptr); ptr = NULL; -/*! Closes VCD device specified via "this", and also wipes memory of it +/*! Closes VCD device specified via "this", and also wipes memory of it from it inside "this". */ int -vcdio_close(vcdplayer_t *p_vcdplayer) +vcdio_close(vcdplayer_t *p_vcdplayer) { p_vcdplayer->b_opened = false; FREE_AND_NULL(p_vcdplayer->psz_source); FREE_AND_NULL(p_vcdplayer->track); FREE_AND_NULL(p_vcdplayer->segment); - FREE_AND_NULL(p_vcdplayer->entry); - + FREE_AND_NULL(p_vcdplayer->entry); + return vcdinfo_close(p_vcdplayer->vcd); } /*! Opens VCD device and initializes things. - - do nothing if the device had already been open and is the same device. + - do nothing if the device had already been open and is the same device. - if the device had been open and is a different, close it before trying - to open new device. + to open new device. */ bool -vcdio_open(vcdplayer_t *p_vcdplayer, char *intended_vcd_device) +vcdio_open(vcdplayer_t *p_vcdplayer, char *intended_vcd_device) { vcdinfo_obj_t *p_vcdinfo = p_vcdplayer->vcd; unsigned int i; @@ -137,60 +137,60 @@ vcdio_open(vcdplayer_t *p_vcdplayer, char *intended_vcd_device) } } - /* - Save summary info on tracks, segments and entries... + /* + Save summary info on tracks, segments and entries... */ if ( 0 < (p_vcdplayer->i_tracks = vcdinfo_get_num_tracks(p_vcdinfo)) ) { - p_vcdplayer->track = (vcdplayer_play_item_info_t *) + p_vcdplayer->track = (vcdplayer_play_item_info_t *) calloc(p_vcdplayer->i_tracks, sizeof(vcdplayer_play_item_info_t)); - - for (i=0; i<p_vcdplayer->i_tracks; i++) { + + for (i=0; i<p_vcdplayer->i_tracks; i++) { track_t i_track=i+1; - p_vcdplayer->track[i].size + p_vcdplayer->track[i].size = vcdinfo_get_track_sect_count(p_vcdinfo, i_track); - p_vcdplayer->track[i].start_LSN + p_vcdplayer->track[i].start_LSN = vcdinfo_get_track_lsn(p_vcdinfo, i_track); } - } else + } else p_vcdplayer->track = NULL; - + if ( 0 < (p_vcdplayer->i_entries = vcdinfo_get_num_entries(p_vcdinfo)) ) { - p_vcdplayer->entry = (vcdplayer_play_item_info_t *) + p_vcdplayer->entry = (vcdplayer_play_item_info_t *) calloc(p_vcdplayer->i_entries, sizeof(vcdplayer_play_item_info_t)); - for (i=0; i<p_vcdplayer->i_entries; i++) { + for (i=0; i<p_vcdplayer->i_entries; i++) { p_vcdplayer->entry[i].size = vcdinfo_get_entry_sect_count(p_vcdinfo, i); - p_vcdplayer->entry[i].start_LSN + p_vcdplayer->entry[i].start_LSN = vcdinfo_get_entry_lsn(p_vcdinfo, i); } - } else + } else p_vcdplayer->entry = NULL; - + if ( 0 < (p_vcdplayer->i_segments = vcdinfo_get_num_segments(p_vcdinfo)) ) { - p_vcdplayer->segment = (vcdplayer_play_item_info_t *) + p_vcdplayer->segment = (vcdplayer_play_item_info_t *) calloc(p_vcdplayer->i_segments, sizeof(vcdplayer_play_item_info_t)); - - for (i=0; i<p_vcdplayer->i_segments; i++) { - p_vcdplayer->segment[i].size + + for (i=0; i<p_vcdplayer->i_segments; i++) { + p_vcdplayer->segment[i].size = vcdinfo_get_seg_sector_count(p_vcdinfo, i); - p_vcdplayer->segment[i].start_LSN + p_vcdplayer->segment[i].start_LSN = vcdinfo_get_seg_lsn(p_vcdinfo, i); } - } else + } else p_vcdplayer->segment = NULL; - + return true; } /*! - seek position, return new position + seek position, return new position if seeking failed, -1 is returned */ -off_t -vcdio_seek (vcdplayer_t *p_vcdplayer, off_t offset, int origin) +off_t +vcdio_seek (vcdplayer_t *p_vcdplayer, off_t offset, int origin) { switch (origin) { @@ -198,54 +198,54 @@ vcdio_seek (vcdplayer_t *p_vcdplayer, off_t offset, int origin) { lsn_t old_lsn = p_vcdplayer->i_lsn; p_vcdplayer->i_lsn = p_vcdplayer->origin_lsn + (offset / M2F2_SECTOR_SIZE); - - dbg_print(INPUT_DBG_SEEK_SET, "seek_set to %ld => %u (start is %u)\n", + + dbg_print(INPUT_DBG_SEEK_SET, "seek_set to %ld => %u (start is %u)\n", (long int) offset, p_vcdplayer->i_lsn, p_vcdplayer->origin_lsn); /* Seek was successful. Invalidate entry location by setting - entry number back to 1. Over time it will adjust upward + entry number back to 1. Over time it will adjust upward to the correct value. */ - if ( !vcdplayer_pbc_is_on(p_vcdplayer) - && p_vcdplayer->play_item.type != VCDINFO_ITEM_TYPE_TRACK + if ( !vcdplayer_pbc_is_on(p_vcdplayer) + && p_vcdplayer->play_item.type != VCDINFO_ITEM_TYPE_TRACK && p_vcdplayer->i_lsn < old_lsn) { dbg_print(INPUT_DBG_SEEK_SET, "seek_set entry backwards\n"); p_vcdplayer->next_entry = 1; } break; } - - case SEEK_CUR: + + case SEEK_CUR: { off_t diff; if (offset) { LOG_ERR(p_vcdplayer, "%s: %d\n", - _("SEEK_CUR not implemented for non-zero offset"), + _("SEEK_CUR not implemented for non-zero offset"), (int) offset); return (off_t) -1; } - + if (p_vcdplayer->slider_length == VCDPLAYER_SLIDER_LENGTH_TRACK) { diff = p_vcdplayer->i_lsn - p_vcdplayer->track_lsn; - dbg_print(INPUT_DBG_SEEK_CUR, - "current pos: %u, track diff %ld\n", + dbg_print(INPUT_DBG_SEEK_CUR, + "current pos: %u, track diff %ld\n", p_vcdplayer->i_lsn, (long int) diff); } else { diff = p_vcdplayer->i_lsn - p_vcdplayer->origin_lsn; - dbg_print(INPUT_DBG_SEEK_CUR, - "current pos: %u, entry diff %ld\n", + dbg_print(INPUT_DBG_SEEK_CUR, + "current pos: %u, entry diff %ld\n", p_vcdplayer->i_lsn, (long int) diff); } - + if (diff < 0) { dbg_print(INPUT_DBG_SEEK_CUR, "Error: diff < 0\n"); return (off_t) 0; } else { return (off_t)diff * M2F2_SECTOR_SIZE; } - + break; } - + case SEEK_END: LOG_ERR(p_vcdplayer, "%s\n", _("SEEK_END not implemented yet.")); return (off_t) -1; @@ -258,7 +258,7 @@ vcdio_seek (vcdplayer_t *p_vcdplayer, off_t offset, int origin) return offset ; /* FIXME */ } -/* +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/input/vcd/vcdio.h b/src/input/vcd/vcdio.h index 145bb4d7f..854ba5333 100644 --- a/src/input/vcd/vcdio.h +++ b/src/input/vcd/vcdio.h @@ -1,22 +1,22 @@ -/* +/* $Id: vcdio.h,v 1.3 2005/01/08 15:12:42 rockyb Exp $ Copyright (C) 2002, 2004, 2005 Rocky Bernstein <rocky@panix.com> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - + */ #ifndef _VCDIO_H_ @@ -27,37 +27,37 @@ read nlen bytes, return number of bytes read. */ -off_t +off_t vcdio_read (vcdplayer_t *p_vcdplayer, char *psz_buf, const off_t nlen); /*! Opens VCD device and initializes things. - - do nothing if the device had already been open and is the same device. + - do nothing if the device had already been open and is the same device. - if the device had been open and is a different, close it before trying - to open new device. + to open new device. */ bool vcdio_open(vcdplayer_t *p_vcdplayer, char *psz_device); -/*! Closes VCD device specified via "this", and also wipes memory of it +/*! Closes VCD device specified via "this", and also wipes memory of it from it inside "this". */ /* FIXME Move player stuff to player. */ -int +int vcdio_close(vcdplayer_t *p_vcdplayer); /*! From xine plugin spec: - seek position, return new position + seek position, return new position if seeking failed, -1 is returned */ -off_t +off_t vcdio_seek (vcdplayer_t *p_vcdplayer, off_t offset, int origin); #endif /* _VCDIO_H_ */ -/* +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/input/vcd/vcdplayer.c b/src/input/vcd/vcdplayer.c index 7f9189cba..5e36e125e 100644 --- a/src/input/vcd/vcdplayer.c +++ b/src/input/vcd/vcdplayer.c @@ -1,22 +1,22 @@ -/* +/* $Id: vcdplayer.c,v 1.20 2007/02/21 23:17:14 dgp85 Exp $ - + Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - + */ #ifdef HAVE_CONFIG_H @@ -64,15 +64,15 @@ static void _vcdplayer_set_origin(vcdplayer_t *p_vcdplayer); Return true if playback control (PBC) is on */ bool -vcdplayer_pbc_is_on(const vcdplayer_t *p_vcdplayer) +vcdplayer_pbc_is_on(const vcdplayer_t *p_vcdplayer) { - return VCDINFO_INVALID_ENTRY != p_vcdplayer->i_lid; + return VCDINFO_INVALID_ENTRY != p_vcdplayer->i_lid; } /* Given an itemid, return the size for the object (via information previously stored when opening the vcd). */ static size_t -_vcdplayer_get_item_size(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) +_vcdplayer_get_item_size(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) { switch (itemid.type) { case VCDINFO_ITEM_TYPE_ENTRY: @@ -125,17 +125,17 @@ _vcdplayer_get_item_size(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) /*! Take a format string and expand escape sequences, that is sequences that - begin with %, with information from the current VCD. + begin with %, with information from the current VCD. The expanded string is returned. Here is a list of escape sequences: - %A : The album information + %A : The album information %C : The VCD volume count - the number of CD's in the collection. - %c : The VCD volume num - the number of the CD in the collection. + %c : The VCD volume num - the number of the CD in the collection. %F : The VCD Format, e.g. VCD 1.0, VCD 1.1, VCD 2.0, or SVCD %I : The current entry/segment/playback type, e.g. ENTRY, TRACK, SEGMENT... %L : The playlist ID prefixed with " LID" if it exists %N : The current number of the above - a decimal number - %P : The publisher ID + %P : The publisher ID %p : The preparer ID %S : If we are in a segment (menu), the kind of segment %T : The track number @@ -174,7 +174,7 @@ vcdplayer_format_str(vcdplayer_t *p_vcdplayer, const char format_str[]) saw_control_prefix = !saw_control_prefix; break; case 'A': - add_format_str_info(vcdinfo_strip_trail(vcdinfo_get_album_id(p_vcdinfo), + add_format_str_info(vcdinfo_strip_trail(vcdinfo_get_album_id(p_vcdinfo), MAX_ALBUM_LEN)); break; @@ -197,19 +197,19 @@ vcdplayer_format_str(vcdplayer_t *p_vcdplayer, const char format_str[]) strncat(tp, "Track", TEMP_STR_LEN-(tp-temp_str)); tp += strlen("Track"); break; - case VCDINFO_ITEM_TYPE_ENTRY: + case VCDINFO_ITEM_TYPE_ENTRY: strncat(tp, "Entry", TEMP_STR_LEN-(tp-temp_str)); tp += strlen("Entry"); break; - case VCDINFO_ITEM_TYPE_SEGMENT: + case VCDINFO_ITEM_TYPE_SEGMENT: strncat(tp, "Segment", TEMP_STR_LEN-(tp-temp_str)); tp += strlen("Segment"); break; - case VCDINFO_ITEM_TYPE_LID: + case VCDINFO_ITEM_TYPE_LID: strncat(tp, "List ID", TEMP_STR_LEN-(tp-temp_str)); tp += strlen("List ID"); break; - case VCDINFO_ITEM_TYPE_SPAREID2: + case VCDINFO_ITEM_TYPE_SPAREID2: strncat(tp, "Navigation", TEMP_STR_LEN-(tp-temp_str)); tp += strlen("Navigation"); break; @@ -247,7 +247,7 @@ vcdplayer_format_str(vcdplayer_t *p_vcdplayer, const char format_str[]) if ( VCDINFO_ITEM_TYPE_SEGMENT==p_vcdplayer->play_item.type ) { char seg_type_str[30]; - snprintf(seg_type_str, sizeof(seg_type_str), " %s", + snprintf(seg_type_str, sizeof(seg_type_str), " %s", vcdinfo_video_type2str(p_vcdinfo, p_vcdplayer->play_item.num)); strncat(tp, seg_type_str, TEMP_STR_LEN-(tp-temp_str)); tp += strlen(seg_type_str); @@ -268,7 +268,7 @@ vcdplayer_format_str(vcdplayer_t *p_vcdplayer, const char format_str[]) break; default: - *tp++ = '%'; + *tp++ = '%'; *tp++ = format_str[i]; saw_control_prefix = false; } @@ -277,7 +277,7 @@ vcdplayer_format_str(vcdplayer_t *p_vcdplayer, const char format_str[]) } static void -_vcdplayer_update_entry(vcdinfo_obj_t *p_vcdinfo, uint16_t ofs, +_vcdplayer_update_entry(vcdinfo_obj_t *p_vcdinfo, uint16_t ofs, uint16_t *entry, const char *label) { if ( ofs == VCDINFO_INVALID_OFFSET ) { @@ -293,8 +293,8 @@ _vcdplayer_update_entry(vcdinfo_obj_t *p_vcdinfo, uint16_t ofs, } /*! - Update next/prev/return/default navigation buttons - (via p_vcdplayer->i_lid). Update size of play-item + Update next/prev/return/default navigation buttons + (via p_vcdplayer->i_lid). Update size of play-item (via p_vcdplayer->play_item). */ void @@ -307,51 +307,51 @@ vcdplayer_update_nav(vcdplayer_t *p_vcdplayer) int max_entry = 0; if (vcdplayer_pbc_is_on(p_vcdplayer)) { - + vcdinfo_lid_get_pxd(p_vcdinfo, &(p_vcdplayer->pxd), p_vcdplayer->i_lid); - + switch (p_vcdplayer->pxd.descriptor_type) { case PSD_TYPE_SELECTION_LIST: case PSD_TYPE_EXT_SELECTION_LIST: if (p_vcdplayer->pxd.psd == NULL) return; - _vcdplayer_update_entry(p_vcdinfo, + _vcdplayer_update_entry(p_vcdinfo, vcdinf_psd_get_prev_offset(p_vcdplayer->pxd.psd), &(p_vcdplayer->prev_entry), "prev"); - - _vcdplayer_update_entry(p_vcdinfo, + + _vcdplayer_update_entry(p_vcdinfo, vcdinf_psd_get_next_offset(p_vcdplayer->pxd.psd), &(p_vcdplayer->next_entry), "next"); - - _vcdplayer_update_entry(p_vcdinfo, + + _vcdplayer_update_entry(p_vcdinfo, vcdinf_psd_get_return_offset(p_vcdplayer->pxd.psd), &(p_vcdplayer->return_entry), "return"); - _vcdplayer_update_entry(p_vcdinfo, - vcdinfo_get_default_offset(p_vcdinfo, + _vcdplayer_update_entry(p_vcdinfo, + vcdinfo_get_default_offset(p_vcdinfo, p_vcdplayer->i_lid), &(p_vcdplayer->default_entry), "default"); break; case PSD_TYPE_PLAY_LIST: if (p_vcdplayer->pxd.pld == NULL) return; - _vcdplayer_update_entry(p_vcdinfo, + _vcdplayer_update_entry(p_vcdinfo, vcdinf_pld_get_prev_offset(p_vcdplayer->pxd.pld), &(p_vcdplayer->prev_entry), "prev"); - - _vcdplayer_update_entry(p_vcdinfo, + + _vcdplayer_update_entry(p_vcdinfo, vcdinf_pld_get_next_offset(p_vcdplayer->pxd.pld), &(p_vcdplayer->next_entry), "next"); - - _vcdplayer_update_entry(p_vcdinfo, + + _vcdplayer_update_entry(p_vcdinfo, vcdinf_pld_get_return_offset(p_vcdplayer->pxd.pld), &(p_vcdplayer->return_entry), "return"); p_vcdplayer->default_entry = VCDINFO_INVALID_ENTRY; break; case PSD_TYPE_END_LIST: - p_vcdplayer->origin_lsn = p_vcdplayer->i_lsn = p_vcdplayer->end_lsn + p_vcdplayer->origin_lsn = p_vcdplayer->i_lsn = p_vcdplayer->end_lsn = VCDINFO_NULL_LSN; /* Fall through */ case PSD_TYPE_COMMAND_LIST: - p_vcdplayer->next_entry = p_vcdplayer->prev_entry + p_vcdplayer->next_entry = p_vcdplayer->prev_entry = p_vcdplayer->return_entry = VCDINFO_INVALID_ENTRY; p_vcdplayer->default_entry = VCDINFO_INVALID_ENTRY; break; @@ -363,53 +363,53 @@ vcdplayer_update_nav(vcdplayer_t *p_vcdplayer) } /* PBC is not on. Set up for simplified next, prev, and return. */ - + switch (p_vcdplayer->play_item.type) { - case VCDINFO_ITEM_TYPE_ENTRY: - case VCDINFO_ITEM_TYPE_SEGMENT: - case VCDINFO_ITEM_TYPE_TRACK: + case VCDINFO_ITEM_TYPE_ENTRY: + case VCDINFO_ITEM_TYPE_SEGMENT: + case VCDINFO_ITEM_TYPE_TRACK: switch (p_vcdplayer->play_item.type) { - case VCDINFO_ITEM_TYPE_ENTRY: + case VCDINFO_ITEM_TYPE_ENTRY: max_entry = p_vcdplayer->i_entries; min_entry = 0; /* Can remove when Entries start at 1. */ p_vcdplayer->i_track = vcdinfo_get_track(p_vcdinfo, play_item); - p_vcdplayer->track_lsn = vcdinfo_get_track_lsn(p_vcdinfo, + p_vcdplayer->track_lsn = vcdinfo_get_track_lsn(p_vcdinfo, p_vcdplayer->i_track); break; - case VCDINFO_ITEM_TYPE_SEGMENT: + case VCDINFO_ITEM_TYPE_SEGMENT: max_entry = p_vcdplayer->i_segments; p_vcdplayer->i_track = VCDINFO_INVALID_TRACK; - + break; - case VCDINFO_ITEM_TYPE_TRACK: + case VCDINFO_ITEM_TYPE_TRACK: max_entry = p_vcdplayer->i_tracks; p_vcdplayer->i_track = p_vcdplayer->play_item.num; - p_vcdplayer->track_lsn = vcdinfo_get_track_lsn(p_vcdinfo, + p_vcdplayer->track_lsn = vcdinfo_get_track_lsn(p_vcdinfo, p_vcdplayer->i_track); break; default: ; /* Handle exceptional cases below */ } - + _vcdplayer_set_origin(p_vcdplayer); /* Set next, prev, return and default to simple and hopefully useful values. */ - if (play_item+1 >= max_entry) + if (play_item+1 >= max_entry) p_vcdplayer->next_entry = VCDINFO_INVALID_ENTRY; - else + else p_vcdplayer->next_entry = play_item+1; - - if (play_item-1 >= min_entry) + + if (play_item-1 >= min_entry) p_vcdplayer->prev_entry = play_item-1; - else + else p_vcdplayer->prev_entry = VCDINFO_INVALID_ENTRY; - + p_vcdplayer->default_entry = play_item; p_vcdplayer->return_entry = min_entry; break; - case VCDINFO_ITEM_TYPE_LID: + case VCDINFO_ITEM_TYPE_LID: { /* Should have handled above. */ break; @@ -423,9 +423,9 @@ vcdplayer_update_nav(vcdplayer_t *p_vcdplayer) Set reading to play an entire track. */ static void -_vcdplayer_set_track(vcdplayer_t *p_vcdplayer, unsigned int i_track) +_vcdplayer_set_track(vcdplayer_t *p_vcdplayer, unsigned int i_track) { - if (i_track < 1 || i_track > p_vcdplayer->i_tracks) + if (i_track < 1 || i_track > p_vcdplayer->i_tracks) return; else { vcdinfo_obj_t *p_vcdinfo = p_vcdplayer->vcd; @@ -449,7 +449,7 @@ _vcdplayer_set_track(vcdplayer_t *p_vcdplayer, unsigned int i_track) Set reading to play an entry */ static void -_vcdplayer_set_entry(vcdplayer_t *p_vcdplayer, unsigned int num) +_vcdplayer_set_entry(vcdplayer_t *p_vcdplayer, unsigned int num) { vcdinfo_obj_t *p_vcdinfo = p_vcdplayer->vcd; const unsigned int i_entries = vcdinfo_get_num_entries(p_vcdinfo); @@ -466,14 +466,14 @@ _vcdplayer_set_entry(vcdplayer_t *p_vcdplayer, unsigned int num) p_vcdplayer->i_lsn = vcdinfo_get_entry_lsn(p_vcdinfo, num); p_vcdplayer->play_item = itemid; p_vcdplayer->i_track = vcdinfo_get_track(p_vcdinfo, num); - p_vcdplayer->track_lsn = vcdinfo_get_track_lsn(p_vcdinfo, + p_vcdplayer->track_lsn = vcdinfo_get_track_lsn(p_vcdinfo, p_vcdplayer->i_track); - p_vcdplayer->track_end_lsn = p_vcdplayer->track_lsn + + p_vcdplayer->track_end_lsn = p_vcdplayer->track_lsn + p_vcdplayer->track[p_vcdplayer->i_track-1].size; _vcdplayer_set_origin(p_vcdplayer); - dbg_print((INPUT_DBG_LSN|INPUT_DBG_PBC), "LSN: %u, track_end LSN: %u\n", + dbg_print((INPUT_DBG_LSN|INPUT_DBG_PBC), "LSN: %u, track_end LSN: %u\n", p_vcdplayer->i_lsn, p_vcdplayer->track_end_lsn); } } @@ -482,7 +482,7 @@ _vcdplayer_set_entry(vcdplayer_t *p_vcdplayer, unsigned int num) Set reading to play an segment (e.g. still frame) */ static void -_vcdplayer_set_segment(vcdplayer_t *p_vcdplayer, unsigned int num) +_vcdplayer_set_segment(vcdplayer_t *p_vcdplayer, unsigned int num) { vcdinfo_obj_t *p_vcdinfo = p_vcdplayer->vcd; segnum_t i_segs = vcdinfo_get_num_segments(p_vcdinfo); @@ -497,17 +497,17 @@ _vcdplayer_set_segment(vcdplayer_t *p_vcdplayer, unsigned int num) p_vcdplayer->i_track = 0; if (VCDINFO_NULL_LSN==p_vcdplayer->i_lsn) { - LOG_ERR(p_vcdplayer, "%s %d\n", + LOG_ERR(p_vcdplayer, "%s %d\n", _("Error in getting current segment number"), num); return; } - + itemid.num = num; itemid.type = VCDINFO_ITEM_TYPE_SEGMENT; p_vcdplayer->play_item = itemid; _vcdplayer_set_origin(p_vcdplayer); - + dbg_print(INPUT_DBG_LSN, "LSN: %u\n", p_vcdplayer->i_lsn); } } @@ -519,29 +519,29 @@ vcdplayer_play_single_item(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) { vcdinfo_obj_t *p_vcdinfo = p_vcdplayer->vcd; - dbg_print(INPUT_DBG_CALL, "called itemid.num: %d, itemid.type: %d\n", + dbg_print(INPUT_DBG_CALL, "called itemid.num: %d, itemid.type: %d\n", itemid.num, itemid.type); p_vcdplayer->i_still = 0; switch (itemid.type) { - case VCDINFO_ITEM_TYPE_SEGMENT: + case VCDINFO_ITEM_TYPE_SEGMENT: { - vcdinfo_video_segment_type_t segtype + vcdinfo_video_segment_type_t segtype = vcdinfo_get_video_type(p_vcdinfo, itemid.num); segnum_t i_segs = vcdinfo_get_num_segments(p_vcdinfo); - dbg_print(INPUT_DBG_PBC, "%s (%d), itemid.num: %d\n", - vcdinfo_video_type2str(p_vcdinfo, itemid.num), + dbg_print(INPUT_DBG_PBC, "%s (%d), itemid.num: %d\n", + vcdinfo_video_type2str(p_vcdinfo, itemid.num), (int) segtype, itemid.num); if (itemid.num >= i_segs) return; _vcdplayer_set_segment(p_vcdplayer, itemid.num); vcdinfo_get_seg_resolution(p_vcdinfo, itemid.num, - &(p_vcdplayer->max_x), + &(p_vcdplayer->max_x), &(p_vcdplayer->max_y)); - + switch (segtype) { case VCDINFO_FILES_VIDEO_NTSC_STILL: case VCDINFO_FILES_VIDEO_NTSC_STILL2: @@ -558,7 +558,7 @@ vcdplayer_play_single_item(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) case VCD_TYPE_VCD: case VCD_TYPE_VCD11: case VCD_TYPE_VCD2: - /* aspect ratio for VCD's is known to be 4:3 for any + /* aspect ratio for VCD's is known to be 4:3 for any type of VCD's */ p_vcdplayer->set_aspect_ratio(1); break; @@ -566,17 +566,17 @@ vcdplayer_play_single_item(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) } p_vcdplayer->i_still = 0; } - + break; } - + case VCDINFO_ITEM_TYPE_TRACK: dbg_print(INPUT_DBG_PBC, "track %d\n", itemid.num); if (itemid.num < 1 || itemid.num > p_vcdplayer->i_tracks) return; _vcdplayer_set_track(p_vcdplayer, itemid.num); break; - - case VCDINFO_ITEM_TYPE_ENTRY: + + case VCDINFO_ITEM_TYPE_ENTRY: { unsigned int i_entries = vcdinfo_get_num_entries(p_vcdinfo); dbg_print(INPUT_DBG_PBC, "entry %d\n", itemid.num); @@ -584,7 +584,7 @@ vcdplayer_play_single_item(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) _vcdplayer_set_entry(p_vcdplayer, itemid.num); break; } - + case VCDINFO_ITEM_TYPE_LID: LOG_ERR(p_vcdplayer, "%s\n", _("Should have converted this above")); break; @@ -598,7 +598,7 @@ vcdplayer_play_single_item(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) LOG_ERR(p_vcdplayer, "item type %d not implemented.\n", itemid.type); return; } - + p_vcdplayer->play_item = itemid; vcdplayer_update_nav(p_vcdplayer); @@ -613,7 +613,7 @@ vcdplayer_play_single_item(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) /* Get the next play-item in the list given in the LIDs. Note play-item here refers to list of play-items for a single LID It shouldn't be - confused with a user's list of favorite things to play or the + confused with a user's list of favorite things to play or the "next" field of a LID which moves us to a different LID. */ static bool @@ -626,9 +626,9 @@ _vcdplayer_inc_play_item(vcdplayer_t *p_vcdplayer) if ( NULL == p_vcdplayer || NULL == p_vcdplayer->pxd.pld ) return false; noi = vcdinf_pld_get_noi(p_vcdplayer->pxd.pld); - + if ( noi <= 0 ) return false; - + /* Handle delays like autowait or wait here? */ p_vcdplayer->pdi++; @@ -636,12 +636,12 @@ _vcdplayer_inc_play_item(vcdplayer_t *p_vcdplayer) if ( p_vcdplayer->pdi < 0 || p_vcdplayer->pdi >= noi ) return false; else { - uint16_t trans_itemid_num=vcdinf_pld_get_play_item(p_vcdplayer->pxd.pld, + uint16_t trans_itemid_num=vcdinf_pld_get_play_item(p_vcdplayer->pxd.pld, p_vcdplayer->pdi); vcdinfo_itemid_t trans_itemid; if (VCDINFO_INVALID_ITEMID == trans_itemid_num) return false; - + vcdinfo_classify_itemid(trans_itemid_num, &trans_itemid); dbg_print(INPUT_DBG_PBC, " play-item[%d]: %s\n", p_vcdplayer->pdi, vcdinfo_pin2str (trans_itemid_num)); @@ -653,7 +653,7 @@ _vcdplayer_inc_play_item(vcdplayer_t *p_vcdplayer) void vcdplayer_play(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) { - dbg_print(INPUT_DBG_CALL, "called itemid.num: %d itemid.type: %d\n", + dbg_print(INPUT_DBG_CALL, "called itemid.num: %d itemid.type: %d\n", itemid.num, itemid.type); if (!vcdplayer_pbc_is_on(p_vcdplayer)) { @@ -667,9 +667,9 @@ vcdplayer_play(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) p_vcdplayer->i_lid = itemid.num; vcdinfo_lid_get_pxd(p_vcdinfo, &(p_vcdplayer->pxd), itemid.num); - + switch (p_vcdplayer->pxd.descriptor_type) { - + case PSD_TYPE_SELECTION_LIST: case PSD_TYPE_EXT_SELECTION_LIST: { vcdinfo_itemid_t trans_itemid; @@ -683,29 +683,29 @@ vcdplayer_play(vcdplayer_t *p_vcdplayer, vcdinfo_itemid_t itemid) vcdplayer_play_single_item(p_vcdplayer, trans_itemid); break; } - + case PSD_TYPE_PLAY_LIST: { if (p_vcdplayer->pxd.pld == NULL) return; p_vcdplayer->pdi = -1; _vcdplayer_inc_play_item(p_vcdplayer); break; } - + case PSD_TYPE_END_LIST: case PSD_TYPE_COMMAND_LIST: - + default: ; } } } -/* - Set's start origin and size for subsequent seeks. +/* + Set's start origin and size for subsequent seeks. input: p_vcdplayer->i_lsn, p_vcdplayer->play_item changed: p_vcdplayer->origin_lsn, p_vcdplayer->end_lsn */ -static void +static void _vcdplayer_set_origin(vcdplayer_t *p_vcdplayer) { size_t size = _vcdplayer_get_item_size(p_vcdplayer, p_vcdplayer->play_item); @@ -713,7 +713,7 @@ _vcdplayer_set_origin(vcdplayer_t *p_vcdplayer) p_vcdplayer->end_lsn = p_vcdplayer->i_lsn + size; p_vcdplayer->origin_lsn = p_vcdplayer->i_lsn; - dbg_print((INPUT_DBG_CALL|INPUT_DBG_LSN), "end LSN: %u\n", + dbg_print((INPUT_DBG_CALL|INPUT_DBG_LSN), "end LSN: %u\n", p_vcdplayer->end_lsn); } @@ -730,29 +730,29 @@ vcdplayer_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) /* We are in playback control. */ vcdinfo_itemid_t itemid; - /* The end of an entry is really the end of the associated + /* The end of an entry is really the end of the associated sequence (or track). */ - - if ( (VCDINFO_ITEM_TYPE_ENTRY == p_vcdplayer->play_item.type) && + + if ( (VCDINFO_ITEM_TYPE_ENTRY == p_vcdplayer->play_item.type) && (p_vcdplayer->i_lsn < p_vcdplayer->track_end_lsn) ) { /* Set up to just continue to the next entry */ p_vcdplayer->play_item.num++; - dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), + dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "continuing into next entry: %u\n", p_vcdplayer->play_item.num); vcdplayer_play_single_item(p_vcdplayer, p_vcdplayer->play_item); p_vcdplayer->update_title(); return READ_BLOCK; } - + switch (p_vcdplayer->pxd.descriptor_type) { case PSD_TYPE_END_LIST: return READ_END; break; case PSD_TYPE_PLAY_LIST: { int wait_time = vcdinf_get_wait_time(p_vcdplayer->pxd.pld); - + dbg_print(INPUT_DBG_PBC, "playlist wait_time: %d\n", wait_time); - + if (_vcdplayer_inc_play_item(p_vcdplayer)) return READ_BLOCK; @@ -773,18 +773,18 @@ vcdplayer_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) int wait_time = vcdinf_get_timeout_time(p_vcdplayer->pxd.psd); uint16_t timeout_offs = vcdinf_get_timeout_offset(p_vcdplayer->pxd.psd); uint16_t max_loop = vcdinf_get_loop_count(p_vcdplayer->pxd.psd); - vcdinfo_offset_t *offset_timeout_LID = + vcdinfo_offset_t *offset_timeout_LID = vcdinfo_get_offset_t(p_vcdplayer->vcd, timeout_offs); - - dbg_print(INPUT_DBG_PBC, "wait_time: %d, looped: %d, max_loop %d\n", + + dbg_print(INPUT_DBG_PBC, "wait_time: %d, looped: %d, max_loop %d\n", wait_time, p_vcdplayer->i_loop, max_loop); - + /* Set caller to handle wait time given. */ if (STILL_READING == p_vcdplayer->i_still && wait_time > 0) { p_vcdplayer->i_still = wait_time; return READ_STILL_FRAME; } - + /* Handle any looping given. */ if ( max_loop == 0 || p_vcdplayer->i_loop < max_loop ) { p_vcdplayer->i_loop++; @@ -793,10 +793,10 @@ vcdplayer_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) if (p_vcdplayer->i_still) p_vcdplayer->force_redisplay(); return READ_BLOCK; } - + /* Looping finished and wait finished. Move to timeout entry or next entry, or handle still. */ - + if (NULL != offset_timeout_LID) { /* Handle timeout_LID */ itemid.num = offset_timeout_LID->lid; @@ -811,12 +811,12 @@ vcdplayer_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) unsigned int bsn=vcdinf_get_bsn(p_vcdplayer->pxd.psd); int rand_selection=bsn + (int) ((i_selections+0.0)*rand()/(RAND_MAX+1.0)); - lid_t rand_lid=vcdinfo_selection_get_lid(p_vcdplayer->vcd, + lid_t rand_lid=vcdinfo_selection_get_lid(p_vcdplayer->vcd, p_vcdplayer->i_lid, rand_selection); itemid.num = rand_lid; itemid.type = VCDINFO_ITEM_TYPE_LID; - dbg_print(INPUT_DBG_PBC, "random selection %d, lid: %d\n", + dbg_print(INPUT_DBG_PBC, "random selection %d, lid: %d\n", rand_selection - bsn, rand_lid); vcdplayer_play(p_vcdplayer, itemid); return READ_BLOCK; @@ -825,19 +825,19 @@ vcdplayer_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) RETURN_NULL_STILL ; } } - + break; } - case VCDINFO_ITEM_TYPE_NOTFOUND: + case VCDINFO_ITEM_TYPE_NOTFOUND: LOG_ERR(p_vcdplayer, "NOTFOUND in PBC -- not supposed to happen\n"); break; - case VCDINFO_ITEM_TYPE_SPAREID2: + case VCDINFO_ITEM_TYPE_SPAREID2: LOG_ERR(p_vcdplayer, "SPAREID2 in PBC -- not supposed to happen\n"); break; - case VCDINFO_ITEM_TYPE_LID: + case VCDINFO_ITEM_TYPE_LID: LOG_ERR(p_vcdplayer, "LID in PBC -- not supposed to happen\n"); break; - + default: ; } @@ -848,8 +848,8 @@ vcdplayer_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) return READ_BLOCK; } -/* Handles navigation when NOT in PBC reaching the end of a play item. - The navigations rules here we are sort of made up, but the intent +/* Handles navigation when NOT in PBC reaching the end of a play item. + The navigations rules here we are sort of made up, but the intent is to do something that's probably right or helpful. */ static vcdplayer_read_status_t @@ -859,22 +859,22 @@ vcdplayer_non_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) switch (p_vcdplayer->play_item.type) { case VCDINFO_ITEM_TYPE_TRACK: case VCDINFO_ITEM_TYPE_ENTRY: - if (p_vcdplayer->autoadvance + if (p_vcdplayer->autoadvance && p_vcdplayer->next_entry != VCDINFO_INVALID_ENTRY) { p_vcdplayer->play_item.num=p_vcdplayer->next_entry; vcdplayer_update_nav(p_vcdplayer); - } else + } else return READ_END; break; - case VCDINFO_ITEM_TYPE_SPAREID2: + case VCDINFO_ITEM_TYPE_SPAREID2: RETURN_NULL_STILL ; - case VCDINFO_ITEM_TYPE_NOTFOUND: + case VCDINFO_ITEM_TYPE_NOTFOUND: LOG_ERR(p_vcdplayer, "NOTFOUND outside PBC -- not supposed to happen\n"); return READ_END; break; - case VCDINFO_ITEM_TYPE_LID: + case VCDINFO_ITEM_TYPE_LID: LOG_ERR(p_vcdplayer, "LID outside PBC -- not supposed to happen\n"); return READ_END; break; @@ -890,26 +890,26 @@ vcdplayer_non_pbc_nav (vcdplayer_t *p_vcdplayer, uint8_t *p_buf) /*! Read i_len bytes into buf and return the status back. - This routine is a bit complicated because on reaching the end of - a track or entry we may automatically advance to the item, or + This routine is a bit complicated because on reaching the end of + a track or entry we may automatically advance to the item, or interpret the next item in the playback-control list. */ vcdplayer_read_status_t -vcdplayer_read (vcdplayer_t *p_vcdplayer, uint8_t *p_buf, - const off_t i_len) +vcdplayer_read (vcdplayer_t *p_vcdplayer, uint8_t *p_buf, + const off_t i_len) { if ( p_vcdplayer->i_lsn >= p_vcdplayer->end_lsn ) { vcdplayer_read_status_t read_status; - + /* We've run off of the end of this entry. Do we continue or stop? */ - dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), - "end reached, cur: %u, end: %u\n", + dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), + "end reached, cur: %u, end: %u\n", p_vcdplayer->i_lsn, p_vcdplayer->end_lsn); handle_item_continuation: - read_status = vcdplayer_pbc_is_on(p_vcdplayer) - ? vcdplayer_pbc_nav(p_vcdplayer, p_buf) + read_status = vcdplayer_pbc_is_on(p_vcdplayer) + ? vcdplayer_pbc_nav(p_vcdplayer, p_buf) : vcdplayer_non_pbc_nav(p_vcdplayer, p_buf); if (READ_STILL_FRAME == read_status) { @@ -919,11 +919,11 @@ vcdplayer_read (vcdplayer_t *p_vcdplayer, uint8_t *p_buf, if (READ_BLOCK != read_status) return read_status; } - /* Read the next block. - + /* Read the next block. + Important note: we probably speed things up by removing "data" and the memcpy to it by extending vcd_image_source_read_mode2 - to allow a mode to do what's below in addition to its + to allow a mode to do what's below in addition to its "raw" and "block" mode. It also would probably improve the modularity a little bit as well. */ @@ -938,7 +938,7 @@ vcdplayer_read (vcdplayer_t *p_vcdplayer, uint8_t *p_buf, vcdsector_t vcd_sector; do { - if (cdio_read_mode2_sector(p_img, &vcd_sector, + if (cdio_read_mode2_sector(p_img, &vcd_sector, p_vcdplayer->i_lsn, true)!=0) { dbg_print(INPUT_DBG_LSN, "read error\n"); p_vcdplayer->i_lsn++; @@ -948,36 +948,36 @@ vcdplayer_read (vcdplayer_t *p_vcdplayer, uint8_t *p_buf, if ( p_vcdplayer->i_lsn >= p_vcdplayer->end_lsn ) { /* We've run off of the end of this entry. Do we continue or stop? */ - dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), - "end reached in reading, cur: %u, end: %u\n", + dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), + "end reached in reading, cur: %u, end: %u\n", p_vcdplayer->i_lsn, p_vcdplayer->end_lsn); break; } - + /* Check header ID for a padding sector and simply discard these. It is alleged that VCD's put these in to keep the bitrate constant. */ } while((vcd_sector.subheader[2]&~0x01)==0x60); - if ( p_vcdplayer->i_lsn >= p_vcdplayer->end_lsn ) + if ( p_vcdplayer->i_lsn >= p_vcdplayer->end_lsn ) /* We've run off of the end of this entry. Do we continue or stop? */ goto handle_item_continuation; - + memcpy (p_buf, vcd_sector.data, M2F2_SECTOR_SIZE); return READ_BLOCK; } } /* Do if needed */ -void +void vcdplayer_send_button_update(vcdplayer_t *p_vcdplayer, const int mode) { /* dbg_print(INPUT_DBG_CALL, "Called\n"); */ return; } -/* +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/input/vcd/vcdplayer.h b/src/input/vcd/vcdplayer.h index 868ca32e4..8a51ced7b 100644 --- a/src/input/vcd/vcdplayer.h +++ b/src/input/vcd/vcdplayer.h @@ -1,22 +1,22 @@ -/* +/* $Id: vcdplayer.h,v 1.12 2006/06/10 17:38:47 dgp85 Exp $ Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - + */ #ifndef _VCDPLAYER_H_ @@ -70,7 +70,7 @@ extern unsigned long int vcdplayer_debug; if (vcdplayer_debug & mask) \ fprintf(stderr, "%s: "s, __func__ , ##args) #else -#define dbg_print(mask, s, args...) +#define dbg_print(mask, s, args...) #endif /*------------------------------------------------------------------ @@ -83,14 +83,14 @@ extern unsigned long int vcdplayer_debug; typedef enum { VCDPLAYER_SLIDER_LENGTH_AUTO, VCDPLAYER_SLIDER_LENGTH_TRACK, - VCDPLAYER_SLIDER_LENGTH_ENTRY, + VCDPLAYER_SLIDER_LENGTH_ENTRY, } vcdplayer_slider_length_t; typedef enum { VCDPLAYER_AUTOPLAY_TRACK = VCDINFO_ITEM_TYPE_TRACK, VCDPLAYER_AUTOPLAY_ENTRY = VCDINFO_ITEM_TYPE_ENTRY, VCDPLAYER_AUTOPLAY_SEGMENT = VCDINFO_ITEM_TYPE_SEGMENT, - VCDPLAYER_AUTOPLAY_PBC = VCDINFO_ITEM_TYPE_LID, + VCDPLAYER_AUTOPLAY_PBC = VCDINFO_ITEM_TYPE_LID, } vcdplayer_autoplay_t; typedef struct { @@ -104,7 +104,7 @@ typedef int (*generic_fn)(); 2,000 seconds (33.33 minutes). We'll use a number larger than this to signal indefinite wait. */ -#define STILL_INDEFINITE_WAIT 3000 +#define STILL_INDEFINITE_WAIT 3000 /* Value when we have yet to finish reading blocks of a frame. */ #define STILL_READING -5 @@ -114,7 +114,7 @@ typedef struct vcdplayer_s { vcdinfo_obj_t *vcd; /* Pointer to libvcd structures. */ /*------------------------------------------------------------------ - User-settable options + User-settable options --------------------------------------------------------------*/ unsigned int i_debug; /* Debugging mask */ unsigned int i_blocks_per_read; /* number of blocks per read */ @@ -122,7 +122,7 @@ typedef struct vcdplayer_s { /*------------------------------------------------------------------ Callback functions - players and higher-level routines can use this to customize their behavior when using this player-independent - code. + code. ---------------------------------------------------------------------*/ generic_fn log_msg; /* function to log a message in the player */ @@ -130,36 +130,36 @@ typedef struct vcdplayer_s { /* Function to flush any audio or video buffers */ - void (*flush_buffers) (void); + void (*flush_buffers) (void); /* Function to force a redisplay. */ - void (*force_redisplay) (void); + void (*force_redisplay) (void); /* Function to set aspect ratio. */ - void (*set_aspect_ratio) (int); + void (*set_aspect_ratio) (int); /* Function to update title of selection. */ void (*update_title) (); /*------------------------------------------------------------- - Playback control fields + Playback control fields --------------------------------------------------------------*/ - int i_still; /* 0 if not in still, + int i_still; /* 0 if not in still, STILL_INDEFINITE_WAIT if indefinite time, STILL_READING if don't have full picture, else number of seconds yet to wait */ int i_lid; /* LID that play item is in. Implies PBC is. - on. VCDPLAYER_BAD_ENTRY if not none or + on. VCDPLAYER_BAD_ENTRY if not none or not in PBC */ PsdListDescriptor pxd; /* If PBC is on, the relevant PSD/PLD */ - int pdi; /* current pld index of pxd. -1 if + int pdi; /* current pld index of pxd. -1 if no index*/ vcdinfo_itemid_t play_item; /* play-item, VCDPLAYER_BAD_ENTRY if none */ vcdinfo_itemid_t loop_item; /* Where do we loop back to? Meaningful only in a selection list */ - int i_loop; /* # of times play-item has been played. + int i_loop; /* # of times play-item has been played. Meaningful only in a selection list. */ track_t i_track; /* current track number */ @@ -167,16 +167,16 @@ typedef struct vcdplayer_s { /*----------------------------------- Navigation and location fields ------------------------------------*/ - uint16_t next_entry; /* where to go if next is pressed, + uint16_t next_entry; /* where to go if next is pressed, VCDPLAYER_BAD_ENTRY if none */ - uint16_t prev_entry; /* where to fo if prev is pressed, + uint16_t prev_entry; /* where to fo if prev is pressed, VCDPLAYER_BAD_ENTRY if none */ uint16_t return_entry; /* Entry index to use if return is pressed */ uint16_t default_entry; /* Default selection entry. */ lsn_t i_lsn; /* LSN of where we are right now */ lsn_t end_lsn; /* LSN of end of current entry/segment/track. - entry/segment/track. This block can be read + entry/segment/track. This block can be read (and is not one after the "end"). */ lsn_t origin_lsn; /* LSN of start of seek/slider position. */ @@ -192,8 +192,8 @@ typedef struct vcdplayer_s { char *psz_source; /* VCD device currently open */ bool b_opened; /* true if initialized */ vcd_type_t vcd_format; /* VCD 2.0, 1,1, SVCD, HQVCD? */ - - track_t i_tracks; /* # of playable MPEG tracks. This is + + track_t i_tracks; /* # of playable MPEG tracks. This is generally one less than the number of CD tracks as the first CD track is an ISO-9660 track and is not @@ -213,20 +213,20 @@ typedef struct vcdplayer_s { ---------------------------------------------------------------*/ /* What type to use on autoplay */ - vcdplayer_autoplay_t default_autoplay; + vcdplayer_autoplay_t default_autoplay; - /* When hitting end of entry or track do we advance automatically + /* When hitting end of entry or track do we advance automatically to next entry/track or stop? Only valid if PBC is off. */ - bool autoadvance; + bool autoadvance; - /* Do next/prev wrap around? Only valid if PBC is off. */ - bool wrap_next_prev; + /* Do next/prev wrap around? Only valid if PBC is off. */ + bool wrap_next_prev; /* Show and be able to select rejected LIDs? */ - bool show_rejected; + bool show_rejected; /* Whether GUI slider is track size or entry size. */ - vcdplayer_slider_length_t slider_length; + vcdplayer_slider_length_t slider_length; } vcdplayer_t; @@ -240,7 +240,7 @@ typedef enum { /* ---------------------------------------------------------------------- - Function Prototypes + Function Prototypes -----------------------------------------------------------------------*/ /*! @@ -250,17 +250,17 @@ bool vcdplayer_pbc_is_on(const vcdplayer_t *p_vcdplayer); /*! Take a format string and expand escape sequences, that is sequences that - begin with %, with information from the current VCD. + begin with %, with information from the current VCD. The expanded string is returned. Here is a list of escape sequences: - %A : The album information + %A : The album information %C : The VCD volume count - the number of CD's in the collection. - %c : The VCD volume num - the number of the CD in the collection. + %c : The VCD volume num - the number of the CD in the collection. %F : The VCD Format, e.g. VCD 1.0, VCD 1.1, VCD 2.0, or SVCD %I : The current entry/segment/playback type, e.g. ENTRY, TRACK, SEGMENT... %L : The playlist ID prefixed with " LID" if it exists %N : The current number of the above - a decimal number - %P : The publisher ID + %P : The publisher ID %p : The preparer ID %V : The volume set ID %v : The volume ID @@ -271,13 +271,13 @@ char * vcdplayer_format_str(vcdplayer_t *p_vcdplayer, const char format_str[]); /*! - Update next/prev/return/default navigation buttons. + Update next/prev/return/default navigation buttons. */ void vcdplayer_update_nav(vcdplayer_t *p_vcdplayer); /*! Update the player title text. */ -void +void vcdplayer_update_title_display(vcdplayer_t *p_vcdplayer); /*! Play title part. If part is -1, use the first title. */ @@ -294,22 +294,22 @@ vcdplayer_read_status_t vcdplayer_read (vcdplayer_t *p_vcdplayer, uint8_t *p_buf, const off_t nlen); /*! - seek position, return new position + seek position, return new position if seeking failed, -1 is returned */ -off_t +off_t vcdplayer_seek (vcdplayer_t *p_vcdplayer, off_t offset, int origin); /*! Get the number of tracks or titles of the VCD. The result is stored in "titles". */ -void +void vcdplayer_send_button_update(vcdplayer_t *p_vcdplayer, int mode); #endif /* _VCDPLAYER_H_ */ -/* +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/input/vcd/xine-extra.c b/src/input/vcd/xine-extra.c index e3b6da912..d211f46a4 100644 --- a/src/input/vcd/xine-extra.c +++ b/src/input/vcd/xine-extra.c @@ -1,23 +1,23 @@ -/* - +/* + Copyright (C) 2002 Rocky Bernstein <rocky@panix.com> - + Program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - + These are routines that probably should be in xine, but for whatever - reason aren't - yet. + reason aren't - yet. */ #ifdef HAVE_CONFIG_H @@ -42,7 +42,7 @@ static xine_t *my_xine = NULL; In short this writes a message to buffer 'buf' and to stdout. */ -void +void xine_vlog_msg(xine_t *this, int buf, const char *format, va_list args) { va_list copy; @@ -58,7 +58,7 @@ xine_vlog_msg(xine_t *this, int buf, const char *format, va_list args) In short this writes a message to buffer 'buf' and to stderr. */ -void +void xine_vlog_err(xine_t *this, int buf, const char *format, va_list args) { va_list copy; @@ -69,7 +69,7 @@ xine_vlog_err(xine_t *this, int buf, const char *format, va_list args) /*! Call this before calling any of the xine_log_msg or xine_log_err routines. It sets up the xine buffer that will be used in error - logging. + logging. \return true if everything went okay; false is returned if logging was already initialized, in which case nothing is done. @@ -85,12 +85,12 @@ xine_log_init(xine_t *this) /*! This routine is like xine_log without any xine-specific paramenters. Before calling this routine you should have set up a xine log buffer via - xine_log_init(). + xine_log_init(). In short this writes a message to buffer 'buf' and to stdout. - \return true if everything went okay; false is there was - an error, such as logging wasn't initialized. On error, nothing is + \return true if everything went okay; false is there was + an error, such as logging wasn't initialized. On error, nothing is logged. */ bool @@ -107,12 +107,12 @@ xine_log_msg(const char *format, ...) /*! This routine is like xine_log without any xine-specific paramenters. Before calling this routine you should have set up a xine log buffer via - xine_log_init(). + xine_log_init(). In short this writes a message to buffer 'buf' and to stdout. - \return true if everything went okay; false is there was - an error, such as logging wasn't initialized. On error, nothing is + \return true if everything went okay; false is there was + an error, such as logging wasn't initialized. On error, nothing is logged. */ bool @@ -128,7 +128,7 @@ xine_log_err(const char *format, ...) } void -xine_free_mrls(int *num_mrls, xine_mrl_t **mrls) +xine_free_mrls(int *num_mrls, xine_mrl_t **mrls) { (*num_mrls)--; for ( ; *num_mrls >= 0; (*num_mrls)-- ) { diff --git a/src/input/vcd/xine-extra.h b/src/input/vcd/xine-extra.h index 59f562cbd..5037e68ad 100644 --- a/src/input/vcd/xine-extra.h +++ b/src/input/vcd/xine-extra.h @@ -1,23 +1,23 @@ -/* - +/* + Copyright (C) 2002 Rocky Bernstein <rocky@panix.com> - + Program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - + These are routines that probably should be in xine, but for whatever - reason aren't - yet. + reason aren't - yet. */ #ifndef XINE_EXTRA_H @@ -47,7 +47,7 @@ In short this writes a message to buffer 'buf' and to stdout. */ -void +void xine_vlog_msg(xine_t *this, int buf, const char *format, va_list args) XINE_FORMAT_PRINTF(3, 0); /*! This routine is like xine_log, except it takes a va_list instead @@ -61,7 +61,7 @@ void xine_vlog_err(xine_t *this, int buf, const char *format, va_list args) XINE /*! Call this before calling any of the xine_log_msg or xine_log_err routines. It sets up the xine buffer that will be used in error - logging. + logging. \return true if everything went okay; false is returned if logging was already initialized, in which case nothing is done. @@ -71,24 +71,24 @@ bool xine_log_init(xine_t *this); /*! This routine is like xine_log without any xine-specific paramenters. Before calling this routine you should have set up a xine log buffer via - xine_log_init(). + xine_log_init(). In short this writes a message to buffer 'buf' and to stdout. - \return true if everything went okay; false is there was - an error, such as logging wasn't initialized. On error, nothing is + \return true if everything went okay; false is there was + an error, such as logging wasn't initialized. On error, nothing is logged. */ bool xine_log_msg(const char *format, ...) XINE_FORMAT_PRINTF(1, 2); /*! This routine is like xine_log without any xine-specific paramenters. Before calling this routine you should have set up a xine log buffer via - xine_log_init(). + xine_log_init(). In short this writes a message to buffer 'buf' and to stdout. - \return true if everything went okay; false is there was - an error, such as logging wasn't initialized. On error, nothing is + \return true if everything went okay; false is there was + an error, such as logging wasn't initialized. On error, nothing is logged. */ bool xine_log_err(const char *format, ...) XINE_FORMAT_PRINTF(1, 2); diff --git a/src/input/vcd/xineplug_inp_vcd.c b/src/input/vcd/xineplug_inp_vcd.c index 8b12ca459..acd4775f4 100644 --- a/src/input/vcd/xineplug_inp_vcd.c +++ b/src/input/vcd/xineplug_inp_vcd.c @@ -1,23 +1,23 @@ /* - + Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ -/* +/* These are plugin routines called by the xine engine. See Chapter 4. Extending xine's input http://www.xine-project.org/hackersguide#INPUT @@ -83,8 +83,8 @@ #define BUF_DEMUX_BLOCK 0x05000000 #endif -/* - Convert an autoplay enumeration into an vcdinfo itemtype enumeration. +/* + Convert an autoplay enumeration into an vcdinfo itemtype enumeration. See definitions in vcdplayer.h and vcdinfo.h to get the below correct. */ static const vcdinfo_item_enum_t autoplay2itemtype[]={ @@ -94,7 +94,7 @@ static const vcdinfo_item_enum_t autoplay2itemtype[]={ VCDINFO_ITEM_TYPE_LID /* VCDPLAYER_AUTOPLAY_PBC */ }; -typedef struct vcd_config_s +typedef struct vcd_config_s { char *title_format; /* Format string of GUI display title */ char *comment_format; /* Format string of stream comment meta */ @@ -106,7 +106,7 @@ typedef struct vcd_input_class_s { input_class_t input_class; xine_t *xine; config_values_t *config; /* Pointer to XineRC config file. */ - vcd_input_plugin_t *ip; + vcd_input_plugin_t *ip; vcd_config_t v_config; /* config stuff passed to child */ xine_mrl_t **mrls; /* list of mrl entries for medium */ @@ -114,10 +114,10 @@ typedef struct vcd_input_class_s { char *vcd_device;/* Device name to use when none specified in MRL */ /*-------------------------------------------------------------- - Media resource locator (MRL) info. + Media resource locator (MRL) info. For the below offsets, use play_item + mrl_xxx_offset to get index - into "mrls" array + into "mrls" array ---------------------------------------------------------------*/ int mrl_track_offset; /* perhaps -1 for tracks staring with 1*/ int mrl_entry_offset; /* i_tracks for entries starting with 0 */ @@ -130,10 +130,10 @@ typedef struct vcd_input_class_s { vcd_input_class_t *vcd_class; struct vcd_input_plugin_tag { - input_plugin_t input_plugin; /* input plugin interface as defined by - by player. For xine it contains a + input_plugin_t input_plugin; /* input plugin interface as defined by + by player. For xine it contains a structure of functions that need - to be implemented. + to be implemented. */ xine_stream_t *stream; xine_event_queue_t *event_queue; @@ -155,7 +155,7 @@ struct vcd_input_plugin_tag { the mouse is not in any "button" region then this has value -1. */ - bool b_mouse_in; /* True if mouse is inside a "button" + bool b_mouse_in; /* True if mouse is inside a "button" region; false otherwise */ vcdplayer_t player ; @@ -168,13 +168,13 @@ vcd_input_plugin_t my_vcd; static bool vcd_handle_events (void); static void vcd_close(vcd_input_class_t *class); #if LIBVCD_VERSION_NUM >= 23 -static void send_mouse_enter_leave_event(vcd_input_plugin_t *p_this, +static void send_mouse_enter_leave_event(vcd_input_plugin_t *p_this, bool b_mouse_in); #endif -/* - If class->vcd_device is NULL or the empty string, - Use libcdio to find a CD drive with a VCD in it. +/* + If class->vcd_device is NULL or the empty string, + Use libcdio to find a CD drive with a VCD in it. */ static bool vcd_get_default_device(vcd_input_class_t *class, bool log_msg_if_fail) @@ -184,7 +184,7 @@ vcd_get_default_device(vcd_input_class_t *class, bool log_msg_if_fail) if (NULL == class->vcd_device || strlen(class->vcd_device)==0) { char **cd_drives=NULL; - cd_drives = cdio_get_devices_with_cap(NULL, + cd_drives = cdio_get_devices_with_cap(NULL, (CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD|CDIO_FS_ANAL_VIDEOCD|CDIO_FS_UNKNOWN), true); if (NULL == cd_drives || NULL == cd_drives[0]) { @@ -201,8 +201,8 @@ vcd_get_default_device(vcd_input_class_t *class, bool log_msg_if_fail) } -static void -meta_info_assign(int field, xine_stream_t *stream, const char * info) +static void +meta_info_assign(int field, xine_stream_t *stream, const char * info) { if (NULL != info) { dbg_print(INPUT_DBG_META, "meta[%d]: %s\n", field, info); @@ -215,10 +215,10 @@ meta_info_assign(int field, xine_stream_t *stream, const char * info) /* Set stream information. */ static void -vcd_set_meta_info (vcd_input_plugin_t *xine_vcd) +vcd_set_meta_info (vcd_input_plugin_t *xine_vcd) { vcdinfo_obj_t *p_vcdinfo= xine_vcd->player.vcd; - meta_info_assign(XINE_META_INFO_ALBUM, xine_vcd->stream, + meta_info_assign(XINE_META_INFO_ALBUM, xine_vcd->stream, vcdinfo_get_album_id(p_vcdinfo)); meta_info_assign(XINE_META_INFO_ARTIST, xine_vcd->stream, vcdinfo_get_preparer_id(p_vcdinfo)); @@ -230,40 +230,40 @@ vcd_set_meta_info (vcd_input_plugin_t *xine_vcd) } static void -vcd_force_redisplay (void) +vcd_force_redisplay (void) { #if 1 my_vcd.stream->xine->clock->adjust_clock(my_vcd.stream->xine->clock, - my_vcd.stream->xine->clock->get_current_time(my_vcd.stream->xine->clock) + my_vcd.stream->xine->clock->get_current_time(my_vcd.stream->xine->clock) + 30 * 90000 ); #else /* Alternate method that causes too much disruption... */ - xine_set_param(my_vcd.stream, XINE_PARAM_VO_ASPECT_RATIO, + xine_set_param(my_vcd.stream, XINE_PARAM_VO_ASPECT_RATIO, (xine_get_param(my_vcd.stream, XINE_PARAM_VO_ASPECT_RATIO))); #endif } static void -vcd_set_aspect_ratio (int i_aspect_ratio) +vcd_set_aspect_ratio (int i_aspect_ratio) { /* Alternate method that causes too much disruption... */ xine_set_param(my_vcd.stream, XINE_PARAM_VO_ASPECT_RATIO, i_aspect_ratio); } -/*! Add another MRL to the MRL list inside "this" to be displayed. - mrl is the string name to add; size is the size of the entry in bytes. - The number of mrls in "this" is incremented. +/*! Add another MRL to the MRL list inside "this" to be displayed. + mrl is the string name to add; size is the size of the entry in bytes. + The number of mrls in "this" is incremented. */ static void -vcd_add_mrl_slot(vcd_input_class_t *this, const char *mrl, off_t size, +vcd_add_mrl_slot(vcd_input_class_t *this, const char *mrl, off_t size, unsigned int *i) { - dbg_print(INPUT_DBG_MRL, "called to add slot %d: %s, size %u\n", + dbg_print(INPUT_DBG_MRL, "called to add slot %d: %s, size %u\n", *i, mrl, (unsigned int) size); - + this->mrls[*i] = malloc(sizeof(xine_mrl_t)); if (NULL==this->mrls[*i]) { - LOG_ERR("Can't malloc %zu bytes for MRL slot %u (%s)", + LOG_ERR("Can't malloc %zu bytes for MRL slot %u (%s)", sizeof(xine_mrl_t), *i, mrl); return; } @@ -271,7 +271,7 @@ vcd_add_mrl_slot(vcd_input_class_t *this, const char *mrl, off_t size, this->mrls[*i]->origin = NULL; this->mrls[*i]->type = mrl_vcd; this->mrls[*i]->size = size * M2F2_SECTOR_SIZE; - + this->mrls[*i]->mrl = strdup(mrl); if (NULL==this->mrls[*i]->mrl) { LOG_ERR("Can't strndup %zu bytes for MRL name %s", strlen(mrl), mrl); @@ -282,9 +282,9 @@ vcd_add_mrl_slot(vcd_input_class_t *this, const char *mrl, off_t size, /*! Return the associated mrl_offset for the given type. */ -static int -vcd_get_mrl_type_offset(vcd_input_plugin_t *inp, - vcdinfo_item_enum_t type, int *size) +static int +vcd_get_mrl_type_offset(vcd_input_plugin_t *inp, + vcdinfo_item_enum_t type, int *size) { switch (type) { case VCDINFO_ITEM_TYPE_ENTRY: @@ -297,7 +297,7 @@ vcd_get_mrl_type_offset(vcd_input_plugin_t *inp, case VCDINFO_ITEM_TYPE_TRACK: *size = inp->class->mrl_entry_offset; return inp->class->mrl_track_offset; - case VCDINFO_ITEM_TYPE_LID: + case VCDINFO_ITEM_TYPE_LID: /* Play list number (LID) */ *size = (inp->player.i_lids > 0) ? 1 : 0; return inp->class->mrl_play_offset; @@ -338,10 +338,10 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) if (!vcd_get_default_device(class, true)) return false; vcd_device = class->vcd_device; } - + if (!vcdio_open(vcdplayer, vcd_device)) { /* Error should have been logged in vcdio_open. If not do the below: - LOG_ERR(vcdplayer, "%s: %s.\n", _("unable to open"), + LOG_ERR(vcdplayer, "%s: %s.\n", _("unable to open"), class->vcd_device, strerror(errno)); */ return false; @@ -359,13 +359,13 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) didn't have to possibly remove rejected LIDs from list done in the loop below. */ - class->num_mrls = vcdplayer->i_tracks + vcdplayer->i_entries + class->num_mrls = vcdplayer->i_tracks + vcdplayer->i_entries + vcdplayer->i_segments + vcdplayer->i_lids; if (!vcdplayer->show_rejected && vcdinfo_get_lot(vcdplayer->vcd)) { /* Remove rejected LIDs from count. */ for (n=0; n<vcdplayer->i_lids; n++) { - if ( vcdinf_get_lot_offset(vcdinfo_get_lot(vcdplayer->vcd), n) + if ( vcdinf_get_lot_offset(vcdinfo_get_lot(vcdplayer->vcd), n) == PSD_OFS_DISABLED ) class->num_mrls--; } @@ -381,24 +381,24 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) } /* Record MRL's for tracks */ - for (n=1; n<=vcdplayer->i_tracks; n++) { + for (n=1; n<=vcdplayer->i_tracks; n++) { memset(&mrl, 0, sizeof (mrl)); snprintf(mrl, sizeof(mrl), "%s%s@T%u", MRL_PREFIX, vcd_device, n); vcd_add_mrl_slot(class, mrl, vcdplayer->track[n-1].size, &i); } - + class->mrl_entry_offset = vcdplayer->i_tracks; class->mrl_play_offset = class->mrl_entry_offset + i_entries - 1; /* Record MRL's for entries */ if (i_entries > 0) { - for (n=0; n<i_entries; n++) { + for (n=0; n<i_entries; n++) { memset(&mrl, 0, sizeof (mrl)); snprintf(mrl, sizeof(mrl), "%s%s@E%u", MRL_PREFIX, vcd_device, n); vcd_add_mrl_slot(class, mrl, vcdplayer->entry[n].size, &i); } } - + /* Record MRL's for LID entries or selection entries*/ class->mrl_segment_offset = class->mrl_play_offset; if (vcdinfo_get_lot(vcdplayer->vcd)) { @@ -406,7 +406,7 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) uint16_t ofs = vcdinf_get_lot_offset(vcdinfo_get_lot(vcdplayer->vcd), n); if (ofs != PSD_OFS_DISABLED || vcdplayer->show_rejected) { memset(&mrl, 0, sizeof (mrl)); - snprintf(mrl, sizeof(mrl), "%s%s@P%u%s", MRL_PREFIX, vcd_device, n+1, + snprintf(mrl, sizeof(mrl), "%s%s@P%u%s", MRL_PREFIX, vcd_device, n+1, ofs == PSD_OFS_DISABLED ? "*" : ""); vcd_add_mrl_slot(class, mrl, 0, &i); class->mrl_segment_offset++; @@ -418,7 +418,7 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) { segnum_t i_segments = vcdplayer->i_segments; for (n=0; n<i_segments; n++) { - vcdinfo_video_segment_type_t segtype + vcdinfo_video_segment_type_t segtype = vcdinfo_get_video_type(p_vcdinfo, n); char c='S'; switch (segtype) { @@ -442,10 +442,10 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) vcd_add_mrl_slot(class, mrl, vcdplayer->segment[n].size, &i); } } - - dbg_print(INPUT_DBG_MRL, - "offsets are track: %d, entry: %d, play: %d seg: %d\n", - class->mrl_track_offset, class->mrl_entry_offset, + + dbg_print(INPUT_DBG_MRL, + "offsets are track: %d, entry: %d, play: %d seg: %d\n", + class->mrl_track_offset, class->mrl_entry_offset, class->mrl_play_offset, class->mrl_segment_offset); return true; @@ -453,9 +453,9 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) /*! parses a MRL which has the format - + vcd://[vcd_path][@[EPTS]?number]\*? - + Examples vcd:// - Play (navigate) default device: /dev/cdrom vcd://@ - same as above @@ -467,7 +467,7 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) vcd://dev/cdrom@E0 - Play Entry id 0 from default device vcd://@P1 - probably same as above. If there is no playback control, MRL will - get converted into vcd://@E0 + get converted into vcd://@E0 vcd://@P1* - probably same as above. vcd://@S0 - Play segment 0 from default device vcd://@3 - Play track 3 from default device @@ -475,7 +475,7 @@ vcd_build_mrl_list(vcd_input_class_t *class, char *vcd_device) vcd:///tmp/ntsc.bin@ - Play default item from /tmp/ntsc.bin vcd:///tmp/ntsc.bin/@E0 - Play entry 0 of /tmp/ntsc.bin -parameters: +parameters: mrl : mrl to parse default_vcd_device: name of device to use when none given auto_type : type of selection (entry, track, LID) when none given @@ -483,10 +483,10 @@ parameters: */ static bool -vcd_parse_mrl(/*in*/ const char *default_vcd_device, /*in*/ char *mrl, +vcd_parse_mrl(/*in*/ const char *default_vcd_device, /*in*/ char *mrl, /*out*/ char *device_str, /*out*/ vcdinfo_itemid_t *itemid, - /*in */ vcdplayer_autoplay_t auto_type, - /*out*/ bool *used_default) + /*in */ vcdplayer_autoplay_t auto_type, + /*out*/ bool *used_default) { char type_str[2]; int count; @@ -507,15 +507,15 @@ vcd_parse_mrl(/*in*/ const char *default_vcd_device, /*in*/ char *mrl, device_str[0] = '/'; device_str[1] = 0; - count = sscanf (p, "%1023[^@]@%1[EePpSsTt]%u", + count = sscanf (p, "%1023[^@]@%1[EePpSsTt]%u", device_str + 1, type_str, &num); itemid->num = num; - + switch (count) { case 1: /* Matched device, but nothing beyond that */ if (strlen(device_str)!=0 && device_str[0] != ':') { - /* See if we have old-style MRL with no type specifier. + /* See if we have old-style MRL with no type specifier. If so, we assume "track". */ count = sscanf (p, "%u", &num); itemid->num = num; @@ -534,7 +534,7 @@ vcd_parse_mrl(/*in*/ const char *default_vcd_device, /*in*/ char *mrl, _x_mrl_unescape (device_str); case 0: - case EOF: + case EOF: { /* No device/file given, so use the default device and try again. */ if (NULL == default_vcd_device) return false; @@ -543,16 +543,16 @@ vcd_parse_mrl(/*in*/ const char *default_vcd_device, /*in*/ char *mrl, count = sscanf (p, "%1[EePpSsTt]%u", type_str, &num); type_str[0] = toupper(type_str[0]); itemid->num = num; - + switch (count) { case EOF: /* Default PBC navigation. */ return true; case 0: - /* See if we have old-style MRL with no type specifier. + /* See if we have old-style MRL with no type specifier. If so, we assume "track". */ count = sscanf (p, "%u", &num); - if (1==count) { + if (1==count) { type_str[0] = 'T'; break; } @@ -568,45 +568,45 @@ vcd_parse_mrl(/*in*/ const char *default_vcd_device, /*in*/ char *mrl, /* We have some sort of track/selection/entry number */ switch (type_str[0]) { - case 'E': + case 'E': itemid->type = VCDINFO_ITEM_TYPE_ENTRY; break; - case '\0': + case '\0': /* None specified, use config value. */ itemid->type = (vcdinfo_item_enum_t) auto_type; *used_default = true; break; - case 'P': + case 'P': itemid->type = VCDINFO_ITEM_TYPE_LID; break; - case 'S': + case 'S': itemid->type = VCDINFO_ITEM_TYPE_SEGMENT; break; - case 'T': + case 'T': itemid->type = VCDINFO_ITEM_TYPE_TRACK; break; default: ; } - - if ( 0==itemid->num - && ( (VCDINFO_ITEM_TYPE_LID == itemid->type) + + if ( 0==itemid->num + && ( (VCDINFO_ITEM_TYPE_LID == itemid->type) || (VCDINFO_ITEM_TYPE_TRACK == itemid->type) ) ) itemid->num = 1; return true; } -/*! +/*! From xine plugin spec: return capabilities of input source */ -static uint32_t +static uint32_t vcd_plugin_get_capabilities (input_plugin_t *this_gen) { - uint32_t ret = - INPUT_CAP_AUDIOLANG | INPUT_CAP_BLOCK | + uint32_t ret = + INPUT_CAP_AUDIOLANG | INPUT_CAP_BLOCK | INPUT_CAP_CHAPTERS | INPUT_CAP_PREVIEW | (my_vcd.player.i_still ? 0: INPUT_CAP_SEEKABLE) | INPUT_CAP_SPULANG; @@ -618,14 +618,14 @@ vcd_plugin_get_capabilities (input_plugin_t *this_gen) # if FINISHED /* If needed, will fill out later... */ -static void +static void vcd_read_ahead_cb(void *this_gen, xine_cfg_entry_t *entry) { return; } #endif -static void +static void vcd_flush_buffers(void) { _x_demux_flush_engine(my_vcd.stream); @@ -636,11 +636,11 @@ vcd_flush_buffers(void) read nlen bytes, return number of bytes read. */ -static off_t +static off_t vcd_plugin_read (input_plugin_t *this_gen, char *buf, const off_t nlen) { - dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), + dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "Called with nlen %u\n", (unsigned int) nlen); /* FIXME: Tricking the demux_mpeg_block plugin */ @@ -652,7 +652,7 @@ vcd_plugin_read (input_plugin_t *this_gen, char *buf, const off_t nlen) } /* Allocate and return a no-op buffer. This signals the outside - to do nothing, but in contrast to returning NULL, it doesn't + to do nothing, but in contrast to returning NULL, it doesn't mean the stream has ended. We use this say for still frames. */ #define RETURN_NOOP_BUF \ @@ -677,8 +677,8 @@ vcd_plugin_read (input_plugin_t *this_gen, char *buf, const off_t nlen) function */ static buf_element_t * -vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, - const off_t i_len) +vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, + const off_t i_len) { vcd_input_plugin_t *vcd_input_plugin= (vcd_input_plugin_t *) this_gen; vcdplayer_t *p_vcdplayer = &my_vcd.player; @@ -718,7 +718,7 @@ vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, SLEEP_AND_HANDLE_EVENTS; } } - + read_block: switch (vcdplayer_read(p_vcdplayer, data, i_len)) { @@ -728,37 +728,37 @@ vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, case READ_ERROR: /* Some sort of error. */ return NULL; - case READ_STILL_FRAME: + case READ_STILL_FRAME: { dbg_print(INPUT_DBG_STILL, "Handled still event wait time %u\n", p_vcdplayer->i_still); vcd_input_plugin->pause_end_time = time(NULL) + p_vcdplayer->i_still; RETURN_NOOP_BUF; } - + default: case READ_BLOCK: /* Read buffer */ p_buf = fifo->buffer_pool_alloc (fifo); p_buf->type = BUF_DEMUX_BLOCK; } - + p_buf->content = p_buf->mem; if (STILL_READING == p_vcdplayer->i_still && 0 == my_vcd.i_old_still) { - my_vcd.i_old_deinterlace = xine_get_param(my_vcd.stream, + my_vcd.i_old_deinterlace = xine_get_param(my_vcd.stream, XINE_PARAM_VO_DEINTERLACE); xine_set_param(my_vcd.stream, XINE_PARAM_VO_DEINTERLACE, 0); - dbg_print(INPUT_DBG_STILL, "going into still, saving deinterlace %d\n", + dbg_print(INPUT_DBG_STILL, "going into still, saving deinterlace %d\n", my_vcd.i_old_deinterlace); } else if (0 == p_vcdplayer->i_still && 0 != my_vcd.i_old_still) { - dbg_print(INPUT_DBG_STILL, + dbg_print(INPUT_DBG_STILL, "going out of still, restoring deinterlace\n"); xine_set_param(my_vcd.stream, XINE_PARAM_VO_DEINTERLACE, my_vcd.i_old_deinterlace); } my_vcd.i_old_still = p_vcdplayer->i_still; - + /* Ideally this should probably be i_len. */ memcpy (p_buf->mem, data, M2F2_SECTOR_SIZE); @@ -768,12 +768,12 @@ vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, /*! From xine plugin spec: - seek position, return new position + seek position, return new position if seeking failed, -1 is returned */ -static off_t -vcd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) +static off_t +vcd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { return vcdio_seek (&my_vcd.player, offset, origin); } @@ -792,7 +792,7 @@ static off_t old_get_length = 0; static vcdplayer_slider_length_t old_slider_length; /* This routine is called a bit. Make reasonably fast. */ -static off_t +static off_t vcd_plugin_get_length (input_plugin_t *this_gen) { vcd_input_plugin_t *ip= (vcd_input_plugin_t *) this_gen; @@ -801,7 +801,7 @@ vcd_plugin_get_length (input_plugin_t *this_gen) { int n = vcdplayer->play_item.num; if (vcdplayer->play_item.num == old_play_item.num - && vcdplayer->play_item.type == old_play_item.type + && vcdplayer->play_item.type == old_play_item.type && vcdplayer->slider_length == old_slider_length) return old_get_length; @@ -833,7 +833,7 @@ vcd_plugin_get_length (input_plugin_t *this_gen) { /* This is the only situation where the size of the current play item is not static. It depends what the current play-item is. */ - old_get_length = (vcdplayer->end_lsn - vcdplayer->origin_lsn) * + old_get_length = (vcdplayer->end_lsn - vcdplayer->origin_lsn) * M2F2_SECTOR_SIZE; return old_get_length; break; @@ -843,11 +843,11 @@ vcd_plugin_get_length (input_plugin_t *this_gen) { /* FIXME? */ return -1; } - + if (n >= 0 && n < ip->class->num_mrls) { old_get_length = ip->class->mrls[n]->size; - dbg_print(INPUT_DBG_MRL, "item: %u, slot %u, size %ld\n", - vcdplayer->play_item.num, + dbg_print(INPUT_DBG_MRL, "item: %u, slot %u, size %ld\n", + vcdplayer->play_item.num, (unsigned int) n, (long int) old_get_length); } return old_get_length; @@ -858,7 +858,7 @@ vcd_plugin_get_length (input_plugin_t *this_gen) { * get current position in stream. * */ -static off_t +static off_t vcd_plugin_get_current_pos (input_plugin_t *this_gen){ // trace_print("Called\n"); return (vcd_plugin_seek (this_gen, 0, SEEK_CUR)); @@ -869,7 +869,7 @@ vcd_plugin_get_current_pos (input_plugin_t *this_gen){ * From xine plugin spec: * return block size of input source (if supported, 0 otherwise) */ -static uint32_t +static uint32_t vcd_plugin_get_blocksize (input_plugin_t *this_gen) { dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n"); @@ -885,7 +885,7 @@ vcd_plugin_get_blocksize (input_plugin_t *this_gen) { */ static xine_mrl_t ** -vcd_class_get_dir (input_class_t *this_gen, const char *filename, +vcd_class_get_dir (input_class_t *this_gen, const char *filename, int *num_files) { char intended_vcd_device[MAX_DEVICE_LEN+1]= { '\0', }; @@ -897,7 +897,7 @@ vcd_class_get_dir (input_class_t *this_gen, const char *filename, bool used_default; if (filename == NULL) { - dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), + dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called with NULL\n"); if ( class->mrls != NULL && NULL != class->mrls[0] ) goto have_mrls; @@ -906,12 +906,12 @@ vcd_class_get_dir (input_class_t *this_gen, const char *filename, } } else { char *mrl = strdup(filename); - dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), + dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called with %s\n", filename); if (!vcd_get_default_device(class, true)) goto no_mrls; - if (!vcd_parse_mrl(class->vcd_device, mrl, - intended_vcd_device, &itemid, - vcdplayer->default_autoplay, &used_default)) { + if (!vcd_parse_mrl(class->vcd_device, mrl, + intended_vcd_device, &itemid, + vcdplayer->default_autoplay, &used_default)) { free (mrl); goto no_mrls; } @@ -923,17 +923,17 @@ vcd_class_get_dir (input_class_t *this_gen, const char *filename, return class->mrls; no_mrls: - *num_files = 0; - return NULL; + *num_files = 0; + return NULL; } #define FREE_AND_NULL(ptr) if (NULL != ptr) free(ptr); ptr = NULL; static void -vcd_close(vcd_input_class_t *class) +vcd_close(vcd_input_class_t *class) { xine_free_mrls(&(class->num_mrls), class->mrls); - FREE_AND_NULL(my_vcd.mrl); + FREE_AND_NULL(my_vcd.mrl); if (my_vcd.player.b_opened) vcdio_close(&my_vcd.player); } @@ -945,15 +945,15 @@ vcd_close(vcd_input_class_t *class) * * returns 0 for temporary failures */ -static int -vcd_class_eject_media (input_class_t *this_gen) +static int +vcd_class_eject_media (input_class_t *this_gen) { int ret; CdIo_t *cdio=vcdinfo_get_cd_image(my_vcd.player.vcd); - + dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n"); if (NULL == cdio) return 0; - + ret = cdio_eject_media(&cdio); if ((ret == 0) || (ret == 2)) { if (my_vcd.player.b_opened) @@ -966,8 +966,8 @@ vcd_class_eject_media (input_class_t *this_gen) * From spec: * return current MRL */ -static const char * -vcd_plugin_get_mrl (input_plugin_t *this_gen) +static const char * +vcd_plugin_get_mrl (input_plugin_t *this_gen) { vcd_input_plugin_t *t = (vcd_input_plugin_t *) this_gen; vcdplayer_t *vcdplayer = &my_vcd.player; @@ -985,13 +985,13 @@ vcd_plugin_get_mrl (input_plugin_t *this_gen) if (-2 == offset) { /* Bad type. */ - LOG_ERR("%s %d", _("Invalid current entry type"), + LOG_ERR("%s %d", _("Invalid current entry type"), vcdplayer->play_item.type); return ""; } else { n += offset; if (n < t->class->num_mrls) { - dbg_print(INPUT_DBG_CALL, "Called, returning %s\n", + dbg_print(INPUT_DBG_CALL, "Called, returning %s\n", t->class->mrls[n]->mrl); return t->class->mrls[n]->mrl; } else { @@ -1000,12 +1000,12 @@ vcd_plugin_get_mrl (input_plugin_t *this_gen) } } -/* +/* Handle all queued keyboard/mouse events. Return TRUE if this causes a change in the play item. */ static bool -vcd_handle_events (void) +vcd_handle_events (void) { vcdplayer_t *p_vcdplayer = &my_vcd.player; xine_event_t *p_event; @@ -1013,7 +1013,7 @@ vcd_handle_events (void) /* What you add to the last input number entry. It accumulates all of the 10_ADD keypresses */ - static unsigned int number_addend = 0; + static unsigned int number_addend = 0; while ((p_event = xine_event_get(my_vcd.event_queue))) { @@ -1023,14 +1023,14 @@ vcd_handle_events (void) switch(p_event->type) { case XINE_EVENT_INPUT_NUMBER_10_ADD: - number_addend += 10; - dbg_print(INPUT_DBG_EVENT, "10 added to number. Is now: %d\n", + number_addend += 10; + dbg_print(INPUT_DBG_EVENT, "10 added to number. Is now: %d\n", number_addend); break; /* The method used below is oblivious to XINE_EVENT_INPUT encodings - In particular, it does not assume XINE_EVENT_INPUT_NUMBE_9 = - XINE_EVENT_INPUT_NUMBER_0 + 9. + In particular, it does not assume XINE_EVENT_INPUT_NUMBE_9 = + XINE_EVENT_INPUT_NUMBER_0 + 9. */ case XINE_EVENT_INPUT_NUMBER_9: digit_entered++; @@ -1054,7 +1054,7 @@ vcd_handle_events (void) { number_addend *= 10; number_addend += digit_entered; - dbg_print(INPUT_DBG_EVENT, + dbg_print(INPUT_DBG_EVENT, "digit added number is now: %d\n", number_addend); break; } @@ -1063,65 +1063,65 @@ vcd_handle_events (void) vcdplayer_debug = number_addend; number_addend = 0; break; - case XINE_EVENT_INPUT_MENU1: + case XINE_EVENT_INPUT_MENU1: case XINE_EVENT_INPUT_MENU2: - case XINE_EVENT_INPUT_NEXT: + case XINE_EVENT_INPUT_NEXT: case XINE_EVENT_INPUT_PREVIOUS: { int num = number_addend; vcdinfo_itemid_t itemid; - + number_addend = 0; - + /* If no number was given it's really the same as 1, not 0. */ if (num == 0) num++; - - dbg_print(INPUT_DBG_EVENT, - "RETURN/NEXT/PREV/DEFAULT (%d) iteration count %d\n", + + dbg_print(INPUT_DBG_EVENT, + "RETURN/NEXT/PREV/DEFAULT (%d) iteration count %d\n", p_event->type, num); for ( ; num > 0; num--) { itemid = p_vcdplayer->play_item; switch (p_event->type) { - case XINE_EVENT_INPUT_MENU1: + case XINE_EVENT_INPUT_MENU1: if (p_vcdplayer->return_entry == VCDINFO_INVALID_ENTRY) { LOG_MSG("%s\n", _("selection has no RETURN entry")); return false; } itemid.num = p_vcdplayer->return_entry; - dbg_print((INPUT_DBG_PBC|INPUT_DBG_EVENT), + dbg_print((INPUT_DBG_PBC|INPUT_DBG_EVENT), "RETURN to %d\n", itemid.num); /* Don't loop around -- doesn't make sense to loop a return*/ - num = 0; + num = 0; break; - case XINE_EVENT_INPUT_MENU2: + case XINE_EVENT_INPUT_MENU2: if (vcdplayer_pbc_is_on(p_vcdplayer)) { - lid_t lid=vcdinfo_get_multi_default_lid(p_vcdplayer->vcd, + lid_t lid=vcdinfo_get_multi_default_lid(p_vcdplayer->vcd, p_vcdplayer->i_lid, p_vcdplayer->i_lsn); if (VCDINFO_INVALID_LID != lid) { itemid.num = lid; - dbg_print((INPUT_DBG_PBC|INPUT_DBG_EVENT), + dbg_print((INPUT_DBG_PBC|INPUT_DBG_EVENT), "DEFAULT to %d\n", itemid.num); } else { - dbg_print((INPUT_DBG_PBC|INPUT_DBG_EVENT), - "no DEFAULT for LID %d\n", + dbg_print((INPUT_DBG_PBC|INPUT_DBG_EVENT), + "no DEFAULT for LID %d\n", p_vcdplayer->i_lid); } - + /* Don't loop around -- doesn't make sense to loop a return*/ - num = 0; + num = 0; } else { - /* PBC is not on. "default" selection beginning of current + /* PBC is not on. "default" selection beginning of current selection . Alternative: */ LOG_MSG("%s\n", _("DEFAULT selected, but PBC is not on.")); } break; - case XINE_EVENT_INPUT_NEXT: + case XINE_EVENT_INPUT_NEXT: if (p_vcdplayer->next_entry == VCDINFO_INVALID_ENTRY) { LOG_MSG("%s\n", _("selection has no NEXT entry")); return false; - } + } itemid.num = p_vcdplayer->next_entry; dbg_print(INPUT_DBG_PBC, "NEXT to %d\n", itemid.num); break; @@ -1133,7 +1133,7 @@ vcd_handle_events (void) itemid.num = p_vcdplayer->prev_entry; dbg_print(INPUT_DBG_PBC, "PREVIOUS to %d\n", itemid.num); break; - default: + default: LOG_MSG("%s %d\n", _("Unknown event type: "), p_event->type); } _x_demux_flush_engine(my_vcd.stream); @@ -1147,13 +1147,13 @@ vcd_handle_events (void) /* In the future will have to test to see if we are in a menu selection. But if not... */ vcdinfo_itemid_t itemid = p_vcdplayer->play_item; - + itemid.num = number_addend; number_addend = 0; - + if (vcdplayer_pbc_is_on(p_vcdplayer)) { - lid_t i_next=vcdinfo_selection_get_lid(p_vcdplayer->vcd, - p_vcdplayer->i_lid, + lid_t i_next=vcdinfo_selection_get_lid(p_vcdplayer->vcd, + p_vcdplayer->i_lid, itemid.num); if (VCDINFO_INVALID_LID != i_next) { itemid.num = i_next; @@ -1164,30 +1164,30 @@ vcd_handle_events (void) } break; } - case XINE_EVENT_INPUT_MOUSE_BUTTON: + case XINE_EVENT_INPUT_MOUSE_BUTTON: if (my_vcd.stream) { xine_input_data_t *p_input = p_event->data; - if (p_input->button == 1) + if (p_input->button == 1) { #if LIBVCD_VERSION_NUM >= 23 int i_selection; #endif - dbg_print(INPUT_DBG_EVENT, - "Button to x: %d, y: %d, scaled x: %d, scaled y %d\n", + dbg_print(INPUT_DBG_EVENT, + "Button to x: %d, y: %d, scaled x: %d, scaled y %d\n", p_input->x, p_input->y, p_input->x * 255 / p_vcdplayer->max_x, p_input->y * 255 / p_vcdplayer->max_y); - + #if LIBVCD_VERSION_NUM >= 23 /* xine_dvd_send_button_update(this, 1); */ - + if (my_vcd.b_mouse_in) send_mouse_enter_leave_event(&my_vcd, false); - i_selection = vcdinfo_get_area_selection(p_vcdplayer->vcd, - p_vcdplayer->i_lid, + i_selection = vcdinfo_get_area_selection(p_vcdplayer->vcd, + p_vcdplayer->i_lid, p_input->x, p_input->y, p_vcdplayer->max_x, @@ -1196,8 +1196,8 @@ vcd_handle_events (void) if (vcdplayer_pbc_is_on(p_vcdplayer)) { vcdinfo_itemid_t itemid = p_vcdplayer->play_item; - lid_t i_next=vcdinfo_selection_get_lid(p_vcdplayer->vcd, - p_vcdplayer->i_lid, + lid_t i_next=vcdinfo_selection_get_lid(p_vcdplayer->vcd, + p_vcdplayer->i_lid, i_selection); if (VCDINFO_INVALID_LID != i_next) { itemid.num = i_next; @@ -1210,33 +1210,33 @@ vcd_handle_events (void) } } break; - case XINE_EVENT_INPUT_BUTTON_FORCE: + case XINE_EVENT_INPUT_BUTTON_FORCE: break; - case XINE_EVENT_INPUT_MOUSE_MOVE: - if (my_vcd.stream) + case XINE_EVENT_INPUT_MOUSE_MOVE: + if (my_vcd.stream) { xine_input_data_t *p_input = p_event->data; #if LIBVCD_VERSION_NUM >= 23 - int32_t i_selection = vcdinfo_get_area_selection(p_vcdplayer->vcd, - p_vcdplayer->i_lid, + int32_t i_selection = vcdinfo_get_area_selection(p_vcdplayer->vcd, + p_vcdplayer->i_lid, p_input->x, p_input->y, p_vcdplayer->max_x, p_vcdplayer->max_y); - dbg_print(INPUT_DBG_EVENT, "Move to x: %d, y: %d\n", + dbg_print(INPUT_DBG_EVENT, "Move to x: %d, y: %d\n", p_input->x, p_input->y); - + if (my_vcd.i_mouse_button != i_selection) { - dbg_print(INPUT_DBG_EVENT, "Old selection: %d, selection: %d\n", + dbg_print(INPUT_DBG_EVENT, "Old selection: %d, selection: %d\n", my_vcd.i_mouse_button, i_selection); my_vcd.i_mouse_button = i_selection; - if (i_selection < 0) + if (i_selection < 0) send_mouse_enter_leave_event(&my_vcd, false); - else + else send_mouse_enter_leave_event(&my_vcd, true); } #else - dbg_print(INPUT_DBG_EVENT, "Move to x: %d, y: %d\n", + dbg_print(INPUT_DBG_EVENT, "Move to x: %d, y: %d\n", p_input->x, p_input->y); #endif } @@ -1267,19 +1267,19 @@ vcd_handle_events (void) request optional data from input plugin. */ -static int -vcd_get_optional_data (input_plugin_t *this_gen, +static int +vcd_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { - dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), + dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "called with %d\n", data_type); if (NULL == my_vcd.stream) return INPUT_OPTIONAL_UNSUPPORTED; /* Fill this out more fully... */ switch(data_type) { - - case INPUT_OPTIONAL_DATA_AUDIOLANG: + + case INPUT_OPTIONAL_DATA_AUDIOLANG: { uint8_t channel; channel = _x_get_audio_channel(my_vcd.stream); @@ -1303,8 +1303,8 @@ vcd_get_optional_data (input_plugin_t *this_gen, } return INPUT_OPTIONAL_SUCCESS; } - - case INPUT_OPTIONAL_DATA_SPULANG: + + case INPUT_OPTIONAL_DATA_SPULANG: { /*uint16_t lang;*/ int8_t channel; @@ -1315,12 +1315,12 @@ vcd_get_optional_data (input_plugin_t *this_gen, } else { sprintf(data, "%1d", channel); } - + } default: ; } - + return INPUT_OPTIONAL_UNSUPPORTED; } @@ -1338,7 +1338,7 @@ vcd_get_optional_data (input_plugin_t *this_gen, */ static char ** -vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) +vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) { vcd_input_class_t *class = (vcd_input_class_t *) this_gen; static char *filelist[MAX_DIR_ENTRIES]; @@ -1351,9 +1351,9 @@ vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) } else { int i; int size = 0; - vcdinfo_item_enum_t itemtype = + vcdinfo_item_enum_t itemtype = autoplay2itemtype[my_vcd.player.default_autoplay]; - + int offset = vcd_get_mrl_type_offset(&my_vcd, itemtype, &size); /* A VCD is not required to have PBC or LID's, default to entry if @@ -1364,7 +1364,7 @@ vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) offset = vcd_get_mrl_type_offset(&my_vcd, itemtype, &size); } - /* This is because entries start at 0 while other playable units + /* This is because entries start at 0 while other playable units start at 1. Can remove the below when everything has the same origin. */ @@ -1385,14 +1385,14 @@ vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_files) } /*! - Things that need to be done when a stream is closed. + Things that need to be done when a stream is closed. */ -static void -vcd_plugin_dispose(input_plugin_t *this_gen) +static void +vcd_plugin_dispose(input_plugin_t *this_gen) { /* Not sure there's much more to do here... - In open_plugin we are given a stream which + In open_plugin we are given a stream which we save... */ dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n"); @@ -1408,10 +1408,10 @@ vcd_plugin_dispose(input_plugin_t *this_gen) static vcd_log_handler_t gl_default_vcd_log_handler = NULL; static cdio_log_handler_t gl_default_cdio_log_handler = NULL; -/*! This routine is called by libvcd routines on error. +/*! This routine is called by libvcd routines on error. Setup is done by init_input_plugin. */ -static void +static void vcd_log_handler (vcd_log_level_t level, const char message[]) { switch (level) { @@ -1428,19 +1428,19 @@ vcd_log_handler (vcd_log_level_t level, const char message[]) LOG_ERR("%s", message); break; default: - LOG_ERR("%s\n%s %d", - message, - _("The above message had unknown vcdimager log level"), + LOG_ERR("%s\n%s %d", + message, + _("The above message had unknown vcdimager log level"), level); } - + /* gl_default_vcd_log_handler (level, message); */ } -/*! This routine is called by libcdio routines on error. +/*! This routine is called by libcdio routines on error. Setup is done by init_input_plugin. */ -static void +static void cdio_log_handler (cdio_log_level_t level, const char message[]) { switch (level) { @@ -1453,10 +1453,10 @@ cdio_log_handler (cdio_log_level_t level, const char message[]) } } -/*! This routine is when xine is not around. +/*! This routine is when xine is not around. Setup is done by vcd_class_dispose. */ -static void +static void uninit_log_handler (vcd_log_level_t level, const char message[]) { switch (level) { @@ -1476,25 +1476,25 @@ uninit_log_handler (vcd_log_level_t level, const char message[]) break; default: fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d", - message, - _("The above message had unknown vcdimager log level"), + message, + _("The above message had unknown vcdimager log level"), level); } - + /* gl_default_vcd_log_handler (level, message); */ } /*! - Things that need to be done the vcd plugin is closed. + Things that need to be done the vcd plugin is closed. */ -static void +static void vcd_class_dispose (input_class_t *this_gen) { vcd_input_class_t *class = (vcd_input_class_t *) this_gen; class->xine->config->unregister_callback(class->xine->config, "media.vcd.device"); gl_default_vcd_log_handler = vcd_log_set_handler (uninit_log_handler); - gl_default_cdio_log_handler = + gl_default_cdio_log_handler = cdio_log_set_handler ((cdio_log_handler_t) uninit_log_handler); dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n"); @@ -1503,22 +1503,22 @@ vcd_class_dispose (input_class_t *this_gen) { } /* Update the xine player title text. */ -static void -vcd_update_title_display(void) +static void +vcd_update_title_display(void) { xine_event_t uevent; xine_ui_data_t data; char *title_str; - - title_str = vcdplayer_format_str(&my_vcd.player, + + title_str = vcdplayer_format_str(&my_vcd.player, my_vcd.v_config.title_format); meta_info_assign(XINE_META_INFO_TITLE, my_vcd.stream, title_str); meta_info_assign(XINE_META_INFO_COMMENT, my_vcd.stream, - vcdplayer_format_str(&my_vcd.player, + vcdplayer_format_str(&my_vcd.player, my_vcd.v_config.comment_format)); - stream_info_assign(XINE_STREAM_INFO_VIDEO_HAS_STILL, my_vcd.stream, + stream_info_assign(XINE_STREAM_INFO_VIDEO_HAS_STILL, my_vcd.stream, my_vcd.player.i_still); /* Set_str title/chapter display */ @@ -1536,8 +1536,8 @@ vcd_update_title_display(void) } #if LIBVCD_VERSION_NUM >= 23 -static void -send_mouse_enter_leave_event(vcd_input_plugin_t *p_this, bool b_mouse_in) +static void +send_mouse_enter_leave_event(vcd_input_plugin_t *p_this, bool b_mouse_in) { if (b_mouse_in && p_this->b_mouse_in) { /* Set up to enter the following "if" statement. */ @@ -1547,16 +1547,16 @@ send_mouse_enter_leave_event(vcd_input_plugin_t *p_this, bool b_mouse_in) if (b_mouse_in != p_this->b_mouse_in) { xine_event_t event; xine_spu_button_t spu_event; - + spu_event.direction = b_mouse_in ? 1 : 0; spu_event.button = p_this->i_mouse_button; - + event.type = XINE_EVENT_SPU_BUTTON; event.stream = p_this->stream; event.data = &spu_event; event.data_length = sizeof(spu_event); xine_event_send(p_this->stream, &event); - + p_this->b_mouse_in = b_mouse_in; } @@ -1564,22 +1564,22 @@ send_mouse_enter_leave_event(vcd_input_plugin_t *p_this, bool b_mouse_in) p_this->i_mouse_button = -1; } #endif - -/* - Not much special initialization needed here. All of the initialization + +/* + Not much special initialization needed here. All of the initialization is either done in the class or when we have an actual MRL we want to deal with. */ -static int +static int vcd_plugin_open (input_plugin_t *this_gen ) { vcd_input_class_t *class = (vcd_input_class_t *) this_gen->input_class; gl_default_vcd_log_handler = vcd_log_set_handler (vcd_log_handler); gl_default_cdio_log_handler = cdio_log_set_handler (cdio_log_handler); - /* actually, this is also done by class initialization. But just in + /* actually, this is also done by class initialization. But just in case... */ - class->ip = &my_vcd; + class->ip = &my_vcd; my_vcd.i_old_still = 0; return 1; @@ -1590,17 +1590,17 @@ vcd_plugin_open (input_plugin_t *this_gen ) { routine is called, xine-lib can read blocks from the thing specified by the MRL, set the position of the thing specified by the MRL, get its size or read its current position... - + See vcdplayer_parses_mrl for the for the format that a valid MRL can take. - Return values: + Return values: pointer to input plugin NULL on failure */ static input_plugin_t * vcd_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, - const char *mrl) + const char *mrl) { vcd_input_class_t *class = (vcd_input_class_t *) class_gen; @@ -1609,9 +1609,9 @@ vcd_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, char *check_mrl=NULL; bool used_default; - if (mrl == NULL) + if (mrl == NULL) check_mrl = strdup(MRL_PREFIX); - else + else check_mrl = strdup(mrl); dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called with %s\n", mrl); @@ -1622,7 +1622,7 @@ vcd_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, vcd_get_default_device(class, false); - if (!vcd_parse_mrl(class->vcd_device, check_mrl, + if (!vcd_parse_mrl(class->vcd_device, check_mrl, intended_vcd_device, &itemid, my_vcd.player.default_autoplay, &used_default)) { dbg_print(INPUT_DBG_MRL, "parsing MRL %s failed\n", check_mrl); @@ -1642,32 +1642,32 @@ vcd_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, my_vcd.player.user_data = (void *) class; /* Do we set PBC (via LID) on? */ - my_vcd.player.i_lid = - ( VCDINFO_ITEM_TYPE_LID == itemid.type + my_vcd.player.i_lid = + ( VCDINFO_ITEM_TYPE_LID == itemid.type && my_vcd.player.i_lids > itemid.num ) ? itemid.num : VCDINFO_INVALID_ENTRY; if ( VCDINFO_ITEM_TYPE_LID == itemid.type && used_default) { - /* LID was selected automatically but we don't have PBC for this VCD. + /* LID was selected automatically but we don't have PBC for this VCD. So silently change LID to track and continue. */ itemid.type=VCDINFO_ITEM_TYPE_TRACK; } - if ( 0==itemid.num - && ( (VCDINFO_ITEM_TYPE_LID == itemid.type) + if ( 0==itemid.num + && ( (VCDINFO_ITEM_TYPE_LID == itemid.type) || (VCDINFO_ITEM_TYPE_TRACK == itemid.type) ) ) itemid.num = 1; - dbg_print(INPUT_DBG_PBC, "Jumping to NUM >%i<, type >%i<\n", + dbg_print(INPUT_DBG_PBC, "Jumping to NUM >%i<, type >%i<\n", itemid.num, itemid.type); vcd_set_meta_info(&my_vcd); vcdplayer_play(&my_vcd.player, itemid); - - dbg_print(INPUT_DBG_MRL, "Successfully opened MRL %s.\n", + + dbg_print(INPUT_DBG_MRL, "Successfully opened MRL %s.\n", my_vcd.mrl); free (check_mrl); @@ -1706,30 +1706,30 @@ vcd_class_get_instance (input_class_t *class_gen, xine_stream_t *stream, var = strdup(entry->str_value); \ } -VCD_STR_CALLBACK(vcd_default_dev_changed_cb, +VCD_STR_CALLBACK(vcd_default_dev_changed_cb, my_vcd.class->vcd_device) -VCD_STR_CALLBACK(vcd_title_format_changed_cb, +VCD_STR_CALLBACK(vcd_title_format_changed_cb, my_vcd.v_config.title_format) -VCD_STR_CALLBACK(vcd_comment_format_changed_cb, +VCD_STR_CALLBACK(vcd_comment_format_changed_cb, my_vcd.v_config.comment_format) VCD_NUM_CALLBACK(vcd_show_rejected_cb, show_rejected) VCD_NUM_CALLBACK(vcd_autoadvance_cb, autoadvance) -VCD_ENUM_CALLBACK(vcd_slider_length_cb, vcdplayer_slider_length_t, +VCD_ENUM_CALLBACK(vcd_slider_length_cb, vcdplayer_slider_length_t, slider_length) VCD_ENUM_CALLBACK(vcd_default_autoplay_cb, vcdinfo_item_enum_t, default_autoplay) -static void -vcd_debug_cb(void *this_gen, xine_cfg_entry_t *entry) +static void +vcd_debug_cb(void *this_gen, xine_cfg_entry_t *entry) { dbg_print(INPUT_DBG_CALL, "Called setting %d\n", entry->num_value); - vcdplayer_debug = entry->num_value; + vcdplayer_debug = entry->num_value; } static void * @@ -1751,7 +1751,7 @@ vcd_init (xine_t *xine, void *data) class->input_class.get_instance = vcd_class_get_instance; class->input_class.identifier = SHORT_PLUGIN_NAME; class->input_class.description = N_("Video CD plugin with PBC and support for: (X)VCD, (X)SVCD, HQVCD, CVD ... "); - class->input_class.get_dir = vcd_class_get_dir; + class->input_class.get_dir = vcd_class_get_dir; class->input_class.get_autoplay_list = vcd_class_get_autoplay_list; class->input_class.dispose = vcd_class_dispose; class->input_class.eject_media = vcd_class_eject_media; @@ -1767,9 +1767,9 @@ vcd_init (xine_t *xine, void *data) my_vcd.player.log_msg = (generic_fn) &xine_log_msg; my_vcd.player.force_redisplay = &vcd_force_redisplay; my_vcd.player.set_aspect_ratio = &vcd_set_aspect_ratio; - + /*------------------------------------------------------------- - Playback control-specific fields + Playback control-specific fields --------------------------------------------------------------*/ my_vcd.player.i_lid = VCDINFO_INVALID_ENTRY; @@ -1785,58 +1785,58 @@ vcd_init (xine_t *xine, void *data) my_vcd.player.prev_entry = -1; my_vcd.player.return_entry = -1; my_vcd.player.default_entry = -1; - + /*-------------------------------------------------------------- Configuration variables ---------------------------------------------------------------*/ - { + { /*Note: these labels have to be listed in the same order as the - enumeration vcdplayer_autoplay_t in vcdplayer.h. + enumeration vcdplayer_autoplay_t in vcdplayer.h. */ - static const char *const autoplay_modes[] = + static const char *const autoplay_modes[] = { "MPEG track", "entry", "segment", "playback-control item", NULL }; - + /*Note: these labels have to be listed in the same order as the - enumeration vcdplayer_slider_length_t in vcdplayer.h. + enumeration vcdplayer_slider_length_t in vcdplayer.h. */ - static const char *const length_reporting_modes[] = + static const char *const length_reporting_modes[] = { "auto", "track", "entry", NULL }; - - my_vcd.player.default_autoplay = - config->register_enum(config, + + my_vcd.player.default_autoplay = + config->register_enum(config, "media.vcd.autoplay", VCDPLAYER_AUTOPLAY_PBC, (char **) autoplay_modes, _("VCD default type to use on autoplay"), _("The VCD play unit to use when none is specified in an MRL, e.g. " "vcd:// or vcd:///dev/dvd:"), - 10, + 10, vcd_default_autoplay_cb, class); - - - class->vcd_device = - strdup (config->register_filename(config, + + + class->vcd_device = + strdup (config->register_filename(config, "media.vcd.device", "", XINE_CONFIG_STRING_IS_DEVICE_NAME, _("CD-ROM drive used for VCD when none given"), -_("What to use if no drive specified. If the setting is empty, xine will scan for CD drives."), +_("What to use if no drive specified. If the setting is empty, xine will scan for CD drives."), 20, - vcd_default_dev_changed_cb, + vcd_default_dev_changed_cb, (void *) class)); my_vcd.player.slider_length = - config->register_enum(config, + config->register_enum(config, "media.vcd.length_reporting", - VCDPLAYER_SLIDER_LENGTH_AUTO, + VCDPLAYER_SLIDER_LENGTH_AUTO, (char **) length_reporting_modes, _("VCD position slider range"), _("range that the stream playback position slider represents playing a VCD."), - 10, + 10, vcd_slider_length_cb, NULL); #if READAHEAD_FINISHED - my_vcd.player.readahead = + my_vcd.player.readahead = config->register_bool(config, "vcd.use_readahead", (int) false, _("VCD read-ahead caching?"), @@ -1846,29 +1846,29 @@ _("range that the stream playback position slider represents playing a VCD."), vcd_read_ahead_cb, NULL); #endif - my_vcd.player.autoadvance = - config->register_bool(config, + my_vcd.player.autoadvance = + config->register_bool(config, "media.vcd.autoadvance", (int) true, _("automatically advance VCD track/entry"), _("If enabled, we should automatically advance to the next entry or track. Used only when playback control (PBC) is disabled."), - 10, - vcd_autoadvance_cb, - NULL); + 10, + vcd_autoadvance_cb, + NULL); - my_vcd.player.show_rejected = - config->register_bool(config, + my_vcd.player.show_rejected = + config->register_bool(config, "media.vcd.show_rejected", (int) false, _("show 'rejected' VCD LIDs"), _("Some playback list IDs (LIDs) are marked not showable, " "but you can see them in the MRL list if this is set. Rejected entries " "are marked with an asterisk (*) appended to the MRL."), - 10, - vcd_show_rejected_cb, - NULL); + 10, + vcd_show_rejected_cb, + NULL); - my_vcd.v_config.title_format = + my_vcd.v_config.title_format = strdup(config->register_string(config, "media.vcd.title_format", "%F - %I %N%L%S, disk %c of %C - %v %A", @@ -1894,7 +1894,7 @@ _("VCD format used in the GUI Title. Similar to the Unix date " vcd_title_format_changed_cb, NULL)); - my_vcd.v_config.comment_format = + my_vcd.v_config.comment_format = strdup(config->register_string(config, "media.vcd.comment_format", "%P - Track %T", @@ -1907,8 +1907,8 @@ _("VCD format used in the GUI Title. Similar to the Unix date " vcd_comment_format_changed_cb, NULL)); - vcdplayer_debug = - config->register_num(config, + vcdplayer_debug = + config->register_num(config, "media.vcd.debug", 0, _("VCD debug flag mask"), @@ -1927,12 +1927,12 @@ _("For tracking down bugs in the VCD plugin. Mask values are:\n" "2048: Debugging from VCDINFO\n" ), 20, - vcd_debug_cb, - class); + vcd_debug_cb, + class); } - + gl_default_vcd_log_handler = vcd_log_set_handler (uninit_log_handler); - gl_default_cdio_log_handler = + gl_default_cdio_log_handler = cdio_log_set_handler ((cdio_log_handler_t) uninit_log_handler); my_vcd.input_plugin.open = vcd_plugin_open; @@ -1952,7 +1952,7 @@ _("For tracking down bugs in the VCD plugin. Mask values are:\n" my_vcd.class = class; my_vcd.i_mouse_button = -1; my_vcd.b_mouse_in = false; - + my_vcd.player.psz_source = NULL; my_vcd.player.b_opened = false; @@ -1964,11 +1964,11 @@ _("For tracking down bugs in the VCD plugin. Mask values are:\n" return class; } -/* +/* Exported plugin catalog entries. All plugins listing only the current API number break when the API - number is increased. This is by design. + number is increased. This is by design. Sometimes in the rush to get out a buggy release, the API number is increased without communication let alone a concern for whether it @@ -1985,13 +1985,13 @@ _("For tracking down bugs in the VCD plugin. Mask values are:\n" */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, (char *) SHORT_PLUGIN_NAME, XINE_VERSION_CODE, NULL, vcd_init }, { PLUGIN_NONE, 0, (char *) "", 0, NULL, NULL } }; -/* +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 |