/***************************************************************************** * SubpicClone: Clone subpicture (shallow copy) *****************************************************************************/ static subpicture_t *SubpicClone( subpicture_t *p_source, subpicture_updater_t *updater ) { subpicture_t *p_subpic; subpicture_updater_t subpic_updater; subpicture_private_t *p_subpic_private; p_subpic = subpicture_New( updater ); if( !p_subpic ) { return NULL; } /* save private members */ subpic_updater = p_subpic->updater; p_subpic_private = p_subpic->p_private; /* copy the entire struct */ memcpy( p_subpic, p_source, sizeof( subpicture_t ) ); /* restore private members */ p_subpic->updater = subpic_updater; p_subpic->p_private = p_subpic_private; return p_subpic; }
/** * \brief Show EPG information about the current program of an input item * \param vout pointer to the vout the information is to be showed on * \param p_input pointer to the input item the information is to be showed */ int vout_OSDEpg(vout_thread_t *vout, input_item_t *input) { char *now_playing = input_item_GetNowPlaying(input); vlc_epg_t *epg = NULL; vlc_mutex_lock(&input->lock); /* Look for the current program EPG event */ for (int i = 0; i < input->i_epg; i++) { vlc_epg_t *tmp = input->pp_epg[i]; if (tmp->p_current && tmp->p_current->psz_name && now_playing != NULL && !strcmp(tmp->p_current->psz_name, now_playing)) { epg = vlc_epg_New(tmp->psz_name); vlc_epg_Merge(epg, tmp); break; } } vlc_mutex_unlock(&input->lock); /* If no EPG event has been found. */ if (epg == NULL) return VLC_EGENERIC; subpicture_updater_sys_t *sys = (subpicture_updater_sys_t *)malloc(sizeof(*sys)); // sunqueen modify if (!sys) { vlc_epg_Delete(epg); return VLC_EGENERIC; } sys->epg = epg; subpicture_updater_t updater = { // sunqueen modify start /*.pf_validate =*/ OSDEpgValidate, /*.pf_update =*/ OSDEpgUpdate, /*.pf_destroy =*/ OSDEpgDestroy, /*.p_sys =*/ sys // sunqueen modify end }; const mtime_t now = mdate(); subpicture_t *subpic = subpicture_New(&updater); if (!subpic) { vlc_epg_Delete(sys->epg); free(sys); return VLC_EGENERIC; } subpic->i_channel = SPU_DEFAULT_CHANNEL; subpic->i_start = now; subpic->i_stop = now + 3000 * INT64_C(1000); subpic->b_ephemer = true; subpic->b_absolute = true; subpic->b_fade = true; vout_PutSubpicture(vout, subpic); return VLC_SUCCESS; }
static subpicture_t *spu_new_buffer( decoder_t *p_dec, const subpicture_updater_t *p_upd ) { VLC_UNUSED( p_dec ); subpicture_t *p_subpicture = subpicture_New( p_upd ); p_subpicture->b_subtitle = true; return p_subpicture; }
subpicture_t *subpicture_NewFromPicture( vlc_object_t *p_obj, picture_t *p_picture, vlc_fourcc_t i_chroma ) { /* */ video_format_t fmt_in = p_picture->format; /* */ video_format_t fmt_out; fmt_out = fmt_in; fmt_out.i_chroma = i_chroma; /* */ image_handler_t *p_image = image_HandlerCreate( p_obj ); if( !p_image ) return NULL; picture_t *p_pip = image_Convert( p_image, p_picture, &fmt_in, &fmt_out ); image_HandlerDelete( p_image ); if( !p_pip ) return NULL; subpicture_t *p_subpic = subpicture_New( NULL ); if( !p_subpic ) { picture_Release( p_pip ); return NULL; } p_subpic->i_original_picture_width = fmt_out.i_width; p_subpic->i_original_picture_height = fmt_out.i_height; fmt_out.i_sar_num = fmt_out.i_sar_den = 0; p_subpic->p_region = subpicture_region_New( &fmt_out ); if( p_subpic->p_region ) { picture_Release( p_subpic->p_region->p_picture ); p_subpic->p_region->p_picture = p_pip; } else { picture_Release( p_pip ); } return p_subpic; }
/** * \brief Show text on the video from a given start date to a given end date * \param p_spu pointer to the subpicture queue the text is to be showed on * \param i_channel Subpicture channel * \param psz_string The text to be shown * \param p_style Pointer to a struct with text style info (it is duplicated) * \param i_flags flags for alignment and such * \param i_hmargin horizontal margin in pixels * \param i_vmargin vertical margin in pixels * \param i_start the time when this string is to appear on the video * \param i_stop the time when this string should stop to be displayed * if this is 0 the string will be shown untill the next string * is about to be shown */ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, const char *psz_string, const text_style_t *p_style, int i_flags, int i_hmargin, int i_vmargin, mtime_t i_start, mtime_t i_stop ) { subpicture_t *p_spu; video_format_t fmt; (void)p_style; if( !psz_string ) return VLC_EGENERIC; p_spu = subpicture_New( NULL ); if( !p_spu ) return VLC_EGENERIC; p_spu->i_channel = i_channel; p_spu->i_start = i_start; p_spu->i_stop = i_stop; p_spu->b_ephemer = true; p_spu->b_absolute = false; /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); fmt.i_chroma = VLC_CODEC_TEXT; fmt.i_width = fmt.i_height = 0; fmt.i_x_offset = fmt.i_y_offset = 0; p_spu->p_region = subpicture_region_New( &fmt ); if( !p_spu->p_region ) { msg_Err( p_spu_channel, "cannot allocate SPU region" ); subpicture_Delete( p_spu ); return VLC_EGENERIC; } p_spu->p_region->psz_text = strdup( psz_string ); p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; p_spu->p_region->i_x = i_hmargin; p_spu->p_region->i_y = i_vmargin; spu_PutSubpicture( p_spu_channel, p_spu ); return VLC_SUCCESS; }
/** * \brief Show EPG information about the current program of an input item * \param p_vout pointer to the vout the information is to be showed on * \param p_input pointer to the input item the information is to be showed */ int vout_OSDEpg( vout_thread_t *p_vout, input_item_t *p_input ) { subpicture_t *p_spu; mtime_t i_now = mdate(); char *psz_now_playing = input_item_GetNowPlaying( p_input ); vlc_epg_t *p_epg = NULL; vlc_mutex_lock( &p_input->lock ); /* Look for the current program EPG event */ for( int i = 0; i < p_input->i_epg; i++ ) { vlc_epg_t *p_tmp = p_input->pp_epg[i]; if( p_tmp->p_current && p_tmp->p_current->psz_name && psz_now_playing != NULL && !strcmp( p_tmp->p_current->psz_name, psz_now_playing ) ) { p_epg = vlc_epg_New( p_tmp->psz_name ); vlc_epg_Merge( p_epg, p_tmp ); break; } } vlc_mutex_unlock( &p_input->lock ); /* If no EPG event has been found. */ if( p_epg == NULL ) return VLC_EGENERIC; subpicture_updater_sys_t *p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) { vlc_epg_Delete( p_epg ); return VLC_EGENERIC; } p_sys->p_epg = p_epg; subpicture_updater_t updater = { .pf_validate = OSDEpgValidate, .pf_update = OSDEpgUpdate, .pf_destroy = OSDEpgDestroy, .p_sys = p_sys }; p_spu = subpicture_New( &updater ); if( !p_spu ) { vlc_epg_Delete( p_sys->p_epg ); free( p_sys ); return VLC_EGENERIC; } p_spu->i_channel = SPU_DEFAULT_CHANNEL; p_spu->i_start = i_now; p_spu->i_stop = i_now + 3000 * INT64_C(1000); p_spu->b_ephemer = true; p_spu->b_absolute = true; p_spu->b_fade = true; vout_PutSubpicture( p_vout, p_spu ); return VLC_SUCCESS; }