From: <ny...@us...> - 2006-05-03 14:42:59
|
Revision: 10 Author: nyaochi Date: 2006-05-03 07:42:46 -0700 (Wed, 03 May 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=10&view=rev Log Message: ----------- Attempt to support Samsung YH-820 player. Modified Paths: -------------- trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc trunk/frontend/easypmp/win32gui/processingdlg.h trunk/lib/pmp_portalplayer1/hdr_template.h trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj trunk/lib/pmp_portalplayer1/pp1db.c Added Paths: ----------- trunk/lib/pmp_portalplayer1/model_samsung_yh820.c Modified: trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc =================================================================== --- trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc 2006-04-16 14:47:55 UTC (rev 9) +++ trunk/frontend/easypmp/win32gui/easypmp_win32gui.rc 2006-05-03 14:42:46 UTC (rev 10) @@ -133,8 +133,8 @@ 12 COMBOBOX IDC_COMBO_MEDIAINFO_SOURCE,138,42,102,36, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "Use &JavaScript playlist (JSPL)",IDC_CHECK_PL_JSPL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,120,144,8 + CONTROL "Use &JavaScript playlist",IDC_CHECK_PL_JSPL,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,96,120,144,8 END IDD_PROCESSING DIALOGEX 0, 0, 263, 246 Modified: trunk/frontend/easypmp/win32gui/processingdlg.h =================================================================== --- trunk/frontend/easypmp/win32gui/processingdlg.h 2006-04-16 14:47:55 UTC (rev 9) +++ trunk/frontend/easypmp/win32gui/processingdlg.h 2006-05-03 14:42:46 UTC (rev 10) @@ -227,8 +227,8 @@ pThis->PostMessage(WM_COMMAND, IDNO, 0); } else { // Show [OK] button and wait for [OK]/[CANCEL] button to be pushed + ::ShowWindow(pThis->GetDlgItem(IDC_CHECK_DONT_CLOSE), SW_HIDE); ::ShowWindow(pThis->GetDlgItem(IDOK), SW_SHOW); - ::ShowWindow(pThis->GetDlgItem(IDC_CHECK_DONT_CLOSE), SW_HIDE); ::EnableWindow(pThis->GetDlgItem(IDCANCEL), TRUE); } Modified: trunk/lib/pmp_portalplayer1/hdr_template.h =================================================================== --- trunk/lib/pmp_portalplayer1/hdr_template.h 2006-04-16 14:47:55 UTC (rev 9) +++ trunk/lib/pmp_portalplayer1/hdr_template.h 2006-05-03 14:42:46 UTC (rev 10) @@ -66,9 +66,11 @@ int hdr_init_h10_20gb_mtp_0251(hdr_t* hdr); 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_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); #endif/*__HDR_TEMPLATE_H__*/ Added: trunk/lib/pmp_portalplayer1/model_samsung_yh820.c =================================================================== --- trunk/lib/pmp_portalplayer1/model_samsung_yh820.c (rev 0) +++ trunk/lib/pmp_portalplayer1/model_samsung_yh820.c 2006-05-03 14:42:46 UTC (rev 10) @@ -0,0 +1,219 @@ +/* + * 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-04-16 14:47:55 UTC (rev 9) +++ trunk/lib/pmp_portalplayer1/pmp_portalplayer1.c 2006-05-03 14:42:46 UTC (rev 10) @@ -140,6 +140,14 @@ ".pla", hdr_init_medion_mdjuke440, medion_mdjuke220_parse_model }, + { + "samsung_yh820", "Samsung YH820", + 5, "UM", + "0.0", "0.0", + "SYSTEM\\FW_YH820.mi4", "System\\DATA\\PP5000.HDR", "System\\MUSIC\\", "System\\PLAYLIST\\", + ".plp", + hdr_init_samsung_yh820, samsung_yh820_parse_model + }, #if 0 { "sirius_s50", "Sirius S50", Modified: trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj =================================================================== --- trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2006-04-16 14:47:55 UTC (rev 9) +++ trunk/lib/pmp_portalplayer1/pmp_portalplayer1.vcproj 2006-05-03 14:42:46 UTC (rev 10) @@ -144,6 +144,9 @@ RelativePath=".\model_medion_mdjuke440.c"> </File> <File + RelativePath=".\model_samsung_yh820.c"> + </File> + <File RelativePath=".\model_sirius_s50.c"> </File> <File Modified: trunk/lib/pmp_portalplayer1/pp1db.c =================================================================== --- trunk/lib/pmp_portalplayer1/pp1db.c 2006-04-16 14:47:55 UTC (rev 9) +++ trunk/lib/pmp_portalplayer1/pp1db.c 2006-05-03 14:42:46 UTC (rev 10) @@ -115,6 +115,7 @@ #if 0 /* For analyzing a new (unknown) player. */ hdr_repr(db->hdr, stdout); fflush(stdout); + return 0; #endif // Read dat. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |