Ticket #2497: get_correct_file_extension.patch

File get_correct_file_extension.patch, 3.3 KB (added by anonymous, 18 years ago)
  • libs/libmythtv/tv_rec.cpp

     
    136136      // tvchain
    137137      tvchain(NULL),
    138138      // RingBuffer info
    139       ringBuffer(NULL), rbFilePrefix(""), rbFileExt("mpg")
     139      ringBuffer(NULL), rbFilePrefix("")
    140140{
    141141}
    142142
    143143bool TVRec::CreateChannel(const QString &startchannel)
    144144{
    145     rbFileExt = "mpg";
    146145    bool init_run = false;
    147146    if (genOpt.cardtype == "DVB")
    148147    {
     
    227226        CloseChannel();
    228227        init_run = true;
    229228#endif
    230         if (genOpt.cardtype != "HDTV" && genOpt.cardtype != "MPEG")
    231             rbFileExt = "nuv";
    232229    }
    233230
    234231    if (!init_run)
     
    641638{
    642639    if (!curRec)
    643640        return;
     641       
     642    QString rbFileExt;
     643   
     644    GetChannelFileExtension(curRec, rbFileExt);
    644645
    645646    curRec->StartedRecording(rbFilePrefix, rbFileExt);
    646647    VERBOSE(VB_RECORD, LOC + "StartedRecording("<<curRec<<") fn("
     
    11151116    channel->Close();
    11161117}
    11171118
     1119/** \fn TVRec::GetChannelFileExtension(const ProgramInfo *pi, QString &rbFileExt) const
     1120 *  \brief Returns the file extension for the corresponding recording.
     1121 *  By default, mpg is used.  Only if a V4L card is detected is the extension changed to nuv.
     1122 *  \param chanId Channel
     1123 *  \param fileExt Recording file extension.
     1124 */
     1125bool TVRec::GetChannelFileExtension(const QString& chanId, QString& fileExt) const
     1126{
     1127    QString test;
     1128   
     1129    fileExt = "mpg";
     1130   
     1131    MSqlQuery query(MSqlQuery::InitCon());
     1132    query.prepare("SELECT cc.cardtype "
     1133                    "FROM channel ch "
     1134                    "JOIN cardinput ci "
     1135                      "ON ch.sourceid = ci.sourceid "
     1136                    "JOIN capturecard cc "
     1137                      "ON ( (ci.childcardid <> 0) AND "
     1138                           "(ci.childcardid = cc.cardid) )"
     1139                           "OR "
     1140                         "( (ci.childcardid = 0) AND "
     1141                           "(ci.cardid = cc.cardid) ) "
     1142                  "WHERE ch.chanid = :CHANID");
     1143    query.bindValue(":CHANID", chanId);
     1144   
     1145    if (!query.exec() || !query.isActive())
     1146    {
     1147        MythContext::DBError("GetRecordingFileExtension", query);
     1148        return false;
     1149    }
     1150   
     1151    if (!query.next())
     1152        return false;
     1153       
     1154    test = query.value(0).toString();
     1155    if (test != QString::null)
     1156    {
     1157        if (test == "V4L")
     1158           fileExt = "nuv"; 
     1159    }
     1160   
     1161    return true;
     1162}
     1163
    11181164DBox2Channel *TVRec::GetDBox2Channel(void)
    11191165{
    11201166#ifdef USING_DBOX2
  • libs/libmythtv/tv_rec.h

     
    254254    bool CreateChannel(const QString &startChanNum);
    255255    void InitChannel(const QString &inputname, const QString &startchannel);
    256256    void CloseChannel(void);
     257    bool GetChannelFileExtension(const QString& chanId, QString& fileExt) const;
    257258    DBox2Channel *GetDBox2Channel(void);
    258259    HDHRChannel  *GetHDHRChannel(void);
    259260    DVBChannel   *GetDVBChannel(void);
     
    367368    // RingBuffer info
    368369    RingBuffer  *ringBuffer;
    369370    QString      rbFilePrefix;
    370     QString      rbFileExt;
    371371
    372372  public:
    373373    static const uint kSignalMonitoringRate;