Skip to content

Commit

Permalink
Revamp the handling of audio and subtitle tracks for media
Browse files Browse the repository at this point in the history
Let code in media.c manage automatic selection of tracks based on language
and in the future other things.
  • Loading branch information
andoma committed Apr 30, 2011
1 parent 1e22311 commit d5ddc98
Show file tree
Hide file tree
Showing 22 changed files with 602 additions and 336 deletions.
14 changes: 7 additions & 7 deletions glwthemes/mono/commandmenu/cmd_details.view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ widget(container_y, {


widget(container_x, {
.hidden = $global.media.current.type != "video";
.hidden = $global.media.current.type != "video" && $global.media.current.type != "tv";
.height = $ui.size * 10;
.spacing = 20;
.align = center;
Expand All @@ -24,10 +24,10 @@ widget(container_y, {

widget(list_y, {
cloner($global.media.current.metadata.audiostreams, container_z, {
commandSelectableItem($self.title,
commandSelectableItem($self.title ?? $self.language ?? $self.source,
$self.format,
$self.id == $global.media.current.audio.current,
selectTrack($self.id));
$self.url == $global.media.current.audio.current,
selectAudioTrack($self.url));
});
});
}));
Expand All @@ -43,10 +43,10 @@ widget(container_y, {

widget(list_y, {
cloner($global.media.current.metadata.subtitlestreams, container_z, {
commandSelectableItem($self.title,
commandSelectableItem($self.title ?? $self.language ?? $self.source,
$self.format,
$self.id == $global.media.current.subtitle.current,
selectTrack($self.id));
$self.url == $global.media.current.subtitle.current,
selectSubtitleTrack($self.url));
});
});
}));
Expand Down
2 changes: 1 addition & 1 deletion glwthemes/mono/directoryviews/infobox/tvchannel.view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ widget(container_y, {
});

widget(list_y, {
cloner($args.metadata.events, container_x, {
cloner($args.metadata.events.list, container_x, {

widget(label, {
.filterConstraintX = true;
Expand Down
30 changes: 8 additions & 22 deletions glwthemes/mono/playdecks/tv.view
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,16 @@ widget(container_x, {
.filterConstraintX = true;
.spacing = 10;

/*
widget(container_y, {
widget(label, {
.hidden = select($global.media.current.metadata.current.title, false, true);
.caption = "Now:";
});
widget(label, {
.hidden = select($global.media.current.metadata.next.title, false, true);

.caption = "Next:";
});
});
*/

widget(container_y, {
.filterConstraintX = true;
widget(label, {
.autohide = true;
.caption = $global.media.current.metadata.current.title;
.caption = $global.media.current.metadata.events.current.title;
});

widget(label, {
.autohide = true;
.caption = $global.media.current.metadata.next.title;
.caption = $global.media.current.metadata.events.next.title;
});
});

Expand All @@ -69,18 +55,18 @@ widget(container_x, {

widget(container_y, {
widget(label, {
.hidden = select($global.media.current.metadata.current.title, false, true);
.hidden = select($global.media.current.metadata.events.current.title, false, true);
.caption =
strftime($global.media.current.metadata.current.start, "%H:%M") + " - " +
strftime($global.media.current.metadata.current.stop, "%H:%M");
strftime($global.media.current.metadata.events.current.start, "%H:%M") + " - " +
strftime($global.media.current.metadata.events.current.stop, "%H:%M");
.align = right;
});

widget(label, {
.hidden = select($global.media.current.metadata.next.title, false, true);
.hidden = select($global.media.current.metadata.events.next.title, false, true);
.caption =
strftime($global.media.current.metadata.next.start, "%H:%M") + " - " +
strftime($global.media.current.metadata.next.stop, "%H:%M");
strftime($global.media.current.metadata.events.next.start, "%H:%M") + " - " +
strftime($global.media.current.metadata.events.next.stop, "%H:%M");
.align = right;
});
});
Expand Down
3 changes: 1 addition & 2 deletions src/backend/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ backend_fini(void)
event_t *
backend_play_video(const char *url, struct media_pipe *mp,
int flags, int priority,
struct play_video_subtitle_list *subtitles,
char *errbuf, size_t errlen)
{
backend_t *nb = backend_canhandle(url);
Expand All @@ -91,7 +90,7 @@ backend_play_video(const char *url, struct media_pipe *mp,
return NULL;
}

return nb->be_play_video(url, mp, flags, priority, subtitles, errbuf, errlen);
return nb->be_play_video(url, mp, flags, priority, errbuf, errlen);
}


Expand Down
16 changes: 1 addition & 15 deletions src/backend/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,10 @@ typedef enum {
} backend_probe_result_t;


LIST_HEAD(play_video_subtitle_list, play_video_subtitle);

/**
*
*/
typedef struct play_video_subtitle {
LIST_ENTRY(play_video_subtitle) pvs_link;
char *pvs_url;
char *pvs_language;
} play_video_subtitle_t;



#define BACKEND_VIDEO_PRIMARY 0x1
#define BACKEND_VIDEO_NO_AUDIO 0x2
#define BACKEND_VIDEO_NO_AUTOSTOP 0x4
#define BACKEND_VIDEO_NO_FS_SCAN 0x8 // Don't scan FS for subtitles

/**
*
Expand All @@ -75,7 +63,6 @@ typedef struct backend {
struct event *(*be_play_video)(const char *url,
struct media_pipe *mp,
int flags, int priority,
struct play_video_subtitle_list *subtitles,
char *errbuf, size_t errlen);

struct event *(*be_play_audio)(const char *url, struct media_pipe *mp,
Expand Down Expand Up @@ -109,7 +96,6 @@ int backend_open(struct prop *page, const char *url)

struct event *backend_play_video(const char *url, struct media_pipe *mp,
int flags, int priority,
struct play_video_subtitle_list *subtitles,
char *errbuf, size_t errlen)
__attribute__ ((warn_unused_result));

Expand Down
28 changes: 19 additions & 9 deletions src/backend/dvd/dvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,17 @@ dvd_block(dvd_player_t *dp, uint8_t *buf, int len)
static void
dvd_init_streams(dvd_player_t *dp, media_pipe_t *mp)
{
mp_add_track(mp->mp_prop_audio_tracks, "Off", "audio:off");
mp_add_track(mp->mp_prop_audio_tracks, "Auto", "audio:auto");
mp_add_track(mp->mp_prop_subtitle_tracks, "Off", "spu:off");
mp_add_track(mp->mp_prop_subtitle_tracks, "Auto", "spu:auto");
prop_destroy_childs(mp->mp_prop_audio_tracks);
mp_add_track(mp->mp_prop_audio_tracks, "Off", "audio:off",
NULL, NULL, NULL, "DVD");
mp_add_track(mp->mp_prop_audio_tracks, "Auto", "audio:auto",
NULL, NULL, NULL, "DVD");

prop_destroy_childs(mp->mp_prop_subtitle_tracks);
mp_add_track(mp->mp_prop_subtitle_tracks, "Off", "sub:off",
NULL, NULL, NULL, "DVD");
mp_add_track(mp->mp_prop_subtitle_tracks, "Auto", "sub:auto",
NULL, NULL, NULL, "DVD");
}


Expand Down Expand Up @@ -518,7 +525,7 @@ dvd_set_spu_stream(dvd_player_t *dp, const char *id)
int idx = atoi(id);
dp->dp_spu_track = idx;
}
prop_set_stringf(dp->dp_mp->mp_prop_subtitle_track_current, "spu:%s", id);
prop_set_stringf(dp->dp_mp->mp_prop_subtitle_track_current, "sub:%s", id);
}


Expand Down Expand Up @@ -608,7 +615,7 @@ dvd_update_streams(dvd_player_t *dp)
}

prop_set_string(prop_create(p, "title"), dvd_langcode_to_string(lang));
prop_set_stringf(prop_create(p, "id"), "spu:%d", i);
prop_set_stringf(prop_create(p, "id"), "sub:%d", i);
before = p;
}
}
Expand Down Expand Up @@ -840,14 +847,17 @@ dvd_process_event(dvd_player_t *dp, event_t *e)
event_is_type(e, EVENT_PLAY_URL))
return e;

if(event_is_type(e, EVENT_SELECT_TRACK)) {
if(event_is_type(e, EVENT_SELECT_AUDIO_TRACK)) {
event_select_track_t *est = (event_select_track_t *)e;

if(!strncmp(est->id, "audio:", strlen("audio:")))
dvd_set_audio_stream(dp, est->id + strlen("audio:"));
else if(!strncmp(est->id, "spu:", strlen("spu:")))
dvd_set_spu_stream(dp, est->id + strlen("spu:"));

} else if(event_is_type(e, EVENT_SELECT_SUBTITLE_TRACK)) {
event_select_track_t *est = (event_select_track_t *)e;

if(!strncmp(est->id, "sub:", strlen("sub:")))
dvd_set_spu_stream(dp, est->id + strlen("sub:"));

} else if(!dvd_in_menu(dp) &&
(event_is_action(e, ACTION_PLAYPAUSE) ||
Expand Down
1 change: 0 additions & 1 deletion src/backend/dvd/linux_dvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ be_dvd_canhandle(const char *url)
static event_t *
be_dvd_play(const char *url, media_pipe_t *mp,
int flags, int priority,
struct play_video_subtitle_list *subtitles,
char *errstr, size_t errlen)
{
event_t *e;
Expand Down
Loading

0 comments on commit d5ddc98

Please sign in to comment.