mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-12-04 14:46:31 -05:00
Change the MP3 special case, so working with metadata is more flexible. Turns
out that there is still a problem with MP3 streams that are being reencoded. This allows me to try out more solutions. git-svn-id: https://svn.xiph.org/trunk/ezstream@13592 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
5927f80401
commit
f481b60418
@ -118,8 +118,8 @@ char * buildCommandString(const char *, const char *, metadata_t *);
|
|||||||
char * getMetadataString(const char *, metadata_t *);
|
char * getMetadataString(const char *, metadata_t *);
|
||||||
metadata_t * getMetadata(const char *);
|
metadata_t * getMetadata(const char *);
|
||||||
int setMetadata(shout_t *, metadata_t *, char **);
|
int setMetadata(shout_t *, metadata_t *, char **);
|
||||||
FILE * openResource(shout_t *, const char *, int *, char **, int *,
|
FILE * openResource(shout_t *, const char *, int *, metadata_t **,
|
||||||
int *);
|
int *, int *);
|
||||||
int reconnectServer(shout_t *, int);
|
int reconnectServer(shout_t *, int);
|
||||||
const char * getTimeString(int);
|
const char * getTimeString(int);
|
||||||
int sendStream(shout_t *, FILE *, const char *, int, const char *,
|
int sendStream(shout_t *, FILE *, const char *, int, const char *,
|
||||||
@ -516,7 +516,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
||||||
char **metaCopy, int *isStdin, int *songLen)
|
metadata_t **mdata_p, int *isStdin, int *songLen)
|
||||||
{
|
{
|
||||||
FILE *filep = NULL;
|
FILE *filep = NULL;
|
||||||
char extension[25];
|
char extension[25];
|
||||||
@ -528,10 +528,13 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
if (metadataFromProgram) {
|
if (metadataFromProgram) {
|
||||||
if ((mdata = getMetadata(pezConfig->metadataProgram)) == NULL)
|
if ((mdata = getMetadata(pezConfig->metadataProgram)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if (setMetadata(shout, mdata, metaCopy) != SHOUTERR_SUCCESS) {
|
if (setMetadata(shout, mdata, NULL) != SHOUTERR_SUCCESS) {
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
if (mdata_p != NULL)
|
||||||
|
*mdata_p = mdata;
|
||||||
|
else
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,8 +573,6 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
if ((mdata = getMetadata(fileName)) == NULL)
|
if ((mdata = getMetadata(fileName)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (metaCopy != NULL)
|
|
||||||
*metaCopy = metadata_assemble_string(mdata);
|
|
||||||
if (songLen != NULL)
|
if (songLen != NULL)
|
||||||
*songLen = metadata_get_length(mdata);
|
*songLen = metadata_get_length(mdata);
|
||||||
|
|
||||||
@ -580,6 +581,9 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
int stderr_fd = -1;
|
int stderr_fd = -1;
|
||||||
|
|
||||||
pCommandString = buildCommandString(extension, fileName, mdata);
|
pCommandString = buildCommandString(extension, fileName, mdata);
|
||||||
|
if (mdata_p != NULL)
|
||||||
|
*mdata_p = mdata;
|
||||||
|
else
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
if (vFlag > 1)
|
if (vFlag > 1)
|
||||||
printf("%s: Running command `%s`\n", __progname,
|
printf("%s: Running command `%s`\n", __progname,
|
||||||
@ -625,10 +629,11 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
close(stderr_fd);
|
close(stderr_fd);
|
||||||
|
|
||||||
return (filep);
|
return (filep);
|
||||||
} else if (strrcasecmp(fileName, ".mp3") == 0)
|
}
|
||||||
/* MP3 streams are special: */
|
|
||||||
setMetadata(shout, mdata, NULL);
|
|
||||||
|
|
||||||
|
if (mdata_p != NULL)
|
||||||
|
*mdata_p = mdata;
|
||||||
|
else
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
|
|
||||||
if ((filep = fopen(fileName, "rb")) == NULL)
|
if ((filep = fopen(fileName, "rb")) == NULL)
|
||||||
@ -831,27 +836,35 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
{
|
{
|
||||||
FILE *filepstream = NULL;
|
FILE *filepstream = NULL;
|
||||||
int popenFlag = 0;
|
int popenFlag = 0;
|
||||||
char *metaData = NULL, *songLenStr = NULL;
|
char *songLenStr = NULL;
|
||||||
int isStdin = 0;
|
int isStdin = 0;
|
||||||
int ret, retval = 0, songLen;
|
int ret, retval = 0, songLen;
|
||||||
|
metadata_t *mdata;
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
struct timeval startTime;
|
struct timeval startTime;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((filepstream = openResource(shout, fileName, &popenFlag,
|
if ((filepstream = openResource(shout, fileName, &popenFlag,
|
||||||
&metaData, &isStdin, &songLen))
|
&mdata, &isStdin, &songLen))
|
||||||
== NULL) {
|
== NULL) {
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaData != NULL) {
|
if (mdata != NULL) {
|
||||||
|
char *metaData = metadata_assemble_string(mdata);
|
||||||
|
|
||||||
printf("%s: Streaming ``%s''", __progname, metaData);
|
printf("%s: Streaming ``%s''", __progname, metaData);
|
||||||
if (vFlag)
|
if (vFlag)
|
||||||
printf(" (file: %s)\n", fileName);
|
printf(" (file: %s)\n", fileName);
|
||||||
else
|
else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
xfree(metaData);
|
xfree(metaData);
|
||||||
metaData = NULL;
|
|
||||||
|
/* MP3 streams are special, so set the metadata explicitly: */
|
||||||
|
if (strcmp(pezConfig->format, MP3_FORMAT) == 0)
|
||||||
|
setMetadata(shout, mdata, NULL);
|
||||||
|
|
||||||
|
metadata_free(&mdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
@ -889,22 +902,22 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
queryMetadata = 0;
|
queryMetadata = 0;
|
||||||
if (metadataFromProgram) {
|
if (metadataFromProgram) {
|
||||||
char *mdataStr = NULL;
|
char *mdataStr = NULL;
|
||||||
metadata_t *mdata;
|
metadata_t *prog_mdata;
|
||||||
|
|
||||||
if (vFlag > 1)
|
if (vFlag > 1)
|
||||||
printf("%s: Querying '%s' for fresh metadata\n",
|
printf("%s: Querying '%s' for fresh metadata\n",
|
||||||
__progname, pezConfig->metadataProgram);
|
__progname, pezConfig->metadataProgram);
|
||||||
if ((mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
|
if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
ret = STREAM_DONE;
|
ret = STREAM_DONE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (setMetadata(shout, mdata, &mdataStr) != SHOUTERR_SUCCESS) {
|
if (setMetadata(shout, prog_mdata, &mdataStr) != SHOUTERR_SUCCESS) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
ret = STREAM_DONE;
|
ret = STREAM_DONE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
metadata_free(&mdata);
|
metadata_free(&prog_mdata);
|
||||||
printf("%s: New metadata: ``%s''\n",
|
printf("%s: New metadata: ``%s''\n",
|
||||||
__progname, mdataStr);
|
__progname, mdataStr);
|
||||||
xfree(mdataStr);
|
xfree(mdataStr);
|
||||||
|
Loading…
Reference in New Issue
Block a user