video: reverse logic for decoding + rendering filters

Replaced the concept of 'rendering filter capable of decoding'
by 'decoding filter capable of rendering'.
It's similar but allows to choose the decoder first (based on
video type) and then let it do the rendering if it can.
parent 7e44142c
...@@ -111,8 +111,8 @@ enum _MSFilterCategory{ ...@@ -111,8 +111,8 @@ enum _MSFilterCategory{
MS_FILTER_DECODER, MS_FILTER_DECODER,
/**used by capture filters that perform encoding*/ /**used by capture filters that perform encoding*/
MS_FILTER_ENCODING_CAPTURER, MS_FILTER_ENCODING_CAPTURER,
/**used by render filters that perform decoding*/ /**used by filters that perform decoding and rendering */
MS_FILTER_DECODING_RENDERER MS_FILTER_DECODER_RENDERER
}; };
/** /**
......
...@@ -87,9 +87,6 @@ struct _MSVideoDisplayDecodingSupport { ...@@ -87,9 +87,6 @@ struct _MSVideoDisplayDecodingSupport {
#define MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION \ #define MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION \
MS_FILTER_METHOD(MSFilterVideoDisplayInterface,11,int) MS_FILTER_METHOD(MSFilterVideoDisplayInterface,11,int)
#define MS_VIDEO_DISPLAY_SUPPORT_DECODING \
MS_FILTER_METHOD(MSFilterVideoDisplayInterface, 12, MSVideoDisplayDecodingSupport*)
/** /**
* Interface definitions for players * Interface definitions for players
**/ **/
...@@ -204,9 +201,11 @@ typedef enum _MSRecorderState MSRecorderState; ...@@ -204,9 +201,11 @@ typedef enum _MSRecorderState MSRecorderState;
#define MS_VIDEO_DECODER_SEND_RPSI \ #define MS_VIDEO_DECODER_SEND_RPSI \
MS_FILTER_EVENT(MSFilterVideoDecoderInterface, 4, const MSVideoCodecRPSI *) MS_FILTER_EVENT(MSFilterVideoDecoderInterface, 4, const MSVideoCodecRPSI *)
#define MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION \ #define MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION \
MS_FILTER_METHOD_NO_ARG(MSFilterVideoDecoderInterface, 0) MS_FILTER_METHOD_NO_ARG(MSFilterVideoDecoderInterface, 5)
#define MS_VIDEO_DECODER_ENABLE_AVPF \ #define MS_VIDEO_DECODER_ENABLE_AVPF \
MS_FILTER_METHOD(MSFilterVideoDecoderInterface, 1, bool_t) MS_FILTER_METHOD(MSFilterVideoDecoderInterface, 6, bool_t)
#define MS_VIDEO_DECODER_SUPPORT_RENDERING \
MS_FILTER_METHOD(MSFilterVideoDecoderInterface, 7, MSVideoDisplayDecodingSupport*)
/** Interface definitions for video capture */ /** Interface definitions for video capture */
#define MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION \ #define MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION \
......
...@@ -104,7 +104,7 @@ MSFilterDesc * ms_filter_get_decoding_renderer(const char *mime) { ...@@ -104,7 +104,7 @@ MSFilterDesc * ms_filter_get_decoding_renderer(const char *mime) {
for (elem = desc_list; elem != NULL; elem = ms_list_next(elem)) { for (elem = desc_list; elem != NULL; elem = ms_list_next(elem)) {
MSFilterDesc *desc = (MSFilterDesc *)elem->data; MSFilterDesc *desc = (MSFilterDesc *)elem->data;
if (desc->category == MS_FILTER_DECODING_RENDERER) { if (desc->category == MS_FILTER_DECODER_RENDERER) {
char *saveptr=NULL; char *saveptr=NULL;
char *enc_fmt = ms_strdup(desc->enc_fmt); char *enc_fmt = ms_strdup(desc->enc_fmt);
char *token = strtok_r(enc_fmt, " ", &saveptr); char *token = strtok_r(enc_fmt, " ", &saveptr);
......
...@@ -466,38 +466,43 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re ...@@ -466,38 +466,43 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
} }
if (stream->dir==VideoStreamSendRecv || stream->dir==VideoStreamRecvOnly){ if (stream->dir==VideoStreamSendRecv || stream->dir==VideoStreamRecvOnly){
MSConnectionHelper ch; MSConnectionHelper ch;
MSVideoDisplayDecodingSupport decoding_support;
/* create decoder first */
stream->ms.decoder=ms_filter_create_decoder(pt->mime_type);
if (stream->ms.decoder==NULL){
/* big problem: we don't have a registered decoderfor this payload...*/
ms_error("videostream.c: No decoder available for payload %i:%s.",payload,pt->mime_type);
return -1;
}
/* display logic */
if (stream->rendercb!=NULL){ if (stream->rendercb!=NULL){
/* rendering logic delegated to user supplied callback */
stream->output=ms_filter_new(MS_EXT_DISPLAY_ID); stream->output=ms_filter_new(MS_EXT_DISPLAY_ID);
ms_filter_add_notify_callback(stream->output,ext_display_cb,stream,TRUE); ms_filter_add_notify_callback(stream->output,ext_display_cb,stream,TRUE);
}else{ }else{
stream->output=ms_filter_new_from_name (stream->display_name); /* no user supplied callback -> create filter */
} MSVideoDisplayDecodingSupport decoding_support;
/* Don't allow null output */
if(stream->output == NULL) {
ms_fatal("No video display filter could be instantiated. Please check build-time configuration");
}
/* Check if the output filter can perform the decoding process */ /* Check if the decoding filter can perform the rendering */
decoding_support.mime_type = pt->mime_type; decoding_support.mime_type = pt->mime_type;
decoding_support.supported = FALSE; decoding_support.supported = FALSE;
ms_filter_call_method(stream->output, MS_VIDEO_DISPLAY_SUPPORT_DECODING, &decoding_support); ms_filter_call_method(stream->ms.decoder, MS_VIDEO_DECODER_SUPPORT_RENDERING, &decoding_support);
stream->output_performs_decoding = decoding_support.supported; stream->output_performs_decoding = decoding_support.supported;
/*plumb the incoming stream */ if (stream->output_performs_decoding) {
if (stream->output_performs_decoding == TRUE) { stream->output = stream->ms.decoder;
stream->ms.decoder = stream->output; /* Consider the decoder is the output */
} else { } else {
stream->ms.decoder=ms_filter_create_decoder(pt->mime_type); /* Create default display filter */
if (stream->ms.decoder==NULL){ stream->output = ms_filter_new_from_name (stream->display_name);
/* big problem: we don't have a registered decoderfor this payload...*/
ms_error("videostream.c: No decoder available for payload %i:%s.",payload,pt->mime_type);
ms_filter_destroy(stream->output);
return -1;
} }
} }
/* Don't allow null output */
if(stream->output == NULL) {
ms_fatal("No video display filter could be instantiated. Please check build-time configuration");
}
ms_filter_add_notify_callback(stream->ms.decoder, event_cb, stream,FALSE); ms_filter_add_notify_callback(stream->ms.decoder, event_cb, stream,FALSE);
stream->ms.rtprecv = ms_filter_new (MS_RTP_RECV_ID); stream->ms.rtprecv = ms_filter_new (MS_RTP_RECV_ID);
......
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