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. |