|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of VideoServices |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <videoplayerengine.h> |
|
19 #include <videoservices.h> |
|
20 #include <videoserviceurifetch.h> |
|
21 #include <videoserviceplay.h> |
|
22 |
|
23 VideoServices *VideoServices::mInstance = 0; |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // VideoServices::instance() |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 VideoServices* VideoServices::instance(QVideoPlayerEngine* engine) |
|
30 { |
|
31 if(!mInstance) |
|
32 { |
|
33 mInstance = new VideoServices(engine); |
|
34 } |
|
35 else if(engine && !mInstance->engine()) |
|
36 { |
|
37 mInstance->setEngine(engine); |
|
38 } |
|
39 mInstance->mReferenceCount++; |
|
40 return mInstance; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // VideoServices::decreaseReferenceCount() |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void VideoServices::decreaseReferenceCount() |
|
48 { |
|
49 if(mInstance) |
|
50 { |
|
51 if(--mInstance->mReferenceCount == 0) |
|
52 { |
|
53 delete mInstance; |
|
54 mInstance = NULL; |
|
55 } |
|
56 } |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // setEngine() |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 void VideoServices::setEngine(QVideoPlayerEngine* engine) |
|
64 { |
|
65 if (mServicePlay) |
|
66 { |
|
67 mEngine = engine; |
|
68 mServicePlay->setEngine(engine); |
|
69 } |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // engine() |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 QVideoPlayerEngine* VideoServices::engine() |
|
77 { |
|
78 return mEngine; |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // VideoServices() |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 VideoServices::VideoServices(QVideoPlayerEngine* engine) : |
|
86 mReferenceCount(0), |
|
87 mEngine(engine), |
|
88 mCurrentService(VideoServices::ENoService) |
|
89 { |
|
90 mServiceUriFetch = new VideoServiceUriFetch(this); |
|
91 mServicePlay = new VideoServicePlay(this, engine); |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // ~VideoServices() |
|
96 // ---------------------------------------------------------------------------- |
|
97 // |
|
98 VideoServices::~VideoServices() |
|
99 { |
|
100 delete mServiceUriFetch; |
|
101 delete mServicePlay; |
|
102 } |
|
103 |
|
104 // ---------------------------------------------------------------------------- |
|
105 // currentService() |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 VideoServices::TVideoService VideoServices::currentService() |
|
109 { |
|
110 return mCurrentService; |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // setCurrentService() |
|
115 // ---------------------------------------------------------------------------- |
|
116 // |
|
117 void VideoServices::setCurrentService(VideoServices::TVideoService service) |
|
118 { |
|
119 mCurrentService = service; |
|
120 } |
|
121 // ---------------------------------------------------------------------------- |
|
122 // contextTitle() |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 QString VideoServices::contextTitle() const |
|
126 { |
|
127 return mServiceUriFetch->contextTitle(); |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // itemSelected() |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 void VideoServices::itemSelected(const QString& item) |
|
135 { |
|
136 QStringList list; |
|
137 list.append(item); |
|
138 mServiceUriFetch->complete(list); |
|
139 } |
|
140 |