Commit 6bc4934b authored by Martin Storsjö's avatar Martin Storsjö

ismindex: Allow adding a path prefix to the generated .ism file

This allows storing the .ismv/.isma/.ismc files separately from
the .ism file on a server, without having to manually edit the
.ism file after generating it with the ismindex tool.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent cdab9db2
......@@ -25,6 +25,10 @@
* This step creates foo.ism and foo.ismc that is required by IIS for
* serving it.
*
* By adding -path-prefix path/, the produced foo.ism will refer to the
* files foo.ismv as "path/foo.ismv" - the prefix for the generated ismc
* file can be set with the -ismc-prefix option similarly.
*
* To pre-split files for serving as static files by a web server without
* any extra server support, create the ismv file as above, and split it:
* ismindex -split foo.ismv
......@@ -42,7 +46,8 @@
static int usage(const char *argv0, int ret)
{
fprintf(stderr, "%s [-split] [-n basename] file1 [file2] ...\n", argv0);
fprintf(stderr, "%s [-split] [-n basename] [-path-prefix prefix] "
"[-ismc-prefix prefix] file1 [file2] ...\n", argv0);
return ret;
}
......@@ -378,7 +383,8 @@ fail:
}
static void output_server_manifest(struct Tracks *tracks,
const char *basename)
const char *basename, const char *path_prefix,
const char *ismc_prefix)
{
char filename[1000];
FILE *out;
......@@ -394,15 +400,15 @@ static void output_server_manifest(struct Tracks *tracks,
fprintf(out, "<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\">\n");
fprintf(out, "\t<head>\n");
fprintf(out, "\t\t<meta name=\"clientManifestRelativePath\" "
"content=\"%s.ismc\" />\n", basename);
"content=\"%s%s.ismc\" />\n", ismc_prefix, basename);
fprintf(out, "\t</head>\n");
fprintf(out, "\t<body>\n");
fprintf(out, "\t\t<switch>\n");
for (i = 0; i < tracks->nb_tracks; i++) {
struct Track *track = tracks->tracks[i];
const char *type = track->is_video ? "video" : "audio";
fprintf(out, "\t\t\t<%s src=\"%s\" systemBitrate=\"%d\">\n",
type, track->name, track->bitrate);
fprintf(out, "\t\t\t<%s src=\"%s%s\" systemBitrate=\"%d\">\n",
type, path_prefix, track->name, track->bitrate);
fprintf(out, "\t\t\t\t<param name=\"trackID\" value=\"%d\" "
"valueType=\"data\" />\n", track->track_id);
fprintf(out, "\t\t\t</%s>\n", type);
......@@ -528,6 +534,7 @@ static void clean_tracks(struct Tracks *tracks)
int main(int argc, char **argv)
{
const char *basename = NULL;
const char *path_prefix = "", *ismc_prefix = "";
int split = 0, i;
struct Tracks tracks = { 0, .video_track = -1, .audio_track = -1 };
......@@ -537,6 +544,12 @@ int main(int argc, char **argv)
if (!strcmp(argv[i], "-n")) {
basename = argv[i + 1];
i++;
} else if (!strcmp(argv[i], "-path-prefix")) {
path_prefix = argv[i + 1];
i++;
} else if (!strcmp(argv[i], "-ismc-prefix")) {
ismc_prefix = argv[i + 1];
i++;
} else if (!strcmp(argv[i], "-split")) {
split = 1;
} else if (argv[i][0] == '-') {
......@@ -550,7 +563,7 @@ int main(int argc, char **argv)
return usage(argv[0], 1);
if (!split)
output_server_manifest(&tracks, basename);
output_server_manifest(&tracks, basename, path_prefix, ismc_prefix);
output_client_manifest(&tracks, basename, split);
clean_tracks(&tracks);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment