shithub: treason

Download patch

ref: d714d3c4c72b146f41f747f412962bc7f2b346a3
parent: 60f4589f28583b6d83dde28c70be3b16092d2858
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Sep 16 15:33:59 EDT 2020

show decoder/stream info

--- a/decoder.c
+++ b/decoder.c
@@ -39,6 +39,7 @@
 				goto err;
 			}
 			d->ops = ops[i].o;
+			snprint(d->info, sizeof(d->info), "%s", ops[i].name);
 			break;
 		}
 	}
--- a/decoder.h
+++ b/decoder.h
@@ -9,6 +9,7 @@
 	double timebase;
 
 	void *aux;
+	char info[128];
 };
 
 struct Decoderops {
--- a/main.c
+++ b/main.c
@@ -17,6 +17,8 @@
 static int audiofd = -1;
 static Channel *audiosync;
 static Channel *audiofinished;
+static char info[256];
+static int showinfo;
 
 static void
 audioproc(void *x)
@@ -89,6 +91,8 @@
 	else
 		r = screen->r;
 	draw(screen, r, curim, nil, ZP);
+	if(showinfo)
+		stringbg(screen, screen->r.min, display->white, ZP, font, info, display->black, ZP);
 	flushimage(display, 1);
 	unlockdisplay(display);
 	if(audiosync != nil)
@@ -219,6 +223,7 @@
 			res = alt(a);
 			switch(res){
 			case Cframe:
+				snprint(info, sizeof(info), " %dx%d %s %s                                             ", frame->w, frame->h, d->info, d->s->info);
 				drawframe(frame);
 				break;
 
@@ -234,6 +239,7 @@
 			case Ckeyboard:
 				end = key == 'q' || key == Kdel;
 				done = key == '\n';
+				showinfo = key == 'i' ? !showinfo : showinfo;
 				forced = 1;
 				break;
 
--- a/stream.c
+++ b/stream.c
@@ -18,12 +18,18 @@
 {
 	int i, failed;
 	Stream *s;
+	char *f;
 
 	*num = 0;
 	for(i = 0; i < nelem(ops); i++){
 		failed = 0;
-		if((s = ops[i].o->open(filename, num, &failed)) != nil)
+		if((s = ops[i].o->open(filename, num, &failed)) != nil){
+			f = utfrrune(filename, '/');
+			if(f == nil)
+				f = filename;
+			snprint(s->info, sizeof(s->info), "%s [%s]", ops[i].name, f);
 			return s;
+		}
 		if(failed){
 			werrstr("%s: %r", ops[i].name);
 			return nil;
--- a/stream.h
+++ b/stream.h
@@ -53,6 +53,8 @@
 			int srate;
 		}audio;
 	};
+
+	char info[128];
 };
 
 struct Stream {