caps: don't create broken caps for invalid media types
caps: don't create broken caps for invalid media types

Check if structure has been created before appending it to the caps. Free the
caps in the case of an error to not conceal it be returning empty caps.

Fixes #642271

Lachann/gstreamer,lovebug356/gstreamer,drothlis/gstreamer,cfoch/gstreamer,drothlis/gstreamer,mparis/gstreamer,krieger-od/gstreamer,jpxiong/gstreamer,Distrotech/gstreamer,magcius/gstreamer,Distrotech/gstreamer,magcius/gstreamer,justinjoy/gstreamer,ahmedammar/platform_external_gst_gstreamer,drothlis/gstreamer,jpxiong/gstreamer,ahmedammar/platform_external_gst_gstreamer,shelsonjava/gstreamer,ahmedammar/platform_external_gst_gstreamer,lubosz/gstreamer,ylatuya/gstreamer,collects/gstreamer,centricular/gstreamer,collects/gstreamer,Lachann/gstreamer,collects/gstreamer,mparis/gstreamer,centricular/gstreamer,Lachann/gstreamer,ahmedammar/platform_external_gst_gstreamer,jpxiong/gstreamer,cfoch/gstreamer,surround-io/gstreamer,surround-io/gstreamer,krichter722/gstreamer,centricular/gstreamer,krieger-od/gstreamer,lubosz/gstreamer,lubosz/gstreamer,magcius/gstreamer,StreamUtils/gstreamer,drothlis/gstreamer,centricular/gstreamer,lovebug356/gstreamer,StreamUtils/gstreamer,cablelabs/gstreamer,cablelabs/gstreamer,krieger-od/gstreamer,ylatuya/gstreamer,krichter722/gstreamer,cablelabs/gstreamer,lovebug356/gstreamer,surround-io/gstreamer,StreamUtils/gstreamer,ensonic/gstreamer,drothlis/gstreamer,jpakkane/gstreamer,centricular/gstreamer,krieger-od/gstreamer,collects/gstreamer,lovebug356/gstreamer,justinjoy/gstreamer,krichter722/gstreamer,mparis/gstreamer,lovebug356/gstreamer,jpxiong/gstreamer,surround-io/gstreamer,jpakkane/gstreamer,shelsonjava/gstreamer,collects/gstreamer,ylatuya/gstreamer,jpxiong/gstreamer,Distrotech/gstreamer,jpakkane/gstreamer,StreamUtils/gstreamer,lubosz/gstreamer,Distrotech/gstreamer,Lachann/gstreamer,jpakkane/gstreamer,ensonic/gstreamer,justinjoy/gstreamer,justinjoy/gstreamer,surround-io/gstreamer,cfoch/gstreamer,ylatuya/gstreamer,magcius/gstreamer,magcius/gstreamer,Distrotech/gstreamer,krieger-od/gstreamer,ensonic/gstreamer,ylatuya/gstreamer,shelsonjava/gstreamer,Lachann/gstreamer,jpakkane/gstreamer,lubosz/gstreamer,shelsonjava/gstreamer,ahmedammar/platform_external_gst_gstreamer,mparis/gstreamer,justinjoy/gstreamer,ensonic/gstreamer,shelsonjava/gstreamer,krichter722/gstreamer,cfoch/gstreamer,cablelabs/gstreamer,cfoch/gstreamer,krichter722/gstreamer,StreamUtils/gstreamer,ensonic/gstreamer,cablelabs/gstreamer,mparis/gstreamer