From: <ny...@us...> - 2006-05-05 09:01:17
|
Revision: 11 Author: nyaochi Date: 2006-05-05 02:01:00 -0700 (Fri, 05 May 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=11&view=rev Log Message: ----------- - Supported Samsung YH-820 and YH-925 players - Predefined Codec class in JSPL. Modified Paths: -------------- trunk/lib/playlist/jspl.c trunk/lib/pmp_portalplayer1/hdr_template.h trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj Added Paths: ----------- trunk/lib/pmp_portalplayer1/model_samsung.c Removed Paths: ------------- trunk/lib/pmp_portalplayer1/model_samsung_yh820.c Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-05-03 14:42:46 UTC (rev 10) +++ trunk/lib/playlist/jspl.c 2006-05-05 09:01:00 UTC (rev 11) @@ -348,22 +348,47 @@ return 0; } -static int jspl_init_script(jspl_t* jspl) +static int jspl_init_register_codec(jspl_t* jspl, const char *name, uint32_t codec, int *lines) { - static const char *script = - "Math.cmp = function(x, y)\n" - "{\n" - " return ((x)>(y))-((x)<(y));\n" - "};\n" - "\n"; + int ret = 0; + jsval retval; + char buffer[1024]; - static const char *_script = "function dummy() {}\n"; + sprintf(buffer, "Codec.%s = %u;\n", name, codec); + ret = JS_EvaluateScript(jspl->context, jspl->global, buffer, strlen(buffer), "easypmp.js", *lines, &retval); + if (!ret) { + return -1; + } + ++(*lines); + return 0; +} +static int jspl_init_codec_class(jspl_t* jspl) +{ jsval retval; - int ret = JS_EvaluateScript(jspl->context, jspl->global, script, strlen(script), "easypmp.js", 1, &retval); + int lines = 1; + static const char *script = "Codec = new Object();\n"; + + int ret = JS_EvaluateScript(jspl->context, jspl->global, script, strlen(script), "easypmp.js", lines, &retval); if (!ret) { return -1; } + ++lines; + + /* Register codec IDs. */ + if (jspl_init_register_codec(jspl, "MP3", PMPCODEC_MPEGLAYER3, &lines) < 0) { + return -1; + } + if (jspl_init_register_codec(jspl, "WMA", PMPCODEC_WMA, &lines) < 0) { + return -1; + } + if (jspl_init_register_codec(jspl, "OggVorbis", PMPCODEC_VORBIS, &lines) < 0) { + return -1; + } + if (jspl_init_register_codec(jspl, "WAV", PMPCODEC_WAV, &lines) < 0) { + return -1; + } + return 0; } @@ -508,6 +533,12 @@ goto error_exit; } + /* Initialize Codec class. */ + if (jspl_init_codec_class(jspl) != 0) { + ret = PLAYLIST_E_JSINITENGINE; + goto error_exit; + } + /* Initialize other fields. */ jspl->path_to_include = path_to_include; jspl->callback = callback; Modified: trunk/lib/pmp_portalplayer1/hdr_template.h =================================================================== --- trunk/lib/pmp_portalplayer1/hdr_template.h 2006-05-03 14:42:46 UTC (rev 10) +++ trunk/lib/pmp_portalplayer1/hdr_template.h 2006-05-05 09:01:00 UTC (rev 11) @@ -67,10 +67,11 @@ int hdr_init_medion_mdjuke220(hdr_t* hdr); int hdr_init_medion_mdjuke440(hdr_t* hdr); int hdr_init_samsung_yh820(hdr_t* hdr); +int hdr_init_samsung_yh925(hdr_t* hdr); int hdr_init_sirius_s50(hdr_t* hdr); int iriver_h10_parse_model(const ucs2char_t* firmware, pp1model_t* model); int medion_mdjuke220_parse_model(const ucs2char_t* firmware, pp1model_t* model); -int samsung_yh820_parse_model(const ucs2char_t* firmware, pp1model_t* model); +int samsung_parse_model(const ucs2char_t* firmware, pp1model_t* model); #endif/*__HDR_TEMPLATE_H__*/ Copied: trunk/lib/pmp_portalplayer1/model_samsung.c (from rev 10, trunk/lib/pmp_portalplayer1/model_samsung_yh820.c) =================================================================== --- trunk/lib/pmp_portalplayer1/model_samsung.c (rev 0) +++ trunk/lib/pmp_portalplayer1/model_samsung.c 2006-05-05 09:01:00 UTC (rev 11) @@ -0,0 +1,272 @@ +/* + * Samsung YH-820/YH-925 specific routines and header templates. + * + * Copyright (c) 2005-2006 Nyaochi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif/*HAVE_CONFIG_H*/ + +#include <os.h> +#include <stdio.h> +#include <stdlib.h> +#include <ucs2char.h> +#include <filepath.h> + +#include "serialize.h" +#include "util.h" +#include "pp1db.h" +#include "hdr_template.h" + +enum { + PP1DB_DATFIELD_UNKNOWN2 = 0,// @0: (INT) + PP1DB_DATFIELD_PATHNAME, // @1: (STR) + PP1DB_DATFIELD_FILENAME, // @2: (STR) + PP1DB_DATFIELD_FORMAT, // @3: (INT) + PP1DB_DATFIELD_BITRATE, // @4: (INT) + PP1DB_DATFIELD_SAMPLERATE, // @5: (INT) + PP1DB_DATFIELD_DURATION, // @6: (INT) + PP1DB_DATFIELD_ARTIST, // @7: (STR) + PP1DB_DATFIELD_ALBUM, // @8: (STR) + PP1DB_DATFIELD_GENRE, // @9: (STR) + PP1DB_DATFIELD_TITLE, // @10: (STR) + PP1DB_DATFIELD_TRACKNUMBER, // @11: (INT) + PP1DB_DATFIELD_YEAR, // @12: (INT) + PP1DB_DATFIELD_FILESIZE, // @13: (INT) + PP1DB_DATFIELD_UNKNOWN4, // @14: (INT) + PP1DB_DATFIELD_UNKNOWN5, // @15: (STR) + PP1DB_DATFIELD_UNKNOWN6, // @16: (STR) + PP1DB_DATFIELD_UNKNOWN7, // @17: (STR) +}; + +static void samsung_dat_repr(const dat_t* record, FILE *fp) +{ + fprintf(fp, " inactive: %d\n", record->status); + fprintf(fp, " unknown1: %d\n", record->unknown1); + fprintf(fp, " unknown2: %d\n", record->fields[PP1DB_DATFIELD_UNKNOWN2].value.dword); + fprints(fp, " file_path: %s\n", record->fields[PP1DB_DATFIELD_PATHNAME].value.str); + fprints(fp, " file_name: %s\n", record->fields[PP1DB_DATFIELD_FILENAME].value.str); + fprintf(fp, " media_type: %d\n", record->fields[PP1DB_DATFIELD_FORMAT].value.dword); + fprintf(fp, " bitrate: %d\n", record->fields[PP1DB_DATFIELD_BITRATE].value.dword); + fprintf(fp, " samplerate: %d\n", record->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword); + fprintf(fp, " duration: %d\n", record->fields[PP1DB_DATFIELD_DURATION].value.dword); + fprints(fp, " artist: %s\n", record->fields[PP1DB_DATFIELD_ARTIST].value.str); + fprints(fp, " album: %s\n", record->fields[PP1DB_DATFIELD_ALBUM].value.str); + fprints(fp, " genre: %s\n", record->fields[PP1DB_DATFIELD_GENRE].value.str); + fprints(fp, " title: %s\n", record->fields[PP1DB_DATFIELD_TITLE].value.str); + fprintf(fp, " number: %d\n", record->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword); + fprintf(fp, " year: %d\n", record->fields[PP1DB_DATFIELD_YEAR].value.dword); + fprintf(fp, " filesize: %d\n", record->fields[PP1DB_DATFIELD_FILESIZE].value.dword); + fprintf(fp, " unknown4: %d\n", record->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword); + fprints(fp, " unknown5: %s\n", record->fields[PP1DB_DATFIELD_UNKNOWN5].value.str); + fprints(fp, " unknown6: %s\n", record->fields[PP1DB_DATFIELD_UNKNOWN6].value.str); + fprints(fp, " unknown7: %s\n", record->fields[PP1DB_DATFIELD_UNKNOWN7].value.str); +} + +static int samsung_dat_set(dat_t* dst, const pmp_record_t* src, const ucs2char_t* path_to_root) +{ + static const ucs2char_t ucs2cs_unknown[] = {0}; + static const ucs2char_t ucs2cs_empty[] = {0}; + + // Set fields. + dst->status = 0; + dst->unknown1 = 0; + dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root)); + filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); + filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); + filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); + dst->fields[PP1DB_DATFIELD_FILENAME].value.str = ucs2dup(filepath_skippath(src->filename)); + dst->fields[PP1DB_DATFIELD_FORMAT].value.dword = 0; + dst->fields[PP1DB_DATFIELD_BITRATE].value.dword = src->bitrate; + dst->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword = src->sample_rate; + dst->fields[PP1DB_DATFIELD_DURATION].value.dword = src->duration; + dst->fields[PP1DB_DATFIELD_ARTIST].value.str = ucs2dup(src->artist ? src->artist : ucs2cs_unknown); + dst->fields[PP1DB_DATFIELD_ALBUM].value.str = ucs2dup(src->album ? src->album : ucs2cs_unknown); + dst->fields[PP1DB_DATFIELD_GENRE].value.str = ucs2dup(src->genre ? src->genre : ucs2cs_unknown); + dst->fields[PP1DB_DATFIELD_TITLE].value.str = ucs2dup(src->title ? src->title : dst->fields[PP1DB_DATFIELD_FILENAME].value.str); + dst->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword = src->track_number; + if (src->date) { + dst->fields[PP1DB_DATFIELD_YEAR].value.dword = ucs2toi(src->date); + } + dst->fields[PP1DB_DATFIELD_FILESIZE].value.dword = src->filesize; + dst->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword = 0; + dst->fields[PP1DB_DATFIELD_UNKNOWN5].value.str = ucs2dup(ucs2cs_empty); + dst->fields[PP1DB_DATFIELD_UNKNOWN6].value.str = ucs2dup(ucs2cs_empty); + dst->fields[PP1DB_DATFIELD_UNKNOWN7].value.str = ucs2dup(ucs2cs_empty); + return 0; +} + +static int samsung_dat_get(pmp_record_t* dst, const dat_t* src, const ucs2char_t* path_to_root) +{ + static const ucs2char_t ucs2cs_mp3[] = {'.','m','p','3',0}; + static const ucs2char_t ucs2cs_wma[] = {'.','w','m','a',0}; + static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; + ucs2char_t tmp[128]; + size_t length = 0; + + length = ucs2len(path_to_root); + length += ucs2len(src->fields[PP1DB_DATFIELD_PATHNAME].value.str); + length += ucs2len(src->fields[PP1DB_DATFIELD_FILENAME].value.str); + length += 3; + + dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * length); + if (dst->filename) { + filepath_combinepath(dst->filename, length, path_to_root, src->fields[PP1DB_DATFIELD_PATHNAME].value.str); + filepath_addslash(dst->filename); + ucs2cat(dst->filename, src->fields[PP1DB_DATFIELD_FILENAME].value.str); + } + + dst->bitrate = src->fields[PP1DB_DATFIELD_BITRATE].value.dword; + dst->sample_rate = src->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword; + dst->duration = ucs2toi(src->fields[PP1DB_DATFIELD_DURATION].value.str); + + dst->artist = ucs2dup(src->fields[PP1DB_DATFIELD_ARTIST].value.str); + dst->album = ucs2dup(src->fields[PP1DB_DATFIELD_ALBUM].value.str); + dst->genre = ucs2dup(src->fields[PP1DB_DATFIELD_GENRE].value.str); + dst->title = ucs2dup(src->fields[PP1DB_DATFIELD_TITLE].value.str); + + // Set codec information according to the file extensions. + if (filepath_hasext(dst->filename, ucs2cs_mp3)) { + dst->codec = PMPCODEC_MPEGLAYER3; + } else if (filepath_hasext(dst->filename, ucs2cs_wma)) { + dst->codec = PMPCODEC_WMA; + } else if (filepath_hasext(dst->filename, ucs2cs_wav)) { + dst->codec = PMPCODEC_WAV; + } + + dst->track_number = src->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword; + itoucs2(src->fields[PP1DB_DATFIELD_YEAR].value.dword, tmp, 10); + dst->date = ucs2dup(tmp); + dst->filesize = src->fields[PP1DB_DATFIELD_FILESIZE].value.dword; + + return 0; +} + +int samsung_parse_model(const ucs2char_t* firmware, pp1model_t* model) +{ + FILE *fp = ucs2fopen(firmware, "rb"); + if (fp) { + char line[33], *p = NULL, *q = NULL; + memset(line, 0, sizeof(line)); + + // Seek to the firmware information. + if (fseek(fp, 0x0220, SEEK_SET) != 0) { + fclose(fp); + return 0; + } + + // Read the firmware information. + if (fread(line, sizeof(char), 32, fp) != 32) { + fclose(fp); + return 0; + } + + // Close the firmware. + fclose(fp); + + // Obtain the model name. + strcpy(model->name, "Samsung "); + strcat(model->name, line); + p = line + strlen(line) + 1; + + // Obtain firmware version. + q = strchr(p, ' '); + if (q) { + *q = 0; + } else { + return 0; + } + strcpy(model->version, p); + p = q+1; + + // Obtain the country code? + q = strchr(p, 0xC0); + if (q) { + *q = 0; + } else { + return 0; + } + strcpy(model->language, p); + + strcpy(model->mode, "UM"); + + return 1; + } else { + return 0; + } +} + + + + +static fd_template_t hdrtmpl_fd_samsung[] = { + {0x0000F001, 2, 4, 0, 0, 1, 0, 0, "System\\DATA\\PP...@DE...x"}, + {0x0000F002, 1, 128, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FPTH.idx"}, + {0x0000F003, 1, 128, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FNAM.idx"}, + {0x0000F00A, 2, 4, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FRMT.idx"}, + {0x0000F005, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000F006, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000F007, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000003C, 1, 40, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TPE1.idx"}, + {0x0000001C, 1, 40, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TALB.idx"}, + {0x0000001F, 1, 20, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TCON.idx"}, + {0x0000002E, 1, 40, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TIT2.idx"}, + {0x00000043, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000004E, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000F009, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000E000, 2, 4, 0, 0, 0, 0, 0, ""}, + {0x0000E001, 1, 40, 0, 0, 0, 0, 0, ""}, + {0x00000083, 1, 10, 0, 0, 0, 0, 0, ""}, + {0x00000084, 1, 64, 0, 0, 0, 0, 0, ""}, +}; + +static uint32_t hdrtmpl_max_dat_field_size_samsung[] = + {8, 12, 268, 524, 528, 532, 536, 540, 620, 700, 740, 820, 824, 828, 832, 836, 916, 936}; + + +/********** Samsung YH-820 firmware 3.00 **********/ +static hdr_template_t hdrtmpl_samsung_yh820 = { + 0, 0, "System\\DATA\\PP5000.DAT", 0, "System\\DATA\\PP5000.HDR", 0x00000428, 0, 0, 18, + hdrtmpl_fd_samsung, + hdrtmpl_max_dat_field_size_samsung, + 0, 0, + {251956, 18, 6000, 1032, 0, samsung_dat_repr, samsung_dat_set, samsung_dat_get}, +}; + +/********** Samsung YH-925 firmware 1.61 **********/ +static hdr_template_t hdrtmpl_samsung_yh925 = { + 0, 0, "System\\DATA\\PP5000.DAT", 1, "System\\DATA\\PP5000.HDR", 0x00000428, 0, 0, 18, + hdrtmpl_fd_samsung, + hdrtmpl_max_dat_field_size_samsung, + 0, 0, + {251956, 18, 6000, 1032, 0, samsung_dat_repr, samsung_dat_set, samsung_dat_get}, +}; + +int hdr_init_samsung_yh820(hdr_t* hdr) +{ + return apply_template(hdr, &hdrtmpl_samsung_yh820); +} + +int hdr_init_samsung_yh925(hdr_t* hdr) +{ + return apply_template(hdr, &hdrtmpl_samsung_yh925); +} + Property changes on: trunk/lib/pmp_portalplayer1/model_samsung.c ___________________________________________________________________ Name: svn:keywords + Id Deleted: trunk/lib/pmp_portalplayer1/model_samsung_yh820.c =================================================================== --- trunk/lib/pmp_portalplayer1/model_samsung_yh820.c 2006-05-03 14:42:46 UTC (rev 10) +++ trunk/lib/pmp_portalplayer1/model_samsung_yh820.c 2006-05-05 09:01:00 UTC (rev 11) @@ -1,219 +0,0 @@ -/* - * Samsung YH-820 specific routines and header templates. - * - * Copyright (c) 2005-2006 Nyaochi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/* $Id: model_medion_mdjuke440.c 5 2006-03-31 05:41:31Z nyaochi $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif/*HAVE_CONFIG_H*/ - -#include <os.h> -#include <stdio.h> -#include <stdlib.h> -#include <ucs2char.h> -#include <filepath.h> - -#include "serialize.h" -#include "util.h" -#include "pp1db.h" -#include "hdr_template.h" - -enum { - PP1DB_DATFIELD_UNKNOWN2 = 0,// @0: (INT) - PP1DB_DATFIELD_PATHNAME, // @1: (STR) - PP1DB_DATFIELD_FILENAME, // @2: (STR) - PP1DB_DATFIELD_FORMAT, // @3: (INT) - PP1DB_DATFIELD_BITRATE, // @4: (INT) - PP1DB_DATFIELD_SAMPLERATE, // @5: (INT) - PP1DB_DATFIELD_DURATION, // @6: (INT) - PP1DB_DATFIELD_ARTIST, // @7: (STR) - PP1DB_DATFIELD_ALBUM, // @8: (STR) - PP1DB_DATFIELD_GENRE, // @9: (STR) - PP1DB_DATFIELD_TITLE, // @10: (STR) - PP1DB_DATFIELD_TRACKNUMBER, // @11: (INT) - PP1DB_DATFIELD_YEAR, // @12: (INT) - PP1DB_DATFIELD_FILESIZE, // @13: (INT) - PP1DB_DATFIELD_UNKNOWN4, // @14: (INT) - PP1DB_DATFIELD_UNKNOWN5, // @15: (STR) - PP1DB_DATFIELD_UNKNOWN6, // @16: (STR) - PP1DB_DATFIELD_UNKNOWN7, // @17: (STR) -}; - -void samsung_yh820_dat_repr(const dat_t* record, FILE *fp) -{ - fprintf(fp, " inactive: %d\n", record->status); - fprintf(fp, " unknown1: %d\n", record->unknown1); - fprintf(fp, " unknown2: %d\n", record->fields[PP1DB_DATFIELD_UNKNOWN2].value.dword); - fprints(fp, " file_path: %s\n", record->fields[PP1DB_DATFIELD_PATHNAME].value.str); - fprints(fp, " file_name: %s\n", record->fields[PP1DB_DATFIELD_FILENAME].value.str); - fprintf(fp, " media_type: %d\n", record->fields[PP1DB_DATFIELD_FORMAT].value.dword); - fprintf(fp, " bitrate: %d\n", record->fields[PP1DB_DATFIELD_BITRATE].value.dword); - fprintf(fp, " samplerate: %d\n", record->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword); - fprintf(fp, " duration: %d\n", record->fields[PP1DB_DATFIELD_DURATION].value.dword); - fprints(fp, " artist: %s\n", record->fields[PP1DB_DATFIELD_ARTIST].value.str); - fprints(fp, " album: %s\n", record->fields[PP1DB_DATFIELD_ALBUM].value.str); - fprints(fp, " genre: %s\n", record->fields[PP1DB_DATFIELD_GENRE].value.str); - fprints(fp, " title: %s\n", record->fields[PP1DB_DATFIELD_TITLE].value.str); - fprintf(fp, " number: %d\n", record->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword); - fprintf(fp, " year: %d\n", record->fields[PP1DB_DATFIELD_YEAR].value.dword); - fprintf(fp, " filesize: %d\n", record->fields[PP1DB_DATFIELD_FILESIZE].value.dword); - fprintf(fp, " unknown4: %d\n", record->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword); - fprints(fp, " unknown5: %s\n", record->fields[PP1DB_DATFIELD_UNKNOWN5].value.str); - fprints(fp, " unknown6: %s\n", record->fields[PP1DB_DATFIELD_UNKNOWN6].value.str); - fprints(fp, " unknown7: %s\n", record->fields[PP1DB_DATFIELD_UNKNOWN7].value.str); -} - -int samsung_yh820_dat_set(dat_t* dst, const pmp_record_t* src, const ucs2char_t* path_to_root) -{ - static const ucs2char_t ucs2cs_unknown[] = {0}; - static const ucs2char_t ucs2cs_empty[] = {0}; - - // Set fields. - dst->status = 0; - dst->unknown1 = 0; - dst->fields[PP1DB_DATFIELD_PATHNAME].value.str = ucs2dup(filepath_skiproot(src->filename, path_to_root)); - filepath_remove_filespec(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); - filepath_addslash(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); - filepath_encode(dst->fields[PP1DB_DATFIELD_PATHNAME].value.str); - dst->fields[PP1DB_DATFIELD_FILENAME].value.str = ucs2dup(filepath_skippath(src->filename)); - dst->fields[PP1DB_DATFIELD_FORMAT].value.dword = 0; - dst->fields[PP1DB_DATFIELD_BITRATE].value.dword = src->bitrate; - dst->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword = src->sample_rate; - dst->fields[PP1DB_DATFIELD_DURATION].value.dword = src->duration; - dst->fields[PP1DB_DATFIELD_ARTIST].value.str = ucs2dup(src->artist ? src->artist : ucs2cs_unknown); - dst->fields[PP1DB_DATFIELD_ALBUM].value.str = ucs2dup(src->album ? src->album : ucs2cs_unknown); - dst->fields[PP1DB_DATFIELD_GENRE].value.str = ucs2dup(src->genre ? src->genre : ucs2cs_unknown); - dst->fields[PP1DB_DATFIELD_TITLE].value.str = ucs2dup(src->title ? src->title : dst->fields[PP1DB_DATFIELD_FILENAME].value.str); - dst->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword = src->track_number; - if (src->date) { - dst->fields[PP1DB_DATFIELD_YEAR].value.dword = ucs2toi(src->date); - } - dst->fields[PP1DB_DATFIELD_FILESIZE].value.dword = src->filesize; - dst->fields[PP1DB_DATFIELD_UNKNOWN4].value.dword = 0; - dst->fields[PP1DB_DATFIELD_UNKNOWN5].value.str = ucs2dup(ucs2cs_empty); - dst->fields[PP1DB_DATFIELD_UNKNOWN6].value.str = ucs2dup(ucs2cs_empty); - dst->fields[PP1DB_DATFIELD_UNKNOWN7].value.str = ucs2dup(ucs2cs_empty); - return 0; -} - -int samsung_yh820_dat_get(pmp_record_t* dst, const dat_t* src, const ucs2char_t* path_to_root) -{ - static const ucs2char_t ucs2cs_mp3[] = {'.','m','p','3',0}; - static const ucs2char_t ucs2cs_wma[] = {'.','w','m','a',0}; - static const ucs2char_t ucs2cs_wav[] = {'.','w','a','v',0}; - ucs2char_t tmp[128]; - size_t length = 0; - - length = ucs2len(path_to_root); - length += ucs2len(src->fields[PP1DB_DATFIELD_PATHNAME].value.str); - length += ucs2len(src->fields[PP1DB_DATFIELD_FILENAME].value.str); - length += 3; - - dst->filename = (ucs2char_t*)ucs2malloc(sizeof(ucs2char_t) * length); - if (dst->filename) { - filepath_combinepath(dst->filename, length, path_to_root, src->fields[PP1DB_DATFIELD_PATHNAME].value.str); - filepath_addslash(dst->filename); - ucs2cat(dst->filename, src->fields[PP1DB_DATFIELD_FILENAME].value.str); - } - - dst->bitrate = src->fields[PP1DB_DATFIELD_BITRATE].value.dword; - dst->sample_rate = src->fields[PP1DB_DATFIELD_SAMPLERATE].value.dword; - dst->duration = ucs2toi(src->fields[PP1DB_DATFIELD_DURATION].value.str); - - dst->artist = ucs2dup(src->fields[PP1DB_DATFIELD_ARTIST].value.str); - dst->album = ucs2dup(src->fields[PP1DB_DATFIELD_ALBUM].value.str); - dst->genre = ucs2dup(src->fields[PP1DB_DATFIELD_GENRE].value.str); - dst->title = ucs2dup(src->fields[PP1DB_DATFIELD_TITLE].value.str); - - // Set codec information according to the file extensions. - if (filepath_hasext(dst->filename, ucs2cs_mp3)) { - dst->codec = PMPCODEC_MPEGLAYER3; - } else if (filepath_hasext(dst->filename, ucs2cs_wma)) { - dst->codec = PMPCODEC_WMA; - } else if (filepath_hasext(dst->filename, ucs2cs_wav)) { - dst->codec = PMPCODEC_WAV; - } - - dst->track_number = src->fields[PP1DB_DATFIELD_TRACKNUMBER].value.dword; - itoucs2(src->fields[PP1DB_DATFIELD_YEAR].value.dword, tmp, 10); - dst->date = ucs2dup(tmp); - dst->filesize = src->fields[PP1DB_DATFIELD_FILESIZE].value.dword; - - return 0; -} - -int samsung_yh820_parse_model(const ucs2char_t* firmware, pp1model_t* model) -{ - FILE *fp = ucs2fopen(firmware, "rb"); - if (fp) { - // We cannot find a way to parse the firmware for now. - strcpy(model->name, "Samsung YH-820"); - strcpy(model->version, "0.0"); - strcpy(model->mode, "UM"); - - fclose(fp); - return 1; - } else { - return 0; - } -} - - - - -static fd_template_t hdrtmpl_fd_yh820[] = { - {0x0000F001, 2, 4, 0, 0, 1, 0, 0, "System\\DATA\\PP...@DE...x"}, - {0x0000F002, 1, 128, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FPTH.idx"}, - {0x0000F003, 1, 128, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FNAM.idx"}, - {0x0000F00A, 2, 4, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_FRMT.idx"}, - {0x0000F005, 2, 4, 0, 0, 0, 0, 0, ""}, - {0x0000F006, 2, 4, 0, 0, 0, 0, 0, ""}, - {0x0000F007, 2, 4, 0, 0, 0, 0, 0, ""}, - {0x0000003C, 1, 40, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TPE1.idx"}, - {0x0000001C, 1, 40, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TALB.idx"}, - {0x0000001F, 1, 20, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TCON.idx"}, - {0x0000002E, 1, 40, 0, 0, 1, 0, 0, "System\\DATA\\PP5000_TIT2.idx"}, - {0x00000043, 2, 4, 0, 0, 0, 0, 0, ""}, - {0x0000004E, 2, 4, 0, 0, 0, 0, 0, ""}, - {0x0000F009, 2, 4, 0, 0, 0, 0, 0, ""}, - {0x0000E000, 2, 4, 0, 0, 0, 0, 0, ""}, - {0x0000E001, 1, 40, 0, 0, 0, 0, 0, ""}, - {0x00000083, 1, 10, 0, 0, 0, 0, 0, ""}, - {0x00000084, 1, 64, 0, 0, 0, 0, 0, ""}, -}; - -static uint32_t hdrtmpl_max_dat_field_size_yh820[] = - {8, 12, 268, 524, 528, 532, 536, 540, 620, 700, 740, 820, 824, 828, 832, 836, 916, 936}; - - -/********** Samsung YH-820 firmware 0.0 **********/ -static hdr_template_t hdrtmpl_samsung_yh820 = { - 0, 0, "System\\DATA\\PP5000.DAT", 0, "System\\DATA\\PP5000.HDR", 0x00000428, 0, 0, 18, - hdrtmpl_fd_yh820, - hdrtmpl_max_dat_field_size_yh820, - 0, 0, - {251956, 18, 6000, 1032, 0, samsung_yh820_dat_repr, samsung_yh820_dat_set, samsung_yh820_dat_get}, -}; -int hdr_init_samsung_yh820(hdr_t* hdr) -{ - return apply_template(hdr, &hdrtmpl_samsung_yh820); -} - Modified: trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c =================================================================== --- trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c 2006-05-03 14:42:46 UTC (rev 10) +++ trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c 2006-05-05 09:01:00 UTC (rev 11) @@ -141,13 +141,21 @@ hdr_init_medion_mdjuke440, medion_mdjuke220_parse_model }, { - "samsung_yh820", "Samsung YH820", + "samsung_yh820", "Samsung YH-820", 5, "UM", - "0.0", "0.0", + "3.00", "3.00", "SYSTEM\\FW_YH820.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", ".plp", - hdr_init_samsung_yh820, samsung_yh820_parse_model + hdr_init_samsung_yh820, samsung_parse_model }, + { + "samsung_yh925", "Samsung YH-925", + 5, "UM", + "1.61", "1.61", + "SYSTEM\\FW_YH925.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", + ".plp", + hdr_init_samsung_yh925, samsung_parse_model + }, #if 0 { "sirius_s50", "Sirius S50", Modified: trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj =================================================================== --- trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2006-05-03 14:42:46 UTC (rev 10) +++ trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2006-05-05 09:01:00 UTC (rev 11) @@ -144,7 +144,7 @@ RelativePath=".\model_medion_mdjuke440.c"> </File> <File - RelativePath=".\model_samsung_yh820.c"> + RelativePath=".\model_samsung.c"> </File> <File RelativePath=".\model_sirius_s50.c"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-05-05 13:35:26
|
Revision: 12 Author: nyaochi Date: 2006-05-05 06:35:12 -0700 (Fri, 05 May 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=12&view=rev Log Message: ----------- - Retrival of JSPL include path for Win32 CUI version. - Better criterion to distinguish Array (single playlist) and Object (multiple playlists). Modified Paths: -------------- trunk/frontend/easypmp/cui/main.c trunk/frontend/easypmp/cui/option.c trunk/frontend/easypmp/win32gui/processingdlg.h trunk/lib/playlist/jspl.c Modified: trunk/frontend/easypmp/cui/main.c =================================================================== --- trunk/frontend/easypmp/cui/main.c 2006-05-05 09:01:00 UTC (rev 11) +++ trunk/frontend/easypmp/cui/main.c 2006-05-05 13:35:12 UTC (rev 12) @@ -272,6 +272,19 @@ } filepath_addslash(opt.path_to_root); + // Generate the path_to_include + if (!opt.path_to_include[0]) { +#ifdef _WIN32 + ucs2char_t ucs2cs_jspl[] = {'j','s','p','l',0}; + + GetModuleFileNameW(GetModuleHandle(NULL), opt.path_to_include, MAX_PATH); + filepath_remove_filespec(opt.path_to_include); + filepath_addslash(opt.path_to_include); + ucs2cat(opt.path_to_include, ucs2cs_jspl); + filepath_addslash(opt.path_to_include); +#endif + } + // Create a PMP instance. pmphelp_create(pmphelp, &pmp, opt.path_to_root, opt.model); if (!pmp) { Modified: trunk/frontend/easypmp/cui/option.c =================================================================== --- trunk/frontend/easypmp/cui/option.c 2006-05-05 09:01:00 UTC (rev 11) +++ trunk/frontend/easypmp/cui/option.c 2006-05-05 13:35:12 UTC (rev 12) @@ -99,19 +99,6 @@ opt->media_info_source |= GMIF_TAG; - if (!opt->path_to_include[0]) { - char pwd[MAX_PATH+1]; - ucs2char_t ucs2pwd[MAX_PATH+1]; - ucs2char_t ucs2argv0[MAX_PATH+1]; - - getcwd(pwd, MAX_PATH); - mbstoucs2(ucs2pwd, MAX_PATH, pwd, strlen(pwd)+1); - mbstoucs2(ucs2argv0, MAX_PATH, argv[0], strlen(argv[0])+1); - filepath_relative_to_absolute(opt->path_to_include, ucs2pwd, ucs2argv0); - - filepath_remove_filespec(opt->path_to_include); - } - /* Parse the command-line arguments. */ for (;;) { int this_option_optind = optind ? optind : 1; Modified: trunk/frontend/easypmp/win32gui/processingdlg.h =================================================================== --- trunk/frontend/easypmp/win32gui/processingdlg.h 2006-05-05 09:01:00 UTC (rev 11) +++ trunk/frontend/easypmp/win32gui/processingdlg.h 2006-05-05 13:35:12 UTC (rev 12) @@ -284,6 +284,9 @@ // Set path to the include folder. ::GetModuleFileNameW(_Module.GetModuleInstance(), opt.path_to_include, MAX_PATH); ::PathRemoveFileSpecW(opt.path_to_include); + ::PathAddBackslashW(opt.path_to_include); + ucs2cat(opt.path_to_include, A2W("jspl")); + ::PathAddBackslashW(opt.path_to_include); // Set model if (!m_preference.strPlayerIdentifier.IsEmpty()) { Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-05-05 09:01:00 UTC (rev 11) +++ trunk/lib/playlist/jspl.c 2006-05-05 13:35:12 UTC (rev 12) @@ -114,8 +114,25 @@ static int object_is_array(JSContext* cx, JSObject* obj) { - jsuint length; - return JS_HasArrayLength(cx, obj, &length) ? 1 : 0; + JSClass *jsclass = NULL; + +#ifdef JS_THREADSAFE + jsclass = JS_GetClass(cx, obj); +#else + jsclass = JS_GetClass(obj); +#endif + + if (strcmp(jsclass->name, "Array") == 0) { + return 1; + } else { + jsint length = 0; + if (JS_GetArrayLength(cx, obj, &length)) { + if (length > 0) { + return 1; + } + } + } + return 0; } static JSBool This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-05-05 13:54:35
|
Revision: 13 Author: nyaochi Date: 2006-05-05 06:54:22 -0700 (Fri, 05 May 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=13&view=rev Log Message: ----------- Added sample JSPL files. Added Paths: ----------- trunk/lib/playlist/sample/ trunk/lib/playlist/sample/artist.jspl trunk/lib/playlist/sample/artists.jspl trunk/lib/playlist/sample/top_ranking.jspl Added: trunk/lib/playlist/sample/artist.jspl =================================================================== --- trunk/lib/playlist/sample/artist.jspl (rev 0) +++ trunk/lib/playlist/sample/artist.jspl 2006-05-05 13:54:22 UTC (rev 13) @@ -0,0 +1,39 @@ +/* + * Artist playlist + * + * This JSPL extracts tracks performed by the artist whose name is + * is specified by either variable 'artist_name' or filename of this JSPL. + * + */ + +// Change this to specify the artist name +var artist_name = ""; + +include("playlist.js"); + +function main(media, source) +{ + // Check artist_name. + if (!artist_name) { + // Retrieve an artist name from the filename. + var begin = 0, end = source.length; + for (var i = 0;i < source.length;++i) { + if (source[i] == '\\' || source[i] == '/') + begin = i; + if (source[i] == '.') + end = i; + } + artist_name = source.slice(begin, end); + } + + // Convert the artist name to lower case. + artist_name = artist_name.toLowerCase(); + + var pl = new Playlist(); + for (var i = 0;i < media.length;++i) + if (media[i].artist.toLowerCase() == artist_name) + pl.push(media[i]); + pl.order("album", "track_number"); + + return pl; +} Added: trunk/lib/playlist/sample/artists.jspl =================================================================== --- trunk/lib/playlist/sample/artists.jspl (rev 0) +++ trunk/lib/playlist/sample/artists.jspl 2006-05-05 13:54:22 UTC (rev 13) @@ -0,0 +1,29 @@ +/* + * Artists playlist + * + * This JSPL generates multiple playlists each of which collects tracks + * performed by an artist. + * + */ + +include("playlist.js"); + +function main(media, playlist) +{ + var pls = new Object(); + + for (var i = 0;i < media.length;++i) { + var artist = media[i].artist.toLowerCase(); + var pl = pls[artist]; + if (pl == undefined) + pl = pls[artist] = new Playlist(); + pl.push(media[i]); + } + + for (var name in pls) { + var pl = pls[name]; + pl.order("album", "track_number"); + } + + return pls; +} Added: trunk/lib/playlist/sample/top_ranking.jspl =================================================================== --- trunk/lib/playlist/sample/top_ranking.jspl (rev 0) +++ trunk/lib/playlist/sample/top_ranking.jspl 2006-05-05 13:54:22 UTC (rev 13) @@ -0,0 +1,26 @@ +/* + * Top ranking playlist + * + * This playlist uses play_count field to generate a ranking playlist. + * The play_count field is currently set by iRiver H10, H10Jr, and U10. + * + */ + + +// Change this to specify the number of top tracks. +var num_top = 50; + +include("playlist.js"); + +function main(media, source) +{ + var pl = new Playlist(); + + for (var i = 0;i < media.length;++i) + pl.push(media[i]); + + pl.order("-play_count"); + + var end = Math.min(pl.length, num_top); + return pl.slice(0, end); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ny...@us...> - 2006-06-04 01:06:34
|
Revision: 35 Author: nyaochi Date: 2006-06-03 18:06:17 -0700 (Sat, 03 Jun 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=35&view=rev Log Message: ----------- - Fixed Win32 build - A symbol indicating the build environment must be defined before '#include <jsapi.h>' Modified Paths: -------------- trunk/lib/playlist/jspl.c trunk/lib/playlist/playlist.vcproj Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-06-03 23:57:29 UTC (rev 34) +++ trunk/lib/playlist/jspl.c 2006-06-04 01:06:17 UTC (rev 35) @@ -37,17 +37,7 @@ #include <pmp.h> #include <playlist.h> -#ifdef USE_INTERNAL_SMJS -// Build against the in-tree copy of SMJS on Windows. -#define XP_WIN -#include <js/jsapi.h> -#else -/* Build against external Javascript library headers. - XP_UNIX is already defined if we found them by pkgconfig, - but #define here just in case we didn't... */ -#define XP_UNIX #include <jsapi.h> -#endif #define MAX_SOURCE_DEPTH 64 Modified: trunk/lib/playlist/playlist.vcproj =================================================================== --- trunk/lib/playlist/playlist.vcproj 2006-06-03 23:57:29 UTC (rev 34) +++ trunk/lib/playlist/playlist.vcproj 2006-06-04 01:06:17 UTC (rev 35) @@ -19,8 +19,8 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="$(SolutionDir)include,.\contrib" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLAYLIST_EXPORTS" + AdditionalIncludeDirectories="$(SolutionDir)include,.\contrib\js" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLAYLIST_EXPORTS;XP_WIN" MinimalRebuild="TRUE" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -69,8 +69,8 @@ CharacterSet="2"> <Tool Name="VCCLCompilerTool" - AdditionalIncludeDirectories="$(SolutionDir)include,.\contrib" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLAYLIST_EXPORTS" + AdditionalIncludeDirectories="$(SolutionDir)include,.\contrib\js" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLAYLIST_EXPORTS;XP_WIN" RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Martin E. <ma...@el...> - 2006-06-04 01:51:52
|
On Sunday 04 June 2006 02:06, ny...@us... wrote: > Log Message: > ----------- > - Fixed Win32 build > - A symbol indicating the build environment must be defined before > '#include <jsapi.h>' Hmm. What should be defined when building on Cygwin? XP_WIN or XP_UNIX? I'm not sure how we could do XP_WIN.... Martin |
From: <ny...@us...> - 2006-06-04 01:31:06
|
Revision: 37 Author: nyaochi Date: 2006-06-03 18:30:52 -0700 (Sat, 03 Jun 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=37&view=rev Log Message: ----------- - Changed "lib/playlist/sample" folder to "lib/playlist/jspl". - Added "playlist.js" to the folder. Added Paths: ----------- trunk/lib/playlist/jspl/ trunk/lib/playlist/jspl/playlist.js Removed Paths: ------------- trunk/lib/playlist/sample/ Copied: trunk/lib/playlist/jspl (from rev 34, trunk/lib/playlist/sample) Added: trunk/lib/playlist/jspl/playlist.js =================================================================== --- trunk/lib/playlist/jspl/playlist.js (rev 0) +++ trunk/lib/playlist/jspl/playlist.js 2006-06-04 01:30:52 UTC (rev 37) @@ -0,0 +1,68 @@ +/** + * Playlist class object. + */ +Playlist.prototype = new Array(); + +function Playlist() { + /** + * Order tracks in an arbitrary order specified by the arguments. + * This method sorts tracks in an arbitrary order by comparing field(s) in + * + * @param [arguments] Field name(s) used for sorting tracks. + */ + this.order = function() + { + // Extract field names for the comparison from the arguments. + var fields = arguments; + + // Sort the elements by using an anonymous function for the comparison. + return this.sort( + function(x, y) { + var ret = 0; // Comparison result. + // Loop over field names. + for (var i = 0;i < fields.length;++i) { + var coeff = 1; // Sorting direction. + var field = fields[i]; // Field name for sorting. + if (field[0] == '-') { + coeff = -1; + field = field.slice(1); + } else { + coeff = +1; + } + + // Compare field values of two objects, x and y. + ret = ((x[field])>(y[field]))-((x[field])<(y[field])); + // Inverse the result when descending sort. + ret *= coeff; + + // Exit if the two values are not identical. + if (ret != 0) { + break; + } + } + // Return the comparison result. + return ret; + } + ); + }; + + this.shuffle = function() + { + // Assign a random number for each track. + for (var i = 0;i < this.length;++i) { + this[i].order = Math.random(); + } + + // Arrange the tracks in a numerical order of the assigned numbers. + this.sort( + function(x, y) { + return ((x.order)>(y.order))-((x.order)<(y.order)); + } + ); + + // Remove the assigned number from each track. + for (var i = 0;i < this.length;++i) { + delete this[i].order; + } + }; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |