Ticket #1828: 1828-v1.patch
File 1828-v1.patch, 86.3 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/NuppelVideoRecorder.cpp
26 26 #include "channelbase.h" 27 27 #include "filtermanager.h" 28 28 #include "recordingprofile.h" 29 #include "tv_rec.h" 30 #include "tv_play.h" 29 31 30 32 extern "C" { 31 33 #include "vbitext/vbi.h" -
libs/libmythtv/tv.h
1 1 #ifndef TV_H 2 2 #define TV_H 3 3 4 #include <qstring.h> 5 4 6 /** \brief ChannelChangeDirection is an enumeration of possible channel 5 7 * changing directions. 6 8 */ … … 50 52 51 53 const int kLiveTVAutoExpire = 10000; 52 54 53 #include "tv_play.h"54 #include "tv_rec.h"55 56 55 QString StateToString(TVState state); 57 56 57 typedef enum PictureAdjustType 58 { 59 kAdjustingPicture_None = 0, 60 kAdjustingPicture_Playback, 61 kAdjustingPicture_Channel, 62 kAdjustingPicture_Recording, 63 } PictureAdjustType; 64 QString toTypeString(PictureAdjustType type); 65 QString toTitleString(PictureAdjustType type); 66 67 typedef enum PictureAttribute 68 { 69 kPictureAttribute_None = 0, 70 kPictureAttribute_MIN = 1, 71 kPictureAttribute_Brightness = 1, 72 kPictureAttribute_Contrast, 73 kPictureAttribute_Colour, 74 kPictureAttribute_Hue, 75 kPictureAttribute_Volume, 76 kPictureAttribute_MAX 77 } PictureAttribute; 78 QString toString(PictureAttribute index); 79 80 //#ifndef IGNORE_TV_PLAY_REC 81 //#include "tv_play.h" 82 //#include "tv_rec.h" 83 //#endif 84 58 85 #endif -
libs/libmythtv/cardutil.h
50 50 QString get_on_source(const QString&, uint, uint); 51 51 QString get_on_input(const QString&, uint, const QString&); 52 52 53 bool set_on_source(const QString&, uint, uint, const QString); 54 53 55 typedef enum 54 56 { 55 57 DVB_DEV_FRONTEND = 1, … … 137 139 static QString GetVBIDevice(uint cardid, const QString &input) 138 140 { return get_on_input("vbidevice", cardid, input); } 139 141 142 143 static int GetValueInt(const QString &col, uint cid, uint sid) 144 { return get_on_source(col, cid, sid).toInt(); } 145 static bool SetValue(const QString &col, uint cid, 146 uint sid, int val) 147 { return set_on_source(col, cid, sid, QString::number(val)); } 148 static bool SetValue(const QString &col, uint cid, 149 uint sid, const QString &val) 150 { return set_on_source(col, cid, sid, val); } 151 152 140 153 static QString GetDefaultInput(uint cardid); 141 154 static QString GetInputName(uint cardid, uint sourceid); 142 155 … … 177 190 178 191 // V4L info 179 192 static bool hasV4L2(int videofd); 193 static bool GetV4LInfo(int videofd, QString &card,QString &driver); 180 194 static InputNames probeV4LInputs(int videofd, bool &ok); 181 195 182 196 private: -
libs/libmythtv/videosource.h
269 269 static void fillSelections(SelectSetting* setting); 270 270 }; 271 271 272 class VBIDevice; 273 274 class V4LConfigurationGroup : public VerticalConfigurationGroup 275 { 276 Q_OBJECT 277 278 public: 279 V4LConfigurationGroup(CaptureCard &parent); 280 281 public slots: 282 void probeCard(const QString &device); 283 284 private: 285 CaptureCard &parent; 286 TransLabelSetting *cardinfo; 287 VBIDevice *vbidev; 288 TunerCardInput *input; 289 }; 290 291 class MPEGConfigurationGroup: public VerticalConfigurationGroup 292 { 293 Q_OBJECT 294 295 public: 296 MPEGConfigurationGroup(CaptureCard &parent); 297 298 public slots: 299 void probeCard(const QString &device); 300 301 private: 302 CaptureCard &parent; 303 TransLabelSetting *cardinfo; 304 TunerCardInput *input; 305 }; 306 307 class pcHDTVConfigurationGroup: public VerticalConfigurationGroup 308 { 309 Q_OBJECT 310 311 public: 312 pcHDTVConfigurationGroup(CaptureCard& a_parent); 313 314 public slots: 315 void probeCard(const QString &device); 316 317 private: 318 CaptureCard &parent; 319 TransLabelSetting *cardinfo; 320 TunerCardInput *input; 321 }; 322 272 323 class TunerCardInput; 273 324 class DVBCardName; 274 325 class DVBCardType; -
libs/libmythtv/tv_play.h
215 215 void ChangeVolume(bool up); 216 216 void ToggleMute(void); 217 217 void ToggleLetterbox(int letterboxMode = -1); 218 void ChangeContrast(bool up, bool recorder);219 void ChangeBrightness(bool up, bool recorder);220 void ChangeColour(bool up, bool recorder);221 void ChangeHue(bool up, bool recorder);222 218 223 219 bool FillMenuTracks(OSDGenericTree*, uint type); 224 220 void ChangeTrack(uint type, int dir); … … 334 330 void ToggleRecord(void); 335 331 void BrowseChannel(const QString &channum); 336 332 337 void DoTogglePictureAttribute(void); 338 void DoToggleRecPictureAttribute(void); 339 void DoChangePictureAttribute(int control, bool up, bool rec); 333 void DoTogglePictureAttribute(int type); 334 void DoChangePictureAttribute(int type, int control, bool up); 340 335 341 336 void BuildOSDTreeMenu(void); 342 337 void ShowOSDTreeMenu(void); … … 409 404 bool doSmartForward; 410 405 bool queuedTranscode; 411 406 bool getRecorderPlaybackInfo; ///< Main loop should get recorderPlaybackInfo 412 int picAdjustment; ///< Player pict attr to modify (on arrow left or right) 413 int recAdjustment; ///< Which recorder picture attribute to modify... 407 int adjustingPicture; 408 ; ///< picture attribute to modify (on arrow left or right) 409 int adjustingPictureAttribute; 414 410 415 411 bool ignoreKeys; 416 412 bool needToSwapPIP; -
libs/libmythtv/guidegrid.cpp
24 24 #include "infostructs.h" 25 25 #include "programinfo.h" 26 26 #include "oldsettings.h" 27 #include "tv.h" 27 #include "tv_play.h" 28 #include "tv_rec.h" 28 29 #include "progfind.h" 29 30 #include "proglist.h" 30 31 #include "util.h" -
libs/libmythtv/channel.h
40 40 bool SwitchToInput(int newcapchannel, bool setstarting); 41 41 42 42 // Picture attributes. 43 void SetBrightness(void); 44 void SetContrast(void); 45 void SetColour(void); 46 void SetHue(void); 47 int ChangeBrightness(bool up); 48 int ChangeColour(bool up); 49 int ChangeContrast(bool up); 50 int ChangeHue(bool up); 43 bool InitPictureAttributes(void); 44 int GetPictureAttribute(const QString db_col_name) const; 45 int ChangePictureAttribute(int, const QString db_col_name, bool up); 51 46 52 47 // PID caching 53 48 void SaveCachedPids(const pid_cache_t&) const; … … 61 56 bool IsTuned(void) const; 62 57 private: 63 58 // Helper Sets 64 void SetColourAttribute(int attrib, const char *name);65 59 void SetFreqTable(const int index); 66 60 int SetFreqTable(const QString &name); 67 61 bool SetInputAndFormat(int newcapchannel, QString newFmt); 68 62 69 63 // Helper Gets 70 unsigned short *GetV4L1Field(int attrib, struct video_picture &vid_pic);71 64 int GetCurrentChannelNum(const QString &channame); 72 65 QString GetFormatForChannel(QString channum, 73 66 QString inputname); 74 67 75 68 // Helper Commands 76 int ChangeColourAttribute(int attrib, const char *name, bool up);69 bool InitPictureAttribute(const QString db_col_name); 77 70 bool TuneTo(const QString &chan, int finetune); 78 71 bool InitializeInputs(void); 79 72 … … 81 74 // Data 82 75 QString device; 83 76 int videofd; 77 QString device_name; 78 QString driver_name; 79 QMap<QString,int> pict_attr_default; 84 80 85 81 struct CHANLIST *curList; 86 82 int totalChannels; -
libs/libmythtv/dbcheck.cpp
10 10 #include "mythdbcon.h" 11 11 12 12 /// This is the DB schema version expected by the running MythTV instance. 13 const QString currentDatabaseVersion = "113 7";13 const QString currentDatabaseVersion = "1138"; 14 14 15 15 static bool UpdateDBVersionNumber(const QString &newnumber); 16 16 static bool performActualUpdate(const QString updates[], QString version, … … 2202 2202 return false; 2203 2203 } 2204 2204 2205 if (dbver == "1137") 2206 { 2207 const QString updates[] = { 2208 "ALTER TABLE capturecard ADD contrast INT NOT NULL default '0';", 2209 "ALTER TABLE capturecard ADD brightness INT NOT NULL default '0';", 2210 "ALTER TABLE capturecard ADD colour INT NOT NULL default '0';", 2211 "ALTER TABLE capturecard ADD hue INT NOT NULL default '0';", 2212 "", 2213 }; 2214 2215 if (!performActualUpdate(updates, "1138", dbver)) 2216 return false; 2217 } 2218 2205 2219 //"ALTER TABLE capturecard DROP COLUMN dvb_recordts;" in 0.21 2206 2220 //"ALTER TABLE capturecard DROP COLUMN dvb_hw_decoder;" in 0.21 2207 2221 //"ALTER TABLE cardinput DROP COLUMN preference;" in 0.22 -
libs/libmythtv/hdhrrecorder.cpp
27 27 #include "atsctables.h" 28 28 #include "atscstreamdata.h" 29 29 #include "eithelper.h" 30 #include "tv_rec.h" 30 31 31 32 #define LOC QString("HDHRRec(%1): ").arg(tvrec->GetCaptureCardNum()) 32 33 #define LOC_ERR QString("HDHRRec(%1), Error: ") \ -
libs/libmythtv/channelbase.h
129 129 { StoreInputChannels(inputs); } 130 130 131 131 // Picture attribute settings 132 virtual void SetBrightness(void) {}; 133 virtual void SetColour(void) {}; 134 virtual void SetContrast(void) {}; 135 virtual void SetHue(void) {}; 136 virtual int ChangeBrightness(bool up) { (void)up; return 0; }; 137 virtual int ChangeColour(bool up) { (void)up; return 0; }; 138 virtual int ChangeContrast(bool up) { (void)up; return 0; }; 139 virtual int ChangeHue(bool up) { (void)up; return 0; }; 132 virtual bool InitPictureAttributes(void) { return false; } 133 virtual int GetPictureAttribute(const QString) const { return 0; } 134 virtual int ChangePictureAttribute(int,const QString,bool) { return 0; } 140 135 141 136 bool CheckChannel(const QString &channum, QString& inputName) const; 142 137 -
libs/libmythtv/dbox2channel.h
14 14 15 15 // Qt headers 16 16 #include <qstring.h> 17 #include <qmutex.h> 17 18 18 19 // MythTV headers 19 20 #include "channelbase.h" 21 #include "tv_rec.h" 20 22 21 23 class DBox2Recorder; 22 24 class DBox2Channel; -
libs/libmythtv/channelbase.cpp
20 20 #include "videodev_myth.h" 21 21 #include "channel.h" 22 22 #include "frequencies.h" 23 #include "tv .h"23 #include "tv_rec.h" 24 24 #include "mythcontext.h" 25 25 #include "exitcodes.h" 26 26 #include "mythdbcon.h" -
libs/libmythtv/tv_play.cpp
10 10 #include <qtimer.h> 11 11 12 12 #include "mythdbcon.h" 13 #include "tv.h" 13 #include "tv_play.h" 14 #include "tv_rec.h" 14 15 #include "osd.h" 15 16 #include "osdsurface.h" 16 17 #include "osdtypes.h" … … 162 163 REG_KEY("TV Playback", "TOGGLESTRETCH", "Toggle time stretch speed", ""); 163 164 REG_KEY("TV Playback", "TOGGLEAUDIOSYNC", 164 165 "Turn on audio sync adjustment controls", ""); 165 REG_KEY("TV Playback", "TOGGLEPICCONTROLS", "Turn on the playback picture " 166 "adjustment controls", "F"); 167 REG_KEY("TV Playback", "TOGGLERECCONTROLS", "Turn on the recording picture " 168 "adjustment controls", "G"); 166 REG_KEY("TV Playback", "TOGGLEPICCONTROLS", 167 "Playback picture adjustments", "F"); 168 REG_KEY("TV Playback", "TOGGLECHANCONTROLS", 169 "Recording picture adjustments for this channel", "Ctrl+G"); 170 REG_KEY("TV Playback", "TOGGLERECCONTROLS", 171 "Recording picture adjustments for this recorder", "G"); 169 172 REG_KEY("TV Playback", "TOGGLEEDIT", "Start Edit Mode", "E"); 170 173 REG_KEY("TV Playback", "CYCLECOMMSKIPMODE", "Cycle Commercial Skip mode", ""); 171 174 REG_KEY("TV Playback", "GUIDE", "Show the Program Guide", "S"); … … 232 235 233 236 Global: Return, Enter, Space, Esc 234 237 235 Global: F1, 236 Playback: Ctrl-B, F7,F8,F9,F10,F11 237 Teletext F2,F3,F4,F5,F6,F7,F8 238 ITV F2,F3,F4,F5,F6,F7 239 */ 238 Global: F1, 239 Playback: F7,F8,F9,F10,F11 240 Teletext F2,F3,F4,F5,F6,F7,F8 241 ITV F2,F3,F4,F5,F6,F7 242 243 Playback: Ctrl-B,Ctrl-G 244 */ 240 245 } 241 246 242 247 void *SpawnDecode(void *param) … … 273 278 update_osd_pos(false), endOfRecording(false), requestDelete(false), 274 279 doSmartForward(false), 275 280 queuedTranscode(false), getRecorderPlaybackInfo(false), 276 picAdjustment(kPictureAttribute_None),277 recAdjustment(kPictureAttribute_None),281 adjustingPicture(kAdjustingPicture_None), 282 adjustingPictureAttribute(kPictureAttribute_None), 278 283 ignoreKeys(false), needToSwapPIP(false), needToJumpMenu(false), 279 284 // Channel Editing 280 285 chanEditMapLock(true), ddMapSourceId(0), ddMapLoaderRunning(false), … … 2163 2168 return; 2164 2169 } 2165 2170 2166 if ( picAdjustment != kPictureAttribute_None)2171 if (adjustingPicture) 2167 2172 { 2168 2173 for (unsigned int i = 0; i < actions.size(); i++) 2169 2174 { … … 2171 2176 handled = true; 2172 2177 2173 2178 if (action == "LEFT") 2174 DoChangePictureAttribute(picAdjustment, false, false); 2179 DoChangePictureAttribute(adjustingPicture, 2180 adjustingPictureAttribute, false); 2175 2181 else if (action == "RIGHT") 2176 DoChangePictureAttribute(picAdjustment, true, false); 2182 DoChangePictureAttribute(adjustingPicture, 2183 adjustingPictureAttribute, true); 2177 2184 else 2178 2185 handled = false; 2179 2186 } 2180 2187 } 2181 2182 if (recAdjustment)2183 {2184 for (unsigned int i = 0; i < actions.size(); i++)2185 {2186 QString action = actions[i];2187 handled = true;2188 2189 if (action == "LEFT")2190 DoChangePictureAttribute(recAdjustment, false, true);2191 else if (action == "RIGHT")2192 DoChangePictureAttribute(recAdjustment, true, true);2193 else2194 handled = false;2195 }2196 }2197 2188 2198 2189 if (stretchAdjustment) 2199 2190 { … … 2318 2309 ChangeAudioSync(0); // just display 2319 2310 else if (action == "TOGGLEPICCONTROLS") 2320 2311 { 2321 if (usePicControls) 2322 { 2323 picAdjustment += 1; 2324 if (picAdjustment >= kPictureAttribute_MAX) 2325 picAdjustment = kPictureAttribute_MIN; 2326 DoTogglePictureAttribute(); 2327 } 2312 DoTogglePictureAttribute(kAdjustingPicture_Playback); 2328 2313 } 2329 2314 else if (action == "NEXTSCAN") 2330 2315 { … … 2693 2678 if (!CommitQueuedInput()) 2694 2679 handled = false; 2695 2680 } 2681 else if (action == "TOGGLECHANCONTROLS") 2682 DoTogglePictureAttribute(kAdjustingPicture_Channel); 2696 2683 else if (action == "TOGGLERECCONTROLS") 2697 DoToggle RecPictureAttribute();2684 DoTogglePictureAttribute(kAdjustingPicture_Recording); 2698 2685 else if (action == "TOGGLEBROWSE" && pseudoLiveTVState[aindx]) 2699 2686 ShowOSDTreeMenu(); 2700 2687 else … … 4868 4855 } 4869 4856 } 4870 4857 4871 void TV::ChangeBrightness(bool up, bool recorder)4872 {4873 int brightness;4874 QString text;4875 4876 if (GetOSD())4877 {4878 if (recorder)4879 {4880 brightness = activerecorder->ChangeBrightness(up);4881 text = QString(tr("Brightness (REC) %1 %")).arg(brightness);4882 GetOSD()->ShowStatus(brightness * 10, true, tr("Adjust Recording"),4883 text, 5, kOSDFunctionalType_RecPictureAdjust);4884 }4885 else4886 {4887 brightness = nvp->getVideoOutput()->ChangeBrightness(up);4888 gContext->SaveSetting("PlaybackBrightness", brightness);4889 text = QString(tr("Brightness %1 %")).arg(brightness);4890 GetOSD()->ShowStatus(brightness * 10, true, tr("Adjust Picture"),4891 text, 5, kOSDFunctionalType_PictureAdjust);4892 }4893 4894 update_osd_pos = false;4895 }4896 }4897 4898 void TV::ChangeContrast(bool up, bool recorder)4899 {4900 int contrast;4901 QString text;4902 4903 if (GetOSD())4904 {4905 if (recorder)4906 {4907 contrast = activerecorder->ChangeContrast(up);4908 text = QString(tr("Contrast (REC) %1 %")).arg(contrast);4909 GetOSD()->ShowStatus(contrast * 10, true, tr("Adjust Recording"),4910 text, 5, kOSDFunctionalType_RecPictureAdjust);4911 }4912 else4913 {4914 contrast = nvp->getVideoOutput()->ChangeContrast(up);4915 gContext->SaveSetting("PlaybackContrast", contrast);4916 text = QString(tr("Contrast %1 %")).arg(contrast);4917 GetOSD()->ShowStatus(contrast * 10, true, tr("Adjust Picture"),4918 text, 5, kOSDFunctionalType_PictureAdjust);4919 }4920 4921 update_osd_pos = false;4922 }4923 }4924 4925 void TV::ChangeColour(bool up, bool recorder)4926 {4927 int colour;4928 QString text;4929 4930 if (GetOSD())4931 {4932 if (recorder)4933 {4934 colour = activerecorder->ChangeColour(up);4935 text = QString(tr("Colour (REC) %1 %")).arg(colour);4936 GetOSD()->ShowStatus(colour * 10, true, tr("Adjust Recording"),4937 text, 5, kOSDFunctionalType_RecPictureAdjust);4938 }4939 else4940 {4941 colour = nvp->getVideoOutput()->ChangeColour(up);4942 gContext->SaveSetting("PlaybackColour", colour);4943 text = QString(tr("Colour %1 %")).arg(colour);4944 GetOSD()->ShowStatus(colour * 10, true, tr("Adjust Picture"),4945 text, 5, kOSDFunctionalType_PictureAdjust);4946 }4947 4948 update_osd_pos = false;4949 }4950 }4951 4952 void TV::ChangeHue(bool up, bool recorder)4953 {4954 int hue;4955 QString text;4956 4957 if (GetOSD())4958 {4959 if (recorder)4960 {4961 hue = activerecorder->ChangeHue(up);4962 text = QString(tr("Hue (REC) %1 %")).arg(hue);4963 GetOSD()->ShowStatus(hue * 10, true, tr("Adjust Recording"),4964 text, 5, kOSDFunctionalType_RecPictureAdjust);4965 }4966 else4967 {4968 hue = nvp->getVideoOutput()->ChangeHue(up);4969 gContext->SaveSetting("PlaybackHue", hue);4970 text = QString(tr("Hue %1 %")).arg(hue);4971 GetOSD()->ShowStatus(hue * 10, true, tr("Adjust Picture"),4972 text, 5, kOSDFunctionalType_PictureAdjust);4973 }4974 4975 update_osd_pos = false;4976 }4977 }4978 4979 4858 void TV::ChangeVolume(bool up) 4980 4859 { 4981 4860 AudioOutput *aud = nvp->getAudioOutput(); … … 5599 5478 { 5600 5479 switch (osdType) 5601 5480 { 5602 case kOSDFunctionalType_RecPictureAdjust:5603 recAdjustment = kPictureAttribute_None;5604 break;5605 5481 case kOSDFunctionalType_PictureAdjust: 5606 picAdjustment = kPictureAttribute_None; 5482 adjustingPicture = kAdjustingPicture_None; 5483 adjustingPictureAttribute = kPictureAttribute_None; 5607 5484 break; 5608 5485 case kOSDFunctionalType_SmartForward: 5609 5486 doSmartForward = false; … … 5619 5496 } 5620 5497 } 5621 5498 5622 void TV::DoTogglePictureAttribute( void)5499 void TV::DoTogglePictureAttribute(int itype) 5623 5500 { 5624 OSDSet *oset; 5625 int value = 0; 5501 PictureAdjustType type = (PictureAdjustType) itype; 5626 5502 5627 if (GetOSD()) 5628 { 5629 oset = GetOSD()->GetSet("status"); 5630 QString title = tr("Adjust Picture"); 5631 QString picName; 5503 adjustingPicture = type; 5632 5504 5633 AudioOutput *aud = NULL; 5634 switch (picAdjustment) 5635 { 5636 case kPictureAttribute_Brightness: 5637 value = nvp->getVideoOutput()->GetCurrentBrightness(); 5638 picName = QString("%1 %2 %").arg(tr("Brightness")).arg(value); 5639 break; 5640 case kPictureAttribute_Contrast: 5641 value = nvp->getVideoOutput()->GetCurrentContrast(); 5642 picName = QString("%1 %2 %").arg(tr("Contrast")).arg(value); 5643 break; 5644 case kPictureAttribute_Colour: 5645 value = nvp->getVideoOutput()->GetCurrentColour(); 5646 picName = QString("%1 %2 %").arg(tr("Colour")).arg(value); 5647 break; 5648 case kPictureAttribute_Hue: 5649 value = nvp->getVideoOutput()->GetCurrentHue(); 5650 picName = QString("%1 %2 %").arg(tr("Hue")).arg(value); 5651 break; 5652 case kPictureAttribute_Volume: 5653 aud = nvp->getAudioOutput(); 5654 value = (aud) ? (aud->GetCurrentVolume()) : 99; 5655 title = tr("Adjust Volume"); 5656 picName = QString("%1 %2 %").arg(tr("Volume")).arg(value); 5657 break; 5658 } 5659 GetOSD()->ShowStatus(value*10, true, title, picName, 5, 5660 kOSDFunctionalType_PictureAdjust); 5661 update_osd_pos = false; 5505 adjustingPictureAttribute += 1; 5506 if ((adjustingPictureAttribute >= kPictureAttribute_MAX) || 5507 ((type >= kAdjustingPicture_Channel) && 5508 (adjustingPictureAttribute > kPictureAttribute_Hue))) 5509 { 5510 adjustingPictureAttribute = kPictureAttribute_MIN; 5662 5511 } 5663 }5664 5512 5665 void TV::DoToggleRecPictureAttribute(void) 5666 { 5667 OSDSet *oset; 5668 int value = 0; 5669 5670 recAdjustment = (recAdjustment % 4) + 1; 5671 5672 if (GetOSD()) 5513 PictureAttribute attr = (PictureAttribute) adjustingPictureAttribute; 5514 QString title = toTitleString(type); 5515 5516 if (!GetOSD()) 5517 return; 5518 5519 GetOSD()->GetSet("status"); 5520 5521 int value = 99; 5522 if (nvp && (kAdjustingPicture_Playback == type)) 5673 5523 { 5674 oset = GetOSD()->GetSet("status"); 5675 QString title = tr("Adjust Recording"); 5676 QString recName; 5677 5678 switch (recAdjustment) 5524 if (kPictureAttribute_Brightness == adjustingPictureAttribute) 5525 value = nvp->getVideoOutput()->GetCurrentBrightness(); 5526 else if (kPictureAttribute_Contrast == adjustingPictureAttribute) 5527 value = nvp->getVideoOutput()->GetCurrentContrast(); 5528 else if (kPictureAttribute_Colour == adjustingPictureAttribute) 5529 value = nvp->getVideoOutput()->GetCurrentColour(); 5530 else if (kPictureAttribute_Hue == adjustingPictureAttribute) 5531 value = nvp->getVideoOutput()->GetCurrentHue(); 5532 else if ((kPictureAttribute_Volume == adjustingPictureAttribute) && 5533 nvp->getAudioOutput()) 5679 5534 { 5680 case kPictureAttribute_Brightness: 5681 activerecorder->ChangeBrightness(true); 5682 value = activerecorder->ChangeBrightness(false); 5683 recName = QString("%1 %2 %3 %").arg(tr("Brightness")) 5684 .arg(tr("(REC)")).arg(value); 5685 break; 5686 case kPictureAttribute_Contrast: 5687 activerecorder->ChangeContrast(true); 5688 value = activerecorder->ChangeContrast(false); 5689 recName = QString("%1 %2 %3 %").arg(tr("Contrast")) 5690 .arg(tr("(REC)")).arg(value); 5691 break; 5692 case kPictureAttribute_Colour: 5693 activerecorder->ChangeColour(true); 5694 value = activerecorder->ChangeColour(false); 5695 recName = QString("%1 %2 %3 %").arg(tr("Colour")) 5696 .arg(tr("(REC)")).arg(value); 5697 break; 5698 case kPictureAttribute_Hue: 5699 activerecorder->ChangeHue(true); 5700 value = activerecorder->ChangeHue(false); 5701 recName = QString("%1 %2 %3 %").arg(tr("Hue")) 5702 .arg(tr("(REC)")).arg(value); 5703 break; 5535 value = nvp->getAudioOutput()->GetCurrentVolume(); 5536 title = tr("Adjust Volume"); 5704 5537 } 5705 GetOSD()->ShowStatus(value * 10, true, title, recName, 5,5706 kOSDFunctionalType_RecPictureAdjust);5707 update_osd_pos = false;5708 5538 } 5539 else if (activerecorder && (kAdjustingPicture_Playback != type)) 5540 { 5541 value = activerecorder->GetPictureAttribute(attr); 5542 } 5543 5544 QString text = toString(attr) + " " + toTypeString(type) + 5545 QString(" %1 %").arg(value); 5546 5547 GetOSD()->ShowStatus(value * 10, true, title, text, 5, 5548 kOSDFunctionalType_PictureAdjust); 5549 5550 update_osd_pos = false; 5709 5551 } 5710 5552 5711 void TV::DoChangePictureAttribute(int control, bool up, bool rec)5553 void TV::DoChangePictureAttribute(int itype, int control, bool up) 5712 5554 { 5713 switch (control) 5555 if (!GetOSD()) 5556 return; 5557 5558 PictureAdjustType type = (PictureAdjustType) itype; 5559 PictureAttribute attr = (PictureAttribute) control; 5560 int value = 99; 5561 5562 if (nvp && (kAdjustingPicture_Playback == type)) 5714 5563 { 5715 case kPictureAttribute_Brightness: 5716 ChangeBrightness(up, rec); 5717 break; 5718 case kPictureAttribute_Contrast: 5719 ChangeContrast(up, rec); 5720 break; 5721 case kPictureAttribute_Colour: 5722 ChangeColour(up, rec); 5723 break; 5724 case kPictureAttribute_Hue: 5725 ChangeHue(up, rec); 5726 break; 5727 case kPictureAttribute_Volume: 5564 if (kPictureAttribute_Brightness == control) 5565 { 5566 value = nvp->getVideoOutput()->ChangeBrightness(up); 5567 gContext->SaveSetting("PlaybackBrightness", value); 5568 } 5569 else if (kPictureAttribute_Contrast == control) 5570 { 5571 value = nvp->getVideoOutput()->ChangeContrast(up); 5572 gContext->SaveSetting("PlaybackContrast", value); 5573 } 5574 else if (kPictureAttribute_Colour == control) 5575 { 5576 value = nvp->getVideoOutput()->ChangeColour(up); 5577 gContext->SaveSetting("PlaybackColour", value); 5578 } 5579 else if (kPictureAttribute_Hue == control) 5580 { 5581 value = nvp->getVideoOutput()->ChangeHue(up); 5582 gContext->SaveSetting("PlaybackHue", value); 5583 } 5584 else if (kPictureAttribute_Volume == control) 5585 { 5728 5586 ChangeVolume(up); 5729 break; 5587 return; 5588 } 5730 5589 } 5590 else if (activerecorder && (kAdjustingPicture_Playback != type)) 5591 { 5592 value = activerecorder->ChangePictureAttribute(type, attr, up); 5593 } 5594 5595 QString text = toString(attr) + " " + toTypeString(type) + 5596 QString(" %1 %").arg(value); 5597 5598 GetOSD()->ShowStatus(value * 10, true, toTitleString(type), text, 5, 5599 kOSDFunctionalType_PictureAdjust); 5600 5601 update_osd_pos = false; 5731 5602 } 5732 5603 5733 5604 OSD *TV::GetOSD(void) … … 6215 6086 } 6216 6087 else if (action.left(17) == "TOGGLEPICCONTROLS") 6217 6088 { 6218 picAdjustment = action.right(1).toInt();6219 DoTogglePictureAttribute( );6089 adjustingPictureAttribute = action.right(1).toInt() - 1; 6090 DoTogglePictureAttribute(kAdjustingPicture_Playback); 6220 6091 } 6221 6092 else if (action.left(12) == "TOGGLEASPECT") 6222 6093 { -
libs/libmythtv/remoteencoder.h
42 42 QStringList GetInputs(void); 43 43 QString GetInput(void); 44 44 QString SetInput(QString); 45 int ChangeContrast(bool direction); 46 int ChangeBrightness(bool direction); 47 int ChangeColour(bool direction); 48 int ChangeHue(bool direction); 45 int GetPictureAttribute(int attr); 46 int ChangePictureAttribute(int type, int attr, bool direction); 49 47 void ChangeChannel(int channeldirection); 50 48 void ChangeDeinterlacer(int deint_mode); 51 49 void ToggleChannelFavorite(void); -
libs/libmythtv/cardutil.cpp
229 229 return QString::null; 230 230 } 231 231 232 bool set_on_source(const QString &to_set, uint cardid, uint sourceid, 233 const QString value) 234 { 235 QString tmp = get_on_source("capturecard.cardid", cardid, sourceid); 236 if (tmp.isEmpty()) 237 return false; 238 239 bool ok; 240 uint input_cardid = tmp.toUInt(&ok); 241 if (!ok) 242 return false; 243 244 MSqlQuery query(MSqlQuery::InitCon()); 245 query.prepare( 246 QString("UPDATE capturecard SET %1 = :VALUE ").arg(to_set) + 247 "WHERE cardid = :CARDID"); 248 query.bindValue(":CARDID", input_cardid); 249 query.bindValue(":VALUE", value); 250 251 if (query.exec()) 252 return true; 253 254 MythContext::DBError("CardUtil::set_on_source", query); 255 return false; 256 } 257 232 258 /** \fn CardUtil::GetCardID(const QString&, QString) 233 259 * \brief Returns the cardid of the card that uses the specified 234 260 * videodevice, and optionally a non-local hostname. … … 446 472 #endif // !USING_V4L 447 473 } 448 474 475 bool CardUtil::GetV4LInfo(int videofd, QString &card, QString &driver) 476 { 477 card = driver = QString::null; 478 479 if (videofd < 0) 480 return false; 481 482 #ifdef USING_V4L 483 // First try V4L2 query 484 struct v4l2_capability capability; 485 bzero(&capability, sizeof(struct v4l2_capability)); 486 if (ioctl(videofd, VIDIOC_QUERYCAP, &capability) >= 0) 487 { 488 card.setAscii((char*)capability.card); 489 driver.setAscii((char*)capability.driver); 490 } 491 else // Fallback to V4L1 query 492 { 493 struct video_capability capability; 494 if (ioctl(videofd, VIDIOCGCAP, &capability) >= 0) 495 card.setAscii((char*)capability.name); 496 } 497 #endif // !USING_V4L 498 499 return !card.isEmpty(); 500 } 501 449 502 InputNames CardUtil::probeV4LInputs(int videofd, bool &ok) 450 503 { 451 504 (void) videofd; -
libs/libmythtv/videosource.cpp
500 500 class VideoDevice: public PathSetting, public CCSetting 501 501 { 502 502 public: 503 VideoDevice(const CaptureCard& parent, 504 uint minor_min=0, uint minor_max=UINT_MAX) 503 VideoDevice(const CaptureCard &parent, 504 uint minor_min = 0, 505 uint minor_max = UINT_MAX, 506 QString card = QString::null, 507 QString driver = QString::null) 505 508 : PathSetting(true), CCSetting(parent, "videodevice") 506 509 { 507 510 setLabel(QObject::tr("Video device")); 508 511 509 512 // /dev/v4l/video* 510 513 QDir dev("/dev/v4l", "video*", QDir::Name, QDir::System); 511 fillSelectionsFromDir(dev, minor_min, minor_max, false); 514 fillSelectionsFromDir(dev, minor_min, minor_max, 515 card, driver, false); 512 516 513 517 // /dev/video* 514 518 dev.setPath("/dev"); 515 fillSelectionsFromDir(dev, minor_min, minor_max, false); 519 fillSelectionsFromDir(dev, minor_min, minor_max, 520 card, driver, false); 516 521 517 522 // /dev/dtv/video* 518 523 dev.setPath("/dev/dtv"); 519 fillSelectionsFromDir(dev, minor_min, minor_max, false); 524 fillSelectionsFromDir(dev, minor_min, minor_max, 525 card, driver, false); 520 526 521 527 // /dev/dtv* 522 528 dev.setPath("/dev"); 523 529 dev.setNameFilter("dtv*"); 524 fillSelectionsFromDir(dev, minor_min, minor_max, false); 525 526 VERBOSE(VB_IMPORTANT, ""); 530 fillSelectionsFromDir(dev, minor_min, minor_max, 531 card, driver, false); 527 532 }; 528 533 529 voidfillSelectionsFromDir(const QDir& dir,534 uint fillSelectionsFromDir(const QDir& dir, 530 535 uint minor_min, uint minor_max, 536 QString card, QString driver, 531 537 bool allow_duplicates) 532 538 { 539 uint cnt = 0; 533 540 const QFileInfoList *il = dir.entryInfoList(); 534 541 if (!il) 535 return ;542 return cnt; 536 543 537 544 QFileInfoListIterator it( *il ); 538 545 QFileInfo *fi; 539 540 for (; (fi = it.current()) != 0; ++it)546 547 for (; (fi = it.current()) != 0; ++it) 541 548 { 542 549 struct stat st; 543 550 QString filepath = fi->absFilePath(); 544 551 int err = lstat(filepath, &st); 545 if (0==err) 552 553 if (0 != err) 546 554 { 547 if (S_ISCHR(st.st_mode)) 555 VERBOSE(VB_IMPORTANT, 556 QString("Could not stat file: %1").arg(filepath)); 557 continue; 558 } 559 560 // is this is a character device? 561 if (!S_ISCHR(st.st_mode)) 562 continue; 563 564 // is this device is in our minor range? 565 uint minor_num = minor(st.st_rdev); 566 if (minor_min > minor_num || minor_max < minor_num) 567 continue; 568 569 // ignore duplicates if allow_duplicates not set 570 if (!allow_duplicates && minor_list[minor_num]) 571 continue; 572 573 // if the driver returns any info add this device to our list 574 int videofd = open(filepath.ascii(), O_RDWR); 575 if (videofd >= 0) 576 { 577 QString cn, dn; 578 if (CardUtil::GetV4LInfo(videofd, cn, dn) && 579 (driver.isEmpty() || (dn == driver)) && 580 (card.isEmpty() || (cn == card))) 548 581 { 549 uint minor_num = minor(st.st_rdev); 550 // this is a character device, if in minor range to list 551 if (minor_min<=minor_num && 552 minor_max>=minor_num && 553 (allow_duplicates || 554 (minor_list.find(minor_num)==minor_list.end()))) 555 { 556 addSelection(filepath); 557 minor_list[minor_num]=1; 558 } 582 addSelection(filepath); 583 cnt++; 559 584 } 585 close(videofd); 560 586 } 561 else 562 { 563 VERBOSE(VB_IMPORTANT, 564 QString("Could not stat file: %1").arg(filepath)); 565 } 587 588 // add to list of minors discovered to avoid duplicates 589 minor_list[minor_num] = 1; 566 590 } 591 592 return cnt; 567 593 } 568 594 569 595 private: 570 596 QMap<uint, uint> minor_list; 571 597 }; 572 598 573 class V biDevice: public PathSetting, public CCSetting599 class VBIDevice: public PathSetting, public CCSetting 574 600 { 575 601 public: 576 V biDevice(const CaptureCard& parent)602 VBIDevice(const CaptureCard& parent) 577 603 : PathSetting(true), CCSetting(parent, "vbidevice") 578 604 { 579 605 setLabel(QObject::tr("VBI device")); 580 QDir dev("/dev", "vbi*", QDir::Name, QDir::System); 581 fillSelectionsFromDir(dev); 582 dev.setPath("/dev/v4l"); 583 fillSelectionsFromDir(dev); 606 setFilter(QString::null, QString::null); 584 607 }; 608 609 void setFilter(const QString &card, const QString &driver) 610 { 611 clearSelections(); 612 QDir dev("/dev/v4l", "vbi*", QDir::Name, QDir::System); 613 if (!fillSelectionsFromDir(dev, card, driver)) 614 { 615 dev.setPath("/v4l"); 616 fillSelectionsFromDir(dev, card, driver); 617 } 618 } 619 620 uint fillSelectionsFromDir(const QDir &dir, const QString &card, 621 const QString &driver) 622 { 623 uint cnt = 0; 624 const QFileInfoList *il = dir.entryInfoList(); 625 if (!il) 626 return cnt; 627 628 QFileInfoListIterator it(*il); 629 QFileInfo *fi; 630 631 for (; (fi = it.current()) != 0; ++it) 632 { 633 QString device = fi->absFilePath(); 634 int vbifd = open(device.ascii(), O_RDWR); 635 if (vbifd < 0) 636 continue; 637 638 QString cn, dn; 639 if (CardUtil::GetV4LInfo(vbifd, cn, dn) && 640 (driver.isEmpty() || (dn == driver)) && 641 (card.isEmpty() || (cn == card))) 642 { 643 addSelection(device); 644 cnt++; 645 } 646 647 close(vbifd); 648 } 649 650 return cnt; 651 } 585 652 }; 586 653 587 654 class AudioDevice: public PathSetting, public CCSetting … … 964 1031 CaptureCard& parent; 965 1032 }; 966 1033 967 class V4LConfigurationGroup: public VerticalConfigurationGroup 1034 V4LConfigurationGroup::V4LConfigurationGroup(CaptureCard& a_parent) : 1035 ConfigurationGroup(false, true, false, false), 1036 VerticalConfigurationGroup(false, true, false, false), 1037 parent(a_parent), 1038 cardinfo(new TransLabelSetting()), vbidev(new VBIDevice(parent)), 1039 input(new TunerCardInput(parent)) 968 1040 { 969 public: 970 V4LConfigurationGroup(CaptureCard& a_parent): 971 ConfigurationGroup(false, true, false, false), 972 VerticalConfigurationGroup(false, true, false, false), 973 parent(a_parent) 974 { 975 VideoDevice* device; 976 TunerCardInput* input; 1041 VideoDevice *device = new VideoDevice(parent); 1042 HorizontalConfigurationGroup *audgrp = 1043 new HorizontalConfigurationGroup(false, false, true, true); 977 1044 978 addChild(device = new VideoDevice(parent));979 addChild(new VbiDevice(parent));980 addChild(new AudioDevice(parent));1045 cardinfo->setLabel(tr("Probed info")); 1046 audgrp->addChild(new AudioRateLimit(parent)); 1047 audgrp->addChild(new SkipBtAudio(parent)); 981 1048 982 HorizontalConfigurationGroup *ag; 983 ag = new HorizontalConfigurationGroup(false, false); 984 ag->addChild(new AudioRateLimit(parent)); 985 ag->addChild(new SkipBtAudio(parent)); 986 addChild(ag); 1049 addChild(device); 1050 addChild(cardinfo); 1051 addChild(vbidev); 1052 addChild(new AudioDevice(parent)); 1053 addChild(audgrp); 1054 addChild(input); 987 1055 988 addChild(input = new TunerCardInput(parent)); 1056 connect(device, SIGNAL(valueChanged(const QString&)), 1057 this, SLOT( probeCard( const QString&))); 989 1058 990 connect(device, SIGNAL(valueChanged(const QString&)), 991 input, SLOT(fillSelections(const QString&))); 992 input->fillSelections(device->getValue()); 993 }; 994 private: 995 CaptureCard& parent; 1059 probeCard(device->getValue()); 996 1060 }; 997 1061 998 class MPEGConfigurationGroup: public VerticalConfigurationGroup 1062 void V4LConfigurationGroup::probeCard(const QString &device) 999 1063 { 1000 public: 1001 MPEGConfigurationGroup(CaptureCard& a_parent): 1002 ConfigurationGroup(false, true, false, false), 1003 VerticalConfigurationGroup(false, true, false, false), 1004 parent(a_parent) 1064 QString cn = tr("Failed to open"), ci = cn, dn = QString::null; 1065 1066 int videofd = open(device.ascii(), O_RDWR); 1067 if (videofd >= 0) 1005 1068 { 1006 VideoDevice* device; 1007 TunerCardInput* input; 1069 if (!CardUtil::GetV4LInfo(videofd, cn, dn)) 1070 ci = cn = tr("Failed to probe"); 1071 else if (!dn.isEmpty()) 1072 ci = cn + " [" + dn + "]"; 1073 close(videofd); 1074 } 1008 1075 1009 addChild(device = new VideoDevice(parent, 0, 15)); 1010 addChild(input = new TunerCardInput(parent)); 1011 connect(device, SIGNAL(valueChanged(const QString&)), 1012 input, SLOT(fillSelections(const QString&))); 1013 input->fillSelections(device->getValue()); 1014 }; 1015 private: 1016 CaptureCard& parent; 1017 }; 1076 cardinfo->setValue(ci); 1077 vbidev->setFilter(cn, dn); 1078 input->fillSelections(device); 1079 } 1018 1080 1019 class pcHDTVConfigurationGroup: public VerticalConfigurationGroup 1081 1082 MPEGConfigurationGroup::MPEGConfigurationGroup(CaptureCard &a_parent) : 1083 ConfigurationGroup(false, true, false, false), 1084 VerticalConfigurationGroup(false, true, false, false), 1085 parent(a_parent), cardinfo(new TransLabelSetting()), 1086 input(new TunerCardInput(parent)) 1020 1087 { 1021 public: 1022 pcHDTVConfigurationGroup(CaptureCard& a_parent): 1023 ConfigurationGroup(false, true, false, false), 1024 VerticalConfigurationGroup(false, true, false, false), 1025 parent(a_parent) 1088 VideoDevice *device = 1089 new VideoDevice(parent, 0, 15, QString::null, "ivtv"); 1090 1091 cardinfo->setLabel(tr("Probed info")); 1092 1093 addChild(device); 1094 addChild(cardinfo); 1095 addChild(input); 1096 1097 connect(device, SIGNAL(valueChanged(const QString&)), 1098 this, SLOT( probeCard( const QString&))); 1099 1100 probeCard(device->getValue()); 1101 } 1102 1103 void MPEGConfigurationGroup::probeCard(const QString &device) 1104 { 1105 QString cn = tr("Failed to open"), ci = cn, dn = QString::null; 1106 1107 int videofd = open(device.ascii(), O_RDWR); 1108 if (videofd >= 0) 1026 1109 { 1027 VideoDevice *atsc_device = new VideoDevice(parent, 0, 64); 1028 TunerCardInput *atsc_input = new TunerCardInput(parent); 1029 SignalTimeout *signal_timeout = new SignalTimeout(parent, 500); 1030 ChannelTimeout *channel_timeout = new ChannelTimeout(parent, 2000); 1031 addChild(atsc_device); 1032 addChild(signal_timeout); 1033 addChild(channel_timeout); 1034 addChild(atsc_input); 1035 connect(atsc_device, SIGNAL(valueChanged(const QString&)), 1036 atsc_input, SLOT(fillSelections(const QString&))); 1037 atsc_input->fillSelections(atsc_device->getValue()); 1038 }; 1039 private: 1040 CaptureCard& parent; 1041 }; 1110 if (!CardUtil::GetV4LInfo(videofd, cn, dn)) 1111 ci = cn = tr("Failed to probe"); 1112 else if (!dn.isEmpty()) 1113 ci = cn + " [" + dn + "]"; 1114 close(videofd); 1115 } 1042 1116 1117 cardinfo->setValue(ci); 1118 input->fillSelections(device); 1119 } 1120 1121 pcHDTVConfigurationGroup::pcHDTVConfigurationGroup(CaptureCard& a_parent) : 1122 ConfigurationGroup(false, true, false, false), 1123 VerticalConfigurationGroup(false, true, false, false), 1124 parent(a_parent), cardinfo(new TransLabelSetting()), 1125 input(new TunerCardInput(parent)) 1126 { 1127 VideoDevice *atsc_device = new VideoDevice(parent, 0, 64); 1128 SignalTimeout *signal_timeout = new SignalTimeout(parent, 500); 1129 ChannelTimeout *channel_timeout = new ChannelTimeout(parent, 2000); 1130 1131 addChild(atsc_device); 1132 addChild(cardinfo); 1133 addChild(signal_timeout); 1134 addChild(channel_timeout); 1135 addChild(input); 1136 1137 connect(atsc_device, SIGNAL(valueChanged(const QString&)), 1138 this, SLOT( probeCard( const QString&))); 1139 1140 probeCard(atsc_device->getValue()); 1141 } 1142 1143 void pcHDTVConfigurationGroup::probeCard(const QString &device) 1144 { 1145 QString cn = tr("Failed to open"), ci = cn, dn = QString::null; 1146 1147 int videofd = open(device.ascii(), O_RDWR); 1148 if (videofd >= 0) 1149 { 1150 if (!CardUtil::GetV4LInfo(videofd, cn, dn)) 1151 ci = cn = tr("Failed to probe"); 1152 else if (!dn.isEmpty()) 1153 ci = cn + " [" + dn + "]"; 1154 close(videofd); 1155 } 1156 1157 cardinfo->setValue(ci); 1158 input->fillSelections(device); 1159 } 1160 1043 1161 CaptureCardGroup::CaptureCardGroup(CaptureCard& parent) : 1044 1162 ConfigurationGroup(true, true, false, false), 1045 1163 VerticalConfigurationGroup(true, true, false, false) -
libs/libmythtv/remoteencoder.cpp
9 9 #include "util.h" 10 10 #include "mythcontext.h" 11 11 #include "signalmonitor.h" 12 #include "videooutbase.h" 12 13 13 14 RemoteEncoder::RemoteEncoder(int num, const QString &host, short port) 14 15 : recordernum(num), controlSock(NULL), remotehost(host), … … 449 450 return timeout; 450 451 } 451 452 452 /** \fn RemoteEncoder::ChangeContrast(bool)453 * \brief Changes contrast of a recording.454 *455 * Note: In practice this only works with frame grabbing recorders.456 *457 * \return contrast if it succeeds, -1 otherwise.458 */459 int RemoteEncoder::ChangeContrast(bool direction)460 {461 QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum);462 strlist << "CHANGE_CONTRAST";463 strlist << QString::number((int)direction);464 453 465 SendReceiveStringList(strlist); 466 467 int retval = strlist[0].toInt(); 468 return retval; 469 } 470 471 /** \fn RemoteEncoder::ChangeBrightness(bool) 472 * \brief Changes the brightness of a recording. 473 * 474 * Note: In practice this only works with frame grabbing recorders. 475 * 476 * \return brightness if it succeeds, -1 otherwise. 477 */ 478 int RemoteEncoder::ChangeBrightness(bool direction) 454 int RemoteEncoder::GetPictureAttribute(int attr) 479 455 { 480 456 QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum); 481 strlist << "CHANGE_BRIGHTNESS";482 strlist << QString::number((int)direction);483 457 458 if (kPictureAttribute_Contrast == attr) 459 strlist << "GET_CONTRAST"; 460 else if (kPictureAttribute_Brightness == attr) 461 strlist << "GET_BRIGHTNESS"; 462 else if (kPictureAttribute_Colour == attr) 463 strlist << "GET_COLOUR"; 464 else if (kPictureAttribute_Hue == attr) 465 strlist << "GET_HUE"; 466 else 467 return -1; 468 484 469 SendReceiveStringList(strlist); 485 470 486 471 int retval = strlist[0].toInt(); 487 472 return retval; 488 473 } 489 474 490 /** \fn RemoteEncoder::ChangeCo lour(bool)491 * \brief Changes the colour phase of a recording.475 /** \fn RemoteEncoder::ChangeContrast(int, int, bool) 476 * \brief Changes brightness/contrast/colour/hue of a recording. 492 477 * 493 * 478 * Note: In practice this only works with frame grabbing recorders. 494 479 * 495 * \return co lourif it succeeds, -1 otherwise.480 * \return contrast if it succeeds, -1 otherwise. 496 481 */ 497 int RemoteEncoder::Change Colour(bool direction)482 int RemoteEncoder::ChangePictureAttribute(int type, int attr, bool up) 498 483 { 499 484 QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum); 500 strlist << "CHANGE_COLOUR";501 strlist << QString::number((int)direction);502 485 503 SendReceiveStringList(strlist); 486 if (kPictureAttribute_Contrast == attr) 487 strlist << "CHANGE_CONTRAST"; 488 else if (kPictureAttribute_Brightness == attr) 489 strlist << "CHANGE_BRIGHTNESS"; 490 else if (kPictureAttribute_Colour == attr) 491 strlist << "CHANGE_COLOUR"; 492 else if (kPictureAttribute_Hue == attr) 493 strlist << "CHANGE_HUE"; 494 else 495 return -1; 504 496 505 int retval = strlist[0].toInt(); 506 return retval; 507 } 497 strlist << QString::number(type); 498 strlist << QString::number((int)up); 508 499 509 /** \fn RemoteEncoder::ChangeHue(bool)510 * \brief Changes the hue of a recording.511 *512 * Note: In practice this only works with frame grabbing recorders.513 *514 * \return hue if it succeeds, -1 otherwise.515 */516 int RemoteEncoder::ChangeHue(bool direction)517 {518 QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum);519 strlist << "CHANGE_HUE";520 strlist << QString::number((int)direction);521 522 500 SendReceiveStringList(strlist); 523 501 524 502 int retval = strlist[0].toInt(); … … 655 633 programid = cleanup(strlist[11]); 656 634 } 657 635 658 void RemoteEncoder::GetChannelInfo( InfoMap&infoMap, uint chanid)636 void RemoteEncoder::GetChannelInfo(QMap<QString, QString> &infoMap, uint chanid) 659 637 { 660 638 QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum); 661 639 strlist << "GET_CHANNEL_INFO"; … … 673 651 infoMap["oldchannum"] = infoMap["channum"]; 674 652 } 675 653 676 bool RemoteEncoder::SetChannelInfo(const InfoMap&infoMap)654 bool RemoteEncoder::SetChannelInfo(const QMap<QString, QString> &infoMap) 677 655 { 678 656 QStringList strlist = "SET_CHANNEL_INFO"; 679 657 strlist << make_safe(infoMap["chanid"]); -
libs/libmythtv/videoout_xv.cpp
36 36 #include "mythconfig.h" 37 37 #include "mythcontext.h" 38 38 #include "filtermanager.h" 39 #define IGNORE_TV_PLAY_REC 40 #include "tv.h" 39 41 40 42 #define LOC QString("VideoOutputXv: ") 41 43 #define LOC_ERR QString("VideoOutputXv Error: ") -
libs/libmythtv/udpnotify.cpp
45 45 #include "udpnotify.h" 46 46 #include "mythcontext.h" 47 47 #include "osd.h" 48 #include "tv .h"48 #include "tv_play.h" 49 49 50 50 UDPNotifyOSDSet::UDPNotifyOSDSet(const QString &name) 51 51 { -
libs/libmythtv/tv_rec.cpp
2638 2638 } 2639 2639 } 2640 2640 2641 /** \fn TVRec::Change Contrast(bool)2642 * \brief Changes contrast of a recording.2641 /** \fn TVRec::ChangePictureAttribute(PictureAdjustType,PictureAttribute,bool) 2642 * \brief Returns current value [0,100] if it succeeds, -1 otherwise. 2643 2643 * 2644 2644 * Note: In practice this only works with frame grabbing recorders. 2645 *2646 * \return contrast if it succeeds, -1 otherwise.2647 2645 */ 2648 int TVRec:: ChangeContrast(bool direction)2646 int TVRec::GetPictureAttribute(PictureAttribute attr) 2649 2647 { 2650 2648 QMutexLocker lock(&stateChangeLock); 2651 2652 2649 if (!channel) 2653 2650 return -1; 2654 2651 2655 int ret = channel->ChangeContrast(direction); 2656 return ret; 2657 } 2652 int ret = -1; 2653 if (kPictureAttribute_Brightness == attr) 2654 ret = channel->GetPictureAttribute("brightness"); 2655 else if (kPictureAttribute_Contrast == attr) 2656 ret = channel->GetPictureAttribute("contrast"); 2657 else if (kPictureAttribute_Colour == attr) 2658 ret = channel->GetPictureAttribute("colour"); 2659 else if (kPictureAttribute_Hue == attr) 2660 ret = channel->GetPictureAttribute("hue"); 2658 2661 2659 /** \fn TVRec::ChangeBrightness(bool) 2660 * \brief Changes the brightness of a recording. 2661 * 2662 * Note: In practice this only works with frame grabbing recorders. 2663 * 2664 * \return brightness if it succeeds, -1 otherwise. 2665 */ 2666 int TVRec::ChangeBrightness(bool direction) 2667 { 2668 QMutexLocker lock(&stateChangeLock); 2669 2670 if (!channel) 2662 if (ret < 0) 2671 2663 return -1; 2672 2673 int ret = channel->ChangeBrightness(direction); 2674 return ret; 2664 return ret / 655; 2675 2665 } 2676 2666 2677 /** \fn TVRec::Change Colour(bool)2678 * \brief Changes the colour phase of a recording.2667 /** \fn TVRec::ChangePictureAttribute(PictureAdjustType,PictureAttribute,bool) 2668 * \brief Changes brightness/contrast/colour/hue of a recording. 2679 2669 * 2680 2670 * Note: In practice this only works with frame grabbing recorders. 2681 2671 * 2682 * \return c olourif it succeeds, -1 otherwise.2672 * \return current value [0,100] if it succeeds, -1 otherwise. 2683 2673 */ 2684 int TVRec::ChangeColour(bool direction) 2674 int TVRec::ChangePictureAttribute(PictureAdjustType type, 2675 PictureAttribute attr, 2676 bool direction) 2685 2677 { 2686 2678 QMutexLocker lock(&stateChangeLock); 2687 2688 2679 if (!channel) 2689 2680 return -1; 2690 2681 2691 int ret = channel->ChangeColour(direction); 2692 return ret; 2693 } 2682 int ret = -1; 2683 if (kPictureAttribute_Brightness == attr) 2684 ret = channel->ChangePictureAttribute(type, "brightness", direction); 2685 else if (kPictureAttribute_Contrast == attr) 2686 ret = channel->ChangePictureAttribute(type, "contrast", direction); 2687 else if (kPictureAttribute_Colour == attr) 2688 ret = channel->ChangePictureAttribute(type, "colour", direction); 2689 else if (kPictureAttribute_Hue == attr) 2690 ret = channel->ChangePictureAttribute(type, "hue", direction); 2694 2691 2695 /** \fn TVRec::ChangeHue(bool) 2696 * \brief Changes the hue of a recording. 2697 * 2698 * Note: In practice this only works with frame grabbing recorders. 2699 * 2700 * \return hue if it succeeds, -1 otherwise. 2701 */ 2702 int TVRec::ChangeHue(bool direction) 2703 { 2704 QMutexLocker lock(&stateChangeLock); 2705 2706 if (!channel) 2692 if (ret < 0) 2707 2693 return -1; 2708 2709 int ret = channel->ChangeHue(direction); 2710 return ret; 2694 return ret / 655; 2711 2695 } 2712 2696 2713 2697 /** \fn TVRec::GetConnectedInputs(void) const … … 3676 3660 #ifdef USING_V4L 3677 3661 if (GetV4LChannel()) 3678 3662 { 3679 channel->SetBrightness(); 3680 channel->SetContrast(); 3681 channel->SetColour(); 3682 channel->SetHue(); 3663 channel->InitPictureAttributes(); 3683 3664 CloseChannel(); 3684 3665 } 3685 3666 #endif -
libs/libmythtv/videooutbase.h
70 70 kCodec_SPECIAL_END, 71 71 }; 72 72 73 enum PictureAttribute74 {75 kPictureAttribute_None = 0,76 kPictureAttribute_MIN = 1,77 kPictureAttribute_Brightness = 1,78 kPictureAttribute_Contrast,79 kPictureAttribute_Colour,80 kPictureAttribute_Hue,81 kPictureAttribute_Volume,82 kPictureAttribute_MAX83 };84 85 73 enum PIPLocations 86 74 { 87 75 kPIPTopLeft = 0, -
libs/libmythtv/tv_rec.h
212 212 void SetChannel(QString name, uint requestType = kFlagDetect); 213 213 214 214 int SetSignalMonitoringRate(int msec, int notifyFrontend = 1); 215 int ChangeColour(bool direction); 216 int ChangeContrast(bool direction); 217 int ChangeBrightness(bool direction); 218 int ChangeHue(bool direction); 215 int GetPictureAttribute(PictureAttribute attr); 216 int ChangePictureAttribute(PictureAdjustType type, PictureAttribute attr, 217 bool direction); 219 218 bool CheckChannel(QString name) const; 220 219 bool ShouldSwitchToAnotherCard(QString chanid); 221 220 bool CheckChannelPrefix(const QString&,uint&,bool&,QString&); -
libs/libmythtv/tv.cpp
1 #include <algorithm> 2 using namespace std; 3 1 4 #include "tv.h" 5 #include "tv_play.h" 6 #include "tv_rec.h" 2 7 3 8 /** \fn StateToString(TVState state) 4 9 * \brief Returns a human readable QString representing a TVState. … … 19 24 } 20 25 return statestr; 21 26 } 27 28 QString toTypeString(PictureAdjustType type) 29 { 30 const QString kPicAdjType[] = 31 { 32 "", 33 "", 34 QObject::tr("(CH)"), 35 QObject::tr("(REC)"), 36 }; 37 38 return kPicAdjType[(int)type & 0x3]; 39 } 40 41 QString toTitleString(PictureAdjustType type) 42 { 43 const QString kPicAdjTitles[] = 44 { 45 "", 46 QObject::tr("Adjust Playback"), 47 QObject::tr("Adjust Recorder"), 48 QObject::tr("Adjust Recorder"), 49 }; 50 51 return kPicAdjTitles[(int)type & 0x3]; 52 } 53 54 QString toString(PictureAttribute index) 55 { 56 const QString tbl[] = 57 { 58 QObject::tr("None"), 59 QObject::tr("Brightness"), 60 QObject::tr("Contrast"), 61 QObject::tr("Colour"), 62 QObject::tr("Hue"), 63 QObject::tr("Volume"), 64 QObject::tr("MAX"), 65 }; 66 67 int i = (int)index; 68 i = max(i, (int) kPictureAttribute_None); 69 i = min(i, (int) kPictureAttribute_MAX); 70 71 return tbl[i]; 72 } -
libs/libmythtv/dbox2channel.cpp
17 17 #include "dbox2channel.h" 18 18 #include "dbox2recorder.h" 19 19 #include "dbox2epg.h" 20 #include "tv_rec.h"21 20 22 21 //#define DBOX2_CHANNEL_DEBUG 23 22 -
libs/libmythtv/channel.cpp
23 23 #include "videodev_myth.h" 24 24 #include "channel.h" 25 25 #include "frequencies.h" 26 #include "tv .h"26 #include "tv_rec.h" 27 27 #include "mythcontext.h" 28 28 #include "mythdbcon.h" 29 29 #include "channelutil.h" 30 30 #include "cardutil.h" 31 31 32 #define DEBUG_ATTRIB 1 33 32 34 #define LOC QString("Channel(%1): ").arg(device) 33 35 #define LOC_ERR QString("Channel(%1) Error: ").arg(device) 34 36 … … 41 43 */ 42 44 43 45 Channel::Channel(TVRec *parent, const QString &videodevice) 44 : ChannelBase(parent), device(videodevice), videofd(-1), 45 curList(NULL), totalChannels(0), 46 currentFormat(""), is_dtv(false), usingv4l2(false), 47 defaultFreqTable(1) 46 : ChannelBase(parent), 47 device(videodevice), videofd(-1), 48 device_name(QString::null), driver_name(QString::null), 49 curList(NULL), totalChannels(0), 50 currentFormat(""), is_dtv(false), 51 usingv4l2(false), defaultFreqTable(1) 48 52 { 49 53 } 50 54 … … 71 75 } 72 76 73 77 usingv4l2 = CardUtil::hasV4L2(videofd); 78 CardUtil::GetV4LInfo(videofd, device_name, driver_name); 79 VERBOSE(VB_CHANNEL, LOC + QString("Device name '%1' driver '%2'.") 80 .arg(device_name).arg(driver_name)); 74 81 75 82 if (!InitializeInputs()) 76 83 { … … 495 502 if (pParent) 496 503 pParent->SetVideoFiltersForChannel(GetCurrentSourceID(), chan); 497 504 498 SetContrast(); 499 SetColour(); 500 SetBrightness(); 501 SetHue(); 505 InitPictureAttributes(); 502 506 503 507 inputs[currentInputID]->startChanNum = curchannelname; 504 508 … … 903 907 return ok; 904 908 } 905 909 906 unsigned short *Channel::GetV4L1Field(int attrib, struct video_picture &vid_pic) 910 static unsigned short *get_v4l1_field( 911 int v4l2_attrib, struct video_picture &vid_pic) 907 912 { 908 switch ( attrib)913 switch (v4l2_attrib) 909 914 { 910 915 case V4L2_CID_CONTRAST: 911 916 return &vid_pic.contrast; … … 916 921 case V4L2_CID_HUE: 917 922 return &vid_pic.hue; 918 923 default: 919 VERBOSE(VB_IMPORTANT, 920 QString("Channel(%1)::SetColourAttribute(): " 921 "invalid attribute argument: %2\n"). 922 arg(device).arg(attrib)); 924 VERBOSE(VB_IMPORTANT, "get_v4l1_field: " 925 "invalid attribute argument "<<v4l2_attrib); 923 926 } 924 927 return NULL; 925 928 } 926 929 927 void Channel::SetColourAttribute(int attrib, const char *name)930 static int get_v4l2_attribute(const QString &db_col_name) 928 931 { 932 if ("brightness" == db_col_name) 933 return V4L2_CID_BRIGHTNESS; 934 else if ("contrast" == db_col_name) 935 return V4L2_CID_SATURATION; 936 else if ("colour" == db_col_name) 937 return V4L2_CID_SATURATION; 938 else if ("hue" == db_col_name) 939 return V4L2_CID_HUE; 940 return -1; 941 } 942 943 bool Channel::InitPictureAttribute(const QString db_col_name) 944 { 929 945 if (!pParent || is_dtv) 930 return ;946 return false; 931 947 932 QString field_name = name;933 i nt field = ChannelUtil::GetChannelValueInt(934 field_name, GetCurrentSourceID(), curchannelname);948 int v4l2_attrib = get_v4l2_attribute(db_col_name); 949 if (v4l2_attrib == -1) 950 return false; 935 951 952 int cfield = ChannelUtil::GetChannelValueInt( 953 db_col_name, GetCurrentSourceID(), curchannelname); 954 int sfield = CardUtil::GetValueInt( 955 db_col_name, GetCardID(), GetCurrentSourceID()); 956 957 if ((cfield == -1) || (sfield == -1)) 958 return false; 959 960 int field = (cfield + sfield) & 0xFFFF; 961 962 QString loc = LOC + 963 QString("InitPictureAttribute(%1): ").arg(db_col_name, 10); 964 QString loc_err = LOC_ERR + 965 QString("InitPictureAttribute(%1): ").arg(db_col_name, 10); 966 936 967 if (usingv4l2) 937 968 { 938 969 struct v4l2_control ctrl; 939 970 struct v4l2_queryctrl qctrl; 940 memset(&ctrl, 0, sizeof(ctrl));941 memset(&qctrl, 0, sizeof(qctrl));971 bzero(&ctrl, sizeof(ctrl)); 972 bzero(&qctrl, sizeof(qctrl)); 942 973 943 if (field != -1) 974 ctrl.id = qctrl.id = v4l2_attrib; 975 if (ioctl(videofd, VIDIOC_QUERYCTRL, &qctrl) < 0) 944 976 { 945 ctrl.id = qctrl.id = attrib; 946 if (ioctl(videofd, VIDIOC_QUERYCTRL, &qctrl) < 0) 977 VERBOSE(VB_IMPORTANT, loc_err + "failed to query controls." + ENO); 978 return false; 979 } 980 981 float new_range = qctrl.maximum - qctrl.minimum; 982 float old_range = 65535 - 0; 983 float scl_range = new_range / old_range; 984 float dfl = (qctrl.default_value - qctrl.minimum) / new_range; 985 int norm_dfl = (0x10000 + (int)(dfl * old_range) - 32768) & 0xFFFF; 986 987 if (pict_attr_default.find(db_col_name) == pict_attr_default.end()) 988 { 989 if (device_name == "pcHDTV HD3000 HDTV") 947 990 { 948 VERBOSE(VB_IMPORTANT, 949 QString("Channel(%1)::SetColourAttribute(): " 950 "failed to query controls, error: %2"). 951 arg(device).arg(strerror(errno))); 952 return; 991 pict_attr_default["brightness"] = 9830; 992 pict_attr_default["contrast"] = 39322; 993 pict_attr_default["colour"] = 45875; 994 pict_attr_default["hue"] = 0; 953 995 } 954 ctrl.value = (int)((qctrl.maximum - qctrl.minimum) 955 / 65535.0 * field + qctrl.minimum); 956 ctrl.value = ctrl.value > qctrl.maximum 957 ? qctrl.maximum 958 : ctrl.value < qctrl.minimum 959 ? qctrl.minimum 960 : ctrl.value; 961 if (ioctl(videofd, VIDIOC_S_CTRL, &ctrl) < 0) 996 else 962 997 { 963 VERBOSE(VB_IMPORTANT, 964 QString("Channel(%1)::SetColourAttribute(): " 965 "failed to set controls, error: %2"). 966 arg(device).arg(strerror(errno))); 967 return; 998 pict_attr_default[db_col_name] = norm_dfl; 968 999 } 969 1000 } 970 }971 else972 {973 unsigned short *setfield;974 struct video_picture vid_pic;975 memset(&vid_pic, 0, sizeof(vid_pic));976 1001 977 if (ioctl(videofd, VIDIOCGPICT, &vid_pic) < 0) 1002 int dfield = pict_attr_default[db_col_name]; 1003 field = (cfield + sfield + dfield) & 0xFFFF; 1004 int value0 = (int) ((scl_range * field) + qctrl.minimum); 1005 int value1 = min(value0, (int)qctrl.maximum); 1006 ctrl.value = max(value1, (int)qctrl.minimum); 1007 1008 #if DEBUG_ATTRIB 1009 VERBOSE(VB_CHANNEL, loc + QString("\n\t\t\t[%1,%2] dflt(%3, %4, %5)") 1010 .arg(qctrl.minimum, 5).arg(qctrl.maximum, 5) 1011 .arg(qctrl.default_value, 5).arg(dfl, 4, 'f', 2) 1012 .arg(norm_dfl)); 1013 #endif 1014 1015 if (ioctl(videofd, VIDIOC_S_CTRL, &ctrl) < 0) 978 1016 { 979 VERBOSE(VB_IMPORTANT, 980 QString("Channel(%1)::SetColourAttribute(): failed " 981 "to get picture controls, error: %2"). 982 arg(device).arg(strerror(errno))); 983 return; 1017 VERBOSE(VB_IMPORTANT, loc_err + "failed to set controls" + ENO); 1018 return false; 984 1019 } 985 setfield = GetV4L1Field(attrib, vid_pic); 986 if (field != -1 && setfield) 987 { 988 *setfield = field; 989 if (ioctl(videofd, VIDIOCSPICT, &vid_pic) < 0) 990 { 991 VERBOSE(VB_IMPORTANT, 992 QString("Channel(%1)::SetColourAttribute(): failed " 993 "to set picture controls, error: %2"). 994 arg(device).arg(strerror(errno))); 995 return; 996 } 997 } 1020 1021 return true; 998 1022 } 999 return; 1023 1024 // V4L1 1025 unsigned short *setfield; 1026 struct video_picture vid_pic; 1027 bzero(&vid_pic, sizeof(vid_pic)); 1028 1029 if (ioctl(videofd, VIDIOCGPICT, &vid_pic) < 0) 1030 { 1031 VERBOSE(VB_IMPORTANT, loc_err + "failed to query controls." + ENO); 1032 return false; 1033 } 1034 setfield = get_v4l1_field(v4l2_attrib, vid_pic); 1035 1036 if (!setfield) 1037 return false; 1038 1039 *setfield = field; 1040 if (ioctl(videofd, VIDIOCSPICT, &vid_pic) < 0) 1041 { 1042 VERBOSE(VB_IMPORTANT, loc_err + "failed to set controls." + ENO); 1043 return false; 1044 } 1045 1046 return true; 1000 1047 } 1001 1048 1002 void Channel::SetContrast(void)1049 bool Channel::InitPictureAttributes(void) 1003 1050 { 1004 SetColourAttribute(V4L2_CID_CONTRAST, "contrast"); 1005 return; 1051 return (InitPictureAttribute("brightness") && 1052 InitPictureAttribute("contrast") && 1053 InitPictureAttribute("colour") && 1054 InitPictureAttribute("hue")); 1006 1055 } 1007 1056 1008 void Channel::SetBrightness() 1057 int Channel::GetPictureAttribute(const QString db_col_name) const 1009 1058 { 1010 SetColourAttribute(V4L2_CID_BRIGHTNESS, "brightness"); 1011 return; 1012 } 1059 int cfield = ChannelUtil::GetChannelValueInt( 1060 db_col_name, GetCurrentSourceID(), curchannelname); 1061 int sfield = CardUtil::GetValueInt( 1062 db_col_name, GetCardID(), GetCurrentSourceID()); 1063 int dfield = 0; 1013 1064 1014 void Channel::SetColour() 1015 { 1016 SetColourAttribute(V4L2_CID_SATURATION, "colour"); 1017 return; 1065 if (pict_attr_default.find(db_col_name) != pict_attr_default.end()) 1066 dfield = pict_attr_default[db_col_name]; 1067 1068 int val = (cfield + sfield + dfield) & 0xFFFF; 1069 1070 #if DEBUG_ATTRIB 1071 VERBOSE(VB_CHANNEL, QString( 1072 "GetPictureAttribute(%1) -> cdb %2 rdb %3 d %4 -> %5") 1073 .arg(db_col_name).arg(cfield).arg(sfield) 1074 .arg(dfield).arg(val)); 1075 #endif 1076 1077 return val; 1018 1078 } 1019 1079 1020 void Channel::SetHue(void)1080 static int get_v4l2_attribute_value(int videofd, int v4l2_attrib) 1021 1081 { 1022 SetColourAttribute(V4L2_CID_HUE, "hue"); 1023 return; 1024 } 1082 struct v4l2_control ctrl; 1083 struct v4l2_queryctrl qctrl; 1084 bzero(&ctrl, sizeof(ctrl)); 1085 bzero(&qctrl, sizeof(qctrl)); 1025 1086 1026 int Channel::ChangeColourAttribute(int attrib, const char *name, bool up) 1027 { 1028 if (!pParent || is_dtv) 1087 ctrl.id = qctrl.id = v4l2_attrib; 1088 if (ioctl(videofd, VIDIOC_QUERYCTRL, &qctrl) < 0) 1089 { 1090 VERBOSE(VB_IMPORTANT, "get_v4l2_attribute_value: " 1091 "failed to query controls (1)" + ENO); 1029 1092 return -1; 1093 } 1030 1094 1031 int newvalue; // The int should have ample space to avoid overflow 1032 // in the case that we're just over or under 65535 1095 if (ioctl(videofd, VIDIOC_G_CTRL, &ctrl) < 0) 1096 { 1097 VERBOSE(VB_IMPORTANT, "get_v4l2_attribute_value: " 1098 "failed to get controls (2)" + ENO); 1099 return -1; 1100 } 1033 1101 1034 QString channel_field = name; 1035 int current_value = ChannelUtil::GetChannelValueInt( 1036 channel_field, GetCurrentSourceID(), curchannelname); 1102 return (int)(65535.0 / (qctrl.maximum - qctrl.minimum) * ctrl.value); 1103 } 1037 1104 1038 int card_value; 1105 static int get_v4l1_attribute_value(int videofd, int v4l2_attrib) 1106 { 1107 struct video_picture vid_pic; 1108 bzero(&vid_pic, sizeof(vid_pic)); 1039 1109 1040 if ( usingv4l2)1110 if (ioctl(videofd, VIDIOCGPICT, &vid_pic) < 0) 1041 1111 { 1042 struct v4l2_control ctrl;1043 struct v4l2_queryctrl qctrl;1044 memset(&ctrl, 0, sizeof(ctrl));1045 memset(&qctrl, 0, sizeof(qctrl));1112 VERBOSE(VB_IMPORTANT, "get_v4l1_attribute_value: " 1113 "failed to get picture control (1)" + ENO); 1114 return -1; 1115 } 1046 1116 1047 ctrl.id = qctrl.id = attrib; 1048 if (ioctl(videofd, VIDIOC_QUERYCTRL, &qctrl) < 0) 1049 { 1050 VERBOSE(VB_IMPORTANT, 1051 QString("Channel(%1)::ChangeColourAttribute(): " 1052 "failed to query controls (1), error: %2"). 1053 arg(device).arg(strerror(errno))); 1054 return -1; 1055 } 1117 unsigned short *setfield = get_v4l1_field(v4l2_attrib, vid_pic); 1118 if (setfield) 1119 return *setfield; 1056 1120 1057 if (ioctl(videofd, VIDIOC_G_CTRL, &ctrl) < 0) 1058 { 1059 VERBOSE(VB_IMPORTANT, 1060 QString("Channel(%1)::ChangeColourAttribute(): " 1061 "failed to get control, error: %2"). 1062 arg(device).arg(strerror(errno))); 1063 return -1; 1064 } 1065 card_value = (int)(65535.0 / (qctrl.maximum - qctrl.minimum) * 1066 ctrl.value); 1067 } 1068 else 1069 { 1070 unsigned short *setfield; 1071 struct video_picture vid_pic; 1072 memset(&vid_pic, 0, sizeof(vid_pic)); 1121 return -1; 1122 } 1073 1123 1074 if (ioctl(videofd, VIDIOCGPICT, &vid_pic) < 0) 1075 { 1076 VERBOSE(VB_IMPORTANT, 1077 QString("Channel(%1)::ChangeColourAttribute(): " 1078 "failed to get picture control (1), error: %2"). 1079 arg(device).arg(strerror(errno))); 1080 return -1; 1081 } 1124 static int get_attribute_value(bool usingv4l2, int videofd, int v4l2_attrib) 1125 { 1126 if (usingv4l2) 1127 return get_v4l2_attribute_value(videofd, v4l2_attrib); 1128 return get_v4l1_attribute_value(videofd, v4l2_attrib); 1129 } 1082 1130 1083 setfield = GetV4L1Field(attrib, vid_pic); 1084 if (!setfield) 1085 { 1086 return -1; 1087 } 1131 static int set_v4l2_attribute_value(int videofd, int v4l2_attrib, int newvalue) 1132 { 1133 struct v4l2_control ctrl; 1134 struct v4l2_queryctrl qctrl; 1135 bzero(&ctrl, sizeof(ctrl)); 1136 bzero(&qctrl, sizeof(qctrl)); 1088 1137 1089 card_value = *setfield; 1138 ctrl.id = qctrl.id = v4l2_attrib; 1139 if (ioctl(videofd, VIDIOC_QUERYCTRL, &qctrl) < 0) 1140 { 1141 VERBOSE(VB_IMPORTANT, "set_v4l2_attribute_value: " 1142 "failed to query control" + ENO); 1143 return -1; 1090 1144 } 1091 1145 1092 newvalue = (current_value < 0) ? card_value : current_value; 1093 newvalue += (up) ? 655 : -655; 1146 float mult = (qctrl.maximum - qctrl.minimum) / 65535.0; 1147 ctrl.value = (int)(mult * newvalue + qctrl.minimum); 1148 ctrl.value = min(ctrl.value, qctrl.maximum); 1149 ctrl.value = max(ctrl.value, qctrl.minimum); 1094 1150 1095 if ( V4L2_CID_HUE == attrib)1151 if (ioctl(videofd, VIDIOC_S_CTRL, &ctrl) < 0) 1096 1152 { 1097 // wrap around for hue1098 newvalue = (newvalue > 65535) ? newvalue - 65535 : newvalue;1099 newvalue = (newvalue < 0) ? newvalue + 65535 : newvalue;1153 VERBOSE(VB_IMPORTANT, "set_v4l2_attribute_value: " 1154 "failed to set control" + ENO); 1155 return -1; 1100 1156 } 1101 1157 1102 // make sure we are within bounds 1103 newvalue = min(newvalue, 65535); 1104 newvalue = max(newvalue, 0); 1158 return 0; 1159 } 1105 1160 1106 if (current_value >= 0) 1161 static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue) 1162 { 1163 unsigned short *setfield; 1164 struct video_picture vid_pic; 1165 bzero(&vid_pic, sizeof(vid_pic)); 1166 1167 if (ioctl(videofd, VIDIOCGPICT, &vid_pic) < 0) 1107 1168 { 1108 // tell the DB about the new attributes1109 ChannelUtil::SetChannelValue(channel_field, QString::number(newvalue),1110 GetCurrentSourceID(), curchannelname);1169 VERBOSE(VB_IMPORTANT, "set_v4l1_attribute_value: " 1170 "failed to get picture control." + ENO); 1171 return -1; 1111 1172 } 1112 1113 if ( usingv4l2)1173 setfield = get_v4l1_field(v4l2_attrib, vid_pic); 1174 if (newvalue != -1 && setfield) 1114 1175 { 1115 struct v4l2_control ctrl; 1116 struct v4l2_queryctrl qctrl; 1117 memset(&ctrl, 0, sizeof(ctrl)); 1118 memset(&qctrl, 0, sizeof(qctrl)); 1119 1120 ctrl.id = qctrl.id = attrib; 1121 if (ioctl(videofd, VIDIOC_QUERYCTRL, &qctrl) < 0) 1176 *setfield = newvalue; 1177 if (ioctl(videofd, VIDIOCSPICT, &vid_pic) < 0) 1122 1178 { 1123 VERBOSE(VB_IMPORTANT, 1124 QString("Channel(%1)::ChangeColourAttribute(): " 1125 "failed to query controls (2), error: %2"). 1126 arg(device).arg(strerror(errno))); 1179 VERBOSE(VB_IMPORTANT, "set_v4l1_attribute_value: " 1180 "failed to set picture control." + ENO); 1127 1181 return -1; 1128 1182 } 1129 float mult = (qctrl.maximum - qctrl.minimum) / 65535.0;1130 ctrl.value = (int)(mult * newvalue + qctrl.minimum);1131 ctrl.value = min(ctrl.value, qctrl.maximum);1132 ctrl.value = max(ctrl.value, qctrl.minimum);1133 1134 if (ioctl(videofd, VIDIOC_S_CTRL, &ctrl) < 0)1135 {1136 VERBOSE(VB_IMPORTANT,1137 QString("Channel(%1)::ChangeColourAttribute(): "1138 "failed to set control, error: %2").1139 arg(device).arg(strerror(errno)));1140 return -1;1141 }1142 1183 } 1143 1184 else 1144 1185 { 1145 unsigned short *setfield; 1146 struct video_picture vid_pic; 1147 memset(&vid_pic, 0, sizeof(vid_pic)); 1148 1149 if (ioctl(videofd, VIDIOCGPICT, &vid_pic) < 0) 1150 { 1151 VERBOSE(VB_IMPORTANT, 1152 QString("Channel(%1)::ChangeColourAttribute(): " 1153 "failed to get picture control (2), error: %2"). 1154 arg(device).arg(strerror(errno))); 1155 return -1; 1156 } 1157 setfield = GetV4L1Field(attrib, vid_pic); 1158 if (newvalue != -1 && setfield) 1159 { 1160 *setfield = newvalue; 1161 if (ioctl(videofd, VIDIOCSPICT, &vid_pic) < 0) 1162 { 1163 VERBOSE(VB_IMPORTANT, 1164 QString("Channel(%1)::ChangeColourAttribute(): " 1165 "failed to set picture control, error: %2"). 1166 arg(device).arg(strerror(errno))); 1167 return -1; 1168 } 1169 } 1170 else 1171 { 1172 // ??? 1173 return -1; 1174 } 1186 // ??? 1187 return -1; 1175 1188 } 1176 1189 1177 return newvalue / 655;1190 return 0; 1178 1191 } 1179 1192 1180 int Channel::ChangeContrast(bool up) 1193 static int set_attribute_value(bool usingv4l2, int videofd, 1194 int v4l2_attrib, int newvalue) 1181 1195 { 1182 return ChangeColourAttribute(V4L2_CID_CONTRAST, "contrast", up); 1196 if (usingv4l2) 1197 return set_v4l2_attribute_value(videofd, v4l2_attrib, newvalue); 1198 return set_v4l1_attribute_value(videofd, v4l2_attrib, newvalue); 1183 1199 } 1184 1200 1185 int Channel::ChangeBrightness(bool up) 1201 int Channel::ChangePictureAttribute( 1202 int type, const QString db_col_name, bool up) 1186 1203 { 1187 return ChangeColourAttribute(V4L2_CID_BRIGHTNESS, "brightness", up);1188 } 1204 if (!pParent || is_dtv) 1205 return -1; 1189 1206 1190 int Channel::ChangeColour(bool up) 1191 { 1192 return ChangeColourAttribute(V4L2_CID_SATURATION, "colour", up); 1193 } 1207 int v4l2_attrib = get_v4l2_attribute(db_col_name); 1208 if (v4l2_attrib == -1) 1209 return -1; 1194 1210 1195 int Channel::ChangeHue(bool up) 1196 { 1197 return ChangeColourAttribute(V4L2_CID_HUE, "hue", up); 1211 // get the old attribute value from the hardware, this is 1212 // just a sanity check on whether this attribute exists 1213 if (get_attribute_value(usingv4l2, videofd, v4l2_attrib) < 0) 1214 return -1; 1215 1216 int old_value = GetPictureAttribute(db_col_name); 1217 int new_value = old_value + ((up) ? 655 : -655); 1218 1219 // make sure we are within bounds (wrap around for hue) 1220 if (V4L2_CID_HUE == v4l2_attrib) 1221 new_value &= 0xffff; 1222 new_value = min(max(new_value, 0), 65535); 1223 1224 #if DEBUG_ATTRIB 1225 VERBOSE(VB_CHANNEL, QString( 1226 "ChangePictureAttribute(%1,%2,%3) cur %4 -> new %5") 1227 .arg(type).arg(db_col_name).arg(up) 1228 .arg(old_value).arg(new_value)); 1229 #endif 1230 1231 // actually set the new attribute value on the hardware 1232 if (set_attribute_value(usingv4l2, videofd, v4l2_attrib, new_value) < 0) 1233 return -1; 1234 1235 // tell the DB about the new attribute value 1236 if (kAdjustingPicture_Channel == type) 1237 { 1238 int adj_value = ChannelUtil::GetChannelValueInt( 1239 db_col_name, GetCurrentSourceID(), curchannelname); 1240 1241 int tmp = new_value - old_value + adj_value; 1242 tmp = (tmp < 0) ? tmp + 0x10000 : tmp; 1243 tmp = (tmp > 0xffff) ? tmp - 0x10000 : tmp; 1244 ChannelUtil::SetChannelValue(db_col_name, QString::number(tmp), 1245 GetCurrentSourceID(), curchannelname); 1246 } 1247 else if (kAdjustingPicture_Recording == type) 1248 { 1249 int adj_value = CardUtil::GetValueInt( 1250 db_col_name, GetCardID(), GetCurrentSourceID()); 1251 1252 int tmp = new_value - old_value + adj_value; 1253 tmp = (tmp < 0) ? tmp + 0x10000 : tmp; 1254 tmp = (tmp > 0xffff) ? tmp - 0x10000 : tmp; 1255 CardUtil::SetValue(db_col_name, GetCardID(), 1256 GetCurrentSourceID(), tmp); 1257 } 1258 1259 return new_value; 1198 1260 } 1199 -
libs/libmyth/mythcontext.h
229 229 * You must also update this value in 230 230 * mythplugins/mythweb/includes/mythbackend.php 231 231 */ 232 #define MYTH_PROTO_VERSION " 29"232 #define MYTH_PROTO_VERSION "30" 233 233 234 234 /** \class MythContext 235 235 * \brief This class contains the runtime context for MythTV. -
programs/mythfrontend/manualbox.h
9 9 10 10 #include <pthread.h> 11 11 12 class TV; 12 13 class QListViewItem; 13 14 class QLabel; 14 15 class QProgressBar; -
programs/mythbackend/encoderlink.h
4 4 #include <qstring.h> 5 5 6 6 #include "tv.h" 7 #include "programinfo.h" 7 8 9 class TVRec; 8 10 class MainServer; 9 11 class PlaybackSock; 10 12 class LiveTVChain; … … 82 84 void ToggleChannelFavorite(void); 83 85 void ChangeChannel(int channeldirection); 84 86 void SetChannel(const QString &name); 85 int ChangeContrast(bool direction);86 int ChangeBrightness(bool direction);87 int ChangeColour(bool direction);88 int ChangeHue(booldirection);87 int GetPictureAttribute(PictureAttribute attr); 88 int ChangePictureAttribute(PictureAdjustType type, 89 PictureAttribute attr, 90 bool direction); 89 91 bool CheckChannel(const QString &name); 90 92 bool ShouldSwitchToAnotherCard(const QString &channelid); 91 93 bool CheckChannelPrefix(const QString&,uint&,bool&,QString&); -
programs/mythbackend/mainserver.cpp
2563 2563 int oldrate = enc->SetSignalMonitoringRate(rate, notifyFrontend); 2564 2564 retlist << QString::number(oldrate); 2565 2565 } 2566 else if (command == "GET_COLOUR") 2567 { 2568 int ret = enc->GetPictureAttribute(kPictureAttribute_Colour); 2569 retlist << QString::number(ret); 2570 } 2571 else if (command == "GET_CONTRAST") 2572 { 2573 int ret = enc->GetPictureAttribute(kPictureAttribute_Contrast); 2574 retlist << QString::number(ret); 2575 } 2576 else if (command == "GET_BRIGHTNESS") 2577 { 2578 int ret = enc->GetPictureAttribute(kPictureAttribute_Brightness); 2579 retlist << QString::number(ret); 2580 } 2581 else if (command == "GET_HUE") 2582 { 2583 int ret = enc->GetPictureAttribute(kPictureAttribute_Hue); 2584 retlist << QString::number(ret); 2585 } 2566 2586 else if (command == "CHANGE_COLOUR") 2567 2587 { 2568 bool up = slist[2].toInt(); 2569 retlist << QString::number(enc->ChangeColour(up)); 2588 int type = slist[2].toInt(); 2589 bool up = slist[3].toInt(); 2590 int ret = enc->ChangePictureAttribute( 2591 (PictureAdjustType) type, kPictureAttribute_Colour, up); 2592 retlist << QString::number(ret); 2570 2593 } 2571 2594 else if (command == "CHANGE_CONTRAST") 2572 2595 { 2573 bool up = slist[2].toInt(); 2574 retlist << QString::number(enc->ChangeContrast(up)); 2596 int type = slist[2].toInt(); 2597 bool up = slist[3].toInt(); 2598 int ret = enc->ChangePictureAttribute( 2599 (PictureAdjustType) type, kPictureAttribute_Contrast, up); 2600 retlist << QString::number(ret); 2575 2601 } 2576 2602 else if (command == "CHANGE_BRIGHTNESS") 2577 2603 { 2578 bool up = slist[2].toInt(); 2579 retlist << QString::number(enc->ChangeBrightness(up)); 2604 int type= slist[2].toInt(); 2605 bool up = slist[3].toInt(); 2606 int ret = enc->ChangePictureAttribute( 2607 (PictureAdjustType) type, kPictureAttribute_Brightness, up); 2608 retlist << QString::number(ret); 2580 2609 } 2581 2610 else if (command == "CHANGE_HUE") 2582 2611 { 2583 bool up = slist[2].toInt(); 2584 retlist << QString::number(enc->ChangeHue(up)); 2612 int type= slist[2].toInt(); 2613 bool up = slist[3].toInt(); 2614 int ret = enc->ChangePictureAttribute( 2615 (PictureAdjustType) type, kPictureAttribute_Hue, up); 2616 retlist << QString::number(ret); 2585 2617 } 2586 2618 else if (command == "CHECK_CHANNEL") 2587 2619 { -
programs/mythbackend/scheduler.cpp
25 25 #include "encoderlink.h" 26 26 #include "mainserver.h" 27 27 #include "remoteutil.h" 28 #include "libmyth/util.h" 28 29 #include "libmyth/exitcodes.h" 29 30 #include "libmyth/mythcontext.h" 30 31 #include "libmyth/mythdbcon.h" -
programs/mythbackend/main.cpp
2 2 #include <qsqldatabase.h> 3 3 #include <qfile.h> 4 4 #include <qmap.h> 5 #include <qregexp.h> 5 6 #include <unistd.h> 6 7 #include <sys/types.h> 7 8 #include <sys/stat.h> … … 19 20 #include <fstream> 20 21 using namespace std; 21 22 22 #include "tv .h"23 #include "tv_rec.h" 23 24 #include "autoexpire.h" 24 25 #include "scheduler.h" 25 26 #include "mainserver.h" -
programs/mythbackend/encoderlink.cpp
9 9 #include "mythcontext.h" 10 10 #include "encoderlink.h" 11 11 #include "playbacksock.h" 12 #include "tv .h"12 #include "tv_rec.h" 13 13 #include "programinfo.h" 14 14 #include "util.h" 15 15 #include "previewgenerator.h" … … 750 750 VERBOSE(VB_IMPORTANT, "Should be local only query: SetChannel"); 751 751 } 752 752 753 /** \fn EncoderLink:: ChangeContrast(bool)754 * \brief Changes contrastof a recording.753 /** \fn EncoderLink::GetPictureAttribute(PictureAttribute) 754 * \brief Changes brightness/contrast/colour/hue of a recording. 755 755 * <b>This only works on local recorders.</b> 756 756 * 757 757 * Note: In practice this only works with frame grabbing recorders. 758 758 * 759 * \return c ontrastif it succeeds, -1 otherwise.759 * \return current value if it succeeds, -1 otherwise. 760 760 */ 761 int EncoderLink:: ChangeContrast(bool direction)761 int EncoderLink::GetPictureAttribute(PictureAttribute attr) 762 762 { 763 int ret = -1; 763 if (!local) 764 { 765 VERBOSE(VB_IMPORTANT, "Should be local only query: " 766 "GetPictureAttribute"); 767 return -1; 768 } 764 769 765 if (local) 766 ret = tv->ChangeContrast(direction); 767 else 768 VERBOSE(VB_IMPORTANT, "Should be local only query: ChangeContrast"); 769 770 return ret; 770 return tv->GetPictureAttribute(attr); 771 771 } 772 772 773 /** \fn EncoderLink::Change Brightness(bool)774 * \brief Changes the brightnessof a recording.773 /** \fn EncoderLink::ChangePictureAttribute(PictureAdjustType,PictureAttribute,bool) 774 * \brief Changes brightness/contrast/colour/hue of a recording. 775 775 * <b>This only works on local recorders.</b> 776 776 * 777 777 * Note: In practice this only works with frame grabbing recorders. 778 778 * 779 * \return brightnessif it succeeds, -1 otherwise.779 * \return current value if it succeeds, -1 otherwise. 780 780 */ 781 int EncoderLink::ChangeBrightness(bool direction) 781 int EncoderLink::ChangePictureAttribute(PictureAdjustType type, 782 PictureAttribute attr, 783 bool direction) 782 784 { 783 int ret = -1; 785 if (!local) 786 { 787 VERBOSE(VB_IMPORTANT, "Should be local only query: " 788 "ChangePictureAttribute"); 789 return -1; 790 } 784 791 785 if (local) 786 ret = tv->ChangeBrightness(direction); 787 else 788 VERBOSE(VB_IMPORTANT, "Should be local only query: ChangeBrightness"); 789 790 return ret; 792 return tv->ChangePictureAttribute(type, attr, direction); 791 793 } 792 794 793 /** \fn EncoderLink::ChangeColour(bool)794 * \brief Changes the colour phase of a recording.795 * <b>This only works on local recorders.</b>796 *797 * Note: In practice this only works with frame grabbing recorders.798 *799 * \return colour if it succeeds, -1 otherwise.800 */801 int EncoderLink::ChangeColour(bool direction)802 {803 int ret = -1;804 805 if (local)806 ret = tv->ChangeColour(direction);807 else808 VERBOSE(VB_IMPORTANT, "Should be local only query: ChangeColor");809 810 return ret;811 }812 813 /** \fn EncoderLink::ChangeHue(bool)814 * \brief Changes the hue of a recording.815 * <b>This only works on local recorders.</b>816 *817 * Note: In practice this only works with frame grabbing recorders.818 *819 * \return hue if it succeeds, -1 otherwise.820 */821 int EncoderLink::ChangeHue(bool direction)822 {823 int ret = -1;824 825 if (local)826 ret = tv->ChangeHue(direction);827 else828 VERBOSE(VB_IMPORTANT, "Should be local only query: ChangeHue");829 830 return ret;831 }832 833 795 /** \fn EncoderLink::CheckChannel(const QString&) 834 796 * \brief Checks if named channel exists on current tuner. 835 797 * <b>This only works on local recorders.</b> -
programs/mythlcdserver/main.cpp
19 19 #include "exitcodes.h" 20 20 #include "mythcontext.h" 21 21 #include "mythdbcon.h" 22 #include "tv_play.h" 22 23 23 24 #include "lcdserver.h" 24 25 -
programs/mythtv/main.cpp
1 #include <unistd.h> 2 1 3 #include <qapplication.h> 2 4 #include <qsqldatabase.h> 3 5 #include <qstring.h> 4 #include <unistd.h> 5 #include "tv.h" 6 #include <qregexp.h> 7 8 #include "tv_play.h" 6 9 #include "programinfo.h" 7 10 8 11 #include "libmyth/exitcodes.h"