1 /*****************************************************************************
2 * intf.c: interface for CMML annotations/hyperlinks
3 *****************************************************************************
4 * Copyright (C) 2003-2004 Commonwealth Scientific and Industrial Research
5 * Organisation (CSIRO) Australia
6 * Copyright (C) 2004 the VideoLAN team
10 * Authors: Andre Pang <Andre.Pang@csiro.au>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
34 #include <vlc_common.h>
42 #include <vlc_codec.h>
43 #include <vlc_input.h>
44 #include <vlc_interface.h>
46 #include <vlc_playlist.h>
51 #include "browser_open.h"
56 #undef CMML_INTF_USE_TIMED_URIS
58 #undef CMML_INTF_DEBUG
59 #undef CMML_INTF_HISTORY_DEBUG
61 /*****************************************************************************
62 * intf_sys_t: description and status of interface
63 *****************************************************************************/
66 decoder_t * p_cmml_decoder;
67 input_thread_t * p_input;
72 struct navigation_history_t
78 /*****************************************************************************
80 *****************************************************************************/
82 int OpenIntf ( vlc_object_t * );
83 void CloseIntf ( vlc_object_t * );
85 static int InitThread ( intf_thread_t * );
86 static int MouseEvent ( vlc_object_t *, char const *,
87 vlc_value_t, vlc_value_t, void * );
88 static int KeyEvent ( vlc_object_t *, char const *,
89 vlc_value_t, vlc_value_t, void * );
91 static void FollowAnchor ( intf_thread_t * );
92 static void GoBack ( intf_thread_t * );
93 static void GoForward ( intf_thread_t * );
95 static int FollowAnchorCallback ( vlc_object_t *, char const *,
96 vlc_value_t, vlc_value_t, void * );
97 static int GoBackCallback ( vlc_object_t *, char const *,
98 vlc_value_t, vlc_value_t, void * );
99 static int GoForwardCallback ( vlc_object_t *, char const *,
100 vlc_value_t, vlc_value_t, void * );
102 static char *GetTimedURLFromPlaylistItem( intf_thread_t *, playlist_item_t * );
103 #ifdef CMML_INTF_USE_TIMED_URIS
104 static int GetCurrentTimeInSeconds ( input_thread_t * );
105 static char *GetTimedURIFragmentForTime ( int );
107 static int DisplayAnchor ( intf_thread_t *, vout_thread_t *,
109 static int DisplayPendingAnchor ( intf_thread_t *, vout_thread_t * );
110 static history_t * GetHistory ( playlist_t * );
111 static void ReplacePlaylistItem ( playlist_t *, char * );
113 /* Exported functions */
114 static void RunIntf ( intf_thread_t *p_intf );
116 /*****************************************************************************
117 * OpenIntf: initialize CMML interface
118 *****************************************************************************/
119 int OpenIntf ( vlc_object_t *p_this )
121 intf_thread_t *p_intf = (intf_thread_t *)p_this;
123 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
124 if( p_intf->p_sys == NULL )
127 p_intf->pf_run = RunIntf;
129 var_AddCallback( p_intf->p_libvlc, "key-action", KeyEvent, p_intf );
130 /* we also need to add the callback for "mouse-clicked", but do that later
131 * when we've found a p_vout */
133 var_Create( p_intf->p_libvlc, "browse-go-back", VLC_VAR_VOID );
134 var_AddCallback( p_intf->p_libvlc, "browse-go-back",
135 GoBackCallback, p_intf );
136 var_Create( p_intf->p_libvlc, "browse-go-forward", VLC_VAR_VOID );
137 var_AddCallback( p_intf->p_libvlc, "browse-go-forward",
138 GoForwardCallback, p_intf );
139 var_Create( p_intf->p_libvlc, "browse-follow-anchor", VLC_VAR_VOID );
140 var_AddCallback( p_intf->p_libvlc, "browse-follow-anchor",
141 FollowAnchorCallback, p_intf );
146 /*****************************************************************************
147 * CloseIntf: destroy dummy interface
148 *****************************************************************************/
149 void CloseIntf ( vlc_object_t *p_this )
151 intf_thread_t * p_intf = (intf_thread_t *)p_this;
152 vout_thread_t * p_vout;
154 #ifdef CMML_INTF_DEBUG
155 msg_Dbg( p_intf, "freeing CMML interface" );
158 /* erase the anchor text description from the video output if it exists */
159 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
162 /* enable CMML as a subtitle track */
163 spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
164 vlc_object_release( p_vout );
167 var_DelCallback( p_intf->p_libvlc, "key-action", KeyEvent, p_intf );
169 vlc_object_release( p_intf->p_sys->p_cmml_decoder );
171 free( p_intf->p_sys );
175 /*****************************************************************************
177 *****************************************************************************/
178 static void RunIntf( intf_thread_t *p_intf )
180 int canc = vlc_savecancel();
181 vout_thread_t * p_vout = NULL;
183 if( InitThread( p_intf ) < 0 )
185 msg_Err( p_intf, "can't initialize CMML interface" );
188 #ifdef CMML_INTF_DEBUG
189 msg_Dbg( p_intf, "CMML intf initialized" );
193 while( vlc_object_alive (p_intf) )
195 /* if video output is dying, disassociate ourselves from it */
196 if( p_vout && !vlc_object_alive (p_vout) )
198 var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
199 vlc_object_release( p_vout );
203 /* find a video output if we currently don't have one */
206 p_vout = vlc_object_find( p_intf->p_sys->p_input,
207 VLC_OBJECT_VOUT, FIND_CHILD );
210 #ifdef CMML_INTF_DEBUG
211 msg_Dbg( p_intf, "found vout thread" );
213 var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
217 vlc_mutex_lock( &p_intf->change_lock );
222 switch( p_intf->p_sys->i_key_action )
224 case ACTIONID_NAV_ACTIVATE:
225 FollowAnchor( p_intf );
227 case ACTIONID_HISTORY_BACK:
230 case ACTIONID_HISTORY_FORWARD:
236 p_intf->p_sys->i_key_action = 0;
237 vlc_mutex_unlock( &p_intf->change_lock );
239 (void) DisplayPendingAnchor( p_intf, p_vout );
242 msleep( INTF_IDLE_SLEEP );
245 /* if we're here, the video output is dying: release the vout object */
249 var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
250 vlc_object_release( p_vout );
253 vlc_object_release( p_intf->p_sys->p_input );
254 vlc_restorecancel( canc );
257 /*****************************************************************************
258 * DisplayPendingAnchor: get a pending anchor description/URL from the CMML
259 * decoder and display it on screen
260 *****************************************************************************/
261 static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
263 decoder_t *p_cmml_decoder;
264 char *psz_description = NULL;
265 char *psz_url = NULL;
267 intf_thread_t *p_primary_intf;
270 p_cmml_decoder = p_intf->p_sys->p_cmml_decoder;
271 if( var_Get( p_cmml_decoder, "psz-current-anchor-description", &val )
280 psz_description = val.p_address;
282 if( var_Get( p_cmml_decoder, "psz-current-anchor-url", &val )
285 psz_url = val.p_address;
290 /* don't display anchor if main interface can display it */
291 p_primary_intf = vlc_object_find( p_intf->p_libvlc, VLC_OBJECT_INTF,
296 if( var_Get( p_primary_intf, "intf-displays-cmml-description", &val )
299 if( val.b_bool == true )
301 vlc_object_release( p_primary_intf );
306 vlc_object_release( p_primary_intf );
309 /* display anchor as subtitle on-screen */
310 if( DisplayAnchor( p_intf, p_vout, psz_description, psz_url )
313 /* text render unsuccessful: do nothing */
317 /* text render successful: clear description */
318 val.p_address = NULL;
319 if( var_Set( p_cmml_decoder, "psz-current-anchor-description", val )
323 "reset of psz-current-anchor-description failed" );
325 free( psz_description );
333 /*****************************************************************************
335 *****************************************************************************/
336 static int InitThread( intf_thread_t * p_intf )
338 /* We might need some locking here */
339 if( vlc_object_alive (p_intf) )
341 input_thread_t * p_input;
342 decoder_t *p_cmml_decoder;
344 p_cmml_decoder = vlc_object_find( p_intf, VLC_OBJECT_DECODER, FIND_PARENT );
345 p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_PARENT );
347 #ifdef CMML_INTF_DEBUG
348 msg_Dbg( p_intf, "cmml decoder at %p, input thread at %p",
349 p_cmml_decoder, p_input );
352 /* Maybe the input just died */
353 if( p_input == NULL )
358 vlc_mutex_lock( &p_intf->change_lock );
360 p_intf->p_sys->p_input = p_input;
361 p_intf->p_sys->p_cmml_decoder = p_cmml_decoder;
363 p_intf->p_sys->i_key_action = 0;
365 vlc_mutex_unlock( &p_intf->change_lock );
375 /*****************************************************************************
376 * MouseEvent: callback for mouse events
377 *****************************************************************************/
378 static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
379 vlc_value_t oldval, vlc_value_t newval, void *p_data )
381 VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
382 VLC_UNUSED(oldval); VLC_UNUSED(newval);
384 /* TODO: handle mouse clicks on the anchor text */
389 /*****************************************************************************
390 * KeyEvent: callback for keyboard events
391 *****************************************************************************/
392 static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
393 vlc_value_t oldval, vlc_value_t newval, void *p_data )
395 VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
396 VLC_UNUSED(oldval); VLC_UNUSED(newval);
397 intf_thread_t *p_intf = (intf_thread_t *)p_data;
398 vlc_mutex_lock( &p_intf->change_lock );
400 p_intf->p_sys->i_key_action = newval.i_int;
402 vlc_mutex_unlock( &p_intf->change_lock );
407 /*****************************************************************************
408 * FollowAnchor: follow the current anchor being displayed to the user
409 *****************************************************************************/
410 static void FollowAnchor ( intf_thread_t *p_intf )
413 decoder_t *p_cmml_decoder;
414 char *psz_url = NULL;
417 msg_Dbg( p_intf, "User followed anchor" );
419 p_sys = p_intf->p_sys;
420 p_cmml_decoder = p_sys->p_cmml_decoder;
422 if( var_Get( p_cmml_decoder, "psz-current-anchor-url", &val ) ==
425 if( val.p_address ) psz_url = val.p_address;
428 #ifdef CMML_INTF_DEBUG
429 msg_Dbg( p_intf, "Current URL is \"%s\"", psz_url );
434 playlist_t *p_playlist;
435 playlist_item_t *p_current_item;
436 char *psz_uri_to_load;
440 p_playlist = pl_Hold( p_intf );
443 p_current_item = playlist_CurrentPlayingItem( p_playlist );
444 char *psz_uri = input_item_GetURI( p_current_item->p_input );
445 #ifdef CMML_INTF_DEBUG
446 msg_Dbg( p_intf, "Current playlist item URL is \"%s\"", psz_uri );
449 psz_uri_to_load = XURL_Concat( psz_uri, psz_url );
452 #ifdef CMML_INTF_DEBUG
453 msg_Dbg( p_intf, "URL to load is \"%s\"", psz_uri_to_load );
456 if( var_Get( p_intf->p_sys->p_input, "time", &time ) )
458 msg_Dbg( p_intf, "couldn't get time from current clip" );
461 i_seconds = time.i_time / 1000000;
462 #ifdef CMML_INTF_DEBUG
463 msg_Dbg( p_intf, "Current time is \"%lld\"", i_seconds );
466 /* TODO: we need a (much) more robust way of detecting whether
467 * the file's a media file ... */
468 if( strstr( psz_uri_to_load, ".anx" ) != NULL )
470 history_t *p_history = NULL;
471 history_item_t *p_history_item = NULL;
474 p_history = GetHistory( p_playlist );
476 /* create history item */
477 psz_timed_url = GetTimedURLFromPlaylistItem( p_intf, p_current_item );
478 p_history_item = historyItem_New( psz_timed_url, psz_timed_url );
479 free( psz_timed_url );
481 if( !p_history_item )
483 msg_Warn( p_intf, "could not initialise history item" );
487 #ifdef CMML_INTF_DEBUG
488 msg_Dbg( p_intf, "history pre-index %d", p_history->i_index );
490 history_PruneAndInsert( p_history, p_history_item );
491 #ifdef CMML_INTF_DEBUG
492 msg_Dbg( p_intf, "new history item at %p, uri is \"%s\"",
493 p_history_item, p_history_item->psz_uri );
494 msg_Dbg( p_intf, "history index now %d", p_history->i_index );
498 /* free current-anchor-url */
500 val.p_address = NULL;
501 if( var_Set( p_cmml_decoder, "psz-current-anchor-url", val ) !=
504 msg_Dbg( p_intf, "couldn't reset psz-current-anchor-url" );
507 ReplacePlaylistItem( p_playlist, psz_uri_to_load );
511 #ifdef CMML_INTF_DEBUG
512 msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
514 (void) browser_Open( psz_url );
515 playlist_Control( p_playlist, PLAYLIST_PAUSE, pl_Unlocked, 0 );
518 free( psz_uri_to_load );
520 vlc_object_release( p_playlist );
525 char *GetTimedURLFromPlaylistItem( intf_thread_t *p_intf,
526 playlist_item_t *p_current_item )
528 #ifdef CMML_INTF_USE_TIMED_URIS
529 char *psz_url = NULL;
530 char *psz_return_value = NULL;
531 char *psz_seconds = NULL;
534 char *psz_uri = input_item_GetURI( p_current_item->p_input );
535 psz_url = XURL_GetWithoutFragment( psz_uri );
538 /* Get current time as a string */
539 if( XURL_IsFileURL( psz_url ) == true )
540 psz_url = xstrcat( psz_url, "#" );
542 psz_url = xstrcat( psz_url, "?" );
544 /* jump back to 2 seconds before where we are now */
545 i_seconds = GetCurrentTimeInSeconds( p_intf->p_sys->p_input ) - 2;
546 psz_seconds = GetTimedURIFragmentForTime( i_seconds < 0 ? 0 : i_seconds );
549 psz_url = xstrcat( psz_url, psz_seconds );
551 psz_return_value = psz_url;
554 return psz_return_value;
558 return input_item_GetURI( p_current_item->p_input );
564 #ifdef CMML_INTF_USE_TIMED_URIS
566 * Get the current time, rounded down to the nearest second
568 * http://www.ietf.org/internet-drafts/draft-pfeiffer-temporal-fragments-02.txt
571 int GetCurrentTimeInSeconds( input_thread_t *p_input )
576 var_Get( p_input, "time", &time );
577 i_seconds = time.i_time / 1000000;
582 char *GetTimedURIFragmentForTime( int seconds )
586 if( asprintf( &psz_time, "%d", seconds ) == -1 )
593 int GoBackCallback( vlc_object_t *p_this, char const *psz_var,
594 vlc_value_t oldval, vlc_value_t newval, void *p_data )
596 VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
597 VLC_UNUSED(oldval); VLC_UNUSED(newval);
598 intf_thread_t *p_intf = (intf_thread_t *) p_data;
604 int GoForwardCallback( vlc_object_t *p_this, char const *psz_var,
605 vlc_value_t oldval, vlc_value_t newval, void *p_data )
607 VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
608 VLC_UNUSED(oldval); VLC_UNUSED(newval);
609 intf_thread_t *p_intf = (intf_thread_t *) p_data;
615 int FollowAnchorCallback( vlc_object_t *p_this, char const *psz_var,
616 vlc_value_t oldval, vlc_value_t newval,
619 VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
620 VLC_UNUSED(oldval); VLC_UNUSED(newval);
621 intf_thread_t *p_intf = (intf_thread_t *) p_data;
622 FollowAnchor( p_intf );
627 void GoBack( intf_thread_t *p_intf )
630 history_t *p_history = NULL;
631 history_item_t *p_history_item = NULL;
632 history_item_t *p_new_history_item = NULL;
633 playlist_t *p_playlist = NULL;
634 char *psz_timed_url = NULL;
635 playlist_item_t *p_current_item;
637 #ifdef CMML_INTF_DEBUG
638 msg_Dbg( p_intf, "Going back in navigation history" );
641 /* Find the playlist */
642 p_playlist = pl_Hold( p_intf );
644 /* Retrieve navigation history from playlist */
645 if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
648 /* History doesn't exist yet: ignore user's request */
649 msg_Warn( p_intf, "can't go back: no history exists yet" );
650 vlc_object_release( p_playlist );
654 p_history = history.p_address;
655 #ifdef CMML_INTF_DEBUG
656 msg_Dbg( p_intf, "back: nav history retrieved from %p", p_history );
657 msg_Dbg( p_intf, "nav history index:%d, p_xarray:%p", p_history->i_index,
658 p_history->p_xarray );
661 /* Check whether we can go back in the history */
662 if( history_CanGoBack( p_history ) == false )
664 msg_Warn( p_intf, "can't go back: already at beginning of history" );
665 vlc_object_release( p_playlist );
669 p_current_item = playlist_CurrentPlayingItem( p_playlist );
671 /* Save the currently-playing media in a new history item */
672 psz_timed_url = GetTimedURLFromPlaylistItem( p_intf, p_current_item );
673 p_new_history_item = historyItem_New( psz_timed_url, psz_timed_url );
674 free( psz_timed_url );
676 if( !p_new_history_item )
678 #ifdef CMML_INTF_DEBUG
679 msg_Dbg( p_intf, "back: could not initialise new history item" );
681 vlc_object_release( p_playlist );
685 /* Go back in the history, saving the currently-playing item */
686 (void) history_GoBackSavingCurrentItem( p_history, p_new_history_item );
687 p_history_item = history_Item( p_history );
689 #ifdef CMML_INTF_DEBUG
690 msg_Dbg( p_intf, "retrieving item from h index %d", p_history->i_index );
691 msg_Dbg( p_intf, "got previous history item: %p", p_history_item );
692 msg_Dbg( p_intf, "prev history item URL: \"%s\"", p_history_item->psz_uri );
695 ReplacePlaylistItem( p_playlist, p_history_item->psz_uri );
696 vlc_object_release( p_playlist );
700 void GoForward( intf_thread_t *p_intf )
703 history_t *p_history = NULL;
704 history_item_t *p_history_item = NULL;
705 history_item_t *p_new_history_item = NULL;
706 playlist_t *p_playlist = NULL;
707 playlist_item_t *p_current_item;
709 #ifdef CMML_INTF_DEBUG
710 msg_Dbg( p_intf, "Going forward in navigation history" );
713 /* Find the playlist */
714 p_playlist = pl_Hold( p_intf );
716 /* Retrieve navigation history from playlist */
717 if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
720 /* History doesn't exist yet: ignore user's request */
721 msg_Warn( p_intf, "can't go back: no history exists yet" );
722 vlc_object_release( p_playlist );
726 p_history = history.p_address;
727 #ifdef CMML_INTF_DEBUG
728 msg_Dbg( p_intf, "forward: nav history retrieved from %p", p_history );
729 msg_Dbg( p_intf, "nav history index:%d, p_xarray:%p", p_history->i_index,
730 p_history->p_xarray );
733 /* Check whether we can go forward in the history */
734 if( history_CanGoForward( p_history ) == false )
736 msg_Warn( p_intf, "can't go forward: already at end of history" );
737 vlc_object_release( p_playlist );
741 /* Save the currently-playing media in a new history item */
742 p_new_history_item = malloc( sizeof(history_item_t) );
743 if( !p_new_history_item )
745 #ifdef CMML_INTF_DEBUG
746 msg_Dbg( p_intf, "forward: could not initialise new history item" );
748 vlc_object_release( p_playlist );
751 p_current_item = playlist_CurrentPlayingItem( p_playlist );
752 p_new_history_item->psz_uri = GetTimedURLFromPlaylistItem( p_intf,
754 p_new_history_item->psz_name = p_new_history_item->psz_uri;
756 /* Go forward in the history, saving the currently-playing item */
757 (void) history_GoForwardSavingCurrentItem( p_history, p_new_history_item );
758 p_history_item = history_Item( p_history );
760 #ifdef CMML_INTF_DEBUG
761 msg_Dbg( p_intf, "retrieving item from h index %d", p_history->i_index );
762 msg_Dbg( p_intf, "got next history item: %p", p_history_item );
763 msg_Dbg( p_intf, "next history item URL: \"%s\"", p_history_item->psz_uri );
766 ReplacePlaylistItem( p_playlist, p_history_item->psz_uri );
767 vlc_object_release( p_playlist );
770 static void ReplacePlaylistItem( playlist_t *p_playlist, char *psz_uri )
772 playlist_Stop( p_playlist );
773 (void) playlist_Add( p_playlist, psz_uri, psz_uri,
774 PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, true /* FIXME: p_playlist->status.i_index */,
778 /****************************************************************************
779 * DisplayAnchor: displays an anchor on the given video output
780 ****************************************************************************/
781 static int DisplayAnchor( intf_thread_t *p_intf,
782 vout_thread_t *p_vout,
783 char *psz_anchor_description,
784 char *psz_anchor_url )
786 int i_margin_h, i_margin_v;
798 /* Should display subtitle underlined and in blue, but it looks
799 * like VLC doesn't implement any text styles yet. D'oh! */
800 // p_style = &blue_with_underline;
804 /* TODO: p_subpicture doesn't have the proper i_x and i_y
805 * coordinates. Need to look at the subpicture display system to
807 if ( vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN,
808 psz_anchor_description, NULL, OSD_ALIGN_BOTTOM,
809 i_margin_h, i_margin_v, i_now, 0 ) == VLC_SUCCESS )
811 /* Displayed successfully */
820 msg_Dbg( p_intf, "DisplayAnchor couldn't find a video output" );
827 static history_t * GetHistory( playlist_t *p_playlist )
830 history_t *p_history = NULL;
832 if( var_Get( p_playlist, "navigation-history", &val ) != VLC_SUCCESS )
834 /* history doesn't exist yet: need to create it */
835 history_t *new_history = history_New();
836 val.p_address = new_history;
837 var_Create( p_playlist, "navigation-history",
838 VLC_VAR_ADDRESS|VLC_VAR_DOINHERIT );
839 if( var_Set( p_playlist, "navigation-history", val ) != VLC_SUCCESS )
841 msg_Warn( p_playlist, "could not initialise history" );
845 p_history = new_history;
846 #ifdef CMML_INTF_HISTORY_DEBUG
847 msg_Dbg( p_playlist, "nav history created at %p", new_history );
848 msg_Dbg( p_playlist, "nav history index:%d, p_xarray:%p",
849 p_history->i_index, p_history->p_xarray );
855 p_history = val.p_address;
856 #ifdef CMML_INTF_HISTORY_DEBUG
857 msg_Dbg( p_playlist, "nav history retrieved from %p", p_history );