1 /*****************************************************************************
2 * dynamicoverlay_commands.c : dynamic overlay plugin commands
3 *****************************************************************************
4 * Copyright (C) 2008 the VideoLAN team
7 * Author: Søren Bøg <avacore@videolan.org>
8 * Jean-Paul Saman <jpsaman@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
30 #include <vlc_arrays.h>
32 #include <vlc_filter.h>
39 #include "dynamicoverlay.h"
42 /*****************************************************************************
43 * overlay_t: Overlay descriptor
44 *****************************************************************************/
46 overlay_t *OverlayCreate( void )
48 overlay_t *p_ovl = malloc( sizeof( overlay_t ) );
51 memset( p_ovl, 0, sizeof( overlay_t ) );
53 p_ovl->i_x = p_ovl->i_y = 0;
54 p_ovl->i_alpha = 0xFF;
55 p_ovl->b_active = VLC_FALSE;
56 vout_InitFormat( &p_ovl->format, VLC_FOURCC( '\0','\0','\0','\0') , 0, 0,
58 memcpy( &p_ovl->fontstyle, &default_text_style, sizeof(struct text_style_t) );
59 p_ovl->data.p_text = NULL;
64 int OverlayDestroy( overlay_t *p_ovl )
66 if( p_ovl->data.p_text != NULL )
67 free( p_ovl->data.p_text );
72 /*****************************************************************************
74 *****************************************************************************/
75 static int skip_space( char **psz_command )
77 char *psz_temp = *psz_command;
79 while( isspace( *psz_temp ) )
83 if( psz_temp == *psz_command )
87 *psz_command = psz_temp;
91 static int parse_digit( char **psz_command, int32_t *value )
94 *value = strtol( *psz_command, &psz_temp, 10 );
95 if( psz_temp == *psz_command )
99 *psz_command = psz_temp;
103 static int parse_char( char **psz_command, char **psz_end,
104 int count, char *psz_value )
106 if( *psz_end - *psz_command < count )
110 memcpy( psz_value, *psz_command, count );
111 *psz_command += count;
115 static int parser_DataSharedMem( char *psz_command,
117 commandparams_t *p_params )
119 /* Parse: 0 128 128 RGBA 9404459 */
120 skip_space( &psz_command );
121 if( isdigit( *psz_command ) )
123 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
126 skip_space( &psz_command );
127 if( isdigit( *psz_command ) )
129 if( parse_digit( &psz_command, &p_params->i_width ) == VLC_EGENERIC )
132 skip_space( &psz_command );
133 if( isdigit( *psz_command ) )
135 if( parse_digit( &psz_command, &p_params->i_height ) == VLC_EGENERIC )
138 skip_space( &psz_command );
139 if( isascii( *psz_command ) )
141 if( parse_char( &psz_command, &psz_end, 4, (char*)&p_params->fourcc )
145 skip_space( &psz_command );
146 if( isdigit( *psz_command ) )
148 if( parse_digit( &psz_command, &p_params->i_shmid ) == VLC_EGENERIC )
154 static int parser_Id( char *psz_command, char *psz_end,
155 commandparams_t *p_params )
158 skip_space( &psz_command );
159 if( isdigit( *psz_command ) )
161 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
167 static int parser_None( char *psz_command, char *psz_end,
168 commandparams_t *p_params )
176 static int parser_SetAlpha( char *psz_command, char *psz_end,
177 commandparams_t *p_params )
180 skip_space( &psz_command );
181 if( isdigit( *psz_command ) )
183 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
186 skip_space( &psz_command );
187 if( isdigit( *psz_command ) )
189 if( parse_digit( &psz_command, &p_params->i_alpha ) == VLC_EGENERIC )
195 static int parser_SetPosition( char *psz_command, char *psz_end,
196 commandparams_t *p_params )
199 skip_space( &psz_command );
200 if( isdigit( *psz_command ) )
202 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
205 skip_space( &psz_command );
206 if( isdigit( *psz_command ) )
208 if( parse_digit( &psz_command, &p_params->i_x ) == VLC_EGENERIC )
211 skip_space( &psz_command );
212 if( isdigit( *psz_command ) )
214 if( parse_digit( &psz_command, &p_params->i_y ) == VLC_EGENERIC )
220 static int parser_SetTextAlpha( char *psz_command, char *psz_end,
221 commandparams_t *p_params )
224 skip_space( &psz_command );
225 if( isdigit( *psz_command ) )
227 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
230 skip_space( &psz_command );
231 if( isdigit( *psz_command ) )
233 if( parse_digit( &psz_command, &p_params->fontstyle.i_font_alpha ) == VLC_EGENERIC )
239 static int parser_SetTextColor( char *psz_command, char *psz_end,
240 commandparams_t *p_params )
244 skip_space( &psz_command );
245 if( isdigit( *psz_command ) )
247 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
250 skip_space( &psz_command );
251 if( isdigit( *psz_command ) )
253 if( parse_digit( &psz_command, &r ) == VLC_EGENERIC )
256 skip_space( &psz_command );
257 if( isdigit( *psz_command ) )
259 if( parse_digit( &psz_command, &g ) == VLC_EGENERIC )
262 skip_space( &psz_command );
263 if( isdigit( *psz_command ) )
265 if( parse_digit( &psz_command, &b ) == VLC_EGENERIC )
268 p_params->fontstyle.i_font_color = (r<<24) | (g<<16) | (b<<8);
272 static int parser_SetTextSize( char *psz_command, char *psz_end,
273 commandparams_t *p_params )
276 skip_space( &psz_command );
277 if( isdigit( *psz_command ) )
279 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
282 skip_space( &psz_command );
283 if( isdigit( *psz_command ) )
285 if( parse_digit( &psz_command, &p_params->fontstyle.i_font_size ) == VLC_EGENERIC )
291 static int parser_SetVisibility( char *psz_command, char *psz_end,
292 commandparams_t *p_params )
295 skip_space( &psz_command );
296 if( isdigit( *psz_command ) )
298 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
301 skip_space( &psz_command );
302 if( isdigit( *psz_command ) )
305 if( parse_digit( &psz_command, &i_vis ) == VLC_EGENERIC )
307 p_params->b_visible = (i_vis == 1) ? VLC_TRUE : VLC_FALSE;
312 /*****************************************************************************
313 * Command unparser functions
314 *****************************************************************************/
316 static int unparse_default( const commandparams_t *p_results,
320 VLC_UNUSED(p_output);
324 static int unparse_GenImage( const commandparams_t *p_results,
327 int ret = BufferPrintf( p_output, " %d", p_results->i_id );
328 if( ret != VLC_SUCCESS )
334 static int unparse_GetAlpha( const commandparams_t *p_results,
337 int ret = BufferPrintf( p_output, " %d", p_results->i_alpha );
338 if( ret != VLC_SUCCESS )
344 static int unparse_GetPosition( const commandparams_t *p_results,
347 int ret = BufferPrintf( p_output, " %d", p_results->i_x );
348 if( ret != VLC_SUCCESS )
351 ret = BufferPrintf( p_output, " %d", p_results->i_y );
352 if( ret != VLC_SUCCESS )
358 static int unparse_GetTextAlpha( const commandparams_t *p_results,
361 int ret = BufferPrintf( p_output, " %d", p_results->fontstyle.i_font_alpha );
362 if( ret != VLC_SUCCESS )
368 static int unparse_GetTextColor( const commandparams_t *p_results,
371 int ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0xff0000)>>24 );
372 if( ret != VLC_SUCCESS )
375 ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x00ff00)>>16 );
376 if( ret != VLC_SUCCESS )
379 ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x0000ff)>>8 );
380 if( ret != VLC_SUCCESS )
386 static int unparse_GetTextSize( const commandparams_t *p_results,
389 int ret = BufferPrintf( p_output, " %d", p_results->fontstyle.i_font_size );
390 if( ret != VLC_SUCCESS )
396 static int unparse_GetVisibility( const commandparams_t *p_results,
399 int ret = BufferPrintf( p_output, " %d", (p_results->b_visible ? 1 : 0) );
400 if( ret != VLC_SUCCESS ) {
406 /*****************************************************************************
408 *****************************************************************************/
409 static int exec_DataSharedMem( filter_t *p_filter,
410 const commandparams_t *p_params,
411 commandparams_t *p_results )
413 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
414 struct shmid_ds shminfo;
420 p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
423 msg_Err( p_filter, "Invalid overlay: %d", p_params->i_id );
427 if( shmctl( p_params->i_shmid, IPC_STAT, &shminfo ) == -1 )
429 msg_Err( p_filter, "Unable to access shared memory" );
432 i_size = shminfo.shm_segsz;
434 if( p_params->fourcc == VLC_FOURCC('T','E','X','T') )
438 if( (p_params->i_height != 1) || (p_params->i_width < 1) )
441 "Invalid width and/or height. when specifing text height "
442 "must be 1 and width the number of bytes in the string, "
443 "including the null terminator" );
447 if( (size_t)p_params->i_width > i_size )
450 "Insufficient data in shared memory. need %d, got %d",
451 p_params->i_width, i_size );
455 p_ovl->data.p_text = malloc( p_params->i_width );
456 if( p_ovl->data.p_text == NULL )
458 msg_Err( p_filter, "Unable to allocate string storage" );
462 vout_InitFormat( &p_ovl->format, VLC_FOURCC('T','E','X','T'),
465 p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY );
468 msg_Err( p_filter, "Unable to attach to shared memory" );
469 free( p_ovl->data.p_text );
470 p_ovl->data.p_text = NULL;
474 memcpy( p_ovl->data.p_text, p_data, p_params->i_width );
480 uint8_t *p_data, *p_in;
481 size_t i_neededsize = 0;
483 p_ovl->data.p_pic = malloc( sizeof( picture_t ) );
484 if( p_ovl->data.p_pic == NULL )
486 msg_Err( p_filter, "Unable to allocate picture structure" );
490 vout_InitFormat( &p_ovl->format, p_params->fourcc,
491 p_params->i_width, p_params->i_height,
492 VOUT_ASPECT_FACTOR );
493 if( vout_AllocatePicture( p_filter, p_ovl->data.p_pic,
494 p_ovl->format.i_chroma, p_params->i_width,
495 p_params->i_height, p_ovl->format.i_aspect ) )
497 msg_Err( p_filter, "Unable to allocate picture" );
498 free( p_ovl->data.p_pic );
499 p_ovl->data.p_pic = NULL;
503 for( size_t i_plane = 0; i_plane < (size_t)p_ovl->data.p_pic->i_planes;
506 i_neededsize += p_ovl->data.p_pic->p[i_plane].i_visible_lines *
507 p_ovl->data.p_pic->p[i_plane].i_visible_pitch;
510 if( i_neededsize > i_size )
513 "Insufficient data in shared memory. need %d, got %d",
514 i_neededsize, i_size );
515 p_ovl->data.p_pic->pf_release( p_ovl->data.p_pic );
516 free( p_ovl->data.p_pic );
517 p_ovl->data.p_pic = NULL;
521 p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY );
524 msg_Err( p_filter, "Unable to attach to shared memory" );
525 p_ovl->data.p_pic->pf_release( p_ovl->data.p_pic );
526 free( p_ovl->data.p_pic );
527 p_ovl->data.p_pic = NULL;
532 for( size_t i_plane = 0; i_plane < (size_t)p_ovl->data.p_pic->i_planes;
535 uint8_t *p_out = p_ovl->data.p_pic->p[i_plane].p_pixels;
536 for( size_t i_line = 0;
537 i_line < (size_t)p_ovl->data.p_pic->p[i_plane].i_visible_lines;
540 p_filter->p_libvlc->pf_memcpy( p_out, p_in,
541 p_ovl->data.p_pic->p[i_plane].i_visible_pitch );
542 p_out += p_ovl->data.p_pic->p[i_plane].i_pitch;
543 p_in += p_ovl->data.p_pic->p[i_plane].i_visible_pitch;
549 p_sys->b_updated = p_ovl->b_active;
554 static int exec_DeleteImage( filter_t *p_filter,
555 const commandparams_t *p_params,
556 commandparams_t *p_results )
559 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
560 p_sys->b_updated = VLC_TRUE;
562 return ListRemove( &p_sys->overlays, p_params->i_id );
565 static int exec_EndAtomic( filter_t *p_filter,
566 const commandparams_t *p_params,
567 commandparams_t *p_results )
571 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
572 QueueTransfer( &p_sys->pending, &p_sys->atomic );
573 p_sys->b_atomic = VLC_FALSE;
577 static int exec_GenImage( filter_t *p_filter,
578 const commandparams_t *p_params,
579 commandparams_t *p_results )
582 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
584 overlay_t *p_ovl = OverlayCreate();
588 ssize_t i_idx = ListAdd( &p_sys->overlays, p_ovl );
592 p_results->i_id = i_idx;
596 static int exec_GetAlpha( filter_t *p_filter,
597 const commandparams_t *p_params,
598 commandparams_t *p_results )
600 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
601 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
605 p_results->i_alpha = p_ovl->i_alpha;
609 static int exec_GetPosition( filter_t *p_filter,
610 const commandparams_t *p_params,
611 commandparams_t *p_results )
613 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
614 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
618 p_results->i_x = p_ovl->i_x;
619 p_results->i_y = p_ovl->i_y;
623 static int exec_GetTextAlpha( filter_t *p_filter,
624 const commandparams_t *p_params,
625 commandparams_t *p_results )
627 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
628 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
632 p_results->fontstyle.i_font_alpha = p_ovl->fontstyle.i_font_alpha;
636 static int exec_GetTextColor( filter_t *p_filter,
637 const commandparams_t *p_params,
638 commandparams_t *p_results )
640 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
641 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
645 p_results->fontstyle.i_font_color = p_ovl->fontstyle.i_font_color;
649 static int exec_GetTextSize( filter_t *p_filter,
650 const commandparams_t *p_params,
651 commandparams_t *p_results )
653 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
654 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
658 p_results->fontstyle.i_font_size = p_ovl->fontstyle.i_font_size;
662 static int exec_GetVisibility( filter_t *p_filter,
663 const commandparams_t *p_params,
664 commandparams_t *p_results )
666 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
668 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
672 p_results->b_visible = ( p_ovl->b_active == VLC_TRUE ) ? 1 : 0;
676 static int exec_SetAlpha( filter_t *p_filter,
677 const commandparams_t *p_params,
678 commandparams_t *p_results )
681 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
683 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
687 p_ovl->i_alpha = p_params->i_alpha;
688 p_sys->b_updated = p_ovl->b_active;
692 static int exec_SetPosition( filter_t *p_filter,
693 const commandparams_t *p_params,
694 commandparams_t *p_results )
697 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
699 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
703 p_ovl->i_x = p_params->i_x;
704 p_ovl->i_y = p_params->i_y;
706 p_sys->b_updated = p_ovl->b_active;
710 static int exec_SetTextAlpha( filter_t *p_filter,
711 const commandparams_t *p_params,
712 commandparams_t *p_results )
715 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
717 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
721 p_ovl->fontstyle.i_font_alpha = p_params->fontstyle.i_font_alpha;
722 p_sys->b_updated = p_ovl->b_active;
726 static int exec_SetTextColor( filter_t *p_filter,
727 const commandparams_t *p_params,
728 commandparams_t *p_results )
731 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
733 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
737 p_ovl->fontstyle.i_font_color = p_params->fontstyle.i_font_color;
738 p_sys->b_updated = p_ovl->b_active;
742 static int exec_SetTextSize( filter_t *p_filter,
743 const commandparams_t *p_params,
744 commandparams_t *p_results )
747 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
749 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
753 p_ovl->fontstyle.i_font_size = p_params->fontstyle.i_font_size;
754 p_sys->b_updated = p_ovl->b_active;
758 static int exec_SetVisibility( filter_t *p_filter,
759 const commandparams_t *p_params,
760 commandparams_t *p_results )
763 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
765 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
769 p_ovl->b_active = p_params->b_visible;// ? VLC_FALSE : VLC_TRUE;
770 p_sys->b_updated = VLC_TRUE;
774 static int exec_StartAtomic( filter_t *p_filter,
775 const commandparams_t *p_params,
776 commandparams_t *p_results )
778 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
782 p_sys->b_atomic = VLC_TRUE;
786 /*****************************************************************************
788 *****************************************************************************/
789 static commanddesc_t p_commands[] =
791 { .psz_command = "DataSharedMem",
792 .b_atomic = VLC_TRUE,
793 .pf_parser = parser_DataSharedMem,
794 .pf_execute = exec_DataSharedMem,
795 .pf_unparse = unparse_default,
797 { .psz_command = "DeleteImage",
798 .b_atomic = VLC_TRUE,
799 .pf_parser = parser_Id,
800 .pf_execute = exec_DeleteImage,
801 .pf_unparse = unparse_default,
803 { .psz_command = "EndAtomic",
804 .b_atomic = VLC_FALSE,
805 .pf_parser = parser_None,
806 .pf_execute = exec_EndAtomic,
807 .pf_unparse = unparse_default,
809 { .psz_command = "GenImage",
810 .b_atomic = VLC_FALSE,
811 .pf_parser = parser_None,
812 .pf_execute = exec_GenImage,
813 .pf_unparse = unparse_GenImage,
815 { .psz_command = "GetAlpha",
816 .b_atomic = VLC_FALSE,
817 .pf_parser = parser_Id,
818 .pf_execute = exec_GetAlpha,
819 .pf_unparse = unparse_GetAlpha,
821 { .psz_command = "GetPosition",
822 .b_atomic = VLC_FALSE,
823 .pf_parser = parser_Id,
824 .pf_execute = exec_GetPosition,
825 .pf_unparse = unparse_GetPosition,
827 { .psz_command = "GetTextAlpha",
828 .b_atomic = VLC_FALSE,
829 .pf_parser = parser_Id,
830 .pf_execute = exec_GetTextAlpha,
831 .pf_unparse = unparse_GetTextAlpha,
833 { .psz_command = "GetTextColor",
834 .b_atomic = VLC_FALSE,
835 .pf_parser = parser_Id,
836 .pf_execute = exec_GetTextColor,
837 .pf_unparse = unparse_GetTextColor,
839 { .psz_command = "GetTextSize",
840 .b_atomic = VLC_TRUE,
841 .pf_parser = parser_Id,
842 .pf_execute = exec_GetTextSize,
843 .pf_unparse = unparse_GetTextSize,
845 { .psz_command = "GetVisibility",
846 .b_atomic = VLC_FALSE,
847 .pf_parser = parser_Id,
848 .pf_execute = exec_GetVisibility,
849 .pf_unparse = unparse_GetVisibility,
851 { .psz_command = "SetAlpha",
852 .b_atomic = VLC_TRUE,
853 .pf_parser = parser_SetAlpha,
854 .pf_execute = exec_SetAlpha,
855 .pf_unparse = unparse_default,
857 { .psz_command = "SetPosition",
858 .b_atomic = VLC_TRUE,
859 .pf_parser = parser_SetPosition,
860 .pf_execute = exec_SetPosition,
861 .pf_unparse = unparse_default,
863 { .psz_command = "SetTextAlpha",
864 .b_atomic = VLC_TRUE,
865 .pf_parser = parser_SetTextAlpha,
866 .pf_execute = exec_SetTextAlpha,
867 .pf_unparse = unparse_default,
869 { .psz_command = "SetTextColor",
870 .b_atomic = VLC_TRUE,
871 .pf_parser = parser_SetTextColor,
872 .pf_execute = exec_SetTextColor,
873 .pf_unparse = unparse_default,
875 { .psz_command = "SetTextSize",
876 .b_atomic = VLC_TRUE,
877 .pf_parser = parser_SetTextSize,
878 .pf_execute = exec_SetTextSize,
879 .pf_unparse = unparse_default,
881 { .psz_command = "SetVisibility",
882 .b_atomic = VLC_TRUE,
883 .pf_parser = parser_SetVisibility,
884 .pf_execute = exec_SetVisibility,
885 .pf_unparse = unparse_default,
887 { .psz_command = "StartAtomic",
888 .b_atomic = VLC_TRUE,
889 .pf_parser = parser_None,
890 .pf_execute = exec_StartAtomic,
891 .pf_unparse = unparse_default,
895 void RegisterCommand( filter_t *p_filter )
897 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
900 p_sys->i_commands = ARRAY_SIZE(p_commands);
901 p_sys->pp_commands = (commanddesc_t **) calloc( p_sys->i_commands, sizeof(commanddesc_t*) );
902 if( !p_sys->pp_commands ) return;
903 for( i_index = 0; i_index < p_sys->i_commands; i_index ++ )
905 p_sys->pp_commands[i_index] = (commanddesc_t *) malloc( sizeof(commanddesc_t) );
906 if( !p_sys->pp_commands[i_index] ) return;
907 p_sys->pp_commands[i_index]->psz_command = strdup( p_commands[i_index].psz_command );
908 p_sys->pp_commands[i_index]->b_atomic = p_commands[i_index].b_atomic;
909 p_sys->pp_commands[i_index]->pf_parser = p_commands[i_index].pf_parser;
910 p_sys->pp_commands[i_index]->pf_execute = p_commands[i_index].pf_execute;
911 p_sys->pp_commands[i_index]->pf_unparse = p_commands[i_index].pf_unparse;
914 msg_Dbg( p_filter, "%d commands are available", p_sys->i_commands );
915 for( size_t i_index = 0; i_index < p_sys->i_commands; i_index++ )
916 msg_Dbg( p_filter, " %s", p_sys->pp_commands[i_index]->psz_command );
919 void UnregisterCommand( filter_t *p_filter )
921 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
924 for( i_index = 0; i_index < p_sys->i_commands; i_index++ )
926 free( p_sys->pp_commands[i_index]->psz_command );
927 free( p_sys->pp_commands[i_index] );
929 free( p_sys->pp_commands );
930 p_sys->pp_commands = NULL;
931 p_sys->i_commands = 0;