]> git.vomp.tv Git - vompclient.git/commitdiff
Widescreen version 2...
authorChris Tallon <chris@vomp.tv>
Sat, 10 Sep 2005 16:42:04 +0000 (16:42 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 10 Sep 2005 16:42:04 +0000 (16:42 +0000)
command.cc
playervideo.cc
playervideo.h
video.cc
video.h
voptions.cc
vvideolive.cc
vvideorec.cc

index bc00eb8fdae44f5205bc38f26f1afdf430254bad..26932f6530e15f9e46cf0109796b117643dc4bff 100644 (file)
@@ -385,23 +385,21 @@ void Command::doJustConnected(VConnect* vconnect)
   {
     if (!strcasecmp(aspect, "16:9"))
     {
-      logger->log("Command", Log::INFO, "Switching to TV aspect 16:9");
-      video->setAspectRatio(Video::ASPECT16X9);
+      logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
+      video->setTVsize(Video::ASPECT16X9);
     }
     else
     {
-      logger->log("Command", Log::INFO, "Switching to TV aspect 4:3");
-      video->setAspectRatio(Video::ASPECT4X3);
+      logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
+      video->setTVsize(Video::ASPECT4X3);
     }
   }
   else
   {
     logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
-    video->setAspectRatio(Video::ASPECT4X3);
+    video->setTVsize(Video::ASPECT4X3);
   }
 
-  video->reinit();
-
   // config done
 
   viewman->removeView(vi);
index aadf76ee41d8c5503072ee6ee6f1cba6630ea1d1..999e8d0ef0292d1df4e0f29de25d83a460d8f601 100644 (file)
@@ -216,15 +216,26 @@ void PlayerVideo::stop()
   playing = 0;
   paused = 0;
 
+  Log* templog = Log::getInstance();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 1");
   threadStop();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 2");
   video->stop();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 3");
   video->blank();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 4");
   audio->stop();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 5");
   audio->unPause();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 6");
   vfeed.stop();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 7");
   afeed.stop();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 8");
   video->reset();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 9");
   demuxer.reset();
+  templog->log("PlayerVideo", Log::DEBUG, "Temp 10");
 
   feedPosition = 0;
 }
@@ -254,7 +265,6 @@ void PlayerVideo::togglePause()
 #ifdef DEV
 void PlayerVideo::test()
 {
-  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST");
 
 /*
 
@@ -272,13 +282,41 @@ void PlayerVideo::test()
 
   printf("A = %i\n", a);
 */
+
+  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 1 4X3");
+  video->setAspectRatio(Video::ASPECT4X3);
 }
 
 void PlayerVideo::test2()
 {
-  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST");
+  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 2 16X9");
+  video->setAspectRatio(Video::ASPECT16X9);
+}
+
+void PlayerVideo::test3()
+{
+  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 3 NORMAL");
+  video->setMode(Video::NORMAL);
+}
+
+void PlayerVideo::test4()
+{
+  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 4 LETTERBOX");
+  video->setMode(Video::LETTERBOX);
+}
+
+void PlayerVideo::test5()
+{
+  Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 5 REINIT");
+
+  video->stop();
+//  video->reset();
+  vfeed.stop();
+//  video->reinit();
+  vfeed.start();
+  video->play();
+  video->sync();
 
-//  video->test2();
 }
 #endif
 
@@ -494,26 +532,23 @@ void PlayerVideo::call(void* caller)
   {
     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");
-      }
+    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->setAspectRatio(Video::ASPECT4X3);
+    }
+    else if (dxCurrentAspect == Demuxer::ASPECT_16_9)
+    {
+      temp->log("Player", Log::DEBUG, "Demuxer said video is 16:9 aspect, switching TV");
+      video->setAspectRatio(Video::ASPECT16X9);
     }
+    else
+    {
+      temp->log("Player", Log::DEBUG, "Demuxer said video is something else... ignoring");
+    }
+
   }
   else
   {
index 28963f94635ac0cd174c65fee76cd2e8f3da1eb0..6cb0f5ffdc6ab92e14acdcc6cf23a17cda286ae2 100644 (file)
@@ -59,6 +59,9 @@ class PlayerVideo : public Player
 #ifdef DEV
     void test();
     void test2();
+    void test3();
+    void test4();
+    void test5();
 #endif
 
     void threadMethod();
index 32d0fa91248b2f5c7a1090dcadda772a236c819b..acb21614c111eb2998e7db1ea1187f321909ed60 100644 (file)
--- a/video.cc
+++ b/video.cc
@@ -34,6 +34,7 @@ Video::Video()
   connection = 0;
   aspectRatio = 0;
   mode = 0;
+  tvsize = 0;
 
   screenWidth = 0;
   screenHeight = 0;
@@ -58,26 +59,41 @@ int Video::init(UCHAR tformat)
 
   if (!setFormat(tformat))           { shutdown(); return 0; }
   if (!setConnection(COMPOSITERGB))  { shutdown(); return 0; }
-  if (!setMode(NORMAL))              { shutdown(); return 0; }
   if (!setAspectRatio(ASPECT4X3))    { shutdown(); return 0; }
+  if (!setMode(NORMAL))              { shutdown(); return 0; }
   if (!setSource())                  { shutdown(); return 0; }
   if (!attachFrameBuffer())          { shutdown(); return 0; }
 
+  setTVsize(ASPECT4X3);
+
   stop();
 
   return 1;
 }
 
-int Video::reinit()
+int Video::setTVsize(UCHAR ttvsize)
 {
+  tvsize = ttvsize;
+
+  // Override the aspect ratio usage, temporarily use to set the video chip mode
+  if (!setAspectRatio(tvsize))       { shutdown(); return 0; }
   close(fdVideo);
   if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0;
   if (!setSource())                  { shutdown(); return 0; }
   if (!attachFrameBuffer())          { shutdown(); return 0; }
 
+  // Reopening the fd causes the scart aspect line to go back to 4:3
+  // Set this again to the same as the tv screen size
+  if (!setAspectRatio(tvsize))       { shutdown(); return 0; }
+
   return 1;
 }
 
+int Video::setDefaultAspect()
+{
+  return setAspectRatio(tvsize);
+}
+
 int Video::shutdown()
 {
   if (!initted) return 0;
@@ -141,6 +157,7 @@ int Video::setAspectRatio(UCHAR taspectRatio)
   aspectRatio = taspectRatio;
 
   if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0;
+//  if (!setMode(mode)) return 0;
   return 1;
 }
 
@@ -344,7 +361,9 @@ UINT Video::getScreenHeight()
   return screenHeight;
 }
 
-UCHAR Video::getAspectRatio()
+/*
+UCHAR Video::getTVsize()
 {
-  return aspectRatio;
+  return ;
 }
+*/
diff --git a/video.h b/video.h
index 4ab987e3f425ba0841fdfbde87cd9c97575eed0a..bf69200099e9e56bd38253bbd5a875fc4a4eb576 100644 (file)
--- a/video.h
+++ b/video.h
@@ -42,7 +42,6 @@ class Video
     static Video* getInstance();
 
     int init(UCHAR format);
-    int reinit(); // for aspect change
     int shutdown();
 
     // Video formats - AV_SET_VID_DISP_FMT
@@ -59,18 +58,28 @@ class Video
 
     // Video modes - AV_SET_VID_MODE
     const static UCHAR NORMAL = 0;
-      // if aspect==4:3 && source==4:3, output==correct-4:3
-      // if aspect==4:3 && source==16:9, output==chop sides
-      // if aspect==16:9 && source==4:3, output==not tested, unknown
-      // if aspect==16:9 && source==16:9, output==stretch middle over all screen
     const static UCHAR LETTERBOX = 1;
-      // if aspect==4:3 && source==4:3, output==not tested, unknown
-      // if aspect==4:3 && source==16:9, output==16:9 letterbox at top of screen
-      // if aspect==16:9 && source==4:3, output==not tested, unknown
-      // if aspect==16:9 && source==16:9 output==
+/*
+    Actual Source Aspect      Aspect IOCTL       Mode IOCTL       MODE A            MODE B
+
+          4:3                     4:3             NORMAL          fullframe43       fullframe43
+          4:3                     16:9            NORMAL          fullframe43       fullframe43
+          4:3                     4:3             LETTERBOX       fullframe43       fullframe43
+          4:3                     16:9            LETTERBOX       fullframe43       fullframe43
+          16:9                    4:3             NORMAL          chop sides        fullframe169
+          16:9                    16:9            NORMAL          chop sides        fullframe169
+          16:9                    4:3             LETTERBOX       letterbox         letterbox
+          16:9                    16:9            LETTERBOX       chop sides        fullframe169
+
+    Conclusions
+
+    1. There are two chip modes - accessible by reopening the fd
+    2. The video chip knows the aspect ratio purely from the incoming MPEG
+
+    To switch to MODE A, set the aspect ioctl to 4:3 and reopen the FD.
+    To switch to MODE B, set the aspect ioctl to 16:9 and reopen the FD.
+*/
 
-    // If aspect==4:3, 4:3 unknown / 16:9 letterbox at top of screen (!!)
-                                      // If aspect==16:9, 4:3 unknown / 16:9 proper 16:9 mode
     const static UCHAR UNKNOWN2 = 2;
     const static UCHAR QUARTER = 3;
     const static UCHAR EIGHTH = 4;
@@ -79,8 +88,10 @@ class Video
 
     int setFormat(UCHAR format);
     int setConnection(UCHAR connection);
-    int setAspectRatio(UCHAR aspectRatio);
-    UCHAR getAspectRatio();
+    int setAspectRatio(UCHAR aspectRatio);   // This one does the pin 8 scart widescreen switching
+//    UCHAR getAspectRatio();
+    int setTVsize(UCHAR size);
+    int setDefaultAspect();
     int setMode(UCHAR mode);
     int setSource();
     int setPosition(int x, int y);
@@ -116,6 +127,7 @@ class Video
 
     int fdVideo;
 
+    UCHAR tvsize;
     UCHAR format;
     UCHAR connection;
     UCHAR aspectRatio;
index eacc6c3e1fec23a6bf3f224af5708b84a58895a7..0227d896cb5275e6837f841b8af66ae51a3a4279 100644 (file)
@@ -280,16 +280,21 @@ void VOptions::doSave()
   else
     Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
 
+  Video* video = Video::getInstance();
 
   if (!strcmp(tvconnection, "S-Video"))
-    Video::getInstance()->setConnection(Video::SVIDEO);
+    video->setConnection(Video::SVIDEO);
   else
-    Video::getInstance()->setConnection(Video::COMPOSITERGB);
+    video->setConnection(Video::COMPOSITERGB);
 
   if (!strcmp(aspect, "16:9"))
-    Video::getInstance()->setAspectRatio(Video::ASPECT16X9);
+  {
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
+    video->setTVsize(Video::ASPECT16X9);
+  }
   else
-    Video::getInstance()->setAspectRatio(Video::ASPECT4X3);
-
-  Video::getInstance()->reinit();
+  {
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting normal");
+    video->setTVsize(Video::ASPECT4X3);
+  }
 }
index 93595d57ee3b8007d0f46bb1ba0c82e566078da5..3e6dde2fd959eca7f182891657a15fe1f5e015f9 100644 (file)
@@ -52,6 +52,7 @@ VVideoLive::~VVideoLive()
 {
   delete player;
   instance = NULL;
+  Video::getInstance()->setDefaultAspect();
 }
 
 VVideoLive* VVideoLive::getInstance()
index cdc757767d264e074766d7b55d758c0ff4ce068c..a514b7644e70724b01bd0efea34798973ab46700 100644 (file)
@@ -36,7 +36,10 @@ VVideoRec::VVideoRec(Recording* rec)
 
 VVideoRec::~VVideoRec()
 {
+  Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre delete player");
   delete player;
+  Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post delete player");
+  Video::getInstance()->setDefaultAspect();
 }
 
 void VVideoRec::draw()
@@ -67,8 +70,10 @@ int VVideoRec::handleCommand(int command)
     case Remote::BACK:
     case Remote::MENU:
     {
+      Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre player stop");
       player->stop();
       vdr->stopStreaming();
+      Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post player stop");
       return 4;
     }
     case Remote::PAUSE:
@@ -94,13 +99,23 @@ int VVideoRec::handleCommand(int command)
     case Remote::YELLOW:
     {
       player->skipBackward(10);
+//        ((PlayerVideo*)player)->test3();
       return 2;
     }
     case Remote::BLUE:
     {
       player->skipForward(10);
+//        ((PlayerVideo*)player)->test4();
       return 2;
     }
+
+//    case Remote::RADIO:
+//    {
+//        ((PlayerVideo*)player)->test5();
+//      return 2;
+//    }
+
+
 //    case Remote::REVERSE:
 //    {
 //      player->toggleFastBackward();