Commit 247b7a5d authored by François Grisez's avatar François Grisez

Add MS_FILTER_GET_OUTPUT_FMT method

parent 02880c87
......@@ -2133,7 +2133,28 @@ static int player_stop(MSFilter *f, void *arg) {
return 0;
}
static int player_get_output_fmt(MSFilter *f, void *arg) {
MKVPlayer *obj = (MKVPlayer *)f->data;
MSPinFormat *pinFmt = (MSPinFormat *)arg;
int err = 0;
ms_filter_lock(f);
if(obj->state == MSPlayerClosed) {
ms_error("MKVPlayer: cannot get pin format when player is closed");
err = -1;
} else {
if(pinFmt->pin < 0 || pinFmt->pin >= f->desc->noutputs) {
ms_error("MKVPlayer: pin #%d does not exist", pinFmt->pin);
err = -2;
} else {
pinFmt->fmt = obj->outputDescsList[pinFmt->pin];
}
}
ms_filter_unlock(f);
return err;
}
static MSFilterMethod player_methods[]= {
{ MS_FILTER_GET_OUTPUT_FMT , player_get_output_fmt },
{ MS_PLAYER_OPEN , player_open_file },
{ MS_PLAYER_CLOSE , player_close },
{ MS_PLAYER_START , player_start },
......
......@@ -149,10 +149,6 @@ void playback_stream_init(PlaybackStream *obj, MSFilterId player,const char *fil
obj->ticker = ms_ticker_new();
obj->filename = strdup(filename);
// temporary
obj->audioDecoder = ms_factory_create_decoder(ms_factory_get_fallback(), "pcmu");
obj->videoDecoder = ms_factory_create_decoder(ms_factory_get_fallback(), "H264");
}
void playback_stream_uninit(PlaybackStream *obj) {
......@@ -166,12 +162,21 @@ void playback_stream_uninit(PlaybackStream *obj) {
}
void playback_stream_start(PlaybackStream *obj) {
MSPinFormat pinFmt;
ms_filter_call_method(obj->player, MS_PLAYER_OPEN, "test.mkv");
pinFmt.pin = 0;
ms_filter_call_method(obj->player, MS_FILTER_GET_OUTPUT_FMT, &pinFmt);
obj->videoDecoder = ms_factory_create_decoder(ms_factory_get_fallback(), pinFmt.fmt->encoding);
pinFmt.pin = 1;
ms_filter_call_method(obj->player, MS_FILTER_GET_OUTPUT_FMT, &pinFmt);
obj->audioDecoder = ms_factory_create_decoder(ms_factory_get_fallback(), pinFmt.fmt->encoding);
ms_filter_link(obj->player, 0, obj->videoDecoder, 0);
ms_filter_link(obj->videoDecoder, 0, obj->videoSink, 0);
ms_filter_link(obj->player, 1, obj->audioDecoder, 0);
ms_filter_link(obj->audioDecoder, 0, obj->audioSink, 0);
ms_ticker_attach(obj->ticker, obj->player);
ms_filter_call_method(obj->player, MS_PLAYER_OPEN, "test.mkv");
ms_filter_call_method_noarg(obj->player, MS_PLAYER_START);
}
......
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