diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/http.c | 4 | ||||
-rw-r--r-- | tools/iso639.h | 12 | ||||
-rw-r--r-- | tools/playlist.c | 86 | ||||
-rw-r--r-- | tools/sdp.h | 25 | ||||
-rw-r--r-- | tools/udp_pes_scheduler.c | 29 | ||||
-rw-r--r-- | tools/vdrdiscovery.c | 37 |
6 files changed, 94 insertions, 99 deletions
diff --git a/tools/http.c b/tools/http.c index 0e7de26a..4a529550 100644 --- a/tools/http.c +++ b/tools/http.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: http.c,v 1.7 2009-06-02 08:37:58 phintuka Exp $ + * $Id: http.c,v 1.6 2007-06-21 09:12:52 phintuka Exp $ * */ @@ -297,7 +297,7 @@ bool cHttpStreamer::Seek(void) } /* content type */ - const char *ext = strrchr(m_Filename, '.'); + char *ext = strrchr(m_Filename, '.'); if(ext) { const char *mime = mimetype(ext+1); if(mime) diff --git a/tools/iso639.h b/tools/iso639.h index ae30fa0e..cd0e954f 100644 --- a/tools/iso639.h +++ b/tools/iso639.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: iso639.h,v 1.4 2009-05-29 14:25:06 phintuka Exp $ + * $Id: iso639.h,v 1.1.2.1 2008-09-26 13:49:45 phintuka Exp $ * */ @@ -60,7 +60,6 @@ static const struct { {"guj", "gu"}, {"hau", "ha"}, {"heb", "he"}, - {"heb", "iw"}, {"hin", "hi"}, {"hun", "hu"}, {"ice", "is"}, @@ -158,9 +157,9 @@ static const struct { static const char *iso639_2_to_iso639_1(const char *lang) { if (lang && lang[0]) { - if (lang[1] && !lang[2]) { + if(lang[1] && !lang[2]) { for (unsigned int i = 0 ; i < sizeof(ISO639_map) / sizeof(ISO639_map[0]); i++) - if (!memcmp(ISO639_map[i].iso639_1, lang, 2)) + if (((uint16_t*)ISO639_map[i].iso639_1)[0] == ((uint16_t*)lang)[0]) return ISO639_map[i].iso639_2; LOGMSG("Unknown iso639-2 code: %s", lang); } @@ -172,9 +171,10 @@ static const char *iso639_2_to_iso639_1(const char *lang) static const char *iso639_1_to_iso639_2(const char *lang) { if (lang && lang[0]) { - if (lang[1] && lang[2] && !lang[3]) { + if(lang[1] && lang[2] && !lang[3]) { for (unsigned int i = 0 ; i < sizeof(ISO639_map) / sizeof(ISO639_map[0]); i++) - if (!memcmp(ISO639_map[i].iso639_2, lang, 3)) + if (((uint16_t*)ISO639_map[i].iso639_2)[0] == ((uint16_t*)lang)[0] && + ((uint8_t *)ISO639_map[i].iso639_2)[2] == ((uint8_t *)lang)[2]) return ISO639_map[i].iso639_1; LOGMSG("Unknown iso639-1 code: %s", lang); } diff --git a/tools/playlist.c b/tools/playlist.c index 652253c6..0217eca7 100644 --- a/tools/playlist.c +++ b/tools/playlist.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: playlist.c,v 1.17.2.4 2009-06-04 21:04:34 phintuka Exp $ + * $Id: playlist.c,v 1.17.2.1 2008-09-26 19:09:29 phintuka Exp $ * */ @@ -36,12 +36,6 @@ #define MAX_PLAYLIST_FILES 1024 -static void strip_extension(cString& fname) -{ - const char *ext = strrchr(fname, '.'); - if (ext) - fname.Truncate(ext - fname); -} // // cPlaylistItem @@ -49,7 +43,7 @@ static void strip_extension(cString& fname) cPlaylistItem::cPlaylistItem(const char *filename) { - const char *pt; + char *pt; Filename = filename; Position = -1; @@ -58,8 +52,9 @@ cPlaylistItem::cPlaylistItem(const char *filename) Title = pt + 1; else Title = filename; - - strip_extension(Title); + + if(NULL != (pt = strrchr(Title, '.'))) + *pt = 0; } cPlaylistItem::cPlaylistItem(const char *filename, @@ -67,6 +62,8 @@ cPlaylistItem::cPlaylistItem(const char *filename, const char *title, int position) { + char *pt; + if(path[strlen(path)-1] != '/') Filename = cString::sprintf("%s/%s", path, filename); else @@ -74,8 +71,8 @@ cPlaylistItem::cPlaylistItem(const char *filename, Position = position; Title = title ?: filename; - if (!title) - strip_extension(Title); + if(!title && (pt = strrchr(Title, '.'))) + *pt = 0; } int cPlaylistItem::Compare(const cListObject &ListObject) const @@ -145,10 +142,8 @@ class cID3Scanner : public cThread { cPlaylistItem *Item = NULL; unsigned int Version = 0; - const int priority = 10; - errno = 0; - if((nice(priority) == -1) && errno) - LOGDBG("ID3Scanner: Can't nice to value: %d", priority); + + (void)nice(10); LOGDBG("ID3Scanner Started"); while(Running()) { @@ -175,11 +170,11 @@ class cID3Scanner : public cThread while(md_list) { if ((key=EXTRACTOR_getKeywordTypeAsString(md_list->keywordType))) { if (!strcasecmp(key,"title")) - Item->Title = md_list->keyword; + Item->Title = strdup(md_list->keyword); else if (!strcasecmp(key,"artist")) - Item->Artist = md_list->keyword; + Item->Artist = strdup(md_list->keyword); else if (!strcasecmp(key,"album")) - Item->Album = md_list->keyword; + Item->Album = strdup(md_list->keyword); else if (!strcasecmp(key,"track number")) Item->Tracknumber = cString::sprintf("%s%s", strlen(md_list->keyword) == 1 ? "0" : "", md_list->keyword); md_list=md_list->next; @@ -534,7 +529,7 @@ bool cPlaylist::ReadCache(void) int len = strlen(m_Folder); cPlaylistItem *it = NULL; cReadLine r; - const char *pt; + char *pt; while(NULL != (pt = r.Read(f))) { if(!strncmp(pt, "File", 4)) { it = NULL; @@ -765,26 +760,29 @@ int cPlaylist::ReadPlaylist(const char *file) if(f) { LOGDBG("cPlaylist: parsing %s", file); - const char *ext = strrchr(file, '.'); - if(!strcasecmp(ext, ".pls")) + char *pt = strrchr(file, '.'); + if(!strcasecmp(pt, ".pls")) parser = new cPlsReader(*this); - else if(!strcasecmp(ext, ".asx")) + else if(!strcasecmp(pt, ".asx")) parser = new cAsxReader(*this); - else /*if(!strcasecmp(ext, ".m3u"))*/ + else /*if(!strcasecmp(pt, ".m3u"))*/ parser = new cM3uReader(*this); /* parses plain lists (.ram, ...) too ...*/ - /* get folder */ - cString Folder = file; - const char *folder = strrchr(Folder, '/'); - if (folder) - Folder.Truncate(folder - Folder + 1); + cString Base(file); + if(NULL != (pt=strrchr(Base,'/'))) + pt[1]=0; int n = 0; cReadLine r; - char *pt; while(NULL != (pt = r.Read(f)) && n < MAX_PLAYLIST_FILES) { if(NULL != (pt = parser->Parse(pt))) { + if(depth && n==0) { + // TODO + // - add "separator" item + // Add(new cPlaylistItem(NULL, Base, "---"); + } + if(xc.IsPlaylistFile(pt)) { parser->ResetCache(); LOGDBG("cPlaylist: found playlist inside playlist"); @@ -797,7 +795,7 @@ int cPlaylist::ReadPlaylist(const char *file) strchr(pt,'/') - pt < 8)) n += ReadPlaylist(pt); else - n += ReadPlaylist(cString::sprintf("%s%s", *Folder, pt)); + n += ReadPlaylist(cString::sprintf("%s%s", *Base, pt)); depth--; } @@ -811,7 +809,7 @@ int cPlaylist::ReadPlaylist(const char *file) Last()->Title = parser->Title(); } else { // relative path - Add(new cPlaylistItem(pt, Folder, parser->Title())); + Add(new cPlaylistItem(pt, Base, parser->Title())); } Last()->Position = parser->Position(); parser->ResetCache(); @@ -836,10 +834,10 @@ int cPlaylist::ReadPlaylist(const char *file) static cString LastDir(cString& path) { - cString tmp = path; - const char *pt = strrchr(tmp, '/'); + cString tmp = strdup(path); + char *pt = strrchr(tmp, '/'); if(pt && pt > *tmp) { - tmp.Truncate(pt - tmp); + *pt = 0; pt = strrchr(tmp, '/'); if(pt) return cString(pt+1); @@ -854,10 +852,9 @@ bool cPlaylist::Read(const char *PlaylistFile, bool Recursive) // extract playlist root folder if(!*m_Folder) { - const char *pt; m_Folder = PlaylistFile; - if (NULL != (pt=strrchr(m_Folder, '/'))) - m_Folder.Truncate(pt - m_Folder + 1); + if(strrchr(m_Folder, '/')) + *(strrchr(m_Folder, '/') + 1) = 0; } if(xc.IsPlaylistFile(PlaylistFile)) { @@ -866,14 +863,15 @@ bool cPlaylist::Read(const char *PlaylistFile, bool Recursive) m_Origin = ePlaylist; cString dir = LastDir(m_Folder); - const char *name = strrchr(PlaylistFile, '/'); + char *name = strrchr(PlaylistFile, '/'); name = name ? name+1 : NULL; if(*dir && name) m_Name = cString::sprintf("%s - %s", *dir, name); else m_Name = name ?: ""; - strip_extension(m_Name); + if(strrchr(m_Name, '.')) + *(strrchr(m_Name, '.')) = 0; } else if(PlaylistFile[ 0] == '/' && PlaylistFile[strlen(PlaylistFile)-1] == '/') { @@ -884,7 +882,7 @@ bool cPlaylist::Read(const char *PlaylistFile, bool Recursive) if(!*m_Name) { m_Name = PlaylistFile; - m_Name.Truncate( strrchr(m_Name, '/') - m_Name); + *(strrchr(m_Name, '/')) = 0; if(strrchr(m_Name, '/')) { cString dir = LastDir(m_Name); if(*dir) @@ -920,7 +918,7 @@ cString cPlaylist::EscapeMrl(const char *mrl) static const uint8_t hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; const uint8_t *fn = (const uint8_t*)mrl; int size = strlen(mrl) + 16; - char *buf = (char *)malloc(size); + uint8_t *buf = (uint8_t*)malloc(size); int i = 0, found = 0; LOGDBG("cPlaylist::EscapeMrl('%s')", fn); @@ -930,7 +928,7 @@ cString cPlaylist::EscapeMrl(const char *mrl) while (*fn) { if(size-7 < i) - buf = (char *)realloc(buf, (size=size+16)); + buf = (uint8_t *)realloc(buf, (size=size+16)); switch (*fn) { case 1 ... ' ': case 127 ... 255: @@ -973,7 +971,7 @@ cString cPlaylist::EscapeMrl(const char *mrl) buf[i] = 0; LOGDBG(" --> '%s'", buf); - return cString(buf, true); + return cString((const char*)buf, true); } cString cPlaylist::GetEntry(cPlaylistItem *i, bool isPlaylist, bool isCurrent) diff --git a/tools/sdp.h b/tools/sdp.h index e56f1ebd..47a3a409 100644 --- a/tools/sdp.h +++ b/tools/sdp.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: sdp.h,v 1.2.2.1 2009-02-12 11:08:15 phintuka Exp $ + * $Id: sdp.h,v 1.2 2006-12-14 12:52:49 phintuka Exp $ * */ @@ -15,16 +15,16 @@ #define SDP_MIME_TYPE "application/sdp" -static const char *vdr_sdp_description(const char *vdr_ip, - int vdr_svdrp_port, - int vdr_xineliboutput_port, - const char *rtp_ip, - uint32_t rtp_ssrc, - int rtp_port, - int rtp_ttl) +static char *vdr_sdp_description(const char *vdr_ip, + int vdr_svdrp_port, + int vdr_xineliboutput_port, + const char *rtp_ip, + uint32_t rtp_ssrc, + int rtp_port, + int rtp_ttl) { static uint8_t s_serial = 0; - static cString s_data; + static char *s_data = NULL; static char s_hostname[257] = {0}; uint64_t serial = (time(NULL) << 2) + ((s_serial++) & 0x03); @@ -32,7 +32,9 @@ static const char *vdr_sdp_description(const char *vdr_ip, if(!s_hostname[0]) gethostname(s_hostname, 256); - s_data = cString::sprintf( + free(s_data); + + asprintf(&s_data, /*** session ***/ /* version */ "v=0" /* origin */ "\r\n" "o=%s %u %"PRIu64" IN IP4 %s" @@ -84,7 +86,8 @@ static const char *vdr_sdp_description(const char *vdr_ip, /* tcp control/x-svdrp */ , vdr_ip , vdr_svdrp_port - ); + ); + return s_data; } diff --git a/tools/udp_pes_scheduler.c b/tools/udp_pes_scheduler.c index 13a59c48..57b20a0b 100644 --- a/tools/udp_pes_scheduler.c +++ b/tools/udp_pes_scheduler.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: udp_pes_scheduler.c,v 1.34.2.2 2009-06-06 13:27:41 phintuka Exp $ + * $Id: udp_pes_scheduler.c,v 1.34 2008-04-28 20:53:07 phintuka Exp $ * */ @@ -676,11 +676,9 @@ void cUdpScheduler::Action(void) #endif /* UDP Scheduler needs high priority */ - const int priority = -5; - SetPriority(priority); + SetPriority(-5); + (void)nice(-5); errno = 0; - if ((nice(priority) == -1) && errno) - LOGDBG("cUdpScheduler: Can't nice to value: %d", priority); m_Lock.Lock(); @@ -821,10 +819,9 @@ void cUdpScheduler::ReSend(int fd, uint64_t Pos, int Seq1, int Seq2) if(fd < 0) /* no re-send for RTP */ return; - struct { - stream_udp_header_t hdr; - char mem[64-sizeof(stream_udp_header_t)]; - } udp_ctrl = {{(uint64_t)INT64_C(-1), (uint16_t)-1}, {0}}; + char udp_ctrl[64] = {0}; + ((stream_udp_header_t *)udp_ctrl)->seq = (uint16_t)(-1); + ((stream_udp_header_t *)udp_ctrl)->pos = (uint64_t)(-1); // Handle buffer wrap if(Seq1 > Seq2) @@ -836,10 +833,10 @@ void cUdpScheduler::ReSend(int fd, uint64_t Pos, int Seq1, int Seq2) LOGDBG("cUdpScheduler::ReSend: requested range too large (%d-%d)", Seq1, Seq2); - sprintf((char*)udp_ctrl.hdr.payload, + sprintf((udp_ctrl+sizeof(stream_udp_header_t)), "UDP MISSING %d-%d %" PRIu64, Seq1, (Seq2 & UDP_BUFFER_MASK), Pos); - send(fd, &udp_ctrl, sizeof(udp_ctrl), 0); + send(fd, udp_ctrl, sizeof(udp_ctrl), 0); return; } @@ -878,19 +875,21 @@ void cUdpScheduler::ReSend(int fd, uint64_t Pos, int Seq1, int Seq2) // buffer has been lost - send packet missing info LOGRESEND("cUdpScheduler::ReSend: missing %d-%d @%d (hdr 0x%llx 0x%x)", - Seq1, Seq1, Pos, udp_ctrl.hdr.pos, udp_ctrl.hdr.seq); + Seq1, Seq1, Pos, + ((stream_udp_header_t *)udp_ctrl)->pos, + ((stream_udp_header_t *)udp_ctrl)->seq); int Seq0 = Seq1; - for(; Seq1 < Seq2; Seq1++) { + for(; Seq1 <= Seq2; Seq1++) { stream_rtp_header_impl_t *frame = m_BackLog->Get(Seq1+1); if(frame && (ntohull(frame->hdr_ext.pos) - Pos < 100000)) break; } - sprintf((char*)udp_ctrl.hdr.payload, + sprintf((udp_ctrl+sizeof(stream_udp_header_t)), "UDP MISSING %d-%d %" PRIu64, Seq0, (Seq1 & UDP_BUFFER_MASK), Pos); - send(fd, &udp_ctrl, sizeof(udp_ctrl), 0); + send(fd, udp_ctrl, sizeof(udp_ctrl), 0); } } diff --git a/tools/vdrdiscovery.c b/tools/vdrdiscovery.c index 7bc1ec53..82a9a109 100644 --- a/tools/vdrdiscovery.c +++ b/tools/vdrdiscovery.c @@ -7,7 +7,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: vdrdiscovery.c,v 1.5.2.1 2009-02-12 11:24:02 phintuka Exp $ + * $Id: vdrdiscovery.c,v 1.5 2008-04-03 13:59:37 phintuka Exp $ * */ @@ -111,28 +111,25 @@ int udp_discovery_broadcast(int fd_discovery, int server_port, const char *serve char *msg = NULL; int result; - if(server_address && *server_address) { - result = asprintf(&msg, + if(server_address && *server_address) + asprintf(&msg, DISCOVERY_1_0_HDR //"VDR xineliboutput DISCOVERY 1.0" "\r\n" DISCOVERY_1_0_SVR //"Server port: %d" "\r\n" DISCOVERY_1_0_ADDR //"Server Address: %d.%d.%d.%d \r\n" DISCOVERY_1_0_VERSION //"Server version: xineliboutput-" XINELIBOUTPUT_VERSION "\r\n" "\r\n", server_port, server_address); - } else { - result = asprintf(&msg, + else + asprintf(&msg, DISCOVERY_1_0_HDR //"VDR xineliboutput DISCOVERY 1.0" "\r\n" DISCOVERY_1_0_SVR //"Server port: %d" "\r\n" DISCOVERY_1_0_VERSION //"Server version: xineliboutput-" XINELIBOUTPUT_VERSION "\r\n" "\r\n", server_port); - } - - if (result >= 0) { - result = udp_discovery_send(fd_discovery, DISCOVERY_PORT, msg); - free(msg); - } + + result = udp_discovery_send(fd_discovery, DISCOVERY_PORT, msg); + free(msg); return result; } #else @@ -141,18 +138,16 @@ static inline int udp_discovery_search(int fd_discovery, int port) char *msg = NULL; int result; - result = asprintf(&msg, - DISCOVERY_1_0_HDR /* "VDR xineliboutput DISCOVERY 1.0" "\r\n" */ - DISCOVERY_1_0_CLI /* "Client: %s:%d" "\r\n" */ - "\r\n", - "255.255.255.255", - port); + asprintf(&msg, + DISCOVERY_1_0_HDR /* "VDR xineliboutput DISCOVERY 1.0" "\r\n" */ + DISCOVERY_1_0_CLI /* "Client: %s:%d" "\r\n" */ + "\r\n", + "255.255.255.255", + port); - if (result >= 0) { - result = udp_discovery_send(fd_discovery, port, msg); - free(msg); - } + result = udp_discovery_send(fd_discovery, port, msg); + free(msg); return result; } #endif |