Step 2 for Third-Party Player App (and ogg/flac)

Posted by: grgcombs

Step 2 for Third-Party Player App (and ogg/flac) - 03/09/2002 19:06

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
Posted by: fvgestel

Re: Step 2 for Third-Party Player App (and ogg/flac) - 04/09/2002 07:11

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.
Posted by: grgcombs

Re: Step 2 for Third-Party Player App (and ogg/flac) - 04/09/2002 07:26

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
Posted by: grgcombs

Re: Step 2 for Third-Party Player App (and ogg/flac) - 04/09/2002 08:01

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
Posted by: fvgestel

Re: Step 2 for Third-Party Player App (and ogg/flac) - 04/09/2002 08:08

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
Posted by: johnmcd3

Re: Step 2 for Third-Party Player App (and ogg/flac) - 04/09/2002 09:33

hehe, your post did the same thing when you tried to add the "" to the tags array.

Just kidding.

John
Posted by: tfabris

Re: Step 2 for Third-Party Player App (and ogg/flac) - 04/09/2002 11:17

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.