author | Sampo Huttunen <sampo.huttunen@nokia.com> |
Wed, 03 Nov 2010 11:45:09 +0200 | |
branch | IOP_Improvements |
changeset 40 | 08b5eae9f9ff |
permissions | -rw-r--r-- |
40
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
1 |
/* |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2007,2009 Nokia Corporation and/or its subsidiary(-ies). |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
8 |
* |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
11 |
* |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
13 |
* |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Implementation of playback time for rendering state machine |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
15 |
* |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
17 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
18 |
// INCLUDES |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
19 |
#include "upnprenderingplaytimecalculator.h" |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
20 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
21 |
_LIT( KComponentLogfile, "upnprenderingstatemachine.txt"); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
22 |
#include "upnplog.h" |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
23 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
24 |
// CONSTANTS |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
25 |
const TInt KMicrosecondsInMillisecond = 1000; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
26 |
const TInt KMillisecondsInSecond = 1000; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
27 |
const TInt KDurationErrorMargin = 3000; // 3 seconds |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
28 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
29 |
// ======== MEMBER FUNCTIONS ======== |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
30 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
31 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
32 |
// CUpnpRenderingPlaytimeCalculator::CUpnpRenderingPlaytimeCalculator |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
33 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
34 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
35 |
CUpnpRenderingPlaytimeCalculator::CUpnpRenderingPlaytimeCalculator() |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
36 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
37 |
iPlaying = EFalse; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
38 |
iPaused = EFalse; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
39 |
iStartMark = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
40 |
iStopMark = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
41 |
iPauseMark = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
42 |
iPauseTime = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
43 |
iOffset = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
44 |
iDuration = KErrNotFound; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
45 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
46 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
47 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
48 |
// CUpnpRenderingPlaytimeCalculator::Start |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
49 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
50 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
51 |
void CUpnpRenderingPlaytimeCalculator::Start() |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
52 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
53 |
__LOG("PlaytimeCalculator: Start()" ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
54 |
iStartMark.UniversalTime(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
55 |
iPauseTime = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
56 |
iPlaying = ETrue; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
57 |
iPaused = EFalse; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
58 |
iOffset = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
59 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
60 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
61 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
62 |
// CUpnpRenderingPlaytimeCalculator::Pause |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
63 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
64 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
65 |
void CUpnpRenderingPlaytimeCalculator::Pause() |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
66 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
67 |
__LOG("PlaytimeCalculator: Pause()" ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
68 |
if( !iPaused ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
69 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
70 |
iPauseMark.UniversalTime(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
71 |
iPaused = ETrue; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
72 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
73 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
74 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
75 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
76 |
// CUpnpRenderingPlaytimeCalculator::Resume |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
77 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
78 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
79 |
void CUpnpRenderingPlaytimeCalculator::Resume() |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
80 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
81 |
__LOG("PlaytimeCalculator: Resume()" ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
82 |
TTime resumeMark; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
83 |
resumeMark.UniversalTime(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
84 |
iPauseTime += PausetimeAt( resumeMark ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
85 |
iPaused = EFalse; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
86 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
87 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
88 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
89 |
// CUpnpRenderingPlaytimeCalculator::Stop |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
90 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
91 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
92 |
void CUpnpRenderingPlaytimeCalculator::Stop() |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
93 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
94 |
__LOG("PlaytimeCalculator: Stop()" ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
95 |
iStopMark.UniversalTime(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
96 |
iPlaying = EFalse; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
97 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
98 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
99 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
100 |
// CUpnpRenderingPlaytimeCalculator::SetDuration |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
101 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
102 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
103 |
void CUpnpRenderingPlaytimeCalculator::SetDuration( TInt aDuration ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
104 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
105 |
iDuration = aDuration; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
106 |
__LOG1("PlaytimeCalculator:SetDuration iDuration %d", iDuration ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
107 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
108 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
109 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
110 |
// CUpnpRenderingPlaytimeCalculator::Duration |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
111 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
112 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
113 |
TInt CUpnpRenderingPlaytimeCalculator::Duration() const |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
114 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
115 |
__LOG1("PlaytimeCalculator: iDuration %d", iDuration ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
116 |
return iDuration; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
117 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
118 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
119 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
120 |
// CUpnpRenderingPlaytimeCalculator::AcknowledgePositionInfo |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
121 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
122 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
123 |
void CUpnpRenderingPlaytimeCalculator::AcknowledgePositionInfo( |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
124 |
TInt aDuration, TInt aPosition ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
125 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
126 |
__LOG3("PlaytimeCalculator::AcknowledgePositionInfo \ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
127 |
aDuration %d aPosition %d, iPlaying %d ", |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
128 |
aDuration, aPosition, iPlaying ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
129 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
130 |
// handle DURATION |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
131 |
if ( aDuration > 0 ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
132 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
133 |
if ( iDuration <= 0) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
134 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
135 |
// we did not know duration before, set it |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
136 |
iDuration = aDuration; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
137 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
138 |
else if ( aDuration > iDuration ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
139 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
140 |
// renderer thinks track is longer. trust longer value! |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
141 |
// too long is more safe than too short. |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
142 |
// TOO LONG -> playlist play may discontinue. (annoying) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
143 |
// TOO SHORT -> pressing stop may cause track skip and |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
144 |
// user can't stop the music (critical) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
145 |
iDuration = aDuration; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
146 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
147 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
148 |
// handle POSITION |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
149 |
if ( iPlaying ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
150 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
151 |
// calculate playtime now, compare to given position |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
152 |
// and manipulate offset accordingly |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
153 |
iOffset = OffsetFromNow( aPosition ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
154 |
__LOG1("PlaytimeCalculator: New Offset %d", iOffset ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
155 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
156 |
else |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
157 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
158 |
// start timer and set position according to ongoing playback |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
159 |
Start(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
160 |
TTimeIntervalSeconds origPos = aPosition / KMillisecondsInSecond; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
161 |
iStartMark -= origPos; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
162 |
iOffset = OffsetFromNow( aPosition ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
163 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
164 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
165 |
__LOG2("PlaytimeCalculator::AcknowledgePositionInfo \ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
166 |
iDuration %d Current Position %d ", iDuration, Position() ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
167 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
168 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
169 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
170 |
// CUpnpRenderingPlaytimeCalculator::Position |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
171 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
172 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
173 |
TInt CUpnpRenderingPlaytimeCalculator::Position() const |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
174 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
175 |
TTime tempTime; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
176 |
if ( iPlaying ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
177 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
178 |
__LOG("PlaytimeCalculator: Position() - using current time" ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
179 |
// measure time until NOW. |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
180 |
tempTime.UniversalTime(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
181 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
182 |
else |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
183 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
184 |
// measure time until last track STOPPED. |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
185 |
tempTime = iStopMark; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
186 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
187 |
return PositionAt( tempTime ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
188 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
189 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
190 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
191 |
// CUpnpRenderingPlaytimeCalculator::IsTrackComplete |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
192 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
193 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
194 |
TBool CUpnpRenderingPlaytimeCalculator::IsTrackComplete() const |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
195 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
196 |
TBool isCompleted = ETrue; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
197 |
TInt playtime = Position(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
198 |
if ( playtime >= 0 && |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
199 |
playtime < iDuration - KDurationErrorMargin ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
200 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
201 |
// [0 - duration-margin] |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
202 |
isCompleted= EFalse; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
203 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
204 |
else if ( playtime >= iDuration - KDurationErrorMargin && |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
205 |
playtime <= iDuration + KDurationErrorMargin ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
206 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
207 |
// [duration-margin - duration+margin] |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
208 |
isCompleted= ETrue; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
209 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
210 |
else |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
211 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
212 |
// position either negative or greater than duration ?? |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
213 |
__LOG2("PlaytimeCalculator: WARNING: playtime=%d duration=%d", |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
214 |
playtime, |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
215 |
iDuration ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
216 |
isCompleted= ETrue; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
217 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
218 |
return isCompleted; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
219 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
220 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
221 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
222 |
// CUpnpRenderingPlaytimeCalculator::IsPlaying |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
223 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
224 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
225 |
TBool CUpnpRenderingPlaytimeCalculator::IsPlaying() const |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
226 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
227 |
return iPlaying; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
228 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
229 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
230 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
231 |
// CUpnpRenderingPlaytimeCalculator::RestartAt |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
232 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
233 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
234 |
void CUpnpRenderingPlaytimeCalculator::RestartAt( TInt aNewPosition ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
235 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
236 |
__LOG("PlaytimeCalculator: RestartAt()" ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
237 |
Stop(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
238 |
Start(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
239 |
// Consider new position to be equivalent to current position |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
240 |
TTimeIntervalSeconds newPos = |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
241 |
aNewPosition / KMillisecondsInSecond; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
242 |
iStartMark -= newPos; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
243 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
244 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
245 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
246 |
// CUpnpRenderingPlaytimeCalculator::PositionAt |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
247 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
248 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
249 |
TInt CUpnpRenderingPlaytimeCalculator::PositionAt( TTime& aMark ) const |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
250 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
251 |
TTimeIntervalMicroSeconds played = |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
252 |
aMark.MicroSecondsFrom( iStartMark ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
253 |
TInt playtime = ( played.Int64() / KMicrosecondsInMillisecond ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
254 |
__LOG1("PlaytimeCalculator: PositionAt played %d", playtime ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
255 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
256 |
playtime -= iPauseTime; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
257 |
playtime -= PausetimeAt( aMark ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
258 |
playtime += iOffset; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
259 |
__LOG3("PlaytimeCalculator: playtime=%d pausetime=%d offset=%d", |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
260 |
playtime, |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
261 |
(iPauseTime + PausetimeAt( aMark )), |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
262 |
iOffset ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
263 |
return playtime; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
264 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
265 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
266 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
267 |
// CUpnpRenderingPlaytimeCalculator::PausetimeAt |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
268 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
269 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
270 |
TInt CUpnpRenderingPlaytimeCalculator::PausetimeAt( TTime& aMark ) const |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
271 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
272 |
TInt pausetime = 0; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
273 |
if ( iPaused ) |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
274 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
275 |
TTimeIntervalMicroSeconds latestPause = |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
276 |
aMark.MicroSecondsFrom( iPauseMark ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
277 |
pausetime = ( latestPause.Int64() / KMicrosecondsInMillisecond ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
278 |
__LOG1("PlaytimeCalculator: PausetimeAt pause time %d", pausetime ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
279 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
280 |
return pausetime; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
281 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
282 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
283 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
284 |
// CUpnpRenderingPlaytimeCalculator::OffsetFromNow |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
285 |
// -------------------------------------------------------------------------- |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
286 |
// |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
287 |
TInt CUpnpRenderingPlaytimeCalculator::OffsetFromNow( TInt aPosition ) const |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
288 |
{ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
289 |
TTime timeNow; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
290 |
timeNow.UniversalTime(); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
291 |
TInt tempPlaytime = PositionAt( timeNow ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
292 |
TInt o = aPosition - tempPlaytime; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
293 |
__LOG2("PlaytimeCalculator: renderer position (%d), \ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
294 |
tempPlaytime (%d)", aPosition, tempPlaytime ); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
295 |
__LOG3("PlaytimeCalculator: old off(%d) current off(%d), \ |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
296 |
new offset(%d)", iOffset, o, iOffset+o); |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
297 |
return iOffset+o; |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
298 |
} |
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
299 |
|
08b5eae9f9ff
merge from Nokia's internal development branch
Sampo Huttunen <sampo.huttunen@nokia.com>
parents:
diff
changeset
|
300 |
// end of file |