Mercurial > mplayer.hg
comparison libmpdemux/demux_ogg.c @ 12135:ec3c9fe261b9
Changed -sid/-aid/-vid to be zero based and select the n'th stream of its type, e.g. -sid 1 will select the second subtitle stream.
author | mosu |
---|---|
date | Tue, 06 Apr 2004 06:36:46 +0000 |
parents | fdce1dd97638 |
children | 26be0fd618b5 |
comparison
equal
deleted
inserted
replaced
12134:83822b2b0a17 | 12135:ec3c9fe261b9 |
---|---|
650 int demux_ogg_open(demuxer_t* demuxer) { | 650 int demux_ogg_open(demuxer_t* demuxer) { |
651 ogg_demuxer_t* ogg_d; | 651 ogg_demuxer_t* ogg_d; |
652 stream_t *s; | 652 stream_t *s; |
653 char* buf; | 653 char* buf; |
654 int np,s_no, n_audio = 0, n_video = 0, n_text = 0; | 654 int np,s_no, n_audio = 0, n_video = 0, n_text = 0; |
655 int audio_id = -1, video_id = -1, text_id = -1; | |
655 ogg_sync_state* sync; | 656 ogg_sync_state* sync; |
656 ogg_page* page; | 657 ogg_page* page; |
657 ogg_packet pack; | 658 ogg_packet pack; |
658 sh_audio_t* sh_a; | 659 sh_audio_t* sh_a; |
659 sh_video_t* sh_v; | 660 sh_video_t* sh_v; |
887 /// Check for text (subtitles) header | 888 /// Check for text (subtitles) header |
888 } else if (strncmp(st->streamtype, "text", 4) == 0) { | 889 } else if (strncmp(st->streamtype, "text", 4) == 0) { |
889 mp_msg(MSGT_DEMUX, MSGL_V, "OGG stream %d is text\n", ogg_d->num_sub); | 890 mp_msg(MSGT_DEMUX, MSGL_V, "OGG stream %d is text\n", ogg_d->num_sub); |
890 ogg_d->subs[ogg_d->num_sub].samplerate= get_uint64(&st->time_unit)/10; | 891 ogg_d->subs[ogg_d->num_sub].samplerate= get_uint64(&st->time_unit)/10; |
891 ogg_d->subs[ogg_d->num_sub].text = 1; | 892 ogg_d->subs[ogg_d->num_sub].text = 1; |
893 if (demuxer->sub->id == n_text) | |
894 text_id = ogg_d->num_sub; | |
892 n_text++; | 895 n_text++; |
893 demux_ogg_init_sub(); | 896 demux_ogg_init_sub(); |
894 //// Unknown header type | 897 //// Unknown header type |
895 } else | 898 } else |
896 mp_msg(MSGT_DEMUX,MSGL_ERR,"OGG stream %d has a header marker but is of an unknown type\n",ogg_d->num_sub); | 899 mp_msg(MSGT_DEMUX,MSGL_ERR,"OGG stream %d has a header marker but is of an unknown type\n",ogg_d->num_sub); |
901 if(sh_a || sh_v) { | 904 if(sh_a || sh_v) { |
902 demux_stream_t* ds = NULL; | 905 demux_stream_t* ds = NULL; |
903 if(sh_a) { | 906 if(sh_a) { |
904 // If the audio stream is not defined we took the first one | 907 // If the audio stream is not defined we took the first one |
905 if(demuxer->audio->id == -1) { | 908 if(demuxer->audio->id == -1) { |
906 demuxer->audio->id = ogg_d->num_sub; | 909 demuxer->audio->id = n_audio - 1; |
907 // if(sh_a->wf) print_wave_header(sh_a->wf); | 910 // if(sh_a->wf) print_wave_header(sh_a->wf); |
908 } | 911 } |
909 /// Is it the stream we want | 912 /// Is it the stream we want |
910 if(demuxer->audio->id == ogg_d->num_sub) { | 913 if(demuxer->audio->id == (n_audio - 1)) { |
911 demuxer->audio->sh = sh_a; | 914 demuxer->audio->sh = sh_a; |
912 sh_a->ds = demuxer->audio; | 915 sh_a->ds = demuxer->audio; |
913 ds = demuxer->audio; | 916 ds = demuxer->audio; |
917 audio_id = ogg_d->num_sub; | |
914 } | 918 } |
915 } | 919 } |
916 if(sh_v) { | 920 if(sh_v) { |
917 /// Also for video | 921 /// Also for video |
918 if(demuxer->video->id == -1) { | 922 if(demuxer->video->id == -1) { |
919 demuxer->video->id = ogg_d->num_sub; | 923 demuxer->video->id = n_video - 1; |
920 // if(sh_v->bih) print_video_header(sh_v->bih); | 924 // if(sh_v->bih) print_video_header(sh_v->bih); |
921 } | 925 } |
922 if(demuxer->video->id == ogg_d->num_sub) { | 926 if(demuxer->video->id == (n_video - 1)) { |
923 demuxer->video->sh = sh_v; | 927 demuxer->video->sh = sh_v; |
924 sh_v->ds = demuxer->video; | 928 sh_v->ds = demuxer->video; |
925 ds = demuxer->video; | 929 ds = demuxer->video; |
930 video_id = ogg_d->num_sub; | |
926 } | 931 } |
927 } | 932 } |
928 /// Add the header packets if the stream isn't seekable | 933 /// Add the header packets if the stream isn't seekable |
929 if(ds && !s->end_pos) { | 934 if(ds && !s->end_pos) { |
930 /// Finish the page, otherwise packets will be lost | 935 /// Finish the page, otherwise packets will be lost |
937 } | 942 } |
938 | 943 |
939 /// Finish to setup the demuxer | 944 /// Finish to setup the demuxer |
940 demuxer->priv = ogg_d; | 945 demuxer->priv = ogg_d; |
941 | 946 |
942 if(!n_video) | 947 if(!n_video || (video_id < 0)) |
943 demuxer->video->id = -2; | 948 demuxer->video->id = -2; |
944 if(!n_audio) | 949 else |
950 demuxer->video->id = video_id; | |
951 if(!n_audio || (audio_id < 0)) | |
945 demuxer->audio->id = -2; | 952 demuxer->audio->id = -2; |
946 if(!n_text) | 953 else |
954 demuxer->audio->id = audio_id; | |
955 if(!n_text || (text_id < 0)) | |
947 demuxer->sub->id = -2; | 956 demuxer->sub->id = -2; |
957 else | |
958 demuxer->sub->id = text_id; | |
948 | 959 |
949 ogg_d->final_granulepos=0; | 960 ogg_d->final_granulepos=0; |
950 if(!s->end_pos) | 961 if(!s->end_pos) |
951 demuxer->seekable = 0; | 962 demuxer->seekable = 0; |
952 else { | 963 else { |