1 /* |
|
2 * Copyright (c) 2010 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: QT Bindings for TMS |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <qtms.h> |
|
19 #include <tmsbuffer.h> |
|
20 #include "tmsutility.h" |
|
21 #include "qtmsmembuffer.h" |
|
22 |
|
23 using namespace QTMS; |
|
24 using namespace TMS; |
|
25 |
|
26 QTMSMemBuffer::QTMSMemBuffer() |
|
27 { |
|
28 iTmsBuffer = NULL; |
|
29 iOwnsBuffer = FALSE; |
|
30 } |
|
31 |
|
32 QTMSMemBuffer::~QTMSMemBuffer() |
|
33 { |
|
34 if (iOwnsBuffer) { |
|
35 free(iDataPtr); |
|
36 } |
|
37 } |
|
38 |
|
39 gint QTMSMemBuffer::Create(QTMSBuffer*& buffer, TMS::TMSBuffer*& tmsbuffer) |
|
40 { |
|
41 gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY); |
|
42 TRACE_PRN_FN_ENT; |
|
43 QTMSMemBuffer* self = new QTMSMemBuffer(); |
|
44 if (self) { |
|
45 self->iTmsBuffer = tmsbuffer; |
|
46 tmsbuffer->GetDataPtr(self->iDataPtr); |
|
47 tmsbuffer->GetDataSize(self->iBufferSize); |
|
48 tmsbuffer->GetTimeStamp(self->iTimeStamp); |
|
49 self->iOwnsBuffer = FALSE; |
|
50 ret = QTMS_RESULT_SUCCESS; |
|
51 } |
|
52 buffer = self; |
|
53 TRACE_PRN_FN_EXT; |
|
54 return ret; |
|
55 } |
|
56 |
|
57 gint QTMSMemBuffer::GetType(QTMSBufferType& buffertype) |
|
58 { |
|
59 gint ret(TMS_RESULT_SUCCESS); |
|
60 buffertype = QTMS_BUFFER_MEMORY; |
|
61 return ret; |
|
62 } |
|
63 |
|
64 /** |
|
65 * Gets the timestamp on the Buffer so that the framework can |
|
66 * determine the time at which this buffer has to be rendered |
|
67 * by the output device sink. |
|
68 * |
|
69 * @param ts timestamp in microseconds |
|
70 * |
|
71 */ |
|
72 gint QTMSMemBuffer::GetTimeStamp(guint64& ts) |
|
73 { |
|
74 gint ret(QTMS_RESULT_SUCCESS); |
|
75 ts = iTimeStamp; |
|
76 return ret; |
|
77 } |
|
78 |
|
79 /** |
|
80 * Sets the timestamp on the Buffer so that the framework can |
|
81 * determine the time at which this buffer has to be rendered |
|
82 * by the output device sink. |
|
83 * |
|
84 * @param ts timestamp in milliseconds |
|
85 * |
|
86 */ |
|
87 gint QTMSMemBuffer::SetTimeStamp(const guint64 ts) |
|
88 { |
|
89 gint ret(QTMS_RESULT_SUCCESS); |
|
90 iTimeStamp = ts; |
|
91 ret = iTmsBuffer->SetTimeStamp(ts); |
|
92 return ret; |
|
93 } |
|
94 |
|
95 /** |
|
96 * Gets the size of data in the buffer specified by the client. |
|
97 * |
|
98 * @param size size of data in bytes |
|
99 * |
|
100 */ |
|
101 gint QTMSMemBuffer::GetDataSize(guint& size) |
|
102 { |
|
103 gint ret(QTMS_RESULT_SUCCESS); |
|
104 size = iBufferSize; |
|
105 return ret; |
|
106 } |
|
107 |
|
108 /** |
|
109 * Sets the size of data in the buffer after the client fill it. |
|
110 * |
|
111 * @param size size of data in bytes |
|
112 * |
|
113 */ |
|
114 gint QTMSMemBuffer::SetDataSize(const guint size) |
|
115 { |
|
116 gint ret(QTMS_RESULT_SUCCESS); |
|
117 ret = iTmsBuffer->SetDataSize(size); |
|
118 iBufferSize = size; //TODO: should realloc when new size > old size (?) |
|
119 return ret; |
|
120 } |
|
121 |
|
122 /** |
|
123 * Gets the pointer to the memory location associated with this |
|
124 * buffer where the data is stored. |
|
125 * |
|
126 * @param bufptr ptr to the data stored in the buffer. |
|
127 * |
|
128 */ |
|
129 gint QTMSMemBuffer::GetDataPtr(guint8*& bufptr) |
|
130 { |
|
131 gint ret(QTMS_RESULT_SUCCESS); |
|
132 bufptr = iDataPtr; |
|
133 return ret; |
|
134 } |
|
135 |
|