User Tools

Site Tools


refresh_on_demand

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
refresh_on_demand [2012/04/27 23:24]
jhb50
refresh_on_demand [2012/04/28 17:10]
jhb50
Line 9: Line 9:
 There are two ways to initiate those more frequent refreshes. There are two ways to initiate those more frequent refreshes.
  
-One approach is to create a WebResource groovy for the feed and set the expiry date to initiate refreshes of that feed on periodic basis consistent with the known dynamics of the source for example just before the start of the next scheduled sports event or every 30 minutes for a news feed. +One approach is to create a WebResource groovy for the feed and set the expiry date to initiate refreshes of that feed on periodic basis consistent with the known dynamics of the source for example just before the start of the next scheduled sports event or every few minutes for a news feed. 
  
 The Online Source ("feed") HAHASPORT.COM and its WebResource groovy is an example. This site maintains and provides a list of scheduled events by sport, and provides links to embedded player streams of events as they go live ("feed items"). To maintain currency of a Serviio menu, the list of scheduled events must be reviewed by the groovy at least hourly since new events ("feed items") can be added or removed at any time; live events ("feed items") must be detected minutes prior to their scheduled start, and if not yet started, again at their scheduled start and a few minutes thereafter; and then live events ("feed items") must be removed a few minutes after their scheduled end time.  The Online Source ("feed") HAHASPORT.COM and its WebResource groovy is an example. This site maintains and provides a list of scheduled events by sport, and provides links to embedded player streams of events as they go live ("feed items"). To maintain currency of a Serviio menu, the list of scheduled events must be reviewed by the groovy at least hourly since new events ("feed items") can be added or removed at any time; live events ("feed items") must be detected minutes prior to their scheduled start, and if not yet started, again at their scheduled start and a few minutes thereafter; and then live events ("feed items") must be removed a few minutes after their scheduled end time. 
Line 15: Line 15:
 The problem with this approach is the continual use of resources by the groovy to refresh and maintain the current set of feed items even though they may never be used. Secondly, this constant stream of refreshes particularly when multiple sport feeds are enabled, is beyond the capacity of most systems and feed refreshes are constantly backlogged due to insufficient time to access the changing feed items. The problem with this approach is the continual use of resources by the groovy to refresh and maintain the current set of feed items even though they may never be used. Secondly, this constant stream of refreshes particularly when multiple sport feeds are enabled, is beyond the capacity of most systems and feed refreshes are constantly backlogged due to insufficient time to access the changing feed items.
  
-The better approach is to be able to "Force Refresh" a feed just prior to its use. However the problem with this approach is that if a significant number of new feed items have been created since the previous refresh, it may take Serviio many minutes to refresh and make the feed available again. Another problem is that while the Serviio Server Console and various Remote Device Console implementations offer the ability to "Force Refresh" Online Sources On Demand, no capability is offered to initiate a "Force Refresh" on demand from the menus on a Client device. so users must access the server or obtain a device which has 3rd party remote console support.+The better approach is to be able to "Force Refresh" a feed just prior to its use. However the problem with this approach is that if a significant number of new feed items have been created since the previous refresh, it may take Serviio many minutes to refresh and make the feed available again, since each new item can take 30 seconds or more to add. Another problem is that while the Serviio Server Console and various Remote Device Console implementations offer the ability to "Force Refresh" Online Sources On Demand, no capability is offered to initiate a "Force Refresh" on demand from the menus on a Client device. so users must access the server or obtain a device which has 3rd party remote console support.
  
-The ultimate solution therefore is to implement these dynamic feeds with a Web Resource that refreshes on a periodic basis that will minimize the number of new feed items to be added by a "Force Refresh", and to provide a "Force Refresh" capability from the menus on the client device, that may be used just prior to using the feed. +The ultimate solution therefore is to implement these dynamic feeds with a Web Resource that refreshes on a periodic basis in order to minimize the number of new feed items that will need to be added by a "Force Refresh", and to provide a "Force Refresh" capability from the menus on the client device, that may be used just prior to using the dynamic feed. 
  
 The facility to initiate periodic refreshes more frequently than the console default refresh value is documented in the "Serviio Online Resource plugin implementation Guide" under "Date expiresOn" Date is based on the current time {long curTimea = System.currentTimeMillis()} plus the milliseconds to the desired expiry time. Note that expiry will be on the earliest of that Date and the console default, and the refresh will actually be performed by Serviio 5 minutes ahead of that time.  The facility to initiate periodic refreshes more frequently than the console default refresh value is documented in the "Serviio Online Resource plugin implementation Guide" under "Date expiresOn" Date is based on the current time {long curTimea = System.currentTimeMillis()} plus the milliseconds to the desired expiry time. Note that expiry will be on the earliest of that Date and the console default, and the refresh will actually be performed by Serviio 5 minutes ahead of that time. 
  
-The facility to initiate "Force Refresh" from the menus on the client device is documented below, and consists of a WebResource RefreshWebResources.groovy that generates a menu of "Force Refresh" feed items for all WebResource feeds in the Serviio online library, which allows one or more feeds to be refreshed on demand, and "forcerefresh" method that may be included in any WebResource groovy to create a "Force Refresh" "feed item" within the Webresource menu itself.+The hahasports.groovy accepts a refresh=nnn parameter that removes the automatic refresh based on event times and only refreshes the feed every nnn minutes. "Force Refresh" is then used to refresh any new feed items in a feed prior to opening the feed. Other dynamic feeds should implement similar capability.
  
-Consistent with this approach the HAHASPORT.GROOVY implements an automatic "expires onrefresh every 60 minutes and the method which creates a "Force Refresh" feed itemIt may be reviewed as an example of the methodology.+The facility to initiate "Force Refreshfrom a menu on the client device is documented below, and consists of WebResource RefreshWebResources.groovy that generates a menu of "Force Refresh" feed items for all WebResource feeds in the Serviio online libraryClicking on a feed initiates its "Forced Refresh" and starts playback of the ISS video stream. The feed is then removed from the list of Online feeds and becomes available again by opening the Online menu once the refresh is complete
  
 __ON DEMAND METHODOLOGY__ __ON DEMAND METHODOLOGY__
  
-The ability to implement "Force Refresh" feed items in the RefreshWebResources.groovy and the "forcerefresh" method in any WebResource is based on 5 prerequisite one time implementations:+The ability to implement "Force Refresh" feed items in the RefreshWebResources.groovy is based on 5 prerequisite one time implementations:
  
 1) The installation of CURL.EXE which provides the abilty to access the Serviio repository data and initiate forced refreshes per the latest "Serviio REST interface specification.pdf" The curl.exe may be obtained from http://curl.haxx.se/dlwiz/?type=bin and use the wizard to select the correct package for your operating system and install it in the appropriate system library. I used the generic Win64-ssl package and copied curl.exe into C:\windows\sysWOW64. W32 users should get the generic Win32 package and copy curl.exe into C:\windows\system32 1) The installation of CURL.EXE which provides the abilty to access the Serviio repository data and initiate forced refreshes per the latest "Serviio REST interface specification.pdf" The curl.exe may be obtained from http://curl.haxx.se/dlwiz/?type=bin and use the wizard to select the correct package for your operating system and install it in the appropriate system library. I used the generic Win64-ssl package and copied curl.exe into C:\windows\sysWOW64. W32 users should get the generic Win32 package and copy curl.exe into C:\windows\system32
Line 41: Line 41:
 </code> </code>
 5) The installation of the attached ffmpeg.bat as C:\Program Files\Serviio\lib\ffmpeg.bat which will detect the ffmpeg calls containing the ISS URL, extract the "vValue" nnn and issue the curl command to refresh the Serviio online library nnn, before calling ffmpeg to process the original ffmpeg call. Note the ffmpeg.bat also logs each ffmpeg call in C:\Program Files\Serviio\log\ffmpeg.log which I have found useful for debugging. The bat may be edited to comment out that line as noted in the bat. 5) The installation of the attached ffmpeg.bat as C:\Program Files\Serviio\lib\ffmpeg.bat which will detect the ffmpeg calls containing the ISS URL, extract the "vValue" nnn and issue the curl command to refresh the Serviio online library nnn, before calling ffmpeg to process the original ffmpeg call. Note the ffmpeg.bat also logs each ffmpeg call in C:\Program Files\Serviio\log\ffmpeg.log which I have found useful for debugging. The bat may be edited to comment out that line as noted in the bat.
- 
-__THE HAHASPORT IMPLEMENTATION__ 
- 
-The HAHASPORT.GROOVY uses the c- value in the hahasport url (eg: %%http://www.hahasport.com/c-3.html%%)to determine the sport events to be displayed. Similarly that url is used to determine which online library id to refresh. 
- 
-It also uses parameters following the url (%%eg:http://www.hahasport.com/c-3.html?refresh=60&estreams=9%%) to establish each mode of operation: Totally automatic refreshes, refresh on demand from console or refresh groovy, and refresh on demand with folder refresh icon. 
- 
-If no refresh=nnn parameter is provided, the groovy will cause automatic refreshes to occur on a frequent basis dictated by scheduled events with no longer than 60 minutes between automatic refreshes. This mode is appropriate for those who have not implemented the above Refresh on Demand methodology or do not wish to use the server or remote console to "Force Refresh" 
- 
-If a refresh=nnn parameter is provided, the groovy will refresh every nn minutes, or according to the console default value if it is less, and no automatic more frequent refreshes based on event schedules will occur. This is appropriate to those who only wish to use the server or remote console "Force Refresh" function and/or, for those who implemented the above methodology, the RefreshWebResource.groovy rather than the "Click to Refresh Folder" icon within each folder. For those who also wish to use the "Click to Refresh Folder" icon within each folder it may be generated by also providing an icon=yes parameter. 
- 
-The HAHASPORT.GROOVY uses "%%https://sites.google.com/site/serviiorss/refresh.jpg%%" as the thumbnail, "Click to Refresh" as the videotitle and "%%rtsp://a1709.l1856953708.c18569.g.lm.akamaistream.net:554/D/1709/18569/vn/reflector:53708%%" (which is the view from the ISS) as the Refresh Menu item stream where the n in vn corresponds to the c- value in the ResourceUrl. 
  
 With these changes clicking on the Refresh menu item, initiates a refresh of the corresponding online source while the Refresh Menu Item stream plays. If one waits for the refresh to complete before stopping playback, the refreshed menu will be displayed on return and the desired item selected for playback, else the menu will be unavailable on return and Serviio will exit and require a restart to access the updated menu once available. (Note that a refresh can require up to 30 seconds to cache a new item, but with hourly automatic updates many of the events should already be cached). With these changes clicking on the Refresh menu item, initiates a refresh of the corresponding online source while the Refresh Menu Item stream plays. If one waits for the refresh to complete before stopping playback, the refreshed menu will be displayed on return and the desired item selected for playback, else the menu will be unavailable on return and Serviio will exit and require a restart to access the updated menu once available. (Note that a refresh can require up to 30 seconds to cache a new item, but with hourly automatic updates many of the events should already be cached).
refresh_on_demand.txt ยท Last modified: 2012/08/06 14:06 by jhb50