Ticket #11491: mythtv-0.27-serviceapi-recorded-markup.4.patch

File mythtv-0.27-serviceapi-recorded-markup.4.patch, 13.4 KB (added by dev-team@…, 11 years ago)

new patch with no concept of mark type id coming from the db

  • new file mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupInfo.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupInfo.h
    new file mode 100644
    index 0000000..1b00141
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: recordedMarkup.h
     3// Created     : Apr. 17, 2013
     4//
     5// Copyright (c) 2013 Tikinou LLC <dev-team@tikinou.com>
     6//
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef RECORDEDMARKUP_H_
     12#define RECORDEDMARKUP_H_
     13
     14#include <QVariantList>
     15#include <QDateTime>
     16
     17#include "serviceexp.h"
     18#include "datacontracthelper.h"
     19
     20#include "recordedMarkupItem.h"
     21
     22namespace DTC
     23{
     24
     25class SERVICE_PUBLIC RecordedMarkupInfo : public QObject
     26{
     27    Q_OBJECT
     28    Q_CLASSINFO( "version", "1.0" );
     29
     30    // Q_CLASSINFO Used to augment Metadata for properties.
     31    // See datacontracthelper.h for details
     32
     33    Q_CLASSINFO( "Markups", "type=DTC::RecordedMarkupItem");
     34
     35    Q_PROPERTY( int          ChannelId      READ ChannelId       WRITE setChannelId      )
     36    Q_PROPERTY( QDateTime    StartTime      READ StartTime       WRITE setStartTime      )
     37    Q_PROPERTY( int          DurationMs     READ DurationMs      WRITE setDurationMs     )
     38    Q_PROPERTY( int          VideoWidth     READ VideoWidth      WRITE setVideoWidth     )
     39    Q_PROPERTY( int          VideoHeight    READ VideoHeight     WRITE setVideoHeight    )
     40    Q_PROPERTY( int          VideoRate      READ VideoRate       WRITE setVideoRate      )
     41    Q_PROPERTY( int          TotalFrames    READ TotalFrames     WRITE setTotalFrames    )
     42
     43    Q_PROPERTY( QVariantList Markups READ Markups DESIGNABLE true )
     44
     45    PROPERTYIMP       ( int         , ChannelId       )
     46    PROPERTYIMP       ( QDateTime   , StartTime       )
     47    PROPERTYIMP       ( int         , DurationMs      )
     48    PROPERTYIMP       ( int         , VideoWidth      )
     49    PROPERTYIMP       ( int         , VideoHeight     )
     50    PROPERTYIMP       ( int         , VideoRate       )
     51    PROPERTYIMP       ( int         , TotalFrames     )
     52
     53    PROPERTYIMP_RO_REF( QVariantList, Markups )
     54
     55    public:
     56
     57        static void InitializeCustomTypes()
     58        {
     59            qRegisterMetaType< RecordedMarkupInfo   >();
     60            qRegisterMetaType< RecordedMarkupInfo*  >();
     61
     62            RecordedMarkupItem::InitializeCustomTypes();
     63        }
     64
     65    public:
     66
     67        RecordedMarkupInfo(QObject *parent = 0)
     68            : QObject( parent ),
     69              m_DurationMs  ( 0 ),
     70              m_VideoWidth  ( 0 ),
     71              m_VideoHeight ( 0 ),
     72              m_VideoRate   ( 0 ),
     73              m_TotalFrames ( 0 )
     74        {
     75        }
     76
     77        RecordedMarkupInfo( const RecordedMarkupInfo &src )
     78        {
     79            Copy( src );
     80        }
     81
     82        void Copy( const RecordedMarkupInfo &src )
     83        {
     84            m_ChannelId     = src.m_ChannelId      ;
     85            m_StartTime     = src.m_StartTime      ;
     86            m_DurationMs    = src.m_DurationMs     ;
     87            m_VideoWidth    = src.m_VideoWidth     ;
     88            m_VideoHeight   = src.m_VideoHeight    ;
     89            m_VideoRate     = src.m_VideoRate      ;
     90            m_TotalFrames   = src.m_TotalFrames    ;
     91
     92            CopyListContents< RecordedMarkupItem >( this, m_Markups, src.m_Markups );
     93        }
     94
     95        RecordedMarkupItem *AddNewMarkupItem()
     96        {
     97            // We must make sure the object added to the QVariantList has
     98            // a parent of 'this'
     99
     100                RecordedMarkupItem *pObject = new RecordedMarkupItem( this );
     101            m_Markups.append( QVariant::fromValue<QObject *>( pObject ));
     102
     103            return pObject;
     104        }
     105
     106};
     107
     108} // namespace DTC
     109
     110Q_DECLARE_METATYPE( DTC::RecordedMarkupInfo  )
     111Q_DECLARE_METATYPE( DTC::RecordedMarkupInfo* )
     112
     113#endif
  • new file mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupItem.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupItem.h b/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupItem.h
    new file mode 100644
    index 0000000..a6f7a5a
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: recordedMarkupItem.h
     3// Created     : Apr. 17, 2013
     4//
     5// Copyright (c) 2013 Tikinou LLC <dev-team@tikinou.com>
     6//                                         
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef RECORDEDMARKUPITEM_H_
     12#define RECORDEDMARKUPITEM_H_
     13
     14#include "serviceexp.h"
     15#include "datacontracthelper.h"
     16
     17namespace DTC
     18{
     19
     20/////////////////////////////////////////////////////////////////////////////
     21
     22class SERVICE_PUBLIC RecordedMarkupItem : public QObject
     23{
     24    Q_OBJECT
     25    Q_CLASSINFO( "version"    , "1.0" );
     26
     27    Q_PROPERTY( QString         Type            READ Type             WRITE setType           )
     28    Q_PROPERTY( int             Start           READ Start            WRITE setStart          )
     29    Q_PROPERTY( int             End             READ End              WRITE setEnd            )
     30
     31    PROPERTYIMP         ( int        , Start           )
     32    PROPERTYIMP         ( int        , End             )
     33    PROPERTYIMP         ( QString    , Type            )
     34
     35    public:
     36
     37        static void InitializeCustomTypes()
     38        {
     39            qRegisterMetaType< RecordedMarkupItem  >();
     40            qRegisterMetaType< RecordedMarkupItem* >();
     41        }
     42
     43    public:
     44
     45        RecordedMarkupItem(QObject *parent = 0)
     46            : QObject             ( parent ),
     47              m_Start             ( 0             ),
     48              m_End               ( 0             ),
     49              m_Type              ( QString("")   )
     50        {
     51        }
     52       
     53        RecordedMarkupItem( const RecordedMarkupItem &src )
     54        {
     55            Copy( src );
     56        }
     57
     58        void Copy( const RecordedMarkupItem &src )
     59        {
     60                m_Start               = src.m_Start               ;
     61                m_End                 = src.m_End                 ;
     62                m_Type                = src.m_Type                ;
     63        }
     64};
     65
     66} // namespace DTC
     67
     68Q_DECLARE_METATYPE( DTC::RecordedMarkupItem  )
     69Q_DECLARE_METATYPE( DTC::RecordedMarkupItem* )
     70
     71#endif
  • mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro

    diff --git a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro
    index 7373098..c09b23e 100644
    a b  
    4242HEADERS += datacontracts/liveStreamInfo.h        datacontracts/liveStreamInfoList.h
    4343HEADERS += datacontracts/labelValue.h
    4444HEADERS += datacontracts/logMessage.h            datacontracts/logMessageList.h
     45HEADERS += datacontracts/recordedMarkupInfo.h    datacontracts/recordedMarkupItem.h
    4546
    4647SOURCES += service.cpp
    4748
     
    8283incDatacontracts.files += datacontracts/liveStreamInfo.h      datacontracts/liveStreamInfoList.h
    8384incDatacontracts.files += datacontracts/labelValue.h
    8485incDatacontracts.files += datacontracts/logMessage.h          datacontracts/logMessageList.h
     86incDatacontracts.files += datacontracts/recordedMarkupInfo.h    datacontracts/recordedMarkupItem.h
    8587
    8688INSTALLS += inc incServices incDatacontracts
    8789
  • mythtv/libs/libmythservicecontracts/services/dvrServices.h

    diff --git a/mythtv/libs/libmythservicecontracts/services/dvrServices.h b/mythtv/libs/libmythservicecontracts/services/dvrServices.h
    index e97cb88..9e02f55 100644
    a b  
    1818#include "datacontracts/programList.h"
    1919#include "datacontracts/encoderList.h"
    2020#include "datacontracts/recRuleList.h"
     21#include "datacontracts/recordedMarkupInfo.h"
    2122
    2223/////////////////////////////////////////////////////////////////////////////
    2324/////////////////////////////////////////////////////////////////////////////
     
    3839class SERVICE_PUBLIC DvrServices : public Service  //, public QScriptable ???
    3940{
    4041    Q_OBJECT
    41     Q_CLASSINFO( "version"    , "1.7" );
     42    Q_CLASSINFO( "version"    , "1.8" );
    4243    Q_CLASSINFO( "RemoveRecordedItem_Method",                   "POST" )
    4344    Q_CLASSINFO( "AddRecordSchedule_Method",                    "POST" )
    4445    Q_CLASSINFO( "RemoveRecordSchedule_Method",                 "POST" )
     
    5657            DTC::ProgramList::InitializeCustomTypes();
    5758            DTC::EncoderList::InitializeCustomTypes();
    5859            DTC::RecRuleList::InitializeCustomTypes();
     60            DTC::RecordedMarkupInfo::InitializeCustomTypes();
    5961        }
    6062
    6163    public slots:
     
    8082        virtual bool               RemoveRecorded        ( int              ChanId,
    8183                                                           const QDateTime &StartTime  ) = 0;
    8284
     85        virtual DTC::RecordedMarkupInfo* GetRecordedMarkupInfo    ( int              ChanId,
     86                                                                 const QDateTime &StartTime  ) = 0;
     87
    8388        virtual DTC::ProgramList*  GetConflictList       ( int              StartIndex,
    8489                                                           int              Count      ) = 0;
    8590
  • mythtv/programs/mythbackend/services/dvr.cpp

    diff --git a/mythtv/programs/mythbackend/services/dvr.cpp b/mythtv/programs/mythbackend/services/dvr.cpp
    index 8d0bc5d..3ecf3ab 100644
    a b  
    204204//
    205205/////////////////////////////////////////////////////////////////////////////
    206206
     207DTC::RecordedMarkupInfo* Dvr::GetRecordedMarkupInfo    ( int              ChanId,
     208                                                            const QDateTime &StartTime  )
     209{
     210    if (ChanId <= 0 || !StartTime.isValid())
     211        throw QString("Channel ID or StartTime appears invalid.");
     212
     213        MSqlQuery query(MSqlQuery::InitCon());
     214
     215        if (!query.isConnected())
     216            throw( QString("Database not open while trying to get "
     217                                "Recording Markups."));
     218    query.prepare("SELECT chanid, starttime, mark, type, data "
     219                      " FROM recordedmarkup "
     220                  " WHERE chanid = :CHANID AND starttime = :STARTTIME "
     221                  " ORDER BY mark, type");
     222
     223    query.bindValue( ":CHANID",     ChanId    );
     224    query.bindValue( ":STARTTIME",  StartTime );
     225
     226    if (!query.exec())
     227        {
     228            MythDB::DBError("MythAPI::GetRecordingMarkups()", query);
     229        throw( QString( "Database Error executing query." ));
     230    }
     231
     232    // ----------------------------------------------------------------------
     233    // return the results of the query
     234    // ----------------------------------------------------------------------
     235
     236    DTC::RecordedMarkupInfo *pRecordedMarkup = new DTC::RecordedMarkupInfo();
     237
     238    DTC::RecordedMarkupItem *pItem  = NULL;
     239        while (query.next())
     240        {
     241        QDateTime dateTime = MythDate::as_utc(query.value(1).toDateTime());
     242        pRecordedMarkup->setChannelId    ( query.value(0).toInt()       );
     243        pRecordedMarkup->setStartTime    ( dateTime    );
     244
     245        switch(query.value(3).toInt())
     246        {
     247            case MARK_COMM_START:
     248                pItem = pRecordedMarkup->AddNewMarkupItem();
     249                pItem->setType(QString("COMMSKIP"));
     250                pItem->setStart(query.value(2).toInt());
     251                break;
     252            case MARK_COMM_END:
     253                if(pItem != NULL)
     254                        pItem->setEnd(query.value(2).toInt());
     255                pItem = NULL;
     256                break;
     257            case MARK_TOTAL_FRAMES:
     258                pRecordedMarkup->setTotalFrames(query.value(4).toInt());
     259                break;
     260            case MARK_DURATION_MS:
     261                pRecordedMarkup->setDurationMs(query.value(4).toInt());
     262                break;
     263            case MARK_VIDEO_RATE:
     264                pRecordedMarkup->setVideoRate(query.value(4).toInt());
     265                break;
     266            case MARK_VIDEO_WIDTH:
     267                pRecordedMarkup->setVideoWidth(query.value(4).toInt());
     268                break;
     269            case MARK_VIDEO_HEIGHT:
     270                pRecordedMarkup->setVideoHeight(query.value(4).toInt());
     271                break;
     272            default:
     273                break;
     274        }
     275        }
     276        return pRecordedMarkup;
     277}
     278
     279/////////////////////////////////////////////////////////////////////////////
     280//
     281/////////////////////////////////////////////////////////////////////////////
     282
    207283DTC::ProgramList* Dvr::GetExpiringList( int nStartIndex,
    208284                                        int nCount      )
    209285{
  • mythtv/programs/mythbackend/services/dvr.h

    diff --git a/mythtv/programs/mythbackend/services/dvr.h b/mythtv/programs/mythbackend/services/dvr.h
    index 42a172b..a84afbd 100644
    a b  
    6060        bool              RemoveRecorded      ( int              ChanId,
    6161                                                const QDateTime &StartTime  );
    6262
     63        DTC::RecordedMarkupInfo* GetRecordedMarkupInfo    ( int              ChanId,
     64                                                            const QDateTime &StartTime  );
     65
    6366        DTC::ProgramList* GetConflictList     ( int              StartIndex,
    6467                                                int              Count      );
    6568