return 0;
}
+ logger->log("Command", Log::DEBUG, "%p", this);
+
return 1;
}
handleCommand(Remote::STOP); // an odd way of doing it, but so simple
break;
}
+ case Message::STREAM_END:
+ {
+ // post a message to ViewMan and then run the viewman message queue
+ Message* m = new Message();
+ m->message = Message::STREAM_END;
+ m->to = VVideoLive::getInstance();
+ viewman->postMessage(m);
+ handleCommand(Remote::NA_NONE);
+ break;
+ }
case Message::VDR_CONNECTED:
{
doJustConnected((VConnect*)m->from);
if (instance) return;
instance = this;
initted = 0;
+ callback = NULL;
}
Demuxer::~Demuxer()
return instance;
}
-int Demuxer::init()
+int Demuxer::init(Callback* tcallback)
{
if (!initted)
{
reset();
initted = 1;
+ callback = tcallback;
return 1;
}
video_current = audio_current = -1;
horizontal_size = vertical_size = 0;
aspect_ratio = (enum AspectRatio) 0;
- frame_rate = bit_rate = 0;
+ cbAspectRatio = frame_rate = bit_rate = 0;
}
int Demuxer::shutdown()
video_current = id;
}
+void Demuxer::setAspectRatio()
+{
+ if (aspect_ratio != cbAspectRatio)
+ {
+ cbAspectRatio = aspect_ratio;
+ callback->call(this);
+ }
+}
+
+int Demuxer::getAspectRatio()
+{
+ return aspect_ratio;
+}
+
int Demuxer::scan(UCHAR *buf, int len)
{
// Temporarily, just look for the lowest audio stream and return it
seeking = 0;
buf += 8; // Minimum length of sequence header
len -= 8;
+ setAspectRatio();
break;
case 0xb8: // Group header
// We're not going to bother parsing anything.
#include "stream.h"
#include "log.h"
#include "defines.h"
+#include "callback.h"
class Demuxer
{
Demuxer();
~Demuxer();
static Demuxer* getInstance();
- int init();
+ int init(Callback* callback);
void reset();
void flush();
void flushAudio();
int scan(UCHAR* buf, int len);
int put(UCHAR* buf, int len);
+ int getAspectRatio();
+
+ enum AspectRatio
+ {
+ ASPECT_4_3 = 2,
+ ASPECT_16_9 = 3
+ };
+
private:
static Demuxer* instance;
Stream videostream;
int seeking;
UCHAR* inbuf;
+ void setAspectRatio();
+ Callback* callback;
+
int video_current, audio_current;
int state_frametype, state_framepos;
int state_stream_fill, state_vid_parsed;
FRAMETYPE_VIDMAX = FRAMETYPE_VID15
};
- enum AspectRatio
- {
- ASPECT_4_3 = 2,
- ASPECT_16_9 = 3
- };
-
int horizontal_size;
int vertical_size;
enum AspectRatio aspect_ratio;
int frame_rate;
int bit_rate;
+
+ int cbAspectRatio;
};
#endif
const static ULONG ADD_VIEW = 14;
const static ULONG CHANNEL_UP = 15;
const static ULONG CHANNEL_DOWN = 16;
+ const static ULONG STREAM_END = 17;
};
#endif
video = Video::getInstance();
- if (!demuxer.init())
+ if (!demuxer.init(this))
{
Log::getInstance()->log("Player", Log::ERR, "Demuxer failed to init");
shutdown();
void PlayerVideo::call(void* caller)
{
- threadSignalNoLock();
+ if (caller == &demuxer)
+ {
+ Log* temp = Log::getInstance();
+ temp->log("Player", Log::DEBUG, "Callback from demuxer");
+ if (video->getAspectRatio() == Video::ASPECT16X9)
+ {
+ temp->log("Player", Log::DEBUG, "TV is 16:9, so will try to do a switch");
+
+ int dxCurrentAspect = demuxer.getAspectRatio();
+ if (dxCurrentAspect == Demuxer::ASPECT_4_3)
+ {
+ temp->log("Player", Log::DEBUG, "Demuxer said video is 4:3 aspect, switching TV");
+ video->setMode(Video::LETTERBOX); // swap these lines over
+ }
+ else if (dxCurrentAspect == Demuxer::ASPECT_16_9)
+ {
+ temp->log("Player", Log::DEBUG, "Demuxer said video is 16:9 aspect, switching TV");
+ video->setMode(Video::NORMAL); // if these are the wrong way around
+ }
+ else
+ {
+ temp->log("Player", Log::DEBUG, "Demuxer said video is something else... ignoring");
+ }
+ }
+ }
+ else
+ {
+ threadSignalNoLock();
+ }
}
// Feed thread
// end of recording
Log::getInstance()->log("Player", Log::DEBUG, "Recording playback ends");
Message* m = new Message();
- m->message = Message::STOP_PLAYBACK;
- Log::getInstance()->log("Player", Log::DEBUG, "Posting message...");
+ if (streamLength) m->message = Message::STOP_PLAYBACK; // recording
+ else m->message = Message::STREAM_END; // live
+ Log::getInstance()->log("Player", Log::DEBUG, "Posting message to %p...", commandMessageQueue);
commandMessageQueue->postMessage(m);
Log::getInstance()->log("Player", Log::DEBUG, "Message posted...");
}
&& (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
mode = tmode;
-// mode = LETTERBOX;
+ if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
-// if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
-
- int a = ioctl(fdVideo, AV_SET_VID_MODE, mode);
- printf("Mode requested: %i, result: %i\n", mode, a);
+// int a = ioctl(fdVideo, AV_SET_VID_MODE, mode);
+// printf("Mode requested: %i, result: %i\n", mode, a);
return 1;
}
{
return screenHeight;
}
+
+UCHAR Video::getAspectRatio()
+{
+ return aspectRatio;
+}
int setFormat(UCHAR format);
int setConnection(UCHAR connection);
int setAspectRatio(UCHAR aspectRatio);
+ UCHAR getAspectRatio();
int setMode(UCHAR mode);
int setSource();
int setPosition(int x, int y);
int retVal2 = 0;
int i;
- // handle command return values
- // 0 - drop through to next view
- // 1 - dont drop to next view, but not handled
- // 2 - handled - stop command here
- // 4 - handled - delete this view
-
- for (i=topView; i>0; i--)
+ if (command != Remote::NA_NONE)
{
- retVal = views[i]->handleCommand(command);
- if (retVal == 1)
- {
- // not handled but don't give to any more views
- pthread_mutex_unlock(&viewManLock);
- return 0;
- }
- if (retVal == 2)
+ // handle command return values
+ // 0 - drop through to next view
+ // 1 - dont drop to next view, but not handled
+ // 2 - handled - stop command here
+ // 4 - handled - delete this view
+
+ for (i=topView; i>0; i--)
{
- // command handled
- if (views[i]->seconds)
+ retVal = views[i]->handleCommand(command);
+ if (retVal == 1)
{
- struct timespec currentTime;
- clock_gettime(CLOCK_REALTIME, ¤tTime);
- views[i]->delSec = currentTime.tv_sec + views[i]->seconds;
- views[i]->delNSec = currentTime.tv_nsec;
- resetThread();
+ // not handled but don't give to any more views
+ pthread_mutex_unlock(&viewManLock);
+ return 0;
+ }
+
+ if (retVal == 2)
+ {
+ // command handled
+ if (views[i]->seconds)
+ {
+ struct timespec currentTime;
+ clock_gettime(CLOCK_REALTIME, ¤tTime);
+ views[i]->delSec = currentTime.tv_sec + views[i]->seconds;
+ views[i]->delNSec = currentTime.tv_nsec;
+ resetThread();
+ }
+ pthread_mutex_unlock(&viewManLock);
+ retVal2 = 1;
+ break;
+ }
+ else if (retVal == 4)
+ {
+ // removeNoLock(views[i]);
+ // Box::showAll();
+ // resetThread();
+ removeView(views[i], 1);
+ pthread_mutex_unlock(&viewManLock);
+ retVal2 = 1;
+ break;
}
- pthread_mutex_unlock(&viewManLock);
- retVal2 = 1;
- break;
- }
- else if (retVal == 4)
- {
-// removeNoLock(views[i]);
-// Box::showAll();
-// resetThread();
- removeView(views[i], 1);
- pthread_mutex_unlock(&viewManLock);
- retVal2 = 1;
- break;
}
}
+ else
+ {
+ // fake the return code
+ retVal2 = 2;
+ }
Log::getInstance()->log("ViewMan", Log::DEBUG, "out of handlecommand code, now on to messages");
#include "view.h"
#include "message.h"
#include "messagequeue.h"
+#include "remote.h"
class ViewMan : public MessageQueue
{
#include "vvideolive.h"
+VVideoLive* VVideoLive::instance = NULL;
+
VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType)
{
+ instance = this;
vdr = VDR::getInstance();
viewman = ViewMan::getInstance();
chanList = tchanList;
streamType = tstreamType;
if (streamType == VDR::VIDEO)
{
- player = new PlayerVideo(NULL, 0);
+ player = new PlayerVideo(Command::getInstance(), 0);
}
else
{
VVideoLive::~VVideoLive()
{
delete player;
+ instance = NULL;
+}
+
+VVideoLive* VVideoLive::getInstance()
+{
+ return instance;
}
void VVideoLive::draw()
vlb->draw();
vlb->show();
}
-
+ else if (m->message == Message::STREAM_END)
+ {
+ Log::getInstance()->log("VVideoLive", Log::DEBUG, "streamEnd");
+ stop();
+ play(1);
+ }
}
void VVideoLive::doBanner()
#include "colour.h"
#include "osd.h"
#include "vinfo.h"
+#include "command.h"
class VVideoLive : public View
{
public:
VVideoLive(ChannelList* chanList, ULONG streamType);
~VVideoLive();
+ static VVideoLive* getInstance();
void draw();
int handleCommand(int command);
void processMessage(Message* m);
void stop(int noRemoveVLB = 0);
private:
+ static VVideoLive* instance;
ViewMan* viewman;
VDR* vdr;
Player* player;