Ticket #5734: 5734_transcode_profiles_v2.patch

File 5734_transcode_profiles_v2.patch, 6.6 KB (added by JYA, 14 years ago)

For 0.22-fixes ; applies with trunk #22835

  • libs/libmythtv/recordinginfo.h

     
    6868    void ApplyRecordRecTitleChange(const QString &newTitle,
    6969                                   const QString &newSubtitle);
    7070    void ApplyTranscoderProfileChange(const QString &profile) const;//pi
     71    void ApplyTranscoderProfileChangeById(int);
    7172
    7273    static void signalChange(int recordid);
    7374
  • libs/libmythtv/recordinginfo.cpp

     
    298298    subtitle = newSubtitle;
    299299}
    300300
     301/* \fn RecordingInfo::ApplyTranscoderProfileChangeById(int id)
     302 * \brief Sets the transcoder profile for a recording
     303 * \param profileid is the 'id' field from recordingprofiles table.
     304 */
     305void RecordingInfo::ApplyTranscoderProfileChangeById(int id)
     306{
     307    MSqlQuery query(MSqlQuery::InitCon());
     308
     309    query.prepare("UPDATE recorded "
     310            "SET transcoder = :PROFILEID "
     311            "WHERE chanid = :CHANID "
     312            "AND starttime = :START");
     313    query.bindValue(":PROFILEID",  id);
     314    query.bindValue(":CHANID",  chanid);
     315    query.bindValue(":START",  recstartts);
     316
     317    if (!query.exec())
     318        MythDB::DBError(LOC + "unable to update transcoder "
     319                "in recorded table", query);
     320}
     321
    301322/** \brief Sets the transcoder profile for a recording
    302323 *  \param profile Descriptive name of the profile. ie: Autodetect
    303324 */
  • programs/mythfrontend/playbackbox.cpp

     
    27482748    if (!(m_popupMenu = createPopupMenu(tr("Transcoding profiles"))))
    27492749        return;
    27502750
    2751     m_popupMenu->AddButton(tr("Default"), SLOT(doBeginTranscoding()));
    2752     m_popupMenu->AddButton(tr("Autodetect"),
    2753                                     SLOT(changeProfileAndTranscodeAuto()));
    2754     m_popupMenu->AddButton(tr("High Quality"),
    2755                                     SLOT(changeProfileAndTranscodeHigh()));
    2756     m_popupMenu->AddButton(tr("Medium Quality"),
    2757                                     SLOT(changeProfileAndTranscodeMedium()));
    2758     m_popupMenu->AddButton(tr("Low Quality"),
    2759                                     SLOT(changeProfileAndTranscodeLow()));
     2751    int buttonCount = kDialogCodeListStart;
     2752    m_transcodeProfileMap.clear();
     2753
     2754    m_popupMenu->AddButton(tr("Default"),qVariantFromValue(buttonCount));
     2755    m_transcodeProfileMap.insert(buttonCount++, -1);
     2756
     2757    m_popupMenu->AddButton(tr("Autodetect"),qVariantFromValue(buttonCount));
     2758    m_transcodeProfileMap.insert(buttonCount++, 0);
     2759
     2760    MSqlQuery query(MSqlQuery::InitCon());
     2761    query.prepare("SELECT r.name, r.id "
     2762            "FROM recordingprofiles r, profilegroups p "
     2763            "WHERE p.name = 'Transcoders' "
     2764            "AND r.profilegroup = p.id "
     2765            "AND r.name != 'RTjpeg/MPEG4' "
     2766            "AND r.name != 'MPEG2' ");
     2767
     2768    if (!query.exec())
     2769    {
     2770        MythDB::DBError(LOC + "unable to query transcoders", query);
     2771        return;
     2772    }
     2773
     2774    while (query.next())
     2775    {
     2776        QString transcoder_name = query.value(0).toString();
     2777        int transcoder_id = query.value(1).toInt();
     2778
     2779        // Translatable strings for known profiles
     2780        if (transcoder_name == "High Quality")
     2781            m_popupMenu->AddButton(tr("High Quality"),qVariantFromValue(buttonCount));
     2782        else if (transcoder_name == "Medium Quality")
     2783            m_popupMenu->AddButton(tr("Medium Quality"),qVariantFromValue(buttonCount));
     2784        else if (transcoder_name == "Low Quality")
     2785            m_popupMenu->AddButton(tr("Low Quality"),qVariantFromValue(buttonCount));
     2786        else
     2787            m_popupMenu->AddButton(transcoder_name,qVariantFromValue(buttonCount));
     2788        m_transcodeProfileMap.insert(buttonCount++, transcoder_id);
     2789    }
     2790    m_popupMenu->SetReturnEvent(this, "TRANSCODE");
    27602791}
    27612792
    2762 void PlaybackBox::changeProfileAndTranscode(const QString &profile)
     2793void PlaybackBox::changeProfileAndTranscode(int id)
    27632794{
    2764    ProgramInfo *pginfo = CurrentItem();
     2795    ProgramInfo *pginfo = CurrentItem();
    27652796
    27662797    if (!pginfo)
    27672798        return;
    27682799
    2769     const RecordingInfo ri(*pginfo);
    2770     ri.ApplyTranscoderProfileChange(profile);
    2771     doBeginTranscoding();
     2800    if (m_transcodeProfileMap.contains(id))
     2801    {
     2802        if (m_transcodeProfileMap.value(id) >= 0)
     2803        {
     2804            RecordingInfo ri(*pginfo);
     2805            ri.ApplyTranscoderProfileChangeById(m_transcodeProfileMap.value(id));
     2806        }
     2807        doBeginTranscoding();
     2808    }
    27722809}
    27732810
    27742811void PlaybackBox::showActionPopup(ProgramInfo *pginfo)
     
    36003637
    36013638void PlaybackBox::customEvent(QEvent *event)
    36023639{
     3640    if (event->type() == kMythDialogBoxCompletionEventType)
     3641    {
     3642        DialogCompletionEvent *dce =
     3643        dynamic_cast<DialogCompletionEvent*>(event);
     3644       
     3645        QString resultid= dce->GetId();
     3646       
     3647        if (resultid == "TRANSCODE")
     3648        {
     3649            int profileid = dce->GetData().toInt();
     3650            changeProfileAndTranscode(profileid);
     3651        }
     3652    }
     3653
    36033654    if ((MythEvent::Type)(event->type()) == MythEvent::MythEventMessage)
    36043655    {
    36053656        MythEvent *me = (MythEvent *)event;
  • programs/mythfrontend/playbackbox.h

     
    158158    void showRecordingPopup();
    159159    void showJobPopup();
    160160    void showTranscodingProfiles();
    161     void changeProfileAndTranscode(const QString &profile);
    162     void changeProfileAndTranscodeAuto()
    163              { changeProfileAndTranscode("Autodetect"); }
    164     void changeProfileAndTranscodeHigh()
    165              { changeProfileAndTranscode("High Quality"); }
    166     void changeProfileAndTranscodeMedium()
    167              { changeProfileAndTranscode("Medium Quality"); }
    168     void changeProfileAndTranscodeLow()
    169              { changeProfileAndTranscode("Low Quality"); }
     161    void changeProfileAndTranscode(int id);
    170162    void showStoragePopup();
    171163    void showPlaylistPopup();
    172164    void showPlaylistStoragePopup();
     
    452444    deque<QString>      m_networkControlCommands;
    453445    bool                m_underNetworkControl;
    454446
     447    // Transcoding Profiles Variables//////////////////////////////////////////
     448    QMap<int,int>       m_transcodeProfileMap;
     449
    455450    TV                  *m_player;
    456451};
    457452