Advertisement
Guest User

hyperion auto 3D detection

a guest
Apr 20th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.25 KB | None | 0 0
  1. diff --git a/include/xbmcvideochecker/XBMCVideoChecker.h b/include/xbmcvideochecker/XBMCVideoChecker.h
  2. index 08fc423..9368cf3 100644
  3. --- a/include/xbmcvideochecker/XBMCVideoChecker.h
  4. +++ b/include/xbmcvideochecker/XBMCVideoChecker.h
  5. @@ -38,7 +38,7 @@ public:
  6.     /// @param grabPhoto Whether or not to grab when the XBMC photo player is playing
  7.     /// @param grabAudio Whether or not to grab when the XBMC audio player is playing
  8.     /// @param grabMenu Whether or not to grab when nothing is playing (in XBMC menu)
  9. -   /// @param grabScreensaver  Whether or not to grab when the XBMC screensaver is activated
  10. +   /// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
  11.     /// @param enable3DDetection Wheter or not to enable the detection of 3D movies playing
  12.     ///
  13.     XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection);
  14. @@ -96,6 +96,9 @@ private:
  15.     /// The JSON-RPC message to check the screensaver
  16.     const QString _checkScreensaverRequest;
  17.  
  18. +   /// The JSON-RPC message to check the active stereoscopicmode
  19. +   const QString _getStereoscopicMode;
  20. +
  21.     /// The QT TCP Socket with connection to XBMC
  22.     QTcpSocket _socket;
  23.  
  24. @@ -111,7 +114,7 @@ private:
  25.     /// Flag indicating whether or not to grab when XBMC is playing nothing (in menu)
  26.     const bool _grabMenu;
  27.  
  28. -   /// Flag inidcating whether or not to grab when the XBMC screensaver is activated
  29. +   /// Flag indicating whether or not to grab when the XBMC screensaver is activated
  30.     const bool _grabScreensaver;
  31.  
  32.     /// Flag indicating wheter or not to enable the detection of 3D movies playing
  33. diff --git a/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp b/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp
  34. index 0c39669..68fb720 100644
  35. --- a/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp
  36. +++ b/libsrc/xbmcvideochecker/XBMCVideoChecker.cpp
  37. @@ -17,6 +17,10 @@
  38.  // {"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}}
  39.  // {"id":668,"jsonrpc":"2.0","result":{"System.ScreenSaverActive":false}}
  40.  
  41. +// Request stereoscopicmode example:
  42. +// {"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":1}
  43. +// {"id":1,"jsonrpc":"2.0","result":{"stereoscopicmode":{"label":"Nebeneinander","mode":"split_vertical"}}}
  44. +
  45.  XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection) :
  46.     QObject(),
  47.     _address(QString::fromStdString(address)),
  48. @@ -24,6 +28,7 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, b
  49.     _activePlayerRequest(R"({"id":666,"jsonrpc":"2.0","method":"Player.GetActivePlayers"})"),
  50.     _currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})"),
  51.     _checkScreensaverRequest(R"({"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}})"),
  52. +   _getStereoscopicMode(R"({"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":1})"),
  53.     _socket(),
  54.     _grabVideo(grabVideo),
  55.     _grabPhoto(grabPhoto),
  56. @@ -116,6 +121,9 @@ void XBMCVideoChecker::receiveReply()
  57.     }
  58.     else if (reply.contains("\"id\":667"))
  59.     {
  60. +       // check of active stereoscopicmode
  61. +       _socket.write(_getStereoscopicMode.toUtf8());
  62. +
  63.         // result of Player.GetItem
  64.         // TODO: what if the filename contains a '"'. In Json this should have been escaped
  65.         QRegExp regex("\"file\":\"((?!\").)*\"");
  66. @@ -143,6 +151,23 @@ void XBMCVideoChecker::receiveReply()
  67.         bool active = reply.contains("\"System.ScreenSaverActive\":true");
  68.         setScreensaverMode(!_grabScreensaver && active);
  69.     }
  70. +   else if (reply.contains("\"stereoscopicmode\""))
  71. +   {
  72. +       QRegExp regex("\"mode\":\"(split_vertical|split_horizontal)\"");
  73. +       int pos = regex.indexIn(reply);
  74. +       if (pos > 0)
  75. +       {
  76. +           QString sMode = regex.cap(1);
  77. +           if (sMode == "split_vertical")
  78. +           {
  79. +               setVideoMode(VIDEO_3DSBS);
  80. +           }
  81. +           else if (sMode == "split_horizontal")
  82. +           {
  83. +               setVideoMode(VIDEO_3DTAB);
  84. +           }
  85. +       }
  86. +   }
  87.  }
  88.  
  89.  void XBMCVideoChecker::connected()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement