Ticket #5932: ResolutionInDB.diff

File ResolutionInDB.diff, 4.9 KB (added by robert.mcnamara@…, 12 years ago)

Adds resolution of recorded material to DB.

  • libs/libmythtv/recorderbase.cpp

     
    240240
    241241    if (rb_changed)
    242242        m_videoAspect = 0;
     243        m_videoWidth = 0;
     244        m_videoHeight = 0;
    243245}
    244246
    245247/** \fn RecorderBase::SavePositionMap(bool)
     
    302304        curRecording->SetAspectChange(mark, frame);
    303305}
    304306
     307void RecorderBase::ResolutionChange(uint width,uint height)
     308{
     309    if (curRecording)
     310        curRecording->SetResolution(width, height);
     311}
     312
     313
    305314/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • libs/libmythtv/dbcheck.cpp

     
    1818#define MINIMUM_DBMS_VERSION 5,0,15
    1919
    2020/// This is the DB schema version expected by the running MythTV instance.
    21 const QString currentDatabaseVersion = "1223";
     21const QString currentDatabaseVersion = "1224";
    2222
    2323static bool UpdateDBVersionNumber(const QString &newnumber);
    2424static bool performActualUpdate(
     
    43024302            return false;
    43034303    }
    43044304
     4305    if (dbver == "1223")
     4306    {
     4307        const char *updates[] = {
     4308"ALTER TABLE `recorded` ADD `width` INT NOT NULL ,",
     4309"ADD `height` INT NOT NULL ;",
     4310NULL
     4311};
     4312        if (!performActualUpdate(updates, "1224", dbver))
     4313            return false;
     4314    }
     4315
    43054316    return true;
    43064317}
    43074318
  • libs/libmythtv/dtvrecorder.cpp

     
    261261    bool hasKeyFrame  = false;
    262262
    263263    uint aspectRatio = 0;
     264    uint height = 0;
     265    uint width = 0;
    264266
    265267    // Scan for PES header codes; specifically picture_start
    266268    // sequence_start (SEQ) and group_start (GOP).
     
    293295
    294296                // Look for aspectRatio changes and store them in the database
    295297                aspectRatio = (bufptr[3] >> 4);
     298
     299                // Get resolution
     300                height = ((bufptr[1] & 0xf) << 8) | bufptr[2];
     301                width = (bufptr[0] <<4) | (bufptr[1]>>4);
     302
    296303                //int frameRate = (bufptr[3] & 0x0000000f);
    297304            }
    298305        }
     
    328335        AspectChange((AspectRatio)aspectRatio, _frames_written_count);
    329336    }
    330337
     338    if ((height > 0) && (height != m_videoHeight))
     339    {
     340        m_videoHeight = height;
     341        ResolutionChange(width, height);
     342    }
     343
    331344    return hasKeyFrame || (_payload_buffer.size() >= (188*50));
    332345}
    333346
  • libs/libmythtv/recorderbase.h

     
    243243     */
    244244    void AspectChange(AspectRatio ratio, long long frame);
    245245
     246    void ResolutionChange(uint width, uint height);
     247
    246248    TVRec         *tvrec;
    247249    RingBuffer    *ringBuffer;
    248250    bool           weMadeBuffer;
     
    259261
    260262    uint           m_videoAspect; // AspectRatio
    261263
     264    uint           m_videoHeight;
     265    uint           m_videoWidth;
     266
    262267    ProgramInfo   *curRecording;
    263268
    264269    // For handling pausing
  • libs/libmythtv/programinfo.h

     
    314314    // Aspect Ratio map
    315315    void SetAspectChange(MarkTypes type, long long frame);
    316316
     317    // Resolution Set
     318    void SetResolution(uint width, uint height);
     319
    317320    // GUI stuff
    318321    void showDetails(void) const;
    319322    void EditRecording(void);
  • libs/libmythtv/programinfo.cpp

     
    29722972        MythDB::DBError("aspect ratio change insert", query);
    29732973}
    29742974
     2975/** \fn ProgramInfo::SetResolution(uint width, uint height)
     2976 *  \brief Store the Resolution in the recorded table
     2977 */
     2978void ProgramInfo::SetResolution(uint width, uint height)
     2979{
     2980    if (isVideo)
     2981        return;
     2982
     2983    MSqlQuery query(MSqlQuery::InitCon());
     2984
     2985    query.prepare("UPDATE recorded SET"
     2986                    " width = :WIDTH,"
     2987                    " height = :HEIGHT WHERE"
     2988                    " chanid = :CHANID AND"
     2989                    " starttime = :STARTTIME;");
     2990    query.bindValue(":CHANID", chanid);
     2991    query.bindValue(":STARTTIME", recstartts);
     2992
     2993    query.bindValue(":WIDTH", width);
     2994    query.bindValue(":HEIGHT", height);
     2995
     2996    if (!query.exec() || !query.isActive())
     2997        MythDB::DBError("Resolution insert", query);
     2998}
     2999
    29753000/** \fn ProgramInfo::ReactivateRecording(void)
    29763001 *  \brief Asks the scheduler to restart this recording if possible.
    29773002 */