videoplayerapp/videoplayerengine/src/videoservices.cpp
author hgs
Fri, 30 Apr 2010 09:52:11 +0300
changeset 37 4eb2df7f7cbe
parent 36 8aed59de29f9
child 24 7d93ee07fb27
permissions -rw-r--r--
201017
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  Implementation of VideoServices
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
37
hgs
parents: 36
diff changeset
    18
// Version : %version: 6 %
36
hgs
parents: 30
diff changeset
    19
hgs
parents: 30
diff changeset
    20
#include "videoplayerengine.h"
hgs
parents: 30
diff changeset
    21
#include "videoservices.h"
hgs
parents: 30
diff changeset
    22
#include "videoserviceurifetch.h"
hgs
parents: 30
diff changeset
    23
#include "videoserviceplay.h"
hgs
parents: 30
diff changeset
    24
#include "videoserviceview.h"
hgs
parents: 30
diff changeset
    25
#include "videoservicebrowse.h"
hgs
parents: 30
diff changeset
    26
#include "mpxvideo_debug.h"
30
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
VideoServices *VideoServices::mInstance = 0;
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    31
// VideoServices::instance()
hgs
parents:
diff changeset
    32
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    33
//
hgs
parents:
diff changeset
    34
VideoServices* VideoServices::instance(QVideoPlayerEngine* engine)
hgs
parents:
diff changeset
    35
{
36
hgs
parents: 30
diff changeset
    36
    MPX_ENTER_EXIT(_L("VideoServices::instance()"));
hgs
parents: 30
diff changeset
    37
    
hgs
parents: 30
diff changeset
    38
    if ( ! mInstance )
30
hgs
parents:
diff changeset
    39
    {
hgs
parents:
diff changeset
    40
        mInstance = new VideoServices(engine);
hgs
parents:
diff changeset
    41
    }
36
hgs
parents: 30
diff changeset
    42
    else if ( engine && ! mInstance->engine() )
30
hgs
parents:
diff changeset
    43
    {
hgs
parents:
diff changeset
    44
    	mInstance->setEngine(engine);
hgs
parents:
diff changeset
    45
    }
37
hgs
parents: 36
diff changeset
    46
30
hgs
parents:
diff changeset
    47
    mInstance->mReferenceCount++;
hgs
parents:
diff changeset
    48
    return mInstance;
hgs
parents:
diff changeset
    49
}
hgs
parents:
diff changeset
    50
hgs
parents:
diff changeset
    51
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    52
// VideoServices::decreaseReferenceCount()
hgs
parents:
diff changeset
    53
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    54
//
hgs
parents:
diff changeset
    55
void VideoServices::decreaseReferenceCount()
hgs
parents:
diff changeset
    56
{
36
hgs
parents: 30
diff changeset
    57
    MPX_ENTER_EXIT(_L("VideoServices::decreaseReferenceCount()"));
hgs
parents: 30
diff changeset
    58
    
hgs
parents: 30
diff changeset
    59
    if ( mInstance )
30
hgs
parents:
diff changeset
    60
    {
36
hgs
parents: 30
diff changeset
    61
        if( --mInstance->mReferenceCount == 0 )
30
hgs
parents:
diff changeset
    62
        {
hgs
parents:
diff changeset
    63
            delete mInstance;
hgs
parents:
diff changeset
    64
            mInstance = NULL;
hgs
parents:
diff changeset
    65
        }
hgs
parents:
diff changeset
    66
    }
hgs
parents:
diff changeset
    67
}
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    70
// setEngine()
hgs
parents:
diff changeset
    71
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    72
//
hgs
parents:
diff changeset
    73
void VideoServices::setEngine(QVideoPlayerEngine* engine)
hgs
parents:
diff changeset
    74
{
36
hgs
parents: 30
diff changeset
    75
    MPX_ENTER_EXIT(_L("VideoServices::setEngine()"));
hgs
parents: 30
diff changeset
    76
    
hgs
parents: 30
diff changeset
    77
    if ( mServicePlay )
30
hgs
parents:
diff changeset
    78
    {
hgs
parents:
diff changeset
    79
    	mEngine = engine;
hgs
parents:
diff changeset
    80
    	mServicePlay->setEngine(engine);
hgs
parents:
diff changeset
    81
    }
36
hgs
parents: 30
diff changeset
    82
    
hgs
parents: 30
diff changeset
    83
    if ( mServiceView )
hgs
parents: 30
diff changeset
    84
    {
hgs
parents: 30
diff changeset
    85
    	mEngine = engine;
hgs
parents: 30
diff changeset
    86
    	mServiceView->setEngine(engine);    	
hgs
parents: 30
diff changeset
    87
    }
hgs
parents: 30
diff changeset
    88
    		
30
hgs
parents:
diff changeset
    89
}
hgs
parents:
diff changeset
    90
hgs
parents:
diff changeset
    91
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    92
// engine()
hgs
parents:
diff changeset
    93
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    94
//
hgs
parents:
diff changeset
    95
QVideoPlayerEngine* VideoServices::engine()
hgs
parents:
diff changeset
    96
{
36
hgs
parents: 30
diff changeset
    97
    MPX_DEBUG(_L("VideoServices::engine"));
hgs
parents: 30
diff changeset
    98
	
37
hgs
parents: 36
diff changeset
    99
    return mEngine;
30
hgs
parents:
diff changeset
   100
}
hgs
parents:
diff changeset
   101
hgs
parents:
diff changeset
   102
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   103
// VideoServices()
hgs
parents:
diff changeset
   104
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   105
//
36
hgs
parents: 30
diff changeset
   106
VideoServices::VideoServices( QVideoPlayerEngine* engine ) 
hgs
parents: 30
diff changeset
   107
    : mReferenceCount( 0 )
hgs
parents: 30
diff changeset
   108
    , mEngine( engine )
hgs
parents: 30
diff changeset
   109
    , mCurrentService( VideoServices::ENoService )
37
hgs
parents: 36
diff changeset
   110
    , mFetchSelected( false )
30
hgs
parents:
diff changeset
   111
{
36
hgs
parents: 30
diff changeset
   112
    MPX_ENTER_EXIT(_L("VideoServices::VideoServices()"));
hgs
parents: 30
diff changeset
   113
    
30
hgs
parents:
diff changeset
   114
    mServiceUriFetch = new VideoServiceUriFetch(this);
37
hgs
parents: 36
diff changeset
   115
    mServicePlay     = new VideoServicePlay(this, engine);
hgs
parents: 36
diff changeset
   116
    mServiceView     = new VideoServiceView(this, engine);
hgs
parents: 36
diff changeset
   117
    mServiceBrowse   = new VideoServiceBrowse(this);
30
hgs
parents:
diff changeset
   118
}
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   121
// ~VideoServices()
hgs
parents:
diff changeset
   122
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   123
//
hgs
parents:
diff changeset
   124
VideoServices::~VideoServices()
hgs
parents:
diff changeset
   125
{
36
hgs
parents: 30
diff changeset
   126
    MPX_ENTER_EXIT(_L("VideoServices::~VideoServices()"));
hgs
parents: 30
diff changeset
   127
    
37
hgs
parents: 36
diff changeset
   128
    delete mServiceUriFetch;
hgs
parents: 36
diff changeset
   129
    delete mServicePlay;
hgs
parents: 36
diff changeset
   130
    delete mServiceView;
hgs
parents: 36
diff changeset
   131
    delete mServiceBrowse;
30
hgs
parents:
diff changeset
   132
}
hgs
parents:
diff changeset
   133
hgs
parents:
diff changeset
   134
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   135
// currentService()
hgs
parents:
diff changeset
   136
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   137
//
hgs
parents:
diff changeset
   138
VideoServices::TVideoService VideoServices::currentService()
hgs
parents:
diff changeset
   139
{
36
hgs
parents: 30
diff changeset
   140
    MPX_DEBUG(_L("VideoServices::currentService() ret %d"), mCurrentService );
hgs
parents: 30
diff changeset
   141
	
37
hgs
parents: 36
diff changeset
   142
    return mCurrentService;
30
hgs
parents:
diff changeset
   143
}
hgs
parents:
diff changeset
   144
hgs
parents:
diff changeset
   145
// ----------------------------------------------------------------------------
36
hgs
parents: 30
diff changeset
   146
// getBrowseCategory()
hgs
parents: 30
diff changeset
   147
// ----------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   148
//
hgs
parents: 30
diff changeset
   149
int VideoServices::getBrowseCategory() const
hgs
parents: 30
diff changeset
   150
{
hgs
parents: 30
diff changeset
   151
    MPX_DEBUG(_L("VideoServices::getBrowseCategory()"));
hgs
parents: 30
diff changeset
   152
	
hgs
parents: 30
diff changeset
   153
    int category = 0;
hgs
parents: 30
diff changeset
   154
    
hgs
parents: 30
diff changeset
   155
    if ( mServiceBrowse )
hgs
parents: 30
diff changeset
   156
    {
hgs
parents: 30
diff changeset
   157
        category = mServiceBrowse->getBrowseCategory();
hgs
parents: 30
diff changeset
   158
    }
hgs
parents: 30
diff changeset
   159
    
hgs
parents: 30
diff changeset
   160
    return category;
hgs
parents: 30
diff changeset
   161
}
hgs
parents: 30
diff changeset
   162
hgs
parents: 30
diff changeset
   163
// ----------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   164
// setCurrentService()
hgs
parents:
diff changeset
   165
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   166
//
hgs
parents:
diff changeset
   167
void VideoServices::setCurrentService(VideoServices::TVideoService service)
hgs
parents:
diff changeset
   168
{
36
hgs
parents: 30
diff changeset
   169
    MPX_DEBUG(_L("VideoServices::setCurrentService(%d)"), service );
hgs
parents: 30
diff changeset
   170
	
37
hgs
parents: 36
diff changeset
   171
    mCurrentService = service;	
30
hgs
parents:
diff changeset
   172
}
36
hgs
parents: 30
diff changeset
   173
30
hgs
parents:
diff changeset
   174
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   175
// contextTitle()
hgs
parents:
diff changeset
   176
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   177
//
hgs
parents:
diff changeset
   178
QString VideoServices::contextTitle() const
hgs
parents:
diff changeset
   179
{
36
hgs
parents: 30
diff changeset
   180
    MPX_DEBUG(_L("VideoServices::contextTitle()") );
hgs
parents: 30
diff changeset
   181
	
hgs
parents: 30
diff changeset
   182
    QString title;
hgs
parents: 30
diff changeset
   183
    
37
hgs
parents: 36
diff changeset
   184
    if (mCurrentService == VideoServices::EUriFetcher && mServiceUriFetch)
36
hgs
parents: 30
diff changeset
   185
    {
hgs
parents: 30
diff changeset
   186
        title = mServiceUriFetch->contextTitle();
hgs
parents: 30
diff changeset
   187
    }
37
hgs
parents: 36
diff changeset
   188
    else if (mCurrentService == VideoServices::EBrowse && mServiceBrowse)
36
hgs
parents: 30
diff changeset
   189
    {
hgs
parents: 30
diff changeset
   190
        title = mServiceBrowse->contextTitle();
hgs
parents: 30
diff changeset
   191
    }
hgs
parents: 30
diff changeset
   192
    
hgs
parents: 30
diff changeset
   193
    return title;
30
hgs
parents:
diff changeset
   194
}
hgs
parents:
diff changeset
   195
hgs
parents:
diff changeset
   196
// ----------------------------------------------------------------------------
37
hgs
parents: 36
diff changeset
   197
// sortRole()
hgs
parents: 36
diff changeset
   198
// ----------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   199
//
hgs
parents: 36
diff changeset
   200
int VideoServices::sortRole() const
hgs
parents: 36
diff changeset
   201
{
hgs
parents: 36
diff changeset
   202
    MPX_ENTER_EXIT(_L("VideoServices::sortType()"));
hgs
parents: 36
diff changeset
   203
    
hgs
parents: 36
diff changeset
   204
    int sortRole = 0;
hgs
parents: 36
diff changeset
   205
    
hgs
parents: 36
diff changeset
   206
    if (mCurrentService == EBrowse && mServiceBrowse)
hgs
parents: 36
diff changeset
   207
    {
hgs
parents: 36
diff changeset
   208
        sortRole = mServiceBrowse->sortRole();
hgs
parents: 36
diff changeset
   209
    }
hgs
parents: 36
diff changeset
   210
    
hgs
parents: 36
diff changeset
   211
    return sortRole;
hgs
parents: 36
diff changeset
   212
}
hgs
parents: 36
diff changeset
   213
hgs
parents: 36
diff changeset
   214
// ----------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   215
// itemSelected()
hgs
parents:
diff changeset
   216
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   217
//
hgs
parents:
diff changeset
   218
void VideoServices::itemSelected(const QString& item)
hgs
parents:
diff changeset
   219
{
36
hgs
parents: 30
diff changeset
   220
    MPX_ENTER_EXIT(_L("VideoServices::itemSelected()"),
hgs
parents: 30
diff changeset
   221
                   _L("item = %s"), item.data() );
hgs
parents: 30
diff changeset
   222
    
30
hgs
parents:
diff changeset
   223
    QStringList list;
36
hgs
parents: 30
diff changeset
   224
    list.append( item );
hgs
parents: 30
diff changeset
   225
    mServiceUriFetch->complete( list );
37
hgs
parents: 36
diff changeset
   226
    mFetchSelected = true;
30
hgs
parents:
diff changeset
   227
}
hgs
parents:
diff changeset
   228
36
hgs
parents: 30
diff changeset
   229
// ----------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   230
// browsingEnded()
hgs
parents: 30
diff changeset
   231
// ----------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   232
//
hgs
parents: 30
diff changeset
   233
void VideoServices::browsingEnded()
hgs
parents: 30
diff changeset
   234
{
hgs
parents: 30
diff changeset
   235
    MPX_ENTER_EXIT(_L("VideoServices::browsingEnded()"));
hgs
parents: 30
diff changeset
   236
	
hgs
parents: 30
diff changeset
   237
    if ( mServiceBrowse )
hgs
parents: 30
diff changeset
   238
    {
hgs
parents: 30
diff changeset
   239
        mServiceBrowse->complete();
hgs
parents: 30
diff changeset
   240
    }
hgs
parents: 30
diff changeset
   241
}
hgs
parents: 30
diff changeset
   242
hgs
parents: 30
diff changeset
   243
// End of file