From 12af158ec7669cd07d2689866f7f707823c2a546 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 4 Mar 2006 23:53:22 +0000 Subject: [PATCH] Bits of OSD for recording play --- box.cc | 5 ++ box.h | 2 + colour.h | 5 ++ command.cc | 6 +++ main.cc | 14 +++--- player.h | 4 ++ playervideo.h | 5 ++ vvideorec.cc | 106 +++++++++++++++++++++++++++++++++++----- vvideorec.h | 12 ++++- wsymbol.cc | 131 ++++++++++++++++++++++++++++++++++++++++++++++++-- wsymbol.h | 3 ++ 11 files changed, 270 insertions(+), 23 deletions(-) diff --git a/box.cc b/box.cc index 96c085c..9c8120b 100644 --- a/box.cc +++ b/box.cc @@ -192,6 +192,11 @@ void Box::rectangle(int x1, int y1, int w, int h, Colour& colour) surface->fillblt(offsetX + x1, offsetY + y1, w, h, surface->rgba(colour.red, colour.green, colour.blue, colour.alpha)); } +void Box::rectangle(Region& region, Colour& colour) +{ + surface->fillblt(offsetX + region.x, offsetY + region.y, region.w, region.h, surface->rgba(colour.red, colour.green, colour.blue, colour.alpha)); +} + void Box::drawText(char* text, int x, int y, Colour& colour) { surface->drawText(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue); diff --git a/box.h b/box.h index bf34622..06de500 100644 --- a/box.h +++ b/box.h @@ -49,6 +49,8 @@ class Box // Drawing functions level 0 void rectangle(int x1, int y1, int w, int h, Colour& colour); + void rectangle(Region& region, Colour& colour); + void drawText(char* text, int x, int y, Colour& colour); void drawTextRJ(char* text, int x, int y, Colour& colour); void drawTextCentre(char* text, int x, int y, Colour& colour); diff --git a/colour.h b/colour.h index 84de2d6..9067e2a 100644 --- a/colour.h +++ b/colour.h @@ -33,6 +33,11 @@ class Colour Colour(int Tred, int Tgreen, int Tblue, int Talpha) { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; } + void set(int Tred, int Tgreen, int Tblue) + { red = Tred; green = Tgreen; blue = Tblue; alpha = 255; } + + void set(int Tred, int Tgreen, int Tblue, int Talpha) + { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; } int red; int green; diff --git a/command.cc b/command.cc index ecaf4e1..9edb793 100644 --- a/command.cc +++ b/command.cc @@ -575,4 +575,10 @@ void Command::doJustConnected(VConnect* vconnect) viewman->updateView(vw); // Enter pre-keys here + handleCommand(Remote::THREE); + handleCommand(Remote::DOWN); + handleCommand(Remote::OK); + handleCommand(Remote::OK); + handleCommand(Remote::OK); + } diff --git a/main.cc b/main.cc index 649224b..84dafac 100644 --- a/main.cc +++ b/main.cc @@ -294,13 +294,6 @@ int main(int argc, char** argv) void shutdown(int code) { - if (command) - { - command->shutdown(); - delete command; - logger->log("Core", Log::NOTICE, "Command module shut down"); - } - if (viewman) { viewman->shutdown(); @@ -308,6 +301,13 @@ void shutdown(int code) logger->log("Core", Log::NOTICE, "ViewMan module shut down"); } + if (command) // shut down command here in case views have posted messages + { + command->shutdown(); + delete command; + logger->log("Core", Log::NOTICE, "Command module shut down"); + } + if (vdr) { vdr->shutdown(); diff --git a/player.h b/player.h index 0b4f990..c4591d1 100644 --- a/player.h +++ b/player.h @@ -45,6 +45,10 @@ class Player : public Thread, public Callback virtual void setPosition(ULLONG position)=0; virtual void setLength(ULLONG length)=0; virtual void resyncAudio()=0; + virtual bool isPaused()=0; + virtual bool isFfwd()=0; + virtual bool isFbwd()=0; + #ifdef DEV virtual void test1()=0; virtual void test2()=0; diff --git a/playervideo.h b/playervideo.h index e9aa4b9..7d3908b 100644 --- a/playervideo.h +++ b/playervideo.h @@ -57,6 +57,11 @@ class PlayerVideo : public Player void setPosition(ULLONG position); void setLength(ULLONG length); void resyncAudio(); + + bool isPaused() { return paused; } + bool isFfwd() { return ffwd; } + bool isFbwd() { return fbwd; } + #ifdef DEV void test1(); void test2(); diff --git a/vvideorec.cc b/vvideorec.cc index 94b571f..3d5bd41 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -31,8 +31,15 @@ VVideoRec::VVideoRec(Recording* rec) myRec = rec; create(video->getScreenWidth(), video->getScreenHeight()); - Colour transparent(0, 0, 0, 0); + transparent.set(0, 0, 0, 0); setBackgroundColour(transparent); + + barRegion.x = 0; + barRegion.y = video->getScreenHeight() - 66; // FIXME, need to be - 1? and below? + barRegion.w = video->getScreenWidth(); + barRegion.h = 66; + + barBlue.set(0, 0, 150, 150); } VVideoRec::~VVideoRec() @@ -41,6 +48,8 @@ VVideoRec::~VVideoRec() delete player; Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post delete player"); Video::getInstance()->setDefaultAspect(); + + Timers::getInstance()->cancelTimer(this, 1); } void VVideoRec::draw() @@ -53,6 +62,7 @@ void VVideoRec::go(ULLONG startPosition) ULLONG recLength = vdr->streamRecording(myRec); if (recLength) { + doBar(0); player->setLength(recLength); player->setPosition(startPosition); player->play(); @@ -110,15 +120,18 @@ int VVideoRec::handleCommand(int command) case Remote::PAUSE: { player->togglePause(); + doBar(0); return 2; } case Remote::SKIPFORWARD: { + doBar(3); player->skipForward(60); return 2; } case Remote::SKIPBACK: { + doBar(4); player->skipBackward(60); return 2; } @@ -129,11 +142,13 @@ int VVideoRec::handleCommand(int command) } case Remote::YELLOW: { + doBar(2); player->skipBackward(10); return 2; } case Remote::BLUE: { + doBar(1); player->skipForward(10); return 2; } @@ -144,12 +159,30 @@ int VVideoRec::handleCommand(int command) return 2; } + case Remote::OK: + { + doBar(0); + return 2; + } + + // case Remote::REVERSE: // { // player->toggleFastBackward(); // return 2; // } + case Remote::ZERO: player->jumpToPercent(0); return 2; + case Remote::ONE: player->jumpToPercent(10); return 2; + case Remote::TWO: player->jumpToPercent(20); return 2; + case Remote::THREE: player->jumpToPercent(30); return 2; + case Remote::FOUR: player->jumpToPercent(40); return 2; + case Remote::FIVE: player->jumpToPercent(50); return 2; + case Remote::SIX: player->jumpToPercent(60); return 2; + case Remote::SEVEN: player->jumpToPercent(70); return 2; + case Remote::EIGHT: player->jumpToPercent(80); return 2; + case Remote::NINE: player->jumpToPercent(90); return 2; + #ifdef DEV case Remote::RED: { @@ -174,17 +207,6 @@ int VVideoRec::handleCommand(int command) } #endif - case Remote::ZERO: player->jumpToPercent(0); return 2; - case Remote::ONE: player->jumpToPercent(10); return 2; - case Remote::TWO: player->jumpToPercent(20); return 2; - case Remote::THREE: player->jumpToPercent(30); return 2; - case Remote::FOUR: player->jumpToPercent(40); return 2; - case Remote::FIVE: player->jumpToPercent(50); return 2; - case Remote::SIX: player->jumpToPercent(60); return 2; - case Remote::SEVEN: player->jumpToPercent(70); return 2; - case Remote::EIGHT: player->jumpToPercent(80); return 2; - case Remote::NINE: player->jumpToPercent(90); return 2; - } return 1; @@ -205,3 +227,63 @@ void VVideoRec::toggleChopSides() video->setMode(Video::NORMAL); } } + +void VVideoRec::doBar(int action) +{ + rectangle(barRegion, barBlue); + + /* Work out what to display - choices: + + Playing > + Paused || + FFwd >> + FBwd << + + Specials, informed by parameter + + Skip forward 10s >| + Skip backward 10s |< + Skip forward 1m >>| + Skip backward 1m |<< + + */ + + WSymbol w; + w.setSurface(surface); + w.nextSymbol = 0; + w.setSurfaceOffset(76, barRegion.y + 16); + + if (action) + { + if (action == 1) w.nextSymbol = WSymbol::SKIPFORWARD; + else if (action == 2) w.nextSymbol = WSymbol::SKIPBACK; + else if (action == 3) w.nextSymbol = WSymbol::SKIPFORWARD2; + else if (action == 4) w.nextSymbol = WSymbol::SKIPBACK2; + } + else + { + if (player->isPaused()) w.nextSymbol = WSymbol::PAUSE; + else if (player->isFfwd()) ; + else if (player->isFbwd()) ; + else w.nextSymbol = WSymbol::PLAY; + } + + w.draw(); + + ViewMan::getInstance()->updateView(this, &barRegion); + Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0}); +} + +void VVideoRec::timercall(int clientReference) +{ + switch(clientReference) + { + case 1: + { + // Remove bar + rectangle(barRegion, transparent); + ViewMan::getInstance()->updateView(this, &barRegion); + break; + } + } +} diff --git a/vvideorec.h b/vvideorec.h index b32e23c..709d475 100644 --- a/vvideorec.h +++ b/vvideorec.h @@ -30,10 +30,12 @@ #include "command.h" #include "colour.h" #include "osd.h" +#include "timers.h" +#include "timerreceiver.h" //#include "vepg.h" // for testing EPG in NTSC with a NTSC test video -class VVideoRec : public View +class VVideoRec : public View, public TimerReceiver { public: VVideoRec(Recording* rec); @@ -42,14 +44,22 @@ class VVideoRec : public View int handleCommand(int command); void go(ULLONG startPosition); + void timercall(int clientReference); + private: VDR* vdr; Video* video; Player* player; Recording* myRec; + Colour transparent; + Colour barBlue; + UCHAR videoMode; void toggleChopSides(); + + void doBar(int action); + Region barRegion; }; #endif diff --git a/wsymbol.cc b/wsymbol.cc index 15cbae4..959b875 100644 --- a/wsymbol.cc +++ b/wsymbol.cc @@ -20,8 +20,8 @@ #include "wsymbol.h" -UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2}; -UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16}; +UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5}; +UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18}; UCHAR WSymbol::symbols[] = { @@ -594,8 +594,133 @@ UCHAR WSymbol::symbols[] = { 0xFF, 0x00, 0xFC, 0x00, 0xF0, 0x00, -0xC0, 0x00 +0xC0, 0x00, + +/* +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 + +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +11111100 00001111 11000000 +*/ + +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, + +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, +0xFC, 0x0F, 0xC0, + +/* +11000000 00000000 00110000 00000000 00001100 +11000000 00000000 11110000 00000000 00111100 +11000000 00000011 11110000 00000000 11111100 +11000000 00001111 11110000 00000011 11111100 +11000000 00111111 11110000 00001111 11111100 +11000000 11111111 11110000 00111111 11111100 +11000011 11111111 11110000 11111111 11111100 +11001111 11111111 11110011 11111111 11111100 +11111111 11111111 11111111 11111111 11111100 + +11111111 11111111 11111111 11111111 11111100 +11001111 11111111 11110011 11111111 11111100 +11000011 11111111 11110000 11111111 11111100 +11000000 11111111 11110000 00111111 11111100 +11000000 00111111 11110000 00001111 11111100 +11000000 00001111 11110000 00000011 11111100 +11000000 00000011 11110000 00000000 11111100 +11000000 00000000 11110000 00000000 00111100 +11000000 00000000 00110000 00000000 00001100 +*/ + +0xC0, 0x00, 0x30, 0x00, 0x0C, +0xC0, 0x00, 0xF0, 0x00, 0x3C, +0xC0, 0x03, 0xF0, 0x00, 0xFC, +0xC0, 0x0F, 0xF0, 0x03, 0xFC, +0xC0, 0x3F, 0xF0, 0x0F, 0xFC, +0xC0, 0xFF, 0xF0, 0x3F, 0xFC, +0xC3, 0xFF, 0xF0, 0xFF, 0xFC, +0xCF, 0xFF, 0xF3, 0xFF, 0xFC, +0xFF, 0xFF, 0xFF, 0xFF, 0xFC, + +0xFF, 0xFF, 0xFF, 0xFF, 0xFC, +0xCF, 0xFF, 0xF3, 0xFF, 0xFC, +0xC3, 0xFF, 0xF0, 0xFF, 0xFC, +0xC0, 0xFF, 0xF0, 0x3F, 0xFC, +0xC0, 0x3F, 0xF0, 0x0F, 0xFC, +0xC0, 0x0F, 0xF0, 0x03, 0xFC, +0xC0, 0x03, 0xF0, 0x00, 0xFC, +0xC0, 0x00, 0xF0, 0x00, 0x3C, +0xC0, 0x00, 0x30, 0x00, 0x0C, + +/* +00110000 00000000 00001100 00000000 00000011 +00111100 00000000 00001111 00000000 00000011 +00111111 00000000 00001111 11000000 00000011 +00111111 11000000 00001111 11110000 00000011 +00111111 11110000 00001111 11111100 00000011 +00111111 11111100 00001111 11111111 00000011 +00111111 11111111 00001111 11111111 11000011 +00111111 11111111 11001111 11111111 11110011 +00111111 11111111 11111111 11111111 11111111 + +00111111 11111111 11111111 11111111 11111111 +00111111 11111111 11001111 11111111 11110011 +00111111 11111111 00001111 11111111 11000011 +00111111 11111100 00001111 11111111 00000011 +00111111 11110000 00001111 11111100 00000011 +00111111 11000000 00001111 11110000 00000011 +00111111 00000000 00001111 11000000 00000011 +00111100 00000000 00001111 00000000 00000011 +00110000 00000000 00001100 00000000 00000011 +*/ +0x30, 0x00, 0x0C, 0x00, 0x03, +0x3C, 0x00, 0x0F, 0x00, 0x03, +0x3F, 0x00, 0x0F, 0xC0, 0x03, +0x3F, 0xC0, 0x0F, 0xF0, 0x03, +0x3F, 0xF0, 0x0F, 0xFC, 0x03, +0x3F, 0xFC, 0x0F, 0xFF, 0x03, +0x3F, 0xFF, 0x0F, 0xFF, 0xC3, +0x3F, 0xFF, 0xCF, 0xFF, 0xF3, +0x3F, 0xFF, 0xFF, 0xFF, 0xFF, + +0x3F, 0xFF, 0xFF, 0xFF, 0xFF, +0x3F, 0xFF, 0xCF, 0xFF, 0xF3, +0x3F, 0xFF, 0x0F, 0xFF, 0xC3, +0x3F, 0xFC, 0x0F, 0xFF, 0x03, +0x3F, 0xF0, 0x0F, 0xFC, 0x03, +0x3F, 0xC0, 0x0F, 0xF0, 0x03, +0x3F, 0x00, 0x0F, 0xC0, 0x03, +0x3C, 0x00, 0x0F, 0x00, 0x03, +0x30, 0x00, 0x0C, 0x00, 0x03, }; diff --git a/wsymbol.h b/wsymbol.h index 1ece792..3074e12 100644 --- a/wsymbol.h +++ b/wsymbol.h @@ -49,6 +49,9 @@ class WSymbol : public Widget const static UCHAR UNMUTE = 12; const static UCHAR LEFTARROW = 13; const static UCHAR RIGHTARROW = 14; + const static UCHAR PAUSE = 15; + const static UCHAR SKIPBACK2 = 16; + const static UCHAR SKIPFORWARD2 = 17; private: static UCHAR symbols[]; -- 2.39.2