Mercurial > mplayer.hg
comparison libmpdemux/demux_lavf.c @ 16175:6b86089c2edd
Demuxer modularization
Demuxer selection by name with -demuxer command (bakward compatible)
author | rtognimp |
---|---|
date | Fri, 05 Aug 2005 19:57:47 +0000 |
parents | 7457c791204e |
children | 6ff303d2876b |
comparison
equal
deleted
inserted
replaced
16174:b118c000ddd2 | 16175:6b86089c2edd |
---|---|
99 mp_write, | 99 mp_write, |
100 mp_seek, | 100 mp_seek, |
101 mp_close, | 101 mp_close, |
102 }; | 102 }; |
103 | 103 |
104 int lavf_check_file(demuxer_t *demuxer){ | 104 static int lavf_check_file(demuxer_t *demuxer){ |
105 AVProbeData avpd; | 105 AVProbeData avpd; |
106 uint8_t buf[PROBE_BUF_SIZE]; | 106 uint8_t buf[PROBE_BUF_SIZE]; |
107 lavf_priv_t *priv; | 107 lavf_priv_t *priv; |
108 | 108 |
109 if(!demuxer->priv) | 109 if(!demuxer->priv) |
123 mp_msg(MSGT_HEADER,MSGL_V,"LAVF_check: no clue about this gibberish!\n"); | 123 mp_msg(MSGT_HEADER,MSGL_V,"LAVF_check: no clue about this gibberish!\n"); |
124 return 0; | 124 return 0; |
125 }else | 125 }else |
126 mp_msg(MSGT_HEADER,MSGL_V,"LAVF_check: %s\n", priv->avif->long_name); | 126 mp_msg(MSGT_HEADER,MSGL_V,"LAVF_check: %s\n", priv->avif->long_name); |
127 | 127 |
128 return 1; | 128 return DEMUXER_TYPE_LAVF; |
129 } | 129 } |
130 | 130 |
131 int demux_open_lavf(demuxer_t *demuxer){ | 131 static demuxer_t* demux_open_lavf(demuxer_t *demuxer){ |
132 AVFormatContext *avfc; | 132 AVFormatContext *avfc; |
133 AVFormatParameters ap; | 133 AVFormatParameters ap; |
134 lavf_priv_t *priv= demuxer->priv; | 134 lavf_priv_t *priv= demuxer->priv; |
135 int i,g; | 135 int i,g; |
136 char mp_filename[256]="mp:"; | 136 char mp_filename[256]="mp:"; |
150 | 150 |
151 ((URLContext*)(priv->pb.opaque))->priv_data= demuxer->stream; | 151 ((URLContext*)(priv->pb.opaque))->priv_data= demuxer->stream; |
152 | 152 |
153 if(av_open_input_stream(&avfc, &priv->pb, mp_filename, priv->avif, &ap)<0){ | 153 if(av_open_input_stream(&avfc, &priv->pb, mp_filename, priv->avif, &ap)<0){ |
154 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_open_input_stream() failed\n"); | 154 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_open_input_stream() failed\n"); |
155 return 0; | 155 return NULL; |
156 } | 156 } |
157 | 157 |
158 priv->avfc= avfc; | 158 priv->avfc= avfc; |
159 | 159 |
160 if(av_find_stream_info(avfc) < 0){ | 160 if(av_find_stream_info(avfc) < 0){ |
161 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_find_stream_info() failed\n"); | 161 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_find_stream_info() failed\n"); |
162 return 0; | 162 return NULL; |
163 } | 163 } |
164 | 164 |
165 if(avfc->title [0]) demux_info_add(demuxer, "name" , avfc->title ); | 165 if(avfc->title [0]) demux_info_add(demuxer, "name" , avfc->title ); |
166 if(avfc->author [0]) demux_info_add(demuxer, "author" , avfc->author ); | 166 if(avfc->author [0]) demux_info_add(demuxer, "author" , avfc->author ); |
167 if(avfc->copyright[0]) demux_info_add(demuxer, "copyright", avfc->copyright); | 167 if(avfc->copyright[0]) demux_info_add(demuxer, "copyright", avfc->copyright); |
302 if(!priv->audio_streams) demuxer->audio->id=-2; // nosound | 302 if(!priv->audio_streams) demuxer->audio->id=-2; // nosound |
303 // else if(best_audio > 0 && demuxer->audio->id == -1) demuxer->audio->id=best_audio; | 303 // else if(best_audio > 0 && demuxer->audio->id == -1) demuxer->audio->id=best_audio; |
304 if(!priv->video_streams){ | 304 if(!priv->video_streams){ |
305 if(!priv->audio_streams){ | 305 if(!priv->audio_streams){ |
306 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF: no audio or video headers found - broken file?\n"); | 306 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF: no audio or video headers found - broken file?\n"); |
307 return 0; | 307 return NULL; |
308 } | 308 } |
309 demuxer->video->id=-2; // audio-only | 309 demuxer->video->id=-2; // audio-only |
310 } //else if (best_video > 0 && demuxer->video->id == -1) demuxer->video->id = best_video; | 310 } //else if (best_video > 0 && demuxer->video->id == -1) demuxer->video->id = best_video; |
311 | 311 |
312 return 1; | 312 return demuxer; |
313 } | 313 } |
314 | 314 |
315 int demux_lavf_fill_buffer(demuxer_t *demux){ | 315 static int demux_lavf_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){ |
316 lavf_priv_t *priv= demux->priv; | 316 lavf_priv_t *priv= demux->priv; |
317 AVPacket pkt; | 317 AVPacket pkt; |
318 demux_packet_t *dp; | 318 demux_packet_t *dp; |
319 demux_stream_t *ds; | 319 demux_stream_t *ds; |
320 int id; | 320 int id; |
380 // append packet to DS stream: | 380 // append packet to DS stream: |
381 ds_add_packet(ds,dp); | 381 ds_add_packet(ds,dp); |
382 return 1; | 382 return 1; |
383 } | 383 } |
384 | 384 |
385 void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags){ | 385 static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags){ |
386 lavf_priv_t *priv = demuxer->priv; | 386 lavf_priv_t *priv = demuxer->priv; |
387 mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %d)\n", demuxer, rel_seek_secs, flags); | 387 mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %d)\n", demuxer, rel_seek_secs, flags); |
388 | 388 |
389 #if LIBAVFORMAT_BUILD < 4619 | 389 #if LIBAVFORMAT_BUILD < 4619 |
390 av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE); | 390 av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE); |
391 #else | 391 #else |
392 av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE, rel_seek_secs < 0 ? AVSEEK_FLAG_BACKWARD : 0); | 392 av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE, rel_seek_secs < 0 ? AVSEEK_FLAG_BACKWARD : 0); |
393 #endif | 393 #endif |
394 } | 394 } |
395 | 395 |
396 int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg) | 396 static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg) |
397 { | 397 { |
398 lavf_priv_t *priv = demuxer->priv; | 398 lavf_priv_t *priv = demuxer->priv; |
399 | 399 |
400 switch (cmd) { | 400 switch (cmd) { |
401 case DEMUXER_CTRL_GET_TIME_LENGTH: | 401 case DEMUXER_CTRL_GET_TIME_LENGTH: |
415 default: | 415 default: |
416 return DEMUXER_CTRL_NOTIMPL; | 416 return DEMUXER_CTRL_NOTIMPL; |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 void demux_close_lavf(demuxer_t *demuxer) | 420 static void demux_close_lavf(demuxer_t *demuxer) |
421 { | 421 { |
422 lavf_priv_t* priv = demuxer->priv; | 422 lavf_priv_t* priv = demuxer->priv; |
423 if (priv){ | 423 if (priv){ |
424 if(priv->avfc) | 424 if(priv->avfc) |
425 { | 425 { |
427 } | 427 } |
428 free(priv); demuxer->priv= NULL; | 428 free(priv); demuxer->priv= NULL; |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 | |
433 demuxer_desc_t demuxer_desc_lavf = { | |
434 "libavformat demuxer", | |
435 "lavf", | |
436 "libavformat", | |
437 "Michael Niedermayer", | |
438 "supports many formats, requires libavformat", | |
439 DEMUXER_TYPE_LAVF, | |
440 0, // Check after other demuxer | |
441 lavf_check_file, | |
442 demux_lavf_fill_buffer, | |
443 demux_open_lavf, | |
444 demux_close_lavf, | |
445 demux_seek_lavf, | |
446 demux_lavf_control | |
447 }; | |
448 | |
432 #endif // USE_LIBAVFORMAT | 449 #endif // USE_LIBAVFORMAT |