All pastes #745747 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-10-22 17:30 UTC
rendered paste body
Index: libmpcodecs/vf_screenshot.c
===================================================================
--- libmpcodecs/vf_screenshot.c	(revision 24811)
+++ libmpcodecs/vf_screenshot.c	(working copy)
@@ -12,6 +12,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "osdep/timer.h"
+
 #include "mp_msg.h"
 
 #include "img_format.h"
@@ -29,12 +31,15 @@
 
 struct vf_priv_s {
     int frameno;
-    char fname[102];
+    char fname[512+102];
     /// shot stores current screenshot mode:
     /// 0: don't take screenshots
     /// 1: take single screenshot, reset to 0 afterwards
     /// 2: take screenshots of each frame
     int shot, store_slices;
+    unsigned int lastShotTime;
+    unsigned int shotEveryMS;
+    char dname[512];
     int dw, dh, stride;
     uint8_t *buffer;
     struct SwsContext *ctx;
@@ -88,6 +93,8 @@
         fwrite(priv->outbuffer, size, 1, fp);
 
     fclose (fp);
+    
+    mp_msg(MSGT_VFILTER,MSGL_INFO,"*** screenshot '%s' ***\n",fname);
 }
 
 static int fexists(char *fname)
@@ -100,14 +107,14 @@
 static void gen_fname(struct vf_priv_s* priv)
 {
     do {
-	snprintf (priv->fname, 100, "shot%04d.png", ++priv->frameno);
+	snprintf (priv->fname, 612, "%sshot%04d.png",priv->dname, ++priv->frameno);
     } while (fexists(priv->fname) && priv->frameno < 100000);
     if (fexists(priv->fname)) {
 	priv->fname[0] = '\0';
 	return;
     }
 
-    mp_msg(MSGT_VFILTER,MSGL_INFO,"*** screenshot '%s' ***\n",priv->fname);
+    //mp_msg(MSGT_VFILTER,MSGL_INFO,"*** screenshot '%s' ***\n",priv->fname);
 
 }
 
@@ -195,6 +202,13 @@
 	dmpi->height=mpi->height;
     }
 
+    
+	unsigned int currentTime = GetTimerMS();
+	if(currentTime - vf->priv->lastShotTime > vf->priv->shotEveryMS) {
+		vf->priv->shot = 1;
+		vf->priv->lastShotTime = currentTime;
+	}
+    
     if(vf->priv->shot) {
 	if (vf->priv->shot==1)
 	    vf->priv->shot=0;
@@ -279,6 +293,17 @@
     vf->priv->buffer=0;
     vf->priv->outbuffer=0;
     vf->priv->ctx=0;
+
+    vf->priv->shotEveryMS=1000;
+    vf->priv->dname[0]=NULL;
+    
+    if(args) sscanf(args, "%u:%s",
+       &vf->priv->shotEveryMS,
+       vf->priv->dname);
+       mp_msg(MSGT_VFILTER,MSGL_V,"Screenshot params: max 1 every %d ms output to %s (-1=no scaling)\n",
+       vf->priv->shotEveryMS,
+       vf->priv->dname);
+
     vf->priv->avctx = avcodec_alloc_context();
     avcodec_register_all();
     if (avcodec_open(vf->priv->avctx, avcodec_find_encoder(CODEC_ID_PNG))) {
Index: libmpcodecs/vd.c
===================================================================
--- libmpcodecs/vd.c	(revision 24811)
+++ libmpcodecs/vd.c	(working copy)
@@ -56,6 +56,8 @@
 #ifdef USE_LIBAVCODEC
         &mpcodecs_vd_ffmpeg,
 #endif
+        
+#ifndef TRIMDOWN
 #ifdef HAVE_OGGTHEORA
 	&mpcodecs_vd_theora,
 #endif
@@ -99,6 +101,7 @@
 #if defined(USE_QTX_CODECS) || defined(MACOSX)
 	&mpcodecs_vd_qtvideo,
 #endif
+#endif
 	NULL
 };
 
Index: libmpcodecs/ad.c
===================================================================
--- libmpcodecs/ad.c	(revision 24811)
+++ libmpcodecs/ad.c	(working copy)
@@ -45,6 +45,10 @@
 
 ad_functions_t* mpcodecs_ad_drivers[] =
 {
+#ifdef USE_LIBAVCODEC
+  &mpcodecs_ad_ffmpeg,
+#endif
+#ifndef TRIMDOWN
 //  &mpcodecs_ad_null,
 #ifdef USE_MP3LIB
   &mpcodecs_ad_mp3lib,
@@ -54,9 +58,6 @@
   &mpcodecs_ad_hwac3,
 #endif
   &mpcodecs_ad_hwmpa,
-#ifdef USE_LIBAVCODEC
-  &mpcodecs_ad_ffmpeg,
-#endif
   &mpcodecs_ad_pcm,
   &mpcodecs_ad_dvdpcm,
   &mpcodecs_ad_alaw,
@@ -97,5 +98,6 @@
 #ifdef USE_LIBDCA
   &mpcodecs_ad_libdca,
 #endif
+#endif
   NULL
 };
Index: libmpcodecs/Makefile
===================================================================
--- libmpcodecs/Makefile	(revision 24811)
+++ libmpcodecs/Makefile	(working copy)
@@ -3,13 +3,21 @@
 LIBNAME_COMMON   = libmpcodecs.a
 LIBNAME_MENCODER = libmpencoders.a
 
-SRCS_COMMON = native/nuppelvideo.c \
+SRCS_COMMON = img_format.c \
+              dec_audio.c \
+              ad.c \
+			  dec_video.c \
+              vd.c \
+              vf.c \
+              vd_null.c \
+              vf_scale.c \
+              vf_vo.c \
+              
+SRCS_COMMON-$(NO_TRIMDOWN) = native/nuppelvideo.c \
               native/RTjpegN.c \
               native/xa_gsm.c \
               img_format.c \
               mp_image.c \
-              dec_audio.c \
-              ad.c \
               ad_alaw.c \
               ad_dk3adpcm.c \
               ad_dvdpcm.c \
@@ -19,17 +27,13 @@
               ad_msadpcm.c \
               ad_msgsm.c \
               ad_pcm.c \
-              dec_video.c \
-              vd.c \
               vd_hmblck.c \
               vd_lzo.c \
               vd_mpegpes.c \
               vd_mtga.c \
-              vd_null.c \
               vd_nuv.c \
               vd_raw.c \
               vd_sgi.c \
-              vf.c \
               pullup.c \
               vf_1bpp.c \
               vf_2xsai.c \
@@ -77,7 +81,6 @@
               vf_rgbtest.c \
               vf_rotate.c \
               vf_sab.c \
-              vf_scale.c \
               vf_smartblur.c \
               vf_softpulldown.c \
               vf_softskip.c \
@@ -88,7 +91,6 @@
               vf_tile.c \
               vf_tinterlace.c \
               vf_unsharp.c \
-              vf_vo.c \
               vf_yadif.c \
               vf_yuvcsp.c \
               vf_yuy2.c \
Index: libmpcodecs/vf.c
===================================================================
--- libmpcodecs/vf.c	(revision 24811)
+++ libmpcodecs/vf.c	(working copy)
@@ -102,6 +102,10 @@
 
 // list of available filters:
 static vf_info_t* filter_list[]={
+	&vf_info_scale,
+	&vf_info_vo,
+		 
+#ifndef TRIMDOWN
     &vf_info_rectangle,
 #ifdef HAVE_POSIX_SELECT
     &vf_info_bmovl,
@@ -111,9 +115,7 @@
 #ifdef USE_LIBPOSTPROC
     &vf_info_pp,
 #endif
-    &vf_info_scale,
 //    &vf_info_osd,
-    &vf_info_vo,
     &vf_info_format,
     &vf_info_noformat,
     &vf_info_yuy2,
@@ -192,7 +194,8 @@
 #endif
     &vf_info_yadif,
     &vf_info_blackframe,
-    &vf_info_ow,
+ 	&vf_info_ow,
+#endif
     NULL
 };
 
Index: stream/http.c
===================================================================
--- stream/http.c	(revision 24811)
+++ stream/http.c	(working copy)
@@ -731,6 +731,7 @@
 
 	do
 	{
+		//mp_msg(MSGT_NETWORK,MSGL_V,"Checking for seekability...\n");
 		redirect = 0;
 		if (fd > 0) closesocket(fd);
 		fd = http_send_request( url, 0 );
@@ -748,11 +749,15 @@
 			http_debug_hdr( http_hdr );
 		}
 		
+		//mp_msg(MSGT_NETWORK,MSGL_V,"Checking for Accept-Ranges...\n");
 		// Check if we can make partial content requests and thus seek in http-streams
 		if( http_hdr!=NULL && http_hdr->status_code==200 ) {
 		    char *accept_ranges;
 		    if( (accept_ranges = http_get_field(http_hdr,"Accept-Ranges")) != NULL )
+		    //mp_msg(MSGT_NETWORK,MSGL_V,"accept_ranges=%s\n", accept_ranges);
 			seekable = strncmp(accept_ranges,"bytes",5)==0;
+		    
+		    //mp_msg(MSGT_NETWORK,MSGL_V,"Seekable(Accept-Ranges)   : %d\n", seekable);
 		}
 
 		// Check if the response is an ICY status_code reason_phrase
@@ -811,14 +816,21 @@
 				if( content_type!=NULL ) {
 					char *content_length = NULL;
 					mp_msg(MSGT_NETWORK,MSGL_V,"Content-Type: [%s]\n", content_type );
-					if( (content_length = http_get_field(http_hdr, "Content-Length")) != NULL)
+					if( (content_length = http_get_field(http_hdr, "Content-Length")) != NULL) {
 						mp_msg(MSGT_NETWORK,MSGL_V,"Content-Length: [%s]\n", http_get_field(http_hdr, "Content-Length"));
+						if(stream->end_pos == 0) {
+							sscanf(content_length , "%d", &(stream->end_pos));
+						}
+						sscanf(content_length , "%d", &(stream->streaming_ctrl->length));
+						stream->streaming_ctrl->pos = 0;
+					}
 					// Check in the mime type table for a demuxer type
 					i = 0;
 					while(mime_type_table[i].mime_type != NULL) {
 						if( !strcasecmp( content_type, mime_type_table[i].mime_type ) ) {
 							*file_format = mime_type_table[i].demuxer_type;
 							res = seekable;
+							//mp_msg(MSGT_NETWORK,MSGL_V,"res   : %d\n", res);
 							goto out;
 						}
 						i++;
Index: stream/cache2.c
===================================================================
--- stream/cache2.c	(revision 24811)
+++ stream/cache2.c	(working copy)
@@ -286,18 +286,21 @@
     stream->cache_pid = CreateThread(NULL,0,ThreadProc,s,0,&threadId);
 #endif
     // wait until cache is filled at least prefill_init %
-    mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"PRId64" [%"PRId64"] %"PRId64"  pre:%d  eof:%d  \n",
-	(int64_t)s->min_filepos,(int64_t)s->read_filepos,(int64_t)s->max_filepos,min,s->eof);
+    // AZ: Commented out mp_msg because there is no \n and other debugs that
+    //     EMP parses may be spewed in between this first line and the \n
+
+    //mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"PRId64" [%"PRId64"] %"PRId64"  pre:%d  eof:%d  \n",
+	//(int64_t)s->min_filepos,(int64_t)s->read_filepos,(int64_t)s->max_filepos,min,s->eof);
     while(s->read_filepos<s->min_filepos || s->max_filepos-s->read_filepos<min){
-	mp_msg(MSGT_CACHE,MSGL_STATUS,MSGTR_CacheFill,
-	    100.0*(float)(s->max_filepos-s->read_filepos)/(float)(s->buffer_size),
-	    (int64_t)s->max_filepos-s->read_filepos
-	);
+//	mp_msg(MSGT_CACHE,MSGL_STATUS,MSGTR_CacheFill,
+//	    100.0*(float)(s->max_filepos-s->read_filepos)/(float)(s->buffer_size),
+//	    (int64_t)s->max_filepos-s->read_filepos
+//	);
 	if(s->eof) break; // file is smaller than prefill size
 	if(mp_input_check_interrupt(PREFILL_SLEEP_TIME))
 	  return 0;
     }
-    mp_msg(MSGT_CACHE,MSGL_STATUS,"\n");
+    //mp_msg(MSGT_CACHE,MSGL_STATUS,"\n");
     return 1; // parent exits
   }
   
Index: stream/network.c
===================================================================
--- stream/network.c	(revision 24811)
+++ stream/network.c	(working copy)
@@ -74,6 +74,8 @@
 	{ "application/x-mms-framed", DEMUXER_TYPE_ASF },
 	{ "application/vnd.ms.wms-hdr.asfv1", DEMUXER_TYPE_ASF },
 	{ "application/octet-stream", DEMUXER_TYPE_UNKNOWN },
+	//MATROSKA
+	{ "video/x-matroska", DEMUXER_TYPE_MATROSKA},
 	// Playlists
 	{ "video/x-ms-wmx", DEMUXER_TYPE_PLAYLIST },
 	{ "video/x-ms-wvx", DEMUXER_TYPE_PLAYLIST },
@@ -353,6 +355,9 @@
 		case 206: // OK
 			mp_msg(MSGT_NETWORK,MSGL_V,"Content-Type: [%s]\n", http_get_field(http_hdr, "Content-Type") );
 			mp_msg(MSGT_NETWORK,MSGL_V,"Content-Length: [%s]\n", http_get_field(http_hdr, "Content-Length") );
+			// AZ
+			sscanf(http_get_field(http_hdr, "Content-Length") , "%d", &(stream->streaming_ctrl->length));
+			stream->streaming_ctrl->pos = 0;
 			if( http_hdr->body_size>0 ) {
 				if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) {
 					http_free( http_hdr );
@@ -394,6 +399,23 @@
 int
 nop_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctrl ) {
 	int len=0;
+	
+
+	{ // AZ
+          //HTTP_header_t* http_hdr = (HTTP_header_t*)stream_ctrl->data;
+          
+          mp_msg(MSGT_NETWORK,MSGL_V,"size: %d, length: %d, pos: %d, size : %d\n",size,stream_ctrl->length,stream_ctrl->pos,stream_ctrl->buffer_size);
+          
+          if(stream_ctrl->length && stream_ctrl->length < stream_ctrl->pos + size ) {
+          	size = stream_ctrl->length - stream_ctrl->pos;
+          }
+          
+          if(size == 0) {
+          	
+          	return -1;
+          }
+	}
+	
 //printf("nop_streaming_read\n");
 	if( stream_ctrl->buffer_size!=0 ) {
 		int buffer_len = stream_ctrl->buffer_size-stream_ctrl->buffer_pos;
@@ -413,13 +435,45 @@
 	}
 
 	if( len<size ) {
-		int ret;
-		ret = recv( fd, buffer+len, size-len, 0 );
-		if( ret<0 ) {
-			mp_msg(MSGT_NETWORK,MSGL_ERR,"nop_streaming_read error : %s\n",strerror(errno));
-		}
-		len += ret;
-//printf("read %d bytes from network\n", len );
+	  // AZ: Section rewrote to signal when buffering is occuring, and
+	  //     to attempt to allow the UI to update while buffering
+		int ret = 0;
+                int i = 0;
+printf(">>BUF %d (had %d)\n", (size-len), len);
+fflush(stdout);
+                int keepLooping;
+                do {
+                  keepLooping = 0;
+                        ret = recv( fd, buffer+len, size-len, 0 );
+                        if( ret<0 ) {
+                                #ifdef HAVE_WINSOCK2
+                          i = WSAGetLastError();
+                          if (i == 10060) { // timeout
+                            keepLooping = 1;
+                          }
+                                #else
+                                if(errno == EAGAIN) {
+                                        keepLooping = 1;
+                                }
+                                #endif
+
+                                if (keepLooping == 1) {
+                                  printf("!!TIMEOUT\n");
+                                  fflush(stdout);
+                                  checkEvents();
+                                  usec_sleep(5000);
+                                } else {
+                                  mp_msg(MSGT_NETWORK,MSGL_ERR,"nop_streaming_read error : %s %d\n",strerror(errno), i);
+                                }
+        		
+        		} else {
+                          stream_ctrl->pos += ret;
+                          len += ret;
+        		}
+                } while (keepLooping == 1);
+printf("<<BUF %d\n", len);
+fflush(stdout);
+//printf("<< read %d bytes from network\n", len );
 	}
 	
 	return len;
Index: stream/Makefile
===================================================================
--- stream/Makefile	(revision 24811)
+++ stream/Makefile	(working copy)
@@ -1,73 +1,83 @@
-include ../config.mak
-
-LIBNAME_COMMON = stream.a
-
-SRCS_COMMON = open.c \
-              stream.c \
-              stream_cue.c \
-              stream_file.c \
-              stream_mf.c \
-              stream_null.c \
-              url.c \
-
-SRCS_COMMON-$(CDDA)              += stream_cdda.c cdinfo.c
-SRCS_COMMON-$(CDDB)              += stream_cddb.c
-SRCS_COMMON-$(DVBIN)             += dvb_tune.c stream_dvb.c
-SRCS_COMMON-$(DVDNAV)            += stream_dvdnav.c
-SRCS_COMMON-$(DVDREAD)           += stream_dvd.c stream_dvd_common.c
-SRCS_COMMON-$(FTP)               += stream_ftp.c
-SRCS_COMMON-$(LIBSMBCLIENT)      += stream_smb.c
-SRCS_COMMON-$(MPLAYER_NETWORK)   += stream_netstream.c     \
-                                    asf_mmst_streaming.c   \
-                                    asf_streaming.c        \
-                                    cookies.c              \
-                                    http.c                 \
-                                    network.c              \
-                                    pnm.c                  \
-                                    rtp.c                  \
-                                    udp.c                  \
-                                    tcp.c                  \
-                                    stream_rtp.c           \
-                                    stream_udp.c           \
-                                    realrtsp/asmrp.c       \
-                                    realrtsp/real.c        \
-                                    realrtsp/rmff.c        \
-                                    realrtsp/sdpplin.c     \
-                                    realrtsp/xbuffer.c     \
-
-SRCS_COMMON-$(NATIVE_RTSP)       += stream_rtsp.c          \
-                                    freesdp/common.c       \
-                                    freesdp/errorlist.c    \
-                                    freesdp/parser.c       \
-                                    librtsp/rtsp.c         \
-                                    librtsp/rtsp_rtp.c     \
-                                    librtsp/rtsp_session.c \
-
-SRCS_COMMON-$(LIBNEMESI)         += stream_nemesi.c
-
-SRCS_COMMON-$(PVR)               += stream_pvr.c
-SRCS_COMMON-$(RADIO)             += stream_radio.c
-SRCS_COMMON-$(RADIO_CAPTURE)     += audio_in.c
-SRCS_COMMON-$(STREAM_CACHE)      += cache2.c
-SRCS_COMMON-$(STREAMING_LIVE555) += stream_livedotcom.c
-SRCS_COMMON-$(TV)                += stream_tv.c tv.c frequencies.c tvi_dummy.c
-SRCS_COMMON-$(TV_BSDBT848)       += tvi_bsdbt848.c
-SRCS_COMMON-$(TV_DSHOW)          += tvi_dshow.c
-SRCS_COMMON-$(TV_TELETEXT)       += tvi_vbi.c
-SRCS_COMMON-$(TV_V4L1)           += tvi_v4l.c  audio_in.c
-SRCS_COMMON-$(TV_V4L2)           += tvi_v4l2.c audio_in.c
-SRCS_COMMON-$(VCD)               += stream_vcd.c
-SRCS_COMMON-$(VSTREAM)           += stream_vstream.c
-
-ifeq ($(AUDIO_INPUT),yes)
-SRCS_COMMON-$(ALSA1X)            += ai_alsa1x.c
-SRCS_COMMON-$(ALSA9)             += ai_alsa.c
-SRCS_COMMON-$(OSS)               += ai_oss.c
-endif
-
-include ../mpcommon.mak
-
-clean::
-	rm -f realrtsp/*.o realrtsp/*.a realrtsp/*~ \
-	librtsp/*.o librtsp/*.a librtsp/*~ \
-	freesdp/*.o freesdp/*.a freesdp/*~
+include ../config.mak
+
+LIBNAME_COMMON = stream.a
+
+SRCS_COMMON = open.c \
+              stream.c \
+              stream_file.c \
+              url.c \
+
+SRCS_COMMON-$(NO_TRIMDOWN) = stream_cue.c \
+							 stream_mf.c \
+			              	 stream_null.c \
+
+SRCS_COMMON-$(CDDA)              += stream_cdda.c cdinfo.c
+SRCS_COMMON-$(CDDB)              += stream_cddb.c
+SRCS_COMMON-$(DVBIN)             += dvb_tune.c stream_dvb.c
+SRCS_COMMON-$(DVDNAV)            += stream_dvdnav.c
+SRCS_COMMON-$(DVDREAD)           += stream_dvd.c stream_dvd_common.c
+SRCS_COMMON-$(FTP)               += stream_ftp.c
+SRCS_COMMON-$(LIBSMBCLIENT)      += stream_smb.c
+ifeq ($(NO_TRIMDOWN),yes)
+SRCS_COMMON-$(MPLAYER_NETWORK)   += stream_netstream.c     \
+                                    asf_mmst_streaming.c   \
+                                    asf_streaming.c        \
+                                    cookies.c              \
+                                    http.c                 \
+                                    network.c              \
+                                    pnm.c                  \
+                                    rtp.c                  \
+                                    udp.c                  \
+                                    tcp.c                  \
+                                    stream_rtp.c           \
+                                    stream_udp.c           \
+                                    realrtsp/asmrp.c       \
+                                    realrtsp/real.c        \
+                                    realrtsp/rmff.c        \
+                                    realrtsp/sdpplin.c     \
+                                    realrtsp/xbuffer.c     \
+
+else
+SRCS_COMMON-$(MPLAYER_NETWORK)   += cookies.c              \
+                                	http.c                 \
+									network.c              \
+									tcp.c                  \
+
+endif
+
+SRCS_COMMON-$(NATIVE_RTSP)       += stream_rtsp.c          \
+                                    freesdp/common.c       \
+                                    freesdp/errorlist.c    \
+                                    freesdp/parser.c       \
+                                    librtsp/rtsp.c         \
+                                    librtsp/rtsp_rtp.c     \
+                                    librtsp/rtsp_session.c \
+
+SRCS_COMMON-$(LIBNEMESI)         += stream_nemesi.c
+
+SRCS_COMMON-$(PVR)               += stream_pvr.c
+SRCS_COMMON-$(RADIO)             += stream_radio.c
+SRCS_COMMON-$(RADIO_CAPTURE)     += audio_in.c
+SRCS_COMMON-$(STREAM_CACHE)      += cache2.c
+SRCS_COMMON-$(STREAMING_LIVE555) += stream_livedotcom.c
+SRCS_COMMON-$(TV)                += stream_tv.c tv.c frequencies.c tvi_dummy.c
+SRCS_COMMON-$(TV_BSDBT848)       += tvi_bsdbt848.c
+SRCS_COMMON-$(TV_DSHOW)          += tvi_dshow.c
+SRCS_COMMON-$(TV_TELETEXT)       += tvi_vbi.c
+SRCS_COMMON-$(TV_V4L1)           += tvi_v4l.c  audio_in.c
+SRCS_COMMON-$(TV_V4L2)           += tvi_v4l2.c audio_in.c
+SRCS_COMMON-$(VCD)               += stream_vcd.c
+SRCS_COMMON-$(VSTREAM)           += stream_vstream.c
+
+ifeq ($(AUDIO_INPUT),yes)
+SRCS_COMMON-$(ALSA1X)            += ai_alsa1x.c
+SRCS_COMMON-$(ALSA9)             += ai_alsa.c
+SRCS_COMMON-$(OSS)               += ai_oss.c
+endif
+
+include ../mpcommon.mak
+
+clean::
+	rm -f realrtsp/*.o realrtsp/*.a realrtsp/*~ \
+	librtsp/*.o librtsp/*.a librtsp/*~ \
+	freesdp/*.o freesdp/*.a freesdp/*~
Index: stream/network.h
===================================================================
--- stream/network.h	(revision 24811)
+++ stream/network.h	(working copy)
@@ -23,7 +23,8 @@
 #include "http.h"
 #include "stream.h"
 
-#define BUFFER_SIZE		2048
+// AZ: Increased buffer from 2k
+#define BUFFER_SIZE		32768
 
 typedef struct {
 	const char *mime_type;
@@ -44,6 +45,9 @@
 	unsigned int buffer_size;
 	unsigned int buffer_pos;
 	unsigned int bandwidth;	// The downstream available
+	//AZ: for http streaming (length, pos)
+	long length;
+	long pos;
 	int (*streaming_read)( int fd, char *buffer, int buffer_size, struct streaming_control *stream_ctrl );
 	int (*streaming_seek)( int fd, off_t pos, struct streaming_control *stream_ctrl );
 	void *data;
Index: stream/tcp.c
===================================================================
--- stream/tcp.c	(revision 24811)
+++ stream/tcp.c	(working copy)
@@ -93,9 +93,11 @@
 #if defined(SO_RCVTIMEO) && defined(SO_SNDTIMEO)
 #ifdef HAVE_WINSOCK2
 	/* timeout in milliseconds */
-	to = 10 * 1000;
+	// AZ: Reduced timout to 100ms (was 10 seconds)
+	to = 100;
 #else
-	to.tv_sec = 10;
+        // AZ: Reduced timout to 1s (was 10 seconds)
+	to.tv_sec = 1;
 	to.tv_usec = 0;
 #endif
 	setsockopt(socket_server_fd, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof(to));
Index: stream/stream.c
===================================================================
--- stream/stream.c	(revision 24811)
+++ stream/stream.c	(working copy)
@@ -89,6 +89,7 @@
 #endif
 
 stream_info_t* auto_open_streams[] = {
+#ifndef TRIMDOWN
 #ifdef HAVE_VCD
   &stream_info_vcd,
 #endif
@@ -97,7 +98,7 @@
 #endif
 #ifdef MPLAYER_NETWORK
   &stream_info_netstream,
-  &stream_info_http1,
+ 
   &stream_info_asf,
   &stream_info_pnm,
   &stream_info_rtsp,
@@ -107,7 +108,7 @@
 #endif
   &stream_info_rtp,
   &stream_info_udp,
-  &stream_info_http2,
+
 #endif
 #ifdef HAS_DVBIN_SUPPORT
   &stream_info_dvb,
@@ -140,6 +141,9 @@
 
   &stream_info_null,
   &stream_info_mf,
+#endif
+  &stream_info_http2,
+  &stream_info_http1,
   &stream_info_file,
   NULL
 };
@@ -289,6 +293,8 @@
 int stream_seek_long(stream_t *s,off_t pos){
 off_t newpos=0;
 
+// AZ: explicit debug (not required for EMP)
+printf("seek_long to 0x%X\n",(unsigned int)pos);
 //  if( mp_msg_test(MSGT_STREAM,MSGL_DBG3) ) printf("seek_long to 0x%X\n",(unsigned int)pos);
 
   s->buf_pos=s->buf_len=0;
Index: stream/stream.h
===================================================================
--- stream/stream.h	(revision 24811)
+++ stream/stream.h	(working copy)
@@ -26,7 +26,8 @@
 #define STREAMTYPE_MF 18
 #define STREAMTYPE_RADIO 19
 
-#define STREAM_BUFFER_SIZE 2048
+// AZ: increased buffer size from 2k
+#define STREAM_BUFFER_SIZE 32768
 
 #define VCD_SECTOR_SIZE 2352
 #define VCD_SECTOR_OFFS 24
@@ -203,9 +204,11 @@
 inline static int stream_read(stream_t *s,char* mem,int total){
   int len=total;
   while(len>0){
+    //printf("---------------------------------read %d; left %d\n", total, len);
     int x;
     x=s->buf_len-s->buf_pos;
     if(x==0){
+      //printf("---------------------------------EOF!\n");
       if(!cache_stream_fill_buffer(s)) return total-len; // EOF
       x=s->buf_len-s->buf_pos;
     }
@@ -214,6 +217,7 @@
     memcpy(mem,&s->buffer[s->buf_pos],x);
     s->buf_pos+=x; mem+=x; len-=x;
   }
+  //printf("---------------------------------read complete %d\n", total);
   return total;
 }
 
@@ -252,6 +256,8 @@
 
 inline static int stream_seek(stream_t *s,off_t pos){
 
+  // AZ: Added expliecit seek debug (not required for EMP)
+  mp_msg(MSGT_DEMUX, MSGL_INFO, "seek to %d\n",(long long)pos);
   mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%qX\n",(long long)pos);
 
   if(pos<s->pos){
Index: input/input.c
===================================================================
--- input/input.c	(revision 24811)
+++ input/input.c	(working copy)
@@ -349,8 +349,8 @@
 
   { { KEY_RIGHT, 0 }, "seek 10" },
   { {  KEY_LEFT, 0 }, "seek -10" },
-  { {  KEY_UP, 0 }, "seek 60" },
-  { {  KEY_DOWN, 0 }, "seek -60" },
+  { {  KEY_UP, 0 }, "volume 1" },
+  { {  KEY_DOWN, 0 }, "volume -1" },
   { {  KEY_PAGE_UP, 0 }, "seek 600" },
   { { KEY_PAGE_DOWN, 0 }, "seek -600" },
   { { '+', 0 }, "audio_delay 0.100" },
@@ -360,8 +360,8 @@
   { { '{', 0 }, "speed_mult 0.5" },
   { { '}', 0 }, "speed_mult 2.0" },
   { { KEY_BACKSPACE, 0 }, "speed_set 1.0" },
-  { { 'q', 0 }, "quit" },
-  { { KEY_ESC, 0 }, "quit" },
+  { { 'q', 0 }, "vo_fullscreen" },
+  { { KEY_ESC, 0 }, "vo_fullscreen" },
   { { 'p', 0 }, "pause" },
   { { ' ', 0 }, "pause" },
   { { '.', 0 }, "frame_step" },
@@ -428,7 +428,7 @@
 #endif
 #ifdef HAVE_APPLE_REMOTE
   { { AR_PLAY, 0}, "pause" },
-  { { AR_PLAY_HOLD, 0}, "quit" },
+  { { AR_PLAY_HOLD, 0}, "vo_fullscreen" },
   { { AR_NEXT, 0 }, "seek 30" },
   { { AR_NEXT_HOLD, 0 }, "seek 120" },
   { { AR_PREV, 0 }, "seek -10" },
@@ -445,12 +445,12 @@
   { { 'w', 0 }, "panscan -0.1" },
   { { 'e', 0 }, "panscan +0.1" },
 
-  { { KEY_POWER, 0 }, "quit" },
+  { { KEY_POWER, 0 }, "vo_fullscreen" },
   { { KEY_MENU, 0 }, "osd" },
   { { KEY_PLAY, 0 }, "pause" },
   { { KEY_PAUSE, 0 }, "pause" },
   { { KEY_PLAYPAUSE, 0 }, "pause" },
-  { { KEY_STOP, 0 }, "quit" },
+  { { KEY_STOP, 0 }, "vo_fullscreen" },
   { { KEY_FORWARD, 0 }, "seek 60" },
   { { KEY_REWIND, 0 }, "seek -60" },
   { { KEY_NEXT, 0 }, "pt_step 1" },
@@ -461,6 +461,9 @@
           
   { { KEY_CLOSE_WIN, 0 }, "quit" },
   
+  { { MOUSE_BTN0_DBL, 0 }, "vo_fullscreen" },
+  { { MOUSE_BTN0, 0 }, "pause" },
+  
   { { '!', 0 }, "seek_chapter -1" },
   { { '@', 0 }, "seek_chapter 1" },
 
Index: input/input.h
===================================================================
--- input/input.h	(revision 24811)
+++ input/input.h	(working copy)
@@ -100,6 +100,8 @@
 #define MP_CMD_TV_TELETEXT_GO_LINK 99
 #define MP_CMD_TV_START_SCAN 100
 
+#define MP_CMD_AZ_PLAYSTATE 2000
+
 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
 #define MP_CMD_GUI_LOADSUBTITLE 5002
Index: libao2/audio_out.c
===================================================================
--- libao2/audio_out.c	(revision 24811)
+++ libao2/audio_out.c	(working copy)
@@ -127,7 +127,14 @@
 #ifdef USE_OPENAL
         &audio_out_openal,
 #endif
+        
+#ifndef TRIMDOWN
 	&audio_out_mpegpes,
+	&audio_out_null,
+	// should not be auto-selected:
+	&audio_out_pcm,
+#endif
+	
 #ifdef HAVE_DXR2
         &audio_out_dxr2,
 #endif
@@ -137,9 +144,6 @@
 #ifdef HAVE_V4L2_DECODER
         &audio_out_v4l2,
 #endif
-        &audio_out_null,
-// should not be auto-selected:
-	&audio_out_pcm,
 	NULL
 };
 
Index: libao2/Makefile
===================================================================
--- libao2/Makefile	(revision 24811)
+++ libao2/Makefile	(working copy)
@@ -3,9 +3,12 @@
 LIBNAME_MPLAYER = libao2.a
 
 SRCS_MPLAYER = audio_out.c \
+				$(AO_SRCS) \
+				
+SRCS_MPLAYER-$(NO_TRIMDOWN) =\
                ao_mpegpes.c \
                ao_null.c \
                ao_pcm.c \
-               $(AO_SRCS) \
+               
 
 include ../mpcommon.mak
Index: libvo/aspect.c
===================================================================
--- libvo/aspect.c	(revision 24811)
+++ libvo/aspect.c	(working copy)
@@ -6,7 +6,7 @@
 #include "help_mp.h"
 //#endif
 
-//#define ASPECT_DEBUG
+//#define ASPECT_DEBUG 1
 
 #if defined(ASPECT_DEBUG) || defined(ASPECT_TEST)
 #include <stdio.h>
@@ -101,11 +101,17 @@
     else
       tmpw = (int)((float)aspdat.prew
                 * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
+    //1920 * (1280/ (800 / (1/1.6)))
+    //0.625
+    //800/1072/1920
     tmpw+= tmpw%2; // round
+    //printf("aspect(2) tmpw %d<=%d\n",tmpw,aspdat.scrw);
     if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){
       *srch = zoom?aspdat.scrh:aspdat.preh;
       *srcw = tmpw;
     }else{
+      //*srch = zoom?aspdat.scrh:aspdat.preh;
+      //*srcw = tmpw;
 #ifndef ASPECT_TEST
       mp_msg(MSGT_VO,MSGL_WARN,MSGTR_LIBVO_ASPECT_NoSuitableNewResFound);
 #else
Index: libvo/Makefile
===================================================================
--- libvo/Makefile	(revision 24811)
+++ libvo/Makefile	(working copy)
@@ -3,14 +3,25 @@
 LIBNAME_COMMON  = libosd.a
 LIBNAME_MPLAYER = libvo.a
 
-SRCS_MPLAYER = aspect.c \
+#SRCS_MPLAYER = aspect.c \
+#               geometry.c \
+#               spuenc.c \
+#               video_out.c \
+#               vo_mpegpes.c \
+#               vo_null.c \
+#               vo_yuv4mpeg.c \
+#               $(VO_SRCS) \
+
+SRCS_MPLAYER = video_out.c \
+			   aspect.c \
                geometry.c \
-               spuenc.c \
-               video_out.c \
+               vo_null.c \
+			   $(VO_SRCS) \
+
+SRCS_MPLAYER-$(NO_TRIMDOWN) = spuenc.c \
                vo_mpegpes.c \
-               vo_null.c \
                vo_yuv4mpeg.c \
-               $(VO_SRCS) \
+               
 
 SRCS_MPLAYER-$(VIDIX)          +=  vosub_vidix.c
 
Index: libvo/video_out.c
===================================================================
--- libvo/video_out.c	(revision 24811)
+++ libvo/video_out.c	(working copy)
@@ -254,8 +254,10 @@
 #ifdef HAVE_XVMC
         &video_out_xvmc,
 #endif
+#ifndef TRIMDOWN
 	&video_out_mpegpes,
 	&video_out_yuv4mpeg,
+#endif
 #ifdef HAVE_PNG
 	&video_out_png,
 #endif	
Index: libvo/vo_directx.c
===================================================================
--- libvo/vo_directx.c	(revision 24811)
+++ libvo/vo_directx.c	(working copy)
@@ -523,6 +523,15 @@
 
 static void check_events(void)
 {
+  // AZ: If we were passed a WinID, quit the player when that window is gone
+  if (WinID != -1) {
+    int i = IsWindow(hWnd);
+    if (i != 1) {
+      printf("AZ Quit\n"); fflush(stdout);
+      exit_player("AZ Quit");
+    }
+  }
+
     MSG msg;
     while (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
     {
@@ -538,7 +547,8 @@
     DDOVERLAYFX     ovfx;
     DWORD           dwUpdateFlags=0;
     int width,height;
-   
+    int deltaWidth,deltaHeight;
+
     if(!vidmode && !vo_fs && WinID!=-1) {
       RECT current_rect = {0, 0, 0, 0};
       GetWindowRect(hWnd, &current_rect);
@@ -583,24 +593,43 @@
 	  rd.left = pt.x;
       rd.top = pt.y; 
       if(!nooverlay && (!width || !height)){
-	    /*window is minimized*/
-	    ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay,NULL, g_lpddsPrimary, NULL, DDOVER_HIDE, NULL);
-	    return 0;
-	  }
+           /*window is minimized*/
+           ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay,NULL, g_lpddsPrimary, NULL, DDOVER_HIDE, NULL);
+           return 0;
+         }
+
+      // AZ: deltaWidth/Height for centering the video in the window
+      deltaWidth = deltaHeight = 0;
       if(vo_keepaspect){
-          int tmpheight=((float)width/window_aspect);
-          tmpheight+=tmpheight%2;       
-          if(tmpheight > height){
-            width=((float)height*window_aspect);
-            width+=width%2;       
-          }
-          else height=tmpheight;
-      }    
+        int tmpheight=((float)width/window_aspect);
+        
+        //printf("tmpheight=%d; height=%d\n", tmpheight, height);  fflush(stdout);
+  
+        tmpheight+=tmpheight%2;
+        if (tmpheight > height) {
+          deltaWidth=width;
+          width=((float)height*window_aspect);
+          width+=width%2;
+          deltaWidth-=width;
+        } else {
+          deltaHeight=height-tmpheight;
+          height=tmpheight;
+        }
+        //printf("width=%d; deltawidth=%d; dh=%d\n", width, deltaWidth, deltaHeight);  fflush(stdout);
+      }
+
       if (WinID == -1)
-          while(ShowCursor(TRUE)<=0){}
-    }
-    rd.right=rd.left+width;
-    rd.bottom=rd.top+height;
+        while(ShowCursor(TRUE)<=0){}
+   }
+   
+   if (!vo_fs && !vidmode) {
+     rd.left+=deltaWidth/2;
+     rd.top+=deltaHeight/2;
+   }
+   rd.right=rd.left+width;
+   rd.bottom=rd.top+height;
+   
+   //printf("draw %d,%d,%d,%d\n", rd.left, rd.top, rd.right, rd.bottom);  fflush(stdout);
 
 	/*ok, let's workaround some overlay limitations*/
 	if(!nooverlay)
@@ -915,7 +944,6 @@
 		}
         case WM_WINDOWPOSCHANGED:
 		{
-			//printf("Windowposchange\n");
 			if(g_lpddsBack != NULL)  //or it will crash with -vm
 			{
 				Directx_ManageDisplay();
@@ -1087,12 +1115,15 @@
     wc.hbrBackground =  vidmode ? blackbrush : colorbrush;
     wc.lpszClassName =  WNDCLASSNAME_WINDOWED;
     wc.lpszMenuName  =  NULL;
-    RegisterClass(&wc);
-    if (WinID != -1) hWnd = WinID;
-    else
+    // AZ: For now, don't register with there's a passed in WinID (locks UI) 
+    if (WinID != -1) {
+      hWnd = WinID;
+    } else {
+      RegisterClass(&wc);
     hWnd = CreateWindowEx(vidmode?WS_EX_TOPMOST:0,
         WNDCLASSNAME_WINDOWED,"",(vidmode || !vo_border)?WS_POPUP:WNDSTYLE,
         CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,NULL,NULL,hInstance,NULL);
+    }
     wc.hbrBackground = blackbrush;
     wc.lpszClassName = WNDCLASSNAME_FULLSCREEN;
     RegisterClass(&wc);
@@ -1230,6 +1261,8 @@
 	uint32_t y = mpi->y;
 	uint32_t w = mpi->w;
 	uint32_t h = mpi->h;
+	
+	//printf("Put Image (%d,%d,%d,%d)\n", mpi->x, mpi->y, mpi->w, mpi->h); fflush(stdout);
 
     if (WinID != -1) Directx_ManageDisplay();
    
@@ -1271,7 +1304,10 @@
 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t options, char *title, uint32_t format)
 {
     RECT rd;
-    vo_fs = options & 0x01;
+    // AZ: Keep FS mode across playlist
+    if (!vo_fs) {
+      vo_fs = options & 0x01;
+    }
 	image_format =  format;
 	image_width = width;
 	image_height = height;
@@ -1576,6 +1612,15 @@
         }
         aspect_save_screenres(vo_screenwidth, vo_screenheight);
         return VO_TRUE;
+    // AZ: fading on pause (disabled for now)
+    case VOCTRL_PAUSE:
+		mp_msg(MSGT_VO, MSGL_INFO,"<vo_directx><INFO>Pause detected\n");
+    	//fadeFrameOut();
+    	return VO_TRUE;
+	case VOCTRL_RESUME:
+		mp_msg(MSGT_VO, MSGL_INFO,"<vo_directx><INFO>Resume detected\n");
+    	//fadeFrameIn();
+    	return VO_TRUE;
     case VOCTRL_RESET:
         last_rect.left = 0xDEADC0DE;   // reset window position cache
         // fall-through intended
Index: libvo/vo_gl2.c
===================================================================
--- libvo/vo_gl2.c	(revision 24811)
+++ libvo/vo_gl2.c	(working copy)
@@ -452,6 +452,11 @@
 #ifdef GL_WIN32
 
 static int config_w32(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) {
+  // AZ: keep fullscreen setting across playlist
+   if(vo_fs) {
+     flags = flags | VOFLAG_FULLSCREEN;
+   }
+
   if (!vo_w32_config(d_width, d_height, flags))
     return -1;
 
Index: configure
===================================================================
--- configure	(revision 24811)
+++ configure	(working copy)
@@ -507,7 +507,8 @@
 _libavparsers_all=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'`
 _libavparsers=$_libavparsers_all
 _libavbsfs_all=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'`
-_libavbsfs=$_libavbsfs_all
+#_libavbsfs=$_libavbsfs_all
+_libavbsfs=""
 _libavdemuxers_all=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]'`
 _libavdemuxers=`echo $_libavdemuxers_all | sed -e s/AUDIO_BEOS_DEMUXER// -e s/OSS_DEMUXER// -e s/DC1394_DEMUXER// -e s/DV1394_DEMUXER// -e s/REDIR_DEMUXER// -e s/RTSP_DEMUXER// -e s/SDP_DEMUXER// -e s/V4L_DEMUXER// -e s/BKTR_DEMUXER// -e s/X11_GRAB_DEVICE_DEMUXER// -e s/V4L2_DEMUXER// -e s/LIBNUT_DEMUXER// -e s/AVISYNTH_DEMUXER// `
 _libavmuxers_all=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]'`
@@ -1198,6 +1199,16 @@
   esac
 done
 
+echo "_libavdecoders"
+echo $_libavdecoders
+echo "_libavparsers"
+echo $_libavparsers
+echo "_libavbsfs"
+echo $_libavbsfs
+echo "_libavdemuxers"
+echo $_libavdemuxers
+
+
 # Atmos: moved this here, to be correct, if --prefix is specified
 test -z "$_bindir" && _bindir="$_prefix/bin"
 test -z "$_datadir" && _datadir="$_prefix/share/mplayer"
@@ -6683,7 +6694,7 @@
   _def_muxers='#define CONFIG_MUXERS 1'
 else
   # mpeg1video for vf_lavc, snow for vf_uspp and vf_mcdeint
-  _libavencoders="MPEG1VIDEO_ENCODER SNOW_ENCODER"
+  _libavencoders=""
   _libavmuxers=""
 fi
 echores "$_mencoder"
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 24811)
+++ mplayer.c	(working copy)
@@ -214,8 +214,10 @@
 double vout_time_usage=0;
 static double audio_time_usage=0;
 static int total_time_usage_start=0;
-static int total_frame_cnt=0;
-static int drop_frame_cnt=0; // total number of dropped frames
+// AZ: changed frame_cnt variables to non-static so they can be extern'd and
+//     queried (is there a better way to do this?)
+int total_frame_cnt=0;
+int drop_frame_cnt=0; // total number of dropped frames
 int benchmark=0;
 
 // options:
@@ -665,6 +667,9 @@
 
 void exit_player_with_rc(const char* how, int rc){
 
+  // AZ: Added debug stating the player is exiting
+  printf("Exit player");  fflush(stdout);
+
   if (mpctx->user_muted && !mpctx->edl_muted) mixer_mute(&mpctx->mixer); 
   uninit_player(INITED_ALL);
 #ifdef HAVE_X11
@@ -1264,6 +1269,7 @@
         msg->prev = osd_msg_stack;
         osd_msg_stack = msg;
     }
+    
     // write the msg
     va_start(va,fmt);
     r = vsnprintf(msg->msg, 64, fmt, va);
@@ -1467,7 +1473,8 @@
     // Clear the term osd line
     if(term_osd && osd_text[0]) {
         osd_text[0] = 0;
-        printf("%s\n",term_osd_esc);
+        // AZ: Comment out OSD spew
+        //printf("O: %s\n",term_osd_esc);
     }
 }
 
@@ -2071,9 +2078,15 @@
     return frame_time;
 }
 
+// AZ: Various changes here to (better?) handle pausing with audio
+//     and handling functions that want pausing_keep  (non-pausing_keep may
+//     be borked)
 void pause_loop(void)
 {
     mp_cmd_t* cmd;
+	int brk_cmd = 0;
+	int resume_playback=0;
+
     if (!quiet) {
         // Small hack to display the pause message on the OSD line.
         // The pause string is: "\n == PAUSE == \r" so we need to
@@ -2092,13 +2105,18 @@
     if (use_gui)
 	guiGetEvent(guiCEvent, (char *)guiSetPause);
 #endif
+
+	//pause audio first...
+	if (mpctx->audio_out && mpctx->sh_audio)
+	mpctx->audio_out->pause();	// pause audio, keep data if possible
+
     if (mpctx->video_out && mpctx->sh_video && vo_config_count)
 	mpctx->video_out->control(VOCTRL_PAUSE, NULL);
 
-    if (mpctx->audio_out && mpctx->sh_audio)
-	mpctx->audio_out->pause();	// pause audio, keep data if possible
+keep_pausing:
 
     while ( (cmd = mp_input_get_cmd(20, 1, 1)) == NULL) {
+
 	if (mpctx->sh_video && mpctx->video_out && vo_config_count)
 	    mpctx->video_out->check_events();
 #ifdef HAVE_NEW_GUI
@@ -2115,16 +2133,37 @@
 #endif
 	usec_sleep(20000);
     }
-    if (cmd && cmd->id == MP_CMD_PAUSE) {
-	cmd = mp_input_get_cmd(0,1,0);
-	mp_cmd_free(cmd);
-    }
-    mpctx->osd_function=OSD_PLAY;
-    if (mpctx->audio_out && mpctx->sh_audio)
-        mpctx->audio_out->resume();	// resume audio
-    if (mpctx->video_out && mpctx->sh_video && vo_config_count)
-        mpctx->video_out->control(VOCTRL_RESUME, NULL);	// resume video
-    (void)GetRelativeTime();	// ignore time that passed during pause
+    if (cmd) {
+    	if (cmd->id == MP_CMD_PAUSE) {
+			cmd = mp_input_get_cmd(0,1,0);
+			mp_cmd_free(cmd);
+			cmd=NULL;
+			resume_playback=1;
+		} else if(cmd->pausing != 2) {
+			resume_playback=1;
+		}
+	}
+	if(resume_playback) {
+		mpctx->osd_function=OSD_PLAY;
+	 
+		if (mpctx->video_out && mpctx->sh_video && vo_config_count)
+			mpctx->video_out->control(VOCTRL_RESUME, NULL);	// resume video
+		if (mpctx->audio_out && mpctx->sh_audio)
+			mpctx->audio_out->resume();	// resume audio
+		(void)GetRelativeTime();	// ignore time that passed during pause
+	} else {
+		cmd = mp_input_get_cmd(0,1,0);
+		brk_cmd = run_command(mpctx, cmd);
+		
+		if (brk_cmd == 2) {
+			 mp_input_queue_cmd(cmd);
+		} else {
+			mp_cmd_free(cmd);
+			goto keep_pausing;
+		}
+	  
+	}
+	
 #ifdef HAVE_NEW_GUI
     if (use_gui) {
 	if (guiIntfStruct.Playing == guiSetStop)
@@ -2516,7 +2555,7 @@
     }
 
 //------ load global data first ------
-
+//#ifndef TRIMDOWN
 // check font
 #ifdef HAVE_FREETYPE
   init_freetype();
@@ -2547,7 +2586,8 @@
 #endif
 
   vo_init_osd();
-
+//#endif
+  
 #ifdef USE_ASS
   ass_library = ass_init();
 #endif
@@ -2726,6 +2766,11 @@
     }
 #endif /* HAVE_NEW_GUI */
 
+//AZ: Send stop event to EMP
+if (player_idle_mode && !filename) {
+  printf("!!Stopped\n");  fflush(stdout);
+}
+
 while (player_idle_mode && !filename) {
     play_tree_t * entry = NULL;
     mp_cmd_t * cmd;
@@ -3351,6 +3396,10 @@
     end_at.type = END_AT_NONE;
 }
 
+// AZ: Send Play event to EMP 
+if(filename) {
+    printf(">>Play %s\n", filename_recode(filename)); fflush(stdout);
+}
 
 while(!mpctx->eof){
     float aq_sleep_time=0;
@@ -3588,8 +3637,6 @@
 
 goto_next_file:  // don't jump here after ao/vo/getch initialization!
 
-mp_msg(MSGT_CPLAYER,MSGL_INFO,"\n");
-
 if(benchmark){
   double tot=video_time_usage+vout_time_usage+audio_time_usage;
   double total_time_usage;
@@ -3617,7 +3664,9 @@
 }
 
 // time to uninit all, except global stuff:
-uninit_player(INITED_ALL-(INITED_GUI+INITED_INPUT+(fixed_vo?INITED_VO:0)));
+// AZ: Don't uninit VO (We'll do that later)
+//uninit_player(INITED_ALL-(INITED_GUI+INITED_INPUT+(fixed_vo?INITED_VO:0)));
+uninit_player(INITED_ALL-(INITED_GUI+INITED_INPUT+INITED_VO));
 
   if ( mpctx->set_of_sub_size > 0 ) 
    {
@@ -3683,6 +3732,14 @@
   }	
 #endif
 
+// AZ: uninit if nothing next in playlist only
+// inited_flags will be set off for INITED_VO, and reinit_video_chain should
+// startup video again
+if (!fixed_vo && mpctx->playtree_iter == NULL) {
+	printf("uninit\n"); fflush(stdout);
+ uninit_player(INITED_VO);
+}
+
 if(use_gui || mpctx->playtree_iter != NULL || player_idle_mode){
   if (!mpctx->playtree_iter) filename = NULL;
   mpctx->eof = 0;
@@ -3694,3 +3751,12 @@
 
 return 1;
 }
+
+
+// AZ: call video out's check-events to allow it to handle things (like UI events)
+void checkEvents() {
+  current_module="vo_check_events";
+  if (vo_config_count && mpctx && mpctx->video_out) {
+    mpctx->video_out->check_events();
+  }
+}
\ No newline at end of file
Index: mplayer.h
===================================================================
--- mplayer.h	(revision 24811)
+++ mplayer.h	(working copy)
@@ -49,5 +49,11 @@
 
 extern void exit_player(const char* how);
 extern void update_set_of_subtitles(void);
+// AZ: access to checkEvents, which may allow the UI to update
+extern void checkEvents();
 
+// AZ: access to frame counts for EMP QOS
+extern int total_frame_cnt;
+extern int drop_frame_cnt; // total number of dropped frames
+
 #endif /* MPLAYER_H */
Index: cfg-common.h
===================================================================
--- cfg-common.h	(revision 24811)
+++ cfg-common.h	(working copy)
@@ -24,9 +24,11 @@
 #else
 	{"cache", "MPlayer was compiled without cache2 support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 #endif
+#ifndef TRIMDOWN
 	{"vcd", "-vcd N has been removed, use vcd://N instead.\n", CONF_TYPE_PRINT, CONF_NOCFG ,0,0, NULL},
 	{"cuefile", "-cuefile has been removed, use cue://filename:N where N is the track number.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
 	{"cdrom-device", &cdrom_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
+#endif
 #ifdef USE_DVDREAD
 	{"dvd-device", &dvd_device,  CONF_TYPE_STRING, 0, 0, 0, NULL}, 
 	{"dvd-speed", &dvd_speed, CONF_TYPE_INT, 0, 0, 0, NULL},
@@ -55,8 +57,10 @@
 	{"cookies-file", &cookies_file, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"prefer-ipv4", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, NULL},	
 	{"ipv4-only-proxy", &network_ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, NULL},	
+#ifndef TRIMDOWN
 	{"reuse-socket", &reuse_socket, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
 	{"noreuse-socket", &reuse_socket, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
+#endif //TRIMDOWN
 #ifdef HAVE_AF_INET6
 	{"prefer-ipv6", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 #else
@@ -80,6 +84,8 @@
 #else
 	{"rtsp-stream-over-tcp", "-rtsp-stream-over-tcp requires the \"LIVE555 Streaming Media\" libraries.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 #endif
+	
+#ifndef TRIMDOWN
 #ifdef MPLAYER_NETWORK
         {"rtsp-port", &rtsp_port, CONF_TYPE_INT, CONF_RANGE, -1, 65535, NULL},	
         {"rtsp-destination", &rtsp_destination, CONF_TYPE_STRING, CONF_MIN, 0, 0, NULL},
@@ -87,7 +93,8 @@
         {"rtsp-port", "MPlayer was compiled without network support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
         {"rtsp-destination", "MPlayer was compiled without network support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 #endif
-  
+#endif //TRIMDOWN
+        
 // ------------------------- demuxer options --------------------
 
 	// number of frames to play/convert
@@ -102,6 +109,7 @@
 
 	{"edl", &edl_filename,  CONF_TYPE_STRING, 0, 0, 0, NULL},
 
+#ifndef TRIMDOWN
 	// AVI specific: force non-interleaved mode
 	{"ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"noni", &force_ni, CONF_TYPE_FLAG, 0, 1, 0, NULL},
@@ -122,9 +130,11 @@
 	{ "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL },
 	{ "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 
+
 	{ "rawaudio", &demux_rawaudio_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 	{ "rawvideo", &demux_rawvideo_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
-
+#endif
+	
 #ifdef HAVE_CDDA
 	{ "cdda", &cdda_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 #endif
@@ -139,6 +149,7 @@
 	{ "extbased", &extension_parsing, CONF_TYPE_FLAG, 0, 0, 1, NULL },
 	{ "noextbased", &extension_parsing, CONF_TYPE_FLAG, 0, 1, 0, NULL },
 
+#ifndef TRIMDOWN
         {"mf", mfopts_conf, CONF_TYPE_SUBCONFIG, 0,0,0, NULL},
 #ifdef USE_RADIO
 	{"radio", radioopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
@@ -155,13 +166,15 @@
 #else
 	{"pvr", "MPlayer was compiled without V4L2/PVR interface support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
 #endif
+
 	{"vivo", vivoopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+#endif
 #ifdef HAS_DVBIN_SUPPORT
 	{"dvbin", dvbin_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 #endif
 
 // ------------------------- a-v sync options --------------------
-
+#ifndef TRIMDOWN
 	// AVI specific: A-V sync mode (bps vs. interleaving)
 	{"bps", &pts_from_bps, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"nobps", &pts_from_bps, CONF_TYPE_FLAG, 0, 1, 0, NULL},
@@ -182,7 +195,8 @@
 	// ignore header-specified delay (dwStart)
 	{"ignore-start", &ignore_start, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"noignore-start", &ignore_start, CONF_TYPE_FLAG, 0, 1, 0, NULL},
-
+#endif
+	
 #ifdef USE_LIBA52
         {"a52drc", &a52_drc_level, CONF_TYPE_FLOAT, CONF_RANGE, 0, 1, NULL},
 #endif
@@ -234,6 +248,7 @@
         {"noflip", &flip, CONF_TYPE_FLAG, 0, -1, 0, NULL},
 	{"tsfastparse", "-tsfastparse is no longer a valid option.\n", CONF_TYPE_PRINT, CONF_NOCFG ,0,0, NULL
 },
+#ifndef TRIMDOWN
 	{"tsprog", &ts_prog, CONF_TYPE_INT, CONF_RANGE, 0, 65534, NULL},
 #define TS_MAX_PROBE_SIZE 2000000 /* don't forget to change this in libmpdemux/demux_ts.c too */
 	{"tsprobe", &ts_probe, CONF_TYPE_POSITION, 0, 0, TS_MAX_PROBE_SIZE, NULL},
@@ -244,7 +259,8 @@
 	{"slices", &vd_use_slices, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"noslices", &vd_use_slices, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 	{"field-dominance", &field_dominance, CONF_TYPE_INT, CONF_RANGE, -1, 1, NULL},
-
+#endif
+	
 #ifdef USE_LIBAVCODEC
 	{"lavdopts", lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 #endif
@@ -545,6 +561,7 @@
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
+#ifndef TRIMDOWN
 /* VIVO demuxer options: */
 extern int vivo_param_version;
 extern char *vivo_param_acodec;
@@ -570,12 +587,12 @@
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
+
+
 extern int    mf_w;
 extern int    mf_h;
 extern float  mf_fps;
 extern char * mf_type;
-extern m_obj_settings_t* vf_settings;
-extern m_obj_list_t vf_obj_list;
 
 m_option_t mfopts_conf[]={
         {"on", "-mf on has been removed, use mf:// instead.\n", CONF_TYPE_PRINT, 0, 0, 1, NULL},
@@ -585,6 +602,9 @@
         {"type", &mf_type, CONF_TYPE_STRING, 0, 0, 0, NULL},
         {NULL, NULL, 0, 0, 0, 0, NULL}
 };
+#endif
+extern m_obj_settings_t* vf_settings;
+extern m_obj_list_t vf_obj_list;
 
 #include "libaf/af.h"
 extern af_cfg_t af_cfg; // Audio filter configuration, defined in libmpcodecs/dec_audio.c
Index: command.c
===================================================================
--- command.c	(revision 24811)
+++ command.c	(working copy)
@@ -499,6 +499,23 @@
     }
 }
 
+/// Paused (R)
+static int mp_property_paused(m_option_t * prop, int action, void *arg,
+	    MPContext * mpctx)
+{
+	int paused = mpctx->osd_function == OSD_PAUSE;
+	return m_property_flag(prop, action, arg, &paused);
+}
+
+/// Percent Drop Frame
+static int mp_property_percent_drop_frame(m_option_t * prop, int action,
+            void *arg, MPContext * mpctx)
+{
+  float drop_frame = total_frame_cnt == 0 ? 0 : (float)drop_frame_cnt/total_frame_cnt;
+  return m_property_float_range(prop, action, arg, &drop_frame);
+}
+
+
 /// Audio delay (RW)
 static int mp_property_audio_delay(m_option_t * prop, int action,
 				   void *arg, MPContext * mpctx)
@@ -1630,6 +1647,12 @@
      M_OPT_MIN, 0, 0, NULL },
     { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST,
      0, 0, 0, NULL },
+     
+     // AZ
+     { "paused", mp_property_paused, CONF_TYPE_FLAG,
+    	 M_OPT_RANGE, 0, 1, NULL },
+     { "percent_drop_frame", mp_property_percent_drop_frame, CONF_TYPE_FLOAT,
+         M_OPT_RANGE, 0.00, 100.0, NULL },
 
     // Audio
     { "volume", mp_property_volume, CONF_TYPE_FLOAT,
@@ -2784,6 +2807,11 @@
 	    break;
 #endif
 
+	case MP_CMD_AZ_PLAYSTATE: {
+		mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_%s=%s\n", "PLAYSTATE");
+	}
+	break;
+	    
 	default:
 #ifdef HAVE_NEW_GUI
 	    if ((use_gui) && (cmd->id > MP_CMD_GUI_EVENTS))
Index: common.mak
===================================================================
--- common.mak	(revision 24811)
+++ common.mak	(working copy)
@@ -10,7 +10,7 @@
 ASM_OBJS += $(ASM_OBJS-yes)
 CPP_OBJS += $(CPP_OBJS-yes)
 
-CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
+CFLAGS += -DHAVE_AV_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
           -D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
           -I$(SRC_PATH)/libavutil $(OPTFLAGS)
 
Index: mp_msg.c
===================================================================
--- mp_msg.c	(revision 24811)
+++ mp_msg.c	(working copy)
@@ -209,6 +209,6 @@
     if (lev <= MSGL_WARN){
         fprintf(stderr, "%s", tmp);fflush(stderr);
     } else {
-        printf("%s", tmp);fflush(stdout);
+        printf("%s", tmp, mod, lev);fflush(stdout);
     }
 }
Index: libmpdemux/Makefile
===================================================================
--- libmpdemux/Makefile	(revision 24811)
+++ libmpdemux/Makefile	(working copy)
@@ -3,20 +3,26 @@
 LIBNAME_COMMON   = libmpdemux.a
 LIBNAME_MENCODER = libmpmux.a
 
-SRCS_COMMON = asfheader.c \
-              aviheader.c \
-              aviprint.c \
-              demuxer.c \
+SRCS_COMMON = demuxer.c \
+			  demux_mkv.c ebml.c \
+			  video.c \
+			  parse_es.c \
+ 			  extension.c \
+ 			  demux_audio.c \
+ 			  demux_demuxers.c \
+ 			  mpeg_hdr.c \
+ 			  aviprint.c \
+ 			  mp3_hdr.c \
+ 			  demux_avi.c \
+ 			  aviheader.c \
+ 
+SRCS_COMMON-$(NO-TRIMDOWN) = asfheader.c \
               demux_aac.c \
               demux_asf.c \
-              demux_audio.c \
-              demux_avi.c \
-              demux_demuxers.c \
               demux_film.c \
               demux_fli.c \
               demux_lmlm4.c \
               demux_mf.c \
-              demux_mkv.c ebml.c \
               demux_mov.c \
               demux_mpg.c \
               demux_nsv.c \
@@ -34,14 +40,9 @@
               demux_viv.c \
               demux_vqf.c \
               demux_y4m.c \
-              extension.c \
               mf.c \
-              mp3_hdr.c \
-              mpeg_hdr.c \
               mpeg_packetizer.c \
-              parse_es.c \
               parse_mp4.c \
-              video.c \
               yuv4mpeg.c \
               yuv4mpeg_ratio.c \
 
Index: libmpdemux/video.c
===================================================================
--- libmpdemux/video.c	(revision 24811)
+++ libmpdemux/video.c	(working copy)
@@ -380,8 +380,13 @@
 
 return 1;
 }
-
+#ifndef TRIMDOWN
 void ty_processuserdata( unsigned char* buf, int len );
+#else
+void ty_processuserdata( unsigned char* buf, int len )
+{
+}
+#endif
 
 static void process_userdata(unsigned char* buf,int len){
     int i;
Index: libmpdemux/demuxer.c
===================================================================
--- libmpdemux/demuxer.c	(revision 24811)
+++ libmpdemux/demuxer.c	(working copy)
@@ -69,6 +69,8 @@
 extern demuxer_desc_t demuxer_desc_nut;
 
 demuxer_desc_t* demuxer_list[] = {
+  &demuxer_desc_matroska,
+#ifndef TRIMDOWN
   &demuxer_desc_rawaudio,
   &demuxer_desc_rawvideo,
 #ifdef USE_TV
@@ -85,7 +87,6 @@
   &demuxer_desc_nuv,
   &demuxer_desc_real,
   &demuxer_desc_smjpeg,
-  &demuxer_desc_matroska,
   &demuxer_desc_realaudio,
   &demuxer_desc_vqf,
   &demuxer_desc_mov,
@@ -132,6 +133,7 @@
 #ifdef HAVE_XMMS
   &demuxer_desc_xmms,
 #endif
+#endif
   NULL
 };
 
Index: libaf/Makefile
===================================================================
--- libaf/Makefile	(revision 24811)
+++ libaf/Makefile	(working copy)
@@ -3,11 +3,15 @@
 LIBNAME_COMMON = libaf.a
 
 SRCS_COMMON = af.c \
-              af_center.c \
+			  af_dummy.c \
+			  af_tools.c \
+			  format.c \
+			  $(AF_SRCS) \
+
+SRCS_COMMON-$(NO_TRIMDOWN) = af_center.c \
               af_channels.c \
               af_comp.c \
               af_delay.c \
-              af_dummy.c \
               af_equalizer.c \
               af_extrastereo.c \
               af_format.c \
@@ -20,13 +24,11 @@
               af_sub.c \
               af_surround.c \
               af_sweep.c \
-              af_tools.c \
               af_volnorm.c \
               af_volume.c \
               filter.c \
-              format.c \
               window.c \
-              $(AF_SRCS) \
+             
 
 SRCS_COMMON-$(HAVE_SYS_MMAN_H)      += af_export.c
 SRCS_COMMON-$(LIBAVCODEC)           += af_lavcresample.c
Index: libaf/af.c
===================================================================
--- libaf/af.c	(revision 24811)
+++ libaf/af.c	(working copy)
@@ -34,6 +34,7 @@
 
 static af_info_t* filter_list[]={ 
    &af_info_dummy,
+#ifndef TRIMDOWN
    &af_info_delay,
    &af_info_channels,
    &af_info_format,
@@ -61,6 +62,7 @@
    &af_info_center,
    &af_info_sinesuppress,
    &af_info_karaoke,
+#endif
    NULL 
 };