CXX = $(CC)
INCLUDES = -I../jpeg-6b
-CXXFLAGS = -Wall -Woverloaded-virtual -Werror $(INCLUDES)
+CXXFLAGS = -g -O0 -Wall -Woverloaded-virtual -Werror $(INCLUDES)
LDFLAGS = -Wall -static
LIBPATHS =
LIBS = -lpthread -lrt
CROSSLIBS = ../jpeg-6b/libjpeg.a
-OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o directory.o thread.o \
+OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o directory.o thread.o event.o \
player.o demuxer.o stream.o vfeed.o afeed.o afeedr.o osd.o surface.o viewman.o vdr.o dsock.o box.o \
- list.o queue.o node.o recording.o channel.o message.o playervideo.o playerradio.o messagequeue.o \
+ recording.o channel.o message.o playervideo.o playerradio.o messagequeue.o \
view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \
vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vradiolive.o \
vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o \
all: vompclient
clean:
- rm -f *.o deps vompclient test *~ fonts/*.o fonts/*~
+ rm -f *.o deps vompclient *~ fonts/*.o fonts/*~
vompclient: $(OBJECTS)
$(CC) $(LDFLAGS) $(LIBPATHS) -o vompclient $(OBJECTS) $(CROSSLIBS) $(LIBS)
{
}
-void Box::setDimensions(int h, int w)
+void Box::setDimensions(int w, int h)
{
- height = h;
width = w;
+ height = h;
}
void Box::setScreenPos(int x, int y)
virtual ~Box();
void setScreenPos(int x, int y);
- void setDimensions(int h, int w);
+ void setDimensions(int w, int h);
void show();
virtual void draw();
/*
Real colours
*/
+Colour Colour::BLACK(0, 0, 0);
+Colour Colour::RED(255, 0, 0);
Colour Colour::VIDEOBLUE(0, 0, 150);
Colour Colour::VIEWBACKGROUND(0, 0, 100);
Colour Colour::TITLEBARBACKGROUND(0, 0, 200);
int blue;
int alpha;
+ static Colour BLACK;
+ static Colour RED;
static Colour VIDEOBLUE;
static Colour VIEWBACKGROUND;
static Colour TITLEBARBACKGROUND;
void Command::stop()
{
- VDR::getInstance()->cancelFindingServer();
+// VDR::getInstance()->cancelFindingServer();
irun = 0;
}
// Blue background
View* v = new View();
- v->setDimensions(video->getScreenHeight(), video->getScreenWidth());
+ v->setDimensions(video->getScreenWidth(), video->getScreenHeight());
v->setBackgroundColour(Colour::VIDEOBLUE);
v->draw();
v->show();
#include "video.h"
#include "remote.h"
#include "vdr.h"
-#include "list.h"
#include "message.h"
#include "messagequeue.h"
#include "box.h"
Directory::Directory()
{
name = NULL;
- dirList = new List();
- recList = new List();
isRoot = 0;
index = -1;
if (name) delete[] name;
index = -1; // just in case
- if (dirList)
+ for (UINT i = 0; i < dirList.size(); i++)
{
- while (!dirList->isEmpty())
- {
- dirList->reset();
- delete (Directory*)dirList->remove();
- }
-
- delete dirList;
+ delete dirList[i];
}
+ dirList.clear();
- if (recList)
+ for (UINT i = 0; i < recList.size(); i++)
{
- while (!recList->isEmpty())
- {
- recList->reset();
- delete (Recording*)recList->remove();
- }
-
- delete recList;
+ delete recList[i];
}
+ recList.clear();
}
void Directory::setName(char* newName)
Directory* Directory::getDirByName(char* dirName)
{
- Directory* currentDir;
- for(dirList->reset(); (currentDir = (Directory*)dirList->getCurrent()); dirList->next())
+ for(UINT i = 0; i < dirList.size(); i++)
{
- if (!strcmp(dirName, currentDir->name)) return currentDir;
+ if (!strcmp(dirName, dirList[i]->name)) return dirList[i];
}
return NULL;
}
ULONG Directory::getNumRecordings()
{
- return recList->getNumElements();
+ return recList.size();
}
// FIXME make an add function in here that adds recs to the end of the list
#define DIRECTORY_H
#include <stdio.h>
+#include <vector>
#include "defines.h"
-#include "list.h"
#include "recording.h"
+class Directory;
+typedef vector<Directory*> DirectoryList;
+typedef vector<Recording*> RecordingList;
+
class Directory
{
public:
int index;
- List* dirList;
- List* recList;
+ DirectoryList dirList;
+ RecordingList recList;
static ULONG totalSpace;
static ULONG freeSpace;
--- /dev/null
+/*
+ Copyright 2004-2005 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "event.h"
+
+Event::Event()
+{
+ id = 0;
+ time = 0;
+ duration = 0;
+
+ title = NULL;
+ subtitle = NULL;
+ description = NULL;
+
+ index = -1;
+}
+
+Event::~Event()
+{
+ if (title) delete[] title;
+ if (subtitle) delete[] subtitle;
+ if (description) delete[] description;
+}
--- /dev/null
+/*
+ Copyright 2004-2005 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef EVENT_H
+#define EVENT_H
+
+#include <stdio.h>
+
+#include "defines.h"
+
+class Event
+{
+ public:
+ Event();
+ ~Event();
+
+ ULONG id;
+ ULONG time;
+ ULONG duration;
+
+ char* title;
+ char* subtitle;
+ char* description;
+
+ int index;
+
+};
+
+class EventSorter
+{
+ public:
+ bool operator()(const Event* e1, const Event* e2)
+ {
+ return e1->time < e2->time;
+ }
+};
+
+#endif
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "list.h"
-
-// ------ Constructor add delete get methods -------------------------------------
-
-List::List(void)
-{
- start = NULL;
- current = NULL;
- prev = NULL;
- numElements = 0;
-}
-
-List::~List()
-{
- while (!isEmpty())
- {
- reset();
- remove();
- }
- numElements = 0;
-}
-
-void List::add(void *newData)
-{
- Node *temp = new Node(newData, current);
- current = temp;
- if (prev == 0)
- start = current;
- else
- prev->setPtr(current);
- ++numElements;
-}
-
-void *List::getCurrent(void) const
-{
- if (current == 0) return 0;
- else return current->getData();
-}
-
-void *List::remove(void)
-{
- if (current == 0) return 0;
- Node *dN;
-
- if (prev == 0)
- start = current->getPtr();
- else
- prev->setPtr(current->getPtr());
- dN = current;
- current = current->getPtr();
-
- // saved a reference to the Node in dN and current points to where it should
- // that's dN out of the list but it still needs to be deleted, and what it
- // points to
-
- void *returnObject;
- returnObject = dN->getData();
- delete dN;
- --numElements;
- return returnObject;
-}
-
-void List::remove(void *removeThis)
-{
- reset();
- while((!eol()) && (current->getData() != removeThis)) next();
- // Now use method above to actually remove the node and get the object
- remove();
-}
-
-unsigned long int List::getNumElements()
-{
- return numElements;
-}
-
-// ------ Pointer shift methods -----------------------------------------------
-
-void List::reset(void)
-{
- current = start;
- prev = 0;
-}
-
-void List::next(void)
-{
- if (current == 0) return;
- prev = current;
- current = current->getPtr();
-}
-
-// ------ Boolean methods -----------------------------------------------------
-
-short List::isEmpty(void) const
-{
- return (start == 0);
-}
-
-short List::eol(void) const
-{
- return (current == 0);
-}
-
-// ------ Save / load methods method --------------------------------------------
-
-void List::save(char *fileName, long int objectLength)
-{
- FILE *f = fopen(fileName, "w");
- fwrite(&objectLength, sizeof(long int), 1, f);
-
- void *v;
- reset();
- while(!eol())
- {
- v = getCurrent();
- fwrite(v, objectLength, 1, f);
- next();
- }
- fclose(f);
-}
-
-int List::load(char *fileName)
-{
-int temp1 = 0;
-
- int readIn = 0;
- long int objectLength = 0;
- FILE *f = fopen(fileName, "r");
- if (!f) return readIn;
-
- if (fread(&objectLength, sizeof(long int), 1, f) != 1)
- {
- fclose(f);
- return 0;
- }
-
- void *temp = 0;
-
- while(1)
- {
- temp = malloc(objectLength);
- if ((temp1=fread(temp, objectLength, 1, f)) < 1) break;
- readIn++;
- add(temp);
- }
-
- // We allocated temp but then fread failed
- free(temp);
- fclose(f);
- return readIn;
-}
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#ifndef LIST_H
-#define LIST_H
-
-#include <stdio.h>
-#include <malloc.h>
-#include "node.h"
-
-class List
-{
- public:
- List();
- ~List();
- void add(void *);
- void *getCurrent(void) const;
- void *remove(void); // Removes node from current position from list
- // and passes it back to be deleted
- void remove(void *); // Removes node passed in from list, does not delete it
- void reset(void);
- void next(void);
- short isEmpty(void) const;
- short eol(void) const;
- void save(char *, long int);
- int load(char *);
- unsigned long int getNumElements();
-
- private:
- Node *start;
- Node *current;
- Node *prev;
- unsigned long int numElements;
-};
-
-/* The list class can not delete the object stored in the node object because
- it does not know the length of it. All the node has is a void *. This is why
- List always passes back the actual stored object to the calling method.
-*/
-
-/* Fixed memory hole, when delete List, it deletes any remaining Nodes but not
- stored objects. That's just tuff.
-*/
-
-/* The new saving code will work as long as the objects don't contain any
- pointers to other areas of memory. Only for use with self-contained objects!
-*/
-
-#endif
const static ULONG VDR_CONNECTED = 12;
const static ULONG REDRAW_DATA = 13;
const static ULONG ADD_VIEW = 14;
+ const static ULONG CHANNEL_UP = 15;
+ const static ULONG CHANNEL_DOWN = 16;
};
#endif
void MessageQueue::postMessage(Message* m)
{
- messages.store(m);
+ messages.push(m);
Log::getInstance()->log("MessageQueue", Log::DEBUG, "have stored message in queue");
}
void MessageQueue::processMessageQueue()
{
Message *m;
- while((m = (Message*)messages.retrieve()))
+ while(messages.size())
{
+ m = messages.front();
+ messages.pop();
Log::getInstance()->log("MessageQueue", Log::DEBUG, "retrieved message from queue");
processMessage(m);
delete m;
#ifndef MESSAGEQUEUE_H
#define MESSAGEQUEUE_H
-#include "queue.h"
+#include <queue>
+
#include "message.h"
#include "log.h"
+typedef queue<Message*> MQueue;
+
class MessageQueue
{
public:
virtual void processMessageQueue();
virtual void processMessage(Message* m)=0;
- Queue messages;
private:
+ MQueue messages;
};
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "node.h"
-
-Node::Node(void *newData, Node *ptr)
-{
- myData = newData;
- ptrNext = ptr;
-}
-
-Node::~Node()
-{
-}
-
-void *Node::getData(void)
-{
- return myData;
-}
-
-Node *Node::getPtr(void)
-{
- return ptrNext;
-}
-
-void Node::setPtr(Node *newPtr)
-{
- ptrNext = newPtr;
-}
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#ifndef NODE_H
-#define NODE_H
-
-class Node
-{
- public:
- Node(void *, Node *);
- ~Node();
- void *getData(void);
- Node *getPtr(void);
- void setPtr(Node *);
- private:
- void *myData;
- Node *ptrNext;
-};
-
-#endif
video = Video::getInstance();
- if (demuxer.init()) // inverted
+ if (!demuxer.init())
{
Log::getInstance()->log("Player", Log::ERR, "Demuxer failed to init");
shutdown();
demuxer.reset();
feedPosition = 0;
}
+ Log::getInstance()->log("Player", Log::DEBUG, "Player shutdown done");
return 1;
}
/*
// video->test();
+*/
+/*
static int flipflop = 0;
int a;
{
Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST");
- video->test2();
+// video->test2();
}
void PlayerVideo::setPosition(ULLONG position)
Log::getInstance()->log("Player", Log::DEBUG, "Posting message...");
commandMessageQueue->postMessage(m);
Log::getInstance()->log("Player", Log::DEBUG, "Message posted...");
-
-
}
void PlayerVideo::threadPostStopCleanup()
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "queue.h"
-
-// ------ Constructor add delete get methods -------------------------------------
-
-Queue::Queue(void)
-{
- start = NULL;
- end = NULL;
-}
-
-Queue::~Queue()
-{
- while(!isEmpty()) retrieve();
-}
-
-void Queue::store(void *newData)
-{
- Node *temp = new Node(newData, NULL);
- if (temp == NULL)
- {
- // oh dear.
- }
- if (start == NULL) // add to empty queue
- {
- start = temp;
- end = temp;
- }
- else // add to non-empty queue
- {
- end->setPtr(temp);
- end = temp;
- }
-}
-
-void *Queue::retrieve(void)
-{
- if (start == NULL) { return NULL; } // there was an exit EXIT here bug?!!?!?
- if (start == end) // then we are removing the last node so set end to 0
- {
- end = NULL;
- }
- void *toReturn = start->getData();
- Node *next = start->getPtr();
- delete start;
- start = next;
- return toReturn;
-}
-
-void *Queue::peekNext(void)
-{
- return start->getData();
-}
-
-// ------ Boolean methods -----------------------------------------------------
-
-short Queue::isEmpty(void) const
-{
- return (start == NULL);
-}
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#ifndef QUEUE_H
-#define QUEUE_H
-
-#include <stdio.h>
-
-#include "node.h"
-
-class Queue
-{
- public:
- Queue();
- ~Queue();
- void store(void *);
- void *retrieve(void);
- short isEmpty(void) const;
- void *peekNext(void);
-
- private:
- Node *start;
- Node *end;
-};
-
-/* The destructor deletes any remaining QNodes but not stored objects. */
-
-#endif
surface.sfc.unknown = -1;
- r = ioctl(fdOsd, GFX_FB_SET_OSD, &displayNumber);
- if (r) return 0;
+// r = ioctl(fdOsd, GFX_FB_SET_OSD, &displayNumber);
+// if (r) return 0;
r = ioctl(fdOsd, GFX_FB_OSD_SURFACE, &displayNumber);
if (r) return 0;
surface.base[2] = (unsigned char *)mmap(NULL, surface.map.map[2].size, PROT_READ|PROT_WRITE, MAP_SHARED, fdOsd, surface.map.map[2].addr);
if (surface.base[2] == MAP_FAILED) return 0;
- surface.display.num = displayNumber;
- r = ioctl(fdOsd, GFX_FB_MOVE_DISPLAY, &surface.display);
- if (r) return 0;
+// surface.display.num = displayNumber;
+// r = ioctl(fdOsd, GFX_FB_MOVE_DISPLAY, &surface.display);
+// if (r) return 0;
- r = ioctl(fdOsd, GFX_FB_SET_DISPLAY, &surface.display);
- if (r) return 0;
+// r = ioctl(fdOsd, GFX_FB_SET_DISPLAY, &surface.display);
+// if (r) return 0;
return 1;
}
pthread_cond_wait(&threadCond, &threadCondMutex);
pthread_mutex_unlock(&threadCondMutex);
}
+
+void Thread::threadSetKillable()
+{
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+}
char threadIsActive(); // returns 1 if thread has been started but not stop() or cancel() 'd
// Methods to use from inside the thread
+ void threadSetKillable(); // allows threadCancel() to work
void threadCheckExit(); // terminates thread if threadStop() has been called
void threadWaitForSignal(); // pauses thread until threadSignal() is called
setScreenPos(70, 35);
}
- setDimensions(420, 570);
+ setDimensions(570, 420);
setBackgroundColour(Colour::VIEWBACKGROUND);
setTitleBarOn(1);
setTitleBarColour(Colour::TITLEBARBACKGROUND);
sl.setScreenPos(screenX + 10, screenY + 30 + 5);
- sl.setDimensions(height - 30 - 15 - 30, width - 20);
+ sl.setDimensions(width - 20, height - 30 - 15 - 30);
}
VChannelList::~VChannelList()
{
if (chanList)
{
- while (!chanList->isEmpty())
+ for (UINT i = 0; i < chanList->size(); i++)
{
- chanList->reset();
- delete (Channel*)chanList->remove();
+ delete (*chanList)[i];
}
+ chanList->clear();
delete chanList;
}
}
-void VChannelList::setList(List* tlist)
+void VChannelList::setList(ChannelList* tlist)
{
char str[500];
sl.addColumn(0);
- sl.addColumn(50);
+ sl.addColumn(60);
chanList = tlist;
int first = 1;
if (chanList)
{
- chanList->reset();
-
- while((chan = (Channel*)chanList->getCurrent()))
+ for (UINT i = 0; i < chanList->size(); i++)
{
+ chan = (*chanList)[i];
sprintf(str, "%lu\t%s", chan->number, chan->name);
chan->index = sl.addOption(str, first);
first = 0;
- chanList->next();
}
}
}
sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
Box b;
b.setScreenPos(screenX + 220, screenY + 385);
- b.setDimensions(25, 160);
+ b.setDimensions(160, 25);
b.fillColour(Colour::VIEWBACKGROUND);
b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
}
if (chanList)
{
int currentOption = sl.getCurrentOption();
- chanList->reset();
- while((chan = (Channel*)chanList->getCurrent()))
+ for (UINT i = 0; i < chanList->size(); i++)
{
+ chan = (*chanList)[i];
if (currentOption == chan->index) break;
- chanList->next();
}
}
#include <stdio.h>
#include <string.h>
+#include <vector>
#include "view.h"
-#include "list.h"
#include "wselectlist.h"
#include "remote.h"
#include "wsymbol.h"
VChannelList(ULONG type);
~VChannelList();
- void setList(List* chanList);
+ void setList(ChannelList* chanList);
int handleCommand(int command);
void draw();
private:
- List* chanList;
+ ChannelList* chanList;
ULONG type;
WSelectList sl;
VChannelSelect::VChannelSelect(VVideoLive* v, int command)
{
- setDimensions(30, 53);
+ setDimensions(53, 30);
setScreenPos(80, 60);
setBackgroundColour(Colour::VIEWBACKGROUND);
vdr = VDR::getInstance();
logger = Log::getInstance();
- setDimensions(200, 400);
+ setDimensions(400, 200);
if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(170, 200);
{
irun = 0;
vdr->cancelFindingServer();
- threadStop();
+ threadCancel();
}
void VConnect::draw()
findingServer = 0;
tcp = NULL;
pthread_mutex_init(&mutex, NULL);
+ packetLength = 0;
+ packetPos = 0;
+ packet = NULL;
}
VDR::~VDR()
return 1;
}
-void VDR::findServers(std::vector<char*>& serverIPs)
+void VDR::findServers(vector<char*>& serverIPs)
{
findingServer = 1;
char* message = "VOMP CLIENT";
Log::getInstance()->log("VDR", Log::DEBUG, "Disconnect");
}
-long VDR::getSimpleReply()
-{
- unsigned char* p = (unsigned char*)tcp->receivePacket();
- if (!p) return -1;
-
- Log::getInstance()->log("VDR", Log::DEBUG, "tcp data length = %i", tcp->getDataLength());
-
- if (tcp->getDataLength() != 4)
- {
- free(p);
- return -1;
- }
-
- ULONG reply = ntohl(*(ULONG*)p);
-
- Log::getInstance()->log("VDR", Log::DEBUG, "VDR said %li", reply);
-
- free(p);
+///////////////////////////////////////////////////////
- return reply;
+int VDR::getPacket()
+{
+ packet = (UCHAR*)tcp->receivePacket();
+ if (!packet) return 0;
+ packetLength = tcp->getDataLength();
+ return 1;
}
-char* VDR::getStringReply()
+void VDR::freePacket()
{
- unsigned char* p = (unsigned char*)tcp->receivePacket();
- if (!p) return NULL;
-
- int dataLength = tcp->getDataLength();
-
-// Log::getInstance()->log("VDR", Log::DEBUG, "GSR Data length %u", dataLength);
+ // Must be called if getPacket return 1, except in getBlock
+ packetLength = 0;
+ packetPos = 0;
+ free(packet);
+ packet = NULL;
+}
- if ((dataLength == 4) && (p[0] == '\0'))
- {
- Log::getInstance()->log("VDR", Log::DEBUG, "GSR returning null no string returned");
- free(p);
- return NULL; // no string returned
- }
+int VDR::serverError()
+{
+ if ((packetPos == 0) && (packetLength == 4) && !ntohl(*(ULONG*)packet)) return 1;
+ else return 0;
+}
- char* returnText;
- int tLength;
+char* VDR::extractString()
+{
+ if (serverError()) return NULL;
+
+ int length = strlen((char*)&packet[packetPos]);
+ if ((packetPos + length) > packetLength) return NULL;
+ char* str = new char[length + 1];
+ strcpy(str, (char*)&packet[packetPos]);
+ packetPos += length + 1;
+ return str;
+}
- tLength = strlen((char*)p);
- returnText = new char[tLength + 1];
- strcpy(returnText, (char*)p);
+ULONG VDR::extractULONG()
+{
+ if ((packetPos + sizeof(ULONG)) > packetLength) return 0;
+ ULONG ul = ntohl(*(ULONG*)&packet[packetPos]);
+ packetPos += sizeof(ULONG);
+ return ul;
+}
- free(p);
+ULLONG VDR::extractULLONG()
+{
+ if ((packetPos + sizeof(ULLONG)) > packetLength) return 0;
+ ULLONG ull = ntohll(*(ULLONG*)&packet[packetPos]);
+ packetPos += sizeof(ULLONG);
+ return ull;
+}
- return returnText;
+long VDR::extractLONG()
+{
+ if ((packetPos + sizeof(long)) > packetLength) return 0;
+ long l = ntohl(*(long*)&packet[packetPos]);
+ packetPos += sizeof(long);
+ return l;
}
/////////////////////////////////////////////////////////////////////////////
// reply
- UCHAR* p = tcp->receivePacket();
- pthread_mutex_unlock(&mutex);
- if (!p) return 0;
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
+
+ ULONG vdrTime = extractULONG();
+ logger->log("VDR", Log::DEBUG, "vdrtime = %lu", vdrTime);
+ long vdrTimeOffset = extractLONG();
+ logger->log("VDR", Log::DEBUG, "offset = %i", vdrTimeOffset);
- int count = 0;
+ freePacket();
+ pthread_mutex_unlock(&mutex);
- unsigned long vdrTime = ntohl(*(unsigned long*)&p[count]);
- count += sizeof(unsigned long);
- Log::getInstance()->log("VDR", Log::DEBUG, "vdrtime = %lu", vdrTime);
struct timespec currentTime;
currentTime.tv_sec = vdrTime;
currentTime.tv_nsec = 0;
int b = clock_settime(CLOCK_REALTIME, ¤tTime);
- Log::getInstance()->log("VDR", Log::DEBUG, "set clock = %u", b);
+ logger->log("VDR", Log::DEBUG, "set clock = %u", b);
// now make a TZ variable and set it
- signed int vdrTimeOffset = ntohl(*(signed int*)&p[count]);
- Log::getInstance()->log("VDR", Log::DEBUG, "offset = %i", vdrTimeOffset);
-
char sign;
int hours;
int minutes;
hours = (int)vdrTimeOffset / 3600;
minutes = vdrTimeOffset % 3600;
- Log::getInstance()->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes);
+ logger->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes);
minutes = (int)minutes / 60;
- Log::getInstance()->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes);
+ logger->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes);
char newTZ[30];
sprintf(newTZ, "MVP%c%i:%i", sign, hours, minutes);
setenv("TZ", newTZ, 1);
- Log::getInstance()->log("VDR", Log::DEBUG, "Timezone data: %s", newTZ);
+ logger->log("VDR", Log::DEBUG, "Timezone data: %s", newTZ);
- free(p);
return 1;
}
// reply
- unsigned char* p = (unsigned char*)tcp->receivePacket();
- pthread_mutex_unlock(&mutex);
- if (!p) return 0;
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
Directory* recDir = new Directory();
recDir->setName("/");
recDir->isRoot = 1;
- int dataLength = tcp->getDataLength();
-
- Log::getInstance()->log("VDR", Log::DEBUG, "Data length %u", dataLength);
-
- int count = 0;
+ Directory::totalSpace = extractULONG();
+ Directory::freeSpace = extractULONG();
+ Directory::usedPercent = extractULONG();
- Directory::totalSpace = (*(ULONG*)&p[count]);
- count += sizeof(ULONG);
- Directory::freeSpace = (*(ULONG*)&p[count]);
- count += sizeof(ULONG);
- Directory::usedPercent = (*(ULONG*)&p[count]);
- count += sizeof(ULONG);
+ char* string;
- int tLength;
-
- while (count < dataLength)
+ while (packetPos < packetLength)
{
Recording* rec = new Recording();
- rec->start = ntohl(*(unsigned long*)&p[count]);
- count += 4;
- tLength = strlen((char*)&p[count]);
- rec->setName((char*)&p[count]);
+ rec->start = extractULONG();
-// rec->name = new char[tLength + 1];
-// strcpy(rec->name, (char*)&p[count]);
- count += tLength + 1;
+ string = extractString();
+ rec->setName(string);
+ delete[] string;
- tLength = strlen((char*)&p[count]);
- rec->fileName = new char[tLength + 1];
- strcpy(rec->fileName, (char*)&p[count]);
- count += tLength + 1;
+ rec->fileName = extractString();
if(rec->isInDir())
{
d = new Directory();
d->setName(dirName);
Log::getInstance()->log("VDR", Log::DEBUG, "Added a new directory = %s", d->name);
- recDir->dirList->add(d);
+ recDir->dirList.push_back(d);
}
- d->recList->add(rec);
- d->recList->next();
+ d->recList.push_back(rec);
}
else
{
- recDir->recList->add(rec);
- recDir->recList->next();
+ recDir->recList.push_back(rec);
}
Log::getInstance()->log("VDR", Log::DEBUG, "Have added a recording to list. %lu %s", rec->start, rec->getProgName());
}
- free(p);
+ freePacket();
+ pthread_mutex_unlock(&mutex);
return recDir;
}
return 0;
}
- int toReturn = getSimpleReply();
- if (toReturn == -1) toReturn = 0; // error is same as 0=bad in this case
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
+
+ int toReturn = (int)extractULONG();
+ freePacket();
pthread_mutex_unlock(&mutex);
+
return toReturn;
}
return NULL;
}
- char* toReturn = getStringReply();
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
+ char* toReturn = extractString();
+ freePacket();
pthread_mutex_unlock(&mutex);
+
return toReturn;
}
-List* VDR::getChannelsList(ULONG type)
+ChannelList* VDR::getChannelsList(ULONG type)
{
UCHAR buffer[8];
// reply
- unsigned char* p = (unsigned char*)tcp->receivePacket();
- pthread_mutex_unlock(&mutex);
- if (!p) return NULL;
-
- List* chanList = new List();
-
- int dataLength = tcp->getDataLength();
-
- Log::getInstance()->log("VDR", Log::DEBUG, "Data length %u", dataLength);
-
- int count = 0;
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
- int tLength;
+ ChannelList* chanList = new ChannelList();
- while (count < dataLength)
+ while (packetPos < packetLength)
{
Channel* chan = new Channel();
- chan->number = ntohl(*(unsigned long*)&p[count]);
- count += 4;
- chan->type = ntohl(*(unsigned long*)&p[count]);
- count += 4;
-
- tLength = strlen((char*)&p[count]);
- chan->name = new char[tLength + 1];
- strcpy(chan->name, (char*)&p[count]);
- count += tLength + 1;
+ chan->number = extractULONG();
+ chan->type = extractULONG();
+ chan->name = extractString();
if (chan->type == type)
{
- chanList->add(chan);
- chanList->next();
+ chanList->push_back(chan);
Log::getInstance()->log("VDR", Log::DEBUG, "Have added a channel to list. %lu %lu %s", chan->number, chan->type, chan->name);
}
else
}
}
- free(p);
+ freePacket();
+ pthread_mutex_unlock(&mutex);
return chanList;
}
return 0;
}
- int toReturn = getSimpleReply();
- if (toReturn == -1) toReturn = 0; // change error to bad
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
+
+ int toReturn = (int)extractULONG();
+ freePacket();
pthread_mutex_unlock(&mutex);
+
return toReturn;
}
return 0;
}
- int toReturn = getSimpleReply();
- if (toReturn == -1) toReturn = 0; // change error to bad
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
+
+ int toReturn = (int)extractULONG();
+ freePacket();
pthread_mutex_unlock(&mutex);
+
return toReturn;
}
return NULL;
}
- unsigned char* p = (unsigned char*)tcp->receivePacket();
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
+
+ UCHAR* toReturn = packet;
+ *amountReceived = packetLength;
+ // Manually clean up instead of running freePacket to keep the block
+ packet = NULL;
+ packetLength = 0;
+ packetPos = 0;
pthread_mutex_unlock(&mutex);
- if (!p) return NULL;
- *amountReceived = tcp->getDataLength();
- return p;
+
+ return toReturn;
}
ULLONG VDR::streamRecording(Recording* rec)
return 0;
}
- unsigned char* p = (unsigned char*)tcp->receivePacket();
- pthread_mutex_unlock(&mutex);
- if (!p) return 0;
-
- if (tcp->getDataLength() != 8)
+ if (!getPacket())
{
- free(p);
+ pthread_mutex_unlock(&mutex);
return 0;
}
- ULLONG recordingLength = ntohll(*(ULLONG*)p);
+ ULLONG recordingLength = extractULLONG();
+ freePacket();
+ pthread_mutex_unlock(&mutex);
Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu", recordingLength);
- free(p);
return recordingLength;
}
return 0;
}
- unsigned char* p = (unsigned char*)tcp->receivePacket();
- pthread_mutex_unlock(&mutex);
- if (!p) return 0;
-
- if (tcp->getDataLength() != 8)
+ if (!getPacket())
{
- free(p);
+ pthread_mutex_unlock(&mutex);
return 0;
}
- ULLONG recordingLength = ntohll(*(ULLONG*)p);
+ ULLONG recordingLength = extractULLONG();
+ freePacket();
+ pthread_mutex_unlock(&mutex);
Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu", recordingLength);
- free(p);
return recordingLength;
}
-int VDR::getChannelSchedule(ULONG number)
+EventList* VDR::getChannelSchedule(ULONG number)
{
UCHAR buffer[12];
if (a != 12)
{
pthread_mutex_unlock(&mutex);
- return -1;
+ return NULL;
}
- unsigned char* p = (unsigned char*)tcp->receivePacket();
- pthread_mutex_unlock(&mutex);
- if (!p) return -1;
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
+
+ if (serverError())
+ {
+ freePacket();
+ pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
- int dataLength = tcp->getDataLength();
- if (dataLength != 4)
+ EventList* eventList = new EventList();
+
+ while (packetPos < packetLength)
{
- free(p);
- return -1;
+ Event* event = new Event();
+ event->id = extractULONG();
+ event->time = extractULONG();
+ event->duration = extractULONG();
+ event->title = extractString();
+ event->subtitle = extractString();
+ event->description = extractString();
+ eventList->push_back(event);
+// eventList->next();
}
- ULONG data = ntohl(*(ULONG*)p);
- free(p);
+ freePacket();
+ pthread_mutex_unlock(&mutex);
+
+ Log::getInstance()->log("VDR", Log::DEBUG, "Success got to end of getChannelSchedule");
+
+
+ // debug
+/*
+ Log* l = Log::getInstance();
+
- Log::getInstance()->log("VDR", Log::DEBUG, "Success got to end of getChannelSchedule %lu", data);
+ l->log("VDR", Log::DEBUG, "datalength = %i count = %i", dataLength, count);
- return data;
+ Event* currentEvent;
+ for(eventList->reset(); !eventList->eol(); eventList->next())
+ {
+ currentEvent = (Event*)eventList->getCurrent();
+ l->log("VDR", Log::DEBUG, "%lu %lu %lu %s %s %s", currentEvent->id, currentEvent->time, currentEvent->duration, currentEvent->title, currentEvent->subtitle, currentEvent->description);
+ }
+*/
+
+ return eventList;
}
ULLONG VDR::getResumePoint(char* fileName)
return 0;
}
- int toReturn = getSimpleReply();
- if (toReturn == -1) toReturn = 0; // change error to bad
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
+
+ int toReturn = (int)extractULONG();
+ freePacket();
pthread_mutex_unlock(&mutex);
+
return toReturn;
}
return NULL;
}
- char* toReturn = getStringReply();
+ if (!getPacket())
+ {
+ pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
+ char* toReturn = extractString();
+ freePacket();
pthread_mutex_unlock(&mutex);
+
return toReturn;
}
#include "log.h"
#include "dsock.h"
#include "tcp.h"
-#include "list.h"
#include "directory.h"
#include "recording.h"
#include "channel.h"
+#include "event.h"
+
+using namespace std;
// FIXME do some tcp connection error checking and kill it!
+typedef vector<Event*> EventList;
+typedef vector<Channel*> ChannelList;
+
class VDR
{
+
public:
VDR();
~VDR();
int init(int port);
int shutdown();
- void findServers(std::vector<char*>& serverIPs);
+ void findServers(vector<char*>& serverIPs);
void cancelFindingServer();
void setServerIP(char*);
int connect();
ULLONG streamRecording(Recording* rec);
ULLONG rescanRecording();
- List* getChannelsList(ULONG type);
- int streamChannel(ULONG number);
+ ChannelList* getChannelsList(ULONG type);
+ int streamChannel(ULONG number);
UCHAR* getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived);
int stopStreaming();
- int getChannelSchedule(ULONG number);
+ EventList* getChannelSchedule(ULONG number);
int configSave(char* section, char* key, char* value);
char* configLoad(char* section, char* key);
char serverIP[16];
pthread_mutex_t mutex;
+ UCHAR* packet;
+ ULONG packetLength;
+ ULONG packetPos;
+
const static ULONG VDR_LOGIN = 1;
const static ULONG VDR_GETRECORDINGLIST = 2;
const static ULONG VDR_DELETERECORDING = 3;
const static ULONG VDR_CONFIGLOAD = 12;
const static ULONG VDR_RESCANRECORDING = 13;
- long getSimpleReply();
- char* getStringReply();
+ int getPacket();
+ void freePacket();
+ int serverError();
+ char* extractString();
+ ULONG extractULONG();
+ ULLONG extractULLONG();
+ long extractLONG();
};
#endif
View::View()
{
- height = 0;
width = 0;
+ height = 0;
screenX = 0;
screenY = 0;
if (i == 0)
{
// not a View we have!
- pthread_mutex_unlock(&viewManLock);
+ if (!noLock) pthread_mutex_unlock(&viewManLock);
return 0;
}
}
#include "vlivebanner.h"
-VLiveBanner::VLiveBanner(Channel* channel)
+VLiveBanner::VLiveBanner(View* tparent, Channel* channel)
{
- currentChannel = channel;
+ eventList = NULL;
+ parent = tparent;
if (Video::getInstance()->getFormat() == Video::PAL)
{
- setScreenPos(130, 370);
+ setScreenPos(125, 410);
}
else
{
- setScreenPos(120, 320);
+ setScreenPos(115, 320);
}
- setDimensions(120, 500);
+ setDimensions(500, 120);
setBackgroundColour(Colour::VIEWBACKGROUND);
setTitleBarOn(1);
- setTitleText(currentChannel->name);
setTitleBarColour(Colour::TITLEBARBACKGROUND);
sl.setScreenPos(screenX, screenY + 30);
- sl.setDimensions(height - 60, width);
+ sl.setDimensions(width, height - 60);
+ sl.setNoLoop();
+
+ setChannel(channel);
}
VLiveBanner::~VLiveBanner()
{
+ delData();
}
-void VLiveBanner::draw()
+void VLiveBanner::delData()
{
-//int success = VDR::getInstance()->getChannelSchedule(1);
-int success = 0;
+ if (eventList)
+ {
+ int eventListSize = eventList->size();
+ for(int i = 0; i < eventListSize; i++)
+ {
+ delete (*eventList)[i];
+ }
+ eventList->clear();
+ delete eventList;
- if (!success)
+ }
+ sl.clear();
+}
+
+void VLiveBanner::setChannel(Channel* tChannel)
+{
+ delData();
+ currentChannel = tChannel;
+ // get the data
+
+ setTitleText(currentChannel->name);
+ eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
+
+ if (!eventList)
{
sl.addOption("No channel data available", 1);
}
else
{
- sl.addOption("This Programme", 1);
- sl.addOption("The Next Programme", 0);
- sl.addOption("The Programme after that", 0);
+ // sort the list
+ Log::getInstance()->log("Banner", Log::DEBUG, "Start sort");
+ sort(eventList->begin(), eventList->end(), EventSorter());
+ Log::getInstance()->log("Banner", Log::DEBUG, "End sort");
+
+ char tempString[300];
+ char tempString2[300];
+ struct tm* btime;
+ Event* event;
+ int first = 1;
+ int eventListSize = eventList->size();
+ for(int i = 0; i < eventListSize; i++)
+ {
+ event = (*eventList)[i];
+
+ btime = localtime((time_t*)&event->time);
+ strftime(tempString2, 299, "%0H:%0M ", btime);
+ snprintf(tempString, 299, "%s %s", tempString2, event->title);
+ event->index = sl.addOption(tempString, first);
+ first = 0;
+ }
+
+ // Reset the timer as it probably took 1-2 seconds to change the channel
+ ViewMan::getInstance()->timedDelete(this, 4, 0);
}
+}
+void VLiveBanner::draw()
+{
View::draw();
sl.draw();
rectangle(0, height - 30, width, 30, titleBarColour);
+
+ rectangle(7, height - 24, 18, 16, Colour::RED);
+ drawText("info", 32, height - 25, Colour::LIGHTTEXT);
}
int VLiveBanner::handleCommand(int command)
show();
return 2;
}
+ case Remote::CHANNELUP:
+ {
+ Message* m = new Message();
+ m->from = this;
+ m->to = parent;
+ m->message = Message::CHANNEL_UP;
+ ViewMan::getInstance()->postMessage(m);
+ return 2;
+ }
+ case Remote::CHANNELDOWN:
+ {
+ Message* m = new Message();
+ m->from = this;
+ m->to = parent;
+ m->message = Message::CHANNEL_DOWN;
+ ViewMan::getInstance()->postMessage(m);
+ return 2;
+ }
+ case Remote::RED:
+ case Remote::MENU:
+ {
+ if (!eventList) return 2;
+ Event* event;
+ int eventListSize = eventList->size();
+ for(int i = 0; i < eventListSize; i++)
+ {
+ event = (*eventList)[i];
+ if (event->index == sl.getCurrentOption())
+ {
+ Log::getInstance()->log("VLiveBanner", Log::DEBUG, "Found the option you pointed at. %s", event->title);
+ // First, cancel my delete timer
+ ViewMan::getInstance()->timedDelete(this, 0, 0);
+
+ VInfo* vi = new VInfo();
+ vi->setTitleText(event->title);
+ vi->setBorderOn(1);
+ vi->setExitable();
+ if (event->description) vi->setMainText(event->description);
+ else vi->setMainText("Summary unavailable");
+ if (Video::getInstance()->getFormat() == Video::PAL)
+ {
+ vi->setScreenPos(120, 130);
+ }
+ else
+ {
+ vi->setScreenPos(110, 90);
+ }
+ vi->setDimensions(510, 270);
+
+ ViewMan::getInstance()->addNoLock(vi);
+ vi->draw();
+ vi->show();
+
+ return 2;
+
+ }
+ }
+ return 2; // should not get here
+ }
}
return 1;
#include <stdio.h>
#include <string.h>
+#include <vector>
+#include <algorithm>
#include "view.h"
#include "remote.h"
#include "wselectlist.h"
#include "colour.h"
#include "video.h"
+#include "event.h"
+#include "vinfo.h"
+#include "viewman.h"
class VLiveBanner : public View
{
public:
- VLiveBanner(Channel* channel);
+ VLiveBanner(View* parent, Channel* channel);
~VLiveBanner();
+ void delData();
+
+ void setChannel(Channel* channel);
int handleCommand(int command);
void draw();
private:
+ View* parent;
WSelectList sl;
Channel* currentChannel;
+ EventList* eventList;
};
VOptions::VOptions()
{
- setDimensions(190, 460);
+ setDimensions(460, 190);
if (Video::getInstance()->getFormat() == Video::PAL)
{
int fontHeight = surface->getFontHeight();
optionBox[0].setScreenPos(screenX + 290, screenY + 45);
- optionBox[0].setDimensions(fontHeight, 150);
+ optionBox[0].setDimensions(150, fontHeight);
optionBox[0].addOption("Old");
optionBox[0].addOption("New");
optionBox[1].setScreenPos(screenX + 290, screenY + 75);
- optionBox[1].setDimensions(fontHeight, 150);
+ optionBox[1].setDimensions(150, fontHeight);
optionBox[1].addOption("RGB+composite");
optionBox[1].addOption("S-Video");
optionBox[2].setScreenPos(screenX + 290, screenY + 105);
- optionBox[2].setDimensions(fontHeight, 150);
+ optionBox[2].setDimensions(150, fontHeight);
optionBox[2].addOption("On");
optionBox[2].addOption("Off");
optionBox[2].addOption("Last state");
#include "vradiolive.h"
-VRadioLive::VRadioLive(List* tchanList)
+VRadioLive::VRadioLive(ChannelList* tchanList)
{
player = new PlayerRadio();
player->init();
player->stop();
vdr->stopStreaming();
upChannel();
- vdr->streamChannel(currentChannel);
+ vdr->streamChannel((*chanList)[currentChannel]->number);
player->play();
return 2;
}
player->stop();
vdr->stopStreaming();
downChannel();
- vdr->streamChannel(currentChannel);
+ vdr->streamChannel((*chanList)[currentChannel]->number);
player->play();
return 2;
}
return 1;
}
-void VRadioLive::setChannel(int number)
+void VRadioLive::setChannel(UINT number)
{
- currentChannel = number;
- vdr->streamChannel(currentChannel);
+ currentChannel = channelIndexFromNumber(number);
+ vdr->streamChannel((*chanList)[currentChannel]->number);
player->play();
}
void VRadioLive::upChannel()
{
- Channel* channel;
- for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
- {
- if (channel->number == currentChannel)
- {
- chanList->next();
- channel = (Channel*)chanList->getCurrent();
- if (!channel) return;
- currentChannel = channel->number;
- }
- }
+ if (currentChannel == (chanList->size() - 1)) return; // at the end
+
+ ++currentChannel;
}
void VRadioLive::downChannel()
{
- Channel* channel;
- Channel* prevChannel = NULL;
- for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
+ if (currentChannel == 0) return; // at the start
+
+ --currentChannel;
+}
+
+UINT VRadioLive::channelIndexFromNumber(int number)
+{
+ for(UINT i = 0; i < chanList->size(); i++)
{
- if (channel->number == currentChannel)
- {
- if (!prevChannel) return;
- currentChannel = prevChannel->number;
- }
- prevChannel = channel;
+ if ((*chanList)[i]->number == (UINT)number) return i;
}
+ return 0;
}
+
#define VRADIOLIVE_H
#include <stdio.h>
+#include <vector>
#include "view.h"
#include "playerradio.h"
#include "vdr.h"
-#include "list.h"
#include "channel.h"
#include "viewman.h"
#include "remote.h"
class VRadioLive : public View
{
public:
- VRadioLive(List* chanList);
+ VRadioLive(ChannelList* chanList);
~VRadioLive();
void draw();
int handleCommand(int command);
- void setChannel(int number);
+ void setChannel(UINT number);
private:
VDR* vdr;
PlayerRadio* player;
- List* chanList;
- ULONG currentChannel;
+ ChannelList* chanList;
+ UINT currentChannel;
void upChannel();
void downChannel();
+ UINT channelIndexFromNumber(int number);
};
#endif
setScreenPos(70, 35);
}
- setDimensions(420, 570);
+ setDimensions(570, 420);
setBackgroundColour(Colour::VIEWBACKGROUND);
setTitleBarOn(1);
setTitleBarColour(Colour::TITLEBARBACKGROUND);
sl.setScreenPos(screenX + 10, screenY + 30 + 5);
- sl.setDimensions(height - 30 - 15 - 30, width - 20);
+ sl.setDimensions(width - 20, height - 30 - 15 - 30);
}
VRecordingList::~VRecordingList()
struct tm* btime;
Directory* dir;
- recDir->dirList->reset();
- while((dir = (Directory*)recDir->dirList->getCurrent()))
+ for (DirectoryList::iterator i = recDir->dirList.begin(); i != recDir->dirList.end(); i++)
{
+ dir = *i;
if (dir->getNumRecordings() == 0)
{
- recDir->dirList->remove(dir);
+ recDir->dirList.erase(i);
continue;
}
dir->index = sl.addOption(tempA, first);
first = 0;
-
- recDir->dirList->next();
}
- // temp FIXME
- List* recList = recDir->recList;
-
// FIXME convert the whole program to time_t's
Recording* rec;
- recList->reset();
- while((rec = (Recording*)recList->getCurrent()))
+ for (UINT i = 0; i < recDir->recList.size(); i++)
{
+ rec = recDir->recList[i];
btime = localtime((time_t*)&rec->start);
strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime);
sprintf(tempB, "%s\t%s", tempA, rec->getProgName());
rec->index = sl.addOption(tempB, first);
first = 0;
- recList->next();
}
dataInvalid = 0;
char freeSpace[50];
int gigFree = Directory::freeSpace / 1024;
- snprintf(freeSpace, 49, "%lu%%, %iGB free", Directory::usedPercent, gigFree);
+ snprintf(freeSpace, 49, "%lu%% used, %iGB free", Directory::usedPercent, gigFree);
drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT);
}
sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
Box b;
b.setScreenPos(screenX + 220, screenY + 385);
- b.setDimensions(25, 160);
+ b.setDimensions(160, 25);
b.fillColour(Colour::VIEWBACKGROUND);
b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
}
saveIndex = toDelete->index;
saveTop = sl.getTopOption();
Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s\n", toDelete->index, toDelete->getProgName(), toDelete->fileName);
- recDir->recList->remove(toDelete);
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "I have removed: %s %s\n", toDelete->getProgName(), toDelete->fileName);
+
+ for(RecordingList::iterator i = recDir->recList.begin(); i != recDir->recList.end(); i++)
+ {
+ if (*i == toDelete)
+ {
+ recDir->recList.erase(i);
+ Log::getInstance()->log("VRecordingList", Log::DEBUG, "Removed from vector: %s %s\n", toDelete->getProgName(), toDelete->fileName);
+ break;
+ }
+ }
VDR* vdr = VDR::getInstance();
vdr->deleteRecording(toDelete->fileName);
Recording* VRecordingList::getCurrentOptionRecording()
{
Recording* current;
- for(recDir->recList->reset(); (current = (Recording*)recDir->recList->getCurrent()); recDir->recList->next())
+ for (UINT i = 0; i < recDir->recList.size(); i++)
{
+ current = recDir->recList[i];
if (current->index == sl.getCurrentOption()) return current;
}
return NULL;
// Check to see if it is a sub directory
Directory* curDir;
- for(recDir->dirList->reset(); (curDir = (Directory*)recDir->dirList->getCurrent()); recDir->dirList->next())
+ for(UINT i = 0; i < recDir->dirList.size(); i++)
{
+ curDir = recDir->dirList[i];
if (curDir->index == sl.getCurrentOption())
{
VRecordingList* sub = new VRecordingList(this);
}
// check to see if it's a recording
- Recording* current;
- for(recDir->recList->reset(); (current = (Recording*)recDir->recList->getCurrent()); recDir->recList->next())
+ Recording* current = getCurrentOptionRecording();
+ if (current)
{
- if (current->index == sl.getCurrentOption())
- {
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->fileName);
-
- VRecordingMenu* v = new VRecordingMenu();
- v->setParent(this);
- v->setRecording(current);
- ViewMan::getInstance()->addNoLock(v);
- v->draw();
- v->show();
- return 2;
- }
+ Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->fileName);
+
+ VRecordingMenu* v = new VRecordingMenu();
+ v->setParent(this);
+ v->setRecording(current);
+ ViewMan::getInstance()->addNoLock(v);
+ v->draw();
+ v->show();
+ return 2;
}
// should not get to here
return 1;
#include <stdio.h>
#include <string.h>
+#include <vector>
#include "view.h"
-#include "list.h"
#include "directory.h"
#include "recording.h"
#include "wselectlist.h"
setScreenPos(250, 160);
}
- setDimensions(140, 200);
+ setDimensions(200, 140);
setBackgroundColour(Colour::VIEWBACKGROUND);
setTitleBarOn(1);
setTitleBarColour(Colour::TITLEBARBACKGROUND);
sl.setScreenPos(screenX + 10, screenY + 30 + 5);
- sl.setDimensions(height - 30 - 15, width - 20);
+ sl.setDimensions(width - 20, height - 30 - 15);
sl.addOption("Play", 1);
sl.addOption("Resume", 0);
sl.addOption("Summary", 0);
{
vi->setScreenPos(110, 90);
}
- vi->setDimensions(300, 490);
+ vi->setDimensions(490, 300);
ViewMan::getInstance()->addNoLock(vi);
vi->draw();
{
v->setScreenPos(220, 140);
}
- v->setDimensions(180, 260);
+ v->setDimensions(260, 180);
ViewMan::getInstance()->addNoLock(v);
v->draw();
{
setScreenPos(210, 150);
}
- setDimensions(200, 300);
+ setDimensions(300, 200);
setBackgroundColour(Colour::VIEWBACKGROUND);
setTitleBarOn(1);
setTitleBarColour(Colour::TITLEBARBACKGROUND);
setTitleText("Choose a VDR server");
- sl.setScreenPos(screenX + 10, screenY + 30 + 5);
- sl.setDimensions(height - 30 - 15, width - 20);
+ sl.setScreenPos(screenY + 30 + 5, screenX + 10);
+ sl.setDimensions(width - 20, height - 30 - 15);
sl.addOption((*serverIPs)[0], 1);
for(UINT k = 1; k < serverIPs->size(); k++)
#include "vvideolive.h"
-VVideoLive::VVideoLive(List* tchanList, ULONG tstreamType)
+VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType)
{
vdr = VDR::getInstance();
viewman = ViewMan::getInstance();
chanList = tchanList;
- currentChannel = NULL;
+ currentChannel = 0;
unavailable = 0;
unavailableView = NULL;
streamType = tstreamType;
player->init();
Video* video = Video::getInstance();
- setDimensions(video->getScreenHeight(), video->getScreenWidth());
+ setDimensions(video->getScreenWidth(), video->getScreenHeight());
Colour transparent(0, 0, 0, 0);
setBackgroundColour(transparent);
}
return 4;
}
case Remote::DF_UP:
- case Remote::UP:
+ case Remote::CHANNELUP:
{
if (unavailable) showUnavailable(0);
else stop();
return 2;
}
case Remote::DF_DOWN:
- case Remote::DOWN:
+ case Remote::CHANNELDOWN:
{
if (unavailable) showUnavailable(0);
else stop();
}
case Remote::OK:
{
- if (!unavailable) doBanner();
+ doBanner();
return 2;
}
if (m->message == Message::CHANNEL_CHANGE)
{
// check channel number is valid
- currentChannel = channelFromNumber(m->parameter);
- if (!currentChannel) return; // this should never happen
+ currentChannel = channelIndexFromNumber(m->parameter);
if (unavailable) showUnavailable(0);
else stop();
play();
}
+ else if (m->message == Message::CHANNEL_UP)
+ {
+ // from vlivebanner
+ if (unavailable) showUnavailable(0);
+ else stop(1);
+ upChannel();
+ play(1);
+ vlb->setChannel((*chanList)[currentChannel]);
+ vlb->draw();
+ vlb->show();
+ }
+ else if (m->message == Message::CHANNEL_DOWN)
+ {
+ // from vlivebanner
+ if (unavailable) showUnavailable(0);
+ else stop(1);
+ downChannel();
+ play(1);
+ vlb->setChannel((*chanList)[currentChannel]);
+ vlb->draw();
+ vlb->show();
+ }
+
}
void VVideoLive::doBanner()
{
- VLiveBanner* v = new VLiveBanner(currentChannel);
- viewman->timedDelete(v, 4, 0);
+ vlb = new VLiveBanner(this, (*chanList)[currentChannel]);
+ viewman->timedDelete(vlb, 4, 0);
Message* m = new Message();
m->from = this;
m->to = viewman;
m->message = Message::ADD_VIEW;
- m->parameter = (ULONG)v;
+ m->parameter = (ULONG)vlb;
viewman->postMessage(m);
}
unavailable = 1;
unavailableView = new VInfo();
- unavailableView->setDimensions(200, 400);
+ unavailableView->setDimensions(400, 200);
if (Video::getInstance()->getFormat() == Video::PAL)
{
unavailableView->setScreenPos(170, 200);
{
unavailableView->setScreenPos(160, 150);
}
- unavailableView->setTitleText(currentChannel->name);
+ unavailableView->setTitleText((*chanList)[currentChannel]->name);
unavailableView->setMainText("\n Channel unavailable");
unavailableView->setDropThrough();
void VVideoLive::setChannel(int number)
{
- currentChannel = channelFromNumber(number);
- if (!currentChannel) return; // should never happen
+ currentChannel = channelIndexFromNumber(number);
play();
}
-void VVideoLive::play()
+void VVideoLive::play(int noShowVLB)
{
showUnavailable(0);
- int available = vdr->streamChannel(currentChannel->number);
+ int available = vdr->streamChannel((*chanList)[currentChannel]->number);
if (!available)
{
showUnavailable(1);
+ if (!noShowVLB) doBanner();
}
else
{
- doBanner();
+ if (!noShowVLB) doBanner();
player->play();
}
}
-void VVideoLive::stop()
+void VVideoLive::stop(int noRemoveVLB)
{
if (unavailable) return;
+ if (!noRemoveVLB) viewman->removeView(vlb, 1, 1); // if live banner is present, remove it. won't cause damage if its not present
+
player->stop();
vdr->stopStreaming();
}
-void VVideoLive::upChannel()
+int VVideoLive::upChannel()
{
- Channel* channel;
- for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
- {
- if (channel == currentChannel)
- {
- chanList->next();
- channel = (Channel*)chanList->getCurrent();
- if (!channel) return;
- currentChannel = channel;
- }
- }
+ if (currentChannel == (chanList->size() - 1)) return 0; // at the end
+
+ ++currentChannel;
+ return 1;
}
-void VVideoLive::downChannel()
+int VVideoLive::downChannel()
{
- Channel* channel;
- Channel* prevChannel = NULL;
- for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
- {
- if (channel == currentChannel)
- {
- if (!prevChannel) return;
- currentChannel = prevChannel;
- }
- prevChannel = channel;
- }
+ if (currentChannel == 0) return 0; // at the start
+
+ --currentChannel;
+ return 1;
}
-Channel* VVideoLive::channelFromNumber(int number)
+UINT VVideoLive::channelIndexFromNumber(int number)
{
- Channel* channel;
- for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
+ for(UINT i = 0; i < chanList->size(); i++)
{
- if (channel->number == (UINT)number) return channel;
+ if ((*chanList)[i]->number == (UINT)number) return i;
}
- return NULL;
+ return 0;
}
#define VVIDEOLIVE_H
#include <stdio.h>
+#include <vector>
#include "view.h"
#include "playervideo.h"
#include "playerradio.h"
#include "vdr.h"
-#include "list.h"
#include "channel.h"
#include "vlivebanner.h"
#include "viewman.h"
class VVideoLive : public View
{
public:
- VVideoLive(List* chanList, ULONG streamType);
+ VVideoLive(ChannelList* chanList, ULONG streamType);
~VVideoLive();
void draw();
int handleCommand(int command);
void setChannel(int number);
- void play();
- void stop();
+ void play(int noShowVLB = 0);
+ void stop(int noRemoveVLB = 0);
private:
ViewMan* viewman;
VDR* vdr;
Player* player;
- List* chanList;
- Channel* currentChannel;
+ ChannelList* chanList;
+ UINT currentChannel;
int unavailable;
VInfo* unavailableView;
ULONG streamType;
+ VLiveBanner* vlb;
- void upChannel();
- void downChannel();
+ int upChannel();
+ int downChannel();
void doBanner();
void showUnavailable(int active);
- Channel* channelFromNumber(int number);
+ UINT channelIndexFromNumber(int number);
};
#endif
myRec = rec;
Video* video = Video::getInstance();
- setDimensions(video->getScreenHeight(), video->getScreenWidth());
+ setDimensions(video->getScreenWidth(), video->getScreenHeight());
Colour transparent(0, 0, 0, 0);
setBackgroundColour(transparent);
}
setScreenPos(90, 400);
}
- setDimensions(31, 227);
+ setDimensions(227, 31);
setBackgroundColour(Colour::VIEWBACKGROUND);
}
jpeg.init(name);
Video* video = Video::getInstance();
- setDimensions(video->getScreenHeight(), video->getScreenWidth());
+ setDimensions(video->getScreenWidth(), video->getScreenHeight());
// Now override the surface pointer found in Box to a seperate wallpaper surface
// but only for the wjpeg, not for this object
VWelcome::VWelcome()
{
- setDimensions(200, 460);
+ setDimensions(460, 200);
if (Video::getInstance()->getFormat() == Video::PAL)
{
setTitleText("Welcome");
sl.setScreenPos(screenX + 20, screenY + 40);
- sl.setDimensions(140, 170);
+ sl.setDimensions(170, 140);
sl.addOption("1. Live TV", 1);
sl.addOption("2. Radio", 0);
void VWelcome::doChannelsList()
{
- List* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
+ ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
if (chanList)
{
void VWelcome::doRadioList()
{
- List* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
+ ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
if (chanList)
{
ViewMan* viewman = ViewMan::getInstance();
VInfo* viewWait = new VInfo();
- viewWait->setDimensions(190, 460);
+ viewWait->setDimensions(460, 190);
if (Video::getInstance()->getFormat() == Video::PAL)
{
viewWait->setScreenPos(140, 170);
WButton::WButton()
{
int fontHeight = surface->getFontHeight();
- setDimensions(fontHeight, 70);
+ setDimensions(70, fontHeight);
mytext = NULL;
active = 0;
logger->log("BJpeg", Log::DEBUG, "JPEG startup done");
// Init the surface
- setDimensions(cinfo.output_height, cinfo.output_width);
+ setDimensions(cinfo.output_width, cinfo.output_height);
// MAKE THE 2D ARRAY
topOption = 0;
numOptionsDisplayable = 0;
numColumns = 0;
+ noLoop = 0;
}
WSelectList::~WSelectList()
numColumns = 0;
}
+void WSelectList::setNoLoop()
+{
+ noLoop = 1;
+}
+
void WSelectList::hintSetCurrent(int index)
{
selectedOption = index;
numOptionsDisplayable = (height - 5) / ySeperation;
if (selectedOption == (topOption + numOptionsDisplayable)) topOption++;
- if (selectedOption == (topOption - 1)) topOption--;
+ if (selectedOption == ((UINT)topOption - 1)) topOption--;
// if still not visible...
- if ((selectedOption < topOption) || (selectedOption > (topOption + numOptionsDisplayable)))
+ if ((selectedOption < (UINT)topOption) || (selectedOption > (topOption + numOptionsDisplayable)))
{
topOption = selectedOption - (numOptionsDisplayable / 2);
}
}
else
{
- selectedOption = options.size() - 1;
+ if (!noLoop) selectedOption = options.size() - 1;
}
}
}
else
{
- selectedOption = 0;
+ if (!noLoop) selectedOption = 0;
}
}
void clear();
void addColumn(int x);
+ void setNoLoop();
int addOption(char* text, int selected);
void draw();
vector<char*> options;
UINT selectedOption;
- UINT topOption;
+ int topOption;
UINT numOptionsDisplayable;
int columns[10];
int numColumns;
+ int noLoop;
};