summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2016-02-05 23:46:25 +0100
committerMarton Balint <cus@passwd.hu>2016-02-21 23:24:09 +0100
commit3a4232a1a0251e2ad595a544996fcc4465baf684 (patch)
treebe55d36be13dfa08dd62152ce17b2fcd40cca443 /libavformat
parent2ac5a1a28ece31cbe33ff2688aad6bfba0edcf73 (diff)
avformat/asfenc: write group_mutual_exclusion_objects for audio on multiple languages
Improves streaming compatibility with Windows Media Services. Also tested for compatilbility in Windows Media Player, Windows Media ASF Viewer and VLC. This version of the patch only writes exclusion among audio streams, therefore choosing a subtitle language should be possible independently of audio language. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/asf.c8
-rw-r--r--libavformat/asf.h2
-rw-r--r--libavformat/asfenc.c23
3 files changed, 33 insertions, 0 deletions
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 455ca4d826..719cae9da5 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -147,6 +147,14 @@ const ff_asf_guid ff_asf_extended_stream_properties_object = {
0xcb, 0xa5, 0xe6, 0x14, 0x72, 0xc6, 0x32, 0x43, 0x83, 0x99, 0xa9, 0x69, 0x52, 0x06, 0x5b, 0x5a
};
+const ff_asf_guid ff_asf_group_mutual_exclusion_object = {
+ 0x40, 0x5a, 0x46, 0xd1, 0x79, 0x5a, 0x38, 0x43, 0xb7, 0x1b, 0xe3, 0x6b, 0x8f, 0xd6, 0xc2, 0x49
+};
+
+const ff_asf_guid ff_asf_mutex_language = {
+ 0x00, 0x2a, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe
+};
+
/* List of official tags at http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
const AVMetadataConv ff_asf_metadata_conv[] = {
{ "WM/AlbumArtist", "album_artist" },
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 914ddef48e..43288ddbaf 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -100,6 +100,8 @@ extern const ff_asf_guid ff_asf_content_encryption;
extern const ff_asf_guid ff_asf_ext_content_encryption;
extern const ff_asf_guid ff_asf_digital_signature;
extern const ff_asf_guid ff_asf_extended_stream_properties_object;
+extern const ff_asf_guid ff_asf_group_mutual_exclusion_object;
+extern const ff_asf_guid ff_asf_mutex_language;
extern const AVMetadataConv ff_asf_metadata_conv[];
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 14f92e258f..66551ea373 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -396,6 +396,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
+ int audio_language_counts[128] = { 0 };
ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
@@ -444,6 +445,8 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
asf->streams[n].stream_language_index = asf->nb_languages;
asf->nb_languages++;
}
+ if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+ audio_language_counts[asf->streams[n].stream_language_index]++;
}
} else {
asf->streams[n].stream_language_index = 128;
@@ -484,6 +487,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
if (asf->nb_languages) {
int64_t hpos2;
int i;
+ int nb_audio_languages = 0;
hpos2 = put_header(pb, &ff_asf_language_guid);
avio_wl16(pb, asf->nb_languages);
@@ -493,6 +497,25 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
}
end_header(pb, hpos2);
+ for (i = 0; i < asf->nb_languages; i++)
+ if (audio_language_counts[i])
+ nb_audio_languages++;
+
+ if (nb_audio_languages > 1) {
+ hpos2 = put_header(pb, &ff_asf_group_mutual_exclusion_object);
+ ff_put_guid(pb, &ff_asf_mutex_language);
+ avio_wl16(pb, nb_audio_languages);
+ for (i = 0; i < asf->nb_languages; i++) {
+ if (audio_language_counts[i]) {
+ avio_wl16(pb, audio_language_counts[i]);
+ for (n = 0; n < s->nb_streams; n++)
+ if (asf->streams[n].stream_language_index == i && s->streams[n]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ avio_wl16(pb, n + 1);
+ }
+ }
+ end_header(pb, hpos2);
+ }
+
for (n = 0; n < s->nb_streams; n++) {
int64_t es_pos;
if (asf->streams[n].stream_language_index > 127)