From ec27866d5d4a9e8ea7e4c8731091358e0cfe62b9 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sun, 28 Oct 2012 12:07:33 +0100 Subject: [PATCH 10/16] new function: himd_create_content_id Creates a random content id. --- himdcli/himdcli.c | 5 ++--- libhimd/himd.h | 2 ++ libhimd/trackindex.c | 13 +++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/himdcli/himdcli.c b/himdcli/himdcli.c index 9ceb2ec..dd0c170 100644 --- a/himdcli/himdcli.c +++ b/himdcli/himdcli.c @@ -351,12 +351,11 @@ void himd_writemp3(struct himd *h, const char *filepath) gchar * mp3buffer; gchar * artist=NULL, * title=NULL, * album=NULL; int i; - unsigned char cid[20] = {0x02, 0x03, 0x00, 0x00}; + unsigned char cid[20]; unsigned char mp3codecinfo[3]; // Generate random content ID - for(i = 4; i <=19; i++) - cid[i] = g_random_int_range(0,0xFF); + himd_create_content_id(cid); // Get track ID3 information if(!get_songinfo(filepath, &artist, &title, &album)) diff --git a/libhimd/himd.h b/libhimd/himd.h index a6f6b7a..95d193a 100644 --- a/libhimd/himd.h +++ b/libhimd/himd.h @@ -201,6 +201,8 @@ int himd_add_fragment_info(struct himd * himd, struct fraginfo * f, struct himde #define himd_trackinfo_framesize(track) sony_codecinfo_bytesperframe(&(track)->codec_info) unsigned int himd_trackinfo_framesperblock(const struct trackinfo * track); +void himd_create_content_id(unsigned char* cid); + typedef unsigned char mp3key[4]; int himd_obtain_mp3key(struct himd * himd, int track, mp3key * key, struct himderrinfo * status); diff --git a/libhimd/trackindex.c b/libhimd/trackindex.c index 1d77221..582f268 100644 --- a/libhimd/trackindex.c +++ b/libhimd/trackindex.c @@ -631,3 +631,16 @@ gboolean himd_set_track_label(struct himd * himd, int trackindex, char * label, return TRUE; } + +void himd_create_content_id(unsigned char* cid) +{ + int i; + + cid[0] = 0x02; + cid[1] = 0x03; + cid[2] = 0x00; + cid[3] = 0x00; + + for(i = 4; i <=19; i++) + cid[i] = g_random_int_range(0,0xFF); +} \ No newline at end of file -- 1.8.0