Results 1 to 2 of 2

Thread: nDVR dvrPlaylistRequestDelegate not working.

  1. #1
    Join Date
    Jul 2013
    Posts
    1

    Default nDVR dvrPlaylistRequestDelegate not working.

    Hello!

    I'm using Wowza 3.5.2 with nDVR addon.
    I have written my own dvrPlaylistRequestDelegate from sample code. Purpose of this delegate is to get playlist from nDVR in UTC time mode.

    package com.wowza.wms.plugin.getutc;
    
    import java.text.DateFormat;
    import java.text.*;
    import java.util.*;
    
    import org.apache.commons.lang.*;
    
    import com.wowza.wms.application.WMSProperties;
    import com.wowza.wms.dvr.*;
    import com.wowza.wms.dvr.IDvrConstants.DvrTimeScale;
    import com.wowza.wms.httpstreamer.model.IHTTPStreamerApplicationContext;
    import com.wowza.wms.logging.WMSLoggerFactory;
    
    public class Getutc extends DvrBasePlaylistRequestDelegate {
    	private static final String CLASSNAME = "Getutc";
    	private static final Class<Getutc> CLASS = Getutc.class;
    	
        public static final String DVR_QUERYSTR_PLAYLIST_DURATION = "duration";
        public static final String DVR_QUERYSTR_PLAYLIST_START = "start";
        public static final String PROPKEY_DVR_PLAYLIST_DURATION_QUERY_PARAMETER = "dvrPlaylistDurationQueryParameter";
        public static final String PROPKEY_DVR_PLAYLIST_START_QUERY_PARAMETER = "dvrPlaylistStartQueryParameter";
        public static final String PROPKEY_DVR_PLAYLIST_LOG_REQUESTS = "dvrPlaylistDebugRequests";
        
    //    private boolean doDebug = true;
        String UTC_FORMAT = "yyyy-MM-dd-HH:mm:ss";
        DateFormat formatter = new SimpleDateFormat(UTC_FORMAT);
        
        public DvrPlaylistRequest getDvrPlaylistRequest(IHTTPStreamerApplicationContext appContext, IDvrStreamStore store, Map<String, String> queryMap) {       
            
        	WMSProperties dvrProperties = getDvrProperties(appContext);
        	String playStartQueryParameter = dvrProperties.getPropertyStr(PROPKEY_DVR_PLAYLIST_START_QUERY_PARAMETER, DVR_QUERYSTR_PLAYLIST_START);
        	String playDurationQueryParameter = dvrProperties.getPropertyStr(PROPKEY_DVR_PLAYLIST_DURATION_QUERY_PARAMETER, DVR_QUERYSTR_PLAYLIST_DURATION);
    
        	String playStartStr = queryMap.get(playStartQueryParameter);
        	String playDurationStr = queryMap.get(playDurationQueryParameter);
    
        	DvrPlaylistRequest fullPlaylistRequest = getDefaultLivePlaylistRequest(DvrTimeScale.UTC_TIME, store);
            
        	Date date = null;
            if (!StringUtils.isEmpty(playStartStr)) {
                 try {
                    date = (Date)formatter.parse(playStartStr);  
                 } catch (ParseException e) {
                    date = null;
                    //e.printStackTrace();
                }
            }
            System.out.printf("'%s' --> date:%s\n", playStartStr, date);
    
             // If the date specified is less than the initial date we have to play, its not valid
             if (date != null && date.before(new Date(fullPlaylistRequest.getPlaylistStart())))
             {
                  System.out.println("Requested start time before actual recording.");
                  date = new Date(fullPlaylistRequest.getPlaylistStart());
             }
    
            DvrPlaylistRequest req;
            if (date != null) {
                req = new DvrPlaylistRequest(DvrTimeScale.UTC_TIME);
                req.setPlaylistStart(date.getTime());
            } else {
                // Use default
                req = super.getDvrPlaylistRequest(appContext, store, queryMap);
            }
            System.out.printf("%s : Resolved Playlist: %s \n", CLASSNAME, req);
            return req;
        }
    it is connected to my Wowza instance in Application.xml:
    			<!-- Properties for DVR -->
    			<Properties>
    				<Property>
    					<Name>dvrPlaylistRequestDelegate</Name>
    					<Value>com.wowza.wms.plugin.getutc.Getutc</Value>
    				</Property>
    				<Property>
    					<Name>dvrPlaylistDurationQueryParameter</Name>
    					<Value>duration</Value>
    				</Property>	
    				<Property>
    					<Name>dvrPlaylistStartQueryParameter</Name>
    					<Value>start</Value>
    				</Property>	
    			</Properties>
    it's connected ok, because i can read it's debug output in console window:
    INFO stream play xx12.stream -
    '2013-07-25-11:25:00' --> date:Thu Jul 25 11:25:00 FET 2013
    Getutc : Resolved Playlist: {DvrPlaylistRequest: [live] timeScale:UTC_TIME playlistStart:1374740700000, playlistEnd:ignored}
    INFO cupertino connect 863836031 -
    INFO stream create xx12.stream -
    INFO stream play xx12.stream -
    but nDVR just ignoring this request.
    i try http://192.168.1.144:1935/dvr/xx12.s...ylist.m3u8?DVR and
    http://192.168.1.144:1935/dvr/xx12.s...07-25-11:25:00
    and didn't get any error. But as result i have same video, any time shifted approximately on a second.
    On a second request i have all time new video, but as i assumed -- it must be started from same moment any time.

    What have i do wrong?

  2. #2
    Join Date
    Feb 2014
    Posts
    2

    Default

    it's work. Try this code.

    String UTC_FORMAT = "yyyy-MM-dd-HH:mm:ss";
        DateFormat formatter = new SimpleDateFormat(UTC_FORMAT);
    
        public DvrPlaylistRequest getDvrPlaylistRequest(IHTTPStreamerApplicationContext appContext, IDvrStreamStore store, Map<String, String> queryMap) {
        	
        	WMSProperties dvrProperties = getDvrProperties(appContext);
        	String playStartQueryParameter = dvrProperties.getPropertyStr(PROPKEY_DVR_PLAYLIST_START_QUERY_PARAMETER, DVR_QUERYSTR_PLAYLIST_START);
        	String playDurationQueryParameter = dvrProperties.getPropertyStr(PROPKEY_DVR_PLAYLIST_DURATION_QUERY_PARAMETER, DVR_QUERYSTR_PLAYLIST_DURATION);
    
        	String playStartStr = queryMap.get(playStartQueryParameter);
        	String playDurationStr = queryMap.get(playDurationQueryParameter);
    
        	DvrPlaylistRequest fullPlaylistRequest = getDefaultLivePlaylistRequest(DvrTimeScale.UTC_TIME, store);
            
        	Date date = null;
            if (!StringUtils.isEmpty(playStartStr)) {
                 try {
                    date = (Date)formatter.parse(playStartStr);  
                 } catch (ParseException e) {
                    date = null;
                    //e.printStackTrace();
                }
            }
            
            Date date1 = null;
            if (!StringUtils.isEmpty(playDurationStr)) {
                 try {
                    date1 = (Date)formatter.parse(playDurationStr);  
                 } catch (ParseException e) {
                    date1 = null;
                    //e.printStackTrace();
                }
            }
            
            System.out.printf("'%s' --> date:%s\n", playStartStr, date);
    
             // If the date specified is less than the initial date we have to play, its not valid
             if (date != null && date.before(new Date(fullPlaylistRequest.getPlaylistStart())))
             {
                  System.out.println("Requested start time before actual recording.");
                  date = new Date(fullPlaylistRequest.getPlaylistStart());
             }
    
            DvrPlaylistRequest req;
            if (date != null) {
                req = new DvrPlaylistRequest(DvrTimeScale.UTC_TIME);
                req.setPlaylistStart(date.getTime());
                req.setPlaylistEnd(date1.getTime());
            } else {
                // Use default
                req = super.getDvrPlaylistRequest(appContext, store, queryMap);
            }
            System.out.printf("%s : Resolved Playlist: %s \n", CLASSNAME, req);
            return req;
        }

Similar Threads

  1. nDVR is not working
    By vietv.com in forum Wowza nDVR
    Replies: 2
    Last Post: 09-08-2014, 01:42 PM
  2. My first nDVR playback not working
    By manickam79 in forum Wowza nDVR
    Replies: 1
    Last Post: 04-09-2014, 10:10 AM
  3. nDVR not working on Amazon EC2
    By nonsense in forum Tutorials Discussion
    Replies: 1
    Last Post: 02-03-2012, 10:49 AM
  4. nDVR not working with Smooth Streaming
    By german in forum AddOn: Wowza nDVR
    Replies: 1
    Last Post: 01-09-2012, 01:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •