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 | 80 | ||||
-rw-r--r-- | tools/udp_pes_scheduler.c | 23 |
4 files changed, 60 insertions, 59 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..18f8944b 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.2 2009-02-12 11:20:24 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 @@ -175,11 +172,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 +531,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 +762,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 +797,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 +811,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 +836,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 +854,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 +865,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 +884,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 +920,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 +930,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 +973,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/udp_pes_scheduler.c b/tools/udp_pes_scheduler.c index 13a59c48..a3c589af 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.2.1 2009-02-12 11:18:37 phintuka Exp $ * */ @@ -821,10 +821,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 +835,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 +877,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); } } |