]> git.sesse.net Git - vlc/blobdiff - modules/misc/quartztext.c
vod: don't handle pause state toggling in the RTSP stack
[vlc] / modules / misc / quartztext.c
index 732f276f2c1d90a2af50fafd6e513ef089f332e6..5a7228945ae511a78b1ee076b9f0999e6b60868b 100644 (file)
 #include <vlc_xml.h>
 #include <vlc_input.h>
 
+#include <TargetConditionals.h>
+
+#ifdef TARGET_OS_IPHONE
+#include <CoreText/CoreText.h>
+#include <CoreGraphics/CoreGraphics.h>
+
+#else
 // Fix ourselves ColorSync headers that gets included in ApplicationServices.
 #define DisposeCMProfileIterateUPP(a) DisposeCMProfileIterateUPP(CMProfileIterateUPP userUPP __attribute__((unused)))
 #define DisposeCMMIterateUPP(a) DisposeCMMIterateUPP(CMProfileIterateUPP userUPP __attribute__((unused)))
 #define __MACHINEEXCEPTIONS__
 #include <ApplicationServices/ApplicationServices.h>
+#endif
 
 #define DEFAULT_FONT           "Arial Black"
 #define DEFAULT_FONT_COLOR     0xffffff
@@ -82,7 +90,7 @@ static void setFontAttibutes( char *psz_fontname, int i_font_size, uint32_t i_fo
 #define FONTSIZER_TEXT N_("Relative font size")
 #define FONTSIZER_LONGTEXT N_("This is the relative default size of the " \
     "fonts that will be rendered on the video. If absolute font size is set, "\
-    "relative size will be overriden." )
+    "relative size will be overridden." )
 #define COLOR_TEXT N_("Text default color")
 #define COLOR_LONGTEXT N_("The color of the text that will be rendered on "\
     "the video. This must be an hexadecimal (like HTML colors). The first two "\
@@ -109,14 +117,14 @@ vlc_module_begin ()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_SUBPIC )
 
-    add_string( "quartztext-font", DEFAULT_FONT, NULL, FONT_TEXT, FONT_LONGTEXT,
+    add_string( "quartztext-font", DEFAULT_FONT, FONT_TEXT, FONT_LONGTEXT,
               false )
-    add_integer( "quartztext-rel-fontsize", DEFAULT_REL_FONT_SIZE, NULL, FONTSIZER_TEXT,
+    add_integer( "quartztext-rel-fontsize", DEFAULT_REL_FONT_SIZE, FONTSIZER_TEXT,
                  FONTSIZER_LONGTEXT, false )
-        change_integer_list( pi_sizes, ppsz_sizes_text, NULL );
-    add_integer( "quartztext-color", 0x00FFFFFF, NULL, COLOR_TEXT,
+        change_integer_list( pi_sizes, ppsz_sizes_text )
+    add_integer( "quartztext-color", 0x00FFFFFF, COLOR_TEXT,
                  COLOR_LONGTEXT, false )
-        change_integer_list( pi_color_values, ppsz_color_descriptions, NULL );
+        change_integer_list( pi_color_values, ppsz_color_descriptions )
     set_capability( "text renderer", 150 )
     add_shortcut( "text" )
     set_callbacks( Create, Destroy )
@@ -165,8 +173,10 @@ struct filter_sys_t
     int            i_font_color;
     int            i_font_size;
 
+#ifndef TARGET_OS_IPHONE
     ATSFontContainerRef    *p_fonts;
     int                     i_fonts;
+#endif
 };
 
 //////////////////////////////////////////////////////////////////////////////
@@ -191,8 +201,10 @@ static int Create( vlc_object_t *p_this )
     p_filter->pf_render_text = RenderText;
     p_filter->pf_render_html = RenderHtml;
 
+#ifndef TARGET_OS_IPHONE
     p_sys->p_fonts = NULL;
     p_sys->i_fonts = 0;
+#endif
 
     LoadFontsFromAttachments( p_filter );
 
@@ -208,7 +220,7 @@ static void Destroy( vlc_object_t *p_this )
 {
     filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
-
+#ifndef TARGET_OS_IPHONE
     if( p_sys->p_fonts )
     {
         int   k;
@@ -220,7 +232,7 @@ static void Destroy( vlc_object_t *p_this )
 
         free( p_sys->p_fonts );
     }
-
+#endif
     free( p_sys->psz_font_name );
     free( p_sys );
 }
@@ -231,60 +243,48 @@ static void Destroy( vlc_object_t *p_this )
 //////////////////////////////////////////////////////////////////////////////
 static int LoadFontsFromAttachments( filter_t *p_filter )
 {
+#ifdef TARGET_OS_IPHONE
+    VLC_UNUSED(p_filter);
+    return VLC_SUCCESS;
+#else
     filter_sys_t         *p_sys = p_filter->p_sys;
-    input_thread_t       *p_input;
     input_attachment_t  **pp_attachments;
     int                   i_attachments_cnt;
-    int                   k;
-    int                   rv = VLC_SUCCESS;
-
-    p_input = (input_thread_t *)vlc_object_find( p_filter, VLC_OBJECT_INPUT, FIND_PARENT );
-    if( ! p_input )
-        return VLC_EGENERIC;
 
-    if( VLC_SUCCESS != input_Control( p_input, INPUT_GET_ATTACHMENTS, &pp_attachments, &i_attachments_cnt ))
-    {
-        vlc_object_release(p_input);
+    if( filter_GetInputAttachments( p_filter, &pp_attachments, &i_attachments_cnt ) )
         return VLC_EGENERIC;
-    }
 
     p_sys->i_fonts = 0;
     p_sys->p_fonts = malloc( i_attachments_cnt * sizeof( ATSFontContainerRef ) );
     if(! p_sys->p_fonts )
-        rv = VLC_ENOMEM;
+        return VLC_ENOMEM;
 
-    for( k = 0; k < i_attachments_cnt; k++ )
+    for( int k = 0; k < i_attachments_cnt; k++ )
     {
         input_attachment_t *p_attach = pp_attachments[k];
 
-        if( p_sys->p_fonts )
+        if( ( !strcmp( p_attach->psz_mime, "application/x-truetype-font" ) || // TTF
+              !strcmp( p_attach->psz_mime, "application/x-font-otf" ) ) &&    // OTF
+            p_attach->i_data > 0 && p_attach->p_data )
         {
-            if(( !strcmp( p_attach->psz_mime, "application/x-truetype-font" ) || // TTF
-                 !strcmp( p_attach->psz_mime, "application/x-font-otf" ) ) &&    // OTF
-               ( p_attach->i_data > 0 ) &&
-               ( p_attach->p_data != NULL ) )
+            ATSFontContainerRef  container;
+
+            if( noErr == ATSFontActivateFromMemory( p_attach->p_data,
+                                                    p_attach->i_data,
+                                                    kATSFontContextLocal,
+                                                    kATSFontFormatUnspecified,
+                                                    NULL,
+                                                    kATSOptionFlagsDefault,
+                                                    &container ))
             {
-                ATSFontContainerRef  container;
-
-                if( noErr == ATSFontActivateFromMemory( p_attach->p_data,
-                                                        p_attach->i_data,
-                                                        kATSFontContextLocal,
-                                                        kATSFontFormatUnspecified,
-                                                        NULL,
-                                                        kATSOptionFlagsDefault,
-                                                        &container ))
-                {
-                    p_sys->p_fonts[ p_sys->i_fonts++ ] = container;
-                }
+                p_sys->p_fonts[ p_sys->i_fonts++ ] = container;
             }
         }
         vlc_input_attachment_Delete( p_attach );
     }
     free( pp_attachments );
-
-    vlc_object_release(p_input);
-
-    return rv;
+    return VLC_SUCCESS;
+#endif
 }
 
 static char *EliminateCRLF( char *psz_string )
@@ -382,8 +382,8 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
                                              CFRangeMake( 0, len ), p_attrString);
 
         RenderYUVA( p_filter, p_region_out, p_attrString );
+        CFRelease( p_attrString );
     }
-    CFRelease(p_attrString);
 
     return VLC_SUCCESS;
 }
@@ -557,7 +557,7 @@ static void setFontAttibutes( char *psz_fontname, int i_font_size, uint32_t i_fo
 {
     CFStringRef p_cfString;
     CTFontRef   p_font;
-    
+
     // Handle font name and size
     p_cfString = CFStringCreateWithCString( NULL,
                                             psz_fontname,
@@ -843,7 +843,7 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
                     else
                     {
                         /* Only text and karaoke tags are supported */
-                        xml_ReaderDelete( p_xml, p_xml_reader );
+                        xml_ReaderDelete( p_xml_reader );
                         p_xml_reader = NULL;
                         rv = VLC_EGENERIC;
                     }
@@ -871,7 +871,7 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
                 }
                 CFRelease(p_attrString);
 
-                xml_ReaderDelete( p_xml, p_xml_reader );
+                xml_ReaderDelete( p_xml_reader );
             }
             xml_Delete( p_xml );
         }
@@ -897,7 +897,7 @@ static CGContextRef CreateOffScreenContext( int i_width, int i_height,
 
         p_bitmap->p_data = calloc( i_height, p_bitmap->i_bytesPerRow );
 
-        *pp_colorSpace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
+        *pp_colorSpace = CGColorSpaceCreateDeviceRGB();
 
         if( p_bitmap->p_data && *pp_colorSpace )
         {