Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#114603 - 03/09/2002 19:06 Step 2 for Third-Party Player App (and ogg/flac)
grgcombs
addict

Registered: 03/07/2001
Posts: 663
Loc: Dallas, TX
So we're making progress with RioPlay running on the Empeg. Right now it runs flac and mp3 files, hopefully soon it'll incorporate the ogg support everyone has been waiting for.

It currently pulls it's music from a RioReceiver Server application, or from a big list of shoutcast servers.

I've got a request though. We'd like to add support for pulling music and playlists from the local empeg harddrive(s). There is code to get at this information in the emptool sources, and in hijack's kftp.c file. However I can't really make heads or tales of these two bits of info.

Would someone be willing to take a look at this and attempt at least a rudimentary ability to read data and music from the player's built in database, for use in RioPlay? To me it appears as if everything required is located in emptool's sources.

Greg
_________________________

Top
#114604 - 04/09/2002 07:11 Re: Step 2 for Third-Party Player App (and ogg/flac) [Re: grgcombs]
fvgestel
old hand

Registered: 12/08/2000
Posts: 702
Loc: Netherlands
Greg,

here's an example of reading the database and tags file :

#include <fcntl.h>
#include <stdio.h>

#define DBFILE "database"
#define TAGFILE "tags"

int main(int argc, char *argv[])
{
unsigned char c;
char s[2048];
char *tags[20];
int i,end_entry;
FILE *fp;

fp=fopen(TAGFILE, "rb");
i=0;
while (fgets(s,sizeof(s), fp) != NULL) {
s[strlen(s)-1]='\0';
tags[i++]=(char *)strdup(s);
}
fclose(fp);
i=0;
fp=fopen(DBFILE, "rb");
while ( fread(&c,1,1,fp) > 0 ) {
if ( c == 0xFF ) {
end_entry=1;
} else {
if (end_entry) {
printf("--------------------------------\n");
end_entry=0;
}
i=c;
fread(&c,1,1,fp);
fread(s,1,c,fp);
s[c]='\0';
printf("%s : %s\n",tags,s);
}
}
fclose(fp);
}


This program generates a list like this :

--------------------------------
type : illegal
--------------------------------
length : 20
title : All Music
type : playlist
--------------------------------
length : 32
options : 0x0
pickn : 0
pickpercent : 0
title : CD
type : playlist
--------------------------------
ctime : 1028582027
length : 124
title : abc
type : playlist
--------------------------------
ctime : 1028582027
length : 4
title : Aerosmith
type : playlist
--------------------------------
ctime : 1028582027
length : 60
title : Get A Grip
type : playlist
--------------------------------
artist : Aerosmith
bitrate : vs159
codec : mp3
comment : Track 1
ctime : 1028582027
duration : 23563
file_id : 1
genre : Rock
length : 470285
offset : 1631
samplerate : 44100
source : Get A Grip
title : Intro
tracknr : 1
type : tune
year : 1993
--------------------------------
.....


The entries of playlists can be read from the playlists file(obviously). I think they are stored in the same order as found in the database file. Just use the length attrib of playlists to read the right amount of data.
_________________________
Frank van Gestel

Top
#114605 - 04/09/2002 07:26 Re: Step 2 for Third-Party Player App (and ogg/flac) [Re: fvgestel]
grgcombs
addict

Registered: 03/07/2001
Posts: 663
Loc: Dallas, TX
You are truly awesome. This looks easy enough to make use of, but if I run into any snags I'll ask.

Thanks Frank!

Greg
_________________________

Top
#114606 - 04/09/2002 08:01 Re: Step 2 for Third-Party Player App (and ogg/flac) [Re: fvgestel]
grgcombs
addict

Registered: 03/07/2001
Posts: 663
Loc: Dallas, TX
For others who may be playing with this code, depending on your setup, you may have to make a couple of changes in order for it to run as planned...

Where you define tags:
char *tags[20];
It may be required to bump this array of pointers up to a larger size to avoid a segmentation fault from overrunning the array...
char *tags[50];

Also, when printing the results:
printf("%s : %s\n",tags,s);
You'll probably need to add the index for the tags array:
printf("%s : %s\n",tags{i},s); /* Replace curly brackets with square ones */

Thanks again Frank for this much more reasonable example on getting into the DB!

Greg


Edited by grgcombs (04/09/2002 09:42)
_________________________

Top
#114607 - 04/09/2002 08:08 Re: Step 2 for Third-Party Player App (and ogg/flac) [Re: grgcombs]
fvgestel
old hand

Registered: 12/08/2000
Posts: 702
Loc: Netherlands
my tags file only has 19 lines of tags; I'm probably running some older sw.
The tags index probably fell off due the HTML-tag option of the Programming thread. It would also explain the sudden italic characters on the end
_________________________
Frank van Gestel

Top
#114608 - 04/09/2002 09:33 Re: Step 2 for Third-Party Player App (and ogg/flac) [Re: grgcombs]
johnmcd3
enthusiast

Registered: 19/04/2001
Posts: 369
Loc: Seattle, WA (formerly Houston,...
hehe, your post did the same thing when you tried to add the "" to the tags array.

Just kidding.

John
_________________________
1998 BMW ///M3 30 GB Mk2a, Tuner, and 10 GB backup

Top
#114609 - 04/09/2002 11:17 Re: Step 2 for Third-Party Player App (and ogg/flac) [Re: grgcombs]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
Greg, this is great to see this project coming along so well. I've updated a couple of FAQ entries to mention this software. Let me know when the software has an official web site (with installation instructions) that I can link from the FAQ.
_________________________
Tony Fabris

Top