videoplayerapp/videoplayerengine/src/videoservices.cpp
changeset 36 8aed59de29f9
parent 30 4f111d64a341
child 20 b9e04db066d4
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    13 *
    13 *
    14 * Description:  Implementation of VideoServices
    14 * Description:  Implementation of VideoServices
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <videoplayerengine.h>
    18 // Version : %version: %
    19 #include <videoservices.h>
    19 
    20 #include <videoserviceurifetch.h>
    20 #include "videoplayerengine.h"
    21 #include <videoserviceplay.h>
    21 #include "videoservices.h"
       
    22 #include "videoserviceurifetch.h"
       
    23 #include "videoserviceplay.h"
       
    24 #include "videoserviceview.h"
       
    25 #include "videoservicebrowse.h"
       
    26 #include "mpxvideo_debug.h"
    22 
    27 
    23 VideoServices *VideoServices::mInstance = 0;
    28 VideoServices *VideoServices::mInstance = 0;
    24 
    29 
    25 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    26 // VideoServices::instance()
    31 // VideoServices::instance()
    27 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    28 //
    33 //
    29 VideoServices* VideoServices::instance(QVideoPlayerEngine* engine)
    34 VideoServices* VideoServices::instance(QVideoPlayerEngine* engine)
    30 {
    35 {
    31     if(!mInstance)
    36     MPX_ENTER_EXIT(_L("VideoServices::instance()"));
       
    37     
       
    38     if ( ! mInstance )
    32     {
    39     {
    33         mInstance = new VideoServices(engine);
    40         mInstance = new VideoServices(engine);
    34     }
    41     }
    35     else if(engine && !mInstance->engine())
    42     else if ( engine && ! mInstance->engine() )
    36     {
    43     {
    37     	mInstance->setEngine(engine);
    44     	mInstance->setEngine(engine);
    38     }
    45     }
    39     mInstance->mReferenceCount++;
    46     mInstance->mReferenceCount++;
    40     return mInstance;
    47     return mInstance;
    44 // VideoServices::decreaseReferenceCount()
    51 // VideoServices::decreaseReferenceCount()
    45 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    46 //
    53 //
    47 void VideoServices::decreaseReferenceCount()
    54 void VideoServices::decreaseReferenceCount()
    48 {
    55 {
    49     if(mInstance)
    56     MPX_ENTER_EXIT(_L("VideoServices::decreaseReferenceCount()"));
    50     {
    57     
    51         if(--mInstance->mReferenceCount == 0)
    58     if ( mInstance )
       
    59     {
       
    60         if( --mInstance->mReferenceCount == 0 )
    52         {
    61         {
    53             delete mInstance;
    62             delete mInstance;
    54             mInstance = NULL;
    63             mInstance = NULL;
    55         }
    64         }
    56     }
    65     }
    60 // setEngine()
    69 // setEngine()
    61 // ----------------------------------------------------------------------------
    70 // ----------------------------------------------------------------------------
    62 //
    71 //
    63 void VideoServices::setEngine(QVideoPlayerEngine* engine)
    72 void VideoServices::setEngine(QVideoPlayerEngine* engine)
    64 {
    73 {
    65     if (mServicePlay)
    74     MPX_ENTER_EXIT(_L("VideoServices::setEngine()"));
       
    75     
       
    76     if ( mServicePlay )
    66     {
    77     {
    67     	mEngine = engine;
    78     	mEngine = engine;
    68     	mServicePlay->setEngine(engine);
    79     	mServicePlay->setEngine(engine);
    69     }
    80     }
       
    81     
       
    82     if ( mServiceView )
       
    83     {
       
    84     	mEngine = engine;
       
    85     	mServiceView->setEngine(engine);    	
       
    86     }
       
    87     		
    70 }
    88 }
    71 
    89 
    72 // ----------------------------------------------------------------------------
    90 // ----------------------------------------------------------------------------
    73 // engine()
    91 // engine()
    74 // ----------------------------------------------------------------------------
    92 // ----------------------------------------------------------------------------
    75 //
    93 //
    76 QVideoPlayerEngine* VideoServices::engine()
    94 QVideoPlayerEngine* VideoServices::engine()
    77 {
    95 {
       
    96     MPX_DEBUG(_L("VideoServices::engine"));
       
    97 	
    78 	return mEngine;
    98 	return mEngine;
    79 }
    99 }
    80 
   100 
    81 // ----------------------------------------------------------------------------
   101 // ----------------------------------------------------------------------------
    82 // VideoServices()
   102 // VideoServices()
    83 // ----------------------------------------------------------------------------
   103 // ----------------------------------------------------------------------------
    84 //
   104 //
    85 VideoServices::VideoServices(QVideoPlayerEngine* engine) :
   105 VideoServices::VideoServices( QVideoPlayerEngine* engine ) 
    86 mReferenceCount(0),
   106     : mReferenceCount( 0 )
    87 mEngine(engine),
   107     , mEngine( engine )
    88 mCurrentService(VideoServices::ENoService)
   108     , mCurrentService( VideoServices::ENoService )
    89 {
   109 {
       
   110     MPX_ENTER_EXIT(_L("VideoServices::VideoServices()"));
       
   111     
    90     mServiceUriFetch = new VideoServiceUriFetch(this);
   112     mServiceUriFetch = new VideoServiceUriFetch(this);
    91 	mServicePlay     = new VideoServicePlay(this, engine);
   113 	mServicePlay     = new VideoServicePlay(this, engine);
       
   114 	mServiceView     = new VideoServiceView(this, engine);
       
   115 	mServiceBrowse   = new VideoServiceBrowse(this);
    92 }
   116 }
    93 
   117 
    94 // ----------------------------------------------------------------------------
   118 // ----------------------------------------------------------------------------
    95 // ~VideoServices()
   119 // ~VideoServices()
    96 // ----------------------------------------------------------------------------
   120 // ----------------------------------------------------------------------------
    97 //
   121 //
    98 VideoServices::~VideoServices()
   122 VideoServices::~VideoServices()
    99 {
   123 {
       
   124     MPX_ENTER_EXIT(_L("VideoServices::~VideoServices()"));
       
   125     
   100 	delete mServiceUriFetch;
   126 	delete mServiceUriFetch;
   101 	delete mServicePlay;
   127 	delete mServicePlay;
       
   128 	delete mServiceView;
       
   129 	delete mServiceBrowse;
   102 }
   130 }
   103 
   131 
   104 // ----------------------------------------------------------------------------
   132 // ----------------------------------------------------------------------------
   105 // currentService()
   133 // currentService()
   106 // ----------------------------------------------------------------------------
   134 // ----------------------------------------------------------------------------
   107 //
   135 //
   108 VideoServices::TVideoService VideoServices::currentService()
   136 VideoServices::TVideoService VideoServices::currentService()
   109 {
   137 {
       
   138     MPX_DEBUG(_L("VideoServices::currentService() ret %d"), mCurrentService );
       
   139 	
   110 	return mCurrentService;
   140 	return mCurrentService;
   111 }
   141 }
   112 
   142 
   113 // ----------------------------------------------------------------------------
   143 // ----------------------------------------------------------------------------
       
   144 // getBrowseCategory()
       
   145 // ----------------------------------------------------------------------------
       
   146 //
       
   147 int VideoServices::getBrowseCategory() const
       
   148 {
       
   149     MPX_DEBUG(_L("VideoServices::getBrowseCategory()"));
       
   150 	
       
   151     int category = 0;
       
   152     
       
   153     if ( mServiceBrowse )
       
   154     {
       
   155         category = mServiceBrowse->getBrowseCategory();
       
   156     }
       
   157     
       
   158     return category;
       
   159 }
       
   160 
       
   161 // ----------------------------------------------------------------------------
   114 // setCurrentService()
   162 // setCurrentService()
   115 // ----------------------------------------------------------------------------
   163 // ----------------------------------------------------------------------------
   116 //
   164 //
   117 void VideoServices::setCurrentService(VideoServices::TVideoService service)
   165 void VideoServices::setCurrentService(VideoServices::TVideoService service)
   118 {
   166 {
   119 	mCurrentService = service;
   167     MPX_DEBUG(_L("VideoServices::setCurrentService(%d)"), service );
   120 }
   168 	
       
   169 	mCurrentService = service;	
       
   170 }
       
   171 
   121 // ----------------------------------------------------------------------------
   172 // ----------------------------------------------------------------------------
   122 // contextTitle()
   173 // contextTitle()
   123 // ----------------------------------------------------------------------------
   174 // ----------------------------------------------------------------------------
   124 //
   175 //
   125 QString VideoServices::contextTitle() const
   176 QString VideoServices::contextTitle() const
   126 {
   177 {
   127     return mServiceUriFetch->contextTitle();
   178     MPX_DEBUG(_L("VideoServices::contextTitle()") );
       
   179 	
       
   180     QString title;
       
   181     
       
   182     if ( mCurrentService == VideoServices::EUriFetcher )
       
   183     {
       
   184         title = mServiceUriFetch->contextTitle();
       
   185     }
       
   186     else if ( mCurrentService == VideoServices::EBrowse )
       
   187     {
       
   188         title = mServiceBrowse->contextTitle();
       
   189     }
       
   190     
       
   191     return title;
   128 }
   192 }
   129 
   193 
   130 // ----------------------------------------------------------------------------
   194 // ----------------------------------------------------------------------------
   131 // itemSelected()
   195 // itemSelected()
   132 // ----------------------------------------------------------------------------
   196 // ----------------------------------------------------------------------------
   133 //
   197 //
   134 void VideoServices::itemSelected(const QString& item)
   198 void VideoServices::itemSelected(const QString& item)
   135 {
   199 {
       
   200     MPX_ENTER_EXIT(_L("VideoServices::itemSelected()"),
       
   201                    _L("item = %s"), item.data() );
       
   202     
   136     QStringList list;
   203     QStringList list;
   137     list.append(item);
   204     list.append( item );
   138     mServiceUriFetch->complete(list);
   205     mServiceUriFetch->complete( list );
   139 }
   206 }
   140 
   207 
       
   208 // ----------------------------------------------------------------------------
       
   209 // browsingEnded()
       
   210 // ----------------------------------------------------------------------------
       
   211 //
       
   212 void VideoServices::browsingEnded()
       
   213 {
       
   214     MPX_ENTER_EXIT(_L("VideoServices::browsingEnded()"));
       
   215 	
       
   216     if ( mServiceBrowse )
       
   217     {
       
   218         mServiceBrowse->complete();
       
   219     }
       
   220 }
       
   221 
       
   222 // End of file