mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 07:23:11 +02:00
armbox eplayer: add metadata
This commit is contained in:
@@ -2580,6 +2580,67 @@ static int32_t container_ffmpeg_get_info(Context_t *context, char **infoString)
|
||||
return cERR_CONTAINER_FFMPEG_NO_ERROR;
|
||||
}
|
||||
|
||||
static int container_ffmpeg_get_metadata(Context_t * context, char ***p)
|
||||
{
|
||||
Track_t *videoTrack = NULL;
|
||||
Track_t *audioTrack = NULL;
|
||||
AVDictionaryEntry *tag = NULL;
|
||||
size_t psize = 1;
|
||||
char **pp;
|
||||
|
||||
if (!context) {
|
||||
fprintf(stderr, "BUG %s:%d\n", __func__, __LINE__);
|
||||
return cERR_CONTAINER_FFMPEG_ERR;
|
||||
}
|
||||
|
||||
if (!p || *p) {
|
||||
fprintf(stderr, "BUG %s:%d\n", __func__, __LINE__);
|
||||
return cERR_CONTAINER_FFMPEG_ERR;
|
||||
}
|
||||
|
||||
context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack);
|
||||
context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack);
|
||||
|
||||
if (avContextTab[0]->metadata)
|
||||
psize += av_dict_count(avContextTab[0]->metadata);
|
||||
if (videoTrack)
|
||||
psize += av_dict_count(((AVStream *)(videoTrack->stream))->metadata);
|
||||
if (audioTrack)
|
||||
psize += av_dict_count(((AVStream *)(audioTrack->stream))->metadata);
|
||||
|
||||
*p = malloc(sizeof(char *) * psize * 2);
|
||||
if (!*p) {
|
||||
fprintf(stderr, "MALLOC %s:%d\n", __func__, __LINE__);
|
||||
return cERR_CONTAINER_FFMPEG_ERR;
|
||||
}
|
||||
pp = *p;
|
||||
|
||||
if (avContextTab[0]->metadata)
|
||||
while ((tag = av_dict_get(avContextTab[0]->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
|
||||
*pp++ = strdup(tag->key);
|
||||
*pp++ = strdup(tag->value);
|
||||
}
|
||||
|
||||
if (videoTrack) {
|
||||
tag = NULL;
|
||||
while ((tag = av_dict_get(((AVStream *)(videoTrack->stream))->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
|
||||
*pp++ = strdup(tag->key);
|
||||
*pp++ = strdup(tag->value);
|
||||
}
|
||||
}
|
||||
if (audioTrack) {
|
||||
tag = NULL;
|
||||
while ((tag = av_dict_get(((AVStream *)(audioTrack->stream))->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
|
||||
*pp++ = strdup(tag->key);
|
||||
*pp++ = strdup(tag->value);
|
||||
}
|
||||
}
|
||||
*pp++ = NULL;
|
||||
*pp = NULL;
|
||||
|
||||
return cERR_CONTAINER_FFMPEG_NO_ERROR;
|
||||
}
|
||||
|
||||
static int32_t Command(void *_context, ContainerCmd_t command, void *argument)
|
||||
{
|
||||
Context_t *context = (Context_t *) _context;
|
||||
@@ -2666,6 +2727,11 @@ static int32_t Command(void *_context, ContainerCmd_t command, void *argument)
|
||||
*((int32_t *)argument) = size;
|
||||
break;
|
||||
}
|
||||
case CONTAINER_GET_METADATA:
|
||||
{
|
||||
ret = container_ffmpeg_get_metadata(context, (char ***) argument);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ffmpeg_err("ContainerCmd %d not supported!\n", command);
|
||||
ret = cERR_CONTAINER_FFMPEG_ERR;
|
||||
|
@@ -24,7 +24,8 @@ typedef enum
|
||||
CONTAINER_SET_BUFFER_SIZE,
|
||||
CONTAINER_GET_BUFFER_SIZE,
|
||||
CONTAINER_GET_BUFFER_STATUS,
|
||||
CONTAINER_STOP_BUFFER
|
||||
CONTAINER_STOP_BUFFER,
|
||||
CONTAINER_GET_METADATA
|
||||
} ContainerCmd_t;
|
||||
|
||||
typedef struct Container_s
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP, PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM, PLAYBACK_FASTFORWARD, PLAYBACK_SEEK, PLAYBACK_SEEK_ABS, PLAYBACK_PTS, PLAYBACK_LENGTH, PLAYBACK_SWITCH_AUDIO, PLAYBACK_SWITCH_SUBTITLE, PLAYBACK_INFO, PLAYBACK_SLOWMOTION, PLAYBACK_FASTBACKWARD, PLAYBACK_GET_FRAME_COUNT} PlaybackCmd_t;
|
||||
typedef enum {PLAYBACK_OPEN, PLAYBACK_CLOSE, PLAYBACK_PLAY, PLAYBACK_STOP, PLAYBACK_PAUSE, PLAYBACK_CONTINUE, PLAYBACK_FLUSH, PLAYBACK_TERM, PLAYBACK_FASTFORWARD, PLAYBACK_SEEK, PLAYBACK_SEEK_ABS, PLAYBACK_PTS, PLAYBACK_LENGTH, PLAYBACK_SWITCH_AUDIO, PLAYBACK_SWITCH_SUBTITLE, PLAYBACK_INFO, PLAYBACK_SLOWMOTION, PLAYBACK_FASTBACKWARD, PLAYBACK_GET_FRAME_COUNT, PLAYBACK_METADATA} PlaybackCmd_t;
|
||||
|
||||
typedef struct PlaybackHandler_s
|
||||
{
|
||||
|
@@ -583,6 +583,17 @@ static int32_t PlaybackInfo(Context_t *context, char **infoString)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int PlaybackMetadata(Context_t * context, char ***metadata)
|
||||
{
|
||||
int ret = cERR_PLAYBACK_NO_ERROR;
|
||||
|
||||
if (context->container && context->container->selectedContainer)
|
||||
context->container->selectedContainer->Command(context,
|
||||
CONTAINER_GET_METADATA,
|
||||
metadata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t Command(void *_context, PlaybackCmd_t command, void *argument)
|
||||
{
|
||||
Context_t *context = (Context_t *) _context; /* to satisfy compiler */
|
||||
@@ -665,6 +676,11 @@ static int32_t Command(void *_context, PlaybackCmd_t command, void *argument)
|
||||
ret = PlaybackGetFrameCount(context, (uint64_t *)argument);
|
||||
break;
|
||||
}
|
||||
case PLAYBACK_METADATA:
|
||||
{
|
||||
ret = PlaybackMetadata(context, (char ***) argument);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
playback_err("PlaybackCmd %d not supported!\n", command);
|
||||
ret = cERR_PLAYBACK_ERROR;
|
||||
|
Reference in New Issue
Block a user