#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
#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 "\
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 )
int i_font_color;
int i_font_size;
+#ifndef TARGET_OS_IPHONE
ATSFontContainerRef *p_fonts;
int i_fonts;
+#endif
};
//////////////////////////////////////////////////////////////////////////////
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 );
{
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;
free( p_sys->p_fonts );
}
-
+#endif
free( p_sys->psz_font_name );
free( p_sys );
}
//////////////////////////////////////////////////////////////////////////////
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 )
CFRangeMake( 0, len ), p_attrString);
RenderYUVA( p_filter, p_region_out, p_attrString );
+ CFRelease( p_attrString );
}
- CFRelease(p_attrString);
return VLC_SUCCESS;
}
{
if( !strcasecmp( "face", psz_name ) )
{
- if( psz_fontname ) free( psz_fontname );
+ free( psz_fontname );
psz_fontname = strdup( psz_value );
}
else if( !strcasecmp( "size", psz_name ) )
{
CFStringRef p_cfString;
CTFontRef p_font;
-
+
// Handle font name and size
p_cfString = CFStringCreateWithCString( NULL,
psz_fontname,
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;
}
}
CFRelease(p_attrString);
- xml_ReaderDelete( p_xml, p_xml_reader );
+ xml_ReaderDelete( p_xml_reader );
}
xml_Delete( p_xml );
}
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 )
{
// Create a new subpicture region
memset( &fmt, 0, sizeof(video_format_t) );
fmt.i_chroma = VLC_CODEC_YUVA;
- fmt.i_aspect = 0;
fmt.i_width = fmt.i_visible_width = i_width;
fmt.i_height = fmt.i_visible_height = __MIN( i_height, i_textblock_height + VERTICAL_MARGIN * 2);
fmt.i_x_offset = fmt.i_y_offset = 0;
- p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect );
+ p_region->p_picture = picture_NewFromFormat( &fmt );
if( !p_region->p_picture )
return VLC_EGENERIC;
p_region->fmt = fmt;