+ es_format_Clean( &p_dec->fmt_in );
+ es_format_Clean( &p_dec->fmt_out );
+ if( p_dec->p_description )
+ vlc_meta_Delete( p_dec->p_description );
+ if( p_owner->p_description )
+ vlc_meta_Delete( p_owner->p_description );
+
+ if( p_owner->p_packetizer )
+ {
+ module_unneed( p_owner->p_packetizer,
+ p_owner->p_packetizer->p_module );
+ es_format_Clean( &p_owner->p_packetizer->fmt_in );
+ es_format_Clean( &p_owner->p_packetizer->fmt_out );
+ if( p_owner->p_packetizer->p_description )
+ vlc_meta_Delete( p_owner->p_packetizer->p_description );
+ vlc_object_release( p_owner->p_packetizer );
+ }
+
+ vlc_cond_destroy( &p_owner->wait_fifo );
+ vlc_cond_destroy( &p_owner->wait_acknowledge );
+ vlc_cond_destroy( &p_owner->wait_request );
+ vlc_mutex_destroy( &p_owner->lock );
+
+ vlc_object_release( p_dec );
+
+ free( p_owner );
+}
+
+/* */
+static void DecoderUnsupportedCodec( decoder_t *p_dec, vlc_fourcc_t codec )
+{
+ if (codec != VLC_FOURCC('u','n','d','f')) {
+ const char *desc = vlc_fourcc_GetDescription(p_dec->fmt_in.i_cat, codec);
+ if (!desc || !*desc)
+ desc = N_("No description for this codec");
+ msg_Err( p_dec, "Codec `%4.4s' (%s) is not supported.", (char*)&codec, desc );
+ dialog_Fatal( p_dec, _("Codec not supported"),
+ _("VLC could not decode the format \"%4.4s\" (%s)"),
+ (char*)&codec, desc );
+ } else {
+ msg_Err( p_dec, "could not identify codec" );
+ dialog_Fatal( p_dec, _("Unidentified codec"),
+ _("VLC could not identify the audio or video codec" ) );
+ }
+}
+
+/* TODO: pass p_sout through p_resource? -- Courmisch */
+static decoder_t *decoder_New( vlc_object_t *p_parent, input_thread_t *p_input,
+ const es_format_t *fmt, input_clock_t *p_clock,
+ input_resource_t *p_resource,
+ sout_instance_t *p_sout )
+{
+ decoder_t *p_dec = NULL;
+ const char *psz_type = p_sout ? N_("packetizer") : N_("decoder");
+ int i_priority;
+
+ /* Create the decoder configuration structure */
+ p_dec = CreateDecoder( p_parent, p_input, fmt,
+ p_sout != NULL, p_resource, p_sout );
+ if( p_dec == NULL )
+ {
+ msg_Err( p_parent, "could not create %s", psz_type );
+ dialog_Fatal( p_parent, _("Streaming / Transcoding failed"),
+ _("VLC could not open the %s module."),
+ vlc_gettext( psz_type ) );
+ return NULL;
+ }
+
+ if( !p_dec->p_module )
+ {
+ DecoderUnsupportedCodec( p_dec, fmt->i_codec );
+
+ DeleteDecoder( p_dec );
+ return NULL;
+ }
+
+ p_dec->p_owner->p_clock = p_clock;
+ assert( p_dec->fmt_out.i_cat != UNKNOWN_ES );